@nucypher/taco 0.6.0 → 0.7.0-alpha.1
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/dist/cjs/conditions/base/address-allowlist.d.ts +10 -0
- package/dist/cjs/conditions/base/address-allowlist.js +19 -0
- package/dist/cjs/conditions/base/address-allowlist.js.map +1 -0
- package/dist/cjs/conditions/base/ecdsa.d.ts +7 -0
- package/dist/cjs/conditions/base/ecdsa.js +21 -0
- package/dist/cjs/conditions/base/ecdsa.js.map +1 -0
- package/dist/cjs/conditions/base/index.d.ts +3 -0
- package/dist/cjs/conditions/base/index.js +4 -1
- package/dist/cjs/conditions/base/index.js.map +1 -1
- package/dist/cjs/conditions/base/signing.d.ts +10 -0
- package/dist/cjs/conditions/base/signing.js +32 -0
- package/dist/cjs/conditions/base/signing.js.map +1 -0
- package/dist/cjs/conditions/condition-factory.js +11 -0
- package/dist/cjs/conditions/condition-factory.js.map +1 -1
- package/dist/cjs/conditions/context/context.d.ts +4 -0
- package/dist/cjs/conditions/context/context.js +28 -3
- package/dist/cjs/conditions/context/context.js.map +1 -1
- package/dist/cjs/conditions/schemas/address-allowlist.d.ts +16 -0
- package/dist/cjs/conditions/schemas/address-allowlist.js +20 -0
- package/dist/cjs/conditions/schemas/address-allowlist.js.map +1 -0
- package/dist/cjs/conditions/schemas/common.d.ts +2 -0
- package/dist/cjs/conditions/schemas/common.js +20 -3
- package/dist/cjs/conditions/schemas/common.js.map +1 -1
- package/dist/cjs/conditions/schemas/contract.d.ts +33 -30
- package/dist/cjs/conditions/schemas/ecdsa.d.ts +38 -0
- package/dist/cjs/conditions/schemas/ecdsa.js +40 -0
- package/dist/cjs/conditions/schemas/ecdsa.js.map +1 -0
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.d.ts +3 -0
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js +4 -0
- package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js.map +1 -1
- package/dist/cjs/conditions/schemas/json-api.d.ts +47 -14
- package/dist/cjs/conditions/schemas/json-api.js +16 -2
- package/dist/cjs/conditions/schemas/json-api.js.map +1 -1
- package/dist/cjs/conditions/schemas/json-rpc.d.ts +48 -13
- package/dist/cjs/conditions/schemas/json-rpc.js +16 -2
- package/dist/cjs/conditions/schemas/json-rpc.js.map +1 -1
- package/dist/cjs/conditions/schemas/jwt.d.ts +2 -4
- package/dist/cjs/conditions/schemas/return-value-test.d.ts +28 -12
- package/dist/cjs/conditions/schemas/return-value-test.js +19 -5
- package/dist/cjs/conditions/schemas/return-value-test.js.map +1 -1
- package/dist/cjs/conditions/schemas/rpc.d.ts +22 -16
- package/dist/cjs/conditions/schemas/sequential.js +31 -11
- package/dist/cjs/conditions/schemas/sequential.js.map +1 -1
- package/dist/cjs/conditions/schemas/signing.d.ts +12 -0
- package/dist/cjs/conditions/schemas/signing.js +204 -0
- package/dist/cjs/conditions/schemas/signing.js.map +1 -0
- package/dist/cjs/conditions/schemas/time.d.ts +18 -10
- package/dist/cjs/conditions/schemas/utils.js +8 -1
- package/dist/cjs/conditions/schemas/utils.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sign.d.ts +26 -0
- package/dist/cjs/sign.js +99 -0
- package/dist/cjs/sign.js.map +1 -0
- package/dist/cjs/types.d.ts +1 -0
- package/dist/es/conditions/base/address-allowlist.d.ts +10 -0
- package/dist/es/conditions/base/address-allowlist.js +15 -0
- package/dist/es/conditions/base/address-allowlist.js.map +1 -0
- package/dist/es/conditions/base/ecdsa.d.ts +7 -0
- package/dist/es/conditions/base/ecdsa.js +12 -0
- package/dist/es/conditions/base/ecdsa.js.map +1 -0
- package/dist/es/conditions/base/index.d.ts +3 -0
- package/dist/es/conditions/base/index.js +3 -0
- package/dist/es/conditions/base/index.js.map +1 -1
- package/dist/es/conditions/base/signing.d.ts +10 -0
- package/dist/es/conditions/base/signing.js +20 -0
- package/dist/es/conditions/base/signing.js.map +1 -0
- package/dist/es/conditions/condition-factory.js +11 -0
- package/dist/es/conditions/condition-factory.js.map +1 -1
- package/dist/es/conditions/context/context.d.ts +4 -0
- package/dist/es/conditions/context/context.js +27 -2
- package/dist/es/conditions/context/context.js.map +1 -1
- package/dist/es/conditions/schemas/address-allowlist.d.ts +16 -0
- package/dist/es/conditions/schemas/address-allowlist.js +17 -0
- package/dist/es/conditions/schemas/address-allowlist.js.map +1 -0
- package/dist/es/conditions/schemas/common.d.ts +2 -0
- package/dist/es/conditions/schemas/common.js +19 -2
- package/dist/es/conditions/schemas/common.js.map +1 -1
- package/dist/es/conditions/schemas/contract.d.ts +33 -30
- package/dist/es/conditions/schemas/ecdsa.d.ts +38 -0
- package/dist/es/conditions/schemas/ecdsa.js +37 -0
- package/dist/es/conditions/schemas/ecdsa.js.map +1 -0
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.d.ts +3 -0
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.js +4 -0
- package/dist/es/conditions/schemas/export-for-zod-doc-gen.js.map +1 -1
- package/dist/es/conditions/schemas/json-api.d.ts +47 -14
- package/dist/es/conditions/schemas/json-api.js +17 -3
- package/dist/es/conditions/schemas/json-api.js.map +1 -1
- package/dist/es/conditions/schemas/json-rpc.d.ts +48 -13
- package/dist/es/conditions/schemas/json-rpc.js +17 -3
- package/dist/es/conditions/schemas/json-rpc.js.map +1 -1
- package/dist/es/conditions/schemas/jwt.d.ts +2 -4
- package/dist/es/conditions/schemas/return-value-test.d.ts +28 -12
- package/dist/es/conditions/schemas/return-value-test.js +19 -5
- package/dist/es/conditions/schemas/return-value-test.js.map +1 -1
- package/dist/es/conditions/schemas/rpc.d.ts +22 -16
- package/dist/es/conditions/schemas/sequential.js +31 -11
- package/dist/es/conditions/schemas/sequential.js.map +1 -1
- package/dist/es/conditions/schemas/signing.d.ts +12 -0
- package/dist/es/conditions/schemas/signing.js +201 -0
- package/dist/es/conditions/schemas/signing.js.map +1 -0
- package/dist/es/conditions/schemas/time.d.ts +18 -10
- package/dist/es/conditions/schemas/utils.js +8 -1
- package/dist/es/conditions/schemas/utils.js.map +1 -1
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/sign.d.ts +26 -0
- package/dist/es/sign.js +95 -0
- package/dist/es/sign.js.map +1 -0
- package/dist/es/types.d.ts +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.es.tsbuildinfo +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ecdsaConditionSchema = exports.SUPPORTED_ECDSA_CURVES = exports.ECDSAConditionType = exports.ECDSA_SIGNATURE_PARAM_DEFAULT = exports.ECDSA_MESSAGE_PARAM_DEFAULT = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const context_1 = require("./context");
|
|
7
|
+
exports.ECDSA_MESSAGE_PARAM_DEFAULT = ':message';
|
|
8
|
+
exports.ECDSA_SIGNATURE_PARAM_DEFAULT = ':signature';
|
|
9
|
+
exports.ECDSAConditionType = 'ecdsa';
|
|
10
|
+
exports.SUPPORTED_ECDSA_CURVES = [
|
|
11
|
+
'SECP256k1',
|
|
12
|
+
'NIST256p',
|
|
13
|
+
'NIST384p',
|
|
14
|
+
'NIST521p',
|
|
15
|
+
'Ed25519',
|
|
16
|
+
'BRAINPOOLP256r1',
|
|
17
|
+
];
|
|
18
|
+
exports.ecdsaConditionSchema = common_1.baseConditionSchema
|
|
19
|
+
.extend({
|
|
20
|
+
conditionType: zod_1.z.literal(exports.ECDSAConditionType).default(exports.ECDSAConditionType),
|
|
21
|
+
message: zod_1.z
|
|
22
|
+
.union([zod_1.z.string(), context_1.contextParamSchema])
|
|
23
|
+
.default(exports.ECDSA_MESSAGE_PARAM_DEFAULT),
|
|
24
|
+
signature: zod_1.z
|
|
25
|
+
.union([common_1.hexStringSchema, context_1.contextParamSchema])
|
|
26
|
+
.default(exports.ECDSA_SIGNATURE_PARAM_DEFAULT),
|
|
27
|
+
verifyingKey: common_1.hexStringSchema,
|
|
28
|
+
curve: zod_1.z.enum(exports.SUPPORTED_ECDSA_CURVES),
|
|
29
|
+
})
|
|
30
|
+
.refine((data) => {
|
|
31
|
+
// ensure that if message starts with 0x that it is valid hex
|
|
32
|
+
if (data.message.startsWith('0x'))
|
|
33
|
+
return common_1.hexStringSchema.safeParse(data.message.slice(2)).success;
|
|
34
|
+
return true;
|
|
35
|
+
}, {
|
|
36
|
+
message: 'Message must be a valid hex string if it starts with "0x"',
|
|
37
|
+
path: ['message'],
|
|
38
|
+
})
|
|
39
|
+
.describe('ECDSA Condition for verifying the authenticity of a message using ECDSA signatures.');
|
|
40
|
+
//# sourceMappingURL=ecdsa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecdsa.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/ecdsa.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qCAAgE;AAChE,uCAA+C;AAElC,QAAA,2BAA2B,GAAG,UAAU,CAAC;AACzC,QAAA,6BAA6B,GAAG,YAAY,CAAC;AAE7C,QAAA,kBAAkB,GAAG,OAAO,CAAC;AAE7B,QAAA,sBAAsB,GAAG;IACpC,WAAW;IACX,UAAU;IACV,UAAU;IACV,UAAU;IACV,SAAS;IACT,iBAAiB;CACT,CAAC;AAIE,QAAA,oBAAoB,GAAG,4BAAmB;KACpD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC,CAAC,OAAO,CAAC,0BAAkB,CAAC,CAAC,OAAO,CAAC,0BAAkB,CAAC;IACxE,OAAO,EAAE,OAAC;SACP,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,4BAAkB,CAAC,CAAC;SACvC,OAAO,CAAC,mCAA2B,CAAC;IACvC,SAAS,EAAE,OAAC;SACT,KAAK,CAAC,CAAC,wBAAe,EAAE,4BAAkB,CAAC,CAAC;SAC5C,OAAO,CAAC,qCAA6B,CAAC;IACzC,YAAY,EAAE,wBAAe;IAC7B,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,8BAAsB,CAAC;CACtC,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE;IACP,6DAA6D;IAC7D,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;QAC/B,OAAO,wBAAe,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAClE,OAAO,IAAI,CAAC;AACd,CAAC,EACD;IACE,OAAO,EAAE,2DAA2D;IACpE,IAAI,EAAE,CAAC,SAAS,CAAC;CAClB,CACF;KACA,QAAQ,CACP,qFAAqF,CACtF,CAAC"}
|
|
@@ -8,6 +8,7 @@ export * from './common';
|
|
|
8
8
|
export * from './context';
|
|
9
9
|
export * from './compound';
|
|
10
10
|
export * from './contract';
|
|
11
|
+
export * from './ecdsa';
|
|
11
12
|
export * from './if-then-else';
|
|
12
13
|
export * from './json-api';
|
|
13
14
|
export * from './json-rpc';
|
|
@@ -15,4 +16,6 @@ export * from './jwt';
|
|
|
15
16
|
export * from './return-value-test';
|
|
16
17
|
export * from './rpc';
|
|
17
18
|
export * from './sequential';
|
|
19
|
+
export * from './signing';
|
|
18
20
|
export * from './time';
|
|
21
|
+
export * from './address-allowlist';
|
|
@@ -26,6 +26,7 @@ __exportStar(require("./context"), exports);
|
|
|
26
26
|
// ts-unused-exports:disable-next-line - this comment line is added to prevent lint from changing or objecting the export order.
|
|
27
27
|
__exportStar(require("./compound"), exports);
|
|
28
28
|
__exportStar(require("./contract"), exports);
|
|
29
|
+
__exportStar(require("./ecdsa"), exports);
|
|
29
30
|
__exportStar(require("./if-then-else"), exports);
|
|
30
31
|
__exportStar(require("./json-api"), exports);
|
|
31
32
|
__exportStar(require("./json-rpc"), exports);
|
|
@@ -33,5 +34,8 @@ __exportStar(require("./jwt"), exports);
|
|
|
33
34
|
__exportStar(require("./return-value-test"), exports);
|
|
34
35
|
__exportStar(require("./rpc"), exports);
|
|
35
36
|
__exportStar(require("./sequential"), exports);
|
|
37
|
+
__exportStar(require("./signing"), exports);
|
|
36
38
|
__exportStar(require("./time"), exports);
|
|
39
|
+
// ts-unused-exports:disable-next-line - this comment line is added to prevent lint from changing or objecting the export order.
|
|
40
|
+
__exportStar(require("./address-allowlist"), exports);
|
|
37
41
|
//# sourceMappingURL=export-for-zod-doc-gen.js.map
|
|
@@ -1 +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
|
+
{"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,0CAAwB;AACxB,iDAA+B;AAC/B,6CAA2B;AAC3B,6CAA2B;AAC3B,wCAAsB;AACtB,sDAAoC;AACpC,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B;AAC1B,yCAAuB;AACvB,gIAAgI;AAChI,sDAAoC"}
|
|
@@ -1,48 +1,81 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const JsonApiConditionType = "json-api";
|
|
3
|
-
export declare const jsonApiConditionSchema: z.
|
|
4
|
-
conditionType: z.ZodString;
|
|
5
|
-
}, {
|
|
3
|
+
export declare const jsonApiConditionSchema: z.ZodEffects<z.ZodObject<{} & {
|
|
6
4
|
conditionType: z.ZodDefault<z.ZodLiteral<"json-api">>;
|
|
7
5
|
endpoint: z.ZodEffects<z.ZodString, string, string>;
|
|
8
6
|
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
9
7
|
query: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
10
8
|
authorizationToken: z.ZodOptional<z.ZodString>;
|
|
11
|
-
|
|
9
|
+
authorizationType: z.ZodOptional<z.ZodEnum<["Bearer", "Basic", "X-API-Key"]>>;
|
|
10
|
+
returnValueTest: z.ZodEffects<z.ZodObject<{
|
|
12
11
|
index: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
14
|
-
}
|
|
12
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!=", "in", "!in"]>;
|
|
13
|
+
} & {
|
|
15
14
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
16
|
-
}
|
|
17
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
17
|
+
value?: any;
|
|
18
|
+
index?: number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
21
|
+
value?: any;
|
|
22
|
+
index?: number | undefined;
|
|
23
|
+
}>, {
|
|
24
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
18
25
|
value?: any;
|
|
19
26
|
index?: number | undefined;
|
|
20
27
|
}, {
|
|
21
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
28
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
22
29
|
value?: any;
|
|
23
30
|
index?: number | undefined;
|
|
24
31
|
}>;
|
|
25
|
-
}
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
33
|
conditionType: "json-api";
|
|
34
|
+
endpoint: string;
|
|
27
35
|
returnValueTest: {
|
|
28
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
36
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
29
37
|
value?: any;
|
|
30
38
|
index?: number | undefined;
|
|
31
39
|
};
|
|
40
|
+
query?: string | undefined;
|
|
41
|
+
authorizationToken?: string | undefined;
|
|
42
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
43
|
+
parameters?: Record<string, unknown> | undefined;
|
|
44
|
+
}, {
|
|
32
45
|
endpoint: string;
|
|
46
|
+
returnValueTest: {
|
|
47
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
48
|
+
value?: any;
|
|
49
|
+
index?: number | undefined;
|
|
50
|
+
};
|
|
51
|
+
conditionType?: "json-api" | undefined;
|
|
52
|
+
query?: string | undefined;
|
|
53
|
+
authorizationToken?: string | undefined;
|
|
54
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
33
55
|
parameters?: Record<string, unknown> | undefined;
|
|
56
|
+
}>, {
|
|
57
|
+
conditionType: "json-api";
|
|
58
|
+
endpoint: string;
|
|
59
|
+
returnValueTest: {
|
|
60
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
61
|
+
value?: any;
|
|
62
|
+
index?: number | undefined;
|
|
63
|
+
};
|
|
34
64
|
query?: string | undefined;
|
|
35
65
|
authorizationToken?: string | undefined;
|
|
66
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
67
|
+
parameters?: Record<string, unknown> | undefined;
|
|
36
68
|
}, {
|
|
69
|
+
endpoint: string;
|
|
37
70
|
returnValueTest: {
|
|
38
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
71
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
39
72
|
value?: any;
|
|
40
73
|
index?: number | undefined;
|
|
41
74
|
};
|
|
42
|
-
endpoint: string;
|
|
43
75
|
conditionType?: "json-api" | undefined;
|
|
44
|
-
parameters?: Record<string, unknown> | undefined;
|
|
45
76
|
query?: string | undefined;
|
|
46
77
|
authorizationToken?: string | undefined;
|
|
78
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
79
|
+
parameters?: Record<string, unknown> | undefined;
|
|
47
80
|
}>;
|
|
48
81
|
export type JsonApiConditionProps = z.infer<typeof jsonApiConditionSchema>;
|
|
@@ -6,12 +6,26 @@ const common_1 = require("./common");
|
|
|
6
6
|
const context_1 = require("./context");
|
|
7
7
|
const return_value_test_1 = require("./return-value-test");
|
|
8
8
|
exports.JsonApiConditionType = 'json-api';
|
|
9
|
-
exports.jsonApiConditionSchema = common_1.baseConditionSchema
|
|
10
|
-
|
|
9
|
+
exports.jsonApiConditionSchema = common_1.baseConditionSchema
|
|
10
|
+
.extend({
|
|
11
|
+
conditionType: zod_1.z
|
|
12
|
+
.literal(exports.JsonApiConditionType)
|
|
13
|
+
.default(exports.JsonApiConditionType),
|
|
11
14
|
endpoint: common_1.httpsURLSchema,
|
|
12
15
|
parameters: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
13
16
|
query: common_1.jsonPathSchema.optional(),
|
|
14
17
|
authorizationToken: context_1.contextParamSchema.optional(),
|
|
18
|
+
authorizationType: common_1.jsonAuthorizationTypeSchema.optional(),
|
|
15
19
|
returnValueTest: return_value_test_1.returnValueTestSchema, // Update to allow multiple return values after expanding supported methods
|
|
20
|
+
})
|
|
21
|
+
.refine((data) => {
|
|
22
|
+
// Ensure that if authorizationType is provided, then authorizationToken is set
|
|
23
|
+
if (data.authorizationType && !data.authorizationToken) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}, {
|
|
28
|
+
message: 'authorizationToken must be provided if authorizationType is set',
|
|
29
|
+
path: ['authorizationType'],
|
|
16
30
|
});
|
|
17
31
|
//# sourceMappingURL=json-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-api.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"json-api.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-api.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qCAKkB;AAClB,uCAA+C;AAC/C,2DAA4D;AAE/C,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAElC,QAAA,sBAAsB,GAAG,4BAAmB;KACtD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SACb,OAAO,CAAC,4BAAoB,CAAC;SAC7B,OAAO,CAAC,4BAAoB,CAAC;IAChC,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,iBAAiB,EAAE,oCAA2B,CAAC,QAAQ,EAAE;IACzD,eAAe,EAAE,yCAAqB,EAAE,2EAA2E;CACpH,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE;IACP,+EAA+E;IAC/E,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,EACD;IACE,OAAO,EACL,iEAAiE;IACnE,IAAI,EAAE,CAAC,mBAAmB,CAAC;CAC5B,CACF,CAAC"}
|
|
@@ -1,51 +1,86 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const JsonRpcConditionType = "json-rpc";
|
|
3
|
-
export declare const jsonRpcConditionSchema: z.
|
|
4
|
-
conditionType: z.ZodString;
|
|
5
|
-
}, {
|
|
3
|
+
export declare const jsonRpcConditionSchema: z.ZodEffects<z.ZodObject<{} & {
|
|
6
4
|
conditionType: z.ZodDefault<z.ZodLiteral<"json-rpc">>;
|
|
7
5
|
endpoint: z.ZodEffects<z.ZodString, string, string>;
|
|
8
6
|
method: z.ZodString;
|
|
9
7
|
params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
10
8
|
query: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
11
9
|
authorizationToken: z.ZodOptional<z.ZodString>;
|
|
12
|
-
|
|
10
|
+
authorizationType: z.ZodOptional<z.ZodEnum<["Bearer", "Basic", "X-API-Key"]>>;
|
|
11
|
+
returnValueTest: z.ZodEffects<z.ZodObject<{
|
|
13
12
|
index: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
15
|
-
}
|
|
13
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!=", "in", "!in"]>;
|
|
14
|
+
} & {
|
|
16
15
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
17
|
-
}
|
|
18
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
18
|
+
value?: any;
|
|
19
|
+
index?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
22
|
+
value?: any;
|
|
23
|
+
index?: number | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
19
26
|
value?: any;
|
|
20
27
|
index?: number | undefined;
|
|
21
28
|
}, {
|
|
22
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
29
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
23
30
|
value?: any;
|
|
24
31
|
index?: number | undefined;
|
|
25
32
|
}>;
|
|
26
|
-
}
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
34
|
conditionType: "json-rpc";
|
|
35
|
+
endpoint: string;
|
|
28
36
|
method: string;
|
|
29
37
|
returnValueTest: {
|
|
30
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
38
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
31
39
|
value?: any;
|
|
32
40
|
index?: number | undefined;
|
|
33
41
|
};
|
|
34
|
-
endpoint: string;
|
|
35
42
|
params?: unknown[] | Record<string, unknown> | undefined;
|
|
36
43
|
query?: string | undefined;
|
|
37
44
|
authorizationToken?: string | undefined;
|
|
45
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
38
46
|
}, {
|
|
47
|
+
endpoint: string;
|
|
48
|
+
method: string;
|
|
49
|
+
returnValueTest: {
|
|
50
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
51
|
+
value?: any;
|
|
52
|
+
index?: number | undefined;
|
|
53
|
+
};
|
|
54
|
+
params?: unknown[] | Record<string, unknown> | undefined;
|
|
55
|
+
conditionType?: "json-rpc" | undefined;
|
|
56
|
+
query?: string | undefined;
|
|
57
|
+
authorizationToken?: string | undefined;
|
|
58
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
59
|
+
}>, {
|
|
60
|
+
conditionType: "json-rpc";
|
|
61
|
+
endpoint: string;
|
|
39
62
|
method: string;
|
|
40
63
|
returnValueTest: {
|
|
41
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
64
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
42
65
|
value?: any;
|
|
43
66
|
index?: number | undefined;
|
|
44
67
|
};
|
|
68
|
+
params?: unknown[] | Record<string, unknown> | undefined;
|
|
69
|
+
query?: string | undefined;
|
|
70
|
+
authorizationToken?: string | undefined;
|
|
71
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
72
|
+
}, {
|
|
45
73
|
endpoint: string;
|
|
74
|
+
method: string;
|
|
75
|
+
returnValueTest: {
|
|
76
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
77
|
+
value?: any;
|
|
78
|
+
index?: number | undefined;
|
|
79
|
+
};
|
|
46
80
|
params?: unknown[] | Record<string, unknown> | undefined;
|
|
47
81
|
conditionType?: "json-rpc" | undefined;
|
|
48
82
|
query?: string | undefined;
|
|
49
83
|
authorizationToken?: string | undefined;
|
|
84
|
+
authorizationType?: "Bearer" | "Basic" | "X-API-Key" | undefined;
|
|
50
85
|
}>;
|
|
51
86
|
export type JsonRpcConditionProps = z.infer<typeof jsonRpcConditionSchema>;
|
|
@@ -6,8 +6,11 @@ const common_1 = require("./common");
|
|
|
6
6
|
const context_1 = require("./context");
|
|
7
7
|
const return_value_test_1 = require("./return-value-test");
|
|
8
8
|
exports.JsonRpcConditionType = 'json-rpc';
|
|
9
|
-
exports.jsonRpcConditionSchema = common_1.baseConditionSchema
|
|
10
|
-
|
|
9
|
+
exports.jsonRpcConditionSchema = common_1.baseConditionSchema
|
|
10
|
+
.extend({
|
|
11
|
+
conditionType: zod_1.z
|
|
12
|
+
.literal(exports.JsonRpcConditionType)
|
|
13
|
+
.default(exports.JsonRpcConditionType),
|
|
11
14
|
endpoint: common_1.httpsURLSchema,
|
|
12
15
|
method: zod_1.z.string(),
|
|
13
16
|
// list or dictionary
|
|
@@ -16,6 +19,17 @@ exports.jsonRpcConditionSchema = common_1.baseConditionSchema.extend({
|
|
|
16
19
|
.optional(),
|
|
17
20
|
query: common_1.jsonPathSchema.optional(),
|
|
18
21
|
authorizationToken: context_1.contextParamSchema.optional(),
|
|
22
|
+
authorizationType: common_1.jsonAuthorizationTypeSchema.optional(),
|
|
19
23
|
returnValueTest: return_value_test_1.returnValueTestSchema,
|
|
24
|
+
})
|
|
25
|
+
.refine((data) => {
|
|
26
|
+
// Ensure that if authorizationType is provided, then authorizationToken is set
|
|
27
|
+
if (data.authorizationType && !data.authorizationToken) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
}, {
|
|
32
|
+
message: 'authorizationToken must be provided if authorizationType is set',
|
|
33
|
+
path: ['authorizationType'],
|
|
20
34
|
});
|
|
21
35
|
//# sourceMappingURL=json-rpc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-rpc.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/json-rpc.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qCAKkB;AAClB,uCAA+C;AAC/C,2DAA4D;AAE/C,QAAA,oBAAoB,GAAG,UAAU,CAAC;AAElC,QAAA,sBAAsB,GAAG,4BAAmB;KACtD,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SACb,OAAO,CAAC,4BAAoB,CAAC;SAC7B,OAAO,CAAC,4BAAoB,CAAC;IAChC,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,iBAAiB,EAAE,oCAA2B,CAAC,QAAQ,EAAE;IACzD,eAAe,EAAE,yCAAqB;CACvC,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE;IACP,+EAA+E;IAC/E,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,EACD;IACE,OAAO,EACL,iEAAiE;IACnE,IAAI,EAAE,CAAC,mBAAmB,CAAC;CAC5B,CACF,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const JWT_PARAM_DEFAULT = ":jwtToken";
|
|
3
3
|
export declare const JWTConditionType = "jwt";
|
|
4
|
-
export declare const jwtConditionSchema: z.ZodObject<
|
|
5
|
-
conditionType: z.ZodString;
|
|
6
|
-
}, {
|
|
4
|
+
export declare const jwtConditionSchema: z.ZodObject<{} & {
|
|
7
5
|
conditionType: z.ZodDefault<z.ZodLiteral<"jwt">>;
|
|
8
6
|
publicKey: z.ZodString;
|
|
9
7
|
expectedIssuer: z.ZodOptional<z.ZodString>;
|
|
10
8
|
jwtToken: z.ZodDefault<z.ZodString>;
|
|
11
|
-
}
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
10
|
conditionType: "jwt";
|
|
13
11
|
publicKey: string;
|
|
14
12
|
jwtToken: string;
|
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const returnValueTestSchema: z.
|
|
2
|
+
export declare const returnValueTestSchema: z.ZodEffects<z.ZodObject<{
|
|
3
3
|
index: z.ZodOptional<z.ZodNumber>;
|
|
4
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
5
|
-
}
|
|
4
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!=", "in", "!in"]>;
|
|
5
|
+
} & {
|
|
6
6
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
7
|
-
}
|
|
8
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
9
|
+
value?: any;
|
|
10
|
+
index?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
13
|
+
value?: any;
|
|
14
|
+
index?: number | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
9
17
|
value?: any;
|
|
10
18
|
index?: number | undefined;
|
|
11
19
|
}, {
|
|
12
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
20
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
13
21
|
value?: any;
|
|
14
22
|
index?: number | undefined;
|
|
15
23
|
}>;
|
|
16
|
-
export declare const blockchainReturnValueTestSchema: z.
|
|
24
|
+
export declare const blockchainReturnValueTestSchema: z.ZodEffects<z.ZodObject<{
|
|
17
25
|
index: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
19
|
-
}
|
|
26
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!=", "in", "!in"]>;
|
|
27
|
+
} & {
|
|
20
28
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
21
|
-
}
|
|
22
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
31
|
+
value?: any;
|
|
32
|
+
index?: number | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
35
|
+
value?: any;
|
|
36
|
+
index?: number | undefined;
|
|
37
|
+
}>, {
|
|
38
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
23
39
|
value?: any;
|
|
24
40
|
index?: number | undefined;
|
|
25
41
|
}, {
|
|
26
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
42
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
27
43
|
value?: any;
|
|
28
44
|
index?: number | undefined;
|
|
29
45
|
}>;
|
|
@@ -5,12 +5,26 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const context_1 = require("./context");
|
|
6
6
|
const returnValueTestBaseSchema = zod_1.z.object({
|
|
7
7
|
index: zod_1.z.number().int().nonnegative().optional(),
|
|
8
|
-
comparator: zod_1.z.enum(['==', '>', '<', '>=', '<=', '!=']),
|
|
8
|
+
comparator: zod_1.z.enum(['==', '>', '<', '>=', '<=', '!=', 'in', '!in']),
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
const requireNonEmptyArrayIfComparatorIsIn = (data) => {
|
|
11
|
+
if (data.comparator === 'in' || data.comparator === '!in') {
|
|
12
|
+
return Array.isArray(data.value) && data.value.length > 0;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
};
|
|
16
|
+
const inComparatorErrorConfig = {
|
|
17
|
+
message: `"value" must be a non-empty array when comparator is "in"/"!in"`,
|
|
18
|
+
path: ['value'],
|
|
19
|
+
};
|
|
20
|
+
exports.returnValueTestSchema = returnValueTestBaseSchema
|
|
21
|
+
.extend({
|
|
11
22
|
value: context_1.paramOrContextParamSchema,
|
|
12
|
-
})
|
|
13
|
-
|
|
23
|
+
})
|
|
24
|
+
.refine(requireNonEmptyArrayIfComparatorIsIn, inComparatorErrorConfig);
|
|
25
|
+
exports.blockchainReturnValueTestSchema = returnValueTestBaseSchema
|
|
26
|
+
.extend({
|
|
14
27
|
value: context_1.blockchainParamOrContextParamSchema,
|
|
15
|
-
})
|
|
28
|
+
})
|
|
29
|
+
.refine(requireNonEmptyArrayIfComparatorIsIn, inComparatorErrorConfig);
|
|
16
30
|
//# sourceMappingURL=return-value-test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"return-value-test.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/return-value-test.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,uCAGmB;AAEnB,MAAM,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,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;
|
|
1
|
+
{"version":3,"file":"return-value-test.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/return-value-test.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,uCAGmB;AAEnB,MAAM,yBAAyB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,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,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,oCAAoC,GAAG,CAAC,IAI7C,EAAW,EAAE;IACZ,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,OAAO,EAAE,iEAAiE;IAC1E,IAAI,EAAE,CAAC,OAAO,CAAC;CAChB,CAAC;AAEW,QAAA,qBAAqB,GAAG,yBAAyB;KAC3D,MAAM,CAAC;IACN,KAAK,EAAE,mCAAyB;CACjC,CAAC;KACD,MAAM,CAAC,oCAAoC,EAAE,uBAAuB,CAAC,CAAC;AAE5D,QAAA,+BAA+B,GAAG,yBAAyB;KACrE,MAAM,CAAC;IACN,KAAK,EAAE,6CAAmC;CAC3C,CAAC;KACD,MAAM,CAAC,oCAAoC,EAAE,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const RpcConditionType = "rpc";
|
|
3
|
-
export declare const rpcConditionSchema: z.ZodObject<
|
|
4
|
-
conditionType: z.ZodString;
|
|
5
|
-
}, {
|
|
3
|
+
export declare const rpcConditionSchema: z.ZodObject<{} & {
|
|
6
4
|
conditionType: z.ZodDefault<z.ZodLiteral<"rpc">>;
|
|
7
5
|
chain: z.ZodNumber;
|
|
8
6
|
method: z.ZodEnum<["eth_getBalance"]>;
|
|
9
7
|
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>]>;
|
|
10
|
-
returnValueTest: z.
|
|
8
|
+
returnValueTest: z.ZodEffects<z.ZodObject<{
|
|
11
9
|
index: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!="]>;
|
|
13
|
-
}
|
|
10
|
+
comparator: z.ZodEnum<["==", ">", "<", ">=", "<=", "!=", "in", "!in"]>;
|
|
11
|
+
} & {
|
|
14
12
|
value: z.ZodType<any, z.ZodTypeDef, any>;
|
|
15
|
-
}
|
|
16
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
17
15
|
value?: any;
|
|
18
16
|
index?: number | undefined;
|
|
19
17
|
}, {
|
|
20
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
18
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
19
|
+
value?: any;
|
|
20
|
+
index?: number | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
23
|
+
value?: any;
|
|
24
|
+
index?: number | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
21
27
|
value?: any;
|
|
22
28
|
index?: number | undefined;
|
|
23
29
|
}>;
|
|
24
|
-
}
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
31
|
conditionType: "rpc";
|
|
26
|
-
chain: number;
|
|
27
32
|
method: "eth_getBalance";
|
|
28
|
-
parameters: [string, string | number] | [string];
|
|
29
33
|
returnValueTest: {
|
|
30
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
34
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
31
35
|
value?: any;
|
|
32
36
|
index?: number | undefined;
|
|
33
37
|
};
|
|
34
|
-
|
|
38
|
+
parameters: [string] | [string, string | number];
|
|
35
39
|
chain: number;
|
|
40
|
+
}, {
|
|
36
41
|
method: "eth_getBalance";
|
|
37
|
-
parameters: [string, string | number] | [string];
|
|
38
42
|
returnValueTest: {
|
|
39
|
-
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=";
|
|
43
|
+
comparator: "==" | ">" | "<" | ">=" | "<=" | "!=" | "in" | "!in";
|
|
40
44
|
value?: any;
|
|
41
45
|
index?: number | undefined;
|
|
42
46
|
};
|
|
47
|
+
parameters: [string] | [string, string | number];
|
|
48
|
+
chain: number;
|
|
43
49
|
conditionType?: "rpc" | undefined;
|
|
44
50
|
}>;
|
|
45
51
|
export type RpcConditionProps = z.infer<typeof rpcConditionSchema>;
|
|
@@ -4,7 +4,36 @@ exports.sequentialConditionSchema = exports.conditionVariableSchema = exports.Se
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const multi_condition_1 = require("../multi-condition");
|
|
6
6
|
const common_1 = require("./common");
|
|
7
|
+
const compound_1 = require("./compound");
|
|
8
|
+
const if_then_else_1 = require("./if-then-else");
|
|
7
9
|
const utils_1 = require("./utils");
|
|
10
|
+
const getAllNestedConditionVariableNames = (condition) => {
|
|
11
|
+
const conditionVariables = [];
|
|
12
|
+
if (condition.conditionType === exports.SequentialConditionType) {
|
|
13
|
+
for (const variable of condition.conditionVariables) {
|
|
14
|
+
conditionVariables.push(variable.varName);
|
|
15
|
+
conditionVariables.push(...getAllNestedConditionVariableNames(variable.condition));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (condition.conditionType === if_then_else_1.IfThenElseConditionType) {
|
|
19
|
+
conditionVariables.push(...getAllNestedConditionVariableNames(condition.ifCondition));
|
|
20
|
+
conditionVariables.push(...getAllNestedConditionVariableNames(condition.thenCondition));
|
|
21
|
+
if (typeof condition.elseCondition !== 'boolean') {
|
|
22
|
+
conditionVariables.push(...getAllNestedConditionVariableNames(condition.elseCondition));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (condition.conditionType === compound_1.CompoundConditionType) {
|
|
26
|
+
for (const operand of condition.operands) {
|
|
27
|
+
conditionVariables.push(...getAllNestedConditionVariableNames(operand));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return conditionVariables;
|
|
31
|
+
};
|
|
32
|
+
const noDuplicateVarNames = (condition) => {
|
|
33
|
+
const allVarNames = getAllNestedConditionVariableNames(condition);
|
|
34
|
+
const duplicates = allVarNames.filter((item, index) => allVarNames.indexOf(item) !== index);
|
|
35
|
+
return duplicates.length === 0;
|
|
36
|
+
};
|
|
8
37
|
exports.SequentialConditionType = 'sequential';
|
|
9
38
|
exports.conditionVariableSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
10
39
|
varName: common_1.plainStringSchema,
|
|
@@ -21,17 +50,8 @@ exports.sequentialConditionSchema = common_1.baseConditionSchema
|
|
|
21
50
|
message: 'Exceeded max nested depth of 2 for multi-condition type',
|
|
22
51
|
path: ['conditionVariables'],
|
|
23
52
|
})
|
|
24
|
-
.refine(
|
|
25
|
-
|
|
26
|
-
(condition) => {
|
|
27
|
-
const seen = new Set();
|
|
28
|
-
return condition.conditionVariables.every((child) => {
|
|
29
|
-
if (seen.has(child.varName)) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
seen.add(child.varName);
|
|
33
|
-
return true;
|
|
34
|
-
});
|
|
53
|
+
.refine((condition) => {
|
|
54
|
+
return noDuplicateVarNames(condition);
|
|
35
55
|
}, {
|
|
36
56
|
message: 'Duplicate variable names are not allowed',
|
|
37
57
|
path: ['conditionVariables'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sequential.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/sequential.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;
|
|
1
|
+
{"version":3,"file":"sequential.js","sourceRoot":"","sources":["../../../../src/conditions/schemas/sequential.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAGxB,wDAAoD;AAEpD,qCAAkE;AAClE,yCAAmD;AACnD,iDAAyD;AACzD,mCAA6C;AAE7C,MAAM,kCAAkC,GAAG,CACzC,SAAyB,EACf,EAAE;IACZ,MAAM,kBAAkB,GAAa,EAAE,CAAC;IACxC,IAAI,SAAS,CAAC,aAAa,KAAK,+BAAuB,EAAE,CAAC;QACxD,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC;YACpD,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC1C,kBAAkB,CAAC,IAAI,CACrB,GAAG,kCAAkC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,SAAS,CAAC,aAAa,KAAK,sCAAuB,EAAE,CAAC;QAC/D,kBAAkB,CAAC,IAAI,CACrB,GAAG,kCAAkC,CAAC,SAAS,CAAC,WAAW,CAAC,CAC7D,CAAC;QACF,kBAAkB,CAAC,IAAI,CACrB,GAAG,kCAAkC,CAAC,SAAS,CAAC,aAAa,CAAC,CAC/D,CAAC;QACF,IAAI,OAAO,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACjD,kBAAkB,CAAC,IAAI,CACrB,GAAG,kCAAkC,CAAC,SAAS,CAAC,aAAa,CAAC,CAC/D,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,SAAS,CAAC,aAAa,KAAK,gCAAqB,EAAE,CAAC;QAC7D,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;YACzC,kBAAkB,CAAC,IAAI,CAAC,GAAG,kCAAkC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,SAAyB,EAAW,EAAE;IACjE,MAAM,WAAW,GAAG,kCAAkC,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CACnC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CACrD,CAAC;IACF,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;AACjC,CAAC,CAAC;AAEW,QAAA,uBAAuB,GAAG,YAAY,CAAC;AAEvC,QAAA,uBAAuB,GAAgB,OAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC9D,OAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,0BAAiB;IAC1B,SAAS,EAAE,0BAAkB;CAC9B,CAAC,CACH,CAAC;AAGW,QAAA,yBAAyB,GAAgB,4BAAmB;KACtE,MAAM,CAAC;IACN,aAAa,EAAE,OAAC;SACb,OAAO,CAAC,+BAAuB,CAAC;SAChC,OAAO,CAAC,+BAAuB,CAAC;IACnC,kBAAkB,EAAE,OAAC,CAAC,KAAK,CAAC,+BAAuB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACnE,CAAC;KACD,MAAM,CACL,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,gCAAc,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAC3C;IACE,OAAO,EAAE,yDAAyD;IAClE,IAAI,EAAE,CAAC,oBAAoB,CAAC;CAC7B,CACF;KACA,MAAM,CACL,CAAC,SAAS,EAAE,EAAE;IACZ,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,EACD;IACE,OAAO,EAAE,0CAA0C;IACnD,IAAI,EAAE,CAAC,oBAAoB,CAAC;CAC7B,CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SIGNING_CONDITION_OBJECT_CONTEXT_VAR = ":signingConditionObject";
|
|
3
|
+
export declare const SigningObjectAttributeConditionType = "signing-attribute";
|
|
4
|
+
export declare const signingObjectAttributeConditionSchema: z.ZodSchema;
|
|
5
|
+
export type SigningObjectAttributeConditionProps = z.infer<typeof signingObjectAttributeConditionSchema>;
|
|
6
|
+
export declare const abiParameterValidationSchema: z.ZodSchema;
|
|
7
|
+
export type AbiParameterValidationProps = z.infer<typeof abiParameterValidationSchema>;
|
|
8
|
+
export declare const abiCallValidationSchema: z.ZodSchema;
|
|
9
|
+
export type AbiCallValidationProps = z.infer<typeof abiCallValidationSchema>;
|
|
10
|
+
export declare const SigningObjectAbiAttributeConditionType = "signing-abi-attribute";
|
|
11
|
+
export declare const signingObjectAbiAttributeConditionSchema: z.ZodSchema;
|
|
12
|
+
export type SigningObjectAbiAttributeConditionProps = z.infer<typeof signingObjectAbiAttributeConditionSchema>;
|