@lit-protocol/vincent-app-sdk 1.0.0-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.
- package/CHANGELOG.md +53 -0
- package/CONTRIBUTING.md +115 -0
- package/README.md +215 -0
- package/dist/CHANGELOG.md +53 -0
- package/dist/CONTRIBUTING.md +115 -0
- package/dist/README.md +215 -0
- package/dist/package.json +54 -0
- package/dist/src/app/app.d.ts +9 -0
- package/dist/src/app/app.d.ts.map +1 -0
- package/dist/src/app/app.js +33 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/constants.d.ts +3 -0
- package/dist/src/app/constants.d.ts.map +1 -0
- package/dist/src/app/constants.js +6 -0
- package/dist/src/app/constants.js.map +1 -0
- package/dist/src/app/index.d.ts +3 -0
- package/dist/src/app/index.d.ts.map +1 -0
- package/dist/src/app/index.js +6 -0
- package/dist/src/app/index.js.map +1 -0
- package/dist/src/app/internal/index.d.ts +3 -0
- package/dist/src/app/internal/index.d.ts.map +1 -0
- package/dist/src/app/internal/index.js +7 -0
- package/dist/src/app/internal/index.js.map +1 -0
- package/dist/src/app/internal/uriHelpers.d.ts +11 -0
- package/dist/src/app/internal/uriHelpers.d.ts.map +1 -0
- package/dist/src/app/internal/uriHelpers.js +32 -0
- package/dist/src/app/internal/uriHelpers.js.map +1 -0
- package/dist/src/app/types.d.ts +119 -0
- package/dist/src/app/types.d.ts.map +1 -0
- package/dist/src/app/types.js +3 -0
- package/dist/src/app/types.js.map +1 -0
- package/dist/src/express-authentication-middleware/express.d.ts +79 -0
- package/dist/src/express-authentication-middleware/express.d.ts.map +1 -0
- package/dist/src/express-authentication-middleware/express.js +137 -0
- package/dist/src/express-authentication-middleware/express.js.map +1 -0
- package/dist/src/express-authentication-middleware/index.d.ts +43 -0
- package/dist/src/express-authentication-middleware/index.d.ts.map +1 -0
- package/dist/src/express-authentication-middleware/index.js +47 -0
- package/dist/src/express-authentication-middleware/index.js.map +1 -0
- package/dist/src/express-authentication-middleware/types.d.ts +22 -0
- package/dist/src/express-authentication-middleware/types.d.ts.map +1 -0
- package/dist/src/express-authentication-middleware/types.js +3 -0
- package/dist/src/express-authentication-middleware/types.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +14 -0
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -0
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js +67 -0
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -0
- package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +7 -0
- package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -0
- package/dist/src/internal/LitNodeClient/getLitNodeClient.js +25 -0
- package/dist/src/internal/LitNodeClient/getLitNodeClient.js.map +1 -0
- package/dist/src/jwt/core/create.d.ts +41 -0
- package/dist/src/jwt/core/create.d.ts.map +1 -0
- package/dist/src/jwt/core/create.js +114 -0
- package/dist/src/jwt/core/create.js.map +1 -0
- package/dist/src/jwt/core/utils/definedObject.d.ts +2 -0
- package/dist/src/jwt/core/utils/definedObject.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/definedObject.js +7 -0
- package/dist/src/jwt/core/utils/definedObject.js.map +1 -0
- package/dist/src/jwt/core/utils/index.d.ts +6 -0
- package/dist/src/jwt/core/utils/index.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/index.js +14 -0
- package/dist/src/jwt/core/utils/index.js.map +1 -0
- package/dist/src/jwt/core/utils/isJWTExpired.d.ts +8 -0
- package/dist/src/jwt/core/utils/isJWTExpired.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/isJWTExpired.js +19 -0
- package/dist/src/jwt/core/utils/isJWTExpired.js.map +1 -0
- package/dist/src/jwt/core/utils/processJWTSignature.d.ts +8 -0
- package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/processJWTSignature.js +21 -0
- package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -0
- package/dist/src/jwt/core/utils/splitJWT.d.ts +11 -0
- package/dist/src/jwt/core/utils/splitJWT.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/splitJWT.js +21 -0
- package/dist/src/jwt/core/utils/splitJWT.js.map +1 -0
- package/dist/src/jwt/core/utils/validateJWTTime.d.ts +12 -0
- package/dist/src/jwt/core/utils/validateJWTTime.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/validateJWTTime.js +24 -0
- package/dist/src/jwt/core/utils/validateJWTTime.js.map +1 -0
- package/dist/src/jwt/core/validate.d.ts +23 -0
- package/dist/src/jwt/core/validate.d.ts.map +1 -0
- package/dist/src/jwt/core/validate.js +96 -0
- package/dist/src/jwt/core/validate.js.map +1 -0
- package/dist/src/jwt/index.d.ts +69 -0
- package/dist/src/jwt/index.d.ts.map +1 -0
- package/dist/src/jwt/index.js +72 -0
- package/dist/src/jwt/index.js.map +1 -0
- package/dist/src/jwt/types.d.ts +68 -0
- package/dist/src/jwt/types.d.ts.map +1 -0
- package/dist/src/jwt/types.js +3 -0
- package/dist/src/jwt/types.js.map +1 -0
- package/dist/src/toolClient/index.d.ts +2 -0
- package/dist/src/toolClient/index.d.ts.map +1 -0
- package/dist/src/toolClient/index.js +6 -0
- package/dist/src/toolClient/index.js.map +1 -0
- package/dist/src/toolClient/resultCreators.d.ts +69 -0
- package/dist/src/toolClient/resultCreators.d.ts.map +1 -0
- package/dist/src/toolClient/resultCreators.js +55 -0
- package/dist/src/toolClient/resultCreators.js.map +1 -0
- package/dist/src/toolClient/typeGuards.d.ts +19 -0
- package/dist/src/toolClient/typeGuards.d.ts.map +1 -0
- package/dist/src/toolClient/typeGuards.js +48 -0
- package/dist/src/toolClient/typeGuards.js.map +1 -0
- package/dist/src/toolClient/types.d.ts +33 -0
- package/dist/src/toolClient/types.d.ts.map +1 -0
- package/dist/src/toolClient/types.js +3 -0
- package/dist/src/toolClient/types.js.map +1 -0
- package/dist/src/toolClient/vincentToolClient.d.ts +15 -0
- package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -0
- package/dist/src/toolClient/vincentToolClient.js +256 -0
- package/dist/src/toolClient/vincentToolClient.js.map +1 -0
- package/dist/src/type-inference-verification/tool-client-inference.d.ts +3 -0
- package/dist/src/type-inference-verification/tool-client-inference.d.ts.map +1 -0
- package/dist/src/type-inference-verification/tool-client-inference.js +214 -0
- package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
## 0.0.7 (2025-05-26)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- improved mcp api doc ([0389014](https://github.com/LIT-Protocol/Vincent/commit/0389014))
|
|
6
|
+
- updated Vincent MCP documentation with its own section ([3457891](https://github.com/LIT-Protocol/Vincent/commit/3457891))
|
|
7
|
+
- add documentation ([f539eb5](https://github.com/LIT-Protocol/Vincent/commit/f539eb5))
|
|
8
|
+
- 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))
|
|
9
|
+
- implementation of the vincent app mcp wrapper ([02dd8ca](https://github.com/LIT-Protocol/Vincent/commit/02dd8ca))
|
|
10
|
+
- add release script to release SDK and its doc to npm and vercel ([eaccd5f](https://github.com/LIT-Protocol/Vincent/commit/eaccd5f))
|
|
11
|
+
- **docs:** change title, downgrade for plugin extras ([cdd62c0](https://github.com/LIT-Protocol/Vincent/commit/cdd62c0))
|
|
12
|
+
- use standard syntax for jwt validation errors and move validation to decoding step ([fefbbc6](https://github.com/LIT-Protocol/Vincent/commit/fefbbc6))
|
|
13
|
+
- deduplicate vincent data in decoded jwt and revert building config changes ([481d131](https://github.com/LIT-Protocol/Vincent/commit/481d131))
|
|
14
|
+
- 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))
|
|
15
|
+
- add authorized app and user info to jwt ([237f70d](https://github.com/LIT-Protocol/Vincent/commit/237f70d))
|
|
16
|
+
- **vincent-app-sdk:** add Express authentication helpers and update docs ([14a04b3](https://github.com/LIT-Protocol/Vincent/commit/14a04b3))
|
|
17
|
+
- **vincent-app-sdk:** Update README.md ([d052e18](https://github.com/LIT-Protocol/Vincent/commit/d052e18))
|
|
18
|
+
- **vincent-app-sdk:** Add sdk-docs TypeDocs to root of repo ([fb15599](https://github.com/LIT-Protocol/Vincent/commit/fb15599))
|
|
19
|
+
- **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))
|
|
20
|
+
- **vincent-app-sdk:** Add `removeLoginJWTFromURI()` method to `VincentWebAppClient` ([17072f4](https://github.com/LIT-Protocol/Vincent/commit/17072f4))
|
|
21
|
+
- **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))
|
|
22
|
+
- **vincent-app-sdk:** Define an internal module for managing a singleton instance of a LitNodeClient ([d297b0c](https://github.com/LIT-Protocol/Vincent/commit/d297b0c))
|
|
23
|
+
- update vincent sdk readme ([090614d](https://github.com/LIT-Protocol/Vincent/commit/090614d))
|
|
24
|
+
- added contracts class ([ef1851e](https://github.com/LIT-Protocol/Vincent/commit/ef1851e))
|
|
25
|
+
|
|
26
|
+
### 🩹 Fixes
|
|
27
|
+
|
|
28
|
+
- ZodSchemmaMap typo ([095f38e](https://github.com/LIT-Protocol/Vincent/commit/095f38e))
|
|
29
|
+
- doc reference ([b1450f8](https://github.com/LIT-Protocol/Vincent/commit/b1450f8))
|
|
30
|
+
- remove unnecessary type annotation ([c71eeac](https://github.com/LIT-Protocol/Vincent/commit/c71eeac))
|
|
31
|
+
- sdk nx project linting tool ([82dd819](https://github.com/LIT-Protocol/Vincent/commit/82dd819))
|
|
32
|
+
- **docs:** rename (remove API) ([a4b8e83](https://github.com/LIT-Protocol/Vincent/commit/a4b8e83))
|
|
33
|
+
- **docs:** formatting fixes, custom css for :::info ([6f2fcef](https://github.com/LIT-Protocol/Vincent/commit/6f2fcef))
|
|
34
|
+
- **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))
|
|
35
|
+
- do not export simple jwt manipulating functions. Consumers should use the sdk directly ([6e46eee](https://github.com/LIT-Protocol/Vincent/commit/6e46eee))
|
|
36
|
+
- **publish:** need to include 'dist' ([ecf38c3](https://github.com/LIT-Protocol/Vincent/commit/ecf38c3))
|
|
37
|
+
- **sdk:** package.json exports ([dd35563](https://github.com/LIT-Protocol/Vincent/commit/dd35563))
|
|
38
|
+
- no need types node ([af98c0e](https://github.com/LIT-Protocol/Vincent/commit/af98c0e))
|
|
39
|
+
- **build:** add missing tsconfig.lib.json ([ce47c23](https://github.com/LIT-Protocol/Vincent/commit/ce47c23))
|
|
40
|
+
- **jest:** enable `passWithNoTests` ([0f4ac57](https://github.com/LIT-Protocol/Vincent/commit/0f4ac57))
|
|
41
|
+
- lint and any ([c4fc2ab](https://github.com/LIT-Protocol/Vincent/commit/c4fc2ab))
|
|
42
|
+
- **deps:** correctly scope dependencies between global & individual packages ([b3fdb8c](https://github.com/LIT-Protocol/Vincent/commit/b3fdb8c))
|
|
43
|
+
- **build:** remove rollup and use default nx settings ([b3769df](https://github.com/LIT-Protocol/Vincent/commit/b3769df))
|
|
44
|
+
- minor changes ([0a70d4a](https://github.com/LIT-Protocol/Vincent/commit/0a70d4a))
|
|
45
|
+
- removed umd build ([6e532fa](https://github.com/LIT-Protocol/Vincent/commit/6e532fa))
|
|
46
|
+
|
|
47
|
+
### ❤️ Thank You
|
|
48
|
+
|
|
49
|
+
- Ansh Saxena @anshss
|
|
50
|
+
- Anson
|
|
51
|
+
- awisniew207 @awisniew207
|
|
52
|
+
- Daryl Collins
|
|
53
|
+
- FedericoAmura @FedericoAmura
|
package/CONTRIBUTING.md
ADDED
|
@@ -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
|
+
### VincentWebAppClient
|
|
47
|
+
|
|
48
|
+
The Vincent Web App 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,215 @@
|
|
|
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
|
+
## VincentWebAppClient
|
|
14
|
+
|
|
15
|
+
The Vincent Web App 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 { getVincentWebAppClient, jwt } from '@lit-protocol/vincent-app-sdk';
|
|
48
|
+
|
|
49
|
+
const { isExpired } = jwt;
|
|
50
|
+
|
|
51
|
+
const vincentAppClient = getVincentWebAppClient({ appId: MY_APP_ID });
|
|
52
|
+
// ... In your app logic:
|
|
53
|
+
if (vincentAppClient.isLogin()) {
|
|
54
|
+
// Handle app logic for the user has just logged in
|
|
55
|
+
const { decoded, jwt } = vincentAppClient.decodeVincentLoginJWT(window.location.origin);
|
|
56
|
+
// Store `jwt` for later usage; the user is now logged in.
|
|
57
|
+
} else {
|
|
58
|
+
// Handle app logic for the user is _already logged in_ (check for stored & unexpired JWT)
|
|
59
|
+
|
|
60
|
+
const jwt = localStorage.getItem('VINCENT_AUTH_JWT');
|
|
61
|
+
if (jwt && isExpired(jwt)) {
|
|
62
|
+
// User must re-log in
|
|
63
|
+
vincentAppClient.redirectToConsentPage({ redirectUri: window.location.href });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!jwt) {
|
|
67
|
+
// Handle app logic for the user is not yet logged in
|
|
68
|
+
vincentAppClient.redirectToConsentPage({ redirectUri: window.location.href });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
# Backend
|
|
74
|
+
|
|
75
|
+
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.
|
|
76
|
+
|
|
77
|
+
## VincentToolClient
|
|
78
|
+
|
|
79
|
+
The Vincent Tool Client uses an ethers signer for your delegatee account to run Vincent Tools on behalf of your app users.
|
|
80
|
+
|
|
81
|
+
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.
|
|
82
|
+
|
|
83
|
+
### Configuration
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
interface VincentToolClientConfig {
|
|
87
|
+
ethersSigner: ethers.Signer; // An ethers v5 compatible signer
|
|
88
|
+
vincentToolCid: string; // The CID of the Vincent Tool to execute
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Methods
|
|
93
|
+
|
|
94
|
+
#### execute(params: VincentToolParams): Promise<ExecuteJsResponse>
|
|
95
|
+
|
|
96
|
+
Executes a Vincent Tool with the provided parameters.
|
|
97
|
+
|
|
98
|
+
- `params`: Record<string, unknown> - Parameters to pass to the Vincent Tool
|
|
99
|
+
- Returns: Promise resolving to an ExecuteJsResponse from the LIT network
|
|
100
|
+
|
|
101
|
+
### Tool execution
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { getVincentToolClient } from '@lit-protocol/vincent-app-sdk';
|
|
105
|
+
// Import the tool you want to execute
|
|
106
|
+
import { bundledVincentTool as erc20BundledTool } from '@lit-protocol/vincent-tool-erc20-approval';
|
|
107
|
+
|
|
108
|
+
// One of delegatee signers from your app's Vincent Dashboard
|
|
109
|
+
const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
|
|
110
|
+
|
|
111
|
+
// Initialize the Vincent Tool Client
|
|
112
|
+
const toolClient = getVincentToolClient({
|
|
113
|
+
ethersSigner: delegateeSigner,
|
|
114
|
+
bundledVincentTool: erc20BundledTool,
|
|
115
|
+
});
|
|
116
|
+
const delegatorPkpEthAddress = '0x09182301238';
|
|
117
|
+
|
|
118
|
+
const toolParams = {
|
|
119
|
+
// Fill with the params your tool needs
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Run precheck to see if tool should be executed
|
|
123
|
+
const precheckResult = await client.precheck(toolParams, {
|
|
124
|
+
delegatorPkpEthAddress,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
if (precheckResult.success === true) {
|
|
128
|
+
// Execute the Vincent Tool
|
|
129
|
+
const executeResult = await client.execute(toolParams, {
|
|
130
|
+
delegatorPkpEthAddress,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// ...tool has executed, you can check `executeResult` for details
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Usage
|
|
138
|
+
|
|
139
|
+
### Authentication
|
|
140
|
+
|
|
141
|
+
A basic Express authentication middleware factory function is provided with the SDK.
|
|
142
|
+
|
|
143
|
+
- Create an express middleware using `getAuthenticateUserExpressHandler()`
|
|
144
|
+
- Once you have added the middleware to your route, use `authenticatedRequestHandler()` to provide
|
|
145
|
+
type-safe access to `req.user` in your downstream RequestHandler functions.
|
|
146
|
+
- When defining your authenticated routes, use the `ExpressAuthHelpers` type to type your functions and function arguments.
|
|
147
|
+
|
|
148
|
+
See getAuthenticateUserExpressHandler() documentation to see the source for the express authentication route handler
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
152
|
+
const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
|
|
153
|
+
|
|
154
|
+
import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
155
|
+
|
|
156
|
+
const { ALLOWED_AUDIENCE } = process.env;
|
|
157
|
+
|
|
158
|
+
const authenticateUserMiddleware = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
|
|
159
|
+
|
|
160
|
+
// Define an authenticated route handler
|
|
161
|
+
const getUserProfile = async (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
|
|
162
|
+
// Access authenticated user information
|
|
163
|
+
const { pkpAddress } = req.user;
|
|
164
|
+
|
|
165
|
+
// Fetch and return user data
|
|
166
|
+
const userData = await userRepository.findByAddress(pkpAddress);
|
|
167
|
+
res.json(userData);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Use in Express route with authentication
|
|
171
|
+
app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## JWT Authentication
|
|
175
|
+
|
|
176
|
+
### Overview
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
180
|
+
### Authentication Flow
|
|
181
|
+
|
|
182
|
+
1. User initiates an action requiring Vincent Tool access
|
|
183
|
+
2. Application redirects to the Vincent consent page using `VincentWebAppClient.redirectToConsentPage()`
|
|
184
|
+
3. User provides consent for the requested tools/policies
|
|
185
|
+
4. User is redirected back to the application with a JWT in the URL
|
|
186
|
+
5. Application validates and stores the JWT using `VincentWebAppClient` methods
|
|
187
|
+
6. JWT is used to authenticate with the app backend
|
|
188
|
+
|
|
189
|
+
### JWT Structure
|
|
190
|
+
|
|
191
|
+
Vincent JWTs contain:
|
|
192
|
+
|
|
193
|
+
- User account identity information (pkpAddress and pkpPublicKey)
|
|
194
|
+
- Expiration timestamp
|
|
195
|
+
- Signature from the Vincent authorization service
|
|
196
|
+
|
|
197
|
+
### Error Handling
|
|
198
|
+
|
|
199
|
+
When JWT validation fails, descriptive error messages are thrown to help with troubleshooting.
|
|
200
|
+
|
|
201
|
+
### Usage Notes
|
|
202
|
+
|
|
203
|
+
- JWTs have an expiration time after which they are no longer valid
|
|
204
|
+
- When a JWT expires, redirect the user to the consent page to obtain a new one using the `VincentWebAppClient`
|
|
205
|
+
|
|
206
|
+
## Release
|
|
207
|
+
|
|
208
|
+
Pre-requisites:
|
|
209
|
+
|
|
210
|
+
- You will need a valid npm account with access to the `@lit-protocol` organization.
|
|
211
|
+
- Run `pnpm vercel login` at sdk root to get a authentication token for vercel
|
|
212
|
+
- 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.
|
|
213
|
+
|
|
214
|
+
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.
|
|
215
|
+
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,53 @@
|
|
|
1
|
+
## 0.0.7 (2025-05-26)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- improved mcp api doc ([0389014](https://github.com/LIT-Protocol/Vincent/commit/0389014))
|
|
6
|
+
- updated Vincent MCP documentation with its own section ([3457891](https://github.com/LIT-Protocol/Vincent/commit/3457891))
|
|
7
|
+
- add documentation ([f539eb5](https://github.com/LIT-Protocol/Vincent/commit/f539eb5))
|
|
8
|
+
- 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))
|
|
9
|
+
- implementation of the vincent app mcp wrapper ([02dd8ca](https://github.com/LIT-Protocol/Vincent/commit/02dd8ca))
|
|
10
|
+
- add release script to release SDK and its doc to npm and vercel ([eaccd5f](https://github.com/LIT-Protocol/Vincent/commit/eaccd5f))
|
|
11
|
+
- **docs:** change title, downgrade for plugin extras ([cdd62c0](https://github.com/LIT-Protocol/Vincent/commit/cdd62c0))
|
|
12
|
+
- use standard syntax for jwt validation errors and move validation to decoding step ([fefbbc6](https://github.com/LIT-Protocol/Vincent/commit/fefbbc6))
|
|
13
|
+
- deduplicate vincent data in decoded jwt and revert building config changes ([481d131](https://github.com/LIT-Protocol/Vincent/commit/481d131))
|
|
14
|
+
- 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))
|
|
15
|
+
- add authorized app and user info to jwt ([237f70d](https://github.com/LIT-Protocol/Vincent/commit/237f70d))
|
|
16
|
+
- **vincent-app-sdk:** add Express authentication helpers and update docs ([14a04b3](https://github.com/LIT-Protocol/Vincent/commit/14a04b3))
|
|
17
|
+
- **vincent-app-sdk:** Update README.md ([d052e18](https://github.com/LIT-Protocol/Vincent/commit/d052e18))
|
|
18
|
+
- **vincent-app-sdk:** Add sdk-docs TypeDocs to root of repo ([fb15599](https://github.com/LIT-Protocol/Vincent/commit/fb15599))
|
|
19
|
+
- **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))
|
|
20
|
+
- **vincent-app-sdk:** Add `removeLoginJWTFromURI()` method to `VincentWebAppClient` ([17072f4](https://github.com/LIT-Protocol/Vincent/commit/17072f4))
|
|
21
|
+
- **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))
|
|
22
|
+
- **vincent-app-sdk:** Define an internal module for managing a singleton instance of a LitNodeClient ([d297b0c](https://github.com/LIT-Protocol/Vincent/commit/d297b0c))
|
|
23
|
+
- update vincent sdk readme ([090614d](https://github.com/LIT-Protocol/Vincent/commit/090614d))
|
|
24
|
+
- added contracts class ([ef1851e](https://github.com/LIT-Protocol/Vincent/commit/ef1851e))
|
|
25
|
+
|
|
26
|
+
### 🩹 Fixes
|
|
27
|
+
|
|
28
|
+
- ZodSchemmaMap typo ([095f38e](https://github.com/LIT-Protocol/Vincent/commit/095f38e))
|
|
29
|
+
- doc reference ([b1450f8](https://github.com/LIT-Protocol/Vincent/commit/b1450f8))
|
|
30
|
+
- remove unnecessary type annotation ([c71eeac](https://github.com/LIT-Protocol/Vincent/commit/c71eeac))
|
|
31
|
+
- sdk nx project linting tool ([82dd819](https://github.com/LIT-Protocol/Vincent/commit/82dd819))
|
|
32
|
+
- **docs:** rename (remove API) ([a4b8e83](https://github.com/LIT-Protocol/Vincent/commit/a4b8e83))
|
|
33
|
+
- **docs:** formatting fixes, custom css for :::info ([6f2fcef](https://github.com/LIT-Protocol/Vincent/commit/6f2fcef))
|
|
34
|
+
- **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))
|
|
35
|
+
- do not export simple jwt manipulating functions. Consumers should use the sdk directly ([6e46eee](https://github.com/LIT-Protocol/Vincent/commit/6e46eee))
|
|
36
|
+
- **publish:** need to include 'dist' ([ecf38c3](https://github.com/LIT-Protocol/Vincent/commit/ecf38c3))
|
|
37
|
+
- **sdk:** package.json exports ([dd35563](https://github.com/LIT-Protocol/Vincent/commit/dd35563))
|
|
38
|
+
- no need types node ([af98c0e](https://github.com/LIT-Protocol/Vincent/commit/af98c0e))
|
|
39
|
+
- **build:** add missing tsconfig.lib.json ([ce47c23](https://github.com/LIT-Protocol/Vincent/commit/ce47c23))
|
|
40
|
+
- **jest:** enable `passWithNoTests` ([0f4ac57](https://github.com/LIT-Protocol/Vincent/commit/0f4ac57))
|
|
41
|
+
- lint and any ([c4fc2ab](https://github.com/LIT-Protocol/Vincent/commit/c4fc2ab))
|
|
42
|
+
- **deps:** correctly scope dependencies between global & individual packages ([b3fdb8c](https://github.com/LIT-Protocol/Vincent/commit/b3fdb8c))
|
|
43
|
+
- **build:** remove rollup and use default nx settings ([b3769df](https://github.com/LIT-Protocol/Vincent/commit/b3769df))
|
|
44
|
+
- minor changes ([0a70d4a](https://github.com/LIT-Protocol/Vincent/commit/0a70d4a))
|
|
45
|
+
- removed umd build ([6e532fa](https://github.com/LIT-Protocol/Vincent/commit/6e532fa))
|
|
46
|
+
|
|
47
|
+
### ❤️ Thank You
|
|
48
|
+
|
|
49
|
+
- Ansh Saxena @anshss
|
|
50
|
+
- Anson
|
|
51
|
+
- awisniew207 @awisniew207
|
|
52
|
+
- Daryl Collins
|
|
53
|
+
- 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
|
+
### VincentWebAppClient
|
|
47
|
+
|
|
48
|
+
The Vincent Web App 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/)
|