@lit-protocol/vincent-app-sdk 1.0.2 → 1.0.3-beta.1

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 (183) hide show
  1. package/CONTRIBUTING.md +2 -2
  2. package/README.md +12 -11
  3. package/dist/CONTRIBUTING.md +2 -2
  4. package/dist/README.md +12 -11
  5. package/dist/package.json +31 -2
  6. package/dist/src/expressMiddleware/express.d.ts +63 -0
  7. package/dist/src/expressMiddleware/express.d.ts.map +1 -0
  8. package/dist/src/expressMiddleware/express.js +125 -0
  9. package/dist/src/expressMiddleware/express.js.map +1 -0
  10. package/dist/src/expressMiddleware/index.d.ts +14 -0
  11. package/dist/src/expressMiddleware/index.d.ts.map +1 -0
  12. package/dist/src/expressMiddleware/index.js +17 -0
  13. package/dist/src/expressMiddleware/index.js.map +1 -0
  14. package/dist/src/expressMiddleware/types.d.ts +31 -0
  15. package/dist/src/expressMiddleware/types.d.ts.map +1 -0
  16. package/dist/src/expressMiddleware/types.js.map +1 -0
  17. package/dist/src/index.d.ts +1 -19
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js +0 -19
  20. package/dist/src/index.js.map +1 -1
  21. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +1 -1
  22. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -1
  23. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -1
  24. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +2 -2
  25. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -1
  26. package/dist/src/jwt/accessors.d.ts +8 -0
  27. package/dist/src/jwt/accessors.d.ts.map +1 -0
  28. package/dist/src/jwt/accessors.js +15 -0
  29. package/dist/src/jwt/accessors.js.map +1 -0
  30. package/dist/src/jwt/core/create.d.ts +2 -19
  31. package/dist/src/jwt/core/create.d.ts.map +1 -1
  32. package/dist/src/jwt/core/create.js +9 -28
  33. package/dist/src/jwt/core/create.js.map +1 -1
  34. package/dist/src/jwt/core/isExpired.d.ts +9 -0
  35. package/dist/src/jwt/core/isExpired.d.ts.map +1 -0
  36. package/dist/src/jwt/core/{utils/isJWTExpired.js → isExpired.js} +4 -3
  37. package/dist/src/jwt/core/isExpired.js.map +1 -0
  38. package/dist/src/jwt/core/utils/base64.d.ts +14 -0
  39. package/dist/src/jwt/core/utils/base64.d.ts.map +1 -0
  40. package/dist/src/jwt/core/utils/base64.js +54 -0
  41. package/dist/src/jwt/core/utils/base64.js.map +1 -0
  42. package/dist/src/jwt/core/utils/index.d.ts +0 -1
  43. package/dist/src/jwt/core/utils/index.d.ts.map +1 -1
  44. package/dist/src/jwt/core/utils/index.js +1 -3
  45. package/dist/src/jwt/core/utils/index.js.map +1 -1
  46. package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -1
  47. package/dist/src/jwt/core/utils/processJWTSignature.js +2 -9
  48. package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -1
  49. package/dist/src/jwt/core/validate.d.ts +28 -22
  50. package/dist/src/jwt/core/validate.d.ts.map +1 -1
  51. package/dist/src/jwt/core/validate.js +82 -35
  52. package/dist/src/jwt/core/validate.js.map +1 -1
  53. package/dist/src/jwt/index.d.ts +15 -63
  54. package/dist/src/jwt/index.d.ts.map +1 -1
  55. package/dist/src/jwt/index.js +24 -64
  56. package/dist/src/jwt/index.js.map +1 -1
  57. package/dist/src/jwt/typeGuards.d.ts +14 -0
  58. package/dist/src/jwt/typeGuards.d.ts.map +1 -0
  59. package/dist/src/jwt/typeGuards.js +32 -0
  60. package/dist/src/jwt/typeGuards.js.map +1 -0
  61. package/dist/src/jwt/types.d.ts +32 -22
  62. package/dist/src/jwt/types.d.ts.map +1 -1
  63. package/dist/src/toolClient/constants.d.ts +2 -0
  64. package/dist/src/toolClient/constants.d.ts.map +1 -0
  65. package/dist/src/toolClient/constants.js +5 -0
  66. package/dist/src/toolClient/constants.js.map +1 -0
  67. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts +1 -1
  68. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts.map +1 -1
  69. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js.map +1 -1
  70. package/dist/src/toolClient/execute/resultCreators.d.ts +13 -11
  71. package/dist/src/toolClient/execute/resultCreators.d.ts.map +1 -1
  72. package/dist/src/toolClient/execute/resultCreators.js +4 -2
  73. package/dist/src/toolClient/execute/resultCreators.js.map +1 -1
  74. package/dist/src/toolClient/execute/types.d.ts +6 -3
  75. package/dist/src/toolClient/execute/types.d.ts.map +1 -1
  76. package/dist/src/toolClient/index.d.ts +13 -1
  77. package/dist/src/toolClient/index.d.ts.map +1 -1
  78. package/dist/src/toolClient/index.js +19 -2
  79. package/dist/src/toolClient/index.js.map +1 -1
  80. package/dist/src/toolClient/precheck/resultCreators.d.ts +13 -9
  81. package/dist/src/toolClient/precheck/resultCreators.d.ts.map +1 -1
  82. package/dist/src/toolClient/precheck/resultCreators.js +4 -2
  83. package/dist/src/toolClient/precheck/resultCreators.js.map +1 -1
  84. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts +4 -3
  85. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts.map +1 -1
  86. package/dist/src/toolClient/precheck/runPolicyPrechecks.js +29 -17
  87. package/dist/src/toolClient/precheck/runPolicyPrechecks.js.map +1 -1
  88. package/dist/src/toolClient/precheck/types.d.ts +8 -6
  89. package/dist/src/toolClient/precheck/types.d.ts.map +1 -1
  90. package/dist/src/toolClient/typeGuards.d.ts +22 -13
  91. package/dist/src/toolClient/typeGuards.d.ts.map +1 -1
  92. package/dist/src/toolClient/typeGuards.js +32 -13
  93. package/dist/src/toolClient/typeGuards.js.map +1 -1
  94. package/dist/src/toolClient/types.d.ts.map +1 -1
  95. package/dist/src/toolClient/vincentToolClient.d.ts +53 -5
  96. package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -1
  97. package/dist/src/toolClient/vincentToolClient.js +124 -30
  98. package/dist/src/toolClient/vincentToolClient.js.map +1 -1
  99. package/dist/src/type-inference-verification/tool-client-inference.d.ts.map +1 -1
  100. package/dist/src/type-inference-verification/tool-client-inference.js +3 -1
  101. package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -1
  102. package/dist/src/utils/delegation.d.ts +4 -18
  103. package/dist/src/utils/delegation.d.ts.map +1 -1
  104. package/dist/src/utils/delegation.js +10 -79
  105. package/dist/src/utils/delegation.js.map +1 -1
  106. package/dist/src/utils/index.d.ts +2 -2
  107. package/dist/src/utils/index.d.ts.map +1 -1
  108. package/dist/src/utils/index.js +1 -1
  109. package/dist/src/utils/index.js.map +1 -1
  110. package/dist/src/utils/typedocRoot.d.ts +7 -0
  111. package/dist/src/utils/typedocRoot.d.ts.map +1 -0
  112. package/dist/src/utils/typedocRoot.js +13 -0
  113. package/dist/src/utils/typedocRoot.js.map +1 -0
  114. package/dist/src/utils/types.d.ts +15 -0
  115. package/dist/src/utils/types.d.ts.map +1 -0
  116. package/dist/src/{app → utils}/types.js.map +1 -1
  117. package/dist/src/webAuthClient/app.d.ts +7 -0
  118. package/dist/src/webAuthClient/app.d.ts.map +1 -0
  119. package/dist/src/webAuthClient/app.js +39 -0
  120. package/dist/src/webAuthClient/app.js.map +1 -0
  121. package/dist/src/webAuthClient/constants.d.ts.map +1 -0
  122. package/dist/src/webAuthClient/constants.js.map +1 -0
  123. package/dist/src/webAuthClient/index.d.ts +13 -0
  124. package/dist/src/webAuthClient/index.d.ts.map +1 -0
  125. package/dist/src/webAuthClient/index.js +15 -0
  126. package/dist/src/webAuthClient/index.js.map +1 -0
  127. package/dist/src/webAuthClient/internal/index.d.ts.map +1 -0
  128. package/dist/src/webAuthClient/internal/index.js.map +1 -0
  129. package/dist/src/webAuthClient/internal/uriHelpers.d.ts +15 -0
  130. package/dist/src/webAuthClient/internal/uriHelpers.d.ts.map +1 -0
  131. package/dist/src/{app → webAuthClient}/internal/uriHelpers.js +12 -6
  132. package/dist/src/webAuthClient/internal/uriHelpers.js.map +1 -0
  133. package/dist/src/{app → webAuthClient}/types.d.ts +33 -41
  134. package/dist/src/webAuthClient/types.d.ts.map +1 -0
  135. package/dist/src/{types.js.map → webAuthClient/types.js.map} +1 -1
  136. package/package.json +30 -3
  137. package/dist/src/app/app.d.ts +0 -9
  138. package/dist/src/app/app.d.ts.map +0 -1
  139. package/dist/src/app/app.js +0 -33
  140. package/dist/src/app/app.js.map +0 -1
  141. package/dist/src/app/constants.d.ts.map +0 -1
  142. package/dist/src/app/constants.js.map +0 -1
  143. package/dist/src/app/index.d.ts +0 -3
  144. package/dist/src/app/index.d.ts.map +0 -1
  145. package/dist/src/app/index.js +0 -6
  146. package/dist/src/app/index.js.map +0 -1
  147. package/dist/src/app/internal/index.d.ts.map +0 -1
  148. package/dist/src/app/internal/index.js.map +0 -1
  149. package/dist/src/app/internal/uriHelpers.d.ts +0 -11
  150. package/dist/src/app/internal/uriHelpers.d.ts.map +0 -1
  151. package/dist/src/app/internal/uriHelpers.js.map +0 -1
  152. package/dist/src/app/types.d.ts.map +0 -1
  153. package/dist/src/express-authentication-middleware/express.d.ts +0 -79
  154. package/dist/src/express-authentication-middleware/express.d.ts.map +0 -1
  155. package/dist/src/express-authentication-middleware/express.js +0 -137
  156. package/dist/src/express-authentication-middleware/express.js.map +0 -1
  157. package/dist/src/express-authentication-middleware/index.d.ts +0 -43
  158. package/dist/src/express-authentication-middleware/index.d.ts.map +0 -1
  159. package/dist/src/express-authentication-middleware/index.js +0 -47
  160. package/dist/src/express-authentication-middleware/index.js.map +0 -1
  161. package/dist/src/express-authentication-middleware/types.d.ts +0 -25
  162. package/dist/src/express-authentication-middleware/types.d.ts.map +0 -1
  163. package/dist/src/express-authentication-middleware/types.js.map +0 -1
  164. package/dist/src/jwt/core/utils/isJWTExpired.d.ts +0 -8
  165. package/dist/src/jwt/core/utils/isJWTExpired.d.ts.map +0 -1
  166. package/dist/src/jwt/core/utils/isJWTExpired.js.map +0 -1
  167. package/dist/src/types.d.ts +0 -5
  168. package/dist/src/types.d.ts.map +0 -1
  169. package/dist/src/utils/contracts.d.ts +0 -49
  170. package/dist/src/utils/contracts.d.ts.map +0 -1
  171. package/dist/src/utils/contracts.js +0 -92
  172. package/dist/src/utils/contracts.js.map +0 -1
  173. package/dist/src/utils/pkp.d.ts +0 -12
  174. package/dist/src/utils/pkp.d.ts.map +0 -1
  175. package/dist/src/utils/pkp.js +0 -19
  176. package/dist/src/utils/pkp.js.map +0 -1
  177. /package/dist/src/{app → expressMiddleware}/types.js +0 -0
  178. /package/dist/src/{express-authentication-middleware → utils}/types.js +0 -0
  179. /package/dist/src/{app → webAuthClient}/constants.d.ts +0 -0
  180. /package/dist/src/{app → webAuthClient}/constants.js +0 -0
  181. /package/dist/src/{app → webAuthClient}/internal/index.d.ts +0 -0
  182. /package/dist/src/{app → webAuthClient}/internal/index.js +0 -0
  183. /package/dist/src/{types.js → webAuthClient/types.js} +0 -0
