@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
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebAuthClient = void 0;
4
+ const constants_1 = require("./constants");
5
+ const internal_1 = require("./internal");
6
+ const { isLoginUri, composeDelegationAuthUrl, removeSearchParam, decodeVincentJWTFromUri } = internal_1.uriHelpers;
7
+ const redirectToDelegationAuthPage = ({ appId, redirectUri, delegationAuthPageUrl, }) => window.open(composeDelegationAuthUrl(appId, redirectUri, delegationAuthPageUrl).toString(), '_self');
8
+ /** Create a new {@link WebAuthClient} instance.
9
+ *
10
+ * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
11
+ * */
12
+ const getWebAuthClient = (appClientConfig) => {
13
+ const { appId } = appClientConfig;
14
+ return {
15
+ redirectToDelegationAuthPage: (redirectDelegationAuthPageConfig) => {
16
+ const { delegationAuthPageUrl, redirectUri } = redirectDelegationAuthPageConfig;
17
+ redirectToDelegationAuthPage({
18
+ appId,
19
+ delegationAuthPageUrl,
20
+ redirectUri,
21
+ });
22
+ },
23
+ isLogin: () => isLoginUri(window.location.href),
24
+ decodeVincentLoginJWT: (expectedAudience) => decodeVincentJWTFromUri({
25
+ uri: window.location.href,
26
+ expectedAudience: expectedAudience,
27
+ requiredAppId: appId,
28
+ }),
29
+ removeLoginJWTFromURI: () => {
30
+ const urlWithoutJWTSearchParam = removeSearchParam({
31
+ paramName: constants_1.JWT_URL_KEY,
32
+ uri: window.location.href,
33
+ });
34
+ window.history.replaceState({}, document.title, urlWithoutJWTSearchParam);
35
+ },
36
+ };
37
+ };
38
+ exports.getWebAuthClient = getWebAuthClient;
39
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/webAuthClient/app.ts"],"names":[],"mappings":";;;AAMA,2CAA0C;AAC1C,yCAAwC;AAExC,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GACxF,qBAAU,CAAC;AAEb,MAAM,4BAA4B,GAAG,CAAC,EACpC,KAAK,EACL,WAAW,EACX,qBAAqB,GAKtB,EAAE,EAAE,CACH,MAAM,CAAC,IAAI,CACT,wBAAwB,CAAC,KAAK,EAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC,QAAQ,EAAE,EAC9E,OAAO,CACR,CAAC;AAEJ;;;KAGK;AACE,MAAM,gBAAgB,GAAG,CAAC,eAAoC,EAAiB,EAAE;IACtF,MAAM,EAAE,KAAK,EAAE,GAAG,eAAe,CAAC;IAElC,OAAO;QACL,4BAA4B,EAAE,CAC5B,gCAAuE,EACvE,EAAE;YACF,MAAM,EAAE,qBAAqB,EAAE,WAAW,EAAE,GAAG,gCAAgC,CAAC;YAChF,4BAA4B,CAAC;gBAC3B,KAAK;gBACL,qBAAqB;gBACrB,WAAW;aACZ,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/C,qBAAqB,EAAE,CAAC,gBAAwB,EAAE,EAAE,CAClD,uBAAuB,CAAC;YACtB,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;YACzB,gBAAgB,EAAE,gBAAgB;YAClC,aAAa,EAAE,KAAK;SACrB,CAAC;QACJ,qBAAqB,EAAE,GAAG,EAAE;YAC1B,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;gBACjD,SAAS,EAAE,uBAAW;gBACtB,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;aAC1B,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,gBAAgB,oBA6B3B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AACnF,eAAO,MAAM,WAAW,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/webAuthClient/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gCAAgC,GAAG,kCAAkC,CAAC;AACtE,QAAA,WAAW,GAAG,KAAK,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** The webAuthClient module contains methods and types that are used to implement authentication in Vincent web apps
2
+ * Authentication is handled via redirects to the Vincent dashboard portal that return JWTs with authentication information
3
+ * that can be used to secure your backend Vincent app UI.
4
+ *
5
+ * ```typescript
6
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
7
+ * ```
8
+ * @packageDocumentation
9
+ */
10
+ import { getWebAuthClient } from './app';
11
+ export { getWebAuthClient };
12
+ export type { WebAuthClient, WebAuthClientConfig, RedirectToVincentDelegationPageParams, } from './types';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,qCAAqC,GACtC,MAAM,SAAS,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWebAuthClient = void 0;
4
+ /** The webAuthClient module contains methods and types that are used to implement authentication in Vincent web apps
5
+ * Authentication is handled via redirects to the Vincent dashboard portal that return JWTs with authentication information
6
+ * that can be used to secure your backend Vincent app UI.
7
+ *
8
+ * ```typescript
9
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
10
+ * ```
11
+ * @packageDocumentation
12
+ */
13
+ const app_1 = require("./app");
14
+ Object.defineProperty(exports, "getWebAuthClient", { enumerable: true, get: function () { return app_1.getWebAuthClient; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webAuthClient/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,+BAAyC;AAEhC,iGAFA,sBAAgB,OAEA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/index.ts"],"names":[],"mappings":";;;;AAAA,iEAA2C;AAElC,gCAAU"}
@@ -0,0 +1,15 @@
1
+ export declare const decodeVincentJWTFromUri: ({ uri, expectedAudience, requiredAppId, }: {
2
+ uri: string;
3
+ expectedAudience: string;
4
+ requiredAppId: number;
5
+ }) => {
6
+ decodedJWT: import("../../jwt").VincentJWTAppSpecific;
7
+ jwtStr: string;
8
+ } | null;
9
+ export declare const isLoginUri: (uri: string) => boolean;
10
+ export declare function composeDelegationAuthUrl(appId: number, redirectUri: string, delegationAuthPageUrl?: string): URL;
11
+ export declare const removeSearchParam: ({ paramName, uri, }: {
12
+ paramName: string;
13
+ uri: string;
14
+ }) => string;
15
+ //# sourceMappingURL=uriHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriHelpers.d.ts","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/uriHelpers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,GAAI,2CAIrC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;;;QAcA,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,YAKrC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,qBAAqB,CAAC,EAAE,MAAM,OAM/B;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,MAKH,CAAC"}
@@ -1,16 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeSearchParam = exports.isLoginUri = exports.decodeVincentJWTFromUri = void 0;
4
- exports.composeConsentUrl = composeConsentUrl;
5
- const constants_1 = require("../constants");
4
+ exports.composeDelegationAuthUrl = composeDelegationAuthUrl;
6
5
  const validate_1 = require("../../jwt/core/validate");
7
- const decodeVincentJWTFromUri = (uri, expectedAudience) => {
6
+ const constants_1 = require("../constants");
7
+ const decodeVincentJWTFromUri = ({ uri, expectedAudience, requiredAppId, }) => {
8
8
  const url = new URL(uri);
9
9
  const jwt = url.searchParams.get(constants_1.JWT_URL_KEY);
10
10
  if (!jwt) {
11
11
  return null;
12
12
  }
13
- return { decodedJWT: (0, validate_1.verifyJWT)(jwt, expectedAudience), jwtStr: jwt };
13
+ try {
14
+ return { decodedJWT: (0, validate_1.verify)({ jwt, expectedAudience, requiredAppId }), jwtStr: jwt };
15
+ }
16
+ catch (error) {
17
+ // Explicitly throw if the JWT doesn't contain the required appId
18
+ throw new Error(`Failed to decode JWT: ${error.message}`);
19
+ }
14
20
  };
15
21
  exports.decodeVincentJWTFromUri = decodeVincentJWTFromUri;
16
22
  const isLoginUri = (uri) => {
@@ -19,8 +25,8 @@ const isLoginUri = (uri) => {
19
25
  return !!loginJwt;
20
26
  };
21
27
  exports.isLoginUri = isLoginUri;
22
- function composeConsentUrl(appId, redirectUri, consentPageUrl) {
23
- return new URL(`/appId/${appId}/consent?redirectUri=${redirectUri}`, consentPageUrl || constants_1.PRODUCTION_VINCENT_DASHBOARD_URL);
28
+ function composeDelegationAuthUrl(appId, redirectUri, delegationAuthPageUrl) {
29
+ return new URL(`/user/consent/appId/${String(appId)}?redirectUri=${redirectUri}`, delegationAuthPageUrl || constants_1.PRODUCTION_VINCENT_DASHBOARD_URL);
24
30
  }
25
31
  const removeSearchParam = ({ paramName, uri, }) => {
26
32
  const url = new URL(uri);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uriHelpers.js","sourceRoot":"","sources":["../../../../src/webAuthClient/internal/uriHelpers.ts"],"names":[],"mappings":";;;AAkCA,4DASC;AA3CD,sDAAiD;AACjD,4CAA6E;AAEtE,MAAM,uBAAuB,GAAG,CAAC,EACtC,GAAG,EACH,gBAAgB,EAChB,aAAa,GAKd,EAAE,EAAE;IACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAW,CAAC,CAAC;IAE9C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,OAAO,EAAE,UAAU,EAAE,IAAA,iBAAM,EAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACvF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,iEAAiE;QACjE,MAAM,IAAI,KAAK,CAAC,yBAA0B,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,uBAAuB,2BAsBlC;AAEK,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAW,CAAC,CAAC;IAEnD,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB;AAEF,SAAgB,wBAAwB,CACtC,KAAa,EACb,WAAmB,EACnB,qBAA8B;IAE9B,OAAO,IAAI,GAAG,CACZ,uBAAuB,MAAM,CAAC,KAAK,CAAC,gBAAgB,WAAW,EAAE,EACjE,qBAAqB,IAAI,4CAAgC,CAC1D,CAAC;AACJ,CAAC;AAEM,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,GAAG,GAIJ,EAAU,EAAE;IACX,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnC,0DAA0D;IAC1D,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B"}
@@ -1,69 +1,61 @@
1
- import { VincentJWT } from '../jwt/types';
2
- /**
3
- * @category Interfaces
4
- */
5
- export interface VincentAppClientConfig {
6
- appId: string;
1
+ import type { VincentJWTAppSpecific } from '../jwt/types';
2
+ export interface WebAuthClientConfig {
3
+ appId: number;
7
4
  }
8
- /**
9
- * @category Interfaces
10
- */
11
- export interface RedirectToVincentConsentPageParams {
5
+ export interface RedirectToVincentDelegationPageParams {
12
6
  redirectUri: string;
13
7
  /** This only needs to be provided for local development with the entire stack
14
8
  * @hidden
15
9
  * */
16
- consentPageUrl?: string;
10
+ delegationAuthPageUrl?: string;
17
11
  }
18
12
  /**
19
13
  * The Vincent Web Application Client is used in web apps to handle interactions with the Vincent app portal.
20
14
  *
21
- * - Consent page redirection
15
+ * - Delegation authorization page redirection
22
16
  * - Authentication helpers that are browser specific
23
17
  *
24
- * @category Interfaces
25
18
  */
26
- export interface VincentWebAppClient {
19
+ export interface WebAuthClient {
27
20
  /**
28
- * Redirects the user to the Vincent consent page.
21
+ * Redirects the user to the Vincent delegation auth page.
29
22
  *
30
23
  * If the user approves your app permissions, they will be redirected back to the `redirectUri`.
31
24
  *
32
- * Use {@link VincentWebAppClient.isLogin} to detect if a user has just opened your app via the consent page
25
+ * Use {@link WebAuthClient.isLogin} to detect if a user has just opened your app via the delegation auth page
33
26
  *
34
- * Use {@link VincentWebAppClient.decodeVincentLoginJWT} to decode and verify the {@link VincentJWT} from the page URI, and store it for later usage
27
+ * Use {@link WebAuthClient.decodeVincentLoginJWT} to decode and verify the {@link VincentJWT} from the page URI, and store it for later usage
35
28
  *
36
29
  * NOTE: You must register the `redirectUri` on your Vincent app for it to be considered a valid redirect target
37
30
  *
38
31
  * @example
39
32
  * ```typescript
40
- * import { getVincentWebAppClient } from '@lit-protocol/vincent-app-sdk';
41
- *
42
- * const vincentAppClient = getVincentWebAppClient({ appId: MY_APP_ID });
43
- * // ... In your app logic:
44
- * if(vincentAppClient.isLogin()) {
45
- * // Handle app logic for the user has just logged in
46
- * const { decoded, jwt } = vincentAppClient.decodeVincentLoginJWT(EXPECTED_AUDIENCE);
47
- * // Store `jwt` for later usage; the user is now logged in.
48
- * } else {
49
- * // Handle app logic for the user is already logged in (check for stored & unexpired JWT)
50
- * // ...
51
- *
52
- * // Handle app logic for the user is not yet logged in
53
- * vincentAppClient.redirectToConsentPage({ redirectUri: window.location.href });
54
- * }
33
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
34
+ *
35
+ * const vincentAppClient = getWebAuthClient({ appId: MY_APP_ID });
36
+ * // ... In your app logic:
37
+ * if(vincentAppClient.isLogin()) {
38
+ * // Handle app logic for the user has just logged in
39
+ * const { decoded, jwtStr } = vincentAppClient.decodeVincentLoginJWT(EXPECTED_AUDIENCE);
40
+ * // Store `jwtStr` for later usage; the user is now logged in.
41
+ * } else {
42
+ * // Handle app logic for the user is already logged in (check for stored & unexpired JWT)
43
+ * // ...
44
+ * * // Handle app logic for the user is not yet logged in
45
+ * vincentAppClient.redirectToDelegationAuthPage({ redirectUri: window.location.href });
46
+ * }
55
47
  * ```
56
48
  * @function
57
49
  * @inline
58
50
  */
59
- redirectToConsentPage: (redirectConfig: RedirectToVincentConsentPageParams) => void;
51
+ redirectToDelegationAuthPage: (redirectConfig: RedirectToVincentDelegationPageParams) => void;
60
52
  /**
61
53
  * Determines whether the current window location is a login URI associated with Vincent
62
54
 
63
55
  * You can use this to detect if a user is loading your app as a result of approving permissions
64
- * on the Vincent consent page -- e.g. they just logged in
56
+ * on the Vincent delegation auth page -- e.g. they just logged in
65
57
  *
66
- * See: {@link VincentWebAppClient.redirectToConsentPage} for example usage
58
+ * See: {@link WebAuthClient.redirectToDelegationAuthPage} for example usage
67
59
  *
68
60
  * @function
69
61
  * @inline
@@ -75,16 +67,16 @@ export interface VincentWebAppClient {
75
67
  *
76
68
  * The token is verified as part of this process; if the token is invalid or expired, this method will throw.
77
69
  *
78
- * See: {@link VincentWebAppClient.redirectToConsentPage} for example usage
70
+ * See: {@link WebAuthClient.redirectToDelegationAuthPage} for example usage
79
71
  *
80
- * @param { string } expectedAudience Provide a valid `redirectUri` for your app; this is typically your app's origin
72
+ * @param expectedAudience Provide a valid `redirectUri` for your app; this is typically your app's origin
81
73
  * @function
82
74
  * @inline
83
- * @returns {decodedJWT: VincentJWT; jwtStr: string | null} `null` if no JWT is found, otherwise both the decoded jwt and the original JWT string is returned
75
+ * @returns {decodedJWT: VincentJWTAppSpecific; jwtStr: string | null} `null` if no JWT is found, otherwise both the decoded jwt and the original JWT string is returned
84
76
  * @throws {Error} If there was a JWT in the page URL, but it was invalid / could not be verified
85
77
  */
86
78
  decodeVincentLoginJWT: (expectedAudience: string) => {
87
- decodedJWT: VincentJWT;
79
+ decodedJWT: VincentJWTAppSpecific;
88
80
  jwtStr: string;
89
81
  } | null;
90
82
  /**
@@ -96,9 +88,9 @@ export interface VincentWebAppClient {
96
88
  *
97
89
  * @example
98
90
  * ```typescript
99
- * import { getVincentWebAppClient } from '@lit-protocol/vincent-app-sdk';
91
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
100
92
  *
101
- * const vincentAppClient = getVincentWebAppClient({ appId: MY_APP_ID });
93
+ * const vincentAppClient = getWebAuthClient({ appId: MY_APP_ID });
102
94
  *
103
95
  * if (vincentAppClient.isLogin()) {
104
96
  * const { decodedJWT, jwtStr } = vincentAppClient.decodeVincentLoginJWT();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qCAAqC;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB;;SAEK;IACL,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,4BAA4B,EAAE,CAAC,cAAc,EAAE,qCAAqC,KAAK,IAAI,CAAC;IAE9F;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB;;;;;;;;;;;;OAYG;IACH,qBAAqB,EAAE,CACrB,gBAAgB,EAAE,MAAM,KACrB;QAAE,UAAU,EAAE,qBAAqB,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAElE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/webAuthClient/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lit-protocol/vincent-app-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-beta.1",
4
4
  "description": "Vincent SDK for browser and backend",
5
5
  "author": "Lit Protocol",
6
6
  "license": "ISC",
@@ -12,8 +12,34 @@
12
12
  "node": "^20.11.1",
13
13
  "pnpm": "10.7.0"
14
14
  },
15
- "main": "./dist/src/index.js",
16
- "types": "./dist/src/index.d.ts",
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ "./jwt": {
18
+ "import": "./dist/src/jwt/index.js",
19
+ "require": "./dist/src/jwt/index.js",
20
+ "types": "./dist/src/jwt/index.d.ts"
21
+ },
22
+ "./toolClient": {
23
+ "import": "./dist/src/toolClient/index.js",
24
+ "require": "./dist/src/toolClient/index.js",
25
+ "types": "./dist/src/toolClient/index.d.ts"
26
+ },
27
+ "./webAuthClient": {
28
+ "import": "./dist/src/webAuthClient/index.js",
29
+ "require": "./dist/src/webAuthClient/index.js",
30
+ "types": "./dist/src/webAuthClient/index.d.ts"
31
+ },
32
+ "./expressMiddleware": {
33
+ "import": "./dist/src/expressMiddleware/index.js",
34
+ "require": "./dist/src/expressMiddleware/index.js",
35
+ "types": "./dist/src/expressMiddleware/index.d.ts"
36
+ },
37
+ "./utils": {
38
+ "import": "./dist/src/utils/index.js",
39
+ "require": "./dist/src/utils/index.js",
40
+ "types": "./dist/src/utils/index.d.ts"
41
+ }
42
+ },
17
43
  "keywords": [
18
44
  "jwt",
19
45
  "authentication",
@@ -28,6 +54,7 @@
28
54
  "ethers": "5.8.0",
29
55
  "tslib": "^2.8.1",
30
56
  "zod": "3.25.64",
57
+ "@lit-protocol/vincent-contracts-sdk": "1.0.0-4",
31
58
  "@lit-protocol/vincent-tool-sdk": "1.0.2"
32
59
  },
33
60
  "sideEffects": false,
@@ -1,9 +0,0 @@
1
- import { VincentAppClientConfig, VincentWebAppClient } from './types';
2
- /** Create a new {@link VincentWebAppClient} instance.
3
- *
4
- * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
5
- *
6
- * @category API Methods
7
- * */
8
- export declare const getVincentWebAppClient: (appClientConfig: VincentAppClientConfig) => VincentWebAppClient;
9
- //# sourceMappingURL=app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAgBjB;;;;;KAKK;AACL,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,sBAAsB,KACtC,mBAmBF,CAAC"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVincentWebAppClient = void 0;
4
- const internal_1 = require("./internal");
5
- const constants_1 = require("./constants");
6
- const { isLoginUri, composeConsentUrl, removeSearchParam, decodeVincentJWTFromUri } = internal_1.uriHelpers;
7
- const redirectToConsentPage = ({ appId, redirectUri, consentPageUrl, }) => window.open(composeConsentUrl(appId, redirectUri, consentPageUrl).toString(), '_self');
8
- /** Create a new {@link VincentWebAppClient} instance.
9
- *
10
- * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
11
- *
12
- * @category API Methods
13
- * */
14
- const getVincentWebAppClient = (appClientConfig) => {
15
- const { appId } = appClientConfig;
16
- return {
17
- redirectToConsentPage: (redirectConsentPageConfig) => {
18
- const { consentPageUrl, redirectUri } = redirectConsentPageConfig;
19
- redirectToConsentPage({ appId, consentPageUrl, redirectUri });
20
- },
21
- isLogin: () => isLoginUri(window.location.href),
22
- decodeVincentLoginJWT: (expectedAudience) => decodeVincentJWTFromUri(window.location.href, expectedAudience),
23
- removeLoginJWTFromURI: () => {
24
- const urlWithoutJWTSearchParam = removeSearchParam({
25
- paramName: constants_1.JWT_URL_KEY,
26
- uri: window.location.href,
27
- });
28
- window.history.replaceState({}, document.title, urlWithoutJWTSearchParam);
29
- },
30
- };
31
- };
32
- exports.getVincentWebAppClient = getVincentWebAppClient;
33
- //# sourceMappingURL=app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/app/app.ts"],"names":[],"mappings":";;;AAKA,yCAAwC;AACxC,2CAA0C;AAE1C,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,qBAAU,CAAC;AAEjG,MAAM,qBAAqB,GAAG,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,cAAc,GAKf,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC;AAE7F;;;;;KAKK;AACE,MAAM,sBAAsB,GAAG,CACpC,eAAuC,EAClB,EAAE;IACvB,MAAM,EAAE,KAAK,EAAE,GAAG,eAAe,CAAC;IAElC,OAAO;QACL,qBAAqB,EAAE,CAAC,yBAA6D,EAAE,EAAE;YACvF,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,yBAAyB,CAAC;YAClE,qBAAqB,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/C,qBAAqB,EAAE,CAAC,gBAAwB,EAAE,EAAE,CAClD,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;QACjE,qBAAqB,EAAE,GAAG,EAAE;YAC1B,MAAM,wBAAwB,GAAG,iBAAiB,CAAC;gBACjD,SAAS,EAAE,uBAAW;gBACtB,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI;aAC1B,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,sBAAsB,0BAqBjC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/app/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,qCAAqC,CAAC;AACnF,eAAO,MAAM,WAAW,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/app/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gCAAgC,GAAG,kCAAkC,CAAC;AACtE,QAAA,WAAW,GAAG,KAAK,CAAC"}
@@ -1,3 +0,0 @@
1
- import { getVincentWebAppClient } from './app';
2
- export { getVincentWebAppClient };
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVincentWebAppClient = void 0;
4
- const app_1 = require("./app");
5
- Object.defineProperty(exports, "getVincentWebAppClient", { enumerable: true, get: function () { return app_1.getVincentWebAppClient; } });
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+C;AAEtC,uGAFA,4BAAsB,OAEA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/app/internal/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/internal/index.ts"],"names":[],"mappings":";;;;AAAA,iEAA2C;AAElC,gCAAU"}
@@ -1,11 +0,0 @@
1
- export declare const decodeVincentJWTFromUri: (uri: string, expectedAudience: string) => {
2
- decodedJWT: import("../..").VincentJWT;
3
- jwtStr: string;
4
- } | null;
5
- export declare const isLoginUri: (uri: string) => boolean;
6
- export declare function composeConsentUrl(appId: string, redirectUri: string, consentPageUrl?: string): URL;
7
- export declare const removeSearchParam: ({ paramName, uri, }: {
8
- paramName: string;
9
- uri: string;
10
- }) => string;
11
- //# sourceMappingURL=uriHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uriHelpers.d.ts","sourceRoot":"","sources":["../../../../src/app/internal/uriHelpers.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,EAAE,kBAAkB,MAAM;;;QAS5E,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,YAKrC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,OAK5F;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;CACb,KAAG,MAKH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"uriHelpers.js","sourceRoot":"","sources":["../../../../src/app/internal/uriHelpers.ts"],"names":[],"mappings":";;;AAqBA,8CAKC;AA1BD,4CAA6E;AAC7E,sDAAoD;AAE7C,MAAM,uBAAuB,GAAG,CAAC,GAAW,EAAE,gBAAwB,EAAE,EAAE;IAC/E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAW,CAAC,CAAC;IAE9C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,IAAA,oBAAS,EAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACvE,CAAC,CAAC;AATW,QAAA,uBAAuB,2BASlC;AAEK,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,QAAQ,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAW,CAAC,CAAC;IAEnD,OAAO,CAAC,CAAC,QAAQ,CAAC;AACpB,CAAC,CAAC;AALW,QAAA,UAAU,cAKrB;AAEF,SAAgB,iBAAiB,CAAC,KAAa,EAAE,WAAmB,EAAE,cAAuB;IAC3F,OAAO,IAAI,GAAG,CACZ,UAAU,KAAK,wBAAwB,WAAW,EAAE,EACpD,cAAc,IAAI,4CAAgC,CACnD,CAAC;AACJ,CAAC;AAEM,MAAM,iBAAiB,GAAG,CAAC,EAChC,SAAS,EACT,GAAG,GAIJ,EAAU,EAAE;IACX,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACnC,0DAA0D;IAC1D,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/app/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB;;SAEK;IACL,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,qBAAqB,EAAE,CAAC,cAAc,EAAE,kCAAkC,KAAK,IAAI,CAAC;IAEpF;;;;;;;;;;;OAWG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC;IAEvB;;;;;;;;;;;;OAYG;IACH,qBAAqB,EAAE,CACrB,gBAAgB,EAAE,MAAM,KACrB;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAEvD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC"}
@@ -1,79 +0,0 @@
1
- import type { NextFunction, Request, Response } from 'express';
2
- import { AuthenticatedRequestHandler } from './types';
3
- /**
4
- * Higher-order helper function to enforce authentication on a request handler and assert the type of `Request` that is
5
- * passed into your authenticated Express routes.
6
- *
7
- * This function takes an `AuthenticatedRequestHandler` and returns a new request handler
8
- * that verifies that the request has a 'user' property with the correct shape on it before calling the original handler.
9
- * If the `req.user` property isn't the correct shape, it sends a `401 Unauthorized` response to the client.
10
- *
11
- * NOTE: This does not verify signatures or any other content -- use `getAuthenticateUserExpressHandler` to create a
12
- * middleware that does those things and ensure that your routes use it.
13
- *
14
- * See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
15
- * @example
16
- * ```typescript
17
- * import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
18
- * const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
19
- *
20
- * import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
21
- *
22
- * // Define an authenticated route handler
23
- * const getUserProfile = async (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
24
- * // Access authenticated user information
25
- * const { pkpAddress } = req.user;
26
- *
27
- * // Fetch and return user data
28
- * const userData = await userRepository.findByAddress(pkpAddress);
29
- * res.json(userData);
30
- * };
31
- *
32
- * // Use in Express route with authentication
33
- * app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
34
- * ```
35
- */
36
- export declare const authenticatedRequestHandler: (handler: AuthenticatedRequestHandler) => (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
37
- /**
38
- * Creates an Express middleware function to authenticate a user using a JWT token.
39
- *
40
- * This middleware checks the `Authorization` header for a Bearer token, verifies the token, and checks its audience.
41
- * If the token is valid, it attaches the user information (decoded JWT, raw token, and PKP address) to the request object as `req.user`.
42
- * If the token is missing or invalid, it returns a 401 Unauthorized response with an error message.
43
- *
44
- * NOTE: Wrap your route handler functions with `authenticatedRequestHandler()` to assert the type of `Request` and to
45
- * ensure that `req.user` was correctly set before your route handler is run.
46
- *
47
- * See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
48
- *
49
- * @example
50
- * ```typescript
51
- * import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
52
- * const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
53
- *
54
- * import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
55
- *
56
- * // In your environment configuration
57
- * const ALLOWED_AUDIENCE = 'https://yourapp.example.com';
58
- *
59
- * // Create the authentication middleware
60
- * const authenticateUser = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
61
- *
62
- * // Define a handler that requires authentication
63
- * const getProtectedResource = (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
64
- * // The request is now authenticated
65
- * // No need for type casting as the handler is properly typed
66
- * const { pkpAddress } = req.user;
67
- * res.json({ message: `Hello, user with PKP address ${pkpAddress}` });
68
- * };
69
- *
70
- * // Apply to routes that require authentication by using authenticatedRequestHandler
71
- * app.get('/protected-resource', authenticateUser, authenticatedRequestHandler(getProtectedResource));
72
- * ```
73
- *
74
- * You can see the source for `getAuthenticateUserExpressHandler()` below; use this as a reference to implement
75
- * your own midddleware/authentication for other frameworks! Pull requests are welcome.
76
- * {@includeCode ./express.ts#expressHandlerTSDocExample}
77
- */
78
- export declare const getAuthenticateUserExpressHandler: (allowedAudience: string) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
79
- //# sourceMappingURL=express.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../src/express-authentication-middleware/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK/D,OAAO,EAAwB,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAsB5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,2BAA2B,GACrC,SAAS,2BAA2B,MAAM,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,yBAOzF,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,eAAO,MAAM,iCAAiC,GAC3C,iBAAiB,MAAM,MAAY,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,kBAmClF,CAAC"}