@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,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExpired = isExpired;
4
+ /** Checks if a JWT is expired based on its 'exp' claim
5
+ *
6
+ * @returns true if expired, false otherwise
7
+ * @param decodedJWT
8
+ * @category API
9
+ */
10
+ function isExpired(decodedJWT) {
11
+ const { payload } = decodedJWT;
12
+ // Tokens that never expire are treated as expired for security.
13
+ if (!payload.exp) {
14
+ return true;
15
+ }
16
+ // JWT exp is in seconds, Date.now() is in milliseconds
17
+ const currentTime = Math.floor(Date.now() / 1000);
18
+ return currentTime >= payload.exp;
19
+ }
20
+ //# sourceMappingURL=isExpired.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExpired.js","sourceRoot":"","sources":["../../../../src/jwt/core/isExpired.ts"],"names":[],"mappings":";;AAQA,8BAWC;AAjBD;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,UAAsB;IAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAE/B,gEAAgE;IAChE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uDAAuD;IACvD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;AACpC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Decodes a base64 or base64url string into a Uint8Array.
3
+ * Works in Node.js, Deno, browsers, and Web Workers.
4
+ *
5
+ * No Buffer polyfill requirement.
6
+ */
7
+ export declare function fromBase64(base64: string): Uint8Array;
8
+ /**
9
+ * Converts a Uint8Array to a base64url-encoded string.
10
+ * Works in all JS environments (Node.js, Deno, browser, Web Workers).
11
+ * No Buffer polyfill requirement.
12
+ */
13
+ export declare function toBase64Url(bytes: Uint8Array): string;
14
+ //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/base64.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAuBrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAkBrD"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fromBase64 = fromBase64;
4
+ exports.toBase64Url = toBase64Url;
5
+ /**
6
+ * Decodes a base64 or base64url string into a Uint8Array.
7
+ * Works in Node.js, Deno, browsers, and Web Workers.
8
+ *
9
+ * No Buffer polyfill requirement.
10
+ */
11
+ function fromBase64(base64) {
12
+ // Normalize base64url → base64
13
+ const normalized = base64
14
+ .replace(/-/g, '+')
15
+ .replace(/_/g, '/')
16
+ .padEnd(Math.ceil(base64.length / 4) * 4, '=');
17
+ // Node.js
18
+ if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') {
19
+ return new Uint8Array(Buffer.from(normalized, 'base64'));
20
+ }
21
+ // Browser / Web Worker / Deno
22
+ if (typeof atob !== 'undefined') {
23
+ const binary = atob(normalized);
24
+ const bytes = new Uint8Array(binary.length);
25
+ for (let i = 0; i < binary.length; i++) {
26
+ bytes[i] = binary.charCodeAt(i);
27
+ }
28
+ return bytes;
29
+ }
30
+ throw new Error('No base64 decoding method available in this environment.');
31
+ }
32
+ /**
33
+ * Converts a Uint8Array to a base64url-encoded string.
34
+ * Works in all JS environments (Node.js, Deno, browser, Web Workers).
35
+ * No Buffer polyfill requirement.
36
+ */
37
+ function toBase64Url(bytes) {
38
+ // Node.js
39
+ if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') {
40
+ return Buffer.from(bytes)
41
+ .toString('base64')
42
+ .replace(/\+/g, '-')
43
+ .replace(/\//g, '_')
44
+ .replace(/=+$/, '');
45
+ }
46
+ // Browser / Deno / Web Worker
47
+ if (typeof btoa !== 'undefined') {
48
+ const binString = String.fromCharCode(...bytes);
49
+ const base64 = btoa(binString);
50
+ return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
51
+ }
52
+ throw new Error('No base64 encoding method available in this environment.');
53
+ }
54
+ //# sourceMappingURL=base64.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/base64.ts"],"names":[],"mappings":";;AAMA,gCAuBC;AAOD,kCAkBC;AAtDD;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,MAAc;IACvC,+BAA+B;IAC/B,MAAM,UAAU,GAAG,MAAM;SACtB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;SAClB,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;SAClB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAEjD,UAAU;IACV,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,8BAA8B;IAC9B,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,KAAK,GAA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
1
+ {"version":3,"file":"definedObject.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/definedObject.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE/D"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDefinedObject = isDefinedObject;
4
+ function isDefinedObject(value) {
5
+ return typeof value === 'object' && value !== null;
6
+ }
7
+ //# sourceMappingURL=definedObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definedObject.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/definedObject.ts"],"names":[],"mappings":";;AAAA,0CAEC;AAFD,SAAgB,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { isDefinedObject } from './definedObject';
2
+ export { validateJWTTime } from './validateJWTTime';
3
+ export { splitJWT } from './splitJWT';
4
+ export { processJWTSignature } from './processJWTSignature';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processJWTSignature = exports.splitJWT = exports.validateJWTTime = exports.isDefinedObject = void 0;
4
+ var definedObject_1 = require("./definedObject");
5
+ Object.defineProperty(exports, "isDefinedObject", { enumerable: true, get: function () { return definedObject_1.isDefinedObject; } });
6
+ var validateJWTTime_1 = require("./validateJWTTime");
7
+ Object.defineProperty(exports, "validateJWTTime", { enumerable: true, get: function () { return validateJWTTime_1.validateJWTTime; } });
8
+ var splitJWT_1 = require("./splitJWT");
9
+ Object.defineProperty(exports, "splitJWT", { enumerable: true, get: function () { return splitJWT_1.splitJWT; } });
10
+ var processJWTSignature_1 = require("./processJWTSignature");
11
+ Object.defineProperty(exports, "processJWTSignature", { enumerable: true, get: function () { return processJWTSignature_1.processJWTSignature; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/index.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAAzC,gHAAA,eAAe,OAAA;AACxB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,8 @@
1
+ /** Processes a JWT signature from base64url to binary
2
+ * @ignore
3
+ *
4
+ * @param signature - The base64url encoded signature string
5
+ * @returns A Uint8Array of the binary signature
6
+ */
7
+ export declare function processJWTSignature(signature: string): Uint8Array;
8
+ //# sourceMappingURL=processJWTSignature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processJWTSignature.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/processJWTSignature.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAEjE"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processJWTSignature = processJWTSignature;
4
+ const base64_1 = require("./base64");
5
+ /** Processes a JWT signature from base64url to binary
6
+ * @ignore
7
+ *
8
+ * @param signature - The base64url encoded signature string
9
+ * @returns A Uint8Array of the binary signature
10
+ */
11
+ function processJWTSignature(signature) {
12
+ return (0, base64_1.fromBase64)(signature);
13
+ }
14
+ //# sourceMappingURL=processJWTSignature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processJWTSignature.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/processJWTSignature.ts"],"names":[],"mappings":";;AAQA,kDAEC;AAVD,qCAAsC;AAEtC;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,OAAO,IAAA,mBAAU,EAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** Splits a JWT into its signed data portion and signature
2
+ * @ignore
3
+ *
4
+ * @param jwt - The JWT string
5
+ * @returns An object with signedData and signature
6
+ */
7
+ export declare function splitJWT(jwt: string): {
8
+ signedData: string;
9
+ signature: string;
10
+ };
11
+ //# sourceMappingURL=splitJWT.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitJWT.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/splitJWT.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAU/E"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitJWT = splitJWT;
4
+ const did_jwt_1 = require("did-jwt");
5
+ /** Splits a JWT into its signed data portion and signature
6
+ * @ignore
7
+ *
8
+ * @param jwt - The JWT string
9
+ * @returns An object with signedData and signature
10
+ */
11
+ function splitJWT(jwt) {
12
+ const parts = jwt.split('.');
13
+ if (parts.length !== 3) {
14
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT format: must contain 3 parts separated by "."`);
15
+ }
16
+ return {
17
+ signedData: `${parts[0]}.${parts[1]}`,
18
+ signature: parts[2],
19
+ };
20
+ }
21
+ //# sourceMappingURL=splitJWT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitJWT.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/splitJWT.ts"],"names":[],"mappings":";;AAQA,4BAUC;AAlBD,qCAAoC;AAEpC;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,qDAAqD,CAAC,CAAC;IACjG,CAAC;IAED,OAAO;QACL,UAAU,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;QACrC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /** Validates JWT time claims (iat and nbf)
2
+ * @ignore
3
+ *
4
+ * @param payload - The decoded JWT payload
5
+ * @param currentTime The time to compare the claims against
6
+ * @returns true if time claims are valid, false otherwise
7
+ */
8
+ export declare function validateJWTTime(payload: {
9
+ nbf?: number;
10
+ iat?: number;
11
+ }, currentTime: number): boolean;
12
+ //# sourceMappingURL=validateJWTTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateJWTTime.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/validateJWTTime.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAeT"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateJWTTime = validateJWTTime;
4
+ const did_jwt_1 = require("did-jwt");
5
+ /** Validates JWT time claims (iat and nbf)
6
+ * @ignore
7
+ *
8
+ * @param payload - The decoded JWT payload
9
+ * @param currentTime The time to compare the claims against
10
+ * @returns true if time claims are valid, false otherwise
11
+ */
12
+ function validateJWTTime(payload, currentTime) {
13
+ // Check 'not before' claim if present
14
+ if (payload.nbf && currentTime < payload.nbf) {
15
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Token not yet valid (nbf claim is in the future)`);
16
+ }
17
+ // Check 'issued at' claim if present
18
+ // Allow a small leeway (30 seconds) for clock skew
19
+ if (payload.iat && currentTime < payload.iat - 30) {
20
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Token issued in the future (iat claim is ahead of current time)`);
21
+ }
22
+ return true;
23
+ }
24
+ //# sourceMappingURL=validateJWTTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateJWTTime.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/validateJWTTime.ts"],"names":[],"mappings":";;AASA,0CAkBC;AA3BD,qCAAoC;AAEpC;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,OAAuC,EACvC,WAAmB;IAEnB,sCAAsC;IACtC,IAAI,OAAO,CAAC,GAAG,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,oDAAoD,CAAC,CAAC;IAChG,CAAC;IAED,qCAAqC;IACrC,mDAAmD;IACnD,IAAI,OAAO,CAAC,GAAG,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,GAAG,mBAAS,CAAC,WAAW,mEAAmE,CAC5F,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { VincentJWT, VincentJWTAppSpecific } from '../types';
2
+ export declare function verify({ jwt, expectedAudience, }: {
3
+ jwt: string;
4
+ expectedAudience: string;
5
+ requiredAppId: undefined;
6
+ }): VincentJWT;
7
+ export declare function verify({ jwt, expectedAudience, requiredAppId, }: {
8
+ jwt: string;
9
+ expectedAudience: string;
10
+ requiredAppId: number;
11
+ }): VincentJWTAppSpecific;
12
+ export declare function verify({ jwt, expectedAudience, requiredAppId, }: {
13
+ jwt: string;
14
+ expectedAudience: string;
15
+ requiredAppId: number | undefined;
16
+ }): VincentJWT | VincentJWTAppSpecific;
17
+ export declare function decode({ jwt, requiredAppId, }: {
18
+ jwt: string;
19
+ requiredAppId: undefined;
20
+ }): VincentJWT;
21
+ export declare function decode({ jwt, requiredAppId, }: {
22
+ jwt: string;
23
+ requiredAppId: number;
24
+ }): VincentJWTAppSpecific;
25
+ export declare function decode({ jwt, requiredAppId, }: {
26
+ jwt: string;
27
+ requiredAppId: number | undefined;
28
+ }): VincentJWT | VincentJWTAppSpecific;
29
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,gBAAgB,GACjB,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,SAAS,CAAC;CAC1B,GAAG,UAAU,CAAC;AAEf,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,gBAAgB,EAChB,aAAa,GACd,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAAC;AAE1B,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,gBAAgB,EAChB,aAAa,GACd,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,GAAG,UAAU,GAAG,qBAAqB,CAAC;AA4GvC,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,aAAa,GACd,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,SAAS,CAAC;CAC1B,GAAG,UAAU,CAAC;AAEf,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,aAAa,GACd,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,qBAAqB,CAAC;AAE1B,wBAAgB,MAAM,CAAC,EACrB,GAAG,EACH,aAAa,GACd,EAAE;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,GAAG,UAAU,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verify = verify;
4
+ exports.decode = decode;
5
+ const tslib_1 = require("tslib");
6
+ const secp256k1 = tslib_1.__importStar(require("@noble/secp256k1"));
7
+ const didJWT = tslib_1.__importStar(require("did-jwt"));
8
+ const did_jwt_1 = require("did-jwt");
9
+ const ethers_1 = require("ethers");
10
+ const utils_1 = require("ethers/lib/utils");
11
+ const typeGuards_1 = require("../typeGuards");
12
+ const isExpired_1 = require("./isExpired");
13
+ const utils_2 = require("./utils");
14
+ /**
15
+ * Decodes and verifies an {@link VincentJWT} token in string form
16
+ *
17
+ * This function returns the decoded {@link VincentJWT} object only if:
18
+ * 1. The JWT signature is valid
19
+ * 2. The JWT is not expired
20
+ * 3. All time claims (nbf, iat) are valid
21
+ * 4. The JWT has an audience claim that includes the expected audience
22
+ *
23
+ * @param params
24
+ * @param jwt - The JWT string to verify
25
+ * @param expectedAudience - String that should be in the audience claim(s)
26
+ * @param requiredAppId - The appId that should be in the payload of the JWT. If app is not defined, or app.id is different, this method will throw.
27
+ *
28
+ * @returns {VincentJWT} The decoded VincentJWT object if it was verified successfully
29
+ *
30
+ * @category API
31
+ * @inline
32
+ * @expand
33
+ * @function
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { verify } from '@lit-protocol/vincent-app-sdk/jwt';
38
+ *
39
+ * try {
40
+ * const decodedAndVerifiedVincentJWT = verify({ jwt, expectedAudience: 'https://myapp.com', requiredAppId: 555 });
41
+ * } catch(e) {
42
+ * // Handle invalid/expired JWT casew
43
+ * }
44
+ * ```
45
+ */
46
+ function verify({ jwt, expectedAudience, requiredAppId, }) {
47
+ if (!expectedAudience) {
48
+ throw new Error(`You must provide an expectedAudience`);
49
+ }
50
+ const decoded = decode({ jwt, requiredAppId });
51
+ const { aud, exp, pkp } = decoded.payload;
52
+ if (!exp) {
53
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT does not contain an expiration claim (exp)`);
54
+ }
55
+ const expired = (0, isExpired_1.isExpired)(decoded);
56
+ if (expired) {
57
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT expired at ${exp}`);
58
+ }
59
+ (0, utils_2.validateJWTTime)(decoded.payload, Math.floor(Date.now() / 1000));
60
+ // Always validate audience - reject if no audience claim or expected audience isn't included
61
+ if (!aud) {
62
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT does not contain an audience claim (aud)`);
63
+ }
64
+ const audiences = Array.isArray(aud) ? aud : [aud];
65
+ if (!audiences.includes(expectedAudience)) {
66
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_AUDIENCE}: Expected audience ${expectedAudience} not found in aud claim`);
67
+ }
68
+ try {
69
+ const { signedData, signature } = (0, utils_2.splitJWT)(jwt);
70
+ // Process signature from base64url to binary
71
+ const signatureBytes = (0, utils_2.processJWTSignature)(signature);
72
+ // Extract r and s values from the signature
73
+ const r = signatureBytes.slice(0, 32);
74
+ const s = signatureBytes.slice(32, 64);
75
+ const publicKeyBytes = (0, utils_1.arrayify)(pkp.publicKey);
76
+ // PKPEthersWallet.signMessage() adds Ethereum prefix, so we need to add it here too
77
+ const ethPrefixedMessage = '\x19Ethereum Signed Message:\n' + signedData.length + signedData;
78
+ const messageHash = ethers_1.ethers.utils.keccak256((0, utils_1.toUtf8Bytes)(ethPrefixedMessage));
79
+ const messageHashBytes = (0, utils_1.arrayify)(messageHash);
80
+ const signatureForSecp = new Uint8Array([...r, ...s]);
81
+ // Verify the signature against the public key
82
+ const isVerified = secp256k1.verify(signatureForSecp, messageHashBytes, publicKeyBytes);
83
+ if (!isVerified) {
84
+ throw new Error(`Signature verify() did not pass for ${signature}`);
85
+ }
86
+ return decoded;
87
+ }
88
+ catch (error) {
89
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_SIGNATURE}: Invalid signature: ${error.message}`);
90
+ }
91
+ }
92
+ /** Decodes a Vincent JWT in string form and returns an {@link VincentJWT} decoded object for your use
93
+ *
94
+ * @param jwt - The jwt in string form. It will be decoded and checked to be sure it is not malformed.
95
+ * @param requiredAppId - The appId that should be in the payload of the JWT. If app is not defined, or app.id is different, this method will throw.
96
+ *
97
+ * <div class="box info-box">
98
+ * <p class="box-title info-box-title">
99
+ * <span class="box-icon info-icon">Info</span> Note
100
+ * </p>
101
+ * This method only <i><b>decodes</b></i> the JWT_ -- you still need to {@link verify} the JWT to be sure it is valid!
102
+ * If the JWT is expired, you need to use a {@link webAuthClient.WebAuthClient | WebAuthClient} to get a new JWT.
103
+ *
104
+ * See {@link webAuthClient.getWebAuthClient | getWebAuthClient}
105
+ *
106
+ * </div>
107
+ * @inline
108
+ * @expand
109
+ * @function
110
+ * @category API
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * import { decode, isExpired } from '@lit-protocol/vincent-app-sdk/jwt';
115
+ *
116
+ * const decodedVincentJWT = decode({ jwt, requiredAppId: 555 });
117
+ * const isJWTExpired = isExpired(decodedVincentJWT);
118
+ *
119
+ * if(!isJWTExpired) {
120
+ * // User is logged in
121
+ * // You still need to verify the JWT!
122
+ * } else {
123
+ * // User needs to get a new JWT
124
+ * webAuthClient.redirectToConnectPage({redirectUri: window.location.href });
125
+ * }
126
+ *
127
+ * ```
128
+ * */
129
+ function decode({ jwt, requiredAppId, }) {
130
+ const decodedJwt = didJWT.decodeJWT(jwt);
131
+ (0, typeGuards_1.assertIsVincentJWT)(decodedJwt);
132
+ if (requiredAppId) {
133
+ if (!(0, typeGuards_1.isAppSpecificJWT)(decodedJwt)) {
134
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT is not app specific; cannot verify requiredAppId`);
135
+ }
136
+ const { app } = decodedJwt.payload;
137
+ if (requiredAppId !== app.id) {
138
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: appId in JWT does not match requiredAppId. Expected ${requiredAppId}, got ${app.id} `);
139
+ }
140
+ }
141
+ return decodedJwt;
142
+ }
143
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":";;AAyEA,wBAwEC;AA+DD,wBA2BC;;AA3OD,oEAA8C;AAC9C,wDAAkC;AAClC,qCAAoC;AACpC,mCAAgC;AAChC,4CAAyD;AAIzD,8CAAqE;AACrE,2CAAwC;AACxC,mCAAyE;AA+BzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,MAAM,CAAC,EACrB,GAAG,EACH,gBAAgB,EAChB,aAAa,GAKd;IACC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,EAAE,GA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MAAM,IAAI,KAAK,CACb,GAAG,mBAAS,CAAC,WAAW,wDAAwD,CACjF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC;QACnC,IAAI,aAAa,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,GAAG,mBAAS,CAAC,WAAW,yDAAyD,aAAa,SAAS,GAAG,CAAC,EAAE,GAAG,CACjH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** The `jwt` module provides helper methods that allow you to decode and validate Vincent-specific JWTs.
2
+ *
3
+ * Vincent JWTs are composed using the `did-jwt` library, but have a custom `alg` of `ES256K`, and are signed using
4
+ * PKP ethereum keys.
5
+ *
6
+ * Vincent JWTs are issued by the Vincent Dashboard when a user provides delegation permission for your app to their agent PKP.
7
+ * They are passed to your web app using a redirectUri which you configure on your app.
8
+ *
9
+ * The methods exported by the `jwt` module are low-level - you probably will just want to use {@link webAuthClient.getWebAuthClient | getWebAuthClient} to get
10
+ * a {@link webAuthClient.WebAuthClient | WebAuthClient} which handles the redirect process, parsing the JWT from the URL, and verifying it for you.
11
+ *
12
+ * @packageDocumentation
13
+ *
14
+ */
15
+ export { create } from './core/create';
16
+ export { isExpired } from './core/isExpired';
17
+ export { decode, verify } from './core/validate';
18
+ export { isGeneralJWT, isAppSpecificJWT, assertIsVincentJWT } from './typeGuards';
19
+ export type { JWTConfig, VincentJWT, VincentJWTAppSpecific } from './types';
20
+ export { getAppInfo, getPKPInfo } from './accessors';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElF,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPKPInfo = exports.getAppInfo = exports.assertIsVincentJWT = exports.isAppSpecificJWT = exports.isGeneralJWT = exports.verify = exports.decode = exports.isExpired = exports.create = void 0;
4
+ /** The `jwt` module provides helper methods that allow you to decode and validate Vincent-specific JWTs.
5
+ *
6
+ * Vincent JWTs are composed using the `did-jwt` library, but have a custom `alg` of `ES256K`, and are signed using
7
+ * PKP ethereum keys.
8
+ *
9
+ * Vincent JWTs are issued by the Vincent Dashboard when a user provides delegation permission for your app to their agent PKP.
10
+ * They are passed to your web app using a redirectUri which you configure on your app.
11
+ *
12
+ * The methods exported by the `jwt` module are low-level - you probably will just want to use {@link webAuthClient.getWebAuthClient | getWebAuthClient} to get
13
+ * a {@link webAuthClient.WebAuthClient | WebAuthClient} which handles the redirect process, parsing the JWT from the URL, and verifying it for you.
14
+ *
15
+ * @packageDocumentation
16
+ *
17
+ */
18
+ var create_1 = require("./core/create");
19
+ Object.defineProperty(exports, "create", { enumerable: true, get: function () { return create_1.create; } });
20
+ var isExpired_1 = require("./core/isExpired");
21
+ Object.defineProperty(exports, "isExpired", { enumerable: true, get: function () { return isExpired_1.isExpired; } });
22
+ var validate_1 = require("./core/validate");
23
+ Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return validate_1.decode; } });
24
+ Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return validate_1.verify; } });
25
+ var typeGuards_1 = require("./typeGuards");
26
+ Object.defineProperty(exports, "isGeneralJWT", { enumerable: true, get: function () { return typeGuards_1.isGeneralJWT; } });
27
+ Object.defineProperty(exports, "isAppSpecificJWT", { enumerable: true, get: function () { return typeGuards_1.isAppSpecificJWT; } });
28
+ Object.defineProperty(exports, "assertIsVincentJWT", { enumerable: true, get: function () { return typeGuards_1.assertIsVincentJWT; } });
29
+ var accessors_1 = require("./accessors");
30
+ Object.defineProperty(exports, "getAppInfo", { enumerable: true, get: function () { return accessors_1.getAppInfo; } });
31
+ Object.defineProperty(exports, "getPKPInfo", { enumerable: true, get: function () { return accessors_1.getPKPInfo; } });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,wCAAuC;AAA9B,gGAAA,MAAM,OAAA;AACf,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,4CAAiD;AAAxC,kGAAA,MAAM,OAAA;AAAE,kGAAA,MAAM,OAAA;AACvB,2CAAkF;AAAzE,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAG3D,yCAAqD;AAA5C,uGAAA,UAAU,OAAA;AAAE,uGAAA,UAAU,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { JWTDecoded, VincentJWT, VincentJWTAppSpecific } from './types';
2
+ /** Use this typeguard function to identify if the JWT is appId specific and make subsequent type-safe
3
+ * references into the payload of the JWT
4
+ */
5
+ export declare function isAppSpecificJWT(decodedJWT: VincentJWT): decodedJWT is VincentJWTAppSpecific;
6
+ /** Use this typeguard function to identify if the JWT is a general authentication JWT that has no specific app target */
7
+ export declare function isGeneralJWT(decodedJWT: VincentJWT): decodedJWT is VincentJWT;
8
+ /** This assert function is used internally to throw if decoding a JWT that is expected to be a VincentJWT gives a malformed response.
9
+ * You probably don't need it -- use `decode()` and `verify()`
10
+ *
11
+ * @hidden
12
+ */
13
+ export declare function assertIsVincentJWT(decodedJWT: JWTDecoded): asserts decodedJWT is VincentJWT | VincentJWTAppSpecific;
14
+ //# sourceMappingURL=typeGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/jwt/typeGuards.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI7E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,qBAAqB,CAE5F;AAED,yHAAyH;AACzH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,UAAU,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,UAAU,IAAI,UAAU,GAAG,qBAAqB,CAU1D"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAppSpecificJWT = isAppSpecificJWT;
4
+ exports.isGeneralJWT = isGeneralJWT;
5
+ exports.assertIsVincentJWT = assertIsVincentJWT;
6
+ const did_jwt_1 = require("did-jwt");
7
+ const index_1 = require("./core/utils/index");
8
+ /** Use this typeguard function to identify if the JWT is appId specific and make subsequent type-safe
9
+ * references into the payload of the JWT
10
+ */
11
+ function isAppSpecificJWT(decodedJWT) {
12
+ return decodedJWT.payload.app && decodedJWT.payload.app.id;
13
+ }
14
+ /** Use this typeguard function to identify if the JWT is a general authentication JWT that has no specific app target */
15
+ function isGeneralJWT(decodedJWT) {
16
+ return !isAppSpecificJWT(decodedJWT);
17
+ }
18
+ /** This assert function is used internally to throw if decoding a JWT that is expected to be a VincentJWT gives a malformed response.
19
+ * You probably don't need it -- use `decode()` and `verify()`
20
+ *
21
+ * @hidden
22
+ */
23
+ function assertIsVincentJWT(decodedJWT) {
24
+ const { authentication, pkp } = decodedJWT.payload;
25
+ if (!(0, index_1.isDefinedObject)(authentication)) {
26
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "authentication" field in JWT payload.`);
27
+ }
28
+ if (!(0, index_1.isDefinedObject)(pkp)) {
29
+ throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "pkp" field in JWT payload.`);
30
+ }
31
+ }
32
+ //# sourceMappingURL=typeGuards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/jwt/typeGuards.ts"],"names":[],"mappings":";;AASA,4CAEC;AAGD,oCAEC;AAOD,gDAYC;AAnCD,qCAAoC;AAIpC,8CAAqD;AAErD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,UAAsB;IACrD,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,yHAAyH;AACzH,SAAgB,YAAY,CAAC,UAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,UAAsB;IAEtB,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC;IAEnD,IAAI,CAAC,IAAA,uBAAe,EAAC,cAAc,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,kDAAkD,CAAC,CAAC;IAC9F,CAAC;IAED,IAAI,CAAC,IAAA,uBAAe,EAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,uCAAuC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC"}