@@ -1,22 +1,4 @@
1
- import type { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
2
1
  import type { JWTConfig } from '../types';
3
- /**
4
- * Creates a signer function compatible with did-jwt that uses a PKP wallet for signing
5
- *
6
- * This function returns a signing function that conforms to the did-jwt library's
7
- * signer interface. When called, it signs data using the PKP wallet, formatting
8
- * the signature according to ES256K requirements (without recovery parameter).
9
- *
10
- * @param pkpWallet - The PKP Ethers wallet instance that will be used for signing
11
- * @returns A signing function that takes data and returns a base64url-encoded signature
12
- * @example
13
- * ```typescript
14
- * const pkpWallet = new PKPEthersWallet({ ... });
15
- * const signer = createPKPSigner(pkpWallet);
16
- * const signature = await signer('data to sign');
17
- * ```
18
- */
19
- export declare function createPKPSigner(pkpWallet: PKPEthersWallet): (data: string | Uint8Array) => Promise<string>;
20
2
  /**
21
3
  * Creates a JWT signed by a PKP wallet using the ES256K algorithm
22
4
  *
@@ -26,6 +8,7 @@ export declare function createPKPSigner(pkpWallet: PKPEthersWallet): (data: stri
26
8
  *
27
9
  * @param config - Configuration object containing all parameters for JWT creation
28
10
  * @returns A promise that resolves to the signed JWT string
11
+ * @hidden
29
12
  * @example
30
13
  * ```typescript
31
14
  * const jwt = await createPKPSignedJWT({
@@ -37,5 +20,5 @@ export declare function createPKPSigner(pkpWallet: PKPEthersWallet): (data: stri
37
20
  * });
38
21
  * ```
39
22
  */
40
- export declare function createPKPSignedJWT(config: JWTConfig): Promise<string>;
23
+ export declare function create(config: JWTConfig): Promise<string>;
41
24
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAqB,MAAM,UAAU,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,eAAe,IAwB1C,MAAM,MAAM,GAAG,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,CAuB1D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAoC3E"}
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"}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPKPSigner = createPKPSigner;
4
- exports.createPKPSignedJWT = createPKPSignedJWT;
3
+ exports.create = create;
5
4
  const tslib_1 = require("tslib");
6
5
  const didJWT = tslib_1.__importStar(require("did-jwt"));
7
6
  const ethers_1 = require("ethers");
7
+ const utils_1 = require("ethers/lib/utils");
8
+ const base64_1 = require("./utils/base64");
8
9
  /**
9
10
  * Creates a signer function compatible with did-jwt that uses a PKP wallet for signing
10
11
  *
@@ -14,6 +15,7 @@ const ethers_1 = require("ethers");
14
15
  *
15
16
  * @param pkpWallet - The PKP Ethers wallet instance that will be used for signing
16
17
  * @returns A signing function that takes data and returns a base64url-encoded signature
18
+ * @private
17
19
  * @example
18
20
  * ```typescript
19
21
  * const pkpWallet = new PKPEthersWallet({ ... });
@@ -22,22 +24,6 @@ const ethers_1 = require("ethers");
22
24
  * ```
23
25
  */
24
26
  function createPKPSigner(pkpWallet) {
25
- /**
26
- * Converts a hex string to a Uint8Array
27
- *
28
- * @param hex - The hex string to convert (with or without 0x prefix)
29
- * @returns A Uint8Array representation of the hex string
30
- */
31
- const hexToUint8Array = (hex) => {
32
- if (hex.startsWith('0x')) {
33
- hex = hex.slice(2);
34
- }
35
- const bytes = new Uint8Array(hex.length / 2);
36
- for (let i = 0; i < hex.length; i += 2) {
37
- bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
38
- }
39
- return bytes;
40
- };
41
27
  /**
42
28
  * The actual signer function conforming to the did-jwt signer interface
43
29
  *
@@ -48,19 +34,13 @@ function createPKPSigner(pkpWallet) {
48
34
  const dataBytes = typeof data === 'string' ? Uint8Array.from(Buffer.from(data, 'utf8')) : data;
49
35
  const sig = await pkpWallet.signMessage(dataBytes);
50
36
  const { r, s } = ethers_1.ethers.utils.splitSignature(sig);
51
- const rBytes = hexToUint8Array(r.slice(2));
52
- const sBytes = hexToUint8Array(s.slice(2));
37
+ const rBytes = (0, utils_1.arrayify)(r);
38
+ const sBytes = (0, utils_1.arrayify)(s);
53
39
  // ES256K signature is r and s concatenated (64 bytes total)
54
40
  const sigBytes = new Uint8Array(64);
55
41
  sigBytes.set(rBytes, 0);
56
42
  sigBytes.set(sBytes, 32);
57
- // Convert to base64url encoding
58
- const base64Sig = Buffer.from(sigBytes)
59
- .toString('base64')
60
- .replace(/\+/g, '-')
61
- .replace(/\//g, '_')
62
- .replace(/=/g, '');
63
- return base64Sig;
43
+ return (0, base64_1.toBase64Url)(sigBytes);
64
44
  };
65
45
  }
66
46
  /**
@@ -72,6 +52,7 @@ function createPKPSigner(pkpWallet) {
72
52
  *
73
53
  * @param config - Configuration object containing all parameters for JWT creation
74
54
  * @returns A promise that resolves to the signed JWT string
55
+ * @hidden
75
56
  * @example
76
57
  * ```typescript
77
58
  * const jwt = await createPKPSignedJWT({
@@ -83,7 +64,7 @@ function createPKPSigner(pkpWallet) {
83
64
  * });
84
65
  * ```
85
66
  */
86
- async function createPKPSignedJWT(config) {
67
+ async function create(config) {
87
68
  const { app, pkpWallet, pkp, payload, expiresInMinutes, audience, authentication } = config;
88
69
  const signer = createPKPSigner(pkpWallet);
89
70
  // iat and exp are expressed in seconds https://datatracker.ietf.org/doc/html/rfc7519
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":";;AAsBA,0CA+CC;AAsBD,gDAoCC;;AA/HD,wDAAkC;AAClC,mCAAgC;AAKhC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,eAAe,CAAC,SAA0B;IACxD;;;;;OAKG;IACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAc,EAAE;QAClD,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC7C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,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AG,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"}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isJWTExpired = isJWTExpired;
3
+ exports.isExpired = isExpired;
4
4
  /** Checks if a JWT is expired based on its 'exp' claim
5
5
  *
6
6
  * @returns true if expired, false otherwise
7
7
  * @param decodedJWT
8
+ * @category API
8
9
  */
9
- function isJWTExpired(decodedJWT) {
10
+ function isExpired(decodedJWT) {
10
11
  const { payload } = decodedJWT;
11
12
  // Tokens that never expire are treated as expired for security.
12
13
  if (!payload.exp) {
@@ -16,4 +17,4 @@ function isJWTExpired(decodedJWT) {
16
17
  const currentTime = Math.floor(Date.now() / 1000);
17
18
  return currentTime >= payload.exp;
18
19
  }
19
- //# sourceMappingURL=isJWTExpired.js.map
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"}
@@ -1,5 +1,4 @@
1
1
  export { isDefinedObject } from './definedObject';
2
- export { isJWTExpired } from './isJWTExpired';
3
2
  export { validateJWTTime } from './validateJWTTime';
4
3
  export { splitJWT } from './splitJWT';
5
4
  export { processJWTSignature } from './processJWTSignature';
@@ -1 +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,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
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"}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processJWTSignature = exports.splitJWT = exports.validateJWTTime = exports.isJWTExpired = exports.isDefinedObject = void 0;
3
+ exports.processJWTSignature = exports.splitJWT = exports.validateJWTTime = exports.isDefinedObject = void 0;
4
4
  var definedObject_1 = require("./definedObject");
5
5
  Object.defineProperty(exports, "isDefinedObject", { enumerable: true, get: function () { return definedObject_1.isDefinedObject; } });
6
- var isJWTExpired_1 = require("./isJWTExpired");
7
- Object.defineProperty(exports, "isJWTExpired", { enumerable: true, get: function () { return isJWTExpired_1.isJWTExpired; } });
8
6
  var validateJWTTime_1 = require("./validateJWTTime");
9
7
  Object.defineProperty(exports, "validateJWTTime", { enumerable: true, get: function () { return validateJWTTime_1.validateJWTTime; } });
10
8
  var splitJWT_1 = require("./splitJWT");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/index.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAAzC,gHAAA,eAAe,OAAA;AACxB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"processJWTSignature.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/processJWTSignature.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAYjE"}
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"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processJWTSignature = processJWTSignature;
4
+ const base64_1 = require("./base64");
4
5
  /** Processes a JWT signature from base64url to binary
5
6
  * @ignore
6
7
  *
@@ -8,14 +9,6 @@ exports.processJWTSignature = processJWTSignature;
8
9
  * @returns A Uint8Array of the binary signature
9
10
  */
10
11
  function processJWTSignature(signature) {
11
- // Convert base64url to base64
12
- let base64 = signature.replace(/-/g, '+').replace(/_/g, '/');
13
- // Pad with '=' if needed
14
- while (base64.length % 4) {
15
- base64 += '=';
16
- }
17
- // Decode base64 to binary
18
- const binary = Buffer.from(base64, 'base64');
19
- return new Uint8Array(binary);
12
+ return (0, base64_1.fromBase64)(signature);
20
13
  }
21
14
  //# sourceMappingURL=processJWTSignature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"processJWTSignature.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/processJWTSignature.ts"],"names":[],"mappings":";;AAMA,kDAYC;AAlBD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,SAAiB;IACnD,8BAA8B;IAC9B,IAAI,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAE7D,yBAAyB;IACzB,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,CAAC;IAChB,CAAC;IAED,0BAA0B;IAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
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"}
@@ -1,23 +1,29 @@
1
- import { VincentJWT } from '../types';
2
- /**
3
- * Decodes and verifies an {@link VincentJWT} token in string form
4
- *
5
- * This function returns the decoded {@link VincentJWT} object only if:
6
- * 1. The JWT signature is valid
7
- * 2. The JWT is not expired
8
- * 3. All time claims (nbf, iat) are valid
9
- * 4. The JWT has an audience claim that includes the expected audience
10
- *
11
- * @param {string} jwt - The JWT string to verify
12
- * @param {string} expectedAudience - String that should be in the audience claim(s)
13
- *
14
- * @returns {VincentJWT} The decoded VincentJWT object if it was verified successfully
15
- */
16
- export declare function verifyJWT(jwt: string, expectedAudience: string): VincentJWT;
17
- /** This function uses the did-jwt library to decode a JWT string into its payload adding any extra Vincent fields
18
- *
19
- * @param {string} jwt - The JWT string to decode
20
- * @returns The decoded Vincent JWT fields
21
- */
22
- export declare function decodeJWT(jwt: string): VincentJWT;
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;
23
29
  //# sourceMappingURL=validate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAStC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAwE3E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAgBjD"}
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"}
@@ -1,13 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyJWT = verifyJWT;
4
- exports.decodeJWT = decodeJWT;
3
+ exports.verify = verify;
4
+ exports.decode = decode;
5
5
  const tslib_1 = require("tslib");
6
6
  const secp256k1 = tslib_1.__importStar(require("@noble/secp256k1"));
7
7
  const didJWT = tslib_1.__importStar(require("did-jwt"));
8
8
  const did_jwt_1 = require("did-jwt");
9
9
  const ethers_1 = require("ethers");
10
- const utils_1 = require("./utils");
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");
11
14
  /**
12
15
  * Decodes and verifies an {@link VincentJWT} token in string form
13
16
  *
@@ -17,25 +20,43 @@ const utils_1 = require("./utils");
17
20
  * 3. All time claims (nbf, iat) are valid
18
21
  * 4. The JWT has an audience claim that includes the expected audience
19
22
  *
20
- * @param {string} jwt - The JWT string to verify
21
- * @param {string} expectedAudience - String that should be in the audience claim(s)
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.
22
27
  *
23
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
+ * ```
24
45
  */
25
- function verifyJWT(jwt, expectedAudience) {
46
+ function verify({ jwt, expectedAudience, requiredAppId, }) {
26
47
  if (!expectedAudience) {
27
48
  throw new Error(`You must provide an expectedAudience`);
28
49
  }
29
- const decoded = decodeJWT(jwt);
50
+ const decoded = decode({ jwt, requiredAppId });
30
51
  const { aud, exp, pkp } = decoded.payload;
31
52
  if (!exp) {
32
53
  throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT does not contain an expiration claim (exp)`);
33
54
  }
34
- const isExpired = (0, utils_1.isJWTExpired)(decoded);
35
- if (isExpired) {
55
+ const expired = (0, isExpired_1.isExpired)(decoded);
56
+ if (expired) {
36
57
  throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT expired at ${exp}`);
37
58
  }
38
- (0, utils_1.validateJWTTime)(decoded.payload, Math.floor(Date.now() / 1000));
59
+ (0, utils_2.validateJWTTime)(decoded.payload, Math.floor(Date.now() / 1000));
39
60
  // Always validate audience - reject if no audience claim or expected audience isn't included
40
61
  if (!aud) {
41
62
  throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: JWT does not contain an audience claim (aud)`);
@@ -45,23 +66,17 @@ function verifyJWT(jwt, expectedAudience) {
45
66
  throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_AUDIENCE}: Expected audience ${expectedAudience} not found in aud claim`);
46
67
  }
47
68
  try {
48
- const { signedData, signature } = (0, utils_1.splitJWT)(jwt);
69
+ const { signedData, signature } = (0, utils_2.splitJWT)(jwt);
49
70
  // Process signature from base64url to binary
50
- const signatureBytes = (0, utils_1.processJWTSignature)(signature);
71
+ const signatureBytes = (0, utils_2.processJWTSignature)(signature);
51
72
  // Extract r and s values from the signature
52
73
  const r = signatureBytes.slice(0, 32);
53
74
  const s = signatureBytes.slice(32, 64);
54
- // Process public key
55
- let publicKey = pkp.publicKey;
56
- if (publicKey.startsWith('0x')) {
57
- publicKey = publicKey.substring(2);
58
- }
59
- const publicKeyBytes = Buffer.from(publicKey, 'hex');
75
+ const publicKeyBytes = (0, utils_1.arrayify)(pkp.publicKey);
60
76
  // PKPEthersWallet.signMessage() adds Ethereum prefix, so we need to add it here too
61
77
  const ethPrefixedMessage = '\x19Ethereum Signed Message:\n' + signedData.length + signedData;
62
- const messageBuffer = Buffer.from(ethPrefixedMessage, 'utf8');
63
- const messageHash = ethers_1.ethers.utils.keccak256(messageBuffer);
64
- const messageHashBytes = Buffer.from(messageHash.substring(2), 'hex');
78
+ const messageHash = ethers_1.ethers.utils.keccak256((0, utils_1.toUtf8Bytes)(ethPrefixedMessage));
79
+ const messageHashBytes = (0, utils_1.arrayify)(messageHash);
65
80
  const signatureForSecp = new Uint8Array([...r, ...s]);
66
81
  // Verify the signature against the public key
67
82
  const isVerified = secp256k1.verify(signatureForSecp, messageHashBytes, publicKeyBytes);
@@ -74,22 +89,54 @@ function verifyJWT(jwt, expectedAudience) {
74
89
  throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_SIGNATURE}: Invalid signature: ${error.message}`);
75
90
  }
76
91
  }
77
- /** This function uses the did-jwt library to decode a JWT string into its payload adding any extra Vincent fields
92
+ /** Decodes a Vincent JWT in string form and returns an {@link VincentJWT} decoded object for your use
78
93
  *
79
- * @param {string} jwt - The JWT string to decode
80
- * @returns The decoded Vincent JWT fields
81
- */
82
- function decodeJWT(jwt) {
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.redirectToDelegationAuthPage({redirectUri: window.location.href });
125
+ * }
126
+ *
127
+ * ```
128
+ * */
129
+ function decode({ jwt, requiredAppId, }) {
83
130
  const decodedJwt = didJWT.decodeJWT(jwt);
84
- const { app, authentication, pkp } = decodedJwt.payload;
85
- if (!(0, utils_1.isDefinedObject)(app)) {
86
- throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "app" field in JWT payload.`);
87
- }
88
- if (!(0, utils_1.isDefinedObject)(authentication)) {
89
- throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "authentication" field in JWT payload.`);
90
- }
91
- if (!(0, utils_1.isDefinedObject)(pkp)) {
92
- throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "pkp" field in JWT payload.`);
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
+ }
93
140
  }
94
141
  return decodedJwt;
95
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":";;AA2BA,8BAwEC;AAOD,8BAgBC;;AA1HD,oEAA8C;AAC9C,wDAAkC;AAClC,qCAAoC;AACpC,mCAAgC;AAEhC,mCAMiB;AAEjB;;;;;;;;;;;;;GAaG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,gBAAwB;IAC7D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;I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