@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,74 @@
1
+ ## 1.0.2 (2025-07-08)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - #### VincentToolClient Precheck fixes ([8da32df2](https://github.com/LIT-Protocol/Vincent/commit/8da32df2))
6
+
7
+ - Fix a case where deny results from `precheck()` were not correctly bubbled to the caller
8
+ - Fixed incorrect return type shape - `error` is a sibling of `result` in the policiesContext- Ensured `error` is bubbled up to the caller when provided
9
+
10
+ - - VincentToolClient - Expose correct policiesContext type when calling `precheck()` ([812d4fe9](https://github.com/LIT-Protocol/Vincent/commit/812d4fe9))
11
+ - - `VincentToolClient` - Fixed case where a tool without its own `precheck()` function would return `success` result even if a policy returned an `deny` result from its `precheck()` ([71380b89](https://github.com/LIT-Protocol/Vincent/commit/71380b89))
12
+ - - `VincentToolClient` - Fixed case where a fail response did not return the `error` or `result` response to the caller correctly ([30e32f1e](https://github.com/LIT-Protocol/Vincent/commit/30e32f1e))
13
+
14
+ ### 🧱 Updated Dependencies
15
+
16
+ - Updated tool-sdk to 1.0.2
17
+
18
+ ### ❤️ Thank You
19
+
20
+ - Daryl Collins
21
+
22
+ ## 0.0.7 (2025-05-26)
23
+
24
+ ### 🚀 Features
25
+
26
+ - improved mcp api doc ([0389014](https://github.com/LIT-Protocol/Vincent/commit/0389014))
27
+ - updated Vincent MCP documentation with its own section ([3457891](https://github.com/LIT-Protocol/Vincent/commit/3457891))
28
+ - add documentation ([f539eb5](https://github.com/LIT-Protocol/Vincent/commit/f539eb5))
29
+ - implementation of the vincent mcp server stdio and http runners using the app to mcp transformer in the sdk ([aa58c17](https://github.com/LIT-Protocol/Vincent/commit/aa58c17))
30
+ - implementation of the vincent app mcp wrapper ([02dd8ca](https://github.com/LIT-Protocol/Vincent/commit/02dd8ca))
31
+ - add release script to release SDK and its doc to npm and vercel ([eaccd5f](https://github.com/LIT-Protocol/Vincent/commit/eaccd5f))
32
+ - **docs:** change title, downgrade for plugin extras ([cdd62c0](https://github.com/LIT-Protocol/Vincent/commit/cdd62c0))
33
+ - use standard syntax for jwt validation errors and move validation to decoding step ([fefbbc6](https://github.com/LIT-Protocol/Vincent/commit/fefbbc6))
34
+ - deduplicate vincent data in decoded jwt and revert building config changes ([481d131](https://github.com/LIT-Protocol/Vincent/commit/481d131))
35
+ - change ts compiler config to increase compatibility surface and fix usage in DCA FE vite app ([027582d](https://github.com/LIT-Protocol/Vincent/commit/027582d))
36
+ - add authorized app and user info to jwt ([237f70d](https://github.com/LIT-Protocol/Vincent/commit/237f70d))
37
+ - **vincent-app-sdk:** add Express authentication helpers and update docs ([14a04b3](https://github.com/LIT-Protocol/Vincent/commit/14a04b3))
38
+ - **vincent-app-sdk:** Update README.md ([d052e18](https://github.com/LIT-Protocol/Vincent/commit/d052e18))
39
+ - **vincent-app-sdk:** Add sdk-docs TypeDocs to root of repo ([fb15599](https://github.com/LIT-Protocol/Vincent/commit/fb15599))
40
+ - **vincent-app-sdk:** Return both the original JWT string and the decoded JWT object from `decodeVincentLoginJWT()` - Also fixed inverted logic check for `isLoginUri()`, and converted to object params for `isLoginUri()` ([c2f3a19](https://github.com/LIT-Protocol/Vincent/commit/c2f3a19))
41
+ - **vincent-app-sdk:** Add `removeLoginJWTFromURI()` method to `VincentWebAppClient` ([17072f4](https://github.com/LIT-Protocol/Vincent/commit/17072f4))
42
+ - **vincent-app-sdk:** Replace `pkp/delegatee-sigs` with a `VincentToolClient` - Exposes a single method, `getVincentToolClient()`, which Vincent app developers will use to interact with Vincent Tool LIT actions - Fixes existing code that created new instances of LitNodeClient and connecting to them every time the tool is interacted with, using newly minted singleton module - Initial TSDoc configurations for exposing the tool client construction and usage under a 'Vincent Tools' category. ([2052ebe](https://github.com/LIT-Protocol/Vincent/commit/2052ebe))
43
+ - **vincent-app-sdk:** Define an internal module for managing a singleton instance of a LitNodeClient ([d297b0c](https://github.com/LIT-Protocol/Vincent/commit/d297b0c))
44
+ - update vincent sdk readme ([090614d](https://github.com/LIT-Protocol/Vincent/commit/090614d))
45
+ - added contracts class ([ef1851e](https://github.com/LIT-Protocol/Vincent/commit/ef1851e))
46
+
47
+ ### 🩹 Fixes
48
+
49
+ - ZodSchemmaMap typo ([095f38e](https://github.com/LIT-Protocol/Vincent/commit/095f38e))
50
+ - doc reference ([b1450f8](https://github.com/LIT-Protocol/Vincent/commit/b1450f8))
51
+ - remove unnecessary type annotation ([c71eeac](https://github.com/LIT-Protocol/Vincent/commit/c71eeac))
52
+ - sdk nx project linting tool ([82dd819](https://github.com/LIT-Protocol/Vincent/commit/82dd819))
53
+ - **docs:** rename (remove API) ([a4b8e83](https://github.com/LIT-Protocol/Vincent/commit/a4b8e83))
54
+ - **docs:** formatting fixes, custom css for :::info ([6f2fcef](https://github.com/LIT-Protocol/Vincent/commit/6f2fcef))
55
+ - **vincent-app-sdk:** Fix import of `JWT_ERROR` to import from root of `did-jwt` package ([dd96111](https://github.com/LIT-Protocol/Vincent/commit/dd96111))
56
+ - do not export simple jwt manipulating functions. Consumers should use the sdk directly ([6e46eee](https://github.com/LIT-Protocol/Vincent/commit/6e46eee))
57
+ - **publish:** need to include 'dist' ([ecf38c3](https://github.com/LIT-Protocol/Vincent/commit/ecf38c3))
58
+ - **sdk:** package.json exports ([dd35563](https://github.com/LIT-Protocol/Vincent/commit/dd35563))
59
+ - no need types node ([af98c0e](https://github.com/LIT-Protocol/Vincent/commit/af98c0e))
60
+ - **build:** add missing tsconfig.lib.json ([ce47c23](https://github.com/LIT-Protocol/Vincent/commit/ce47c23))
61
+ - **jest:** enable `passWithNoTests` ([0f4ac57](https://github.com/LIT-Protocol/Vincent/commit/0f4ac57))
62
+ - lint and any ([c4fc2ab](https://github.com/LIT-Protocol/Vincent/commit/c4fc2ab))
63
+ - **deps:** correctly scope dependencies between global & individual packages ([b3fdb8c](https://github.com/LIT-Protocol/Vincent/commit/b3fdb8c))
64
+ - **build:** remove rollup and use default nx settings ([b3769df](https://github.com/LIT-Protocol/Vincent/commit/b3769df))
65
+ - minor changes ([0a70d4a](https://github.com/LIT-Protocol/Vincent/commit/0a70d4a))
66
+ - removed umd build ([6e532fa](https://github.com/LIT-Protocol/Vincent/commit/6e532fa))
67
+
68
+ ### ❤️ Thank You
69
+
70
+ - Ansh Saxena @anshss
71
+ - Anson
72
+ - awisniew207 @awisniew207
73
+ - Daryl Collins
74
+ - FedericoAmura @FedericoAmura
@@ -0,0 +1,115 @@
1
+ # Contributing to Vincent SDK
2
+
3
+ This document provides guidelines for contributing to the Vincent SDK project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent SDK is a TypeScript SDK that exposes useful tools to interact with Vincent systems in web or Node.js environments. It provides client libraries for both frontend applications and backend services.
8
+
9
+ ## Setup
10
+
11
+ 1. Follow the global setup instructions in the repository root [CONTRIBUTING.md](../../CONTRIBUTING.md).
12
+ 2. Install dependencies:
13
+ ```bash
14
+ pnpm install
15
+ ```
16
+
17
+ ## Development Workflow
18
+
19
+ ### Building
20
+
21
+ Build the SDK:
22
+
23
+ ```bash
24
+ pnpm build
25
+ ```
26
+
27
+ ### Documentation
28
+
29
+ Generate TypeDoc documentation:
30
+
31
+ ```bash
32
+ pnpm typedoc
33
+ ```
34
+
35
+ ## Project Structure
36
+
37
+ - `src/`: Source code
38
+ - `index.ts`: Main entry point
39
+ - `app/`: Web utilities to authenticate against Vincent Apps in clients
40
+ - `express-authentication-middleware/`: Express middleware wrapper to properly validate clients JWT server side
41
+ - `jwt/`: Utility functions to work with Vincent JWT between Vincent Apps client and server
42
+ - `tool/`: Utility functions to work with Vincent Tools
43
+
44
+ ## SDK Components
45
+
46
+ ### WebAuthClient
47
+
48
+ The Vincent Web Auth Client provides methods for managing user authentication, JWT tokens, and consent flows in Vincent applications.
49
+
50
+ ### VincentToolClient
51
+
52
+ The Vincent Tool Client uses an ethers signer for your delegatee account to run Vincent Tools on behalf of your app users.
53
+
54
+ ## Coding Standards
55
+
56
+ 1. Use TypeScript for all new code
57
+ 2. Follow the project's existing coding style
58
+ 3. Write clear, descriptive comments and JSDoc for public APIs
59
+ 4. Include appropriate error handling
60
+ 5. Write unit tests for new functionality
61
+ 6. Maintain backward compatibility when possible
62
+
63
+ ## Type Safety
64
+
65
+ - Use proper TypeScript types for all functions and variables
66
+ - Avoid using `any` type; prefer `unknown` when the type is truly unknown
67
+ - Use generics where appropriate to maintain type safety
68
+ - Ensure exported APIs have proper type definitions
69
+
70
+ ## Testing
71
+
72
+ Write unit tests for new functionality:
73
+
74
+ ```bash
75
+ pnpm test
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ - Document all public APIs with JSDoc comments
81
+ - Update README.md when adding new features
82
+ - Generate and review TypeDoc documentation
83
+
84
+ ## Pull Request Process
85
+
86
+ 1. Ensure your code follows the coding standards
87
+ 2. Update documentation if necessary
88
+ 3. Include tests for new features or bug fixes
89
+ 4. Link any related issues in your pull request description
90
+ 5. Add an nx version plan documenting your changes
91
+ 6. Request a review from a maintainer
92
+
93
+ ## For AI Editors and IDEs
94
+
95
+ When working with AI-powered editors like Cursor, GitHub Copilot, or other AI assistants in this project directory, please note:
96
+
97
+ ### Context Priority
98
+
99
+ 1. **Primary Context**: When working within the SDK project directory, AI editors should prioritize this CONTRIBUTING.md file and the project's README.md for specific guidance on the SDK project.
100
+
101
+ 2. **Secondary Context**: The root-level CONTRIBUTING.md and README.md files provide important context about how this project fits into the broader Vincent ecosystem.
102
+
103
+ ### Key Files for SDK Context
104
+
105
+ - `/packages/libs/app-sdk/README.md`: Overview of the SDK project
106
+ - `/packages/libs/app-sdk/CONTRIBUTING.md`: This file, with SDK-specific contribution guidelines
107
+ - `/packages/libs/app-sdk/src/`: Source code for the SDK
108
+
109
+ When working on SDK code, consider these dependencies and consumers for context.
110
+
111
+ ## Additional Resources
112
+
113
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
114
+ - [SDK Documentation](https://sdk-docs.heyvincent.ai/)
115
+ - [TypeScript Documentation](https://www.typescriptlang.org/docs/)
package/README.md ADDED
@@ -0,0 +1,216 @@
1
+ # Vincent SDK
2
+
3
+ ## Installation
4
+
5
+ ```
6
+ npm install @lit-protocol/vincent-app-sdk
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ # Client (Web)
12
+
13
+ ## WebAuthClient
14
+
15
+ The Vincent Web Auth Client provides methods for managing user authentication, JWT tokens, and consent flows in Vincent applications.
16
+
17
+ ### Methods
18
+
19
+ #### redirectToConsentPage()
20
+
21
+ Redirects the user to the Vincent consent page to obtain authorization. Once the user has completed the vincent consent flow
22
+ they will be redirected back to your app with a signed JWT that you can use to authenticate requests against your backend APIs
23
+
24
+ - When a JWT is expired, you need to use this method to get a new JWT
25
+
26
+ #### isLoginUri()
27
+
28
+ Checks if the current window location contains a Vincent login JWT. You can use this method to know that you should update login state with the newly provided JWT
29
+
30
+ - Returns: Boolean indicating if the URI contains a login JWT
31
+
32
+ #### decodeVincentLoginJWT(expectedAudience)
33
+
34
+ Decodes a Vincent login JWT. Performs basic sanity check but does not perform full verify() logic. You will want to run `verify()` from the jwt tools to verify the JWT is fully valid and not expired etc.
35
+
36
+ - The expected audience is typically your app's domain -- it should be one of your valid redirectUri values from your Vincent app configuration
37
+
38
+ - Returns: An object containing both the original JWT string and the decoded JWT object
39
+
40
+ #### removeLoginJWTFromURI()
41
+
42
+ Removes the login JWT parameter from the current URI. Call this after you have verified and stored the JWT for later usage.
43
+
44
+ ### Basic Usage
45
+
46
+ ```typescript
47
+ import { getWebAuthClient } from '@lit-protocol/vincent-app-sdk/webaAthClient';
48
+ import { isExpired } from '@lit-protocol/vincent-app-sdk/jwt';
49
+
50
+ const vincentAppClient = getWebAuthClient({ appId: MY_APP_ID });
51
+ // ... In your app logic:
52
+ if (vincentAppClient.isLogin()) {
53
+ // Handle app logic for the user has just logged in
54
+ const { decoded, jwt } = vincentAppClient.decodeVincentLoginJWT(window.location.origin);
55
+ // Store `jwt` for later usage; the user is now logged in.
56
+ } else {
57
+ // Handle app logic for the user is _already logged in_ (check for stored & unexpired JWT)
58
+
59
+ const jwt = localStorage.getItem('VINCENT_AUTH_JWT');
60
+ if (jwt && isExpired(jwt)) {
61
+ // User must re-log in
62
+ vincentAppClient.redirectToConsentPage({ redirectUri: window.location.href });
63
+ }
64
+
65
+ if (!jwt) {
66
+ // Handle app logic for the user is not yet logged in
67
+ vincentAppClient.redirectToConsentPage({ redirectUri: window.location.href });
68
+ }
69
+ }
70
+ ```
71
+
72
+ # Backend
73
+
74
+ In your backend, you will have to verify the JWT to make sure the user has granted you the required permissions to act on their behalf.
75
+
76
+ ## VincentToolClient
77
+
78
+ The Vincent Tool Client uses an ethers signer for your delegatee account to run Vincent Tools on behalf of your app users.
79
+
80
+ This client will typically be used by an AI agent or your app backend service, as it requires a signer that conforms to the ethers v5 signer API, and with access to your delegatee account's private key to authenticate with the LIT network when executing the Vincent Tool.
81
+
82
+ ### Configuration
83
+
84
+ ```typescript
85
+ interface VincentToolClientConfig {
86
+ ethersSigner: ethers.Signer; // An ethers v5 compatible signer
87
+ vincentToolCid: string; // The CID of the Vincent Tool to execute
88
+ }
89
+ ```
90
+
91
+ ### Methods
92
+
93
+ #### execute(params: VincentToolParams): Promise<ExecuteJsResponse>
94
+
95
+ Executes a Vincent Tool with the provided parameters.
96
+
97
+ - `params`: Record<string, unknown> - Parameters to pass to the Vincent Tool
98
+ - Returns: Promise resolving to an ExecuteJsResponse from the LIT network
99
+
100
+ ### Tool execution
101
+
102
+ ```typescript
103
+ import { getVincentToolClient } from '@lit-protocol/vincent-app-sdk/toolClient';
104
+ // Import the tool you want to execute
105
+ import { bundledVincentTool as erc20BundledTool } from '@lit-protocol/vincent-tool-erc20-approval';
106
+
107
+ // One of delegatee signers from your app's Vincent Dashboard
108
+ const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
109
+
110
+ // Initialize the Vincent Tool Client
111
+ const toolClient = getVincentToolClient({
112
+ ethersSigner: delegateeSigner,
113
+ bundledVincentTool: erc20BundledTool,
114
+ });
115
+ const delegatorPkpEthAddress = '0x09182301238';
116
+
117
+ const toolParams = {
118
+ // Fill with the params your tool needs
119
+ };
120
+
121
+ // Run precheck to see if tool should be executed
122
+ const precheckResult = await client.precheck(toolParams, {
123
+ delegatorPkpEthAddress,
124
+ });
125
+
126
+ if (precheckResult.success === true) {
127
+ // Execute the Vincent Tool
128
+ const executeResult = await client.execute(toolParams, {
129
+ delegatorPkpEthAddress,
130
+ });
131
+
132
+ // ...tool has executed, you can check `executeResult` for details
133
+ }
134
+ ```
135
+
136
+ ### Usage
137
+
138
+ ### Authentication
139
+
140
+ A basic Express authentication middleware factory function is provided with the SDK.
141
+
142
+ - Create an express middleware using `getAuthenticateUserExpressHandler()`
143
+ - Once you have added the middleware to your route, use `authenticatedRequestHandler()` to provide
144
+ type-safe access to `req.user` in your downstream RequestHandler functions.
145
+ - When defining your authenticated routes, use the `ExpressAuthHelpers` type to type your functions and function arguments.
146
+
147
+ See getAuthenticateUserExpressHandler() documentation to see the source for the express authentication route handler
148
+
149
+ ```typescript
150
+ import {
151
+ authenticatedRequestHandler,
152
+ getAuthenticateUserExpressHandler,
153
+ } from '@lit-protocol/vincent-app-sdk/expressMiddleware';
154
+
155
+ import type { AuthenticatedRequest } from '@lit-protocol/vincent-app-sdk/expressMiddleware';
156
+
157
+ const { ALLOWED_AUDIENCE } = process.env;
158
+
159
+ const authenticateUserMiddleware = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
160
+
161
+ // Define an authenticated route handler
162
+ const getUserProfile = async (req: AuthenticatedRequest, res: Response) => {
163
+ // Access authenticated user information
164
+ const { pkpAddress } = req.user;
165
+
166
+ // Fetch and return user data
167
+ const userData = await userRepository.findByAddress(pkpAddress);
168
+ res.json(userData);
169
+ };
170
+
171
+ // Use in Express route with authentication
172
+ app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
173
+ ```
174
+
175
+ ## JWT Authentication
176
+
177
+ ### Overview
178
+
179
+ The JWT authentication system in Vincent SDK allows for secure communication between user applications and Vincent Tools. JWTs are used to verify user consent and authorize tool executions.
180
+
181
+ ### Authentication Flow
182
+
183
+ 1. User initiates an action requiring Vincent Tool access
184
+ 2. Application redirects to the Vincent consent page using `VincentWebAppClient.redirectToConsentPage()`
185
+ 3. User provides consent for the requested tools/policies
186
+ 4. User is redirected back to the application with a JWT in the URL
187
+ 5. Application validates and stores the JWT using `VincentWebAppClient` methods
188
+ 6. JWT is used to authenticate with the app backend
189
+
190
+ ### JWT Structure
191
+
192
+ Vincent JWTs contain:
193
+
194
+ - User account identity information (pkpAddress and pkpPublicKey)
195
+ - Expiration timestamp
196
+ - Signature from the Vincent authorization service
197
+
198
+ ### Error Handling
199
+
200
+ When JWT validation fails, descriptive error messages are thrown to help with troubleshooting.
201
+
202
+ ### Usage Notes
203
+
204
+ - JWTs have an expiration time after which they are no longer valid
205
+ - When a JWT expires, redirect the user to the consent page to obtain a new one using the `VincentWebAppClient`
206
+
207
+ ## Release
208
+
209
+ Pre-requisites:
210
+
211
+ - You will need a valid npm account with access to the `@lit-protocol` organization.
212
+ - Run `pnpm vercel login` at sdk root to get a authentication token for vercel
213
+ - Also you will need to fill the `.env` file with the vercel project and org ids for the [vincent-docs](https://vercel.com/lit-protocol/vincent-docs) project.
214
+
215
+ Then run `pnpm release` on the repository root. It will prompt you to update the Vincent SDK version and then ask you to confirm the release.
216
+ This process will also generate a `CHANGELOG.md` record with the changes for the release and update typedoc in vercel after publishing the SDK.
@@ -0,0 +1,74 @@
1
+ ## 1.0.2 (2025-07-08)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - #### VincentToolClient Precheck fixes ([8da32df2](https://github.com/LIT-Protocol/Vincent/commit/8da32df2))
6
+
7
+ - Fix a case where deny results from `precheck()` were not correctly bubbled to the caller
8
+ - Fixed incorrect return type shape - `error` is a sibling of `result` in the policiesContext- Ensured `error` is bubbled up to the caller when provided
9
+
10
+ - - VincentToolClient - Expose correct policiesContext type when calling `precheck()` ([812d4fe9](https://github.com/LIT-Protocol/Vincent/commit/812d4fe9))
11
+ - - `VincentToolClient` - Fixed case where a tool without its own `precheck()` function would return `success` result even if a policy returned an `deny` result from its `precheck()` ([71380b89](https://github.com/LIT-Protocol/Vincent/commit/71380b89))
12
+ - - `VincentToolClient` - Fixed case where a fail response did not return the `error` or `result` response to the caller correctly ([30e32f1e](https://github.com/LIT-Protocol/Vincent/commit/30e32f1e))
13
+
14
+ ### 🧱 Updated Dependencies
15
+
16
+ - Updated tool-sdk to 1.0.2
17
+
18
+ ### ❤️ Thank You
19
+
20
+ - Daryl Collins
21
+
22
+ ## 0.0.7 (2025-05-26)
23
+
24
+ ### 🚀 Features
25
+
26
+ - improved mcp api doc ([0389014](https://github.com/LIT-Protocol/Vincent/commit/0389014))
27
+ - updated Vincent MCP documentation with its own section ([3457891](https://github.com/LIT-Protocol/Vincent/commit/3457891))
28
+ - add documentation ([f539eb5](https://github.com/LIT-Protocol/Vincent/commit/f539eb5))
29
+ - implementation of the vincent mcp server stdio and http runners using the app to mcp transformer in the sdk ([aa58c17](https://github.com/LIT-Protocol/Vincent/commit/aa58c17))
30
+ - implementation of the vincent app mcp wrapper ([02dd8ca](https://github.com/LIT-Protocol/Vincent/commit/02dd8ca))
31
+ - add release script to release SDK and its doc to npm and vercel ([eaccd5f](https://github.com/LIT-Protocol/Vincent/commit/eaccd5f))
32
+ - **docs:** change title, downgrade for plugin extras ([cdd62c0](https://github.com/LIT-Protocol/Vincent/commit/cdd62c0))
33
+ - use standard syntax for jwt validation errors and move validation to decoding step ([fefbbc6](https://github.com/LIT-Protocol/Vincent/commit/fefbbc6))
34
+ - deduplicate vincent data in decoded jwt and revert building config changes ([481d131](https://github.com/LIT-Protocol/Vincent/commit/481d131))
35
+ - change ts compiler config to increase compatibility surface and fix usage in DCA FE vite app ([027582d](https://github.com/LIT-Protocol/Vincent/commit/027582d))
36
+ - add authorized app and user info to jwt ([237f70d](https://github.com/LIT-Protocol/Vincent/commit/237f70d))
37
+ - **vincent-app-sdk:** add Express authentication helpers and update docs ([14a04b3](https://github.com/LIT-Protocol/Vincent/commit/14a04b3))
38
+ - **vincent-app-sdk:** Update README.md ([d052e18](https://github.com/LIT-Protocol/Vincent/commit/d052e18))
39
+ - **vincent-app-sdk:** Add sdk-docs TypeDocs to root of repo ([fb15599](https://github.com/LIT-Protocol/Vincent/commit/fb15599))
40
+ - **vincent-app-sdk:** Return both the original JWT string and the decoded JWT object from `decodeVincentLoginJWT()` - Also fixed inverted logic check for `isLoginUri()`, and converted to object params for `isLoginUri()` ([c2f3a19](https://github.com/LIT-Protocol/Vincent/commit/c2f3a19))
41
+ - **vincent-app-sdk:** Add `removeLoginJWTFromURI()` method to `VincentWebAppClient` ([17072f4](https://github.com/LIT-Protocol/Vincent/commit/17072f4))
42
+ - **vincent-app-sdk:** Replace `pkp/delegatee-sigs` with a `VincentToolClient` - Exposes a single method, `getVincentToolClient()`, which Vincent app developers will use to interact with Vincent Tool LIT actions - Fixes existing code that created new instances of LitNodeClient and connecting to them every time the tool is interacted with, using newly minted singleton module - Initial TSDoc configurations for exposing the tool client construction and usage under a 'Vincent Tools' category. ([2052ebe](https://github.com/LIT-Protocol/Vincent/commit/2052ebe))
43
+ - **vincent-app-sdk:** Define an internal module for managing a singleton instance of a LitNodeClient ([d297b0c](https://github.com/LIT-Protocol/Vincent/commit/d297b0c))
44
+ - update vincent sdk readme ([090614d](https://github.com/LIT-Protocol/Vincent/commit/090614d))
45
+ - added contracts class ([ef1851e](https://github.com/LIT-Protocol/Vincent/commit/ef1851e))
46
+
47
+ ### 🩹 Fixes
48
+
49
+ - ZodSchemmaMap typo ([095f38e](https://github.com/LIT-Protocol/Vincent/commit/095f38e))
50
+ - doc reference ([b1450f8](https://github.com/LIT-Protocol/Vincent/commit/b1450f8))
51
+ - remove unnecessary type annotation ([c71eeac](https://github.com/LIT-Protocol/Vincent/commit/c71eeac))
52
+ - sdk nx project linting tool ([82dd819](https://github.com/LIT-Protocol/Vincent/commit/82dd819))
53
+ - **docs:** rename (remove API) ([a4b8e83](https://github.com/LIT-Protocol/Vincent/commit/a4b8e83))
54
+ - **docs:** formatting fixes, custom css for :::info ([6f2fcef](https://github.com/LIT-Protocol/Vincent/commit/6f2fcef))
55
+ - **vincent-app-sdk:** Fix import of `JWT_ERROR` to import from root of `did-jwt` package ([dd96111](https://github.com/LIT-Protocol/Vincent/commit/dd96111))
56
+ - do not export simple jwt manipulating functions. Consumers should use the sdk directly ([6e46eee](https://github.com/LIT-Protocol/Vincent/commit/6e46eee))
57
+ - **publish:** need to include 'dist' ([ecf38c3](https://github.com/LIT-Protocol/Vincent/commit/ecf38c3))
58
+ - **sdk:** package.json exports ([dd35563](https://github.com/LIT-Protocol/Vincent/commit/dd35563))
59
+ - no need types node ([af98c0e](https://github.com/LIT-Protocol/Vincent/commit/af98c0e))
60
+ - **build:** add missing tsconfig.lib.json ([ce47c23](https://github.com/LIT-Protocol/Vincent/commit/ce47c23))
61
+ - **jest:** enable `passWithNoTests` ([0f4ac57](https://github.com/LIT-Protocol/Vincent/commit/0f4ac57))
62
+ - lint and any ([c4fc2ab](https://github.com/LIT-Protocol/Vincent/commit/c4fc2ab))
63
+ - **deps:** correctly scope dependencies between global & individual packages ([b3fdb8c](https://github.com/LIT-Protocol/Vincent/commit/b3fdb8c))
64
+ - **build:** remove rollup and use default nx settings ([b3769df](https://github.com/LIT-Protocol/Vincent/commit/b3769df))
65
+ - minor changes ([0a70d4a](https://github.com/LIT-Protocol/Vincent/commit/0a70d4a))
66
+ - removed umd build ([6e532fa](https://github.com/LIT-Protocol/Vincent/commit/6e532fa))
67
+
68
+ ### ❤️ Thank You
69
+
70
+ - Ansh Saxena @anshss
71
+ - Anson
72
+ - awisniew207 @awisniew207
73
+ - Daryl Collins
74
+ - FedericoAmura @FedericoAmura
@@ -0,0 +1,115 @@
1
+ # Contributing to Vincent SDK
2
+
3
+ This document provides guidelines for contributing to the Vincent SDK project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent SDK is a TypeScript SDK that exposes useful tools to interact with Vincent systems in web or Node.js environments. It provides client libraries for both frontend applications and backend services.
8
+
9
+ ## Setup
10
+
11
+ 1. Follow the global setup instructions in the repository root [CONTRIBUTING.md](../../CONTRIBUTING.md).
12
+ 2. Install dependencies:
13
+ ```bash
14
+ pnpm install
15
+ ```
16
+
17
+ ## Development Workflow
18
+
19
+ ### Building
20
+
21
+ Build the SDK:
22
+
23
+ ```bash
24
+ pnpm build
25
+ ```
26
+
27
+ ### Documentation
28
+
29
+ Generate TypeDoc documentation:
30
+
31
+ ```bash
32
+ pnpm typedoc
33
+ ```
34
+
35
+ ## Project Structure
36
+
37
+ - `src/`: Source code
38
+ - `index.ts`: Main entry point
39
+ - `app/`: Web utilities to authenticate against Vincent Apps in clients
40
+ - `express-authentication-middleware/`: Express middleware wrapper to properly validate clients JWT server side
41
+ - `jwt/`: Utility functions to work with Vincent JWT between Vincent Apps client and server
42
+ - `tool/`: Utility functions to work with Vincent Tools
43
+
44
+ ## SDK Components
45
+
46
+ ### WebAuthClient
47
+
48
+ The Vincent Web Auth Client provides methods for managing user authentication, JWT tokens, and consent flows in Vincent applications.
49
+
50
+ ### VincentToolClient
51
+
52
+ The Vincent Tool Client uses an ethers signer for your delegatee account to run Vincent Tools on behalf of your app users.
53
+
54
+ ## Coding Standards
55
+
56
+ 1. Use TypeScript for all new code
57
+ 2. Follow the project's existing coding style
58
+ 3. Write clear, descriptive comments and JSDoc for public APIs
59
+ 4. Include appropriate error handling
60
+ 5. Write unit tests for new functionality
61
+ 6. Maintain backward compatibility when possible
62
+
63
+ ## Type Safety
64
+
65
+ - Use proper TypeScript types for all functions and variables
66
+ - Avoid using `any` type; prefer `unknown` when the type is truly unknown
67
+ - Use generics where appropriate to maintain type safety
68
+ - Ensure exported APIs have proper type definitions
69
+
70
+ ## Testing
71
+
72
+ Write unit tests for new functionality:
73
+
74
+ ```bash
75
+ pnpm test
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ - Document all public APIs with JSDoc comments
81
+ - Update README.md when adding new features
82
+ - Generate and review TypeDoc documentation
83
+
84
+ ## Pull Request Process
85
+
86
+ 1. Ensure your code follows the coding standards
87
+ 2. Update documentation if necessary
88
+ 3. Include tests for new features or bug fixes
89
+ 4. Link any related issues in your pull request description
90
+ 5. Add an nx version plan documenting your changes
91
+ 6. Request a review from a maintainer
92
+
93
+ ## For AI Editors and IDEs
94
+
95
+ When working with AI-powered editors like Cursor, GitHub Copilot, or other AI assistants in this project directory, please note:
96
+
97
+ ### Context Priority
98
+
99
+ 1. **Primary Context**: When working within the SDK project directory, AI editors should prioritize this CONTRIBUTING.md file and the project's README.md for specific guidance on the SDK project.
100
+
101
+ 2. **Secondary Context**: The root-level CONTRIBUTING.md and README.md files provide important context about how this project fits into the broader Vincent ecosystem.
102
+
103
+ ### Key Files for SDK Context
104
+
105
+ - `/packages/libs/app-sdk/README.md`: Overview of the SDK project
106
+ - `/packages/libs/app-sdk/CONTRIBUTING.md`: This file, with SDK-specific contribution guidelines
107
+ - `/packages/libs/app-sdk/src/`: Source code for the SDK
108
+
109
+ When working on SDK code, consider these dependencies and consumers for context.
110
+
111
+ ## Additional Resources
112
+
113
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
114
+ - [SDK Documentation](https://sdk-docs.heyvincent.ai/)
115
+ - [TypeScript Documentation](https://www.typescriptlang.org/docs/)