buckyos / cyfs-ts-sdk

BSD 2-Clause "Simplified" License
8 stars 2 forks source link

Add dynamic acl related support #18

Closed lurenpluto closed 1 year ago

lurenpluto commented 1 year ago

We need to add support for the ts-sdk side of this feature https://github.com/buckyos/CYFS/issues/175, mainly including changes related to the cyfs-lib side, involving the following.

weiqiushi commented 1 year ago

@lizhihongTest

lizhihongTest commented 1 year ago

Why cyfs-ts-sdk cyfs.GlobalStatePathAccessItem constructor function can`t set parameter? And cyfs.AccessString not contain Handler type. Currently constructing GlobalStatePathGroupAccess::Handler access is very unfriendly

lizhihongTest commented 1 year ago

@weiqiushi You set cyfs.GlobalStatePathAccessItem constructor private ,If use cyfs-ts-sdk source code ,I can use private constructor ,But if compile code as cyfs_node it will missing private function https://github.com/buckyos/cyfs-ts-sdk/blob/0c7d1d5360bc2e8e0019a5148eab044a07e02c08/src/sdk/cyfs-lib/rmeta/def.ts#L113

weiqiushi commented 1 year ago

@weiqiushi You set cyfs.GlobalStatePathAccessItem constructor private ,If use cyfs-ts-sdk source code ,I can use private constructor ,But if compile code as cyfs_node it will missing private function

https://github.com/buckyos/cyfs-ts-sdk/blob/0c7d1d5360bc2e8e0019a5148eab044a07e02c08/src/sdk/cyfs-lib/rmeta/def.ts#L113

Yes. Unlike the rust language, there is no struct in typescript, only use class to approximate the GlobalStatePathAccessItem struct.

And because class must have a constructor, in order to simulate the behavior of new() and new_group() in rust, a private constructor is used, and the public static functions new() and new_group() are used to construct the GlobalStatePathAccessItem.

In fact, in the rust code, if you construct the GlobalStatePathAccessItem using only new() and new_group(), the written code will be the same as the ts version

lizhihongTest commented 1 year ago

When emit acl handler,It will maybe throw error "convert base58 str failed, str=undefined, Expected String"

Details

[debug],[2023-04-27 17:20:24.658],<>,will emit handler: full_id=acl_acl_smoke-test-dynamic-token, param={"request":{"dec_id":"9tGpLNndR5tyui8DkYBpEz8mFHzjfqkCVmsFusa5roHd","permissions":"r--","req_path":"/QATest","req_query_string":"token=QATest-token","source":{"dec":"9tGpLNndR5tyui8DkYBpEz8mFHzjfqkCVmsFusa5roHd","protocol":"http-bdt","zone":{"device":"5aSixgMHNaHEBwwhu8VhSCSgynDSzzhSmEbh59DgZRsN","zone":"5r4MYfFQWVzRG9i88MgDEbmRtsdugbsCU81LmFE5cWGF","zone_category":"other-zone"}}}}, cyfs_node.js:85892 [error],[2023-04-27 17:20:24.659],<>,convert base58 str failed, str=undefined, Expected String, cyfs_node.js:35424 [error],[2023-04-27 17:20:25.217],<>,Trace: [trace],[2023-04-27 17:20:24.660],<>,convert base58 str failed, str=undefined, Expected String, cyfs_node.js:35425 at BLogConsoleTarget.output (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\node_modules\cyfs-sdk-nightly\index.js:94068:13) at E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\node_modules\cyfs-sdk-nightly\index.js:96145:20 at Array.forEach () at BLog.log (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\node_modules\cyfs-sdk-nightly\index.js:96144:17) at console.trace (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-debug\blog\node_blog.js:2265:1) at from_base_x (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-base\base\basex.ts:42:16) at Object.from_base_58 (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-base\base\basex.ts:48:2) at Function.from_base_58 (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-base\objects\object_id.ts:209:20) at AclHandlerRequestJsonCodec.decode_object (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-lib\acl\request.ts:34:25) at RouterHandlerRequestJsonCodec.decode_object (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-lib\router_handler\request.ts:117:26) at RouterHandlerRequestJsonCodec.decode_string (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-lib\base\codec.ts:31:6) at RouterHandlerEventRoutineT.emit (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-lib\router_handler\handler.ts:51:26) at RouterHandlerItem.emit (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\cyfs-lib\router_handler\ws\handler.ts:48:10) at Function.on_event (E:\githubSpace\cyfs-test-lab\src\cyfs-test-dec-app\cyfs\webpack:\cyfs-sdk\src\sdk\c...... [debug],[2023-04-27 17:20:25.222],<>,ws process packet complete: sid=12, cmd=13, seq=1, cyfs_node.js:88475

lizhihongTest commented 1 year ago

This feature has test finished.