@nucypher/taco 0.6.0-alpha.1 → 0.6.0-alpha.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 +2 -2
- package/dist/cjs/conditions/base/index.d.ts +2 -0
- package/dist/cjs/conditions/base/index.js +20 -8
- package/dist/cjs/conditions/base/index.js.map +1 -1
- package/dist/cjs/conditions/base/json-api.d.ts +1 -1
- package/dist/cjs/conditions/base/json-api.js +1 -2
- package/dist/cjs/conditions/base/json-api.js.map +1 -1
- package/dist/cjs/conditions/base/json-rpc.d.ts +7 -0
- package/dist/cjs/conditions/base/json-rpc.js +18 -0
- package/dist/cjs/conditions/base/json-rpc.js.map +1 -0
- package/dist/cjs/conditions/base/jwt.d.ts +7 -0
- package/dist/cjs/conditions/base/jwt.js +19 -0
- package/dist/cjs/conditions/base/jwt.js.map +1 -0
- package/dist/cjs/conditions/condition-expr.js +5 -5
- package/dist/cjs/conditions/condition-expr.js.map +1 -1
- package/dist/cjs/conditions/condition-factory.js +6 -0
- package/dist/cjs/conditions/condition-factory.js.map +1 -1
- package/dist/cjs/conditions/condition.js +2 -1
- package/dist/cjs/conditions/condition.js.map +1 -1
- package/dist/cjs/conditions/const.d.ts +0 -2
- package/dist/cjs/conditions/const.js +1 -9
- package/dist/cjs/conditions/const.js.map +1 -1
- package/dist/cjs/conditions/context/context.d.ts +2 -1
- package/dist/cjs/conditions/context/context.js +57 -61
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/index.js +17 -7
- package/dist/cjs/conditions/index.js.map +1 -1
- package/dist/cjs/conditions/predefined/index.js +17 -7
- package/dist/cjs/conditions/predefined/index.js.map +1 -1
- package/dist/cjs/conditions/schemas/common.d.ts +3 -1
- package/dist/cjs/conditions/schemas/common.js +40 -7
- package/dist/cjs/conditions/schemas/common.js.map +1 -1
- package/dist/cjs/conditions/schemas/context.d.ts +1 -0
- package/dist/cjs/conditions/schemas/context.js +24 -3
- package/dist/cjs/conditions/schemas/context.js.map +1 -1
- package/dist/cjs/conditions/schemas/contract.d.ts +44 -25
- package/dist/cjs/conditions/schemas/contract.js +7 -7
- package/dist/cjs/conditions/schemas/contract.js.map +1 -1
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.d.ts +18 -0
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js +37 -0
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js.map +1 -0
- package/dist/cjs/conditions/schemas/json-api.d.ts +14 -12
- package/dist/cjs/conditions/schemas/json-api.js +5 -25
- package/dist/cjs/conditions/schemas/json-api.js.map +1 -1
- package/dist/cjs/conditions/schemas/json-rpc.d.ts +51 -0
- package/dist/cjs/conditions/schemas/json-rpc.js +21 -0
- package/dist/cjs/conditions/schemas/json-rpc.js.map +1 -0
- package/dist/cjs/conditions/schemas/jwt.d.ts +22 -0
- package/dist/cjs/conditions/schemas/jwt.js +19 -0
- package/dist/cjs/conditions/schemas/jwt.js.map +1 -0
- package/dist/cjs/conditions/schemas/return-value-test.d.ts +18 -2
- package/dist/cjs/conditions/schemas/return-value-test.js +7 -2
- package/dist/cjs/conditions/schemas/return-value-test.js.map +1 -1
- package/dist/cjs/conditions/schemas/rpc.d.ts +19 -16
- package/dist/cjs/conditions/schemas/rpc.js +19 -37
- package/dist/cjs/conditions/schemas/rpc.js.map +1 -1
- package/dist/cjs/conditions/schemas/time.d.ts +11 -10
- package/dist/cjs/conditions/schemas/utils.js +4 -0
- package/dist/cjs/conditions/schemas/utils.js.map +1 -1
- package/dist/cjs/conditions/shared.d.ts +1 -1
- package/dist/cjs/conditions/shared.js +2 -1
- package/dist/cjs/conditions/shared.js.map +1 -1
- package/dist/cjs/index.js +17 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils.d.ts +2 -0
- package/dist/cjs/utils.js +48 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/es/conditions/base/index.d.ts +2 -0
- package/dist/es/conditions/base/index.js +2 -0
- package/dist/es/conditions/base/index.js.map +1 -1
- package/dist/es/conditions/base/json-api.d.ts +1 -1
- package/dist/es/conditions/base/json-api.js +1 -1
- package/dist/es/conditions/base/json-api.js.map +1 -1
- package/dist/es/conditions/base/json-rpc.d.ts +7 -0
- package/dist/es/conditions/base/json-rpc.js +12 -0
- package/dist/es/conditions/base/json-rpc.js.map +1 -0
- package/dist/es/conditions/base/jwt.d.ts +7 -0
- package/dist/es/conditions/base/jwt.js +12 -0
- package/dist/es/conditions/base/jwt.js.map +1 -0
- package/dist/es/conditions/condition-expr.js +3 -3
- package/dist/es/conditions/condition-expr.js.map +1 -1
- package/dist/es/conditions/condition-factory.js +6 -0
- package/dist/es/conditions/condition-factory.js.map +1 -1
- package/dist/es/conditions/condition.js +2 -1
- package/dist/es/conditions/condition.js.map +1 -1
- package/dist/es/conditions/const.d.ts +0 -2
- package/dist/es/conditions/const.js +1 -9
- package/dist/es/conditions/const.js.map +1 -1
- package/dist/es/conditions/context/context.d.ts +2 -1
- package/dist/es/conditions/context/context.js +57 -61
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/schemas/common.d.ts +3 -1
- package/dist/es/conditions/schemas/common.js +41 -8
- package/dist/es/conditions/schemas/common.js.map +1 -1
- package/dist/es/conditions/schemas/context.d.ts +1 -0
- package/dist/es/conditions/schemas/context.js +23 -2
- package/dist/es/conditions/schemas/context.js.map +1 -1
- package/dist/es/conditions/schemas/contract.d.ts +44 -25
- package/dist/es/conditions/schemas/contract.js +4 -4
- package/dist/es/conditions/schemas/contract.js.map +1 -1
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.d.ts +18 -0
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.js +21 -0
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.js.map +1 -0
- package/dist/es/conditions/schemas/json-api.d.ts +14 -12
- package/dist/es/conditions/schemas/json-api.js +3 -23
- package/dist/es/conditions/schemas/json-api.js.map +1 -1
- package/dist/es/conditions/schemas/json-rpc.d.ts +51 -0
- package/dist/es/conditions/schemas/json-rpc.js +18 -0
- package/dist/es/conditions/schemas/json-rpc.js.map +1 -0
- package/dist/es/conditions/schemas/jwt.d.ts +22 -0
- package/dist/es/conditions/schemas/jwt.js +16 -0
- package/dist/es/conditions/schemas/jwt.js.map +1 -0
- package/dist/es/conditions/schemas/return-value-test.d.ts +18 -2
- package/dist/es/conditions/schemas/return-value-test.js +7 -2
- package/dist/es/conditions/schemas/return-value-test.js.map +1 -1
- package/dist/es/conditions/schemas/rpc.d.ts +19 -16
- package/dist/es/conditions/schemas/rpc.js +20 -15
- package/dist/es/conditions/schemas/rpc.js.map +1 -1
- package/dist/es/conditions/schemas/time.d.ts +11 -10
- package/dist/es/conditions/schemas/utils.js +4 -0
- package/dist/es/conditions/schemas/utils.js.map +1 -1
- package/dist/es/conditions/shared.d.ts +1 -1
- package/dist/es/conditions/shared.js +1 -1
- package/dist/es/conditions/shared.js.map +1 -1
- package/dist/es/utils.d.ts +2 -0
- package/dist/es/utils.js +43 -0
- package/dist/es/utils.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +13 -8
- package/dist/cjs/conditions/context/providers.d.ts +0 -16
- package/dist/cjs/conditions/context/providers.js +0 -111
- package/dist/cjs/conditions/context/providers.js.map +0 -1
- package/dist/cjs/web3.d.ts +0 -33
- package/dist/cjs/web3.js +0 -3
- package/dist/cjs/web3.js.map +0 -1
- package/dist/es/conditions/context/providers.d.ts +0 -16
- package/dist/es/conditions/context/providers.js +0 -107
- package/dist/es/conditions/context/providers.js.map +0 -1
- package/dist/es/web3.d.ts +0 -33
- package/dist/es/web3.js +0 -2
- package/dist/es/web3.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Primitive, z } from 'zod';
|
|
2
2
|
export declare const plainStringSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
3
|
-
export declare const UserAddressSchema: z.
|
|
3
|
+
export declare const UserAddressSchema: z.ZodLiteral<":userAddress">;
|
|
4
4
|
export declare const baseConditionSchema: z.ZodObject<{
|
|
5
5
|
conditionType: z.ZodString;
|
|
6
6
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -10,3 +10,5 @@ export declare const baseConditionSchema: z.ZodObject<{
|
|
|
10
10
|
}>;
|
|
11
11
|
declare function createUnionSchema<T extends readonly Primitive[]>(values: T): z.ZodNever | z.ZodLiteral<Primitive> | z.ZodUnion<[z.ZodLiteral<Primitive>, z.ZodLiteral<Primitive>, ...z.ZodLiteral<Primitive>[]]>;
|
|
12
12
|
export default createUnionSchema;
|
|
13
|
+
export declare const jsonPathSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
+
export declare const httpsURLSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.baseConditionSchema = exports.UserAddressSchema = exports.plainStringSchema = void 0;
|
|
3
|
+
exports.httpsURLSchema = exports.jsonPathSchema = exports.baseConditionSchema = exports.UserAddressSchema = exports.plainStringSchema = void 0;
|
|
4
|
+
const jsonpath_1 = require("@astronautlabs/jsonpath");
|
|
4
5
|
const taco_auth_1 = require("@nucypher/taco-auth");
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const const_1 = require("../const");
|
|
7
8
|
// We want to discriminate between ContextParams and plain strings
|
|
8
9
|
// If a string starts with `:`, it's a ContextParam
|
|
9
|
-
exports.plainStringSchema = zod_1.z
|
|
10
|
+
exports.plainStringSchema = zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.refine((str) => {
|
|
10
13
|
return !str.startsWith(const_1.CONTEXT_PARAM_PREFIX);
|
|
11
14
|
}, {
|
|
12
15
|
message: `String must not be a context parameter i.e. not start with "${const_1.CONTEXT_PARAM_PREFIX}"`,
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
taco_auth_1.
|
|
17
|
-
|
|
16
|
+
})
|
|
17
|
+
.describe(`Any string that is not a Context Parameter i.e. does not start with \`${const_1.CONTEXT_PARAM_PREFIX}\`.`);
|
|
18
|
+
exports.UserAddressSchema = zod_1.z
|
|
19
|
+
.literal(taco_auth_1.USER_ADDRESS_PARAM_DEFAULT)
|
|
20
|
+
.describe('This is a context variable that will be replaced at decryption time. It represents the Ethereum address of the requester attempting decryption.');
|
|
18
21
|
exports.baseConditionSchema = zod_1.z.object({
|
|
19
22
|
conditionType: zod_1.z.string(),
|
|
20
23
|
});
|
|
@@ -33,4 +36,34 @@ function createUnionSchema(values) {
|
|
|
33
36
|
return createUnion(values);
|
|
34
37
|
}
|
|
35
38
|
exports.default = createUnionSchema;
|
|
39
|
+
const validateJSONPath = (jsonPath) => {
|
|
40
|
+
// account for embedded context variables
|
|
41
|
+
if (const_1.CONTEXT_PARAM_REGEXP.test(jsonPath)) {
|
|
42
|
+
// skip validation
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
jsonpath_1.JSONPath.parse(jsonPath);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.jsonPathSchema = zod_1.z
|
|
54
|
+
.string()
|
|
55
|
+
.refine((val) => validateJSONPath(val), {
|
|
56
|
+
message: 'Invalid JSONPath expression',
|
|
57
|
+
})
|
|
58
|
+
.describe('A string containing either a valid JSON Path Expression, or a Context Parameter.');
|
|
59
|
+
const validateHttpsURL = (url) => {
|
|
60
|
+
return URL.canParse(url) && url.startsWith('https://');
|
|
61
|
+
};
|
|
62
|
+
// Use our own URL refinement check due to https://github.com/colinhacks/zod/issues/2236
|
|
63
|
+
exports.httpsURLSchema = zod_1.z
|
|
64
|
+
.string()
|
|
65
|
+
.url()
|
|
66
|
+
.refine((url) => validateHttpsURL(url), {
|
|
67
|
+
message: 'Invalid URL',
|
|
68
|
+
});
|
|
36
69
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/common.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/common.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAiE;AACjE,6BAA+C;AAE/C,oCAAsE;AAEtE,kEAAkE;AAClE,mDAAmD;AACtC,QAAA,iBAAiB,GAAG,OAAC;KAC/B,MAAM,EAAE;KACR,MAAM,CACL,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;KACA,QAAQ,CACP,yEAAyE,4BAAoB,KAAK,CACnG,CAAC;AAES,QAAA,iBAAiB,GAAG,OAAC;KAC/B,OAAO,CAAC,sCAA0B,CAAC;KACnC,QAAQ,CACP,iJAAiJ,CAClJ,CAAC;AAES,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC;AAEH,+EAA+E;AAC/E,MAAM,WAAW,GAAG,CAGlB,MAAS,EACT,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAIzD,CAAC;IACF,OAAO,OAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,SAAS,iBAAiB,CAAiC,MAAS;IAClE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,OAAC,CAAC,KAAK,EAAE,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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.paramOrContextParamSchema = exports.contextParamSchema = void 0;
|
|
3
|
+
exports.blockchainParamOrContextParamSchema = exports.paramOrContextParamSchema = exports.contextParamSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const const_1 = require("../const");
|
|
6
6
|
const common_1 = require("./common");
|
|
7
|
+
const UINT256_MAX = BigInt('115792089237316195423570985008687907853269984665640564039457584007913129639935');
|
|
8
|
+
const INT256_MIN = BigInt('-57896044618658097711785492504343953926634992332820282019728792003956564819968');
|
|
7
9
|
exports.contextParamSchema = zod_1.z
|
|
8
10
|
.string()
|
|
9
|
-
.regex(const_1.CONTEXT_PARAM_FULL_MATCH_REGEXP)
|
|
10
|
-
|
|
11
|
+
.regex(const_1.CONTEXT_PARAM_FULL_MATCH_REGEXP)
|
|
12
|
+
.describe(`A Context Parameter i.e. a placeholder used within conditions and specified at the encryption time, whose value is provided at decryption time.`);
|
|
13
|
+
const paramSchema = zod_1.z.union([
|
|
14
|
+
common_1.plainStringSchema,
|
|
15
|
+
zod_1.z.boolean(),
|
|
16
|
+
zod_1.z.number(),
|
|
17
|
+
zod_1.z.bigint(),
|
|
18
|
+
]);
|
|
19
|
+
const blockchainParamSchema = zod_1.z
|
|
20
|
+
.union([
|
|
21
|
+
common_1.plainStringSchema,
|
|
22
|
+
zod_1.z.boolean(),
|
|
23
|
+
zod_1.z.number().int().safe(),
|
|
24
|
+
zod_1.z.bigint().lte(UINT256_MAX).gte(INT256_MIN),
|
|
25
|
+
])
|
|
26
|
+
.describe('Blockchain-compatible parameter values for blockchain RPC API calls and Smart Contracts functions; numbers must be in safe range and bigints must be in the range [-2^255, 2^256-1]).');
|
|
11
27
|
exports.paramOrContextParamSchema = zod_1.z.union([
|
|
12
28
|
paramSchema,
|
|
13
29
|
exports.contextParamSchema,
|
|
14
30
|
zod_1.z.lazy(() => zod_1.z.array(exports.paramOrContextParamSchema)),
|
|
15
31
|
]);
|
|
32
|
+
exports.blockchainParamOrContextParamSchema = zod_1.z.union([
|
|
33
|
+
blockchainParamSchema,
|
|
34
|
+
exports.contextParamSchema,
|
|
35
|
+
zod_1.z.lazy(() => zod_1.z.array(exports.blockchainParamOrContextParamSchema)),
|
|
36
|
+
]);
|
|
16
37
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/context.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,oCAA2D;AAE3D,qCAA6C;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/context.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,oCAA2D;AAE3D,qCAA6C;AAE7C,MAAM,WAAW,GAAG,MAAM,CACxB,gFAAgF,CACjF,CAAC;AACF,MAAM,UAAU,GAAG,MAAM,CACvB,gFAAgF,CACjF,CAAC;AAEW,QAAA,kBAAkB,GAAG,OAAC;KAChC,MAAM,EAAE;KACR,KAAK,CAAC,uCAA+B,CAAC;KACtC,QAAQ,CACP,iJAAiJ,CAClJ,CAAC;AAEJ,MAAM,WAAW,GAAG,OAAC,CAAC,KAAK,CAAC;IAC1B,0BAAiB;IACjB,OAAC,CAAC,OAAO,EAAE;IACX,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,MAAM,EAAE;CACX,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,OAAC;KAC5B,KAAK,CAAC;IACL,0BAAiB;IACjB,OAAC,CAAC,OAAO,EAAE;IACX,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE;IACvB,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC;CAC5C,CAAC;KACD,QAAQ,CACP,uLAAuL,CACxL,CAAC;AAES,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,mCAAmC,GAAgB,OAAC,CAAC,KAAK,CAAC;IACtE,qBAAqB;IACrB,0BAAkB;IAClB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAC,CAAC,KAAK,CAAC,2CAAmC,CAAC,CAAC;CAC3D,CAAC,CAAC"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
declare const
|
|
2
|
+
export declare const functionAbiVariableSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
type: z.ZodEnum<[string, ...string[]]>;
|
|
5
|
+
internalType: z.ZodEnum<[string, ...string[]]>;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
internalType: string;
|
|
10
|
+
}, {
|
|
11
|
+
type: string;
|
|
12
|
+
name: string;
|
|
13
|
+
internalType: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const functionAbiSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
3
16
|
name: z.ZodString;
|
|
4
17
|
type: z.ZodLiteral<"function">;
|
|
5
18
|
inputs: z.ZodArray<z.ZodObject<{
|
|
@@ -140,21 +153,28 @@ declare const functionAbiSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
140
153
|
}>;
|
|
141
154
|
export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;
|
|
142
155
|
export declare const ContractConditionType = "contract";
|
|
143
|
-
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
144
|
-
|
|
156
|
+
export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
157
|
+
conditionType: z.ZodString;
|
|
158
|
+
}, {
|
|
159
|
+
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
160
|
+
chain: z.ZodNumber;
|
|
161
|
+
method: z.ZodEnum<["eth_getBalance"]>;
|
|
162
|
+
parameters: z.ZodUnion<[z.ZodTuple<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<":userAddress">, z.ZodString]>, z.ZodUnion<[z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodEnum<["earliest", "finalized", "safe", "latest", "pending"]>]>, z.ZodString]>], null>, z.ZodTuple<[z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodLiteral<":userAddress">, z.ZodString]>], null>]>;
|
|
163
|
+
returnValueTest: z.ZodObject<z.objectUtil.extendShape<{
|
|
145
164
|
index: z.ZodOptional<z.ZodNumber>;
|
|
146
165
|
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
166
|
+
}, {
|
|
147
167
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
148
|
-
}
|
|
168
|
+
}>, "strip", z.ZodTypeAny, {
|
|
149
169
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
150
|
-
index?: number | undefined;
|
|
151
170
|
value?: any;
|
|
171
|
+
index?: number | undefined;
|
|
152
172
|
}, {
|
|
153
173
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
154
|
-
index?: number | undefined;
|
|
155
174
|
value?: any;
|
|
175
|
+
index?: number | undefined;
|
|
156
176
|
}>;
|
|
157
|
-
|
|
177
|
+
}>, {
|
|
158
178
|
conditionType: z.ZodDefault<z.ZodLiteral<"contract">>;
|
|
159
179
|
contractAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
160
180
|
standardContractType: z.ZodOptional<z.ZodEnum<["ERC20", "ERC721"]>>;
|
|
@@ -299,18 +319,17 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
299
319
|
stateMutability: "view" | "pure";
|
|
300
320
|
}>>;
|
|
301
321
|
parameters: z.ZodArray<z.ZodType<any, z.ZodTypeDef, any>, "many">;
|
|
302
|
-
}
|
|
322
|
+
}>, "strip", z.ZodTypeAny, {
|
|
303
323
|
conditionType: "contract";
|
|
324
|
+
chain: number;
|
|
325
|
+
method: string;
|
|
304
326
|
parameters: any[];
|
|
305
327
|
returnValueTest: {
|
|
306
328
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
307
|
-
index?: number | undefined;
|
|
308
329
|
value?: any;
|
|
330
|
+
index?: number | undefined;
|
|
309
331
|
};
|
|
310
|
-
method: string;
|
|
311
332
|
contractAddress: string;
|
|
312
|
-
chain?: z.Primitive;
|
|
313
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
314
333
|
functionAbi?: {
|
|
315
334
|
type: "function";
|
|
316
335
|
name: string;
|
|
@@ -330,18 +349,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
330
349
|
}[]];
|
|
331
350
|
stateMutability: "view" | "pure";
|
|
332
351
|
} | undefined;
|
|
352
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
333
353
|
}, {
|
|
354
|
+
chain: number;
|
|
355
|
+
method: string;
|
|
334
356
|
parameters: any[];
|
|
335
357
|
returnValueTest: {
|
|
336
358
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
337
|
-
index?: number | undefined;
|
|
338
359
|
value?: any;
|
|
360
|
+
index?: number | undefined;
|
|
339
361
|
};
|
|
340
|
-
method: string;
|
|
341
362
|
contractAddress: string;
|
|
342
|
-
chain?: z.Primitive;
|
|
343
363
|
conditionType?: "contract" | undefined;
|
|
344
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
345
364
|
functionAbi?: {
|
|
346
365
|
type: "function";
|
|
347
366
|
name: string;
|
|
@@ -361,18 +380,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
361
380
|
}[]];
|
|
362
381
|
stateMutability: "view" | "pure";
|
|
363
382
|
} | undefined;
|
|
383
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
364
384
|
}>, {
|
|
365
385
|
conditionType: "contract";
|
|
386
|
+
chain: number;
|
|
387
|
+
method: string;
|
|
366
388
|
parameters: any[];
|
|
367
389
|
returnValueTest: {
|
|
368
390
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
369
|
-
index?: number | undefined;
|
|
370
391
|
value?: any;
|
|
392
|
+
index?: number | undefined;
|
|
371
393
|
};
|
|
372
|
-
method: string;
|
|
373
394
|
contractAddress: string;
|
|
374
|
-
chain?: z.Primitive;
|
|
375
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
376
395
|
functionAbi?: {
|
|
377
396
|
type: "function";
|
|
378
397
|
name: string;
|
|
@@ -392,18 +411,18 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
392
411
|
}[]];
|
|
393
412
|
stateMutability: "view" | "pure";
|
|
394
413
|
} | undefined;
|
|
414
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
395
415
|
}, {
|
|
416
|
+
chain: number;
|
|
417
|
+
method: string;
|
|
396
418
|
parameters: any[];
|
|
397
419
|
returnValueTest: {
|
|
398
420
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
399
|
-
index?: number | undefined;
|
|
400
421
|
value?: any;
|
|
422
|
+
index?: number | undefined;
|
|
401
423
|
};
|
|
402
|
-
method: string;
|
|
403
424
|
contractAddress: string;
|
|
404
|
-
chain?: z.Primitive;
|
|
405
425
|
conditionType?: "contract" | undefined;
|
|
406
|
-
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
407
426
|
functionAbi?: {
|
|
408
427
|
type: "function";
|
|
409
428
|
name: string;
|
|
@@ -423,6 +442,6 @@ export declare const contractConditionSchema: z.ZodEffects<z.ZodObject<{
|
|
|
423
442
|
}[]];
|
|
424
443
|
stateMutability: "view" | "pure";
|
|
425
444
|
} | undefined;
|
|
445
|
+
standardContractType?: "ERC20" | "ERC721" | undefined;
|
|
426
446
|
}>;
|
|
427
447
|
export type ContractConditionProps = z.infer<typeof contractConditionSchema>;
|
|
428
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contractConditionSchema = exports.ContractConditionType = void 0;
|
|
3
|
+
exports.contractConditionSchema = exports.ContractConditionType = exports.functionAbiSchema = exports.functionAbiVariableSchema = void 0;
|
|
4
4
|
const shared_1 = require("@nucypher/shared");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
6
|
const zod_1 = require("zod");
|
|
@@ -19,19 +19,19 @@ const EthBaseTypes = [
|
|
|
19
19
|
...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), // uint8 through uint256
|
|
20
20
|
...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), // int8 through int256
|
|
21
21
|
];
|
|
22
|
-
|
|
22
|
+
exports.functionAbiVariableSchema = zod_1.z
|
|
23
23
|
.object({
|
|
24
24
|
name: zod_1.z.string(),
|
|
25
25
|
type: zod_1.z.enum(EthBaseTypes),
|
|
26
26
|
internalType: zod_1.z.enum(EthBaseTypes), // TODO: Do we need to validate this?
|
|
27
27
|
})
|
|
28
28
|
.strict();
|
|
29
|
-
|
|
29
|
+
exports.functionAbiSchema = zod_1.z
|
|
30
30
|
.object({
|
|
31
31
|
name: zod_1.z.string(),
|
|
32
32
|
type: zod_1.z.literal('function'),
|
|
33
|
-
inputs: zod_1.z.array(functionAbiVariableSchema).min(0),
|
|
34
|
-
outputs: zod_1.z.array(functionAbiVariableSchema).nonempty(),
|
|
33
|
+
inputs: zod_1.z.array(exports.functionAbiVariableSchema).min(0),
|
|
34
|
+
outputs: zod_1.z.array(exports.functionAbiVariableSchema).nonempty(),
|
|
35
35
|
stateMutability: zod_1.z.union([zod_1.z.literal('view'), zod_1.z.literal('pure')]),
|
|
36
36
|
})
|
|
37
37
|
.strict()
|
|
@@ -67,8 +67,8 @@ exports.contractConditionSchema = rpc_1.rpcConditionSchema
|
|
|
67
67
|
contractAddress: shared_1.EthAddressSchema,
|
|
68
68
|
standardContractType: zod_1.z.enum(['ERC20', 'ERC721']).optional(),
|
|
69
69
|
method: zod_1.z.string(),
|
|
70
|
-
functionAbi: functionAbiSchema.optional(),
|
|
71
|
-
parameters: zod_1.z.array(context_1.
|
|
70
|
+
functionAbi: exports.functionAbiSchema.optional(),
|
|
71
|
+
parameters: zod_1.z.array(context_1.blockchainParamOrContextParamSchema),
|
|
72
72
|
})
|
|
73
73
|
// Adding this custom logic causes the return type to be ZodEffects instead of ZodObject
|
|
74
74
|
// https://github.com/colinhacks/zod/issues/2474
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/contract.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,mCAAgC;AAChC,6BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/contract.ts"],"names":[],"mappings":";;;AAAA,6CAAoD;AACpD,mCAAgC;AAChC,6BAAwB;AAExB,uCAAgE;AAChE,+BAA2C;AAE3C,6CAA6C;AAC7C,gHAAgH;AAChH,iDAAiD;AACjD,MAAM,YAAY,GAA0B;IAC1C,MAAM;IACN,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,yBAAyB;IACpF,OAAO;IACP,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE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M;AACL,0EAA0E;AAC1E,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAC1E;IACE,OAAO,EACL,oFAAoF;IACtF,IAAI,EAAE,CAAC,sBAAsB,CAAC;CAC/B,CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is used by zod2md to generate markdown documentation for the Zod schemas.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: The order of the exported Zod objects in this file dictates the order of the generated markdown.
|
|
5
|
+
*/
|
|
6
|
+
export * from './utils';
|
|
7
|
+
export * from './common';
|
|
8
|
+
export * from './context';
|
|
9
|
+
export * from './compound';
|
|
10
|
+
export * from './contract';
|
|
11
|
+
export * from './if-then-else';
|
|
12
|
+
export * from './json-api';
|
|
13
|
+
export * from './json-rpc';
|
|
14
|
+
export * from './jwt';
|
|
15
|
+
export * from './return-value-test';
|
|
16
|
+
export * from './rpc';
|
|
17
|
+
export * from './sequential';
|
|
18
|
+
export * from './time';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file is used by zod2md to generate markdown documentation for the Zod schemas.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: The order of the exported Zod objects in this file dictates the order of the generated markdown.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
23
|
+
// ts-unused-exports:disable-next-line - this comment line is added to prevent lint from changing or objecting the export order.
|
|
24
|
+
__exportStar(require("./common"), exports);
|
|
25
|
+
__exportStar(require("./context"), exports);
|
|
26
|
+
// ts-unused-exports:disable-next-line - this comment line is added to prevent lint from changing or objecting the export order.
|
|
27
|
+
__exportStar(require("./compound"), exports);
|
|
28
|
+
__exportStar(require("./contract"), exports);
|
|
29
|
+
__exportStar(require("./if-then-else"), exports);
|
|
30
|
+
__exportStar(require("./json-api"), exports);
|
|
31
|
+
__exportStar(require("./json-rpc"), exports);
|
|
32
|
+
__exportStar(require("./jwt"), exports);
|
|
33
|
+
__exportStar(require("./return-value-test"), exports);
|
|
34
|
+
__exportStar(require("./rpc"), exports);
|
|
35
|
+
__exportStar(require("./sequential"), exports);
|
|
36
|
+
__exportStar(require("./time"), exports);
|
|
37
|
+
//# sourceMappingURL=export-for-zod-doc-gen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-for-zod-doc-gen.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/export-for-zod-doc-gen.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,gIAAgI;AAChI,2CAAyB;AACzB,4CAA0B;AAC1B,gIAAgI;AAChI,6CAA2B;AAC3B,6CAA2B;AAC3B,iDAA+B;AAC/B,6CAA2B;AAC3B,6CAA2B;AAC3B,wCAAsB;AACtB,sDAAoC;AACpC,wCAAsB;AACtB,+CAA6B;AAC7B,yCAAuB"}
|
|
@@ -1,43 +1,45 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const JsonApiConditionType = "json-api";
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
3
|
+
export declare const jsonApiConditionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
|
+
conditionType: z.ZodString;
|
|
5
|
+
}, {
|
|
5
6
|
conditionType: z.ZodDefault<z.ZodLiteral<"json-api">>;
|
|
6
|
-
endpoint: z.ZodString
|
|
7
|
+
endpoint: z.ZodEffects<z.ZodString, string, string>;
|
|
7
8
|
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
8
9
|
query: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
9
10
|
authorizationToken: z.ZodOptional<z.ZodString>;
|
|
10
|
-
returnValueTest: z.ZodObject<{
|
|
11
|
+
returnValueTest: z.ZodObject<z.objectUtil.extendShape<{
|
|
11
12
|
index: z.ZodOptional<z.ZodNumber>;
|
|
12
13
|
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
14
|
+
}, {
|
|
13
15
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
14
|
-
}
|
|
16
|
+
}>, "strip", z.ZodTypeAny, {
|
|
15
17
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
-
index?: number | undefined;
|
|
17
18
|
value?: any;
|
|
19
|
+
index?: number | undefined;
|
|
18
20
|
}, {
|
|
19
21
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
-
index?: number | undefined;
|
|
21
22
|
value?: any;
|
|
23
|
+
index?: number | undefined;
|
|
22
24
|
}>;
|
|
23
|
-
}
|
|
25
|
+
}>, "strip", z.ZodTypeAny, {
|
|
24
26
|
conditionType: "json-api";
|
|
25
|
-
endpoint: string;
|
|
26
27
|
returnValueTest: {
|
|
27
28
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
28
|
-
index?: number | undefined;
|
|
29
29
|
value?: any;
|
|
30
|
+
index?: number | undefined;
|
|
30
31
|
};
|
|
32
|
+
endpoint: string;
|
|
31
33
|
parameters?: Record<string, unknown> | undefined;
|
|
32
34
|
query?: string | undefined;
|
|
33
35
|
authorizationToken?: string | undefined;
|
|
34
36
|
}, {
|
|
35
|
-
endpoint: string;
|
|
36
37
|
returnValueTest: {
|
|
37
38
|
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
38
|
-
index?: number | undefined;
|
|
39
39
|
value?: any;
|
|
40
|
+
index?: number | undefined;
|
|
40
41
|
};
|
|
42
|
+
endpoint: string;
|
|
41
43
|
conditionType?: "json-api" | undefined;
|
|
42
44
|
parameters?: Record<string, unknown> | undefined;
|
|
43
45
|
query?: string | undefined;
|
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonApiConditionSchema = exports.
|
|
4
|
-
const jsonpath_1 = require("@astronautlabs/jsonpath");
|
|
3
|
+
exports.jsonApiConditionSchema = exports.JsonApiConditionType = void 0;
|
|
5
4
|
const zod_1 = require("zod");
|
|
6
|
-
const
|
|
5
|
+
const common_1 = require("./common");
|
|
7
6
|
const context_1 = require("./context");
|
|
8
7
|
const return_value_test_1 = require("./return-value-test");
|
|
9
8
|
exports.JsonApiConditionType = 'json-api';
|
|
10
|
-
|
|
11
|
-
// account for embedded context variables
|
|
12
|
-
if (const_1.CONTEXT_PARAM_REGEXP.test(jsonPath)) {
|
|
13
|
-
// skip validation
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
jsonpath_1.JSONPath.parse(jsonPath);
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.jsonPathSchema = zod_1.z
|
|
25
|
-
.string()
|
|
26
|
-
.refine((val) => validateJSONPath(val), {
|
|
27
|
-
message: 'Invalid JSONPath expression',
|
|
28
|
-
});
|
|
29
|
-
exports.jsonApiConditionSchema = zod_1.z.object({
|
|
9
|
+
exports.jsonApiConditionSchema = common_1.baseConditionSchema.extend({
|
|
30
10
|
conditionType: zod_1.z.literal(exports.JsonApiConditionType).default(exports.JsonApiConditionType),
|
|
31
|
-
endpoint:
|
|
11
|
+
endpoint: common_1.httpsURLSchema,
|
|
32
12
|
parameters: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
33
|
-
query:
|
|
13
|
+
query: common_1.jsonPathSchema.optional(),
|
|
34
14
|
authorizationToken: context_1.contextParamSchema.optional(),
|
|
35
15
|
returnValueTest: return_value_test_1.returnValueTestSchema, // Update to allow multiple return values after expanding supported methods
|
|
36
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-api.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-api.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qCAA+E;AAC/E,uCAA+C;AAC/C,2DAA4D;AAE/C,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAElC,QAAA,sBAAsB,GAAG,4BAAmB,CAAC,MAAM,CAAC;IAC/D,aAAa,EAAE,OAAC,CAAC,OAAO,CAAC,4BAAoB,CAAC,CAAC,OAAO,CAAC,4BAAoB,CAAC;IAC5E,QAAQ,EAAE,uBAAc;IACxB,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxD,KAAK,EAAE,uBAAc,CAAC,QAAQ,EAAE;IAChC,kBAAkB,EAAE,4BAAkB,CAAC,QAAQ,EAAE;IACjD,eAAe,EAAE,yCAAqB,EAAE,2EAA2E;CACpH,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const JsonRpcConditionType = "json-rpc";
|
|
3
|
+
export declare const jsonRpcConditionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
|
+
conditionType: z.ZodString;
|
|
5
|
+
}, {
|
|
6
|
+
conditionType: z.ZodDefault<z.ZodLiteral<"json-rpc">>;
|
|
7
|
+
endpoint: z.ZodEffects<z.ZodString, string, string>;
|
|
8
|
+
method: z.ZodString;
|
|
9
|
+
params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
10
|
+
query: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
|
+
authorizationToken: z.ZodOptional<z.ZodString>;
|
|
12
|
+
returnValueTest: z.ZodObject<z.objectUtil.extendShape<{
|
|
13
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
15
|
+
}, {
|
|
16
|
+
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
17
|
+
}>, "strip", z.ZodTypeAny, {
|
|
18
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
19
|
+
value?: any;
|
|
20
|
+
index?: number | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
23
|
+
value?: any;
|
|
24
|
+
index?: number | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
}>, "strip", z.ZodTypeAny, {
|
|
27
|
+
conditionType: "json-rpc";
|
|
28
|
+
method: string;
|
|
29
|
+
returnValueTest: {
|
|
30
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
31
|
+
value?: any;
|
|
32
|
+
index?: number | undefined;
|
|
33
|
+
};
|
|
34
|
+
endpoint: string;
|
|
35
|
+
params?: unknown[] | Record<string, unknown> | undefined;
|
|
36
|
+
query?: string | undefined;
|
|
37
|
+
authorizationToken?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
method: string;
|
|
40
|
+
returnValueTest: {
|
|
41
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
42
|
+
value?: any;
|
|
43
|
+
index?: number | undefined;
|
|
44
|
+
};
|
|
45
|
+
endpoint: string;
|
|
46
|
+
params?: unknown[] | Record<string, unknown> | undefined;
|
|
47
|
+
conditionType?: "json-rpc" | undefined;
|
|
48
|
+
query?: string | undefined;
|
|
49
|
+
authorizationToken?: string | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export type JsonRpcConditionProps = z.infer<typeof jsonRpcConditionSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jsonRpcConditionSchema = exports.JsonRpcConditionType = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const context_1 = require("./context");
|
|
7
|
+
const return_value_test_1 = require("./return-value-test");
|
|
8
|
+
exports.JsonRpcConditionType = 'json-rpc';
|
|
9
|
+
exports.jsonRpcConditionSchema = common_1.baseConditionSchema.extend({
|
|
10
|
+
conditionType: zod_1.z.literal(exports.JsonRpcConditionType).default(exports.JsonRpcConditionType),
|
|
11
|
+
endpoint: common_1.httpsURLSchema,
|
|
12
|
+
method: zod_1.z.string(),
|
|
13
|
+
// list or dictionary
|
|
14
|
+
params: zod_1.z
|
|
15
|
+
.union([zod_1.z.array(zod_1.z.unknown()), zod_1.z.record(zod_1.z.string(), zod_1.z.unknown())])
|
|
16
|
+
.optional(),
|
|
17
|
+
query: common_1.jsonPathSchema.optional(),
|
|
18
|
+
authorizationToken: context_1.contextParamSchema.optional(),
|
|
19
|
+
returnValueTest: return_value_test_1.returnValueTestSchema,
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=json-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-rpc.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qCAA+E;AAC/E,uCAA+C;AAC/C,2DAA4D;AAE/C,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAElC,QAAA,sBAAsB,GAAG,4BAAmB,CAAC,MAAM,CAAC;IAC/D,aAAa,EAAE,OAAC,CAAC,OAAO,CAAC,4BAAoB,CAAC,CAAC,OAAO,CAAC,4BAAoB,CAAC;IAC5E,QAAQ,EAAE,uBAAc;IACxB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,qBAAqB;IACrB,MAAM,EAAE,OAAC;SACN,KAAK,CAAC,CAAC,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;SAChE,QAAQ,EAAE;IACb,KAAK,EAAE,uBAAc,CAAC,QAAQ,EAAE;IAChC,kBAAkB,EAAE,4BAAkB,CAAC,QAAQ,EAAE;IACjD,eAAe,EAAE,yCAAqB;CACvC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const JWT_PARAM_DEFAULT = ":jwtToken";
|
|
3
|
+
export declare const JWTConditionType = "jwt";
|
|
4
|
+
export declare const jwtConditionSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
5
|
+
conditionType: z.ZodString;
|
|
6
|
+
}, {
|
|
7
|
+
conditionType: z.ZodDefault<z.ZodLiteral<"jwt">>;
|
|
8
|
+
publicKey: z.ZodString;
|
|
9
|
+
expectedIssuer: z.ZodOptional<z.ZodString>;
|
|
10
|
+
jwtToken: z.ZodDefault<z.ZodString>;
|
|
11
|
+
}>, "strip", z.ZodTypeAny, {
|
|
12
|
+
conditionType: "jwt";
|
|
13
|
+
publicKey: string;
|
|
14
|
+
jwtToken: string;
|
|
15
|
+
expectedIssuer?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
publicKey: string;
|
|
18
|
+
conditionType?: "jwt" | undefined;
|
|
19
|
+
expectedIssuer?: string | undefined;
|
|
20
|
+
jwtToken?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type JWTConditionProps = z.infer<typeof jwtConditionSchema>;
|