@lit-protocol/vincent-app-sdk 0.0.4-mma

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 (172) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/CONTRIBUTING.md +115 -0
  3. package/README.md +216 -0
  4. package/dist/CHANGELOG.md +74 -0
  5. package/dist/CONTRIBUTING.md +115 -0
  6. package/dist/README.md +216 -0
  7. package/dist/package.json +86 -0
  8. package/dist/src/expressMiddleware/express.d.ts +63 -0
  9. package/dist/src/expressMiddleware/express.d.ts.map +1 -0
  10. package/dist/src/expressMiddleware/express.js +125 -0
  11. package/dist/src/expressMiddleware/express.js.map +1 -0
  12. package/dist/src/expressMiddleware/index.d.ts +14 -0
  13. package/dist/src/expressMiddleware/index.d.ts.map +1 -0
  14. package/dist/src/expressMiddleware/index.js +17 -0
  15. package/dist/src/expressMiddleware/index.js.map +1 -0
  16. package/dist/src/expressMiddleware/types.d.ts +31 -0
  17. package/dist/src/expressMiddleware/types.d.ts.map +1 -0
  18. package/dist/src/expressMiddleware/types.js +3 -0
  19. package/dist/src/expressMiddleware/types.js.map +1 -0
  20. package/dist/src/index.d.ts +2 -0
  21. package/dist/src/index.d.ts.map +1 -0
  22. package/dist/src/index.js +3 -0
  23. package/dist/src/index.js.map +1 -0
  24. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +14 -0
  25. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -0
  26. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js +67 -0
  27. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -0
  28. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +7 -0
  29. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -0
  30. package/dist/src/internal/LitNodeClient/getLitNodeClient.js +25 -0
  31. package/dist/src/internal/LitNodeClient/getLitNodeClient.js.map +1 -0
  32. package/dist/src/jwt/accessors.d.ts +8 -0
  33. package/dist/src/jwt/accessors.d.ts.map +1 -0
  34. package/dist/src/jwt/accessors.js +15 -0
  35. package/dist/src/jwt/accessors.js.map +1 -0
  36. package/dist/src/jwt/core/create.d.ts +24 -0
  37. package/dist/src/jwt/core/create.d.ts.map +1 -0
  38. package/dist/src/jwt/core/create.js +95 -0
  39. package/dist/src/jwt/core/create.js.map +1 -0
  40. package/dist/src/jwt/core/isExpired.d.ts +9 -0
  41. package/dist/src/jwt/core/isExpired.d.ts.map +1 -0
  42. package/dist/src/jwt/core/isExpired.js +20 -0
  43. package/dist/src/jwt/core/isExpired.js.map +1 -0
  44. package/dist/src/jwt/core/utils/base64.d.ts +14 -0
  45. package/dist/src/jwt/core/utils/base64.d.ts.map +1 -0
  46. package/dist/src/jwt/core/utils/base64.js +54 -0
  47. package/dist/src/jwt/core/utils/base64.js.map +1 -0
  48. package/dist/src/jwt/core/utils/definedObject.d.ts +2 -0
  49. package/dist/src/jwt/core/utils/definedObject.d.ts.map +1 -0
  50. package/dist/src/jwt/core/utils/definedObject.js +7 -0
  51. package/dist/src/jwt/core/utils/definedObject.js.map +1 -0
  52. package/dist/src/jwt/core/utils/index.d.ts +5 -0
  53. package/dist/src/jwt/core/utils/index.d.ts.map +1 -0
  54. package/dist/src/jwt/core/utils/index.js +12 -0
  55. package/dist/src/jwt/core/utils/index.js.map +1 -0
  56. package/dist/src/jwt/core/utils/processJWTSignature.d.ts +8 -0
  57. package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -0
  58. package/dist/src/jwt/core/utils/processJWTSignature.js +14 -0
  59. package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -0
  60. package/dist/src/jwt/core/utils/splitJWT.d.ts +11 -0
  61. package/dist/src/jwt/core/utils/splitJWT.d.ts.map +1 -0
  62. package/dist/src/jwt/core/utils/splitJWT.js +21 -0
  63. package/dist/src/jwt/core/utils/splitJWT.js.map +1 -0
  64. package/dist/src/jwt/core/utils/validateJWTTime.d.ts +12 -0
  65. package/dist/src/jwt/core/utils/validateJWTTime.d.ts.map +1 -0
  66. package/dist/src/jwt/core/utils/validateJWTTime.js +24 -0
  67. package/dist/src/jwt/core/utils/validateJWTTime.js.map +1 -0
  68. package/dist/src/jwt/core/validate.d.ts +29 -0
  69. package/dist/src/jwt/core/validate.d.ts.map +1 -0
  70. package/dist/src/jwt/core/validate.js +143 -0
  71. package/dist/src/jwt/core/validate.js.map +1 -0
  72. package/dist/src/jwt/index.d.ts +21 -0
  73. package/dist/src/jwt/index.d.ts.map +1 -0
  74. package/dist/src/jwt/index.js +32 -0
  75. package/dist/src/jwt/index.js.map +1 -0
  76. package/dist/src/jwt/typeGuards.d.ts +14 -0
  77. package/dist/src/jwt/typeGuards.d.ts.map +1 -0
  78. package/dist/src/jwt/typeGuards.js +32 -0
  79. package/dist/src/jwt/typeGuards.js.map +1 -0
  80. package/dist/src/jwt/types.d.ts +82 -0
  81. package/dist/src/jwt/types.d.ts.map +1 -0
  82. package/dist/src/jwt/types.js +3 -0
  83. package/dist/src/jwt/types.js.map +1 -0
  84. package/dist/src/toolClient/constants.d.ts +2 -0
  85. package/dist/src/toolClient/constants.d.ts.map +1 -0
  86. package/dist/src/toolClient/constants.js +5 -0
  87. package/dist/src/toolClient/constants.js.map +1 -0
  88. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts +8 -0
  89. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts.map +1 -0
  90. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js +33 -0
  91. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js.map +1 -0
  92. package/dist/src/toolClient/execute/resultCreators.d.ts +71 -0
  93. package/dist/src/toolClient/execute/resultCreators.d.ts.map +1 -0
  94. package/dist/src/toolClient/execute/resultCreators.js +57 -0
  95. package/dist/src/toolClient/execute/resultCreators.js.map +1 -0
  96. package/dist/src/toolClient/execute/types.d.ts +38 -0
  97. package/dist/src/toolClient/execute/types.d.ts.map +1 -0
  98. package/dist/src/toolClient/execute/types.js +4 -0
  99. package/dist/src/toolClient/execute/types.js.map +1 -0
  100. package/dist/src/toolClient/index.d.ts +19 -0
  101. package/dist/src/toolClient/index.d.ts.map +1 -0
  102. package/dist/src/toolClient/index.js +26 -0
  103. package/dist/src/toolClient/index.js.map +1 -0
  104. package/dist/src/toolClient/precheck/resultCreators.d.ts +71 -0
  105. package/dist/src/toolClient/precheck/resultCreators.d.ts.map +1 -0
  106. package/dist/src/toolClient/precheck/resultCreators.js +57 -0
  107. package/dist/src/toolClient/precheck/resultCreators.js.map +1 -0
  108. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts +14 -0
  109. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts.map +1 -0
  110. package/dist/src/toolClient/precheck/runPolicyPrechecks.js +98 -0
  111. package/dist/src/toolClient/precheck/runPolicyPrechecks.js.map +1 -0
  112. package/dist/src/toolClient/precheck/types.d.ts +82 -0
  113. package/dist/src/toolClient/precheck/types.d.ts.map +1 -0
  114. package/dist/src/toolClient/precheck/types.js +4 -0
  115. package/dist/src/toolClient/precheck/types.js.map +1 -0
  116. package/dist/src/toolClient/typeGuards.d.ts +28 -0
  117. package/dist/src/toolClient/typeGuards.d.ts.map +1 -0
  118. package/dist/src/toolClient/typeGuards.js +67 -0
  119. package/dist/src/toolClient/typeGuards.js.map +1 -0
  120. package/dist/src/toolClient/types.d.ts +50 -0
  121. package/dist/src/toolClient/types.d.ts.map +1 -0
  122. package/dist/src/toolClient/types.js +4 -0
  123. package/dist/src/toolClient/types.js.map +1 -0
  124. package/dist/src/toolClient/vincentToolClient.d.ts +76 -0
  125. package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -0
  126. package/dist/src/toolClient/vincentToolClient.js +285 -0
  127. package/dist/src/toolClient/vincentToolClient.js.map +1 -0
  128. package/dist/src/type-inference-verification/tool-client-inference.d.ts +3 -0
  129. package/dist/src/type-inference-verification/tool-client-inference.d.ts.map +1 -0
  130. package/dist/src/type-inference-verification/tool-client-inference.js +220 -0
  131. package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -0
  132. package/dist/src/utils/delegation.d.ts +7 -0
  133. package/dist/src/utils/delegation.d.ts.map +1 -0
  134. package/dist/src/utils/delegation.js +18 -0
  135. package/dist/src/utils/delegation.js.map +1 -0
  136. package/dist/src/utils/index.d.ts +3 -0
  137. package/dist/src/utils/index.d.ts.map +1 -0
  138. package/dist/src/utils/index.js +6 -0
  139. package/dist/src/utils/index.js.map +1 -0
  140. package/dist/src/utils/typedocRoot.d.ts +7 -0
  141. package/dist/src/utils/typedocRoot.d.ts.map +1 -0
  142. package/dist/src/utils/typedocRoot.js +13 -0
  143. package/dist/src/utils/typedocRoot.js.map +1 -0
  144. package/dist/src/utils/types.d.ts +15 -0
  145. package/dist/src/utils/types.d.ts.map +1 -0
  146. package/dist/src/utils/types.js +3 -0
  147. package/dist/src/utils/types.js.map +1 -0
  148. package/dist/src/webAuthClient/app.d.ts +7 -0
  149. package/dist/src/webAuthClient/app.d.ts.map +1 -0
  150. package/dist/src/webAuthClient/app.js +39 -0
  151. package/dist/src/webAuthClient/app.js.map +1 -0
  152. package/dist/src/webAuthClient/constants.d.ts +3 -0
  153. package/dist/src/webAuthClient/constants.d.ts.map +1 -0
  154. package/dist/src/webAuthClient/constants.js +6 -0
  155. package/dist/src/webAuthClient/constants.js.map +1 -0
  156. package/dist/src/webAuthClient/index.d.ts +13 -0
  157. package/dist/src/webAuthClient/index.d.ts.map +1 -0
  158. package/dist/src/webAuthClient/index.js +15 -0
  159. package/dist/src/webAuthClient/index.js.map +1 -0
  160. package/dist/src/webAuthClient/internal/index.d.ts +3 -0
  161. package/dist/src/webAuthClient/internal/index.d.ts.map +1 -0
  162. package/dist/src/webAuthClient/internal/index.js +7 -0
  163. package/dist/src/webAuthClient/internal/index.js.map +1 -0
  164. package/dist/src/webAuthClient/internal/uriHelpers.d.ts +15 -0
  165. package/dist/src/webAuthClient/internal/uriHelpers.d.ts.map +1 -0
  166. package/dist/src/webAuthClient/internal/uriHelpers.js +38 -0
  167. package/dist/src/webAuthClient/internal/uriHelpers.js.map +1 -0
  168. package/dist/src/webAuthClient/types.d.ts +109 -0
  169. package/dist/src/webAuthClient/types.d.ts.map +1 -0
  170. package/dist/src/webAuthClient/types.js +3 -0
  171. package/dist/src/webAuthClient/types.js.map +1 -0
  172. package/package.json +82 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LitNodeClientInstance = void 0;
