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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/CONTRIBUTING.md +115 -0
  3. package/README.md +216 -0
  4. package/dist/CHANGELOG.md +74 -0
  5. package/dist/CONTRIBUTING.md +115 -0
  6. package/dist/README.md +216 -0
  7. package/dist/package.json +86 -0
  8. package/dist/src/expressMiddleware/express.d.ts +63 -0
  9. package/dist/src/expressMiddleware/express.d.ts.map +1 -0
  10. package/dist/src/expressMiddleware/express.js +125 -0
  11. package/dist/src/expressMiddleware/express.js.map +1 -0
  12. package/dist/src/expressMiddleware/index.d.ts +14 -0
  13. package/dist/src/expressMiddleware/index.d.ts.map +1 -0
  14. package/dist/src/expressMiddleware/index.js +17 -0
  15. package/dist/src/expressMiddleware/index.js.map +1 -0
  16. package/dist/src/expressMiddleware/types.d.ts +31 -0
  17. package/dist/src/expressMiddleware/types.d.ts.map +1 -0
  18. package/dist/src/expressMiddleware/types.js +3 -0
  19. package/dist/src/expressMiddleware/types.js.map +1 -0
  20. package/dist/src/index.d.ts +2 -0
  21. package/dist/src/index.d.ts.map +1 -0
  22. package/dist/src/index.js +3 -0
  23. package/dist/src/index.js.map +1 -0
  24. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +14 -0
  25. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -0
  26. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js +67 -0
  27. package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -0
  28. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +7 -0
  29. package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -0
  30. package/dist/src/internal/LitNodeClient/getLitNodeClient.js +25 -0
  31. package/dist/src/internal/LitNodeClient/getLitNodeClient.js.map +1 -0
  32. package/dist/src/jwt/accessors.d.ts +8 -0
  33. package/dist/src/jwt/accessors.d.ts.map +1 -0
  34. package/dist/src/jwt/accessors.js +15 -0
  35. package/dist/src/jwt/accessors.js.map +1 -0
  36. package/dist/src/jwt/core/create.d.ts +24 -0
  37. package/dist/src/jwt/core/create.d.ts.map +1 -0
  38. package/dist/src/jwt/core/create.js +95 -0
  39. package/dist/src/jwt/core/create.js.map +1 -0
  40. package/dist/src/jwt/core/isExpired.d.ts +9 -0
  41. package/dist/src/jwt/core/isExpired.d.ts.map +1 -0
  42. package/dist/src/jwt/core/isExpired.js +20 -0
  43. package/dist/src/jwt/core/isExpired.js.map +1 -0
  44. package/dist/src/jwt/core/utils/base64.d.ts +14 -0
  45. package/dist/src/jwt/core/utils/base64.d.ts.map +1 -0
  46. package/dist/src/jwt/core/utils/base64.js +54 -0
  47. package/dist/src/jwt/core/utils/base64.js.map +1 -0
  48. package/dist/src/jwt/core/utils/definedObject.d.ts +2 -0
  49. package/dist/src/jwt/core/utils/definedObject.d.ts.map +1 -0
  50. package/dist/src/jwt/core/utils/definedObject.js +7 -0
  51. package/dist/src/jwt/core/utils/definedObject.js.map +1 -0
  52. package/dist/src/jwt/core/utils/index.d.ts +5 -0
  53. package/dist/src/jwt/core/utils/index.d.ts.map +1 -0
  54. package/dist/src/jwt/core/utils/index.js +12 -0
  55. package/dist/src/jwt/core/utils/index.js.map +1 -0
  56. package/dist/src/jwt/core/utils/processJWTSignature.d.ts +8 -0
  57. package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -0
  58. package/dist/src/jwt/core/utils/processJWTSignature.js +14 -0
  59. package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -0
  60. package/dist/src/jwt/core/utils/splitJWT.d.ts +11 -0
  61. package/dist/src/jwt/core/utils/splitJWT.d.ts.map +1 -0
  62. package/dist/src/jwt/core/utils/splitJWT.js +21 -0
  63. package/dist/src/jwt/core/utils/splitJWT.js.map +1 -0
  64. package/dist/src/jwt/core/utils/validateJWTTime.d.ts +12 -0
  65. package/dist/src/jwt/core/utils/validateJWTTime.d.ts.map +1 -0
  66. package/dist/src/jwt/core/utils/validateJWTTime.js +24 -0
  67. package/dist/src/jwt/core/utils/validateJWTTime.js.map +1 -0
  68. package/dist/src/jwt/core/validate.d.ts +29 -0
  69. package/dist/src/jwt/core/validate.d.ts.map +1 -0
  70. package/dist/src/jwt/core/validate.js +143 -0
  71. package/dist/src/jwt/core/validate.js.map +1 -0
  72. package/dist/src/jwt/index.d.ts +21 -0
  73. package/dist/src/jwt/index.d.ts.map +1 -0
  74. package/dist/src/jwt/index.js +32 -0
  75. package/dist/src/jwt/index.js.map +1 -0
  76. package/dist/src/jwt/typeGuards.d.ts +14 -0
  77. package/dist/src/jwt/typeGuards.d.ts.map +1 -0
  78. package/dist/src/jwt/typeGuards.js +32 -0
  79. package/dist/src/jwt/typeGuards.js.map +1 -0
  80. package/dist/src/jwt/types.d.ts +82 -0
  81. package/dist/src/jwt/types.d.ts.map +1 -0
  82. package/dist/src/jwt/types.js +3 -0
  83. package/dist/src/jwt/types.js.map +1 -0
  84. package/dist/src/toolClient/constants.d.ts +2 -0
  85. package/dist/src/toolClient/constants.d.ts.map +1 -0
  86. package/dist/src/toolClient/constants.js +5 -0
  87. package/dist/src/toolClient/constants.js.map +1 -0
  88. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts +8 -0
  89. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts.map +1 -0
  90. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js +33 -0
  91. package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js.map +1 -0
  92. package/dist/src/toolClient/execute/resultCreators.d.ts +71 -0
  93. package/dist/src/toolClient/execute/resultCreators.d.ts.map +1 -0
  94. package/dist/src/toolClient/execute/resultCreators.js +57 -0
  95. package/dist/src/toolClient/execute/resultCreators.js.map +1 -0
  96. package/dist/src/toolClient/execute/types.d.ts +38 -0
  97. package/dist/src/toolClient/execute/types.d.ts.map +1 -0
  98. package/dist/src/toolClient/execute/types.js +4 -0
  99. package/dist/src/toolClient/execute/types.js.map +1 -0
  100. package/dist/src/toolClient/index.d.ts +19 -0
  101. package/dist/src/toolClient/index.d.ts.map +1 -0
  102. package/dist/src/toolClient/index.js +26 -0
  103. package/dist/src/toolClient/index.js.map +1 -0
  104. package/dist/src/toolClient/precheck/resultCreators.d.ts +71 -0
  105. package/dist/src/toolClient/precheck/resultCreators.d.ts.map +1 -0
  106. package/dist/src/toolClient/precheck/resultCreators.js +57 -0
  107. package/dist/src/toolClient/precheck/resultCreators.js.map +1 -0
  108. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts +14 -0
  109. package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts.map +1 -0
  110. package/dist/src/toolClient/precheck/runPolicyPrechecks.js +98 -0
  111. package/dist/src/toolClient/precheck/runPolicyPrechecks.js.map +1 -0
  112. package/dist/src/toolClient/precheck/types.d.ts +82 -0
  113. package/dist/src/toolClient/precheck/types.d.ts.map +1 -0
  114. package/dist/src/toolClient/precheck/types.js +4 -0
  115. package/dist/src/toolClient/precheck/types.js.map +1 -0
  116. package/dist/src/toolClient/typeGuards.d.ts +28 -0
  117. package/dist/src/toolClient/typeGuards.d.ts.map +1 -0
  118. package/dist/src/toolClient/typeGuards.js +67 -0
  119. package/dist/src/toolClient/typeGuards.js.map +1 -0
  120. package/dist/src/toolClient/types.d.ts +50 -0
  121. package/dist/src/toolClient/types.d.ts.map +1 -0
  122. package/dist/src/toolClient/types.js +4 -0
  123. package/dist/src/toolClient/types.js.map +1 -0
  124. package/dist/src/toolClient/vincentToolClient.d.ts +76 -0
  125. package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -0
  126. package/dist/src/toolClient/vincentToolClient.js +285 -0
  127. package/dist/src/toolClient/vincentToolClient.js.map +1 -0
  128. package/dist/src/type-inference-verification/tool-client-inference.d.ts +3 -0
  129. package/dist/src/type-inference-verification/tool-client-inference.d.ts.map +1 -0
  130. package/dist/src/type-inference-verification/tool-client-inference.js +220 -0
  131. package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -0
  132. package/dist/src/utils/delegation.d.ts +7 -0
  133. package/dist/src/utils/delegation.d.ts.map +1 -0
  134. package/dist/src/utils/delegation.js +18 -0
  135. package/dist/src/utils/delegation.js.map +1 -0
  136. package/dist/src/utils/index.d.ts +3 -0
  137. package/dist/src/utils/index.d.ts.map +1 -0
  138. package/dist/src/utils/index.js +6 -0
  139. package/dist/src/utils/index.js.map +1 -0
  140. package/dist/src/utils/typedocRoot.d.ts +7 -0
  141. package/dist/src/utils/typedocRoot.d.ts.map +1 -0
  142. package/dist/src/utils/typedocRoot.js +13 -0
  143. package/dist/src/utils/typedocRoot.js.map +1 -0
  144. package/dist/src/utils/types.d.ts +15 -0
  145. package/dist/src/utils/types.d.ts.map +1 -0
  146. package/dist/src/utils/types.js +3 -0
  147. package/dist/src/utils/types.js.map +1 -0
  148. package/dist/src/webAuthClient/app.d.ts +7 -0
  149. package/dist/src/webAuthClient/app.d.ts.map +1 -0
  150. package/dist/src/webAuthClient/app.js +39 -0
  151. package/dist/src/webAuthClient/app.js.map +1 -0
  152. package/dist/src/webAuthClient/constants.d.ts +3 -0
  153. package/dist/src/webAuthClient/constants.d.ts.map +1 -0
  154. package/dist/src/webAuthClient/constants.js +6 -0
  155. package/dist/src/webAuthClient/constants.js.map +1 -0
  156. package/dist/src/webAuthClient/index.d.ts +13 -0
  157. package/dist/src/webAuthClient/index.d.ts.map +1 -0
  158. package/dist/src/webAuthClient/index.js +15 -0
  159. package/dist/src/webAuthClient/index.js.map +1 -0
  160. package/dist/src/webAuthClient/internal/index.d.ts +3 -0
  161. package/dist/src/webAuthClient/internal/index.d.ts.map +1 -0
  162. package/dist/src/webAuthClient/internal/index.js +7 -0
  163. package/dist/src/webAuthClient/internal/index.js.map +1 -0
  164. package/dist/src/webAuthClient/internal/uriHelpers.d.ts +15 -0
  165. package/dist/src/webAuthClient/internal/uriHelpers.d.ts.map +1 -0
  166. package/dist/src/webAuthClient/internal/uriHelpers.js +38 -0
  167. package/dist/src/webAuthClient/internal/uriHelpers.js.map +1 -0
  168. package/dist/src/webAuthClient/types.d.ts +109 -0
  169. package/dist/src/webAuthClient/types.d.ts.map +1 -0
  170. package/dist/src/webAuthClient/types.js +3 -0
  171. package/dist/src/webAuthClient/types.js.map +1 -0
  172. package/package.json +82 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDelegatorsAgentPkpAddresses = getDelegatorsAgentPkpAddresses;
