@lit-protocol/vincent-app-sdk 0.0.4-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.
Files changed (169) hide show
  1. package/CHANGELOG.md +207 -0
  2. package/CONTRIBUTING.md +114 -0
  3. package/README.md +216 -0
  4. package/dist/package.json +86 -0
  5. package/dist/src/abilityClient/constants.d.ts +2 -0
  6. package/dist/src/abilityClient/constants.d.ts.map +1 -0
  7. package/dist/src/abilityClient/constants.js +5 -0
  8. package/dist/src/abilityClient/constants.js.map +1 -0
  9. package/dist/src/abilityClient/execute/generateVincentAbilitySessionSigs.d.ts +8 -0
  10. package/dist/src/abilityClient/execute/generateVincentAbilitySessionSigs.d.ts.map +1 -0
  11. package/dist/src/abilityClient/execute/generateVincentAbilitySessionSigs.js +33 -0
  12. package/dist/src/abilityClient/execute/generateVincentAbilitySessionSigs.js.map +1 -0
  13. package/dist/src/abilityClient/execute/resultCreators.d.ts +71 -0
  14. package/dist/src/abilityClient/execute/resultCreators.d.ts.map +1 -0
  15. package/dist/src/abilityClient/execute/resultCreators.js +57 -0
  16. package/dist/src/abilityClient/execute/resultCreators.js.map +1 -0
  17. package/dist/src/abilityClient/execute/types.d.ts +38 -0
  18. package/dist/src/abilityClient/execute/types.d.ts.map +1 -0
  19. package/dist/src/abilityClient/execute/types.js +4 -0
  20. package/dist/src/abilityClient/execute/types.js.map +1 -0
  21. package/dist/src/abilityClient/index.d.ts +19 -0
  22. package/dist/src/abilityClient/index.d.ts.map +1 -0
  23. package/dist/src/abilityClient/index.js +26 -0
  24. package/dist/src/abilityClient/index.js.map +1 -0
  25. package/dist/src/abilityClient/precheck/resultCreators.d.ts +71 -0
  26. package/dist/src/abilityClient/precheck/resultCreators.d.ts.map +1 -0
  27. package/dist/src/abilityClient/precheck/resultCreators.js +57 -0
  28. package/dist/src/abilityClient/precheck/resultCreators.js.map +1 -0
  29. package/dist/src/abilityClient/precheck/runPolicyPrechecks.d.ts +14 -0
  30. package/dist/src/abilityClient/precheck/runPolicyPrechecks.d.ts.map +1 -0
  31. package/dist/src/abilityClient/precheck/runPolicyPrechecks.js +98 -0
  32. package/dist/src/abilityClient/precheck/runPolicyPrechecks.js.map +1 -0
  33. package/dist/src/abilityClient/precheck/types.d.ts +82 -0
  34. package/dist/src/abilityClient/precheck/types.d.ts.map +1 -0
  35. package/dist/src/abilityClient/precheck/types.js +4 -0
  36. package/dist/src/abilityClient/precheck/types.js.map +1 -0
  37. package/dist/src/abilityClient/typeGuards.d.ts +28 -0
  38. package/dist/src/abilityClient/typeGuards.d.ts.map +1 -0
  39. package/dist/src/abilityClient/typeGuards.js +67 -0
  40. package/dist/src/abilityClient/typeGuards.js.map +1 -0
  41. package/dist/src/abilityClient/types.d.ts +50 -0
  42. package/dist/src/abilityClient/types.d.ts.map +1 -0
  43. package/dist/src/abilityClient/types.js +4 -0
  44. package/dist/src/abilityClient/types.js.map +1 -0
  45. package/dist/src/abilityClient/vincentAbilityClient.d.ts +76 -0
  46. package/dist/src/abilityClient/vincentAbilityClient.d.ts.map +1 -0
  47. package/dist/src/abilityClient/vincentAbilityClient.js +285 -0
  48. package/dist/src/abilityClient/vincentAbilityClient.js.map +1 -0
  49. package/dist/src/expressMiddleware/express.d.ts +63 -0
  50. package/dist/src/expressMiddleware/express.d.ts.map +1 -0
  51. package/dist/src/expressMiddleware/express.js +125 -0
  52. package/dist/src/expressMiddleware/express.js.map +1 -0
  53. package/dist/src/expressMiddleware/index.d.ts +14 -0
  54. package/dist/src/expressMiddleware/index.d.ts.map +1 -0
  55. package/dist/src/expressMiddleware/index.js +17 -0
  56. package/dist/src/expressMiddleware/index.js.map +1 -0
  57. package/dist/src/expressMiddleware/types.d.ts +31 -0
  58. package/dist/src/expressMiddleware/types.d.ts.map +1 -0
  59. package/dist/src/expressMiddleware/types.js +3 -0
  60. package/dist/src/expressMiddleware/types.js.map +1 -0
  61. package/dist/src/index.d.ts +2 -0
  62. package/dist/src/index.d.ts.map +1 -0
  63. package/dist/src/index.js +3 -0
  64. package/dist/src/index.js.map +1 -0
  65. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +14 -0
  66. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -0
  67. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js +67 -0
  68. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -0
  69. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +7 -0
  70. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -0
  71. package/dist/src/internal/LitNodeClient/getLitNodeClient.js +25 -0
  72. package/dist/src/internal/LitNodeClient/getLitNodeClient.js.map +1 -0
  73. package/dist/src/jwt/accessors.d.ts +8 -0
  74. package/dist/src/jwt/accessors.d.ts.map +1 -0
  75. package/dist/src/jwt/accessors.js +15 -0
  76. package/dist/src/jwt/accessors.js.map +1 -0
  77. package/dist/src/jwt/core/create.d.ts +24 -0
  78. package/dist/src/jwt/core/create.d.ts.map +1 -0
  79. package/dist/src/jwt/core/create.js +95 -0
  80. package/dist/src/jwt/core/create.js.map +1 -0
  81. package/dist/src/jwt/core/isExpired.d.ts +9 -0
  82. package/dist/src/jwt/core/isExpired.d.ts.map +1 -0
  83. package/dist/src/jwt/core/isExpired.js +20 -0
  84. package/dist/src/jwt/core/isExpired.js.map +1 -0
  85. package/dist/src/jwt/core/utils/base64.d.ts +14 -0
  86. package/dist/src/jwt/core/utils/base64.d.ts.map +1 -0
  87. package/dist/src/jwt/core/utils/base64.js +54 -0
  88. package/dist/src/jwt/core/utils/base64.js.map +1 -0
  89. package/dist/src/jwt/core/utils/definedObject.d.ts +2 -0
  90. package/dist/src/jwt/core/utils/definedObject.d.ts.map +1 -0
  91. package/dist/src/jwt/core/utils/definedObject.js +7 -0
  92. package/dist/src/jwt/core/utils/definedObject.js.map +1 -0
  93. package/dist/src/jwt/core/utils/index.d.ts +5 -0
  94. package/dist/src/jwt/core/utils/index.d.ts.map +1 -0
  95. package/dist/src/jwt/core/utils/index.js +12 -0
  96. package/dist/src/jwt/core/utils/index.js.map +1 -0
  97. package/dist/src/jwt/core/utils/processJWTSignature.d.ts +8 -0
  98. package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -0
  99. package/dist/src/jwt/core/utils/processJWTSignature.js +14 -0
  100. package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -0
  101. package/dist/src/jwt/core/utils/splitJWT.d.ts +11 -0
  102. package/dist/src/jwt/core/utils/splitJWT.d.ts.map +1 -0
  103. package/dist/src/jwt/core/utils/splitJWT.js +21 -0
  104. package/dist/src/jwt/core/utils/splitJWT.js.map +1 -0
  105. package/dist/src/jwt/core/utils/validateJWTTime.d.ts +12 -0
  106. package/dist/src/jwt/core/utils/validateJWTTime.d.ts.map +1 -0
  107. package/dist/src/jwt/core/utils/validateJWTTime.js +24 -0
  108. package/dist/src/jwt/core/utils/validateJWTTime.js.map +1 -0
  109. package/dist/src/jwt/core/validate.d.ts +29 -0
  110. package/dist/src/jwt/core/validate.d.ts.map +1 -0
  111. package/dist/src/jwt/core/validate.js +143 -0
  112. package/dist/src/jwt/core/validate.js.map +1 -0
  113. package/dist/src/jwt/index.d.ts +21 -0
  114. package/dist/src/jwt/index.d.ts.map +1 -0
  115. package/dist/src/jwt/index.js +32 -0
  116. package/dist/src/jwt/index.js.map +1 -0
  117. package/dist/src/jwt/typeGuards.d.ts +14 -0
  118. package/dist/src/jwt/typeGuards.d.ts.map +1 -0
  119. package/dist/src/jwt/typeGuards.js +32 -0
  120. package/dist/src/jwt/typeGuards.js.map +1 -0
  121. package/dist/src/jwt/types.d.ts +82 -0
  122. package/dist/src/jwt/types.d.ts.map +1 -0
  123. package/dist/src/jwt/types.js +3 -0
  124. package/dist/src/jwt/types.js.map +1 -0
  125. package/dist/src/type-inference-verification/ability-client-inference.d.ts +3 -0
  126. package/dist/src/type-inference-verification/ability-client-inference.d.ts.map +1 -0
  127. package/dist/src/type-inference-verification/ability-client-inference.js +220 -0
  128. package/dist/src/type-inference-verification/ability-client-inference.js.map +1 -0
  129. package/dist/src/utils/delegation.d.ts +7 -0
  130. package/dist/src/utils/delegation.d.ts.map +1 -0
  131. package/dist/src/utils/delegation.js +18 -0
  132. package/dist/src/utils/delegation.js.map +1 -0
  133. package/dist/src/utils/index.d.ts +3 -0
  134. package/dist/src/utils/index.d.ts.map +1 -0
  135. package/dist/src/utils/index.js +6 -0
  136. package/dist/src/utils/index.js.map +1 -0
  137. package/dist/src/utils/typedocRoot.d.ts +7 -0
  138. package/dist/src/utils/typedocRoot.d.ts.map +1 -0
  139. package/dist/src/utils/typedocRoot.js +13 -0
  140. package/dist/src/utils/typedocRoot.js.map +1 -0
  141. package/dist/src/utils/types.d.ts +15 -0
  142. package/dist/src/utils/types.d.ts.map +1 -0
  143. package/dist/src/utils/types.js +3 -0
  144. package/dist/src/utils/types.js.map +1 -0
  145. package/dist/src/webAuthClient/app.d.ts +7 -0
  146. package/dist/src/webAuthClient/app.d.ts.map +1 -0
  147. package/dist/src/webAuthClient/app.js +39 -0
  148. package/dist/src/webAuthClient/app.js.map +1 -0
  149. package/dist/src/webAuthClient/constants.d.ts +3 -0
  150. package/dist/src/webAuthClient/constants.d.ts.map +1 -0
  151. package/dist/src/webAuthClient/constants.js +6 -0
  152. package/dist/src/webAuthClient/constants.js.map +1 -0
  153. package/dist/src/webAuthClient/index.d.ts +13 -0
  154. package/dist/src/webAuthClient/index.d.ts.map +1 -0
  155. package/dist/src/webAuthClient/index.js +15 -0
  156. package/dist/src/webAuthClient/index.js.map +1 -0
  157. package/dist/src/webAuthClient/internal/index.d.ts +3 -0
  158. package/dist/src/webAuthClient/internal/index.d.ts.map +1 -0
  159. package/dist/src/webAuthClient/internal/index.js +7 -0
  160. package/dist/src/webAuthClient/internal/index.js.map +1 -0
  161. package/dist/src/webAuthClient/internal/uriHelpers.d.ts +15 -0
  162. package/dist/src/webAuthClient/internal/uriHelpers.d.ts.map +1 -0
  163. package/dist/src/webAuthClient/internal/uriHelpers.js +38 -0
  164. package/dist/src/webAuthClient/internal/uriHelpers.js.map +1 -0
  165. package/dist/src/webAuthClient/types.d.ts +109 -0
  166. package/dist/src/webAuthClient/types.d.ts.map +1 -0
  167. package/dist/src/webAuthClient/types.js +3 -0
  168. package/dist/src/webAuthClient/types.js.map +1 -0
  169. package/package.json +82 -0
