@lit-protocol/vincent-ability-sdk 0.0.1-ea
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/CHANGELOG.md +64 -0
- package/CONTRIBUTING.md +117 -0
- package/README.md +213 -0
- package/dist/package.json +44 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal.d.ts +12 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +32 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/abilityContext.d.ts +28 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/abilityContext.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/abilityContext.js +51 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/abilityContext.js.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/resultCreators.d.ts +18 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/resultCreators.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/resultCreators.js +48 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/resultCreators.js.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/types.d.ts +31 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/types.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/types.js +9 -0
- package/dist/src/lib/abilityCore/abilityConfig/context/types.js.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/types.d.ts +20 -0
- package/dist/src/lib/abilityCore/abilityConfig/types.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/abilityConfig/types.js +4 -0
- package/dist/src/lib/abilityCore/abilityConfig/types.js.map +1 -0
- package/dist/src/lib/abilityCore/bundledAbility/bundledAbility.d.ts +5 -0
- package/dist/src/lib/abilityCore/bundledAbility/bundledAbility.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/bundledAbility/bundledAbility.js +21 -0
- package/dist/src/lib/abilityCore/bundledAbility/bundledAbility.js.map +1 -0
- package/dist/src/lib/abilityCore/bundledAbility/types.d.ts +18 -0
- package/dist/src/lib/abilityCore/bundledAbility/types.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/bundledAbility/types.js +4 -0
- package/dist/src/lib/abilityCore/bundledAbility/types.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/getMappedAbilityPolicyParams.d.ts +5 -0
- package/dist/src/lib/abilityCore/helpers/getMappedAbilityPolicyParams.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/getMappedAbilityPolicyParams.js +18 -0
- package/dist/src/lib/abilityCore/helpers/getMappedAbilityPolicyParams.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/getPkpInfo.d.ts +10 -0
- package/dist/src/lib/abilityCore/helpers/getPkpInfo.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/getPkpInfo.js +26 -0
- package/dist/src/lib/abilityCore/helpers/getPkpInfo.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/index.d.ts +5 -0
- package/dist/src/lib/abilityCore/helpers/index.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/index.js +12 -0
- package/dist/src/lib/abilityCore/helpers/index.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/resultCreators.d.ts +21 -0
- package/dist/src/lib/abilityCore/helpers/resultCreators.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/resultCreators.js +48 -0
- package/dist/src/lib/abilityCore/helpers/resultCreators.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/supportedPoliciesForAbility.d.ts +55 -0
- package/dist/src/lib/abilityCore/helpers/supportedPoliciesForAbility.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/supportedPoliciesForAbility.js +68 -0
- package/dist/src/lib/abilityCore/helpers/supportedPoliciesForAbility.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/typeGuards.d.ts +8 -0
- package/dist/src/lib/abilityCore/helpers/typeGuards.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/typeGuards.js +28 -0
- package/dist/src/lib/abilityCore/helpers/typeGuards.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/validatePolicies.d.ts +24 -0
- package/dist/src/lib/abilityCore/helpers/validatePolicies.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/validatePolicies.js +31 -0
- package/dist/src/lib/abilityCore/helpers/validatePolicies.js.map +1 -0
- package/dist/src/lib/abilityCore/helpers/zod.d.ts +43 -0
- package/dist/src/lib/abilityCore/helpers/zod.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/helpers/zod.js +70 -0
- package/dist/src/lib/abilityCore/helpers/zod.js.map +1 -0
- package/dist/src/lib/abilityCore/vincentAbility.d.ts +54 -0
- package/dist/src/lib/abilityCore/vincentAbility.d.ts.map +1 -0
- package/dist/src/lib/abilityCore/vincentAbility.js +162 -0
- package/dist/src/lib/abilityCore/vincentAbility.js.map +1 -0
- package/dist/src/lib/assertSupportedAbilityVersion.d.ts +2 -0
- package/dist/src/lib/assertSupportedAbilityVersion.d.ts.map +1 -0
- package/dist/src/lib/assertSupportedAbilityVersion.js +15 -0
- package/dist/src/lib/assertSupportedAbilityVersion.js.map +1 -0
- package/dist/src/lib/constants.d.ts +2 -0
- package/dist/src/lib/constants.d.ts.map +1 -0
- package/dist/src/lib/constants.js +5 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/handlers/constants.d.ts +2 -0
- package/dist/src/lib/handlers/constants.d.ts.map +1 -0
- package/dist/src/lib/handlers/constants.js +6 -0
- package/dist/src/lib/handlers/constants.js.map +1 -0
- package/dist/src/lib/handlers/evaluatePolicies.d.ts +11 -0
- package/dist/src/lib/handlers/evaluatePolicies.d.ts.map +1 -0
- package/dist/src/lib/handlers/evaluatePolicies.js +110 -0
- package/dist/src/lib/handlers/evaluatePolicies.js.map +1 -0
- package/dist/src/lib/handlers/vincentAbilityHandler.d.ts +15 -0
- package/dist/src/lib/handlers/vincentAbilityHandler.d.ts.map +1 -0
- package/dist/src/lib/handlers/vincentAbilityHandler.js +160 -0
- package/dist/src/lib/handlers/vincentAbilityHandler.js.map +1 -0
- package/dist/src/lib/handlers/vincentPolicyHandler.d.ts +13 -0
- package/dist/src/lib/handlers/vincentPolicyHandler.d.ts.map +1 -0
- package/dist/src/lib/handlers/vincentPolicyHandler.js +70 -0
- package/dist/src/lib/handlers/vincentPolicyHandler.js.map +1 -0
- package/dist/src/lib/policyCore/bundledPolicy/bundledPolicy.d.ts +5 -0
- package/dist/src/lib/policyCore/bundledPolicy/bundledPolicy.d.ts.map +1 -0
- package/dist/src/lib/policyCore/bundledPolicy/bundledPolicy.js +21 -0
- package/dist/src/lib/policyCore/bundledPolicy/bundledPolicy.js.map +1 -0
- package/dist/src/lib/policyCore/bundledPolicy/types.d.ts +17 -0
- package/dist/src/lib/policyCore/bundledPolicy/types.d.ts.map +1 -0
- package/dist/src/lib/policyCore/bundledPolicy/types.js +4 -0
- package/dist/src/lib/policyCore/bundledPolicy/types.js.map +1 -0
- package/dist/src/lib/policyCore/helpers/index.d.ts +5 -0
- package/dist/src/lib/policyCore/helpers/index.d.ts.map +1 -0
- package/dist/src/lib/policyCore/helpers/index.js +16 -0
- package/dist/src/lib/policyCore/helpers/index.js.map +1 -0
- package/dist/src/lib/policyCore/helpers/resultCreators.d.ts +38 -0
- package/dist/src/lib/policyCore/helpers/resultCreators.d.ts.map +1 -0
- package/dist/src/lib/policyCore/helpers/resultCreators.js +89 -0
- package/dist/src/lib/policyCore/helpers/resultCreators.js.map +1 -0
- package/dist/src/lib/policyCore/helpers/typeGuards.d.ts +7 -0
- package/dist/src/lib/policyCore/helpers/typeGuards.d.ts.map +1 -0
- package/dist/src/lib/policyCore/helpers/typeGuards.js +23 -0
- package/dist/src/lib/policyCore/helpers/typeGuards.js.map +1 -0
- package/dist/src/lib/policyCore/helpers/zod.d.ts +55 -0
- package/dist/src/lib/policyCore/helpers/zod.d.ts.map +1 -0
- package/dist/src/lib/policyCore/helpers/zod.js +82 -0
- package/dist/src/lib/policyCore/helpers/zod.js.map +1 -0
- package/dist/src/lib/policyCore/index.d.ts +3 -0
- package/dist/src/lib/policyCore/index.d.ts.map +1 -0
- package/dist/src/lib/policyCore/index.js +8 -0
- package/dist/src/lib/policyCore/index.js.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/policyConfigContext.d.ts +12 -0
- package/dist/src/lib/policyCore/policyConfig/context/policyConfigContext.d.ts.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/policyConfigContext.js +20 -0
- package/dist/src/lib/policyCore/policyConfig/context/policyConfigContext.js.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/resultCreators.d.ts +6 -0
- package/dist/src/lib/policyCore/policyConfig/context/resultCreators.d.ts.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/resultCreators.js +30 -0
- package/dist/src/lib/policyCore/policyConfig/context/resultCreators.js.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/types.d.ts +24 -0
- package/dist/src/lib/policyCore/policyConfig/context/types.d.ts.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/context/types.js +5 -0
- package/dist/src/lib/policyCore/policyConfig/context/types.js.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/types.d.ts +46 -0
- package/dist/src/lib/policyCore/policyConfig/types.d.ts.map +1 -0
- package/dist/src/lib/policyCore/policyConfig/types.js +3 -0
- package/dist/src/lib/policyCore/policyConfig/types.js.map +1 -0
- package/dist/src/lib/policyCore/policyParameters/getOnchainPolicyParams.d.ts +17 -0
- package/dist/src/lib/policyCore/policyParameters/getOnchainPolicyParams.d.ts.map +1 -0
- package/dist/src/lib/policyCore/policyParameters/getOnchainPolicyParams.js +54 -0
- package/dist/src/lib/policyCore/policyParameters/getOnchainPolicyParams.js.map +1 -0
- package/dist/src/lib/policyCore/vincentPolicy.d.ts +92 -0
- package/dist/src/lib/policyCore/vincentPolicy.d.ts.map +1 -0
- package/dist/src/lib/policyCore/vincentPolicy.js +242 -0
- package/dist/src/lib/policyCore/vincentPolicy.js.map +1 -0
- package/dist/src/lib/types.d.ts +260 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +4 -0
- package/dist/src/lib/types.js.map +1 -0
- package/dist/src/lib/utils.d.ts +2 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/lib/utils.js +8 -0
- package/dist/src/lib/utils.js.map +1 -0
- package/dist/src/type-inference-verification/ability-definition-tests.d.ts +702 -0
- package/dist/src/type-inference-verification/ability-definition-tests.d.ts.map +1 -0
- package/dist/src/type-inference-verification/ability-definition-tests.js +203 -0
- package/dist/src/type-inference-verification/ability-definition-tests.js.map +1 -0
- package/dist/src/type-inference-verification/ability-lifecycle-inference.d.ts +2 -0
- package/dist/src/type-inference-verification/ability-lifecycle-inference.d.ts.map +1 -0
- package/dist/src/type-inference-verification/ability-lifecycle-inference.js +109 -0
- package/dist/src/type-inference-verification/ability-lifecycle-inference.js.map +1 -0
- package/dist/src/type-inference-verification/ability-lifecycle-succeed-fail-tests.d.ts +923 -0
- package/dist/src/type-inference-verification/ability-lifecycle-succeed-fail-tests.d.ts.map +1 -0
- package/dist/src/type-inference-verification/ability-lifecycle-succeed-fail-tests.js +196 -0
- package/dist/src/type-inference-verification/ability-lifecycle-succeed-fail-tests.js.map +1 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases-ability.d.ts +4305 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases-ability.d.ts.map +1 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases-ability.js +644 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases-ability.js.map +1 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases.d.ts +646 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases.d.ts.map +1 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases.js +264 -0
- package/dist/src/type-inference-verification/allow-deny-test-cases.js.map +1 -0
- package/dist/src/type-inference-verification/context-switching-tests.d.ts +637 -0
- package/dist/src/type-inference-verification/context-switching-tests.d.ts.map +1 -0
- package/dist/src/type-inference-verification/context-switching-tests.js +229 -0
- package/dist/src/type-inference-verification/context-switching-tests.js.map +1 -0
- package/dist/src/type-inference-verification/create-policy-map-from-tool-policies.d.ts +2 -0
- package/dist/src/type-inference-verification/create-policy-map-from-tool-policies.d.ts.map +1 -0
- package/dist/src/type-inference-verification/create-policy-map-from-tool-policies.js +56 -0
- package/dist/src/type-inference-verification/create-policy-map-from-tool-policies.js.map +1 -0
- package/dist/src/type-inference-verification/create-vincent-ability-policy.d.ts +2 -0
- package/dist/src/type-inference-verification/create-vincent-ability-policy.d.ts.map +1 -0
- package/dist/src/type-inference-verification/create-vincent-ability-policy.js +49 -0
- package/dist/src/type-inference-verification/create-vincent-ability-policy.js.map +1 -0
- package/dist/src/type-inference-verification/create-vincent-ability.d.ts +250 -0
- package/dist/src/type-inference-verification/create-vincent-ability.d.ts.map +1 -0
- package/dist/src/type-inference-verification/create-vincent-ability.js +68 -0
- package/dist/src/type-inference-verification/create-vincent-ability.js.map +1 -0
- package/dist/src/type-inference-verification/parameter-inference-tests-tool.d.ts +1710 -0
- package/dist/src/type-inference-verification/parameter-inference-tests-tool.d.ts.map +1 -0
- package/dist/src/type-inference-verification/parameter-inference-tests-tool.js +537 -0
- package/dist/src/type-inference-verification/parameter-inference-tests-tool.js.map +1 -0
- package/dist/src/type-inference-verification/parameter-inference-tests.d.ts +456 -0
- package/dist/src/type-inference-verification/parameter-inference-tests.d.ts.map +1 -0
- package/dist/src/type-inference-verification/parameter-inference-tests.js +179 -0
- package/dist/src/type-inference-verification/parameter-inference-tests.js.map +1 -0
- package/dist/src/type-inference-verification/playground.d.ts +1556 -0
- package/dist/src/type-inference-verification/playground.d.ts.map +1 -0
- package/dist/src/type-inference-verification/playground.js +473 -0
- package/dist/src/type-inference-verification/playground.js.map +1 -0
- package/dist/src/type-inference-verification/schema-test.d.ts +470 -0
- package/dist/src/type-inference-verification/schema-test.d.ts.map +1 -0
- package/dist/src/type-inference-verification/schema-test.js +252 -0
- package/dist/src/type-inference-verification/schema-test.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter Inference Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests to verify TypeScript correctly enforces type constraints
|
|
5
|
+
* on parameters passed to allow() and deny() methods.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Test 1: Basic schema validation for allow/deny
|
|
10
|
+
*/
|
|
11
|
+
declare function testBasicSchemaValidation(): {
|
|
12
|
+
vincentPolicy: import("../internal").VincentPolicy<"@lit-protocol/test-policy@1.34.2", z.ZodObject<{
|
|
13
|
+
actionType: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
actionType: string;
|
|
16
|
+
}, {
|
|
17
|
+
actionType: string;
|
|
18
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodObject<{
|
|
19
|
+
success: z.ZodBoolean;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
success: boolean;
|
|
22
|
+
}, {
|
|
23
|
+
success: boolean;
|
|
24
|
+
}>, z.ZodObject<{
|
|
25
|
+
errorCode: z.ZodNumber;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
errorCode: number;
|
|
28
|
+
}, {
|
|
29
|
+
errorCode: number;
|
|
30
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
31
|
+
actionType: z.ZodString;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
actionType: string;
|
|
34
|
+
}, {
|
|
35
|
+
actionType: string;
|
|
36
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
37
|
+
success: z.ZodBoolean;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
success: boolean;
|
|
40
|
+
}, {
|
|
41
|
+
success: boolean;
|
|
42
|
+
}>, z.ZodObject<{
|
|
43
|
+
errorCode: z.ZodNumber;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
errorCode: number;
|
|
46
|
+
}, {
|
|
47
|
+
errorCode: number;
|
|
48
|
+
}>>, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
49
|
+
actionType: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
actionType: string;
|
|
52
|
+
}, {
|
|
53
|
+
actionType: string;
|
|
54
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>, import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>>;
|
|
55
|
+
ipfsCid: "oi3wjfn9048w2j";
|
|
56
|
+
abilityParameterMappings: Partial<{
|
|
57
|
+
action: "actionType";
|
|
58
|
+
target: "actionType";
|
|
59
|
+
amount: "actionType";
|
|
60
|
+
}>;
|
|
61
|
+
vincentAbilityApiVersion: string;
|
|
62
|
+
__schemaTypes: {
|
|
63
|
+
policyAbilityParamsSchema: z.ZodObject<{
|
|
64
|
+
actionType: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
actionType: string;
|
|
67
|
+
}, {
|
|
68
|
+
actionType: string;
|
|
69
|
+
}>;
|
|
70
|
+
userParamsSchema: z.ZodUndefined;
|
|
71
|
+
evalAllowResultSchema: z.ZodObject<{
|
|
72
|
+
success: z.ZodBoolean;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
success: boolean;
|
|
75
|
+
}, {
|
|
76
|
+
success: boolean;
|
|
77
|
+
}>;
|
|
78
|
+
evalDenyResultSchema: z.ZodObject<{
|
|
79
|
+
errorCode: z.ZodNumber;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
errorCode: number;
|
|
82
|
+
}, {
|
|
83
|
+
errorCode: number;
|
|
84
|
+
}>;
|
|
85
|
+
precheckAllowResultSchema: z.ZodUndefined;
|
|
86
|
+
precheckDenyResultSchema: z.ZodUndefined;
|
|
87
|
+
commitParamsSchema: z.ZodUndefined;
|
|
88
|
+
commitAllowResultSchema: z.ZodUndefined;
|
|
89
|
+
commitDenyResultSchema: z.ZodUndefined;
|
|
90
|
+
evaluate: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
91
|
+
actionType: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
actionType: string;
|
|
94
|
+
}, {
|
|
95
|
+
actionType: string;
|
|
96
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
97
|
+
success: z.ZodBoolean;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
success: boolean;
|
|
100
|
+
}, {
|
|
101
|
+
success: boolean;
|
|
102
|
+
}>, z.ZodObject<{
|
|
103
|
+
errorCode: z.ZodNumber;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
errorCode: number;
|
|
106
|
+
}, {
|
|
107
|
+
errorCode: number;
|
|
108
|
+
}>>;
|
|
109
|
+
precheck: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
110
|
+
actionType: z.ZodString;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
actionType: string;
|
|
113
|
+
}, {
|
|
114
|
+
actionType: string;
|
|
115
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
116
|
+
commit: import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Test 2: No schema case validation
|
|
121
|
+
*/
|
|
122
|
+
declare function testNoSchemaValidation(): {
|
|
123
|
+
vincentPolicy: import("../internal").VincentPolicy<"@lit-protocol/test-policy@1.34.2", z.ZodObject<{
|
|
124
|
+
actionType: z.ZodString;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
actionType: string;
|
|
127
|
+
}, {
|
|
128
|
+
actionType: string;
|
|
129
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
130
|
+
actionType: z.ZodString;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
actionType: string;
|
|
133
|
+
}, {
|
|
134
|
+
actionType: string;
|
|
135
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
136
|
+
actionType: z.ZodString;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
actionType: string;
|
|
139
|
+
}, {
|
|
140
|
+
actionType: string;
|
|
141
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>, import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>>;
|
|
142
|
+
ipfsCid: "1098jwsdoifosdji";
|
|
143
|
+
abilityParameterMappings: Partial<{
|
|
144
|
+
action: "actionType";
|
|
145
|
+
target: "actionType";
|
|
146
|
+
amount: "actionType";
|
|
147
|
+
}>;
|
|
148
|
+
vincentAbilityApiVersion: string;
|
|
149
|
+
__schemaTypes: {
|
|
150
|
+
policyAbilityParamsSchema: z.ZodObject<{
|
|
151
|
+
actionType: z.ZodString;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
actionType: string;
|
|
154
|
+
}, {
|
|
155
|
+
actionType: string;
|
|
156
|
+
}>;
|
|
157
|
+
userParamsSchema: z.ZodUndefined;
|
|
158
|
+
evalAllowResultSchema: z.ZodUndefined;
|
|
159
|
+
evalDenyResultSchema: z.ZodUndefined;
|
|
160
|
+
precheckAllowResultSchema: z.ZodUndefined;
|
|
161
|
+
precheckDenyResultSchema: z.ZodUndefined;
|
|
162
|
+
commitParamsSchema: z.ZodUndefined;
|
|
163
|
+
commitAllowResultSchema: z.ZodUndefined;
|
|
164
|
+
commitDenyResultSchema: z.ZodUndefined;
|
|
165
|
+
evaluate: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
166
|
+
actionType: z.ZodString;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
actionType: string;
|
|
169
|
+
}, {
|
|
170
|
+
actionType: string;
|
|
171
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>;
|
|
172
|
+
precheck: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
173
|
+
actionType: z.ZodString;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
actionType: string;
|
|
176
|
+
}, {
|
|
177
|
+
actionType: string;
|
|
178
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
179
|
+
commit: import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Test 3: String schema validation
|
|
184
|
+
*/
|
|
185
|
+
declare function testStringSchemaValidation(): {
|
|
186
|
+
vincentPolicy: import("../internal").VincentPolicy<"@lit-protocol/test-policy@1.34.2", z.ZodObject<{
|
|
187
|
+
actionType: z.ZodString;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
actionType: string;
|
|
190
|
+
}, {
|
|
191
|
+
actionType: string;
|
|
192
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodString, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
193
|
+
actionType: z.ZodString;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
actionType: string;
|
|
196
|
+
}, {
|
|
197
|
+
actionType: string;
|
|
198
|
+
}>, z.ZodUndefined, z.ZodString, z.ZodUndefined>, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
199
|
+
actionType: z.ZodString;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
actionType: string;
|
|
202
|
+
}, {
|
|
203
|
+
actionType: string;
|
|
204
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>, import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>>;
|
|
205
|
+
ipfsCid: "082u0fij0w9jf0sjdf";
|
|
206
|
+
abilityParameterMappings: Partial<{
|
|
207
|
+
action: "actionType";
|
|
208
|
+
target: "actionType";
|
|
209
|
+
amount: "actionType";
|
|
210
|
+
}>;
|
|
211
|
+
vincentAbilityApiVersion: string;
|
|
212
|
+
__schemaTypes: {
|
|
213
|
+
policyAbilityParamsSchema: z.ZodObject<{
|
|
214
|
+
actionType: z.ZodString;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
actionType: string;
|
|
217
|
+
}, {
|
|
218
|
+
actionType: string;
|
|
219
|
+
}>;
|
|
220
|
+
userParamsSchema: z.ZodUndefined;
|
|
221
|
+
evalAllowResultSchema: z.ZodString;
|
|
222
|
+
evalDenyResultSchema: z.ZodUndefined;
|
|
223
|
+
precheckAllowResultSchema: z.ZodUndefined;
|
|
224
|
+
precheckDenyResultSchema: z.ZodUndefined;
|
|
225
|
+
commitParamsSchema: z.ZodUndefined;
|
|
226
|
+
commitAllowResultSchema: z.ZodUndefined;
|
|
227
|
+
commitDenyResultSchema: z.ZodUndefined;
|
|
228
|
+
evaluate: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
229
|
+
actionType: z.ZodString;
|
|
230
|
+
}, "strip", z.ZodTypeAny, {
|
|
231
|
+
actionType: string;
|
|
232
|
+
}, {
|
|
233
|
+
actionType: string;
|
|
234
|
+
}>, z.ZodUndefined, z.ZodString, z.ZodUndefined>;
|
|
235
|
+
precheck: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
236
|
+
actionType: z.ZodString;
|
|
237
|
+
}, "strip", z.ZodTypeAny, {
|
|
238
|
+
actionType: string;
|
|
239
|
+
}, {
|
|
240
|
+
actionType: string;
|
|
241
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
242
|
+
commit: import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Test 4: Deny parameter validation
|
|
247
|
+
*/
|
|
248
|
+
declare function testDenyValidation(): {
|
|
249
|
+
vincentPolicy: import("../internal").VincentPolicy<"@lit-protocol/test-policy@1.34.2", z.ZodObject<{
|
|
250
|
+
actionType: z.ZodString;
|
|
251
|
+
}, "strip", z.ZodTypeAny, {
|
|
252
|
+
actionType: string;
|
|
253
|
+
}, {
|
|
254
|
+
actionType: string;
|
|
255
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodObject<{
|
|
256
|
+
code: z.ZodNumber;
|
|
257
|
+
message: z.ZodString;
|
|
258
|
+
}, "strip", z.ZodTypeAny, {
|
|
259
|
+
code: number;
|
|
260
|
+
message: string;
|
|
261
|
+
}, {
|
|
262
|
+
code: number;
|
|
263
|
+
message: string;
|
|
264
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
265
|
+
actionType: z.ZodString;
|
|
266
|
+
}, "strip", z.ZodTypeAny, {
|
|
267
|
+
actionType: string;
|
|
268
|
+
}, {
|
|
269
|
+
actionType: string;
|
|
270
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodObject<{
|
|
271
|
+
code: z.ZodNumber;
|
|
272
|
+
message: z.ZodString;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
code: number;
|
|
275
|
+
message: string;
|
|
276
|
+
}, {
|
|
277
|
+
code: number;
|
|
278
|
+
message: string;
|
|
279
|
+
}>>, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
280
|
+
actionType: z.ZodString;
|
|
281
|
+
}, "strip", z.ZodTypeAny, {
|
|
282
|
+
actionType: string;
|
|
283
|
+
}, {
|
|
284
|
+
actionType: string;
|
|
285
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>, import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>>;
|
|
286
|
+
ipfsCid: "198hf0298w3hfo9idfjh";
|
|
287
|
+
abilityParameterMappings: Partial<{
|
|
288
|
+
action: "actionType";
|
|
289
|
+
target: "actionType";
|
|
290
|
+
amount: "actionType";
|
|
291
|
+
}>;
|
|
292
|
+
vincentAbilityApiVersion: string;
|
|
293
|
+
__schemaTypes: {
|
|
294
|
+
policyAbilityParamsSchema: z.ZodObject<{
|
|
295
|
+
actionType: z.ZodString;
|
|
296
|
+
}, "strip", z.ZodTypeAny, {
|
|
297
|
+
actionType: string;
|
|
298
|
+
}, {
|
|
299
|
+
actionType: string;
|
|
300
|
+
}>;
|
|
301
|
+
userParamsSchema: z.ZodUndefined;
|
|
302
|
+
evalAllowResultSchema: z.ZodUndefined;
|
|
303
|
+
evalDenyResultSchema: z.ZodObject<{
|
|
304
|
+
code: z.ZodNumber;
|
|
305
|
+
message: z.ZodString;
|
|
306
|
+
}, "strip", z.ZodTypeAny, {
|
|
307
|
+
code: number;
|
|
308
|
+
message: string;
|
|
309
|
+
}, {
|
|
310
|
+
code: number;
|
|
311
|
+
message: string;
|
|
312
|
+
}>;
|
|
313
|
+
precheckAllowResultSchema: z.ZodUndefined;
|
|
314
|
+
precheckDenyResultSchema: z.ZodUndefined;
|
|
315
|
+
commitParamsSchema: z.ZodUndefined;
|
|
316
|
+
commitAllowResultSchema: z.ZodUndefined;
|
|
317
|
+
commitDenyResultSchema: z.ZodUndefined;
|
|
318
|
+
evaluate: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
319
|
+
actionType: z.ZodString;
|
|
320
|
+
}, "strip", z.ZodTypeAny, {
|
|
321
|
+
actionType: string;
|
|
322
|
+
}, {
|
|
323
|
+
actionType: string;
|
|
324
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodObject<{
|
|
325
|
+
code: z.ZodNumber;
|
|
326
|
+
message: z.ZodString;
|
|
327
|
+
}, "strip", z.ZodTypeAny, {
|
|
328
|
+
code: number;
|
|
329
|
+
message: string;
|
|
330
|
+
}, {
|
|
331
|
+
code: number;
|
|
332
|
+
message: string;
|
|
333
|
+
}>>;
|
|
334
|
+
precheck: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
335
|
+
actionType: z.ZodString;
|
|
336
|
+
}, "strip", z.ZodTypeAny, {
|
|
337
|
+
actionType: string;
|
|
338
|
+
}, {
|
|
339
|
+
actionType: string;
|
|
340
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
341
|
+
commit: import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
/**
|
|
345
|
+
* Test 5: Different schemas for different contexts
|
|
346
|
+
*/
|
|
347
|
+
declare function testContextSchemas(): {
|
|
348
|
+
vincentPolicy: import("../internal").VincentPolicy<"@lit-protocol/test-policy@1.34.2", z.ZodObject<{
|
|
349
|
+
actionType: z.ZodString;
|
|
350
|
+
}, "strip", z.ZodTypeAny, {
|
|
351
|
+
actionType: string;
|
|
352
|
+
}, {
|
|
353
|
+
actionType: string;
|
|
354
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
355
|
+
valid: z.ZodBoolean;
|
|
356
|
+
}, "strip", z.ZodTypeAny, {
|
|
357
|
+
valid: boolean;
|
|
358
|
+
}, {
|
|
359
|
+
valid: boolean;
|
|
360
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
361
|
+
approved: z.ZodBoolean;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
approved: boolean;
|
|
364
|
+
}, {
|
|
365
|
+
approved: boolean;
|
|
366
|
+
}>, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, z.ZodUndefined, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
367
|
+
actionType: z.ZodString;
|
|
368
|
+
}, "strip", z.ZodTypeAny, {
|
|
369
|
+
actionType: string;
|
|
370
|
+
}, {
|
|
371
|
+
actionType: string;
|
|
372
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
373
|
+
approved: z.ZodBoolean;
|
|
374
|
+
}, "strip", z.ZodTypeAny, {
|
|
375
|
+
approved: boolean;
|
|
376
|
+
}, {
|
|
377
|
+
approved: boolean;
|
|
378
|
+
}>, z.ZodUndefined>, import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
379
|
+
actionType: z.ZodString;
|
|
380
|
+
}, "strip", z.ZodTypeAny, {
|
|
381
|
+
actionType: string;
|
|
382
|
+
}, {
|
|
383
|
+
actionType: string;
|
|
384
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
385
|
+
valid: z.ZodBoolean;
|
|
386
|
+
}, "strip", z.ZodTypeAny, {
|
|
387
|
+
valid: boolean;
|
|
388
|
+
}, {
|
|
389
|
+
valid: boolean;
|
|
390
|
+
}>, z.ZodUndefined>, import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined>>;
|
|
391
|
+
ipfsCid: "swmfd08238rhjdskjfn";
|
|
392
|
+
abilityParameterMappings: Partial<{
|
|
393
|
+
action: "actionType";
|
|
394
|
+
target: "actionType";
|
|
395
|
+
amount: "actionType";
|
|
396
|
+
}>;
|
|
397
|
+
vincentAbilityApiVersion: string;
|
|
398
|
+
__schemaTypes: {
|
|
399
|
+
policyAbilityParamsSchema: z.ZodObject<{
|
|
400
|
+
actionType: z.ZodString;
|
|
401
|
+
}, "strip", z.ZodTypeAny, {
|
|
402
|
+
actionType: string;
|
|
403
|
+
}, {
|
|
404
|
+
actionType: string;
|
|
405
|
+
}>;
|
|
406
|
+
userParamsSchema: z.ZodUndefined;
|
|
407
|
+
evalAllowResultSchema: z.ZodObject<{
|
|
408
|
+
approved: z.ZodBoolean;
|
|
409
|
+
}, "strip", z.ZodTypeAny, {
|
|
410
|
+
approved: boolean;
|
|
411
|
+
}, {
|
|
412
|
+
approved: boolean;
|
|
413
|
+
}>;
|
|
414
|
+
evalDenyResultSchema: z.ZodUndefined;
|
|
415
|
+
precheckAllowResultSchema: z.ZodObject<{
|
|
416
|
+
valid: z.ZodBoolean;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
valid: boolean;
|
|
419
|
+
}, {
|
|
420
|
+
valid: boolean;
|
|
421
|
+
}>;
|
|
422
|
+
precheckDenyResultSchema: z.ZodUndefined;
|
|
423
|
+
commitParamsSchema: z.ZodUndefined;
|
|
424
|
+
commitAllowResultSchema: z.ZodUndefined;
|
|
425
|
+
commitDenyResultSchema: z.ZodUndefined;
|
|
426
|
+
evaluate: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
427
|
+
actionType: z.ZodString;
|
|
428
|
+
}, "strip", z.ZodTypeAny, {
|
|
429
|
+
actionType: string;
|
|
430
|
+
}, {
|
|
431
|
+
actionType: string;
|
|
432
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
433
|
+
approved: z.ZodBoolean;
|
|
434
|
+
}, "strip", z.ZodTypeAny, {
|
|
435
|
+
approved: boolean;
|
|
436
|
+
}, {
|
|
437
|
+
approved: boolean;
|
|
438
|
+
}>, z.ZodUndefined>;
|
|
439
|
+
precheck: import("../lib/types").PolicyLifecycleFunction<z.ZodObject<{
|
|
440
|
+
actionType: z.ZodString;
|
|
441
|
+
}, "strip", z.ZodTypeAny, {
|
|
442
|
+
actionType: string;
|
|
443
|
+
}, {
|
|
444
|
+
actionType: string;
|
|
445
|
+
}>, z.ZodUndefined, z.ZodObject<{
|
|
446
|
+
valid: z.ZodBoolean;
|
|
447
|
+
}, "strip", z.ZodTypeAny, {
|
|
448
|
+
valid: boolean;
|
|
449
|
+
}, {
|
|
450
|
+
valid: boolean;
|
|
451
|
+
}>, z.ZodUndefined> | undefined;
|
|
452
|
+
commit: import("../lib/types").CommitLifecycleFunction<z.ZodUndefined, z.ZodUndefined, z.ZodUndefined> | undefined;
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
export { testBasicSchemaValidation, testNoSchemaValidation, testStringSchemaValidation, testDenyValidation, testContextSchemas, };
|
|
456
|
+
//# sourceMappingURL=parameter-inference-tests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter-inference-tests.d.ts","sourceRoot":"","sources":["../../../src/type-inference-verification/parameter-inference-tests.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB;;GAEG;AACH,iBAAS,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCjC;AAED;;GAEG;AACH,iBAAS,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B9B;AAED;;GAEG;AACH,iBAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BlC;AAED;;GAEG;AACH,iBAAS,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiC1B;AAED;;GAEG;AACH,iBAAS,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqC1B;AAGD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,GACnB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/type-inference-verification/parameter-inference-tests.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.testBasicSchemaValidation = testBasicSchemaValidation;
|
|
5
|
+
exports.testNoSchemaValidation = testNoSchemaValidation;
|
|
6
|
+
exports.testStringSchemaValidation = testStringSchemaValidation;
|
|
7
|
+
exports.testDenyValidation = testDenyValidation;
|
|
8
|
+
exports.testContextSchemas = testContextSchemas;
|
|
9
|
+
/**
|
|
10
|
+
* Parameter Inference Tests
|
|
11
|
+
*
|
|
12
|
+
* Tests to verify TypeScript correctly enforces type constraints
|
|
13
|
+
* on parameters passed to allow() and deny() methods.
|
|
14
|
+
*/
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const bundledPolicy_1 = require("../lib/policyCore/bundledPolicy/bundledPolicy");
|
|
17
|
+
const vincentPolicy_1 = require("../lib/policyCore/vincentPolicy");
|
|
18
|
+
// Base ability schema for all tests
|
|
19
|
+
const baseAbilitySchema = zod_1.z.object({
|
|
20
|
+
action: zod_1.z.string(),
|
|
21
|
+
target: zod_1.z.string(),
|
|
22
|
+
amount: zod_1.z.number(),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Test 1: Basic schema validation for allow/deny
|
|
26
|
+
*/
|
|
27
|
+
function testBasicSchemaValidation() {
|
|
28
|
+
const basicSchemaPolicyValid = (0, vincentPolicy_1.createVincentPolicy)({
|
|
29
|
+
packageName: '@lit-protocol/test-policy@1.34.2',
|
|
30
|
+
abilityParamsSchema: zod_1.z.object({ actionType: zod_1.z.string() }),
|
|
31
|
+
// Define schemas
|
|
32
|
+
evalAllowResultSchema: zod_1.z.object({ success: zod_1.z.boolean() }),
|
|
33
|
+
evalDenyResultSchema: zod_1.z.object({ errorCode: zod_1.z.number() }),
|
|
34
|
+
evaluate: async (params, context) => {
|
|
35
|
+
// Test TypeScript errors first
|
|
36
|
+
// @ts-expect-error - No arguments when schema exists
|
|
37
|
+
context.allow();
|
|
38
|
+
// @ts-expect-error - Wrong type (string not matching schema)
|
|
39
|
+
context.allow('not an object');
|
|
40
|
+
// @ts-expect-error - Wrong shape (missing required field)
|
|
41
|
+
context.allow({});
|
|
42
|
+
// Valid call - matches schema
|
|
43
|
+
return context.allow({ success: true });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const basicSchemaPolicy = (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
47
|
+
abilityParamsSchema: baseAbilitySchema,
|
|
48
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(basicSchemaPolicyValid, 'oi3wjfn9048w2j'),
|
|
49
|
+
abilityParameterMappings: {
|
|
50
|
+
action: 'actionType',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
return basicSchemaPolicy;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Test 2: No schema case validation
|
|
57
|
+
*/
|
|
58
|
+
function testNoSchemaValidation() {
|
|
59
|
+
const noSchemaPolicy = (0, vincentPolicy_1.createVincentPolicy)({
|
|
60
|
+
packageName: '@lit-protocol/test-policy@1.34.2',
|
|
61
|
+
abilityParamsSchema: zod_1.z.object({ actionType: zod_1.z.string() }),
|
|
62
|
+
// No schemas defined
|
|
63
|
+
evaluate: async (params, context) => {
|
|
64
|
+
// Test TypeScript errors first
|
|
65
|
+
// @ts-expect-error - No schema means no args allowed
|
|
66
|
+
context.allow('should error');
|
|
67
|
+
// @ts-expect-error - No schema means no object allowed
|
|
68
|
+
context.allow({ shouldError: true });
|
|
69
|
+
// Valid calls - no args for allow with no schema
|
|
70
|
+
// And string error for deny with no schema
|
|
71
|
+
if (Math.random() > 0.5) {
|
|
72
|
+
return context.allow();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// @ts-expect-error Can't return a string when no schema defined
|
|
76
|
+
return context.deny('Error message');
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
return (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
81
|
+
abilityParamsSchema: baseAbilitySchema,
|
|
82
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(noSchemaPolicy, '1098jwsdoifosdji'),
|
|
83
|
+
abilityParameterMappings: {
|
|
84
|
+
action: 'actionType',
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Test 3: String schema validation
|
|
90
|
+
*/
|
|
91
|
+
function testStringSchemaValidation() {
|
|
92
|
+
const stringSchemaPolicy = (0, vincentPolicy_1.createVincentPolicy)({
|
|
93
|
+
packageName: '@lit-protocol/test-policy@1.34.2',
|
|
94
|
+
abilityParamsSchema: zod_1.z.object({ actionType: zod_1.z.string() }),
|
|
95
|
+
// String schema
|
|
96
|
+
evalAllowResultSchema: zod_1.z.string(),
|
|
97
|
+
evaluate: async (params, context) => {
|
|
98
|
+
// Test TypeScript errors first
|
|
99
|
+
// @ts-expect-error - No arguments when schema exists
|
|
100
|
+
context.allow();
|
|
101
|
+
// @ts-expect-error - Wrong type (number not matching string schema)
|
|
102
|
+
context.allow(123);
|
|
103
|
+
// @ts-expect-error - Wrong type (object not matching string schema)
|
|
104
|
+
context.allow({ notAString: true });
|
|
105
|
+
// Valid - matches string schema
|
|
106
|
+
return context.allow('Success message');
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
return (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
110
|
+
abilityParamsSchema: baseAbilitySchema,
|
|
111
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(stringSchemaPolicy, '082u0fij0w9jf0sjdf'),
|
|
112
|
+
abilityParameterMappings: {
|
|
113
|
+
action: 'actionType',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Test 4: Deny parameter validation
|
|
119
|
+
*/
|
|
120
|
+
function testDenyValidation() {
|
|
121
|
+
const denyValidationPolicy = (0, vincentPolicy_1.createVincentPolicy)({
|
|
122
|
+
packageName: '@lit-protocol/test-policy@1.34.2',
|
|
123
|
+
abilityParamsSchema: zod_1.z.object({ actionType: zod_1.z.string() }),
|
|
124
|
+
// Define deny schema
|
|
125
|
+
evalDenyResultSchema: zod_1.z.object({ code: zod_1.z.number(), message: zod_1.z.string() }),
|
|
126
|
+
evaluate: async (params, context) => {
|
|
127
|
+
// Test TypeScript errors first
|
|
128
|
+
// @ts-expect-error - String only when schema exists
|
|
129
|
+
context.deny('string only error');
|
|
130
|
+
// @ts-expect-error - Wrong shape (missing required field)
|
|
131
|
+
context.deny({ code: 400 });
|
|
132
|
+
// @ts-expect-error - Wrong shape (missing required field)
|
|
133
|
+
context.deny({ message: 'Error message' });
|
|
134
|
+
// Valid - matches schema
|
|
135
|
+
return context.deny({ code: 403, message: 'Forbidden' });
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
return (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
139
|
+
abilityParamsSchema: baseAbilitySchema,
|
|
140
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(denyValidationPolicy, '198hf0298w3hfo9idfjh'),
|
|
141
|
+
abilityParameterMappings: {
|
|
142
|
+
action: 'actionType',
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Test 5: Different schemas for different contexts
|
|
148
|
+
*/
|
|
149
|
+
function testContextSchemas() {
|
|
150
|
+
const contextSchemasPolicy = (0, vincentPolicy_1.createVincentPolicy)({
|
|
151
|
+
packageName: '@lit-protocol/test-policy@1.34.2',
|
|
152
|
+
abilityParamsSchema: zod_1.z.object({ actionType: zod_1.z.string() }),
|
|
153
|
+
// Different schemas for precheck and evaluate
|
|
154
|
+
precheckAllowResultSchema: zod_1.z.object({ valid: zod_1.z.boolean() }),
|
|
155
|
+
evalAllowResultSchema: zod_1.z.object({ approved: zod_1.z.boolean() }),
|
|
156
|
+
precheck: async (params, context) => {
|
|
157
|
+
// TypeScript error test
|
|
158
|
+
// @ts-expect-error - Using eval schema in precheck
|
|
159
|
+
context.allow({ approved: true });
|
|
160
|
+
// Valid for precheck
|
|
161
|
+
return context.allow({ valid: true });
|
|
162
|
+
},
|
|
163
|
+
evaluate: async (params, context) => {
|
|
164
|
+
// TypeScript error test
|
|
165
|
+
// @ts-expect-error - Using precheck schema in eval
|
|
166
|
+
context.allow({ valid: true });
|
|
167
|
+
// Valid for evaluate
|
|
168
|
+
return context.allow({ approved: true });
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
return (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
172
|
+
abilityParamsSchema: baseAbilitySchema,
|
|
173
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(contextSchemasPolicy, 'swmfd08238rhjdskjfn'),
|
|
174
|
+
abilityParameterMappings: {
|
|
175
|
+
action: 'actionType',
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=parameter-inference-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameter-inference-tests.js","sourceRoot":"","sources":["../../../src/type-inference-verification/parameter-inference-tests.ts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