@lit-protocol/vincent-app-sdk 1.0.3-beta.7 → 2.0.1-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.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,186 @@
1
+ ## 2.0.1 (2025-09-03)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated ability-sdk to 2.0.1
6
+ - Updated contracts-sdk to 1.1.0
7
+
8
+ # 2.0.0 (2025-08-05)
9
+
10
+ ### 🚀 Features
11
+
12
+ - Bug fix in app-sdk that kept a policy's allow result from being returned ([11325427](https://github.com/LIT-Protocol/Vincent/commit/11325427))
13
+ - ### Implement supported Vincent Ability API range ([14f0ece1](https://github.com/LIT-Protocol/Vincent/commit/14f0ece1))
14
+
15
+ Added basic Ability API handling to ensure abilities & policies are only used by compatible abilities and policies, and with the correct version of the vincentAbilityClient / app-sdk
16
+ - Added a new jsParam when VincentAbilityClient calls an ability, `vincentAbilityApiVersion`
17
+ - LIT action wrappers for abilities + policies compare `vincentAbilityApiVersion` to match the major semver range the handler was built with from the ability-sdk
18
+ - vincentAbilityHandler() is responsible for passing along the value when it evaluates supported policies
19
+
20
+ ### 🩹 Fixes
21
+
22
+ - ### Fix ability failure response cases ([e2be50d9](https://github.com/LIT-Protocol/Vincent/commit/e2be50d9))
23
+ - Ensures that policy denial disables checking the ability result against its fail schema in the abilityClient, because it will always be undefined :)
24
+ - Ensures that `context` is returned in the response from the abilityClient.execute() method in cases where the ability response was a runtime or schemaValidationError
25
+
26
+ ### ⚠️ Breaking Changes
27
+
28
+ - Add support for CBOR2 encoded policy parameters using the new vincent-contracts-sdk ([868c6c2a](https://github.com/LIT-Protocol/Vincent/commit/868c6c2a))
29
+ - ### Add support for explicit `schemaValidationError` ([337a4bde](https://github.com/LIT-Protocol/Vincent/commit/337a4bde))
30
+ - Previously, a failure to validate either input or results of lifecycle method would result in `result: { zodError }` being returned
31
+ - Now, `result` will be `undefined` and there will be an explicit `schemaValidationError` in the result of the ability / policy
32
+
33
+ ```typescript
34
+ export interface SchemaValidationError {
35
+ zodError: ZodError<unknown>; // The result of `zod.safeParse().error`
36
+ phase: string; // Policies: `precheck`|`evaluate`|`commit` - Abilities: `precheck` | `execute`
37
+ stage: string; // `input` | `output`
38
+ }
39
+ ```
40
+
41
+ - ### `error` is now `runtimeError` and can only be set by `throw ...` ([337a4bde](https://github.com/LIT-Protocol/Vincent/commit/337a4bde))
42
+ - Previously, if you had not defined a `deny` or `fail` schema, you could call `deny()` or `fail()` with a string
43
+ - That string would end up in the ability/policy response as the `error` property instead of `result`
44
+ - This was problematic because there was no consistent way to identify _un-handled_ error vs. _explicitly returned fail/deny results_
45
+ - If you don't define a deny or fail schema, you can no longer call those methods with a string.
46
+ - `error` is now `runtimeError`, and is _only_ set if a lifecycle method `throw`s an Error - in that case it will be the `message` property of the error
47
+ - If you want to be able to return simple errors in your _result_, you can define a simple deny or fail schema like `z.object({ error: z.string() }`
48
+
49
+ - ### Create vincentAbilityClient namespace ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
50
+
51
+ Previously, `getVincentAbilityClient()` and `disconnectVincentAbilityClients()` were exported from the root of the `vincent-app-sdk` package.
52
+ These methods, along with several other methods are now exported from the `@lit-protocol/app-sdk/abilityClient` namespace
53
+
54
+ ```typescript
55
+ import {
56
+ getVincentAbilityClient,
57
+ disconnectVincentAbilityClients,
58
+ isAbilityResponseFailure,
59
+ isAbilityResponseRuntimeFailure,
60
+ isAbilityResponseSchemaValidationFailure,
61
+ isAbilityResponseSuccess,
62
+ } from '@lit-protocol/app-sdk/abilityClient';
63
+ ```
64
+
65
+ - #### Standardized `app` property on on JWT payload to be a number instead of a string. ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
66
+ - #### Renamed `consent page` to `delegation auth page` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
67
+ - #### Move utils exports to `@lit-protocol/vincent-app-sdk/utils` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
68
+ - #### Moved jwt exports to `@lit-protocol/vincent-app-sdk/jwt` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
69
+ - Enhanced typedocs for all methods and removed type aliases for core functions
70
+
71
+ - #### Move `VincentWebAppClient` exports to `@lit-protocol/vincent-app-sdk/webAppClient` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
72
+ - Renamed `VincentWebAppClient` to `WebAuthClient`
73
+ - Renamed `VincentAppClientConfig` to `WebAuthClientConfig`
74
+ - Renamed `RedirectToVincentConsentPageParams` to `RedirectToVincentDelegationPageParams`
75
+ - Renamed `redirectToConsentPage()` to `redirectToDelegationAuthPage()`
76
+ - Renamed `getVincentWebAppClient()` to `getWebAuthClient()`
77
+
78
+ - #### Move express-authentication-middleware exports to `@lit-protocol/vincent-app-sdk/expressMiddleware` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
79
+ - Removed `ExpressAuthHelpers` interface - its types are now directly exported from the `expressMiddleware` package sub-path
80
+
81
+ - #### Moved abilityClient exports to `@lit-protocol/vincent-app-sdk/abilityClient` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
82
+ - ### Update express middleware to support non-app-specific JWTs ([9dd1cd26](https://github.com/LIT-Protocol/Vincent/commit/9dd1cd26))
83
+ - Replaced individual function exports of `authenticatedRequestHandler()` and `getAuthenticateUserExpressHandler()` with a single `createVincentUserMiddleware()` function
84
+
85
+ #### createVincentUserMiddleware({ allowedAudience, userKey, requiredAppId? }) -> { middleware(), handler() }
86
+ - You can now configure the property on `req` where the vincent user JWT data will be placed using `userKey`
87
+ - You can now configure the authentication middleware to throw if `requiredAppId` does not match a specific appId you provide
88
+ - `allowedAudience` behaviour remains unchanged
89
+ - See example usage on the API docs for the package @ http://docs.heyvincent.ai
90
+
91
+ ```
92
+
93
+ ```
94
+
95
+ - ### Support JWTs that are not app-specific ([0553a934](https://github.com/LIT-Protocol/Vincent/commit/0553a934))
96
+
97
+ This release adds support for general authentication JWTs that are not tied to a specific app. This is a breaking change that requires updates to code that uses the JWT validation functions.
98
+
99
+ #### API Changes
100
+ - `verify` and `decode` functions now accept object parameters instead of separate parameters
101
+ - Their return values are strongly typed based on whether `requiredAppId` is provided.
102
+ - They throw if `requiredAppId` is provided but the jwt is either not app-specific or the app id on the token doesn't match the `requiredAppId`
103
+ - `appId` type changed from `string` to `number` in WebAuthClient configuration
104
+ - WebAuthClient now throws an error if the `appId` it was configured with isn't in the JWT it decodes
105
+
106
+ #### New Functions
107
+ - `isGeneralJWT`: Type guard to check if a JWT is Vincent JWT that has no app associated
108
+ - `isAppSpecificJWT`: Type guard to check if a JWT is a vincent JWT that is app-specific
109
+ - `assertIsVincentJWT`: Assertion function to validate if a decoded JWT is a valid Vincent JWT
110
+ - `getAppInfo`: Convenience method that returns the app ID and version from an app-specific JWT's payload
111
+ - `getPKPInfo`: Convenience method that returns PKP information from any Vincent JWT's payload
112
+
113
+ #### New Types
114
+ - `VincentJWT`: Interface for a decoded Vincent JWT without app-specific details (general authentication)
115
+ - `VincentJWTAppSpecific`: Interface for a decoded app-specific Vincent JWT
116
+ - `BaseVincentJWTPayload`: Payload that contains always-present properties on all Vincent JWTs
117
+ - `VincentAppSpecificJWTPayload`: Extends VincentJWTPayload with app-specific information
118
+
119
+ - ## JWT Refactor ([c21bc3c3](https://github.com/LIT-Protocol/Vincent/commit/c21bc3c3))
120
+
121
+ #### Refactored our JWT structure, composition, and verification logic.
122
+ - Removed dependency on `did-jwt`; since we are signing using EIP-191 compliant signatures, the presence of `did:ethr` was misleading.
123
+ - Added support for Delegatee JWTs
124
+
125
+ #### We now support 3 types of JWT:
126
+ - `VincentJWTAppUser`
127
+ - `role` claim in the JWT payload is `app-user`
128
+ - Contains PKP info
129
+ - Is app-specific
130
+ - Is provided to app end-users, so that they can authenticate with services that are provided by individual Vincent Apps
131
+ - `VincentJWTPlatformUser`
132
+ - `role` claim in the JWT payload is `platform-user`
133
+ - Contains PKP info
134
+ - Used to authenticate with Vincent platform services (e.g. the registry backend)
135
+ - Is not app-specific
136
+ - The Vincent dashboard uses these for App owners and Ability & Policy authors
137
+ - `VincentJWTDelegatee`
138
+ - `role` claim in the JWT payload is `app-delegatee`
139
+ - Does not contain PKP info; delegatees are not PKP-backed
140
+ - Is not app-specific
141
+ - Used to authenticate with services that require proof that they are being used by a specific delegatee who has permissions to act on behalf of a delegator (app user) account.
142
+
143
+ ### API Changes
144
+ - Many classes and interfaces were renamed to clearly indicate which type of JWT that they apply to.
145
+ - Added `publicKey` to the `payload` of all JWTs for signature verification convenience
146
+ - `iss` and `sub` are now raw hex-formatted ethers addresses, without `did:ethr` prefixes
147
+ - JWT verification has been converted to be an async process, and explicit verify methods have been defined for each type of JWT
148
+ - `verifyVincentAppUserJWT()`
149
+ - `verifyVincentPlatformJWT()`
150
+ - `verifyVincentDelegateeJWT()`
151
+ - Type-guard functions have also been added to help identify the kind of JWT you are using and provide type-safe references to those JWTs, but for most use-cases you will probably just use the type-specific `verify` methods.
152
+ - `isVincentJWTAppSpecific()`
153
+ - `isVincentPlatformJWT()`
154
+ - `isVincentJWTDelegatee()`
155
+ - `isAnyVincentJWT()`
156
+ - Added accessor helper functions to facilitate easy, type-safe access to properties on supported JWTs
157
+ - `getRole()` - All Vincent JWTs
158
+ - `getPublicKey()` - All Vincent JWTs
159
+ - `getIssuerAddress()` - All Vincent JWTs
160
+ - `getAudience()` - All Vincent JWTs
161
+ - `getSubjectAddress()` - Only for `VincentJWTDelegatee`
162
+ - `getAppInfo()` - Only for `VincentJWTAppUser`
163
+ - `getPKPInfo()` - Only for `VincentJWTAppUser` or `VincentJWTPlatformUser`
164
+ - `getAuthentication()` - Only for `VincentJWTAppUser` or `VincentJWTPlatformUser`
165
+ - `decode` has been renamed to `decodeVincentJWT()`;
166
+ - You probably want to use the type-specific `verify` methods instead of calling decode directly, unless you're absolutely sure that you've already verified the JWT and are positive it hasn't expired!
167
+ - This function returns an `AnyVincentJWT` type which you must narrow using type-guard functions.
168
+
169
+ ### 🧱 Updated Dependencies
170
+
171
+ - Updated ability-sdk to 2.0.0
172
+ - Updated contracts-sdk to 2.0.0
173
+
174
+ ### ❤️ Thank You
175
+
176
+ - Daryl Collins
177
+ - Wyatt Barnes @spacesailor24
178
+
1
179
  ## 1.0.2 (2025-07-08)
2
180
 
3
181
  ### 🩹 Fixes
4
182
 
5
183
  - #### VincentAbilityClient Precheck fixes ([8da32df2](https://github.com/LIT-Protocol/Vincent/commit/8da32df2))
6
-
7
184
  - Fix a case where deny results from `precheck()` were not correctly bubbled to the caller
8
185
  - 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
186
 
package/dist/CHANGELOG.md CHANGED
@@ -1,9 +1,186 @@
1
+ ## 2.0.1 (2025-09-03)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated ability-sdk to 2.0.1
6
+ - Updated contracts-sdk to 1.1.0
7
+
8
+ # 2.0.0 (2025-08-05)
9
+
10
+ ### 🚀 Features
11
+
12
+ - Bug fix in app-sdk that kept a policy's allow result from being returned ([11325427](https://github.com/LIT-Protocol/Vincent/commit/11325427))
13
+ - ### Implement supported Vincent Ability API range ([14f0ece1](https://github.com/LIT-Protocol/Vincent/commit/14f0ece1))
14
+
15
+ Added basic Ability API handling to ensure abilities & policies are only used by compatible abilities and policies, and with the correct version of the vincentAbilityClient / app-sdk
16
+ - Added a new jsParam when VincentAbilityClient calls an ability, `vincentAbilityApiVersion`
17
+ - LIT action wrappers for abilities + policies compare `vincentAbilityApiVersion` to match the major semver range the handler was built with from the ability-sdk
18
+ - vincentAbilityHandler() is responsible for passing along the value when it evaluates supported policies
19
+
20
+ ### 🩹 Fixes
21
+
22
+ - ### Fix ability failure response cases ([e2be50d9](https://github.com/LIT-Protocol/Vincent/commit/e2be50d9))
23
+ - Ensures that policy denial disables checking the ability result against its fail schema in the abilityClient, because it will always be undefined :)
24
+ - Ensures that `context` is returned in the response from the abilityClient.execute() method in cases where the ability response was a runtime or schemaValidationError
25
+
26
+ ### ⚠️ Breaking Changes
27
+
28
+ - Add support for CBOR2 encoded policy parameters using the new vincent-contracts-sdk ([868c6c2a](https://github.com/LIT-Protocol/Vincent/commit/868c6c2a))
29
+ - ### Add support for explicit `schemaValidationError` ([337a4bde](https://github.com/LIT-Protocol/Vincent/commit/337a4bde))
30
+ - Previously, a failure to validate either input or results of lifecycle method would result in `result: { zodError }` being returned
31
+ - Now, `result` will be `undefined` and there will be an explicit `schemaValidationError` in the result of the ability / policy
32
+
33
+ ```typescript
34
+ export interface SchemaValidationError {
35
+ zodError: ZodError<unknown>; // The result of `zod.safeParse().error`
36
+ phase: string; // Policies: `precheck`|`evaluate`|`commit` - Abilities: `precheck` | `execute`
37
+ stage: string; // `input` | `output`
38
+ }
39
+ ```
40
+
41
+ - ### `error` is now `runtimeError` and can only be set by `throw ...` ([337a4bde](https://github.com/LIT-Protocol/Vincent/commit/337a4bde))
42
+ - Previously, if you had not defined a `deny` or `fail` schema, you could call `deny()` or `fail()` with a string
43
+ - That string would end up in the ability/policy response as the `error` property instead of `result`
44
+ - This was problematic because there was no consistent way to identify _un-handled_ error vs. _explicitly returned fail/deny results_
45
+ - If you don't define a deny or fail schema, you can no longer call those methods with a string.
46
+ - `error` is now `runtimeError`, and is _only_ set if a lifecycle method `throw`s an Error - in that case it will be the `message` property of the error
47
+ - If you want to be able to return simple errors in your _result_, you can define a simple deny or fail schema like `z.object({ error: z.string() }`
48
+
49
+ - ### Create vincentAbilityClient namespace ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
50
+
51
+ Previously, `getVincentAbilityClient()` and `disconnectVincentAbilityClients()` were exported from the root of the `vincent-app-sdk` package.
52
+ These methods, along with several other methods are now exported from the `@lit-protocol/app-sdk/abilityClient` namespace
53
+
54
+ ```typescript
55
+ import {
56
+ getVincentAbilityClient,
57
+ disconnectVincentAbilityClients,
58
+ isAbilityResponseFailure,
59
+ isAbilityResponseRuntimeFailure,
60
+ isAbilityResponseSchemaValidationFailure,
61
+ isAbilityResponseSuccess,
62
+ } from '@lit-protocol/app-sdk/abilityClient';
63
+ ```
64
+
65
+ - #### Standardized `app` property on on JWT payload to be a number instead of a string. ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
66
+ - #### Renamed `consent page` to `delegation auth page` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
67
+ - #### Move utils exports to `@lit-protocol/vincent-app-sdk/utils` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
68
+ - #### Moved jwt exports to `@lit-protocol/vincent-app-sdk/jwt` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
69
+ - Enhanced typedocs for all methods and removed type aliases for core functions
70
+
71
+ - #### Move `VincentWebAppClient` exports to `@lit-protocol/vincent-app-sdk/webAppClient` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
72
+ - Renamed `VincentWebAppClient` to `WebAuthClient`
73
+ - Renamed `VincentAppClientConfig` to `WebAuthClientConfig`
74
+ - Renamed `RedirectToVincentConsentPageParams` to `RedirectToVincentDelegationPageParams`
75
+ - Renamed `redirectToConsentPage()` to `redirectToDelegationAuthPage()`
76
+ - Renamed `getVincentWebAppClient()` to `getWebAuthClient()`
77
+
78
+ - #### Move express-authentication-middleware exports to `@lit-protocol/vincent-app-sdk/expressMiddleware` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
79
+ - Removed `ExpressAuthHelpers` interface - its types are now directly exported from the `expressMiddleware` package sub-path
80
+
81
+ - #### Moved abilityClient exports to `@lit-protocol/vincent-app-sdk/abilityClient` ([b94ca569](https://github.com/LIT-Protocol/Vincent/commit/b94ca569))
82
+ - ### Update express middleware to support non-app-specific JWTs ([9dd1cd26](https://github.com/LIT-Protocol/Vincent/commit/9dd1cd26))
83
+ - Replaced individual function exports of `authenticatedRequestHandler()` and `getAuthenticateUserExpressHandler()` with a single `createVincentUserMiddleware()` function
84
+
85
+ #### createVincentUserMiddleware({ allowedAudience, userKey, requiredAppId? }) -> { middleware(), handler() }
86
+ - You can now configure the property on `req` where the vincent user JWT data will be placed using `userKey`
87
+ - You can now configure the authentication middleware to throw if `requiredAppId` does not match a specific appId you provide
88
+ - `allowedAudience` behaviour remains unchanged
89
+ - See example usage on the API docs for the package @ http://docs.heyvincent.ai
90
+
91
+ ```
92
+
93
+ ```
94
+
95
+ - ### Support JWTs that are not app-specific ([0553a934](https://github.com/LIT-Protocol/Vincent/commit/0553a934))
96
+
97
+ This release adds support for general authentication JWTs that are not tied to a specific app. This is a breaking change that requires updates to code that uses the JWT validation functions.
98
+
99
+ #### API Changes
100
+ - `verify` and `decode` functions now accept object parameters instead of separate parameters
101
+ - Their return values are strongly typed based on whether `requiredAppId` is provided.
102
+ - They throw if `requiredAppId` is provided but the jwt is either not app-specific or the app id on the token doesn't match the `requiredAppId`
103
+ - `appId` type changed from `string` to `number` in WebAuthClient configuration
104
+ - WebAuthClient now throws an error if the `appId` it was configured with isn't in the JWT it decodes
105
+
106
+ #### New Functions
107
+ - `isGeneralJWT`: Type guard to check if a JWT is Vincent JWT that has no app associated
108
+ - `isAppSpecificJWT`: Type guard to check if a JWT is a vincent JWT that is app-specific
109
+ - `assertIsVincentJWT`: Assertion function to validate if a decoded JWT is a valid Vincent JWT
110
+ - `getAppInfo`: Convenience method that returns the app ID and version from an app-specific JWT's payload
111
+ - `getPKPInfo`: Convenience method that returns PKP information from any Vincent JWT's payload
112
+
113
+ #### New Types
114
+ - `VincentJWT`: Interface for a decoded Vincent JWT without app-specific details (general authentication)
115
+ - `VincentJWTAppSpecific`: Interface for a decoded app-specific Vincent JWT
116
+ - `BaseVincentJWTPayload`: Payload that contains always-present properties on all Vincent JWTs
117
+ - `VincentAppSpecificJWTPayload`: Extends VincentJWTPayload with app-specific information
118
+
119
+ - ## JWT Refactor ([c21bc3c3](https://github.com/LIT-Protocol/Vincent/commit/c21bc3c3))
120
+
121
+ #### Refactored our JWT structure, composition, and verification logic.
122
+ - Removed dependency on `did-jwt`; since we are signing using EIP-191 compliant signatures, the presence of `did:ethr` was misleading.
123
+ - Added support for Delegatee JWTs
124
+
125
+ #### We now support 3 types of JWT:
126
+ - `VincentJWTAppUser`
127
+ - `role` claim in the JWT payload is `app-user`
128
+ - Contains PKP info
129
+ - Is app-specific
130
+ - Is provided to app end-users, so that they can authenticate with services that are provided by individual Vincent Apps
131
+ - `VincentJWTPlatformUser`
132
+ - `role` claim in the JWT payload is `platform-user`
133
+ - Contains PKP info
134
+ - Used to authenticate with Vincent platform services (e.g. the registry backend)
135
+ - Is not app-specific
136
+ - The Vincent dashboard uses these for App owners and Ability & Policy authors
137
+ - `VincentJWTDelegatee`
138
+ - `role` claim in the JWT payload is `app-delegatee`
139
+ - Does not contain PKP info; delegatees are not PKP-backed
140
+ - Is not app-specific
141
+ - Used to authenticate with services that require proof that they are being used by a specific delegatee who has permissions to act on behalf of a delegator (app user) account.
142
+
143
+ ### API Changes
144
+ - Many classes and interfaces were renamed to clearly indicate which type of JWT that they apply to.
145
+ - Added `publicKey` to the `payload` of all JWTs for signature verification convenience
146
+ - `iss` and `sub` are now raw hex-formatted ethers addresses, without `did:ethr` prefixes
147
+ - JWT verification has been converted to be an async process, and explicit verify methods have been defined for each type of JWT
148
+ - `verifyVincentAppUserJWT()`
149
+ - `verifyVincentPlatformJWT()`
150
+ - `verifyVincentDelegateeJWT()`
151
+ - Type-guard functions have also been added to help identify the kind of JWT you are using and provide type-safe references to those JWTs, but for most use-cases you will probably just use the type-specific `verify` methods.
152
+ - `isVincentJWTAppSpecific()`
153
+ - `isVincentPlatformJWT()`
154
+ - `isVincentJWTDelegatee()`
155
+ - `isAnyVincentJWT()`
156
+ - Added accessor helper functions to facilitate easy, type-safe access to properties on supported JWTs
157
+ - `getRole()` - All Vincent JWTs
158
+ - `getPublicKey()` - All Vincent JWTs
159
+ - `getIssuerAddress()` - All Vincent JWTs
160
+ - `getAudience()` - All Vincent JWTs
161
+ - `getSubjectAddress()` - Only for `VincentJWTDelegatee`
162
+ - `getAppInfo()` - Only for `VincentJWTAppUser`
163
+ - `getPKPInfo()` - Only for `VincentJWTAppUser` or `VincentJWTPlatformUser`
164
+ - `getAuthentication()` - Only for `VincentJWTAppUser` or `VincentJWTPlatformUser`
165
+ - `decode` has been renamed to `decodeVincentJWT()`;
166
+ - You probably want to use the type-specific `verify` methods instead of calling decode directly, unless you're absolutely sure that you've already verified the JWT and are positive it hasn't expired!
167
+ - This function returns an `AnyVincentJWT` type which you must narrow using type-guard functions.
168
+
169
+ ### 🧱 Updated Dependencies
170
+
171
+ - Updated ability-sdk to 2.0.0
172
+ - Updated contracts-sdk to 2.0.0
173
+
174
+ ### ❤️ Thank You
175
+
176
+ - Daryl Collins
177
+ - Wyatt Barnes @spacesailor24
178
+
1
179
  ## 1.0.2 (2025-07-08)
2
180
 
3
181
  ### 🩹 Fixes
4
182
 
5
183
  - #### VincentAbilityClient Precheck fixes ([8da32df2](https://github.com/LIT-Protocol/Vincent/commit/8da32df2))
6
-
7
184
  - Fix a case where deny results from `precheck()` were not correctly bubbled to the caller
8
185
  - 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
186
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lit-protocol/vincent-app-sdk",
3
- "version": "1.0.3-beta.6",
3
+ "version": "2.0.1",
4
4
  "description": "Vincent SDK for browser and backend",
5
5
  "author": "Lit Protocol",
6
6
  "license": "ISC",
@@ -39,6 +39,11 @@
39
39
  "import": "./dist/src/utils/index.js",
40
40
  "require": "./dist/src/utils/index.js",
41
41
  "types": "./dist/src/utils/index.d.ts"
42
+ },
43
+ "./react": {
44
+ "import": "./dist/src/react/index.js",
45
+ "require": "./dist/src/react/index.js",
46
+ "types": "./dist/src/react/index.d.ts"
42
47
  }
43
48
  },
44
49
  "keywords": [
@@ -52,27 +57,37 @@
52
57
  "typecheck": "./scripts/precommit-check.sh"
53
58
  },
54
59
  "dependencies": {
55
- "@lit-protocol/auth-helpers": "^7.0.9",
56
- "@lit-protocol/constants": "^7.0.8",
57
- "@lit-protocol/lit-node-client": "^7.0.8",
58
- "@lit-protocol/vincent-ability-sdk": "0.0.7-mma",
60
+ "@lit-protocol/auth-helpers": "^7.2.3",
61
+ "@lit-protocol/constants": "^7.2.3",
62
+ "@lit-protocol/lit-node-client": "^7.2.3",
63
+ "@lit-protocol/vincent-ability-sdk": "workspace:*",
59
64
  "@lit-protocol/vincent-contracts-sdk": "workspace:*",
60
65
  "@noble/secp256k1": "^2.2.3",
61
66
  "ethers": "5.8.0",
62
67
  "tslib": "^2.8.1",
63
68
  "zod": "3.25.64"
64
69
  },
70
+ "peerDependencies": {
71
+ "react": "^19.0.0"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "react": {
75
+ "optional": true
76
+ }
77
+ },
65
78
  "sideEffects": false,
66
79
  "files": [
67
80
  "dist/**/*",
68
81
  "*.md"
69
82
  ],
70
83
  "devDependencies": {
71
- "@lit-protocol/pkp-ethers": "^7.2.0",
72
- "@lit-protocol/types": "^7.0.8",
84
+ "@lit-protocol/pkp-ethers": "^7.2.3",
85
+ "@lit-protocol/types": "^7.2.3",
73
86
  "@types/express": "^5.0.1",
87
+ "@types/react": "^19.0.10",
74
88
  "chokidar-cli": "^3.0.0",
75
89
  "live-server": "^1.2.2",
90
+ "react": "^19.0.0",
76
91
  "typedoc": "0.27.9",
77
92
  "typedoc-material-theme": "1.3.0",
78
93
  "typedoc-plugin-extras": "^4.0.0",
@@ -11,8 +11,7 @@ export declare function createAppUserJWT(config: CreateAppUserJWTParams): Promis
11
11
  /**
12
12
  * Creates a JWT for an app delegatee (Ethereum account that may act on behalf of a user).
13
13
  *
14
- * If your use-case is to authenticate with a service on behalf of a specific delegator, you must provide a valid `subjectAddress`
15
- * which should be a valid delegator for your Delegatee address.
14
+ * You must provide a valid `subjectAddress`, which must be a valid delegator for your Delegatee address.
16
15
  *
17
16
  * @category API > Create
18
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAG5B,MAAM,UAAU,CAAC;AAgDlB;;;KAGK;AACL,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAYhG;AAED;;KAEK;AACL,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBtF;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ1F"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,2BAA2B,EAI5B,MAAM,UAAU,CAAC;AAuDlB;;;KAGK;AACL,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAYhG;AAED;;KAEK;AACL,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBtF;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ1F"}
@@ -6,6 +6,7 @@ exports.createDelegateeJWT = createDelegateeJWT;
6
6
  const utils_1 = require("ethers/lib/utils");
7
7
  const constants_1 = require("../constants");
8
8
  const base64_1 = require("./utils/base64");
9
+ const ensureHex = (s) => (0, utils_1.hexlify)(s, { allowMissingPrefix: true });
9
10
  function createES256KSigner(wallet) {
10
11
  return async (data) => {
11
12
  const messageBytes = typeof data === 'string' ? (0, utils_1.toUtf8Bytes)(data) : data;
@@ -22,12 +23,14 @@ async function createJWS({ payload, wallet, config }) {
22
23
  const iat = Math.floor(Date.now() / 1000);
23
24
  const exp = (payload.nbf || Math.floor(Date.now() / 1000) + expiresInMinutes * 60);
24
25
  const header = { alg: 'ES256K', typ: 'JWT' };
26
+ const iss = ensureHex(await wallet.getAddress());
27
+ const publicKey = ensureHex(wallet.publicKey);
25
28
  const _payload = {
26
29
  ...payload,
27
30
  iat,
28
31
  exp,
29
- iss: await wallet.getAddress(),
30
- publicKey: wallet.publicKey,
32
+ iss,
33
+ publicKey,
31
34
  aud: audience,
32
35
  role,
33
36
  ...(subjectAddress ? { sub: subjectAddress } : {}),
@@ -77,8 +80,7 @@ async function createAppUserJWT(config) {
77
80
  /**
78
81
  * Creates a JWT for an app delegatee (Ethereum account that may act on behalf of a user).
79
82
  *
80
- * If your use-case is to authenticate with a service on behalf of a specific delegator, you must provide a valid `subjectAddress`
81
- * which should be a valid delegator for your Delegatee address.
83
+ * You must provide a valid `subjectAddress`, which must be a valid delegator for your Delegatee address.
82
84
  *
83
85
  * @category API > Create
84
86
  */
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/jwt/core/create.ts"],"names":[],"mappings":";;AA4DA,sDAYC;AAKD,4CAqBC;AAUD,gDAQC;AApHD,4CAAyE;AAUzE,4CAAuD;AACvD,2CAA6C;AAE7C,SAAS,kBAAkB,CAAC,MAAuB;IACjD,OAAO,KAAK,EAAE,IAAyB,EAAmB,EAAE;QAC1D,MAAM,YAAY,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACzE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACnD,MAAM,EAAE,CA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ACf,OAAO;QACP,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,EAAE;KAC9E,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"verifyES256KSignature.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/verifyES256KSignature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,iBAiClF"}
1
+ {"version":3,"file":"verifyES256KSignature.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/verifyES256KSignature.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,wBAAsB,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,iBA8BlF"}
@@ -15,10 +15,7 @@ async function verifyES256KSignature({ decoded }) {
15
15
  // Extract r and s values from the signature
16
16
  const r = signatureBytes.slice(0, 32);
17
17
  const s = signatureBytes.slice(32, 64);
18
- const publicKeyHex = decoded.payload.publicKey.startsWith('0x')
19
- ? decoded.payload.publicKey
20
- : `0x${decoded.payload.publicKey}`;
21
- const publicKeyBytes = (0, utils_1.arrayify)(publicKeyHex);
18
+ const publicKeyBytes = (0, utils_1.arrayify)(decoded.payload.publicKey, { allowMissingPrefix: true });
22
19
  // PKPEthersWallet.signMessage() adds Ethereum prefix, so we need to add it here too
23
20
  const ethPrefixedMessage = '\x19Ethereum Signed Message:\n' + data.length + data;
24
21
  const messageHashBytes = (0, utils_1.arrayify)(ethers_1.ethers.utils.keccak256((0, utils_1.toUtf8Bytes)(ethPrefixedMessage)));
@@ -1 +1 @@
1
- {"version":3,"file":"verifyES256KSignature.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gB,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAEtD,8CAA8C;QAC9C,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAExF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,EAAE,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,qBAAS,CAAC,iBAAiB,wBAAyB,KAAe,CAAC,OAAO,EAAE,CACjF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -28,7 +28,7 @@ export interface CreateJWSConfig {
28
28
  config: {
29
29
  audience: string | string[];
30
30
  expiresInMinutes: number;
31
- subjectAddress?: string;
31
+ subjectAddress?: `0x${string}`;
32
32
  role: VincentJWTRole;
33
33
  };
34
34
  }
@@ -69,6 +69,14 @@ export interface PKPAuthenticationMethod {
69
69
  type: string;
70
70
  value?: string;
71
71
  }
72
+ /**
73
+ *
74
+ * @category Interfaces
75
+ */
76
+ export interface AppInfo {
77
+ id: number;
78
+ version: number;
79
+ }
72
80
  /** All valid Vincent JWT roles
73
81
  *
74
82
  * @category Interfaces
@@ -98,10 +106,7 @@ export interface VincentJWTPlatformUser extends DecodedJWT {
98
106
  export interface VincentJWTAppUser extends DecodedJWT {
99
107
  payload: VincentPKPPayload & {
100
108
  role: 'app-user';
101
- app: {
102
- id: number;
103
- version: number;
104
- };
109
+ app: AppInfo;
105
110
  };
106
111
  }
107
112
  /**
@@ -139,10 +144,7 @@ export type CreatePlatformUserJWTParams = VincentPKPJWTParams;
139
144
  * @category Interfaces
140
145
  */
141
146
  export interface CreateAppUserJWTParams extends VincentPKPJWTParams {
142
- app: {
143
- id: number;
144
- version: number;
145
- };
147
+ app: AppInfo;
146
148
  }
147
149
  /**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E,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,mBAAoB,SAAQ,aAAa;IACjD,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,SAAS,CAAC;IACnB,cAAc,EAAE,uBAAuB,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE9D;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,mBAAmB;IACjE,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;CAC/B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The `react` module provides React-specific utilities and components for Vincent authentication.
3
+ *
4
+ * This module exports:
5
+ * - {@link JwtProvider}: A context provider that manages JWT authentication state
6
+ * - {@link useJwtContext}: A hook to access the JWT authentication context
7
+ * - {@link useVincentWebAuthClient}: A hook to get a memoized Vincent WebAuth client instance
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * import { JwtProvider, useJwtContext } from '@lit-protocol/vincent-app-sdk/react';
12
+ *
13
+ * function App() {
14
+ * return (
15
+ * <JwtProvider appId="your-vincent-app-id">
16
+ * <YourAuthenticatedComponent />
17
+ * </JwtProvider>
18
+ * );
19
+ * }
20
+ *
21
+ * function YourAuthenticatedComponent() {
22
+ * const { authInfo, loading, loginWithJwt, logOut } = useJwtContext();
23
+ * // ... your component logic
24
+ * }
25
+ * ```
26
+ *
27
+ * @packageDocumentation
28
+ */
29
+ export * from './jwtProvider';
30
+ export * from './useVincentWebAuthClient';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * The `react` module provides React-specific utilities and components for Vincent authentication.
4
+ *
5
+ * This module exports:
6
+ * - {@link JwtProvider}: A context provider that manages JWT authentication state
7
+ * - {@link useJwtContext}: A hook to access the JWT authentication context
8
+ * - {@link useVincentWebAuthClient}: A hook to get a memoized Vincent WebAuth client instance
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { JwtProvider, useJwtContext } from '@lit-protocol/vincent-app-sdk/react';
13
+ *
14
+ * function App() {
15
+ * return (
16
+ * <JwtProvider appId="your-vincent-app-id">
17
+ * <YourAuthenticatedComponent />
18
+ * </JwtProvider>
19
+ * );
20
+ * }
21
+ *
22
+ * function YourAuthenticatedComponent() {
23
+ * const { authInfo, loading, loginWithJwt, logOut } = useJwtContext();
24
+ * // ... your component logic
25
+ * }
26
+ * ```
27
+ *
28
+ * @packageDocumentation
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ const tslib_1 = require("tslib");
32
+ tslib_1.__exportStar(require("./jwtProvider"), exports);
33
+ tslib_1.__exportStar(require("./useVincentWebAuthClient"), exports);
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAEH,wDAA8B;AAC9B,oEAA0C"}
@@ -0,0 +1,137 @@
1
+ import type { JSX, ReactNode } from 'react';
2
+ import React from 'react';
3
+ import type { IRelayPKP } from '@lit-protocol/types';
4
+ import type { AppInfo, PKPAuthenticationMethod } from '../jwt/types';
5
+ /**
6
+ * Interface representing the authenticated user information.
7
+ *
8
+ * Contains details about the application, authentication method, JWT token,
9
+ * and the PKP (Programmable Key Pair) associated with the authenticated user.
10
+ */
11
+ export interface AuthInfo {
12
+ app: AppInfo;
13
+ authentication: PKPAuthenticationMethod;
14
+ jwt: string;
15
+ pkp: IRelayPKP;
16
+ }
17
+ interface JwtContextType {
18
+ authInfo: AuthInfo | null;
19
+ loading: boolean;
20
+ connect: (redirectUri: string) => void;
21
+ loginWithJwt: () => void;
22
+ logOut: () => void;
23
+ }
24
+ export declare const JwtContext: React.Context<JwtContextType>;
25
+ /**
26
+ * React hook to access the JWT authentication context.
27
+ *
28
+ * This hook provides access to authentication state and methods for managing JWT-based
29
+ * authentication in Vincent applications. It must be used within a component that is a
30
+ * descendant of JwtProvider.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import { useJwtContext } from '@lit-protocol/vincent-app-sdk/react';
35
+ *
36
+ * function AuthenticatedComponent() {
37
+ * const { authInfo, loading, loginWithJwt, logOut } = useJwtContext();
38
+ *
39
+ * if (loading) {
40
+ * return <div>Loading authentication...</div>;
41
+ * }
42
+ *
43
+ * if (!authInfo) {
44
+ * return (
45
+ * <button onClick={loginWithJwt}>
46
+ * Login
47
+ * </button>
48
+ * );
49
+ * }
50
+ *
51
+ * return (
52
+ * <div>
53
+ * <p>Logged in with PKP: {authInfo.pkp.ethAddress}</p>
54
+ * <button onClick={logOut}>Logout</button>
55
+ * </div>
56
+ * );
57
+ * }
58
+ * ```
59
+ *
60
+ * @returns The JWT context containing authentication state and methods
61
+ */
62
+ export declare function useJwtContext(): JwtContextType;
63
+ /**
64
+ * Interface for storage providers that can be used with JwtProvider.
65
+ *
66
+ * This allows you to use custom storage solutions (like AsyncStorage in React Native)
67
+ * instead of the default localStorage.
68
+ */
69
+ export interface AsyncStorage {
70
+ getItem: (key: string) => Promise<string | null> | string | null;
71
+ setItem: (key: string, value: string) => Promise<void> | void;
72
+ removeItem: (key: string) => Promise<void> | void;
73
+ }
74
+ interface JwtProviderProps {
75
+ children: ReactNode;
76
+ appId: number;
77
+ storage?: AsyncStorage;
78
+ storageKeyBuilder?: (appId: number) => string;
79
+ }
80
+ /**
81
+ * React component that provides JWT authentication capabilities for Vincent applications.
82
+ *
83
+ * The JwtProvider handles JWT token management, including
84
+ * - Retrieving and validating JWTs from the Vincent consent page
85
+ * - Storing and retrieving JWTs from persistent storage
86
+ * - Providing authentication state and methods to child components
87
+ * - Managing login/logout flows
88
+ *
89
+ * It uses the Context API to make authentication information and methods available
90
+ * throughout your application without prop drilling.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { JwtProvider } from '@lit-protocol/vincent-app-sdk/react';
95
+ *
96
+ * function App() {
97
+ * return (
98
+ * <JwtProvider appId=<YOUR_VINCENT_APP_ID>>
99
+ * <YourApplication />
100
+ * </JwtProvider>
101
+ * );
102
+ * }
103
+ *
104
+ * // In a child component:
105
+ * function LoginButton() {
106
+ * const { authInfo, loading, connect, logOut } = useJwtContext();
107
+ *
108
+ * if (loading) return <div>Loading...</div>;
109
+ *
110
+ * if (authInfo) {
111
+ * return (
112
+ * <div>
113
+ * <p>Logged in as: {authInfo.pkp.ethAddress}</p>
114
+ * <button onClick={logOut}>Log out</button>
115
+ * </div>
116
+ * );
117
+ * }
118
+ *
119
+ * return (
120
+ * <button
121
+ * onClick={() => connect(window.location.href)}
122
+ * >
123
+ * Login with Vincent
124
+ * </button>
125
+ * );
126
+ * }
127
+ * ```
128
+ *
129
+ * @param props - Props for the JwtProvider component
130
+ * @param props.children - Child components that will have access to the JWT context
131
+ * @param props.appId - Your Vincent App Id
132
+ * @param props.storage - Optional custom storage implementation (defaults to localStorage)
133
+ * @param props.storageKeyBuilder - Optional function to customize the storage key for JWT tokens
134
+ */
135
+ export declare const JwtProvider: ({ children, appId, storage, storageKeyBuilder, }: JwtProviderProps) => JSX.Element;
136
+ export {};
137
+ //# sourceMappingURL=jwtProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwtProvider.d.ts","sourceRoot":"","sources":["../../../src/react/jwtProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5C,O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,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,WAAW,GAAI,kDAKzB,gBAAgB,KAAG,GAAG,CAAC,OAoGzB,CAAC"}
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JwtProvider = exports.JwtContext = void 0;
4
+ exports.useJwtContext = useJwtContext;
5
+ const tslib_1 = require("tslib");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const jwt_1 = require("../jwt");
8
+ const useVincentWebAuthClient_1 = require("./useVincentWebAuthClient");
9
+ function jwtContextNotInitialized() {
10
+ throw new Error('JwtContext must be used within an JwtProvider');
11
+ }
12
+ exports.JwtContext = (0, react_1.createContext)({
13
+ authInfo: null,
14
+ loading: false,
15
+ connect: jwtContextNotInitialized,
16
+ loginWithJwt: jwtContextNotInitialized,
17
+ logOut: jwtContextNotInitialized,
18
+ });
19
+ /**
20
+ * React hook to access the JWT authentication context.
21
+ *
22
+ * This hook provides access to authentication state and methods for managing JWT-based
23
+ * authentication in Vincent applications. It must be used within a component that is a
24
+ * descendant of JwtProvider.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { useJwtContext } from '@lit-protocol/vincent-app-sdk/react';
29
+ *
30
+ * function AuthenticatedComponent() {
31
+ * const { authInfo, loading, loginWithJwt, logOut } = useJwtContext();
32
+ *
33
+ * if (loading) {
34
+ * return <div>Loading authentication...</div>;
35
+ * }
36
+ *
37
+ * if (!authInfo) {
38
+ * return (
39
+ * <button onClick={loginWithJwt}>
40
+ * Login
41
+ * </button>
42
+ * );
43
+ * }
44
+ *
45
+ * return (
46
+ * <div>
47
+ * <p>Logged in with PKP: {authInfo.pkp.ethAddress}</p>
48
+ * <button onClick={logOut}>Logout</button>
49
+ * </div>
50
+ * );
51
+ * }
52
+ * ```
53
+ *
54
+ * @returns The JWT context containing authentication state and methods
55
+ */
56
+ function useJwtContext() {
57
+ return (0, react_1.useContext)(exports.JwtContext);
58
+ }
59
+ /**
60
+ * React component that provides JWT authentication capabilities for Vincent applications.
61
+ *
62
+ * The JwtProvider handles JWT token management, including
63
+ * - Retrieving and validating JWTs from the Vincent consent page
64
+ * - Storing and retrieving JWTs from persistent storage
65
+ * - Providing authentication state and methods to child components
66
+ * - Managing login/logout flows
67
+ *
68
+ * It uses the Context API to make authentication information and methods available
69
+ * throughout your application without prop drilling.
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * import { JwtProvider } from '@lit-protocol/vincent-app-sdk/react';
74
+ *
75
+ * function App() {
76
+ * return (
77
+ * <JwtProvider appId=<YOUR_VINCENT_APP_ID>>
78
+ * <YourApplication />
79
+ * </JwtProvider>
80
+ * );
81
+ * }
82
+ *
83
+ * // In a child component:
84
+ * function LoginButton() {
85
+ * const { authInfo, loading, connect, logOut } = useJwtContext();
86
+ *
87
+ * if (loading) return <div>Loading...</div>;
88
+ *
89
+ * if (authInfo) {
90
+ * return (
91
+ * <div>
92
+ * <p>Logged in as: {authInfo.pkp.ethAddress}</p>
93
+ * <button onClick={logOut}>Log out</button>
94
+ * </div>
95
+ * );
96
+ * }
97
+ *
98
+ * return (
99
+ * <button
100
+ * onClick={() => connect(window.location.href)}
101
+ * >
102
+ * Login with Vincent
103
+ * </button>
104
+ * );
105
+ * }
106
+ * ```
107
+ *
108
+ * @param props - Props for the JwtProvider component
109
+ * @param props.children - Child components that will have access to the JWT context
110
+ * @param props.appId - Your Vincent App Id
111
+ * @param props.storage - Optional custom storage implementation (defaults to localStorage)
112
+ * @param props.storageKeyBuilder - Optional function to customize the storage key for JWT tokens
113
+ */
114
+ const JwtProvider = ({ children, appId, storage = localStorage, storageKeyBuilder = (appId) => `vincent-${appId}-jwt`, }) => {
115
+ const appJwtKey = storageKeyBuilder(appId);
116
+ const vincentWebAppClient = (0, useVincentWebAuthClient_1.useVincentWebAuthClient)(appId);
117
+ const [authInfo, setAuthInfo] = (0, react_1.useState)(null);
118
+ const [loading, setLoading] = (0, react_1.useState)(true);
119
+ const logOut = (0, react_1.useCallback)(async () => {
120
+ try {
121
+ setLoading(true);
122
+ await storage.removeItem(appJwtKey);
123
+ setAuthInfo(null);
124
+ }
125
+ catch (error) {
126
+ console.error(`Error logging out. Could not remove your JWT from storage: ${error.message}`);
127
+ }
128
+ finally {
129
+ setLoading(false);
130
+ }
131
+ }, [appJwtKey, storage]);
132
+ const connect = (0, react_1.useCallback)((redirectUri) => {
133
+ // Redirect to Vincent Auth consent page with appId and version
134
+ vincentWebAppClient.redirectToConnectPage({
135
+ // connectPageUrl: `http://localhost:5173/`,
136
+ redirectUri,
137
+ });
138
+ }, [vincentWebAppClient]);
139
+ const getJwt = (0, react_1.useCallback)(async () => {
140
+ if (vincentWebAppClient.uriContainsVincentJWT()) {
141
+ const jwtResult = await vincentWebAppClient.decodeVincentJWTFromUri(window.location.origin);
142
+ if (!jwtResult) {
143
+ return null;
144
+ }
145
+ const { decodedJWT, jwtStr } = jwtResult;
146
+ await storage.setItem(appJwtKey, jwtStr);
147
+ vincentWebAppClient.removeVincentJWTFromURI();
148
+ return { jwtStr, decodedJWT };
149
+ }
150
+ const existingJwtStr = await storage.getItem(appJwtKey);
151
+ if (!existingJwtStr) {
152
+ return null;
153
+ }
154
+ const decodedJWT = await (0, jwt_1.verifyVincentAppUserJWT)({
155
+ expectedAudience: window.location.origin,
156
+ jwt: existingJwtStr,
157
+ requiredAppId: appId,
158
+ });
159
+ return { jwtStr: existingJwtStr, decodedJWT };
160
+ }, [appJwtKey, storage, vincentWebAppClient]);
161
+ const loginWithJwt = (0, react_1.useCallback)(async () => {
162
+ try {
163
+ setLoading(true);
164
+ const jwtResult = await getJwt();
165
+ if (!jwtResult) {
166
+ throw new Error('Could not get JWT');
167
+ }
168
+ const { decodedJWT, jwtStr } = jwtResult;
169
+ setAuthInfo({
170
+ app: decodedJWT.payload.app,
171
+ authentication: decodedJWT.payload.authentication,
172
+ jwt: jwtStr,
173
+ pkp: decodedJWT.payload.pkp,
174
+ });
175
+ }
176
+ catch (error) {
177
+ console.error(`Error logging in with JWT. Need to relogin: ${error.message}`);
178
+ await logOut();
179
+ }
180
+ finally {
181
+ setLoading(false);
182
+ }
183
+ }, [getJwt, logOut]);
184
+ const value = (0, react_1.useMemo)(() => ({
185
+ authInfo,
186
+ connect,
187
+ loading,
188
+ loginWithJwt,
189
+ logOut,
190
+ }), [authInfo, connect, loading, loginWithJwt, logOut]);
191
+ (0, react_1.useEffect)(() => {
192
+ void loginWithJwt();
193
+ }, [loginWithJwt]);
194
+ return react_1.default.createElement(exports.JwtContext.Provider, { value: value }, children);
195
+ };
196
+ exports.JwtProvider = JwtProvider;
197
+ //# sourceMappingURL=jwtProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwtProvider.js","sourceRoot":"","sources":["../../../src/react/jwtProvider.tsx"],"names":[],"mappings":";;;AAiFA,sCAEC;;AAjFD,uDAAoG;AAMpG,gCAAiD;AACjD,uEAAoE;AAuBpE,SAAS,wBAAwB;IAC/B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACnE,CAAC;AAEY,QAAA,UAAU,GAAG,IAAA,qBAAa,EAAiB;IACtD,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,wBAAwB;IACtC,MAAM,EAAE,wBAAwB;CACjC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAA,kBAAU,EAAC,kBAAU,CAAC,CAAC;AAChC,CAAC;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACI,MAAM,WAAW,GAAG,CAAC,EAC1B,QAAQ,EACR,KAAK,EACL,OAAO,GAAG,YAAY,EACtB,iBAAiB,GAAG,CAAC,KAAK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,UAAU,CAAC,OAAO,CAAC,GAAG;aAC5B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+CAAgD,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;YACzF,MAAM,MAAM,EAAE,CAAC;QACjB,CAAC;gBAAS,CAAC;YACT,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAErB,MAAM,KAAK,GAAG,IAAA,eAAO,EACnB,GAAG,EAAE,CAAC,CAAC;QACL,QAAQ;QACR,OAAO;QACP,OAAO;QACP,YAAY;QACZ,MAAM;KACP,CAAC,EACF,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,CACnD,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,KAAK,YAAY,EAAE,CAAC;IACtB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,8BAAC,kBAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAuB,CAAC;AAC7E,CAAC,CAAC;AAzGW,QAAA,WAAW,eAyGtB"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * React hook that provides a memoized VincentWebAppClient instance.
3
+ *
4
+ * This hook creates a VincentWebAppClient instance using the provided App ID and memoizes it
5
+ * to prevent unnecessary re-creation of the client on each render. The client is only
6
+ * re-created when the App ID changes.
7
+ *
8
+ * The VincentWebAppClient provides methods for authentication, JWT handling, and redirecting
9
+ * to consent pages in Vincent applications.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { useVincentWebAuthClient } from '@lit-protocol/vincent-app-sdk/react';
14
+ *
15
+ * function MyComponent() {
16
+ * // Create a memoized Vincent Web App client
17
+ * const vincentClient = useVincentWebAuthClient('my-app-id');
18
+ *
19
+ * // Check if the user is logging in
20
+ * useEffect(() => {
21
+ * if (vincentClient.isLogin()) {
22
+ * const jwtResult = vincentClient.decodeVincentLoginJWT(window.location.origin);
23
+ * // Handle successful login
24
+ * console.log('User logged in with PKP address:', jwtResult.pkpAddress);
25
+ *
26
+ * // Remove JWT from URI to prevent issues with browser history
27
+ * vincentClient.removeLoginJWTFromURI();
28
+ * }
29
+ * }, [vincentClient]);
30
+ *
31
+ * // Function to handle the login button click
32
+ * const handleLogin = () => {
33
+ * vincentClient.redirectToConsentPage({
34
+ * redirectUri: window.location.href,
35
+ * });
36
+ * };
37
+ *
38
+ * return <button onClick={handleLogin}>Login with Vincent</button>;
39
+ * }
40
+ * ```
41
+ *
42
+ * @param appId - The unique identifier for your Vincent application
43
+ * @returns A memoized VincentWebAppClient instance
44
+ */
45
+ export declare const useVincentWebAuthClient: (appId: number) => import("../webAuthClient").WebAuthClient;
46
+ //# sourceMappingURL=useVincentWebAuthClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVincentWebAuthClient.d.ts","sourceRoot":"","sources":["../../../src/react/useVincentWebAuthClient.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,6CAEpD,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useVincentWebAuthClient = void 0;
4
+ const react_1 = require("react");
5
+ const webAuthClient_1 = require("../webAuthClient");
6
+ /**
7
+ * React hook that provides a memoized VincentWebAppClient instance.
8
+ *
9
+ * This hook creates a VincentWebAppClient instance using the provided App ID and memoizes it
10
+ * to prevent unnecessary re-creation of the client on each render. The client is only
11
+ * re-created when the App ID changes.
12
+ *
13
+ * The VincentWebAppClient provides methods for authentication, JWT handling, and redirecting
14
+ * to consent pages in Vincent applications.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { useVincentWebAuthClient } from '@lit-protocol/vincent-app-sdk/react';
19
+ *
20
+ * function MyComponent() {
21
+ * // Create a memoized Vincent Web App client
22
+ * const vincentClient = useVincentWebAuthClient('my-app-id');
23
+ *
24
+ * // Check if the user is logging in
25
+ * useEffect(() => {
26
+ * if (vincentClient.isLogin()) {
27
+ * const jwtResult = vincentClient.decodeVincentLoginJWT(window.location.origin);
28
+ * // Handle successful login
29
+ * console.log('User logged in with PKP address:', jwtResult.pkpAddress);
30
+ *
31
+ * // Remove JWT from URI to prevent issues with browser history
32
+ * vincentClient.removeLoginJWTFromURI();
33
+ * }
34
+ * }, [vincentClient]);
35
+ *
36
+ * // Function to handle the login button click
37
+ * const handleLogin = () => {
38
+ * vincentClient.redirectToConsentPage({
39
+ * redirectUri: window.location.href,
40
+ * });
41
+ * };
42
+ *
43
+ * return <button onClick={handleLogin}>Login with Vincent</button>;
44
+ * }
45
+ * ```
46
+ *
47
+ * @param appId - The unique identifier for your Vincent application
48
+ * @returns A memoized VincentWebAppClient instance
49
+ */
50
+ const useVincentWebAuthClient = (appId) => {
51
+ return (0, react_1.useMemo)(() => (0, webAuthClient_1.getWebAuthClient)({ appId }), [appId]);
52
+ };
53
+ exports.useVincentWebAuthClient = useVincentWebAuthClient;
54
+ //# sourceMappingURL=useVincentWebAuthClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVincentWebAuthClient.js","sourceRoot":"","sources":["../../../src/react/useVincentWebAuthClient.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEhC,oDAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,EAAE;IACvD,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,gCAAgB,EAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lit-protocol/vincent-app-sdk",
3
- "version": "1.0.3-beta.7",
3
+ "version": "2.0.1-mma",
4
4
  "description": "Vincent SDK for browser and backend",
5
5
  "author": "Lit Protocol",
6
6
  "license": "ISC",
@@ -38,6 +38,11 @@
38
38
  "import": "./dist/src/utils/index.js",
39
39
  "require": "./dist/src/utils/index.js",
40
40
  "types": "./dist/src/utils/index.d.ts"
41
+ },
42
+ "./react": {
43
+ "import": "./dist/src/react/index.js",
44
+ "require": "./dist/src/react/index.js",
45
+ "types": "./dist/src/react/index.d.ts"
41
46
  }
42
47
  },
