@nucypher/taco 0.4.0 → 0.5.0
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 +0 -1
- package/dist/cjs/conditions/base/contract.d.ts +14 -18
- package/dist/cjs/conditions/base/rpc.d.ts +6 -6
- package/dist/cjs/conditions/base/time.d.ts +5 -5
- package/dist/cjs/conditions/condition-expr.d.ts +0 -3
- package/dist/cjs/conditions/condition-expr.js +0 -4
- package/dist/cjs/conditions/condition-expr.js.map +1 -1
- package/dist/cjs/conditions/const.d.ts +0 -2
- package/dist/cjs/conditions/const.js +2 -7
- package/dist/cjs/conditions/const.js.map +1 -1
- package/dist/cjs/conditions/context/context.d.ts +15 -13
- package/dist/cjs/conditions/context/context.js +61 -55
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/shared.d.ts +2 -2
- package/dist/cjs/conditions/shared.js +2 -2
- package/dist/cjs/conditions/shared.js.map +1 -1
- package/dist/cjs/dkg.d.ts +1 -1
- package/dist/cjs/dkg.js +2 -2
- package/dist/cjs/dkg.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js +2 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/taco.d.ts +5 -23
- package/dist/cjs/taco.js +9 -36
- package/dist/cjs/taco.js.map +1 -1
- package/dist/cjs/tdec.d.ts +3 -4
- package/dist/cjs/tdec.js +11 -8
- package/dist/cjs/tdec.js.map +1 -1
- package/dist/es/conditions/base/contract.d.ts +14 -18
- package/dist/es/conditions/base/rpc.d.ts +6 -6
- package/dist/es/conditions/base/time.d.ts +5 -5
- package/dist/es/conditions/condition-expr.d.ts +0 -3
- package/dist/es/conditions/condition-expr.js +0 -4
- package/dist/es/conditions/condition-expr.js.map +1 -1
- package/dist/es/conditions/const.d.ts +0 -2
- package/dist/es/conditions/const.js +1 -6
- package/dist/es/conditions/const.js.map +1 -1
- package/dist/es/conditions/context/context.d.ts +15 -13
- package/dist/es/conditions/context/context.js +62 -56
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/shared.d.ts +2 -2
- package/dist/es/conditions/shared.js +3 -5
- package/dist/es/conditions/shared.js.map +1 -1
- package/dist/es/dkg.d.ts +1 -1
- package/dist/es/dkg.js +2 -2
- package/dist/es/dkg.js.map +1 -1
- package/dist/es/index.d.ts +2 -3
- package/dist/es/index.js +2 -5
- package/dist/es/index.js.map +1 -1
- package/dist/es/taco.d.ts +5 -23
- package/dist/es/taco.js +9 -34
- package/dist/es/taco.js.map +1 -1
- package/dist/es/tdec.d.ts +3 -4
- package/dist/es/tdec.js +12 -9
- package/dist/es/tdec.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -142,25 +142,21 @@ declare const functionAbiSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
142
142
|
}>;
|
|
143
143
|
export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;
|
|
144
144
|
export declare const ContractConditionType = "contract";
|
|
145
|
-
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<
|
|
146
|
-
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
145
|
+
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
147
146
|
chain: z.ZodNever | z.ZodLiteral<z.Primitive> | z.ZodUnion<[z.ZodLiteral<z.Primitive>, z.ZodLiteral<z.Primitive>, ...z.ZodLiteral<z.Primitive>[]]>;
|
|
148
|
-
method: z.ZodEnum<["eth_getBalance"]>;
|
|
149
|
-
parameters: z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, "atleastone">, z.ZodTuple<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>, z.ZodType<any, z.ZodTypeDef, any>], null>]>;
|
|
150
147
|
returnValueTest: z.ZodObject<{
|
|
151
148
|
index: z.ZodOptional<z.ZodNumber>;
|
|
152
149
|
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
153
150
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
154
151
|
}, "strip", z.ZodTypeAny, {
|
|
155
152
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
156
|
-
value?: any;
|
|
157
153
|
index?: number | undefined;
|
|
154
|
+
value?: any;
|
|
158
155
|
}, {
|
|
159
156
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
160
|
-
value?: any;
|
|
161
157
|
index?: number | undefined;
|
|
158
|
+
value?: any;
|
|
162
159
|
}>;
|
|
163
|
-
}, {
|
|
164
160
|
conditionType: z.ZodDefault<z.ZodLiteral<"contract">>;
|
|
165
161
|
contractAddress: z.ZodString;
|
|
166
162
|
standardContractType: z.ZodOptional<z.ZodEnum<["ERC20", "ERC721"]>>;
|
|
@@ -305,17 +301,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
305
301
|
stateMutability: "view" | "pure";
|
|
306
302
|
}>>;
|
|
307
303
|
parameters: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
|
|
308
|
-
}
|
|
304
|
+
}, "strip", z.ZodTypeAny, {
|
|
309
305
|
conditionType: "contract";
|
|
310
306
|
method: string;
|
|
311
307
|
parameters: any[];
|
|
312
308
|
returnValueTest: {
|
|
313
309
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
314
|
-
value?: any;
|
|
315
310
|
index?: number | undefined;
|
|
311
|
+
value?: any;
|
|
316
312
|
};
|
|
317
313
|
contractAddress: string;
|
|
318
314
|
chain?: z.Primitive;
|
|
315
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
319
316
|
functionAbi?: {
|
|
320
317
|
type: "function";
|
|
321
318
|
name: string;
|
|
@@ -335,18 +332,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
335
332
|
}[]];
|
|
336
333
|
stateMutability: "view" | "pure";
|
|
337
334
|
} | undefined;
|
|
338
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
339
335
|
}, {
|
|
340
336
|
method: string;
|
|
341
337
|
parameters: any[];
|
|
342
338
|
returnValueTest: {
|
|
343
339
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
344
|
-
value?: any;
|
|
345
340
|
index?: number | undefined;
|
|
341
|
+
value?: any;
|
|
346
342
|
};
|
|
347
343
|
contractAddress: string;
|
|
348
|
-
conditionType?: "contract" | undefined;
|
|
349
344
|
chain?: z.Primitive;
|
|
345
|
+
conditionType?: "contract" | undefined;
|
|
346
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
350
347
|
functionAbi?: {
|
|
351
348
|
type: "function";
|
|
352
349
|
name: string;
|
|
@@ -366,18 +363,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
366
363
|
}[]];
|
|
367
364
|
stateMutability: "view" | "pure";
|
|
368
365
|
} | undefined;
|
|
369
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
370
366
|
}>, {
|
|
371
367
|
conditionType: "contract";
|
|
372
368
|
method: string;
|
|
373
369
|
parameters: any[];
|
|
374
370
|
returnValueTest: {
|
|
375
371
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
376
|
-
value?: any;
|
|
377
372
|
index?: number | undefined;
|
|
373
|
+
value?: any;
|
|
378
374
|
};
|
|
379
375
|
contractAddress: string;
|
|
380
376
|
chain?: z.Primitive;
|
|
377
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
381
378
|
functionAbi?: {
|
|
382
379
|
type: "function";
|
|
383
380
|
name: string;
|
|
@@ -397,18 +394,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
397
394
|
}[]];
|
|
398
395
|
stateMutability: "view" | "pure";
|
|
399
396
|
} | undefined;
|
|
400
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
401
397
|
}, {
|
|
402
398
|
method: string;
|
|
403
399
|
parameters: any[];
|
|
404
400
|
returnValueTest: {
|
|
405
401
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
406
|
-
value?: any;
|
|
407
402
|
index?: number | undefined;
|
|
403
|
+
value?: any;
|
|
408
404
|
};
|
|
409
405
|
contractAddress: string;
|
|
410
|
-
conditionType?: "contract" | undefined;
|
|
411
406
|
chain?: z.Primitive;
|
|
407
|
+
conditionType?: "contract" | undefined;
|
|
408
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
412
409
|
functionAbi?: {
|
|
413
410
|
type: "function";
|
|
414
411
|
name: string;
|
|
@@ -428,7 +425,6 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectU
|
|
|
428
425
|
}[]];
|
|
429
426
|
stateMutability: "view" | "pure";
|
|
430
427
|
} | undefined;
|
|
431
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
432
428
|
}>;
|
|
433
429
|
export type ContractConditionProps = z.infer<typeof contractConditionSchema>;
|
|
434
430
|
export declare class ContractCondition extends Condition {
|
|
@@ -13,30 +13,30 @@ export declare const rpcConditionSchema: z.ZodObject<{
|
|
|
13
13
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
value?: any;
|
|
17
16
|
index?: number | undefined;
|
|
17
|
+
value?: any;
|
|
18
18
|
}, {
|
|
19
19
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
value?: any;
|
|
21
20
|
index?: number | undefined;
|
|
21
|
+
value?: any;
|
|
22
22
|
}>;
|
|
23
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
24
|
conditionType: "rpc";
|
|
25
25
|
method: "eth_getBalance";
|
|
26
|
-
parameters: [string, ...string[]] | [string, any];
|
|
26
|
+
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
27
27
|
returnValueTest: {
|
|
28
28
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
29
|
-
value?: any;
|
|
30
29
|
index?: number | undefined;
|
|
30
|
+
value?: any;
|
|
31
31
|
};
|
|
32
32
|
chain?: z.Primitive;
|
|
33
33
|
}, {
|
|
34
34
|
method: "eth_getBalance";
|
|
35
|
-
parameters: [string, ...string[]] | [string, any];
|
|
35
|
+
parameters: ([string, ...string[]] | [string, any]) & ([string, ...string[]] | [string, any] | undefined);
|
|
36
36
|
returnValueTest: {
|
|
37
37
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
38
|
-
value?: any;
|
|
39
38
|
index?: number | undefined;
|
|
39
|
+
value?: any;
|
|
40
40
|
};
|
|
41
41
|
conditionType?: "rpc" | undefined;
|
|
42
42
|
chain?: z.Primitive;
|
|
@@ -13,31 +13,31 @@ export declare const timeConditionSchema: z.ZodObject<{
|
|
|
13
13
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
15
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
value?: any;
|
|
17
16
|
index?: number | undefined;
|
|
17
|
+
value?: any;
|
|
18
18
|
}, {
|
|
19
19
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
value?: any;
|
|
21
20
|
index?: number | undefined;
|
|
21
|
+
value?: any;
|
|
22
22
|
}>;
|
|
23
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
24
|
conditionType: "time";
|
|
25
25
|
method: "blocktime";
|
|
26
26
|
returnValueTest: {
|
|
27
27
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
28
|
-
value?: any;
|
|
29
28
|
index?: number | undefined;
|
|
29
|
+
value?: any;
|
|
30
30
|
};
|
|
31
31
|
chain?: z.Primitive;
|
|
32
32
|
}, {
|
|
33
33
|
returnValueTest: {
|
|
34
34
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
35
|
-
value?: any;
|
|
36
35
|
index?: number | undefined;
|
|
36
|
+
value?: any;
|
|
37
37
|
};
|
|
38
38
|
conditionType?: "time" | undefined;
|
|
39
|
-
chain?: z.Primitive;
|
|
40
39
|
method?: "blocktime" | undefined;
|
|
40
|
+
chain?: z.Primitive;
|
|
41
41
|
}>;
|
|
42
42
|
export type TimeConditionProps = z.infer<typeof timeConditionSchema>;
|
|
43
43
|
export declare class TimeCondition extends Condition {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Conditions as CoreConditions } from '@nucypher/nucypher-core';
|
|
2
|
-
import { AuthProviders } from '@nucypher/taco-auth';
|
|
3
2
|
import { Condition } from './condition';
|
|
4
|
-
import { ConditionContext, CustomContextParam } from './context';
|
|
5
3
|
export type ConditionExpressionJSON = {
|
|
6
4
|
version: string;
|
|
7
5
|
condition: Record<string, unknown>;
|
|
@@ -17,6 +15,5 @@ export declare class ConditionExpression {
|
|
|
17
15
|
static fromJSON(json: string): ConditionExpression;
|
|
18
16
|
toCoreCondition(): CoreConditions;
|
|
19
17
|
static fromCoreConditions(conditions: CoreConditions): ConditionExpression;
|
|
20
|
-
buildContext(customParameters?: Record<string, CustomContextParam>, authProviders?: AuthProviders): ConditionContext;
|
|
21
18
|
equals(other: ConditionExpression): boolean;
|
|
22
19
|
}
|
|
@@ -5,7 +5,6 @@ const nucypher_core_1 = require("@nucypher/nucypher-core");
|
|
|
5
5
|
const shared_1 = require("@nucypher/shared");
|
|
6
6
|
const semver_1 = require("semver");
|
|
7
7
|
const condition_factory_1 = require("./condition-factory");
|
|
8
|
-
const context_1 = require("./context");
|
|
9
8
|
const ERR_VERSION = (provided, current) => `Version provided, ${provided}, is incompatible with current version, ${current}`;
|
|
10
9
|
const ERR_CONDITION = (condition) => `Invalid condition: unrecognized condition data ${JSON.stringify(condition)}`;
|
|
11
10
|
class ConditionExpression {
|
|
@@ -47,9 +46,6 @@ class ConditionExpression {
|
|
|
47
46
|
static fromCoreConditions(conditions) {
|
|
48
47
|
return ConditionExpression.fromJSON(conditions.toString());
|
|
49
48
|
}
|
|
50
|
-
buildContext(customParameters = {}, authProviders = {}) {
|
|
51
|
-
return new context_1.ConditionContext(this.condition, customParameters, authProviders);
|
|
52
|
-
}
|
|
53
49
|
equals(other) {
|
|
54
50
|
return [
|
|
55
51
|
this.version === other.version,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-expr.js","sourceRoot":"","sources":["../../../src/conditions/condition-expr.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,6CAA0C;
|
|
1
|
+
{"version":3,"file":"condition-expr.js","sourceRoot":"","sources":["../../../src/conditions/condition-expr.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,6CAA0C;AAC1C,mCAAgC;AAGhC,2DAAuD;AAEvD,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAE,EAAE,CACxD,qBAAqB,QAAQ,2CAA2C,OAAO,EAAE,CAAC;AACpF,MAAM,aAAa,GAAG,CAAC,SAAkC,EAAE,EAAE,CAC3D,kDAAkD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;AAOhF,MAAa,mBAAmB;IAIZ;IACA;IAJX,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IAEhC,YACkB,SAAoB,EACpB,UAAkB,mBAAmB,CAAC,OAAO;QAD7C,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAsC;IAC5D,CAAC;IAEG,KAAK;QACV,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,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;IAEM,MAAM,CAAC,KAA0B;QACtC,OAAO;YACL,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;YAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;SACvC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;;AApDH,kDAqDC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ChainId } from '@nucypher/shared';
|
|
2
|
-
export declare const USER_ADDRESS_PARAM_EXTERNAL_EIP4361 = ":userAddressExternalEIP4361";
|
|
3
2
|
export declare const CONTEXT_PARAM_REGEXP: RegExp;
|
|
4
3
|
export declare const CONTEXT_PARAM_PREFIX = ":";
|
|
5
4
|
export declare const SUPPORTED_CHAIN_IDS: ChainId[];
|
|
6
5
|
export declare const USER_ADDRESS_PARAMS: string[];
|
|
7
|
-
export declare const RESERVED_CONTEXT_PARAMS: string[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.USER_ADDRESS_PARAMS = exports.SUPPORTED_CHAIN_IDS = exports.CONTEXT_PARAM_PREFIX = exports.CONTEXT_PARAM_REGEXP = void 0;
|
|
4
4
|
const shared_1 = require("@nucypher/shared");
|
|
5
5
|
const taco_auth_1 = require("@nucypher/taco-auth");
|
|
6
|
-
exports.USER_ADDRESS_PARAM_EXTERNAL_EIP4361 = ':userAddressExternalEIP4361';
|
|
7
6
|
// Only allow alphanumeric characters and underscores
|
|
8
7
|
exports.CONTEXT_PARAM_REGEXP = new RegExp('^:[a-zA-Z_][a-zA-Z0-9_]*$');
|
|
9
8
|
exports.CONTEXT_PARAM_PREFIX = ':';
|
|
@@ -14,12 +13,8 @@ exports.SUPPORTED_CHAIN_IDS = [
|
|
|
14
13
|
shared_1.ChainId.ETHEREUM_MAINNET,
|
|
15
14
|
];
|
|
16
15
|
exports.USER_ADDRESS_PARAMS = [
|
|
17
|
-
|
|
16
|
+
taco_auth_1.USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
|
|
18
17
|
// Ordering matters, this should always be last
|
|
19
18
|
taco_auth_1.USER_ADDRESS_PARAM_DEFAULT,
|
|
20
19
|
];
|
|
21
|
-
exports.RESERVED_CONTEXT_PARAMS = [
|
|
22
|
-
taco_auth_1.USER_ADDRESS_PARAM_DEFAULT,
|
|
23
|
-
// USER_ADDRESS_PARAM_EXTERNAL_EIP4361 is not reserved and can be used as a custom context parameter
|
|
24
|
-
];
|
|
25
20
|
//# sourceMappingURL=const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/conditions/const.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/conditions/const.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,mDAG6B;AAE7B,qDAAqD;AACxC,QAAA,oBAAoB,GAAG,IAAI,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE/D,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAE3B,QAAA,mBAAmB,GAAG;IACjC,gBAAO,CAAC,OAAO;IACf,gBAAO,CAAC,IAAI;IACZ,gBAAO,CAAC,OAAO;IACf,gBAAO,CAAC,gBAAgB;CACzB,CAAC;AAEW,QAAA,mBAAmB,GAAG;IACjC,+CAAmC;IACnC,+CAA+C;IAC/C,sCAA0B;CAC3B,CAAC"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { ThresholdMessageKit } from '@nucypher/nucypher-core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Condition
|
|
5
|
-
export type CustomContextParam = string | number | boolean
|
|
2
|
+
import { AuthProvider, AuthSignature } from '@nucypher/taco-auth';
|
|
3
|
+
import { CoreContext } from '../../types';
|
|
4
|
+
import { Condition } from '../condition';
|
|
5
|
+
export type CustomContextParam = string | number | boolean;
|
|
6
6
|
export type ContextParam = CustomContextParam | AuthSignature;
|
|
7
|
+
export declare const RESERVED_CONTEXT_PARAMS: string[];
|
|
7
8
|
export declare class ConditionContext {
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
constructor(condition: Condition
|
|
12
|
-
private
|
|
13
|
-
private validateCoreConditions;
|
|
9
|
+
requestedContextParameters: Set<string>;
|
|
10
|
+
private customContextParameters;
|
|
11
|
+
private authProviders;
|
|
12
|
+
constructor(condition: Condition);
|
|
13
|
+
private static validateCoreConditions;
|
|
14
14
|
private validateNoMissingContextParameters;
|
|
15
15
|
private fillContextParameters;
|
|
16
16
|
private validateAuthProviders;
|
|
17
17
|
private fillAuthContextParameters;
|
|
18
|
+
private validateCustomContextParameter;
|
|
18
19
|
private static isContextParameter;
|
|
19
|
-
static findContextParameters
|
|
20
|
+
private static findContextParameters;
|
|
21
|
+
addCustomContextParameterValues(customContextParameters: Record<string, CustomContextParam>): void;
|
|
22
|
+
addAuthProvider(contextParam: string, authProvider: AuthProvider): void;
|
|
20
23
|
toJson(): Promise<string>;
|
|
21
24
|
toCoreContext(): Promise<CoreContext>;
|
|
22
25
|
toContextParameters: () => Promise<Record<string, ContextParam>>;
|
|
23
|
-
static
|
|
24
|
-
static requestedContextParameters(messageKit: ThresholdMessageKit): Set<string>;
|
|
26
|
+
static fromMessageKit(messageKit: ThresholdMessageKit): ConditionContext;
|
|
25
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConditionContext = void 0;
|
|
3
|
+
exports.ConditionContext = exports.RESERVED_CONTEXT_PARAMS = void 0;
|
|
4
4
|
const shared_1 = require("@nucypher/shared");
|
|
5
5
|
const taco_auth_1 = require("@nucypher/taco-auth");
|
|
6
6
|
const types_1 = require("../../types");
|
|
@@ -11,33 +11,28 @@ const ERR_RESERVED_PARAM = (key) => `Cannot use reserved parameter name ${key} a
|
|
|
11
11
|
const ERR_INVALID_CUSTOM_PARAM = (key) => `Custom parameter ${key} must start with ${const_1.CONTEXT_PARAM_PREFIX}`;
|
|
12
12
|
const ERR_AUTH_PROVIDER_REQUIRED = (key) => `No matching authentication provider to satisfy ${key} context variable in condition`;
|
|
13
13
|
const ERR_MISSING_CONTEXT_PARAMS = (params) => `Missing custom context parameter(s): ${params.join(', ')}`;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const ERR_UNKNOWN_CUSTOM_CONTEXT_PARAM = (param) => `Unknown custom context parameter: ${param}`;
|
|
15
|
+
const ERR_INVALID_AUTH_PROVIDER_TYPE = (param, expected) => `Invalid AuthProvider type for ${param}; expected ${expected}`;
|
|
16
|
+
const ERR_AUTH_PROVIDER_NOT_NEEDED_FOR_CONTEXT_PARAM = (param) => `AuthProvider not necessary for context parameter: ${param}`;
|
|
17
|
+
const EXPECTED_AUTH_PROVIDER_TYPES = {
|
|
18
|
+
[taco_auth_1.USER_ADDRESS_PARAM_DEFAULT]: taco_auth_1.EIP4361AuthProvider,
|
|
19
|
+
[taco_auth_1.USER_ADDRESS_PARAM_EXTERNAL_EIP4361]: taco_auth_1.SingleSignOnEIP4361AuthProvider,
|
|
20
|
+
};
|
|
21
|
+
exports.RESERVED_CONTEXT_PARAMS = [
|
|
22
|
+
taco_auth_1.USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
|
|
23
|
+
taco_auth_1.USER_ADDRESS_PARAM_DEFAULT,
|
|
24
|
+
];
|
|
16
25
|
class ConditionContext {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constructor(condition
|
|
21
|
-
this.customParameters = customParameters;
|
|
22
|
-
this.authProviders = authProviders;
|
|
26
|
+
requestedContextParameters;
|
|
27
|
+
customContextParameters = {};
|
|
28
|
+
authProviders = {};
|
|
29
|
+
constructor(condition) {
|
|
23
30
|
const condProps = condition.toObj();
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
this.requestedParameters =
|
|
31
|
+
ConditionContext.validateCoreConditions(condProps);
|
|
32
|
+
this.requestedContextParameters =
|
|
27
33
|
ConditionContext.findContextParameters(condProps);
|
|
28
|
-
this.validateAuthProviders(this.requestedParameters);
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
Object.keys(this.customParameters).forEach((key) => {
|
|
32
|
-
if (const_1.RESERVED_CONTEXT_PARAMS.includes(key)) {
|
|
33
|
-
throw new Error(ERR_RESERVED_PARAM(key));
|
|
34
|
-
}
|
|
35
|
-
if (!key.startsWith(const_1.CONTEXT_PARAM_PREFIX)) {
|
|
36
|
-
throw new Error(ERR_INVALID_CUSTOM_PARAM(key));
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
validateCoreConditions(condObject) {
|
|
35
|
+
static validateCoreConditions(condObject) {
|
|
41
36
|
// Checking whether the condition is compatible with the current version of the library
|
|
42
37
|
// Intentionally ignoring the return value of the function
|
|
43
38
|
new types_1.CoreConditions((0, shared_1.toJSON)(condObject));
|
|
@@ -45,54 +40,52 @@ class ConditionContext {
|
|
|
45
40
|
validateNoMissingContextParameters(parameters) {
|
|
46
41
|
// Ok, so at this point we should have all the parameters we need
|
|
47
42
|
// If we don't, we have a problem and we should throw
|
|
48
|
-
const missingParameters = Array.from(this.
|
|
43
|
+
const missingParameters = Array.from(this.requestedContextParameters).filter((key) => parameters[key] === undefined);
|
|
49
44
|
if (missingParameters.length > 0) {
|
|
50
45
|
throw new Error(ERR_MISSING_CONTEXT_PARAMS(missingParameters));
|
|
51
46
|
}
|
|
52
|
-
// We may also have some parameters that are not used
|
|
53
|
-
const unknownParameters = Object.keys(parameters).filter((key) => !this.requestedParameters.has(key) &&
|
|
54
|
-
!const_1.RESERVED_CONTEXT_PARAMS.includes(key));
|
|
55
|
-
if (unknownParameters.length > 0) {
|
|
56
|
-
throw new Error(ERR_UNKNOWN_CONTEXT_PARAMS(unknownParameters));
|
|
57
|
-
}
|
|
58
47
|
}
|
|
59
|
-
async fillContextParameters(
|
|
60
|
-
const parameters = await this.fillAuthContextParameters(
|
|
61
|
-
for (const key in this.
|
|
62
|
-
parameters[key] = this.
|
|
48
|
+
async fillContextParameters(requestedContextParameters) {
|
|
49
|
+
const parameters = await this.fillAuthContextParameters(requestedContextParameters);
|
|
50
|
+
for (const key in this.customContextParameters) {
|
|
51
|
+
parameters[key] = this.customContextParameters[key];
|
|
63
52
|
}
|
|
64
53
|
return parameters;
|
|
65
54
|
}
|
|
66
|
-
validateAuthProviders(
|
|
67
|
-
for (const param of
|
|
55
|
+
validateAuthProviders() {
|
|
56
|
+
for (const param of this.requestedContextParameters) {
|
|
68
57
|
// If it's not a user address parameter, we can skip
|
|
69
58
|
if (!const_1.USER_ADDRESS_PARAMS.includes(param)) {
|
|
70
59
|
continue;
|
|
71
60
|
}
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
if (!authMethod && !this.customParameters[param]) {
|
|
75
|
-
// If we don't have an auth method, and we don't have a custom parameter, we have a problem
|
|
76
|
-
throw new Error(ERR_NO_AUTH_PROVIDER_FOR_PARAM(param));
|
|
77
|
-
}
|
|
78
|
-
// If we have an auth method, but we don't have an auth provider, we have a problem
|
|
79
|
-
if (authMethod && !this.authProviders[authMethod]) {
|
|
61
|
+
// we don't have a corresponding auth provider, we have a problem
|
|
62
|
+
if (!this.authProviders[param]) {
|
|
80
63
|
throw new Error(ERR_AUTH_PROVIDER_REQUIRED(param));
|
|
81
64
|
}
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
67
|
async fillAuthContextParameters(requestedParameters) {
|
|
85
68
|
const entries = await Promise.all([...requestedParameters]
|
|
86
|
-
.
|
|
87
|
-
.
|
|
88
|
-
.
|
|
89
|
-
const maybeAuthProvider = this.authProviders[authMethod];
|
|
69
|
+
.filter((param) => const_1.USER_ADDRESS_PARAMS.includes(param))
|
|
70
|
+
.map(async (param) => {
|
|
71
|
+
const maybeAuthProvider = this.authProviders[param];
|
|
90
72
|
// TODO: Throw here instead of validating in the constructor?
|
|
91
73
|
// TODO: Hide getOrCreateAuthSignature behind a more generic interface
|
|
92
74
|
return [param, await maybeAuthProvider.getOrCreateAuthSignature()];
|
|
93
75
|
}));
|
|
94
76
|
return Object.fromEntries(entries);
|
|
95
77
|
}
|
|
78
|
+
validateCustomContextParameter(customParam) {
|
|
79
|
+
if (!ConditionContext.isContextParameter(customParam)) {
|
|
80
|
+
throw new Error(ERR_INVALID_CUSTOM_PARAM(customParam));
|
|
81
|
+
}
|
|
82
|
+
if (exports.RESERVED_CONTEXT_PARAMS.includes(customParam)) {
|
|
83
|
+
throw new Error(ERR_RESERVED_PARAM(customParam));
|
|
84
|
+
}
|
|
85
|
+
if (!this.requestedContextParameters.has(customParam)) {
|
|
86
|
+
throw new Error(ERR_UNKNOWN_CUSTOM_CONTEXT_PARAM(customParam));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
96
89
|
static isContextParameter(param) {
|
|
97
90
|
return !!String(param).match(const_1.CONTEXT_PARAM_REGEXP);
|
|
98
91
|
}
|
|
@@ -134,6 +127,21 @@ class ConditionContext {
|
|
|
134
127
|
}
|
|
135
128
|
return requestedParameters;
|
|
136
129
|
}
|
|
130
|
+
addCustomContextParameterValues(customContextParameters) {
|
|
131
|
+
Object.keys(customContextParameters).forEach((key) => {
|
|
132
|
+
this.validateCustomContextParameter(key);
|
|
133
|
+
this.customContextParameters[key] = customContextParameters[key];
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
addAuthProvider(contextParam, authProvider) {
|
|
137
|
+
if (!(contextParam in EXPECTED_AUTH_PROVIDER_TYPES)) {
|
|
138
|
+
throw new Error(ERR_AUTH_PROVIDER_NOT_NEEDED_FOR_CONTEXT_PARAM(contextParam));
|
|
139
|
+
}
|
|
140
|
+
if (!(authProvider instanceof EXPECTED_AUTH_PROVIDER_TYPES[contextParam])) {
|
|
141
|
+
throw new Error(ERR_INVALID_AUTH_PROVIDER_TYPE(contextParam, typeof authProvider));
|
|
142
|
+
}
|
|
143
|
+
this.authProviders[contextParam] = authProvider;
|
|
144
|
+
}
|
|
137
145
|
async toJson() {
|
|
138
146
|
const parameters = await this.toContextParameters();
|
|
139
147
|
return (0, shared_1.toJSON)(parameters);
|
|
@@ -143,16 +151,14 @@ class ConditionContext {
|
|
|
143
151
|
return new types_1.CoreContext(asJson);
|
|
144
152
|
}
|
|
145
153
|
toContextParameters = async () => {
|
|
146
|
-
|
|
154
|
+
this.validateAuthProviders();
|
|
155
|
+
const parameters = await this.fillContextParameters(this.requestedContextParameters);
|
|
147
156
|
this.validateNoMissingContextParameters(parameters);
|
|
148
157
|
return parameters;
|
|
149
158
|
};
|
|
150
|
-
static
|
|
151
|
-
return new ConditionContext(condition_expr_1.ConditionExpression.fromCoreConditions(conditions).condition, customParameters, authProviders);
|
|
152
|
-
}
|
|
153
|
-
static requestedContextParameters(messageKit) {
|
|
159
|
+
static fromMessageKit(messageKit) {
|
|
154
160
|
const conditionExpr = condition_expr_1.ConditionExpression.fromCoreConditions(messageKit.acp.conditions);
|
|
155
|
-
return ConditionContext
|
|
161
|
+
return new ConditionContext(conditionExpr.condition);
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
exports.ConditionContext = ConditionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/conditions/context/context.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/conditions/context/context.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,mDAO6B;AAE7B,uCAA0D;AAC1D,8DAA8D;AAE9D,sDAAwD;AACxD,oCAIkB;AAKlB,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,EAAE,CACzC,sCAAsC,GAAG,sBAAsB,CAAC;AAClE,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAE,EAA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CAC1B,CAAC;QACF,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AA1LD,4CA0LC"}
|
|
@@ -8,12 +8,12 @@ export declare const returnValueTestSchema: z.ZodObject<{
|
|
|
8
8
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
10
10
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
11
|
-
value?: any;
|
|
12
11
|
index?: number | undefined;
|
|
12
|
+
value?: any;
|
|
13
13
|
}, {
|
|
14
14
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
15
|
-
value?: any;
|
|
16
15
|
index?: number | undefined;
|
|
16
|
+
value?: any;
|
|
17
17
|
}>;
|
|
18
18
|
export type ReturnValueTestProps = z.infer<typeof returnValueTestSchema>;
|
|
19
19
|
export declare const EthAddressOrUserAddressSchema: z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEnum<[":userAddress", ":userAddressExternalEIP4361"]>]>;
|
|
@@ -11,7 +11,7 @@ exports.contextParamSchema = zod_1.z.string().regex(const_1.CONTEXT_PARAM_REGEXP
|
|
|
11
11
|
exports.plainStringSchema = zod_1.z.string().refine((str) => {
|
|
12
12
|
return !str.startsWith(const_1.CONTEXT_PARAM_PREFIX);
|
|
13
13
|
}, {
|
|
14
|
-
message:
|
|
14
|
+
message: `String must not be a context parameter i.e. not start with "${const_1.CONTEXT_PARAM_PREFIX}"`,
|
|
15
15
|
});
|
|
16
16
|
const paramSchema = zod_1.z.union([exports.plainStringSchema, zod_1.z.boolean(), zod_1.z.number()]);
|
|
17
17
|
exports.paramOrContextParamSchema = zod_1.z.union([
|
|
@@ -26,7 +26,7 @@ exports.returnValueTestSchema = zod_1.z.object({
|
|
|
26
26
|
});
|
|
27
27
|
const UserAddressSchema = zod_1.z.enum([
|
|
28
28
|
taco_auth_1.USER_ADDRESS_PARAM_DEFAULT,
|
|
29
|
-
|
|
29
|
+
taco_auth_1.USER_ADDRESS_PARAM_EXTERNAL_EIP4361,
|
|
30
30
|
]);
|
|
31
31
|
exports.EthAddressOrUserAddressSchema = zod_1.z.union([
|
|
32
32
|
shared_1.EthAddressSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/conditions/shared.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../src/conditions/shared.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,mDAG6B;AAC7B,6BAAwB;AAExB,mCAAqE;AAExD,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,4BAAoB,CAAC,CAAC;AACzE,kEAAkE;AAClE,mDAAmD;AACtC,QAAA,iBAAiB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,EAAE;IACN,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,4BAAoB,CAAC,CAAC;AAC/C,CAAC,EACD;IACE,OAAO,EAAE,+DAA+D,4BAAoB,GAAG;CAChG,CACF,CAAC;AAEF,MAAM,WAAW,GAAG,OAAC,CAAC,KAAK,CAAC,CAAC,yBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAE7D,QAAA,yBAAyB,GAAgB,OAAC,CAAC,KAAK,CAAC;IAC5D,WAAW;IACX,0BAAkB;IAClB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC,iCAAyB,CAAC,CAAC;CACjD,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IAChD,UAAU,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACtD,KAAK,EAAE,iCAAyB;CACjC,CAAC,CAAC;AAIH,MAAM,iBAAiB,GAAG,OAAC,CAAC,IAAI,CAAC;IAC/B,sCAA0B;IAC1B,+CAAmC;CACpC,CAAC,CAAC;AACU,QAAA,6BAA6B,GAAG,OAAC,CAAC,KAAK,CAAC;IACnD,yBAAgB;IAChB,iBAAiB;CAClB,CAAC,CAAC"}
|
package/dist/cjs/dkg.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class DkgRitual {
|
|
|
20
20
|
equals(other: DkgRitual): boolean;
|
|
21
21
|
}
|
|
22
22
|
export declare class DkgClient {
|
|
23
|
-
static initializeRitual(provider: ethers.providers.Provider, signer: ethers.Signer, domain: Domain, ursulas: ChecksumAddress[], authority: string, duration: BigNumberish, accessController: string, waitUntilEnd?: boolean): Promise<number | undefined>;
|
|
23
|
+
static initializeRitual(provider: ethers.providers.Provider, signer: ethers.Signer, domain: Domain, ursulas: ChecksumAddress[], authority: string, duration: BigNumberish, feeModel: string, accessController: string, waitUntilEnd?: boolean): Promise<number | undefined>;
|
|
24
24
|
private static waitUntilRitualEnd;
|
|
25
25
|
static getRitual(provider: ethers.providers.Provider, domain: Domain, ritualId: number): Promise<DkgRitual>;
|
|
26
26
|
static getActiveRitual(provider: ethers.providers.Provider, domain: Domain, ritualId: number): Promise<DkgRitual>;
|
package/dist/cjs/dkg.js
CHANGED
|
@@ -41,9 +41,9 @@ class DkgRitual {
|
|
|
41
41
|
exports.DkgRitual = DkgRitual;
|
|
42
42
|
const ERR_RITUAL_NOT_FINALIZED = (ritualId, ritual) => `Ritual ${ritualId} is not finalized. State: ${ritual.state}`;
|
|
43
43
|
class DkgClient {
|
|
44
|
-
static async initializeRitual(provider, signer, domain, ursulas, authority, duration, accessController, waitUntilEnd = false) {
|
|
44
|
+
static async initializeRitual(provider, signer, domain, ursulas, authority, duration, feeModel, accessController, waitUntilEnd = false) {
|
|
45
45
|
const ritualId = await shared_1.DkgCoordinatorAgent.initializeRitual(provider, signer, domain, ursulas.sort(), // Contract call requires sorted addresses
|
|
46
|
-
authority, duration, accessController);
|
|
46
|
+
authority, duration, feeModel, accessController);
|
|
47
47
|
if (waitUntilEnd) {
|
|
48
48
|
const isSuccessful = await DkgClient.waitUntilRitualEnd(provider, domain, ritualId);
|
|
49
49
|
if (!isSuccessful) {
|