4
+ const vincent_contracts_sdk_1 = require("@lit-protocol/vincent-contracts-sdk");
5
+ /** Get a (paginated) list of delegator agent PKPs for a specific app version
6
+ *
7
+ * See documentation at {@link vincent-contracts-sdk!getDelegatedPkpEthAddresses | vincent-contracts-sdk/getDelegatedPkpEthAddresses}
8
+ */
9
+ async function getDelegatorsAgentPkpAddresses(params) {
10
+ const { appId, appVersion, signer, pageOpts } = params;
11
+ const contractClient = (0, vincent_contracts_sdk_1.getClient)({ signer });
12
+ return await contractClient.getDelegatedPkpEthAddresses({
13
+ appId,
14
+ version: appVersion,
15
+ pageOpts,
16
+ });
17
+ }
18
+ //# sourceMappingURL=delegation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../../src/utils/delegation.ts"],"names":[],"mappings":";;AAQA,wEASC;AAjBD,+EAAgE;AAIhE;;;GAGG;AACI,KAAK,UAAU,8BAA8B,CAAC,MAAoC;IACvF,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAEvD,MAAM,cAAc,GAAG,IAAA,iCAAS,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,OAAO,MAAM,cAAc,CAAC,2BAA2B,CAAC;QACtD,KAAK;QACL,OAAO,EAAE,UAAU;QACnB,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getDelegatorsAgentPkpAddresses } from './delegation';
2
+ export type { GetDelegatorsAgentPkpsParams } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,YAAY,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDelegatorsAgentPkpAddresses = void 0;
4
+ var delegation_1 = require("./delegation");
5
+ Object.defineProperty(exports, "getDelegatorsAgentPkpAddresses", { enumerable: true, get: function () { return delegation_1.getDelegatorsAgentPkpAddresses; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAArD,4HAAA,8BAA8B,OAAA"}
@@ -0,0 +1,7 @@
1
+ /** Utility functions for interacting with the Vincent delegation backend
2
+ *
3
+ * @module utils
4
+ * @packageDocumentation
5
+ */
6
+ export { getDelegatorsAgentPkpAddresses } from './delegation';
7
+ //# sourceMappingURL=typedocRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedocRoot.d.ts","sourceRoot":"","sources":["../../../src/utils/typedocRoot.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // This file exists because the function params and options are inlined and expanded, and delegated to the docs in the contracts-sdk
3
+ // We don't want them to be 'root-level' exports for Typedoc purpose, or they appear under an 'Other' category and are not navigable
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getDelegatorsAgentPkpAddresses = void 0;
6
+ /** Utility functions for interacting with the Vincent delegation backend
7
+ *
8
+ * @module utils
9
+ * @packageDocumentation
10
+ */
11
+ var delegation_1 = require("./delegation");
12
+ Object.defineProperty(exports, "getDelegatorsAgentPkpAddresses", { enumerable: true, get: function () { return delegation_1.getDelegatorsAgentPkpAddresses; } });
13
+ //# sourceMappingURL=typedocRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedocRoot.js","sourceRoot":"","sources":["../../../src/utils/typedocRoot.ts"],"names":[],"mappings":";AAAA,oIAAoI;AACpI,oIAAoI;;;AAEpI;;;;GAIG;AAEH,2CAA8D;AAArD,4HAAA,8BAA8B,OAAA"}
@@ -0,0 +1,15 @@
1
+ import type { Signer } from 'ethers';
2
+ /**
3
+ * @inline
4
+ * @expand
5
+ */
6
+ export interface GetDelegatorsAgentPkpsParams {
7
+ appId: number;
8
+ appVersion: number;
9
+ signer: Signer;
10
+ pageOpts?: {
11
+ offset?: number;
12
+ limit?: number;
13
+ };
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD"}
@@ -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/utils/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { WebAuthClientConfig, WebAuthClient } from './types';
2
+ /** Create a new {@link WebAuthClient} instance.
3
+ *
4
+ * - `appId` is the numeric app ID displayed for your app on the Vincent Dashboard
5
+ * */
6
+ export declare const getWebAuthClient: (appClientConfig: WebAuthClientConfig) => WebAuthClient;
7
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/webAuthClient/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,aAAa,EACd,MAAM,SAAS,CAAC;AAsBjB;;;KAGK;AACL,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,mBAAmB,KAAG,aA6BvE,CAAC"}
@@ -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,3 @@
1
+ export declare const PRODUCTION_VINCENT_DASHBOARD_URL = "https://dashboard.heyvincent.ai/";
2
+ export declare const JWT_URL_KEY = "jwt";
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JWT_URL_KEY = exports.PRODUCTION_VINCENT_DASHBOARD_URL = void 0;
4
+ exports.PRODUCTION_VINCENT_DASHBOARD_URL = 'https://dashboard.heyvincent.ai/';
5
+ exports.JWT_URL_KEY = 'jwt';
6
+ //# sourceMappingURL=constants.js.map
@@ -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,3 @@
1
+ import * as uriHelpers from './uriHelpers';
2
+ export { uriHelpers };
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uriHelpers = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const uriHelpers = tslib_1.__importStar(require("./uriHelpers"));
6
+ exports.uriHelpers = uriHelpers;
7
+ //# sourceMappingURL=index.js.map
@@ -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"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeSearchParam = exports.isLoginUri = exports.decodeVincentJWTFromUri = void 0;
4
+ exports.composeDelegationAuthUrl = composeDelegationAuthUrl;
5
+ const validate_1 = require("../../jwt/core/validate");
6
+ const constants_1 = require("../constants");
7
+ const decodeVincentJWTFromUri = ({ uri, expectedAudience, requiredAppId, }) => {
8
+ const url = new URL(uri);
9
+ const jwt = url.searchParams.get(constants_1.JWT_URL_KEY);
10
+ if (!jwt) {
11
+ return null;
12
+ }
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
+ }
20
+ };
21
+ exports.decodeVincentJWTFromUri = decodeVincentJWTFromUri;
22
+ const isLoginUri = (uri) => {
23
+ const url = new URL(uri);
24
+ const loginJwt = url.searchParams.get(constants_1.JWT_URL_KEY);
25
+ return !!loginJwt;
26
+ };
27
+ exports.isLoginUri = isLoginUri;
28
+ function composeDelegationAuthUrl(appId, redirectUri, delegationAuthPageUrl) {
29
+ return new URL(`/user/consent/appId/${String(appId)}?redirectUri=${redirectUri}`, delegationAuthPageUrl || constants_1.PRODUCTION_VINCENT_DASHBOARD_URL);
30
+ }
31
+ const removeSearchParam = ({ paramName, uri, }) => {
32
+ const url = new URL(uri);
33
+ url.searchParams.delete(paramName);
34
+ // Update the browser's history without reloading the page
35
+ return url.toString();
36
+ };
37
+ exports.removeSearchParam = removeSearchParam;
38
+ //# sourceMappingURL=uriHelpers.js.map
@@ -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"}
@@ -0,0 +1,109 @@
1
+ import type { VincentJWTAppSpecific } from '../jwt/types';
2
+ export interface WebAuthClientConfig {
3
+ appId: number;
4
+ }
5
+ export interface RedirectToVincentDelegationPageParams {
6
+ redirectUri: string;
7
+ /** This only needs to be provided for local development with the entire stack
8
+ * @hidden
9
+ * */
10
+ delegationAuthPageUrl?: string;
11
+ }
12
+ /**
13
+ * The Vincent Web Application Client is used in web apps to handle interactions with the Vincent app portal.
14
+ *
15
+ * - Delegation authorization page redirection
16
+ * - Authentication helpers that are browser specific
17
+ *
18
+ */
19
+ export interface WebAuthClient {
20
+ /**
21
+ * Redirects the user to the Vincent delegation auth page.
22
+ *
23
+ * If the user approves your app permissions, they will be redirected back to the `redirectUri`.
24
+ *
25
+ * Use {@link WebAuthClient.isLogin} to detect if a user has just opened your app via the delegation auth page
26
+ *
27
+ * Use {@link WebAuthClient.decodeVincentLoginJWT} to decode and verify the {@link VincentJWT} from the page URI, and store it for later usage
28
+ *
29
+ * NOTE: You must register the `redirectUri` on your Vincent app for it to be considered a valid redirect target
30
+ *
31
+ * @example
32
+ * ```typescript
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
+ * }
47
+ * ```
48
+ * @function
49
+ * @inline
50
+ */
51
+ redirectToDelegationAuthPage: (redirectConfig: RedirectToVincentDelegationPageParams) => void;
52
+ /**
53
+ * Determines whether the current window location is a login URI associated with Vincent
54
+
55
+ * You can use this to detect if a user is loading your app as a result of approving permissions
56
+ * on the Vincent delegation auth page -- e.g. they just logged in
57
+ *
58
+ * See: {@link WebAuthClient.redirectToDelegationAuthPage} for example usage
59
+ *
60
+ * @function
61
+ * @inline
62
+ * @returns `true` if the current window URI is a login URI, otherwise `false`.
63
+ */
64
+ isLogin: () => boolean;
65
+ /**
66
+ * Extracts a decoded/parsed Vincent JWT (JSON Web Token) from the current window location
67
+ *
68
+ * The token is verified as part of this process; if the token is invalid or expired, this method will throw.
69
+ *
70
+ * See: {@link WebAuthClient.redirectToDelegationAuthPage} for example usage
71
+ *
72
+ * @param expectedAudience Provide a valid `redirectUri` for your app; this is typically your app's origin
73
+ * @function
74
+ * @inline
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
76
+ * @throws {Error} If there was a JWT in the page URL, but it was invalid / could not be verified
77
+ */
78
+ decodeVincentLoginJWT: (expectedAudience: string) => {
79
+ decodedJWT: VincentJWTAppSpecific;
80
+ jwtStr: string;
81
+ } | null;
82
+ /**
83
+ * Removes the Vincent login JWT from the current window URI.
84
+ *
85
+ * This is useful for cleaning up the URL after decoding and storing the JWT,
86
+ * ensuring the redirect URL looks clean for the user and no sensitive information
87
+ * is exposed in the URI.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webAuthClient';
92
+ *
93
+ * const vincentAppClient = getWebAuthClient({ appId: MY_APP_ID });
94
+ *
95
+ * if (vincentAppClient.isLogin()) {
96
+ * const { decodedJWT, jwtStr } = vincentAppClient.decodeVincentLoginJWT();
97
+ * // Store the JWT and use it for authentication
98
+ *
99
+ * // Now we can remove the JWT from the URL searchParams
100
+ * vincentAppClient.removeLoginJWTFromURI();
101
+ * }
102
+ * ```
103
+ *
104
+ * @function
105
+ * @inline
106
+ */
107
+ removeLoginJWTFromURI: () => void;
108
+ }
109
+ //# sourceMappingURL=types.d.ts.map
@@ -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"}
@@ -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/webAuthClient/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@lit-protocol/vincent-app-sdk",
3
+ "version": "0.0.4-mma",
4
+ "description": "Vincent SDK for browser and backend",
5
+ "author": "Lit Protocol",
6
+ "license": "ISC",
7
+ "access": "public",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "engines": {
12
+ "node": "^20.11.1",
13
+ "pnpm": "10.7.0"
14
+ },
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
+ },
43
+ "keywords": [
44
+ "jwt",
45
+ "authentication",
46
+ "sdk"
47
+ ],
48
+ "dependencies": {
49
+ "@lit-protocol/auth-helpers": "^7.0.9",
50
+ "@lit-protocol/constants": "^7.0.8",
51
+ "@lit-protocol/lit-node-client": "^7.0.8",
52
+ "@noble/secp256k1": "^2.2.3",
53
+ "did-jwt": "^8.0.8",
54
+ "ethers": "5.8.0",
55
+ "tslib": "^2.8.1",
56
+ "zod": "3.25.64",
57
+ "@lit-protocol/vincent-contracts-sdk": "1.0.0-4",
58
+ "@lit-protocol/vincent-tool-sdk": "1.0.2"
59
+ },
60
+ "sideEffects": false,
61
+ "files": [
62
+ "dist/**/*",
63
+ "*.md"
64
+ ],
65
+ "devDependencies": {
66
+ "@lit-protocol/pkp-ethers": "^7.2.0",
67
+ "@lit-protocol/types": "^7.0.8",
68
+ "@types/express": "^5.0.1",
69
+ "chokidar-cli": "^3.0.0",
70
+ "live-server": "^1.2.2",
71
+ "typedoc": "0.27.9",
72
+ "typedoc-material-theme": "1.3.0",
73
+ "typedoc-plugin-extras": "^4.0.0",
74
+ "typedoc-plugin-zod": "^1.4.1",
75
+ "vercel": "^41.6.2"
76
+ },
77
+ "scripts": {
78
+ "type-tests": "./scripts/run-typecheck.sh",
79
+ "watch:type-tests": "chokidar 'src/**/*' --initial --await-write-finish --delay 100 --silent -c './scripts/run-typecheck.sh'",
80
+ "typecheck": "./scripts/precommit-check.sh"
81
+ }
82
+ }