@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 @@
|
|
|
1
|
+
{"version":3,"file":"allow-deny-test-cases-ability.d.ts","sourceRoot":"","sources":["../../../src/type-inference-verification/allow-deny-test-cases-ability.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8CxB;;;GAGG;AACH,wBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mEA+B5B;AAED;;;GAGG;AACH,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAmD7B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4DnC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAqBrC,CAAC;AAEF;;GAEG;AACH,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAqCvC"}
|
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/type-inference-verification/allow-deny-test-cases-ability.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.testExecuteTryCatchReturn = exports.testPrecheckAsyncWithoutAwait = exports.testExecuteConditionalReturns = exports.testPrecheckConditionalReturns = exports.testReturnWithInnerFunctions = exports.testExecuteFailWithSuccessSchema = exports.testPrecheckSuccessWithFailSchema = exports.testExecuteWrongSchema = exports.testPrecheckWrongSchema = exports.testExecuteWrongTypeReturn = exports.testExecuteRawReturn = exports.testPrecheckRawReturn = exports.testExecuteNoReturn = exports.testPrecheckNoReturn = exports.testReturnNoSchema = exports.missingSchema = exports.missingExecute = void 0;
|
|
5
|
+
exports.testNoSchemas = testNoSchemas;
|
|
6
|
+
exports.tesWithSchemas = tesWithSchemas;
|
|
7
|
+
exports.testDifferentSchemas = testDifferentSchemas;
|
|
8
|
+
exports.testPolicyResultTypes = testPolicyResultTypes;
|
|
9
|
+
exports.assertAllow = assertAllow;
|
|
10
|
+
exports.testExecutePolicyResultTyping = testExecutePolicyResultTyping;
|
|
11
|
+
exports.testContextDestructuring = testContextDestructuring;
|
|
12
|
+
/**
|
|
13
|
+
* Ability Definition Type Checking
|
|
14
|
+
*
|
|
15
|
+
* This file validates that TypeScript correctly enforces type constraints
|
|
16
|
+
* for ability definitions, focusing on success/failure responses.
|
|
17
|
+
*/
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const helpers_1 = require("../lib/abilityCore/helpers");
|
|
20
|
+
const vincentAbility_1 = require("../lib/abilityCore/vincentAbility");
|
|
21
|
+
const bundledPolicy_1 = require("../lib/policyCore/bundledPolicy/bundledPolicy");
|
|
22
|
+
const vincentPolicy_1 = require("../lib/policyCore/vincentPolicy");
|
|
23
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
24
|
+
// Define a simple schema for our test cases
|
|
25
|
+
const testSchema = zod_1.z.object({
|
|
26
|
+
action: zod_1.z.string(),
|
|
27
|
+
target: zod_1.z.string(),
|
|
28
|
+
amount: zod_1.z.number().optional(),
|
|
29
|
+
});
|
|
30
|
+
// Define result schemas for different test cases
|
|
31
|
+
const successSchema = zod_1.z.object({
|
|
32
|
+
message: zod_1.z.string(),
|
|
33
|
+
});
|
|
34
|
+
const failSchema = zod_1.z.object({
|
|
35
|
+
error: zod_1.z.string(),
|
|
36
|
+
code: zod_1.z.number(),
|
|
37
|
+
});
|
|
38
|
+
// Create a test policy
|
|
39
|
+
const baseTestPolicy = (0, vincentPolicy_1.createVincentPolicy)({
|
|
40
|
+
packageName: '@lit-protocol/test-policy@1.0.0',
|
|
41
|
+
abilityParamsSchema: zod_1.z.object({
|
|
42
|
+
actionType: zod_1.z.string(),
|
|
43
|
+
}),
|
|
44
|
+
evalAllowResultSchema: zod_1.z.object({
|
|
45
|
+
approved: zod_1.z.boolean(),
|
|
46
|
+
}),
|
|
47
|
+
evaluate: async (params, { allow }) => {
|
|
48
|
+
return allow({ approved: true });
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const testPolicy = (0, vincentPolicy_1.createVincentAbilityPolicy)({
|
|
52
|
+
abilityParamsSchema: testSchema,
|
|
53
|
+
bundledVincentPolicy: (0, bundledPolicy_1.asBundledVincentPolicy)(baseTestPolicy, 'j298jhodf9024j4jfg'),
|
|
54
|
+
abilityParameterMappings: {
|
|
55
|
+
action: 'actionType',
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Test Case 1: Basic ability with no schemas
|
|
60
|
+
* This validates the behavior when no explicit schemas are provided.
|
|
61
|
+
*/
|
|
62
|
+
function testNoSchemas() {
|
|
63
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
64
|
+
packageName: '@lit-protocol/yesability@1.0.0',
|
|
65
|
+
abilityDescription: 'Yes Ability',
|
|
66
|
+
abilityParamsSchema: testSchema,
|
|
67
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
68
|
+
precheck: async (params, { succeed, fail }) => {
|
|
69
|
+
// Should allow succeed() with no arguments
|
|
70
|
+
succeed();
|
|
71
|
+
// @ts-expect-error Should not allow fail() with string error
|
|
72
|
+
fail('Error message');
|
|
73
|
+
// @ts-expect-error - Should not allow succeed() with arguments when no schema
|
|
74
|
+
succeed({ message: 'test' });
|
|
75
|
+
// @ts-expect-error - Should not allow fail() with object when no schema
|
|
76
|
+
fail({ error: 'test' });
|
|
77
|
+
return succeed();
|
|
78
|
+
},
|
|
79
|
+
execute: async (params, { succeed }) => {
|
|
80
|
+
// Should allow succeed() with no arguments
|
|
81
|
+
succeed();
|
|
82
|
+
// @ts-expect-error - Should not allow succeed() with arguments when no schema
|
|
83
|
+
return succeed({ data: 'test' });
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Test Case 2: Ability with explicit success/fail schemas
|
|
89
|
+
* This validates that TypeScript enforces schema constraints.
|
|
90
|
+
*/
|
|
91
|
+
function tesWithSchemas() {
|
|
92
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
93
|
+
packageName: '@lit-protocol/yesability2@1.0.0',
|
|
94
|
+
abilityDescription: 'Yes Ability',
|
|
95
|
+
abilityParamsSchema: testSchema,
|
|
96
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
97
|
+
executeSuccessSchema: successSchema,
|
|
98
|
+
executeFailSchema: failSchema,
|
|
99
|
+
precheck: async (params, { succeed }) => {
|
|
100
|
+
return succeed();
|
|
101
|
+
},
|
|
102
|
+
execute: async (params, { succeed, fail }) => {
|
|
103
|
+
// Should allow succeed() with valid schema
|
|
104
|
+
succeed({
|
|
105
|
+
message: 'Operation completed',
|
|
106
|
+
});
|
|
107
|
+
// Should allow fail() with valid schema
|
|
108
|
+
fail({
|
|
109
|
+
error: 'Something went wrong',
|
|
110
|
+
code: 400,
|
|
111
|
+
});
|
|
112
|
+
// @ts-expect-error - Missing required fields
|
|
113
|
+
succeed({});
|
|
114
|
+
succeed({
|
|
115
|
+
success: true,
|
|
116
|
+
// @ts-expect-error - Wrong type for message
|
|
117
|
+
message: 123,
|
|
118
|
+
});
|
|
119
|
+
succeed({
|
|
120
|
+
message: 'test',
|
|
121
|
+
// @ts-expect-error - Extra unexpected fields
|
|
122
|
+
extra: 'field',
|
|
123
|
+
});
|
|
124
|
+
fail({
|
|
125
|
+
error: 'Error message',
|
|
126
|
+
// @ts-expect-error - Wrong type for error code
|
|
127
|
+
code: '400',
|
|
128
|
+
});
|
|
129
|
+
return succeed({
|
|
130
|
+
message: 'Success',
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Test Case 3: Ability with different precheck and execute schemas
|
|
137
|
+
* This validates that different schema types are correctly enforced.
|
|
138
|
+
*/
|
|
139
|
+
function testDifferentSchemas() {
|
|
140
|
+
const precheckSuccessSchema = zod_1.z.object({
|
|
141
|
+
valid: zod_1.z.boolean(),
|
|
142
|
+
});
|
|
143
|
+
const precheckFailSchema = zod_1.z.object({
|
|
144
|
+
reason: zod_1.z.string(),
|
|
145
|
+
});
|
|
146
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
147
|
+
result: zod_1.z.string(),
|
|
148
|
+
timestamp: zod_1.z.number(),
|
|
149
|
+
});
|
|
150
|
+
const executeFailSchema = zod_1.z.object({
|
|
151
|
+
errorCode: zod_1.z.number(),
|
|
152
|
+
});
|
|
153
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
154
|
+
packageName: '@lit-protocol/yesability3@1.0.0',
|
|
155
|
+
abilityDescription: 'Yes Ability',
|
|
156
|
+
abilityParamsSchema: testSchema,
|
|
157
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
158
|
+
precheckSuccessSchema,
|
|
159
|
+
precheckFailSchema,
|
|
160
|
+
executeSuccessSchema,
|
|
161
|
+
executeFailSchema,
|
|
162
|
+
precheck: async (params, { succeed, fail }) => {
|
|
163
|
+
// Valid precheck schema
|
|
164
|
+
succeed({ valid: true });
|
|
165
|
+
// Valid precheck fail schema
|
|
166
|
+
fail({ reason: 'Invalid parameters' });
|
|
167
|
+
// @ts-expect-error - Using execute success schema in precheck
|
|
168
|
+
succeed({ result: 'test', timestamp: 123 });
|
|
169
|
+
// @ts-expect-error - Using execute fail schema in precheck
|
|
170
|
+
fail({ errorCode: 400 });
|
|
171
|
+
return succeed({ valid: true });
|
|
172
|
+
},
|
|
173
|
+
execute: async (params, { succeed, fail }) => {
|
|
174
|
+
// Valid execute schema
|
|
175
|
+
succeed({ result: 'success', timestamp: Date.now() });
|
|
176
|
+
// Valid execute fail schema
|
|
177
|
+
fail({ errorCode: 500 });
|
|
178
|
+
// @ts-expect-error - Using precheck success schema in execute
|
|
179
|
+
succeed({ valid: true });
|
|
180
|
+
// @ts-expect-error - Using precheck fail schema in execute
|
|
181
|
+
fail({ reason: 'Error' });
|
|
182
|
+
return succeed({ result: 'data', timestamp: Date.now() });
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Test Case 4: Context type safety with policy results
|
|
188
|
+
* This validates that policiesContext is correctly typed.
|
|
189
|
+
*/
|
|
190
|
+
function testPolicyResultTypes() {
|
|
191
|
+
// First test: Precheck with properly typed policiesContext
|
|
192
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
193
|
+
packageName: '@lit-protocol/yesability4@1.0.0',
|
|
194
|
+
abilityDescription: 'Yes Ability',
|
|
195
|
+
abilityParamsSchema: testSchema,
|
|
196
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
197
|
+
precheck: async (params, { policiesContext, succeed }) => {
|
|
198
|
+
// Should be able to check if policy evaluation allowed
|
|
199
|
+
if (policiesContext.allow) {
|
|
200
|
+
// Should be able to access the policy result with the correct type
|
|
201
|
+
const result = policiesContext.allowedPolicies['@lit-protocol/test-policy@1.0.0'];
|
|
202
|
+
if (result) {
|
|
203
|
+
const { approved } = result.result;
|
|
204
|
+
console.log(approved);
|
|
205
|
+
}
|
|
206
|
+
const invalid =
|
|
207
|
+
// @ts-expect-error - Property doesn't exist on the result type
|
|
208
|
+
policiesContext.allowedPolicies.testPolicy?.result.invalid;
|
|
209
|
+
console.log(invalid);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
// Should be able to access deny result when not allowed
|
|
213
|
+
const denyResult = policiesContext.deniedPolicy;
|
|
214
|
+
console.log(denyResult.packageName);
|
|
215
|
+
}
|
|
216
|
+
return succeed();
|
|
217
|
+
},
|
|
218
|
+
execute: async (params, { succeed }) => {
|
|
219
|
+
return succeed();
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function assertAllow(obj) {
|
|
224
|
+
// This function just asserts that obj.allow is true
|
|
225
|
+
// It doesn't actually need to do anything at runtime
|
|
226
|
+
// TypeScript will use it for control flow analysis
|
|
227
|
+
}
|
|
228
|
+
// Separate test for execute-specific policy result typing
|
|
229
|
+
function testExecutePolicyResultTyping() {
|
|
230
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
231
|
+
packageName: '@lit-protocol/yesability5@1.0.0',
|
|
232
|
+
abilityDescription: 'Yes Ability',
|
|
233
|
+
abilityParamsSchema: testSchema,
|
|
234
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
235
|
+
precheck: async (params, { succeed }) => {
|
|
236
|
+
return succeed();
|
|
237
|
+
},
|
|
238
|
+
execute: async (params, { policiesContext, succeed }) => {
|
|
239
|
+
assertAllow(policiesContext);
|
|
240
|
+
// @ts-expect-error - Cannot negate a property known to be true
|
|
241
|
+
const allowIsAlwaysTrue = !policiesContext.allow;
|
|
242
|
+
// Should have access to test policy result
|
|
243
|
+
const result = policiesContext.allowedPolicies['@lit-protocol/test-policy@1.0.0'];
|
|
244
|
+
if (result) {
|
|
245
|
+
// Should be able to access properties of the result
|
|
246
|
+
const { approved } = result.result;
|
|
247
|
+
console.log(approved);
|
|
248
|
+
}
|
|
249
|
+
// @ts-expect-error - denyPolicyResult should not exist in execute
|
|
250
|
+
const denyResult = policiesContext.deniedPolicy[testPolicy];
|
|
251
|
+
console.log(denyResult);
|
|
252
|
+
return succeed();
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
// @ts-expect-error - Missing required execute function
|
|
257
|
+
exports.missingExecute = (0, vincentAbility_1.createVincentAbility)({
|
|
258
|
+
abilityParamsSchema: testSchema,
|
|
259
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
260
|
+
precheck: async (params, { succeed }) => {
|
|
261
|
+
return succeed();
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
// @ts-expect-error - Missing required abilityParamsSchema
|
|
265
|
+
exports.missingSchema = (0, vincentAbility_1.createVincentAbility)({
|
|
266
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
267
|
+
precheck: async (params, { succeed }) => {
|
|
268
|
+
return succeed();
|
|
269
|
+
},
|
|
270
|
+
execute: async (params, { succeed }) => {
|
|
271
|
+
return succeed();
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
/**
|
|
275
|
+
* Test Case 6: Testing return types are enforced
|
|
276
|
+
* Each sub-test has its own function to properly test at the function definition level.
|
|
277
|
+
*/
|
|
278
|
+
// Basic abilities for tests
|
|
279
|
+
const testReturnNoSchema = () => {
|
|
280
|
+
// This is a good ability with proper returns
|
|
281
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
282
|
+
packageName: '@lit-protocol/yesability6@1.0.0',
|
|
283
|
+
abilityDescription: 'Yes Ability',
|
|
284
|
+
abilityParamsSchema: testSchema,
|
|
285
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
286
|
+
precheck: async (params, { succeed }) => {
|
|
287
|
+
return succeed();
|
|
288
|
+
},
|
|
289
|
+
execute: async (params, { succeed }) => {
|
|
290
|
+
return succeed();
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
exports.testReturnNoSchema = testReturnNoSchema;
|
|
295
|
+
// Test: Precheck with no return
|
|
296
|
+
const testPrecheckNoReturn = () => {
|
|
297
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
298
|
+
abilityParamsSchema: testSchema,
|
|
299
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
300
|
+
// @ts-expect-error - Function doesn't return anything
|
|
301
|
+
precheck: async (params, { succeed }) => {
|
|
302
|
+
// No return statement
|
|
303
|
+
},
|
|
304
|
+
execute: async (params, { succeed }) => {
|
|
305
|
+
return succeed();
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
exports.testPrecheckNoReturn = testPrecheckNoReturn;
|
|
310
|
+
// Test: Execute with no return
|
|
311
|
+
const testExecuteNoReturn = () => {
|
|
312
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
313
|
+
abilityParamsSchema: testSchema,
|
|
314
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
315
|
+
precheck: async (params, { succeed }) => {
|
|
316
|
+
return succeed();
|
|
317
|
+
},
|
|
318
|
+
// @ts-expect-error - Function doesn't return anything
|
|
319
|
+
execute: async (params, { succeed }) => {
|
|
320
|
+
// No return statement
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
exports.testExecuteNoReturn = testExecuteNoReturn;
|
|
325
|
+
// Test: Precheck returning raw value
|
|
326
|
+
const testPrecheckRawReturn = () => {
|
|
327
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
328
|
+
abilityParamsSchema: testSchema,
|
|
329
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
330
|
+
// @ts-expect-error - Returning raw value instead of AbilityPrecheckResponse
|
|
331
|
+
precheck: async (params, { succeed }) => {
|
|
332
|
+
return true;
|
|
333
|
+
},
|
|
334
|
+
execute: async (params, { succeed }) => {
|
|
335
|
+
return succeed();
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
exports.testPrecheckRawReturn = testPrecheckRawReturn;
|
|
340
|
+
// Test: Execute returning raw value
|
|
341
|
+
const testExecuteRawReturn = () => {
|
|
342
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
343
|
+
success: zod_1.z.boolean(),
|
|
344
|
+
message: zod_1.z.string(),
|
|
345
|
+
});
|
|
346
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
347
|
+
abilityParamsSchema: testSchema,
|
|
348
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
349
|
+
executeSuccessSchema,
|
|
350
|
+
precheck: async (params, { succeed }) => {
|
|
351
|
+
return succeed();
|
|
352
|
+
},
|
|
353
|
+
// @ts-expect-error - Returning raw object instead of AbilityExecutionResponse
|
|
354
|
+
execute: async (params, { succeed }) => {
|
|
355
|
+
return { success: true, message: 'test' };
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
exports.testExecuteRawReturn = testExecuteRawReturn;
|
|
360
|
+
// Test: Execute returning wrong type object
|
|
361
|
+
const testExecuteWrongTypeReturn = () => {
|
|
362
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
363
|
+
success: zod_1.z.boolean(),
|
|
364
|
+
message: zod_1.z.string(),
|
|
365
|
+
});
|
|
366
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
367
|
+
packageName: '@lit-protocol/yesability7@1.0.0',
|
|
368
|
+
abilityDescription: 'Yes Ability',
|
|
369
|
+
abilityParamsSchema: testSchema,
|
|
370
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
371
|
+
executeSuccessSchema,
|
|
372
|
+
precheck: async (params, { succeed }) => {
|
|
373
|
+
return succeed();
|
|
374
|
+
},
|
|
375
|
+
execute: async (params, { succeed }) => {
|
|
376
|
+
// This is correct
|
|
377
|
+
// return context.succeed({ success: true, message: "test" });
|
|
378
|
+
// @ts-expect-error - Wrong type of return object
|
|
379
|
+
return succeed({ wrongField: 'test' });
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
exports.testExecuteWrongTypeReturn = testExecuteWrongTypeReturn;
|
|
384
|
+
// Test: Precheck returning wrong schema
|
|
385
|
+
const testPrecheckWrongSchema = () => {
|
|
386
|
+
const precheckSuccessSchema = zod_1.z.object({
|
|
387
|
+
valid: zod_1.z.boolean(),
|
|
388
|
+
});
|
|
389
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
390
|
+
result: zod_1.z.string(),
|
|
391
|
+
});
|
|
392
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
393
|
+
packageName: '@lit-protocol/yesability7@1.0.0',
|
|
394
|
+
abilityDescription: 'Yes Ability',
|
|
395
|
+
abilityParamsSchema: testSchema,
|
|
396
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
397
|
+
precheckSuccessSchema,
|
|
398
|
+
executeSuccessSchema,
|
|
399
|
+
precheck: async (params, { succeed }) => {
|
|
400
|
+
// This would be correct
|
|
401
|
+
// return context.succeed({ valid: true });
|
|
402
|
+
// @ts-expect-error - Using execute schema for precheck return
|
|
403
|
+
return succeed({ result: 'test' });
|
|
404
|
+
},
|
|
405
|
+
execute: async (params, { succeed }) => {
|
|
406
|
+
return succeed({ result: 'test' });
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
exports.testPrecheckWrongSchema = testPrecheckWrongSchema;
|
|
411
|
+
// Test: Execute returning precheck schema
|
|
412
|
+
const testExecuteWrongSchema = () => {
|
|
413
|
+
const precheckSuccessSchema = zod_1.z.object({
|
|
414
|
+
valid: zod_1.z.boolean(),
|
|
415
|
+
});
|
|
416
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
417
|
+
result: zod_1.z.string(),
|
|
418
|
+
});
|
|
419
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
420
|
+
packageName: '@lit-protocol/yesability8@1.0.0',
|
|
421
|
+
abilityDescription: 'Yes Ability',
|
|
422
|
+
abilityParamsSchema: testSchema,
|
|
423
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
424
|
+
precheckSuccessSchema,
|
|
425
|
+
executeSuccessSchema,
|
|
426
|
+
precheck: async (params, { succeed }) => {
|
|
427
|
+
return succeed({ valid: true });
|
|
428
|
+
},
|
|
429
|
+
execute: async (params, { succeed }) => {
|
|
430
|
+
// This would be correct
|
|
431
|
+
// return context.succeed({ result: "test" });
|
|
432
|
+
// @ts-expect-error - Using precheck schema for execute return
|
|
433
|
+
return succeed({ valid: true });
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
exports.testExecuteWrongSchema = testExecuteWrongSchema;
|
|
438
|
+
// Test: Precheck returning fail from success schema
|
|
439
|
+
const testPrecheckSuccessWithFailSchema = () => {
|
|
440
|
+
const precheckSuccessSchema = zod_1.z.object({
|
|
441
|
+
valid: zod_1.z.boolean(),
|
|
442
|
+
});
|
|
443
|
+
const precheckFailSchema = zod_1.z.object({
|
|
444
|
+
reason: zod_1.z.string(),
|
|
445
|
+
code: zod_1.z.number(),
|
|
446
|
+
});
|
|
447
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
448
|
+
packageName: '@lit-protocol/yesability9@1.0.0',
|
|
449
|
+
abilityDescription: 'Yes Ability',
|
|
450
|
+
abilityParamsSchema: testSchema,
|
|
451
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
452
|
+
precheckSuccessSchema,
|
|
453
|
+
precheckFailSchema,
|
|
454
|
+
precheck: async (params, { succeed, fail }) => {
|
|
455
|
+
if (Math.random() > 0.5) {
|
|
456
|
+
return succeed({ valid: true });
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
// This would be correct
|
|
460
|
+
// return context.fail({ reason: "test", code: 400 });
|
|
461
|
+
// @ts-expect-error - Using success schema for fail return
|
|
462
|
+
return fail({ valid: false });
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
execute: async (params, { succeed }) => {
|
|
466
|
+
return succeed();
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
exports.testPrecheckSuccessWithFailSchema = testPrecheckSuccessWithFailSchema;
|
|
471
|
+
// Test: Execute returning fail with success schema
|
|
472
|
+
const testExecuteFailWithSuccessSchema = () => {
|
|
473
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
474
|
+
result: zod_1.z.string(),
|
|
475
|
+
});
|
|
476
|
+
const executeFailSchema = zod_1.z.object({
|
|
477
|
+
error: zod_1.z.string(),
|
|
478
|
+
code: zod_1.z.number(),
|
|
479
|
+
});
|
|
480
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
481
|
+
packageName: '@lit-protocol/yesability10@1.0.0',
|
|
482
|
+
abilityDescription: 'Yes Ability',
|
|
483
|
+
abilityParamsSchema: testSchema,
|
|
484
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
485
|
+
executeSuccessSchema,
|
|
486
|
+
executeFailSchema,
|
|
487
|
+
precheck: async (params, { succeed }) => {
|
|
488
|
+
return succeed();
|
|
489
|
+
},
|
|
490
|
+
execute: async (params, { succeed, fail }) => {
|
|
491
|
+
if (Math.random() > 0.5) {
|
|
492
|
+
return succeed({ result: 'test' });
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
// This would be correct
|
|
496
|
+
// return context.fail({ error: "test", code: 400 });
|
|
497
|
+
// @ts-expect-error - Using success schema for fail return
|
|
498
|
+
return fail({ result: 'error' });
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
exports.testExecuteFailWithSuccessSchema = testExecuteFailWithSuccessSchema;
|
|
504
|
+
// Test: Ability with void-returning functions inside
|
|
505
|
+
const testReturnWithInnerFunctions = () => {
|
|
506
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
507
|
+
packageName: '@lit-protocol/yesability11@1.0.0',
|
|
508
|
+
abilityDescription: 'Yes Ability',
|
|
509
|
+
abilityParamsSchema: testSchema,
|
|
510
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
511
|
+
precheck: async (params, { succeed }) => {
|
|
512
|
+
// Internal function that doesn't return anything shouldn't affect the overall return type
|
|
513
|
+
const logDetails = () => {
|
|
514
|
+
console.log('Details:', params);
|
|
515
|
+
// No return here is fine
|
|
516
|
+
};
|
|
517
|
+
logDetails();
|
|
518
|
+
return succeed();
|
|
519
|
+
},
|
|
520
|
+
execute: async (params, { succeed }) => {
|
|
521
|
+
// Internal async function with no return
|
|
522
|
+
const processData = async () => {
|
|
523
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
524
|
+
// No return here is fine
|
|
525
|
+
};
|
|
526
|
+
await processData();
|
|
527
|
+
return succeed();
|
|
528
|
+
},
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
exports.testReturnWithInnerFunctions = testReturnWithInnerFunctions;
|
|
532
|
+
// Test: Conditional returns in precheck
|
|
533
|
+
const testPrecheckConditionalReturns = () => {
|
|
534
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
535
|
+
abilityParamsSchema: testSchema,
|
|
536
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
537
|
+
// @ts-expect-error - Missing return in one code path
|
|
538
|
+
precheck: async ({ abilityParams }, { succeed }) => {
|
|
539
|
+
if (abilityParams.action === 'test') {
|
|
540
|
+
return succeed();
|
|
541
|
+
}
|
|
542
|
+
// Missing return in this path
|
|
543
|
+
},
|
|
544
|
+
execute: async (params, { succeed }) => {
|
|
545
|
+
return succeed();
|
|
546
|
+
},
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
exports.testPrecheckConditionalReturns = testPrecheckConditionalReturns;
|
|
550
|
+
// Test: Conditional returns in execute
|
|
551
|
+
const testExecuteConditionalReturns = () => {
|
|
552
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
553
|
+
abilityParamsSchema: testSchema,
|
|
554
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
555
|
+
precheck: async (_, { succeed }) => {
|
|
556
|
+
return succeed();
|
|
557
|
+
},
|
|
558
|
+
// @ts-expect-error - Missing return in one code path
|
|
559
|
+
execute: async ({ abilityParams }, { succeed }) => {
|
|
560
|
+
if (abilityParams.action === 'test') {
|
|
561
|
+
return succeed();
|
|
562
|
+
}
|
|
563
|
+
// Missing return in this path
|
|
564
|
+
},
|
|
565
|
+
});
|
|
566
|
+
};
|
|
567
|
+
exports.testExecuteConditionalReturns = testExecuteConditionalReturns;
|
|
568
|
+
// Test: Async precheck without await or return
|
|
569
|
+
const testPrecheckAsyncWithoutAwait = () => {
|
|
570
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
571
|
+
abilityParamsSchema: testSchema,
|
|
572
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
573
|
+
// @ts-expect-error - Missing return from async function that calls other async functions
|
|
574
|
+
precheck: async (params, { succeed }) => {
|
|
575
|
+
// Call async function without await or using its result
|
|
576
|
+
await fetchData();
|
|
577
|
+
async function fetchData() {
|
|
578
|
+
return succeed();
|
|
579
|
+
}
|
|
580
|
+
// No return here
|
|
581
|
+
},
|
|
582
|
+
execute: async (params, { succeed }) => {
|
|
583
|
+
return succeed();
|
|
584
|
+
},
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
exports.testPrecheckAsyncWithoutAwait = testPrecheckAsyncWithoutAwait;
|
|
588
|
+
// Test: Return from try-catch in execute
|
|
589
|
+
const testExecuteTryCatchReturn = () => {
|
|
590
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
591
|
+
abilityParamsSchema: testSchema,
|
|
592
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
593
|
+
precheck: async (params, { succeed }) => {
|
|
594
|
+
return succeed();
|
|
595
|
+
},
|
|
596
|
+
// @ts-expect-error - Missing return in catch block
|
|
597
|
+
execute: async (params, { succeed, fail }) => {
|
|
598
|
+
try {
|
|
599
|
+
// This is fine
|
|
600
|
+
return succeed();
|
|
601
|
+
}
|
|
602
|
+
catch (error) {
|
|
603
|
+
// Missing return here
|
|
604
|
+
// @ts-expect-error Can't call fail w/ string when no schema
|
|
605
|
+
fail('Error occurred');
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
exports.testExecuteTryCatchReturn = testExecuteTryCatchReturn;
|
|
611
|
+
/**
|
|
612
|
+
* Test Case 7: Context destructuring maintains type safety
|
|
613
|
+
*/
|
|
614
|
+
function testContextDestructuring() {
|
|
615
|
+
const executeSuccessSchema = zod_1.z.object({
|
|
616
|
+
data: zod_1.z.string(),
|
|
617
|
+
});
|
|
618
|
+
return (0, vincentAbility_1.createVincentAbility)({
|
|
619
|
+
packageName: '@lit-protocol/yesability12@1.0.0',
|
|
620
|
+
abilityDescription: 'Yes Ability',
|
|
621
|
+
abilityParamsSchema: testSchema,
|
|
622
|
+
supportedPolicies: (0, helpers_1.supportedPoliciesForAbility)([testPolicy]),
|
|
623
|
+
executeSuccessSchema,
|
|
624
|
+
precheck: async (params, { succeed }) => {
|
|
625
|
+
// Destructuring should maintain type safety
|
|
626
|
+
// This should all work
|
|
627
|
+
succeed();
|
|
628
|
+
// @ts-expect-error - Wrong parameter type for succeed
|
|
629
|
+
succeed({ wrongField: true });
|
|
630
|
+
return succeed();
|
|
631
|
+
},
|
|
632
|
+
execute: async (params, { succeed }) => {
|
|
633
|
+
// Destructuring with type-specific functions
|
|
634
|
+
// Should be type safe
|
|
635
|
+
succeed({ data: 'result' });
|
|
636
|
+
// @ts-expect-error - Wrong field name
|
|
637
|
+
succeed({ wrongField: 'result' });
|
|
638
|
+
// @ts-expect-error - Missing required field
|
|
639
|
+
succeed({});
|
|
640
|
+
return succeed({ data: 'final result' });
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
//# sourceMappingURL=allow-deny-test-cases-ability.js.map
|