@@ -0,0 +1,82 @@
1
+ import type { JWTHeader, JWTPayload } from 'did-jwt';
2
+ import type { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
3
+ import type { IRelayPKP } from '@lit-protocol/types';
4
+ export interface JWTDecoded {
5
+ header: JWTHeader;
6
+ payload: JWTPayload;
7
+ signature: string;
8
+ data: string;
9
+ }
10
+ /**
11
+ * Configuration interface for creating a JWT (JSON Web Token) signed by a PKP wallet.
12
+ * Vincent App developers will likely never need this function, as the provider of the JWT is the Vincent Connect page frontend
13
+ *
14
+ * @interface JWTConfig
15
+ * @hidden
16
+ * @property pkpWallet - The PKP Ethers wallet instance used for signing the JWT
17
+ * @property pkp - The PKP object
18
+ * @property payload - Custom claims to include in the JWT payload
19
+ * @property expiresInMinutes - Token expiration time in minutes from current time
20
+ * @property [app] - The app / appversion that the JWT is limited to (if it is at all)
21
+ * @property audience - The domain(s) this token is intended for (aud claim)
22
+ * @property authentication - The authentication method used to generate the JWT.
23
+ *
24
+ */
25
+ export interface JWTConfig {
26
+ pkpWallet: PKPEthersWallet;
27
+ pkp: IRelayPKP;
28
+ payload: Record<string, unknown>;
29
+ expiresInMinutes: number;
30
+ audience: string | string[];
31
+ app?: {
32
+ id: number;
33
+ version: number;
34
+ };
35
+ authentication: {
36
+ type: string;
37
+ value?: string;
38
+ };
39
+ }
40
+ /**
41
+ * Extended payload interface for Vincent-specific JWTs.
42
+ *
43
+ * @interface BaseVincentJWTPayload
44
+ * @extends {JWTPayload} Extends the JWTPayload type from `did-jwt` with Vincent-specific properties
45
+ *
46
+ * @property pkp - The PKP details associated with the JWT.
47
+ * @property authentication - The authentication method that was used to authenticate with the PKP that generated the JWT.
48
+ *
49
+ * @category Interfaces
50
+ */
51
+ export interface BaseVincentJWTPayload extends JWTPayload {
52
+ pkp: IRelayPKP;
53
+ authentication: {
54
+ type: string;
55
+ value?: string;
56
+ };
57
+ }
58
+ /**
59
+ * Interface representing a decoded Vincent JWT
60
+ *
61
+ * @interface VincentJWT
62
+ * @property { BaseVincentJWTPayload } payload - The payload of the JWT
63
+ *
64
+ * @category Interfaces
65
+ */
66
+ export interface VincentJWT extends JWTDecoded {
67
+ payload: BaseVincentJWTPayload;
68
+ }
69
+ /** App-specific Vincent JWT payloads are used to authenticate with a specific app @ a specific version */
70
+ interface VincentJWTAppSpecificPayload extends BaseVincentJWTPayload {
71
+ app: {
72
+ id: number;
73
+ version: number;
74
+ };
75
+ }
76
+ /** VincentJWTAppSpecific type JWTs are used to signal authorization from a user to use a specific app / appVersion
77
+ */
78
+ export interface VincentJWTAppSpecific extends VincentJWT {
79
+ payload: VincentJWTAppSpecificPayload;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/jwt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,eAAe,CAAC;IAC3B,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,GAAG,CAAC,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,GAAG,EAAE,SAAS,CAAC;IACf,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED,0GAA0G;AAC1G,UAAU,4BAA6B,SAAQ,qBAAqB;IAClE,GAAG,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;GACG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,OAAO,EAAE,4BAA4B,CAAC;CACvC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/jwt/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare function run(): Promise<void>;
2
+ export declare function gogo(): Promise<void>;
3
+ //# sourceMappingURL=ability-client-inference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ability-client-inference.d.ts","sourceRoot":"","sources":["../../../src/type-inference-verification/ability-client-inference.ts"],"names":[],"mappings":"AAsEA,wBAAsB,GAAG,kBA6FxB;AAwDD,wBAAsB,IAAI,kBAiCzB"}
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = run;
4
+ exports.gogo = gogo;
5
+ const zod_1 = require("zod");
6
+ const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
7
+ const vincentAbilityClient_1 = require("../abilityClient/vincentAbilityClient");
8
+ const currencyPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
9
+ packageName: 'currency-policy',
10
+ abilityParamsSchema: zod_1.z.object({ currency: zod_1.z.string() }),
11
+ evaluate: async ({ abilityParams }, ctx) => ctx.allow({ approvedCurrency: abilityParams.currency }),
12
+ evalAllowResultSchema: zod_1.z.object({ approvedCurrency: zod_1.z.string() }),
13
+ evalDenyResultSchema: zod_1.z.object({ borked: zod_1.z.string() }),
14
+ });
15
+ const currencyAbilityPolicy = (0, vincent_ability_sdk_1.createVincentAbilityPolicy)({
16
+ abilityParamsSchema: zod_1.z.object({
17
+ currency: zod_1.z.string(),
18
+ }),
19
+ bundledVincentPolicy: (0, vincent_ability_sdk_1.asBundledVincentPolicy)(currencyPolicy, 'QmCurrency123'),
20
+ abilityParameterMappings: {
21
+ currency: 'currency',
22
+ },
23
+ });
24
+ const rateLimitPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
25
+ packageName: 'rate-limit',
26
+ abilityParamsSchema: zod_1.z.object({ userId: zod_1.z.string() }),
27
+ evaluate: async (_, ctx) => ctx.allow({ allowed: true }),
28
+ evalAllowResultSchema: zod_1.z.object({ allowed: zod_1.z.literal(true) }),
29
+ commit: async (_, ctx) => ctx.allow({ committed: true }),
30
+ commitAllowResultSchema: zod_1.z.object({ committed: zod_1.z.boolean() }),
31
+ });
32
+ const rateLimitAbilityPolicy = (0, vincent_ability_sdk_1.createVincentAbilityPolicy)({
33
+ abilityParamsSchema: zod_1.z.object({
34
+ userId: zod_1.z.string(),
35
+ }),
36
+ bundledVincentPolicy: (0, vincent_ability_sdk_1.asBundledVincentPolicy)(rateLimitPolicy, 'QmRateLimit123'),
37
+ abilityParameterMappings: {
38
+ userId: 'userId',
39
+ },
40
+ });
41
+ const abilityParamsSchema = zod_1.z.object({
42
+ currency: zod_1.z.string(),
43
+ userId: zod_1.z.string(),
44
+ });
45
+ const ability = (0, vincent_ability_sdk_1.createVincentAbility)({
46
+ packageName: '@lit-protocol/ability3@1.0.0',
47
+ abilityDescription: 'Yes Ability',
48
+ abilityParamsSchema,
49
+ supportedPolicies: (0, vincent_ability_sdk_1.supportedPoliciesForAbility)([currencyAbilityPolicy, rateLimitAbilityPolicy]),
50
+ execute: async ({ abilityParams }, ctx) => ctx.succeed({ ok: true }),
51
+ executeSuccessSchema: zod_1.z.object({ ok: zod_1.z.literal(true) }),
52
+ });
53
+ const client = (0, vincentAbilityClient_1.getVincentAbilityClient)({
54
+ bundledVincentAbility: (0, vincent_ability_sdk_1.asBundledVincentAbility)(ability, 'QmFakeAbility123'),
55
+ ethersSigner: {}, // stubbed
56
+ });
57
+ async function run() {
58
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
59
+ const abilityParams = {
60
+ currency: 'USD',
61
+ userId: 'user-123',
62
+ };
63
+ const precheckResult = await client.precheck(abilityParams, {
64
+ delegatorPkpEthAddress: '0xabc',
65
+ });
66
+ if (precheckResult.success === true) {
67
+ // ✅ Inferred success result shape
68
+ const successResult = precheckResult.result;
69
+ // Should be ok to access successResult with correct type
70
+ if (successResult !== undefined) {
71
+ // @ts-expect-error - no properties defined on undefined schema
72
+ console.log(successResult.foo);
73
+ }
74
+ const policiesContext = (_a = precheckResult === null || precheckResult === void 0 ? void 0 : precheckResult.context) === null || _a === void 0 ? void 0 : _a.policiesContext;
75
+ if (precheckResult && policiesContext && policiesContext.allow) {
76
+ const p = policiesContext.allowedPolicies;
77
+ // ✅ Should infer currency-policy result shape
78
+ if (p['currency-policy']) {
79
+ // @ts-expect-error There is no precheck result schema; result must be undefined
80
+ p['currency-policy'].result.approvedCurrency.toUpperCase();
81
+ // @ts-expect-error - no commit on currency-policy
82
+ p['currency-policy'].commit();
83
+ }
84
+ // ✅ Should infer rate-limit result shape and commit
85
+ if (p['rate-limit']) {
86
+ // @ts-expect-error There is no precheck result schema; result must be undefined
87
+ const val = p['rate-limit'].result.allowed;
88
+ console.log(val);
89
+ }
90
+ // @ts-expect-error - policy not in map
91
+ console.log(p['non-existent-policy']);
92
+ }
93
+ }
94
+ else {
95
+ // ✅ Inferred failure shape
96
+ const fail = precheckResult.result;
97
+ // @ts-expect-error - fail is z.undefined(), cannot have properties
98
+ console.log(fail.reason);
99
+ // Can still access error message
100
+ (_b = precheckResult.runtimeError) === null || _b === void 0 ? void 0 : _b.toUpperCase();
101
+ // Should still be optional policiesContext
102
+ const deniedPolicy = (_d = (_c = precheckResult.context) === null || _c === void 0 ? void 0 : _c.policiesContext) === null || _d === void 0 ? void 0 : _d.deniedPolicy;
103
+ if (deniedPolicy) {
104
+ if (deniedPolicy.packageName === 'currency-policy' &&
105
+ deniedPolicy.result &&
106
+ // @ts-expect-error There's no precheck deny schema!
107
+ deniedPolicy.result.borked) {
108
+ // @ts-expect-error There's no precheck deny schema!
109
+ console.log(deniedPolicy.result.borked);
110
+ }
111
+ console.log(deniedPolicy.result);
112
+ }
113
+ }
114
+ // 🧪 Now check execute inference
115
+ const executeResult = await client.execute(abilityParams, {
116
+ delegatorPkpEthAddress: '0x09182301238',
117
+ });
118
+ if (executeResult.success === true) {
119
+ if (executeResult.result) {
120
+ const val = executeResult.result;
121
+ // @ts-expect-error - invalid field on success result
122
+ console.log(val.failureReason);
123
+ const result = (_f = (_e = executeResult.context) === null || _e === void 0 ? void 0 : _e.policiesContext) === null || _f === void 0 ? void 0 : _f.allowedPolicies;
124
+ if (result) {
125
+ const currencyPolicyResult = result['currency-policy'];
126
+ if (currencyPolicyResult) {
127
+ console.log(currencyPolicyResult.result.approvedCurrency);
128
+ }
129
+ }
130
+ }
131
+ }
132
+ else {
133
+ console.log((_j = (_h = (_g = executeResult.context) === null || _g === void 0 ? void 0 : _g.policiesContext) === null || _h === void 0 ? void 0 : _h.deniedPolicy) === null || _j === void 0 ? void 0 : _j.result);
134
+ }
135
+ }
136
+ const fullSchemaPolicy = (0, vincent_ability_sdk_1.createVincentPolicy)({
137
+ packageName: 'full-policy',
138
+ abilityParamsSchema: zod_1.z.object({ count: zod_1.z.number() }),
139
+ evaluate: async ({ abilityParams }, ctx) => {
140
+ if (abilityParams.count > 0) {
141
+ return ctx.allow({ result: 'ok' });
142
+ }
143
+ else {
144
+ return ctx.deny({ reason: 'must be > 0' });
145
+ }
146
+ },
147
+ evalAllowResultSchema: zod_1.z.object({ result: zod_1.z.literal('ok') }),
148
+ evalDenyResultSchema: zod_1.z.object({ reason: zod_1.z.string() }),
149
+ });
150
+ const fullSchemaAbilityPolicy = (0, vincent_ability_sdk_1.createVincentAbilityPolicy)({
151
+ abilityParamsSchema: zod_1.z.object({ count: zod_1.z.number() }),
152
+ bundledVincentPolicy: (0, vincent_ability_sdk_1.asBundledVincentPolicy)(fullSchemaPolicy, 'QmFullSchema123'),
153
+ abilityParameterMappings: {
154
+ count: 'count',
155
+ },
156
+ });
157
+ const fullAbility = (0, vincent_ability_sdk_1.createVincentAbility)({
158
+ packageName: '@lit-protocol/ability3@1.0.0',
159
+ abilityDescription: 'Yes Ability',
160
+ abilityParamsSchema: zod_1.z.object({ count: zod_1.z.number() }),
161
+ supportedPolicies: (0, vincent_ability_sdk_1.supportedPoliciesForAbility)([fullSchemaAbilityPolicy]),
162
+ precheck: async ({ abilityParams }, ctx) => {
163
+ if (abilityParams.count > 10) {
164
+ return ctx.succeed({ accepted: true });
165
+ }
166
+ else {
167
+ return ctx.fail({ reason: 'too small' });
168
+ }
169
+ },
170
+ precheckSuccessSchema: zod_1.z.object({ accepted: zod_1.z.literal(true) }),
171
+ precheckFailSchema: zod_1.z.object({ reason: zod_1.z.string() }),
172
+ execute: async ({ abilityParams }, ctx) => {
173
+ if (abilityParams.count < 100) {
174
+ return ctx.succeed({ ok: true });
175
+ }
176
+ else {
177
+ return ctx.fail({ reason: 'too big' });
178
+ }
179
+ },
180
+ executeSuccessSchema: zod_1.z.object({ ok: zod_1.z.literal(true) }),
181
+ executeFailSchema: zod_1.z.object({ reason: zod_1.z.string() }),
182
+ });
183
+ const fullClient = (0, vincentAbilityClient_1.getVincentAbilityClient)({
184
+ bundledVincentAbility: (0, vincent_ability_sdk_1.asBundledVincentAbility)(fullAbility, 'QmFullAbility123'),
185
+ ethersSigner: {},
186
+ });
187
+ const fullParams = { count: 5 };
188
+ async function gogo() {
189
+ const precheck = await fullClient.precheck(fullParams, {
190
+ delegatorPkpEthAddress: '0x1sfskjdfhf',
191
+ });
192
+ if (precheck.success === true) {
193
+ const ok = precheck.result.accepted;
194
+ console.log(ok);
195
+ // @ts-expect-error foo not valid on precheck result
196
+ console.log(precheck.result.foo);
197
+ }
198
+ else {
199
+ const reason = precheck.result.reason;
200
+ console.log(reason);
201
+ // @ts-expect-error accepted not valid on failure!
202
+ console.log(precheck.result.accepted);
203
+ }
204
+ const execute = await fullClient.execute(fullParams, {
205
+ delegatorPkpEthAddress: '0x098479847928734',
206
+ });
207
+ if (execute.success === true) {
208
+ const val = execute.result.ok;
209
+ console.log(val);
210
+ // @ts-expect-error reason not valid on success result
211
+ console.log(execute.result.reason);
212
+ }
213
+ else {
214
+ const msg = execute.result.reason;
215
+ console.log(msg);
216
+ // @ts-expect-error OK not valid on failure result
217
+ console.log(execute.result.ok);
218
+ }
219
+ }
220
+ //# sourceMappingURL=ability-client-inference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ability-client-inference.js","sourceRoot":"","sources":["../../../src/type-inference-verification/ability-client-inference.ts"],"names":[],"mappings":";;AAsEA,kBA6FC;AAwDD,oBAiCC;AA5PD,6BAAwB;AAExB,2EAO2C;AAE3C,gFAAgF;AAEhF,MAAM,cAAc,GAAG,IAAA,yCAAmB,EAAC;IACzC,WAAW,EAAE,iBAAiB;I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AAE,CAAC;QAC7B,MAAM,GAAG,GAAS,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,sDAAsD;QACtD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAW,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,kDAAkD;QAClD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { GetDelegatorsAgentPkpsParams } from './types';
2
+ /** Get a (paginated) list of delegator agent PKPs for a specific app version
3
+ *
4
+ * See documentation at {@link vincent-contracts-sdk!getDelegatedPkpEthAddresses | vincent-contracts-sdk/getDelegatedPkpEthAddresses}
5
+ */
6
+ export declare function getDelegatorsAgentPkpAddresses(params: GetDelegatorsAgentPkpsParams): Promise<string[]>;
7
+ //# sourceMappingURL=delegation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.d.ts","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D;;;GAGG;AACH,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,4BAA4B,qBASxF"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDelegatorsAgentPkpAddresses = getDelegatorsAgentPkpAddresses;
4
+ const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
5
+ /** Get a (paginated) list of delegator agent PKPs for a specific app version
6
+ *
7
+ * See documentation at {@link vincent-contracts-sdk!getDelegatedPkpEthAddresses | vincent-contracts-sdk/getDelegatedPkpEthAddresses}
8
+ */
9
+ async function getDelegatorsAgentPkpAddresses(params) {
10
+ const { appId, appVersion, signer, pageOpts } = params;
11
+ const contractClient = (0, vincent_contracts_sdk_1.getClient)({ signer });
12
+ return await contractClient.getDelegatedPkpEthAddresses({
13
+ appId,
14
+ version: appVersion,
15
+ pageOpts,
16
+ });
17
+ }
18
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":";;AAQA,wEASC;AAjBD,+EAAgE;AAIhE;;;GAGG;AACI,KAAK,UAAU,8BAA8B,CAAC,MAAoC;IACvF,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEvD,MAAM,cAAc,GAAG,IAAA,iCAAS,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,MAAM,cAAc,CAAC,2BAA2B,CAAC;QACtD,KAAK;QACL,OAAO,EAAE,UAAU;QACnB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getDelegatorsAgentPkpAddresses } from './delegation';
2
+ export type { GetDelegatorsAgentPkpsParams } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,YAAY,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDelegatorsAgentPkpAddresses = void 0;
4
+ var delegation_1 = require("./delegation");
5
+ Object.defineProperty(exports, "getDelegatorsAgentPkpAddresses", { enumerable: true, get: function () { return delegation_1.getDelegatorsAgentPkpAddresses; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAArD,4HAAA,8BAA8B,OAAA"}
@@ -0,0 +1,7 @@
1
+ /** Utility functions for interacting with the Vincent delegation backend
2
+ *
3
+ * @module utils
4
+ * @packageDocumentation
5
+ */
6
+ export { getDelegatorsAgentPkpAddresses } from './delegation';
7
+ //# sourceMappingURL=typedocRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedocRoot.d.ts","sourceRoot":"","sources":["../../../src/utils/typedocRoot.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // This file exists because the function params and options are inlined and expanded, and delegated to the docs in the contracts-sdk
3
+ // We don't want them to be 'root-level' exports for Typedoc purpose, or they appear under an 'Other' category and are not navigable
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getDelegatorsAgentPkpAddresses = void 0;
6
+ /** Utility functions for interacting with the Vincent delegation backend
7
+ *
8
+ * @module utils
9
+ * @packageDocumentation
10
+ */
11
+ var delegation_1 = require("./delegation");
12
+ Object.defineProperty(exports, "getDelegatorsAgentPkpAddresses", { enumerable: true, get: function () { return delegation_1.getDelegatorsAgentPkpAddresses; } });
13
+ //# sourceMappingURL=typedocRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedocRoot.js","sourceRoot":"","sources":["../../../src/utils/typedocRoot.ts"],"names":[],"mappings":";AAAA,oIAAoI;AACpI,oIAAoI;;;AAEpI;;;;GAIG;AAEH,2CAA8D;AAArD,4HAAA,8BAA8B,OAAA"}
@@ -0,0 +1,15 @@
1
+ import type { Signer } from 'ethers';
2
+ /**
3
+ * @inline
4
+ * @expand
5
+ */
6
+ export interface GetDelegatorsAgentPkpsParams {
7
+ appId: number;
8
+ appVersion: number;
9
+ signer: Signer;
10
+ pageOpts?: {
11
+ offset?: number;
12
+ limit?: number;
13
+ };
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { WebAuthClientConfig, WebAuthClient } from './types';
2
+ /** Create a new {@link WebAuthClient} instance.
3
+ *
4
+ * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
5
+ * */
6
+ export declare const getWebAuthClient: (appClientConfig: WebAuthClientConfig) => WebAuthClient;
7
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,aAAa,EACd,MAAM,SAAS,CAAC;AAkBjB;;;KAGK;AACL,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,mBAAmB,KAAG,aA2BvE,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebAuthClient = void 0;
4
+ const constants_1 = require("./constants");
5
+ const internal_1 = require("./internal");
6
+ const { uriContainsVincentJWT, composeConnectUrl, removeSearchParam, decodeVincentJWTFromUri } = internal_1.uriHelpers;
7
+ const redirectToConnectPage = ({ appId, redirectUri, connectPageUrl, }) => window.open(composeConnectUrl(appId, redirectUri, connectPageUrl).toString(), '_self');
8
+ /** Create a new {@link WebAuthClient} instance.
9
+ *
10
+ * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
11
+ * */
12
+ const getWebAuthClient = (appClientConfig) => {
13
+ const { appId } = appClientConfig;
14
+ return {
15
+ redirectToConnectPage: (redirectConnectPageConfig) => {
16
+ const { connectPageUrl, redirectUri } = redirectConnectPageConfig;
17
+ redirectToConnectPage({
18
+ appId,
19
+ connectPageUrl,
20
+ redirectUri,
21
+ });
22
+ },
23
+ uriContainsVincentJWT: () => uriContainsVincentJWT(window.location.href),
24
+ decodeVincentJWT: (expectedAudience) => decodeVincentJWTFromUri({
25
+ uri: window.location.href,
26
+ expectedAudience: expectedAudience,
27
+ requiredAppId: appId,
28
+ }),
29
+ removeVincentJWTFromURI: () => {
30
+ const urlWithoutJWTSearchParam = removeSearchParam({
31
+ paramName: constants_1.JWT_URL_KEY,
32
+ uri: window.location.href,
33
+ });
34
+ window.history.replaceState({}, document.title, urlWithoutJWTSearchParam);
35
+ },
36
+ };
37
+ };
38
+ exports.getWebAuthClient = getWebAuthClient;
39
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/webAuthClient/app.ts"],"names":[],"mappings":";;;AAMA,2CAA0C;AAC1C,yCAAwC;AAExC,MAAM,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GAC5F,qBAAU,CAAC;AAEb,MAAM,qBAAqB,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,cAAc,GAKf,E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@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AACnF,eAAO,MAAM,WAAW,QAAQ,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JWT_URL_KEY = exports.PRODUCTION_VINCENT_DASHBOARD_URL = void 0;
4
+ exports.PRODUCTION_VINCENT_DASHBOARD_URL = 'https://dashboard.heyvincent.ai/';
5
+ exports.JWT_URL_KEY = 'jwt';
6
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/webAuthClient/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gCAAgC,GAAG,kCAAkC,CAAC;AACtE,QAAA,WAAW,GAAG,KAAK,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** The webAuthClient module contains methods and types that are used to implement authentication in Vincent web apps
2
+ * Authentication is handled via redirects to the Vincent dashboard portal that return JWTs with authentication information
3
+ * that can be used to secure your backend Vincent app UI.
4
+ *
5
+ * ```typescript
6
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
7
+ * ```
8
+ * @packageDocumentation
9
+ */
10
+ import { getWebAuthClient } from './app';
11
+ export { getWebAuthClient };
12
+ export type { WebAuthClient, WebAuthClientConfig, RedirectToVincentDelegationPageParams, } from './types';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,qCAAqC,GACtC,MAAM,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebAuthClient = void 0;
4
+ /** The webAuthClient module contains methods and types that are used to implement authentication in Vincent web apps
5
+ * Authentication is handled via redirects to the Vincent dashboard portal that return JWTs with authentication information
6
+ * that can be used to secure your backend Vincent app UI.
7
+ *
8
+ * ```typescript
9
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
10
+ * ```
11
+ * @packageDocumentation
12
+ */
13
+ const app_1 = require("./app");
14
+ Object.defineProperty(exports, "getWebAuthClient", { enumerable: true, get: function () { return app_1.getWebAuthClient; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webAuthClient/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,+BAAyC;AAEhC,iGAFA,sBAAgB,OAEA"}
@@ -0,0 +1,3 @@
1
+ import * as uriHelpers from './uriHelpers';
2
+ export { uriHelpers };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uriHelpers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const uriHelpers = tslib_1.__importStar(require("./uriHelpers"));
6
+ exports.uriHelpers = uriHelpers;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/index.ts"],"names":[],"mappings":";;;;AAAA,iEAA2C;AAElC,gCAAU"}
@@ -0,0 +1,15 @@
1
+ export declare const decodeVincentJWTFromUri: ({ uri, expectedAudience, requiredAppId, }: {
2
+ uri: string;
3
+ expectedAudience: string;
4
+ requiredAppId: number;
5
+ }) => {
6
+ decodedJWT: import("../../jwt").VincentJWTAppSpecific;
7
+ jwtStr: string;
8
+ } | null;
9
+ export declare const uriContainsVincentJWT: (uri: string) => boolean;
10
+ export declare function composeConnectUrl(appId: number, redirectUri: string, connectPageUrl?: string): URL;
11
+ export declare const removeSearchParam: ({ paramName, uri, }: {
12
+ paramName: string;
13
+ uri: string;
14
+ }) => string;
15
+ //# sourceMappingURL=uriHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriHelpers.d.ts","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/uriHelpers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,GAAI,2CAIrC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;;;QAcA,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,YAKhD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,OAK5F;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,MAKH,CAAC"}