4
+ const lit_node_client_1 = require("@lit-protocol/lit-node-client");
5
+ class LitNodeClientInstance {
6
+ constructor({ network }) {
7
+ this.isConnected = false;
8
+ this.connectHandle = null;
9
+ this.litNodeClientInstance = new lit_node_client_1.LitNodeClient({
10
+ debug: true,
11
+ litNetwork: network,
12
+ });
13
+ }
14
+ async connect() {
15
+ if (!this.isConnected) {
16
+ // Coalesce concurrent calls
17
+ if (this.connectHandle) {
18
+ return this.connectHandle;
19
+ }
20
+ // Stash a handle so concurrent calls to connect are coaelesced into 1
21
+ this.connectHandle = this.litNodeClientInstance.connect().then(() => true);
22
+ try {
23
+ // Don't return until we know the result of pending connect attempt
24
+ await this.connectHandle;
25
+ this.isConnected = true;
26
+ }
27
+ catch (e) {
28
+ // We allow multiple calls to (retries!) to `connect()` even in case where one succeeded
29
+ // if `isConnected` is false (e.g. a prior attempt failed)
30
+ this.isConnected = false;
31
+ throw e;
32
+ }
33
+ finally {
34
+ this.connectHandle = null;
35
+ }
36
+ return this.isConnected;
37
+ }
38
+ return true;
39
+ }
40
+ async disconnect() {
41
+ if (!this.isConnected && this.connectHandle) {
42
+ // Wait for connect attempt to finish so we don't end up just re-adding the listener when it finishes.
43
+ try {
44
+ await this.connectHandle;
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ }
47
+ catch (e) {
48
+ /* Ignore errors on connect; we're disconnecting! */
49
+ }
50
+ }
51
+ try {
52
+ await this.litNodeClientInstance.disconnect();
53
+ }
54
+ catch (e) {
55
+ /* We did our best */
56
+ console.log('Failed to disconnect from LitNodeClientInstance.', e.message);
57
+ }
58
+ finally {
59
+ this.isConnected = false;
60
+ }
61
+ }
62
+ get litNodeClient() {
63
+ return this.litNodeClientInstance;
64
+ }
65
+ }
66
+ exports.LitNodeClientInstance = LitNodeClientInstance;
67
+ //# sourceMappingURL=LitNodeClientInstance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LitNodeClientInstance.js","sourceRoot":"","sources":["../../../../src/internal/LitNodeClient/LitNodeClientInstance.ts"],"names":[],"mappings":";;;AAEA,mEAA8D;AAE9D,MAAa,qBAAqB;IAOhC,YAAY,EAAE,OAAO,EAAkC;QAJ/C,gBAAW,GAAG,KAAK,CAAC;QAEpB,kBAAa,GAA4B,IAAI,CAAC;QAGpD,IAAI,CAAC,qBAAqB,GAAG,IAAI,+BAAa,CAAC;YAC7C,KAAK,EAAE,IAAI;YACX,UAAU,EAAE,OAAO;SACpB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,4BAA4B;YAC5B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAC,aAAa,CAAC;YAC5B,CAAC;YAED,sEAAsE;YACtE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAE3E,IAAI,CAAC;gBACH,mEAAmE;gBACnE,MAAM,IAAI,CAAC,aAAa,CAAC;gBACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;YAC1B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,wFAAwF;gBACxF,0DAA0D;gBAC1D,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;gBACzB,MAAM,CAAC,CAAC;YACV,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC5B,CAAC;YACD,OAAO,IAAI,CAAC,WAAW,CAAC;QAC1B,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC5C,sGAAsG;YACtG,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,aAAa,CAAC;gBACzB,6DAA6D;YAC/D,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,oDAAoD;YACtD,CAAC;QACH,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,EAAE,CAAC;QAChD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,qBAAqB;YACrB,OAAO,CAAC,GAAG,CAAC,kDAAkD,EAAG,CAAW,CAAC,OAAO,CAAC,CAAC;QACxF,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;CACF;AAlED,sDAkEC"}
@@ -0,0 +1,7 @@
1
+ import type { LitNodeClient } from '@lit-protocol/lit-node-client';
2
+ import type { LIT_NETWORKS_KEYS } from '@lit-protocol/types';
3
+ export declare function getLitNodeClientInstance({ network, }: {
4
+ network: LIT_NETWORKS_KEYS;
5
+ }): Promise<LitNodeClient>;
6
+ export declare function disconnectLitNodeClientInstance(): Promise<boolean>;
7
+ //# sourceMappingURL=getLitNodeClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLitNodeClient.d.ts","sourceRoot":"","sources":["../../../../src/internal/LitNodeClient/getLitNodeClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,wBAAsB,wBAAwB,CAAC,EAC7C,OAAO,GACR,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;CAC5B,GAAG,OAAO,CAAC,aAAa,CAAC,CAYzB;AAED,wBAAsB,+BAA+B,qBAMpD"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLitNodeClientInstance = getLitNodeClientInstance;
4
+ exports.disconnectLitNodeClientInstance = disconnectLitNodeClientInstance;
5
+ const LitNodeClientInstance_1 = require("./LitNodeClientInstance");
6
+ let instance = null;
7
+ async function getLitNodeClientInstance({ network, }) {
8
+ if (instance) {
9
+ // connect() is idempotent; if we're retrying from outside, attempt to connect again
10
+ // This is a no-op if already connected 🎉 but if a prior attempt fails, it'll try again.
11
+ await instance.connect();
12
+ return instance.litNodeClient;
13
+ }
14
+ instance = new LitNodeClientInstance_1.LitNodeClientInstance({ network });
15
+ await instance.connect();
16
+ return instance.litNodeClient;
17
+ }
18
+ async function disconnectLitNodeClientInstance() {
19
+ if (instance) {
20
+ await instance.disconnect();
21
+ instance = null;
22
+ }
23
+ return true;
24
+ }
25
+ //# sourceMappingURL=getLitNodeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLitNodeClient.js","sourceRoot":"","sources":["../../../../src/internal/LitNodeClient/getLitNodeClient.ts"],"names":[],"mappings":";;AAOA,4DAgBC;AAED,0EAMC;AA5BD,mEAAgE;AAEhE,IAAI,QAAQ,GAAiC,IAAI,CAAC;AAE3C,KAAK,UAAU,wBAAwB,CAAC,EAC7C,OAAO,GAGR;IACC,IAAI,QAAQ,EAAE,CAAC;QACb,oFAAoF;QACpF,yFAAyF;QACzF,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC,aAAa,CAAC;IAChC,CAAC;IAED,QAAQ,GAAG,IAAI,6CAAqB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEzB,OAAO,QAAQ,CAAC,aAAa,CAAC;AAChC,CAAC;AAEM,KAAK,UAAU,+BAA+B;IACnD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { IRelayPKP } from '@lit-protocol/types';
2
+ import type { VincentJWT, VincentJWTAppSpecific } from './types';
3
+ export declare function getAppInfo(decodedJWT: VincentJWTAppSpecific): {
4
+ appId: number;
5
+ version: number;
6
+ };
7
+ export declare function getPKPInfo(decodedJWT: VincentJWT): IRelayPKP;
8
+ //# sourceMappingURL=accessors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessors.d.ts","sourceRoot":"","sources":["../../../src/jwt/accessors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAIjE,wBAAgB,UAAU,CAAC,UAAU,EAAE,qBAAqB,GAAG;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAMA;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,CAE5D"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAppInfo = getAppInfo;
4
+ exports.getPKPInfo = getPKPInfo;
5
+ const typeGuards_1 = require("./typeGuards");
6
+ function getAppInfo(decodedJWT) {
7
+ if (!(0, typeGuards_1.isAppSpecificJWT)(decodedJWT)) {
8
+ throw new Error('JWT is not app specific');
9
+ }
10
+ return { appId: decodedJWT.payload.app.id, version: decodedJWT.payload.app.version };
11
+ }
12
+ function getPKPInfo(decodedJWT) {
13
+ return decodedJWT.payload.pkp;
14
+ }
15
+ //# sourceMappingURL=accessors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessors.js","sourceRoot":"","sources":["../../../src/jwt/accessors.ts"],"names":[],"mappings":";;AAMA,gCASC;AAED,gCAEC;AAfD,6CAAgD;AAEhD,SAAgB,UAAU,CAAC,UAAiC;IAI1D,IAAI,CAAC,IAAA,6BAAgB,EAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;AACvF,CAAC;AAED,SAAgB,UAAU,CAAC,UAAsB;IAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;AAChC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { JWTConfig } from '../types';
2
+ /**
3
+ * Creates a JWT signed by a PKP wallet using the ES256K algorithm
4
+ *
5
+ * This function creates a JWT with the provided payload, adding standard claims
6
+ * like iat (issued at), exp (expiration), and iss (issuer). It also includes the
7
+ * PKP public key in the payload, which is used for verification.
8
+ *
9
+ * @param config - Configuration object containing all parameters for JWT creation
10
+ * @returns A promise that resolves to the signed JWT string
11
+ * @hidden
12
+ * @example
13
+ * ```typescript
14
+ * const jwt = await createPKPSignedJWT({
15
+ * pkpWallet: pkpWallet,
16
+ * pkp: pkpInfo,
17
+ * payload: { name: "Lit Protocol User", customField: "value" },
18
+ * expiresInMinutes: 30, // expires in 30 minutes
19
+ * audience: "example.com" // audience domain
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function create(config: JWTConfig): Promise<string>;
24
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAyB,MAAM,UAAU,CAAC;AA8CjE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC/D"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.create = create;
4
+ const tslib_1 = require("tslib");
5
+ const didJWT = tslib_1.__importStar(require("did-jwt"));
6
+ const ethers_1 = require("ethers");
7
+ const utils_1 = require("ethers/lib/utils");
8
+ const base64_1 = require("./utils/base64");
9
+ /**
10
+ * Creates a signer function compatible with did-jwt that uses a PKP wallet for signing
11
+ *
12
+ * This function returns a signing function that conforms to the did-jwt library's
13
+ * signer interface. When called, it signs data using the PKP wallet, formatting
14
+ * the signature according to ES256K requirements (without recovery parameter).
15
+ *
16
+ * @param pkpWallet - The PKP Ethers wallet instance that will be used for signing
17
+ * @returns A signing function that takes data and returns a base64url-encoded signature
18
+ * @private
19
+ * @example
20
+ * ```typescript
21
+ * const pkpWallet = new PKPEthersWallet({ ... });
22
+ * const signer = createPKPSigner(pkpWallet);
23
+ * const signature = await signer('data to sign');
24
+ * ```
25
+ */
26
+ function createPKPSigner(pkpWallet) {
27
+ /**
28
+ * The actual signer function conforming to the did-jwt signer interface
29
+ *
30
+ * @param data - The data to sign, either as a string or Uint8Array
31
+ * @returns A promise that resolves to the base64url-encoded signature
32
+ */
33
+ return async (data) => {
34
+ const dataBytes = typeof data === 'string' ? Uint8Array.from(Buffer.from(data, 'utf8')) : data;
35
+ const sig = await pkpWallet.signMessage(dataBytes);
36
+ const { r, s } = ethers_1.ethers.utils.splitSignature(sig);
37
+ const rBytes = (0, utils_1.arrayify)(r);
38
+ const sBytes = (0, utils_1.arrayify)(s);
39
+ // ES256K signature is r and s concatenated (64 bytes total)
40
+ const sigBytes = new Uint8Array(64);
41
+ sigBytes.set(rBytes, 0);
42
+ sigBytes.set(sBytes, 32);
43
+ return (0, base64_1.toBase64Url)(sigBytes);
44
+ };
45
+ }
46
+ /**
47
+ * Creates a JWT signed by a PKP wallet using the ES256K algorithm
48
+ *
49
+ * This function creates a JWT with the provided payload, adding standard claims
50
+ * like iat (issued at), exp (expiration), and iss (issuer). It also includes the
51
+ * PKP public key in the payload, which is used for verification.
52
+ *
53
+ * @param config - Configuration object containing all parameters for JWT creation
54
+ * @returns A promise that resolves to the signed JWT string
55
+ * @hidden
56
+ * @example
57
+ * ```typescript
58
+ * const jwt = await createPKPSignedJWT({
59
+ * pkpWallet: pkpWallet,
60
+ * pkp: pkpInfo,
61
+ * payload: { name: "Lit Protocol User", customField: "value" },
62
+ * expiresInMinutes: 30, // expires in 30 minutes
63
+ * audience: "example.com" // audience domain
64
+ * });
65
+ * ```
66
+ */
67
+ async function create(config) {
68
+ const { app, pkpWallet, pkp, payload, expiresInMinutes, audience, authentication } = config;
69
+ const signer = createPKPSigner(pkpWallet);
70
+ // iat and exp are expressed in seconds https://datatracker.ietf.org/doc/html/rfc7519
71
+ const iat = Math.floor(Date.now() / 1000);
72
+ const exp = iat + expiresInMinutes * 60;
73
+ const walletAddress = await pkpWallet.getAddress();
74
+ const fullPayload = {
75
+ ...payload,
76
+ aud: audience,
77
+ iat,
78
+ exp,
79
+ iss: `did:ethr:${walletAddress}`,
80
+ pkp,
81
+ app,
82
+ authentication: {
83
+ type: authentication.type,
84
+ ...(authentication.value ? { value: authentication.value } : {}),
85
+ },
86
+ };
87
+ const jwt = await didJWT.createJWT(fullPayload, {
88
+ issuer: `did:ethr:${walletAddress}`,
89
+ signer,
90
+ }, {
91
+ alg: 'ES256K',
92
+ });
93
+ return jwt;
94
+ }
95
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":";;AAyEA,wBAoCC;;AA7GD,wDAAkC;AAClC,mCAAgC;AAChC,4CAA4C;AAM5C,2CAA6C;AAE7C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,eAAe,CAAC,SAA0B;IACjD;;;;;OAKG;IACH,OAAO,KAAK,EAAE,IAAyB,EAAmB,EAAE;QAC1D,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/F,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,eAAM,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;QAE3B,4DAA4D;QAC5D,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;QACpC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxB,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEzB,OAAO,IAAA,oBAAW,EAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,MAAM,CAAC,MAAiB;IAC5C,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAC5F,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE1C,qFAAqF;IACrF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,GAAG,GAAG,gBAAgB,GAAG,EAAE,CAAC;IAExC,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAEnD,MAAM,WAAW,GAA0B;QACzC,GAAG,OAAO;QACV,GAAG,EAAE,QAAQ;QACb,GAAG;QACH,GAAG;QACH,GAAG,EAAE,YAAY,aAAa,EAAE;QAChC,GAAG;QACH,GAAG;QACH,cAAc,EAAE;YACd,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE;KACF,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAChC,WAAW,EACX;QACE,MAAM,EAAE,YAAY,aAAa,EAAE;QACnC,MAAM;KACP,EACD;QACE,GAAG,EAAE,QAAQ;KACd,CACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { VincentJWT } from '../types';
2
+ /** Checks if a JWT is expired based on its 'exp' claim
3
+ *
4
+ * @returns true if expired, false otherwise
5
+ * @param decodedJWT
6
+ * @category API
7
+ */
8
+ export declare function isExpired(decodedJWT: VincentJWT): boolean;
9
+ //# sourceMappingURL=isExpired.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExpired.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/isExpired.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAWzD"}
@@ -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,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,KAAiB;IAC3C,UAAU;IACV,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtB,QAAQ,CAAC,QAAQ,CAAC;aAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,8BAA8B;IAC9B,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function isDefinedObject(value: unknown): value is object;
2
+ //# sourceMappingURL=definedObject.d.ts.map
@@ -0,0 +1 @@
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"}