43
48
  "keywords": [
@@ -46,15 +51,23 @@
46
51
  "sdk"
47
52
  ],
48
53
  "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
- "@lit-protocol/vincent-ability-sdk": "0.0.7-mma",
54
+ "@lit-protocol/auth-helpers": "^7.2.3",
55
+ "@lit-protocol/constants": "^7.2.3",
56
+ "@lit-protocol/lit-node-client": "^7.2.3",
53
57
  "@noble/secp256k1": "^2.2.3",
54
58
  "ethers": "5.8.0",
55
59
  "tslib": "^2.8.1",
56
60
  "zod": "3.25.64",
57
- "@lit-protocol/vincent-contracts-sdk": "1.0.0-beta.3"
61
+ "@lit-protocol/vincent-ability-sdk": "2.0.1",
62
+ "@lit-protocol/vincent-contracts-sdk": "1.1.0"
63
+ },
64
+ "peerDependencies": {
65
+ "react": "^19.0.0"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "react": {
69
+ "optional": true
70
+ }
58
71
  },
59
72
  "sideEffects": false,
60
73
  "files": [
@@ -62,11 +75,13 @@
62
75
  "*.md"
63
76
  ],
64
77
  "devDependencies": {
65
- "@lit-protocol/pkp-ethers": "^7.2.0",
66
- "@lit-protocol/types": "^7.0.8",
78
+ "@lit-protocol/pkp-ethers": "^7.2.3",
79
+ "@lit-protocol/types": "^7.2.3",
67
80
  "@types/express": "^5.0.1",
81
+ "@types/react": "^19.0.10",
68
82
  "chokidar-cli": "^3.0.0",
69
83
  "live-server": "^1.2.2",
84
+ "react": "^19.0.0",
70
85
  "typedoc": "0.27.9",
71
86
  "typedoc-material-theme": "1.3.0",
72
87
  "typedoc-plugin-extras": "^4.0.0",