@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 @@
1
+ {"version":3,"file":"vincentAbilityClient.js","sourceRoot":"","sources":["../../../src/abilityClient/vincentAbilityClient.ts"],"names":[],"mappings":";AAAA,4CAA4C;;AAiH5C,0DAqYC;AApfD,mCAAgC;AAChC,6BAAwB;AAKxB,uDAAsD;AACtD,yEAOoD;AAMpD,iFAAsF;AACtF,mGAAgG;AAChG,6DAIkC;AAClC,8DAGmC;AACnC,sEAA0E;AAC1E,6CAKsB;AAEtB,MAAM,mBAAmB,GAAG,0CAA0C,CAAC;AAEvE,MAAM,cAAc,GAAG,CAAC,GAAQ,EAAE,KAAU,EAAE,EAAE;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiEK;AACL,SAAgB,uBAAuB,CAUrC,MAiBD;;IAQC,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IACvD,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,GAAG,qBAAqB,CAAC;IAEpF,IAAA,wCAA6B,EAAC,wBAAwB,CAAC,CAAC;IAExD,MAAM,OAAO,GAAG,uBAAW,CAAC,KAAK,CAAC;IAElC,MAAM,oBAAoB,GAAG,CAAC,MAAA,cAAc,CAAC,aAAa,CAAC,oBAAoB,mCAC7E,OAAC,CAAC,SAAS,EAAE,CAAyB,CAA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AC7B,WAAW,EACX,SAAS,EACT,QAAQ,CACT,CAAC;YAEF,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;YAEhD,IAAI,IAAA,qCAAwB,EAAC,aAAa,CAAC,EAAE,CAAC;gBAC5C,sCAAsC;gBACtC,OAAO,aAIN,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAAC;YAEvE,kFAAkF;YAClF,IAAI,IAAA,qCAAwB,EAAC,sBAAsB,CAAC,EAAE,CAAC;gBACrD,OAAO,IAAA,oDAAmC,EAAC;oBACzC,GAAG,CAAC,sBAAsB,CAAC,YAAY;wBACrC,CAAC,CAAC,EAAE,YAAY,EAAE,sBAAsB,CAAC,YAAY,EAAE;wBACvD,CAAC,CAAC,EAAE,CAAC;oBACP,GAAG,CAAC,sBAAsB,CAAC,qBAAqB;wBAC9C,CAAC,CAAC,EAAE,qBAAqB,EAAE,sBAAsB,CAAC,qBAAqB,EAAE;wBACzE,CAAC,CAAC,EAAE,CAAC;oBACP,MAAM,EAAE,aAAa;oBACrB,OAAO,EAAE,0BAA0B,CAAC,cAAc;iBACnD,CAIA,CAAC;YACJ,CAAC;YAED,MAAM,GAAG,GAA6C,aAAa,CAAC;YAEpE,OAAO,IAAA,oDAAmC,EAAC;gBACzC,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,0BAA0B,CAAC,cAAc;aACnD,CAA2F,CAAC;QAC/F,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { NextFunction, Request, Response } from 'express';
2
+ import type { AuthenticatedRequestHandler } from './types';
3
+ /** Returns an Express middleware function to authenticate a user using a JWT token, and a type-guard wrapper function
4
+ * for type-safe usage of route handlers guarded by the middleware.
5
+ *
6
+ * The `middleware()` function:
7
+ * - Checks the `Authorization` header for a Bearer token, verifies the token, and checks its audience.
8
+ * - If the token is valid, it attaches the user information (decoded JWT, and raw JWT string) to the request object
9
+ * - If the token is missing or invalid, it returns a 401 Unauthorized response with an error message.
10
+ *
11
+ * Designate what field on `req` should be set with the JWT with the `userKey` configuration option.
12
+ *
13
+ * The `handler()` function:
14
+ * - Provides a type-safe reference to `req` where the `userKey` you have provided is correctly inferred to the appropriate type
15
+ * - Note that it is still your responsibility to ensure you have attached the `middleware` somewhere in the chain before you use the `handler()`
16
+ * - If you forget, the `handler()` function will throw an error if the expected `req[userKey]` does not exist.
17
+ *
18
+ * See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
19
+ * @category API
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { createVincentUserMiddleware } from '@lit-protocol/vincent-app-sdk/expressMiddleware';
24
+ *
25
+ * // In your environment configuration
26
+ * const ALLOWED_AUDIENCE = 'https://yourapp.example.com';
27
+ * const VINCENT_APP_ID = 555; // Provided by the vincent app registry
28
+ *
29
+ * const { middleware, handler } = createVincentUserMiddleware({
30
+ * allowedAudience: ALLOWED_AUDIENCE,
31
+ * requiredAppId: VINCENT_APP_ID,
32
+ * userKey: 'vincentUser',
33
+ * });
34
+ *
35
+ * // Apply to routes that require authentication; req is guaranteed authenticated because it is wrapped in `handler()`
36
+ * app.get('/protected-resource', middleware, handler((req, res) => {
37
+ * // handler() gives you the correct inferred type of `req[userKey]`
38
+ * const pkpAddress = req.vincentUser.decodedJWT.payload.pkp.ethAddress;
39
+ * const appInfo = req.vincentUser.decodedJWT.payload.app;
40
+ *
41
+ * if(appInfo) {
42
+ * res.json({ message: `Hello, user with PKP address ${pkpAddress}. You are authenticated for app ${appInfo.id} @ v${appInfo.version}` });
43
+ * return;
44
+ * }
45
+ *
46
+ * res.json({ message: `Hello, user with PKP address ${pkpAddress}.` });
47
+ * })
48
+ * );
49
+ * ```
50
+ *
51
+ * See the code below for the implementation used by the `middleware` returned by this function. You can adapt this logic
52
+ * to the HTTP framework of your choice.
53
+ *
54
+ */
55
+ export declare function createVincentUserMiddleware<const UserKey extends string>(config: {
56
+ allowedAudience: string;
57
+ userKey: UserKey;
58
+ requiredAppId: number | undefined;
59
+ }): {
60
+ middleware: (req: Request, res: Response, next: NextFunction) => Promise<void>;
61
+ handler: (handler: AuthenticatedRequestHandler<UserKey>) => (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
62
+ };
63
+ //# sourceMappingURL=express.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../src/expressMiddleware/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,KAAK,EAAwB,2BAA2B,EAAkB,MAAM,SAAS,CAAC;AAwBjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,CAAC,OAAO,SAAS,MAAM,EAAE,MAAM,EAAE;IAChF,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;sBA8BoB,OAAO,OAAO,QAAQ,QAAQ,YAAY;iEArBnD,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY;EAJ1D"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVincentUserMiddleware = createVincentUserMiddleware;
4
+ const jwt_1 = require("../jwt");
5
+ const utils_1 = require("../jwt/core/utils");
6
+ function assertAuthenticatedRequest(req, userKey) {
7
+ // @ts-expect-error It's an assertion
8
+ if (!(userKey in req) || typeof req[userKey] !== 'object' || !req[userKey]) {
9
+ throw new Error('Request is not an AuthenticatedRequest: Missing or invalid "user" property');
10
+ }
11
+ // Cast with a type assertion
12
+ const user = req[userKey];
13
+ const { decodedJWT, rawJWT } = user;
14
+ if (typeof rawJWT !== 'string' || !(0, utils_1.isDefinedObject)(decodedJWT)) {
15
+ throw new Error('Request is not an AuthenticatedRequest: Invalid "user" properties');
16
+ }
17
+ }
18
+ /** Returns an Express middleware function to authenticate a user using a JWT token, and a type-guard wrapper function
19
+ * for type-safe usage of route handlers guarded by the middleware.
20
+ *
21
+ * The `middleware()` function:
22
+ * - Checks the `Authorization` header for a Bearer token, verifies the token, and checks its audience.
23
+ * - If the token is valid, it attaches the user information (decoded JWT, and raw JWT string) to the request object
24
+ * - If the token is missing or invalid, it returns a 401 Unauthorized response with an error message.
25
+ *
26
+ * Designate what field on `req` should be set with the JWT with the `userKey` configuration option.
27
+ *
28
+ * The `handler()` function:
29
+ * - Provides a type-safe reference to `req` where the `userKey` you have provided is correctly inferred to the appropriate type
30
+ * - Note that it is still your responsibility to ensure you have attached the `middleware` somewhere in the chain before you use the `handler()`
31
+ * - If you forget, the `handler()` function will throw an error if the expected `req[userKey]` does not exist.
32
+ *
33
+ * See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
34
+ * @category API
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import { createVincentUserMiddleware } from '@lit-protocol/vincent-app-sdk/expressMiddleware';
39
+ *
40
+ * // In your environment configuration
41
+ * const ALLOWED_AUDIENCE = 'https://yourapp.example.com';
42
+ * const VINCENT_APP_ID = 555; // Provided by the vincent app registry
43
+ *
44
+ * const { middleware, handler } = createVincentUserMiddleware({
45
+ * allowedAudience: ALLOWED_AUDIENCE,
46
+ * requiredAppId: VINCENT_APP_ID,
47
+ * userKey: 'vincentUser',
48
+ * });
49
+ *
50
+ * // Apply to routes that require authentication; req is guaranteed authenticated because it is wrapped in `handler()`
51
+ * app.get('/protected-resource', middleware, handler((req, res) => {
52
+ * // handler() gives you the correct inferred type of `req[userKey]`
53
+ * const pkpAddress = req.vincentUser.decodedJWT.payload.pkp.ethAddress;
54
+ * const appInfo = req.vincentUser.decodedJWT.payload.app;
55
+ *
56
+ * if(appInfo) {
57
+ * res.json({ message: `Hello, user with PKP address ${pkpAddress}. You are authenticated for app ${appInfo.id} @ v${appInfo.version}` });
58
+ * return;
59
+ * }
60
+ *
61
+ * res.json({ message: `Hello, user with PKP address ${pkpAddress}.` });
62
+ * })
63
+ * );
64
+ * ```
65
+ *
66
+ * See the code below for the implementation used by the `middleware` returned by this function. You can adapt this logic
67
+ * to the HTTP framework of your choice.
68
+ *
69
+ */
70
+ function createVincentUserMiddleware(config) {
71
+ return {
72
+ middleware: getAuthenticateUserExpressHandler(config),
73
+ handler: authenticatedRequestHandler(config.userKey),
74
+ };
75
+ }
76
+ function authenticatedRequestHandler(userKey) {
77
+ return function (handler) {
78
+ return (req, res, next) => {
79
+ try {
80
+ assertAuthenticatedRequest(req, userKey);
81
+ return handler(req, res, next);
82
+ }
83
+ catch (_a) {
84
+ res.status(401).json({ error: 'Not authenticated' });
85
+ }
86
+ };
87
+ };
88
+ }
89
+ // #region expressHandlerTSDocExample
90
+ function getAuthenticateUserExpressHandler({ allowedAudience, requiredAppId, userKey, }) {
91
+ return async (req, res, next) => {
92
+ const authHeader = req.headers.authorization;
93
+ if (!authHeader) {
94
+ res.status(401).json({ error: 'No token provided' });
95
+ return;
96
+ }
97
+ const parts = authHeader.split(' ');
98
+ if (parts.length !== 2) {
99
+ res.status(401).json({ error: `Invalid authorization header - expected "Bearer <token>"` });
100
+ return;
101
+ }
102
+ const [scheme, rawJWT] = parts;
103
+ if (!/^Bearer$/i.test(scheme)) {
104
+ res.status(401).json({ error: `Expected "Bearer" scheme, got "${scheme}"` });
105
+ return;
106
+ }
107
+ try {
108
+ const decodedJWT = (0, jwt_1.verify)({ jwt: rawJWT, expectedAudience: allowedAudience, requiredAppId });
109
+ if (!decodedJWT) {
110
+ res.status(401).json({ error: 'Invalid token' });
111
+ return;
112
+ }
113
+ req[userKey] = {
114
+ decodedJWT,
115
+ rawJWT,
116
+ };
117
+ next();
118
+ }
119
+ catch (e) {
120
+ res.status(401).json({ error: `Invalid token: ${e.message}` });
121
+ }
122
+ };
123
+ }
124
+ // #endregion expressHandlerTSDocExample
125
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.js","sourceRoot":"","sources":["../../../src/expressMiddleware/express.ts"],"names":[],"mappings":";;AA8EA,kEASC;AAnFD,gCAAgC;AAChC,6CAAoD;AAEpD,SAAS,0BAA0B,CACjC,GAAY,EACZ,OAAgB;IAEhB,qCAAqC;IACrC,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAChG,CAAC;IAED,6BAA6B;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAA4B,CAAC;IAErD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAEpC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,IAAA,uBAAe,EAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,2BAA2B,CAA+B,MAIzE;IACC,OAAO;QACL,UAAU,EAAE,iCAAiC,CAAC,MAAM,CAAC;QACrD,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,OAAO,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,SAAS,2BAA2B,CAA+B,OAAgB;IACjF,OAAO,UAAU,OAA6C;QAC5D,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;YACzD,IAAI,CAAC;gBACH,0BAA0B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBACzC,OAAO,OAAO,C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eAAe,EAAE,aAAa,EAAE,CAAC,CAAC;YAC7F,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;gBACjD,OAAO;YACT,CAAC;YAEA,GAAiD,CAAC,OAAO,CAAC,GAAG;gBAC5D,UAAU;gBACV,MAAM;aACW,CAAC;YAEpB,IAAI,EAAE,CAAC;QACT,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAmB,CAAW,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AACD,wCAAwC"}
@@ -0,0 +1,14 @@
1
+ /** Express middleware is used to add a VincentJWT-specific authentication to your Express.js server routes
2
+ *
3
+ * All functionality is encapsulated into a single factory function -- see {@link createVincentUserMiddleware} for details
4
+ *
5
+ * You can see the source for the Express authentication handler below; use this as a reference to implement
6
+ * your own midddleware/authentication for other frameworks! Pull requests are welcome.
7
+ * {@includeCode ./express.ts#expressHandlerTSDocExample}
8
+ *
9
+ * @packageDocumentation
10
+ * @module expressMiddleware
11
+ * */
12
+ export { createVincentUserMiddleware } from './express';
13
+ export type { AuthenticatedRequest, AuthenticatedRequestHandler, ExtractRequestHandlerParams, VincentJWTData, } from './types';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/expressMiddleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;KAUK;AAEL,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAExD,YAAY,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,2BAA2B,EAC3B,cAAc,GACf,MAAM,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /** Express middleware is used to add a VincentJWT-specific authentication to your Express.js server routes
3
+ *
4
+ * All functionality is encapsulated into a single factory function -- see {@link createVincentUserMiddleware} for details
5
+ *
6
+ * You can see the source for the Express authentication handler below; use this as a reference to implement
7
+ * your own midddleware/authentication for other frameworks! Pull requests are welcome.
8
+ * {@includeCode ./express.ts#expressHandlerTSDocExample}
9
+ *
10
+ * @packageDocumentation
11
+ * @module expressMiddleware
12
+ * */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.createVincentUserMiddleware = void 0;
15
+ var express_1 = require("./express");
16
+ Object.defineProperty(exports, "createVincentUserMiddleware", { enumerable: true, get: function () { return express_1.createVincentUserMiddleware; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/expressMiddleware/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;KAUK;;;AAEL,qCAAwD;AAA/C,sHAAA,2BAA2B,OAAA"}
@@ -0,0 +1,31 @@
1
+ import type { NextFunction, Request, RequestHandler, Response } from 'express';
2
+ import type { VincentJWT } from '../jwt/types';
3
+ /** Extract the params type from the original Express.js RequestHandler
4
+ *
5
+ * You probably don't need this type; see { @link createVincentUserMiddleware } for details
6
+ *
7
+ * @category Interfaces
8
+ * */
9
+ export type ExtractRequestHandlerParams<T> = T extends RequestHandler<infer P, infer ResBody, infer ReqBody, infer ReqQuery, infer Locals> ? [P, ResBody, ReqBody, ReqQuery, Locals] : never;
10
+ /**
11
+ * An Express.js RequestHandler that guarantees the request is authenticated with a PKP address
12
+ *
13
+ * You probably don't need this type; see { @link createVincentUserMiddleware } for details
14
+ *
15
+ * @category Interfaces
16
+ * */
17
+ export type AuthenticatedRequestHandler<UserKey extends string, P = ExtractRequestHandlerParams<RequestHandler>[0], ResBody = ExtractRequestHandlerParams<RequestHandler>[1], ReqBody = ExtractRequestHandlerParams<RequestHandler>[2], ReqQuery = ExtractRequestHandlerParams<RequestHandler>[3], Locals extends Record<string, any> = ExtractRequestHandlerParams<RequestHandler>[4]> = (req: AuthenticatedRequest<UserKey, P, ResBody, ReqBody, ReqQuery>, res: Response<ResBody, Locals>, next: NextFunction) => void | Promise<void>;
18
+ export interface VincentJWTData {
19
+ decodedJWT: VincentJWT;
20
+ rawJWT: string;
21
+ }
22
+ /** An interface that extends the Express.js Request interface to include authenticated user data
23
+ *
24
+ * You probably don't need this type; see { @link createVincentUserMiddleware } for details
25
+ *
26
+ * @category Interfaces
27
+ * */
28
+ export type AuthenticatedRequest<UserKey extends string, P = any, ResBody = any, ReqBody = any, ReqQuery = any> = Request<P, ResBody, ReqBody, ReqQuery> & {
29
+ [K in UserKey]: VincentJWTData;
30
+ };
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/expressMiddleware/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;KAKK;AACL,MAAM,MAAM,2BAA2B,CAAC,CAAC,IACvC,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,OAAO,EAAE,MAAM,OAAO,EAAE,MAAM,QAAQ,EAAE,MAAM,MAAM,CAAC,GACzF,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,GACvC,KAAK,CAAC;AAEZ;;;;;;KAMK;AACL,MAAM,MAAM,2BAA2B,CACrC,OAAO,SAAS,MAAM,EACtB,CAAC,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAClD,OAAO,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACxD,OAAO,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACxD,QAAQ,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EACzD,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,2BAA2B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IACjF,CACF,GAAG,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EACjE,GAAG,EAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAC9B,IAAI,EAAE,YAAY,KACf,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;KAKK;AACL,MAAM,MAAM,oBAAoB,CAC9B,OAAO,SAAS,MAAM,EACtB,CAAC,GAAG,GAAG,EACP,OAAO,GAAG,GAAG,EACb,OAAO,GAAG,GAAG,EACb,QAAQ,GAAG,GAAG,IACZ,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG;KAC1C,CAAC,IAAI,OAAO,GAAG,cAAc;CAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/expressMiddleware/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { LIT_NETWORKS_KEYS } from '@lit-protocol/types';
2
+ import { LitNodeClient } from '@lit-protocol/lit-node-client';
3
+ export declare class LitNodeClientInstance {
4
+ private readonly litNodeClientInstance;
5
+ private isConnected;
6
+ private connectHandle;
7
+ constructor({ network }: {
8
+ network: LIT_NETWORKS_KEYS;
9
+ });
10
+ connect(): Promise<boolean>;
11
+ disconnect(): Promise<void>;
12
+ get litNodeClient(): LitNodeClient;
13
+ }
14
+ //# sourceMappingURL=LitNodeClientInstance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LitNodeClientInstance.d.ts","sourceRoot":"","sources":["../../../../src/internal/LitNodeClient/LitNodeClientInstance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAgB;IAEtD,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,aAAa,CAAiC;gBAE1C,EAAE,OAAO,EAAE,EAAE;QAAE,OAAO,EAAE,iBAAiB,CAAA;KAAE;IAOjD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IA4B3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBjC,IAAI,aAAa,IAAI,aAAa,CAEjC;CACF"}
@@ -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;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D,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,E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C,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"}