wowok 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/exception.d.ts +2 -1
- package/dist/exception.d.ts.map +1 -1
- package/dist/exception.js +1 -0
- package/dist/guard.d.ts +24 -24
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +307 -324
- package/dist/passport.d.ts +17 -14
- package/dist/passport.d.ts.map +1 -1
- package/dist/passport.js +111 -76
- package/dist/protocol.d.ts +34 -38
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +32 -48
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +6 -0
- package/package.json +3 -2
- package/src/exception.ts +1 -0
- package/src/guard.ts +315 -335
- package/src/passport.ts +121 -82
- package/src/protocol.ts +35 -51
- package/src/utils.ts +6 -0
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
AI-oriented web3 collaboration protocol, driving innovaion and making it more likely to happen.
|
|
5
5
|
|
|
6
6
|
Github: [https://github.com/wowok-ai/sdk](https://github.com/wowok-ai/sdk)
|
|
7
|
-
Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
|
|
7
|
+
Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai/sdk-examples)
|
|
8
|
+
Docs: [https://github.com/wowok-ai/sdk/wiki](https://github.com/wowok-ai/sdk/wiki)
|
|
8
9
|
|
|
9
10
|
### Installation
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ Examples: [https://github.com/wowok-ai/sdk-examples](https://github.com/wowok-ai
|
|
|
12
13
|
$ npm i wowok
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
### Documentation
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
|
package/dist/exception.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare enum Errors {
|
|
|
14
14
|
InvalidParam = "invalid parameter",
|
|
15
15
|
IsValidPermissionIndex = "invalid permission index",
|
|
16
16
|
IsValidKey = "invalid key",
|
|
17
|
-
Fail = "fail"
|
|
17
|
+
Fail = "fail",
|
|
18
|
+
IsValidIndentifier = "indentifier invalid"
|
|
18
19
|
}
|
|
19
20
|
export declare const ERROR: (error: Errors, info?: any) => never;
|
|
20
21
|
//# sourceMappingURL=exception.d.ts.map
|
package/dist/exception.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AACA,oBAAY,MAAM;IACd,iBAAiB,wBAAwB;IACzC,WAAW,iBAAiB;IAC5B,sBAAsB,iBAAiB;IACvC,eAAe,qBAAqB;IACpC,cAAc,oBAAoB;IAClC,cAAc,yBAAyB;IACvC,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,cAAc,oBAAoB;IAClC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,UAAU,uBAAuB;IACjC,YAAY,sBAAuB;IACnC,sBAAsB,6BAA6B;IACnD,UAAU,gBAAgB;IAC1B,IAAI,SAAS;IACb,kBAAkB,wBAAwB;CAC7C;AAED,eAAO,MAAM,KAAK,UAAU,MAAM,SAAQ,GAAG,UAG5C,CAAA"}
|
package/dist/exception.js
CHANGED
|
@@ -16,6 +16,7 @@ export var Errors;
|
|
|
16
16
|
Errors["IsValidPermissionIndex"] = "invalid permission index";
|
|
17
17
|
Errors["IsValidKey"] = "invalid key";
|
|
18
18
|
Errors["Fail"] = "fail";
|
|
19
|
+
Errors["IsValidIndentifier"] = "indentifier invalid";
|
|
19
20
|
})(Errors || (Errors = {}));
|
|
20
21
|
export const ERROR = (error, info) => {
|
|
21
22
|
const e = error + info ? (': ' + info) : '';
|
package/dist/guard.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType } from './protocol';
|
|
2
|
-
export type
|
|
1
|
+
import { Protocol, GuardAddress, Data_Type, MODULES, ContextType, ValueType, OperatorType, VariableType } from './protocol';
|
|
2
|
+
export type GuardVariable = Map<number, Guard_Vriable>;
|
|
3
3
|
export interface Guard_Vriable {
|
|
4
|
-
type:
|
|
4
|
+
type: VariableType;
|
|
5
5
|
value?: Uint8Array;
|
|
6
6
|
witness?: Uint8Array;
|
|
7
7
|
}
|
|
8
|
-
export type Guard_Creation = {
|
|
9
|
-
description: string;
|
|
10
|
-
variables?: VariableType;
|
|
11
|
-
input: Uint8Array;
|
|
12
|
-
};
|
|
13
8
|
export declare class Guard {
|
|
14
9
|
static MAX_INPUT_LENGTH: number;
|
|
15
|
-
static launch(protocol: Protocol,
|
|
10
|
+
static launch(protocol: Protocol, description: string, maker: GuardMaker): GuardAddress;
|
|
16
11
|
static signer_guard(protocol: Protocol): GuardAddress;
|
|
17
12
|
static everyone_guard(protocol: Protocol): GuardAddress;
|
|
18
13
|
static QUERIES: any[];
|
|
19
14
|
}
|
|
20
|
-
export declare class
|
|
21
|
-
static IsValidGuardVirableType: (type: OperatorType | ContextType) => boolean;
|
|
15
|
+
export declare class GuardVariableHelper {
|
|
22
16
|
static IsValidIndentifier: (identifier: number) => boolean;
|
|
23
|
-
static get_variable_value(variables:
|
|
24
|
-
static get_variable_witness(variables:
|
|
25
|
-
static add_future_variable(variables:
|
|
26
|
-
static add_variable(variables:
|
|
17
|
+
static get_variable_value(variables: GuardVariable, identifier: number, type: VariableType): Uint8Array | undefined;
|
|
18
|
+
static get_variable_witness(variables: GuardVariable, identifier: number): Uint8Array | undefined;
|
|
19
|
+
static add_future_variable(variables: GuardVariable, identifier: number, witness: any, value?: any, bNeedSerialize?: boolean): void;
|
|
20
|
+
static add_variable(variables: GuardVariable, identifier: number, type: ValueType, value: any, bNeedSerialize?: boolean): false | undefined;
|
|
27
21
|
}
|
|
28
|
-
export declare class
|
|
22
|
+
export declare class GuardMaker {
|
|
29
23
|
protected data: Uint8Array[];
|
|
30
24
|
protected type_validator: Data_Type[];
|
|
25
|
+
protected variable: GuardVariable;
|
|
26
|
+
private static index;
|
|
27
|
+
private static get_index;
|
|
31
28
|
constructor();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
add_variable(type: VariableType, value: any, bNeedSerialize?: boolean): number;
|
|
30
|
+
add_param(type: ValueType | ContextType, param?: any): GuardMaker;
|
|
31
|
+
add_query(module: MODULES, query_name: string, object_address_from: string | number, bWitness?: boolean): GuardMaker;
|
|
32
|
+
add_logic(type: OperatorType): GuardMaker;
|
|
33
|
+
build(bNot?: boolean): GuardMaker;
|
|
34
|
+
IsReady(): boolean;
|
|
35
|
+
combine(otherBuilt: GuardMaker, bAnd?: boolean, bCombinVariable?: boolean): GuardMaker;
|
|
36
|
+
get_variable(): GuardVariable;
|
|
37
|
+
get_input(): Uint8Array[];
|
|
38
|
+
static input_combine(input1: Uint8Array, input2: Uint8Array, bAnd?: boolean): Uint8Array;
|
|
39
|
+
static input_not(input: Uint8Array): Uint8Array;
|
|
40
40
|
static match_u128(type: number): boolean;
|
|
41
41
|
}
|
|
42
42
|
//# sourceMappingURL=guard.d.ts.map
|
package/dist/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAc,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAG,YAAY,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAKxI,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,YAAY,CAAE;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,qBAAa,KAAK;IACd,MAAM,CAAC,gBAAgB,SAAQ;IAC/B,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,EAAE,KAAK,EAAC,UAAU,GAAI,YAAY;IA4DrF,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAI,YAAY;IAOtD,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAC,QAAQ,GAAI,YAAY;IAMvD,MAAM,CAAC,OAAO,EAAC,GAAG,EAAE,CAgInB;CACJ;AAED,qBAAa,mBAAmB;IAC5B,MAAM,CAAC,kBAAkB,eAAe,MAAM,KAAI,OAAO,CAGxD;IACD,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,EAAE,IAAI,EAAC,YAAY,GAAI,UAAU,GAAG,SAAS;I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