@lit-protocol/vincent-app-sdk 1.0.1 → 1.0.3-beta.0
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 +21 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +12 -11
- package/dist/CHANGELOG.md +21 -0
- package/dist/CONTRIBUTING.md +2 -2
- package/dist/README.md +12 -11
- package/dist/package.json +32 -3
- package/dist/src/expressMiddleware/express.d.ts +63 -0
- package/dist/src/expressMiddleware/express.d.ts.map +1 -0
- package/dist/src/expressMiddleware/express.js +125 -0
- package/dist/src/expressMiddleware/express.js.map +1 -0
- package/dist/src/expressMiddleware/index.d.ts +14 -0
- package/dist/src/expressMiddleware/index.d.ts.map +1 -0
- package/dist/src/expressMiddleware/index.js +17 -0
- package/dist/src/expressMiddleware/index.js.map +1 -0
- package/dist/src/expressMiddleware/types.d.ts +31 -0
- package/dist/src/expressMiddleware/types.d.ts.map +1 -0
- package/dist/src/expressMiddleware/types.js.map +1 -0
- package/dist/src/index.d.ts +1 -17
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -16
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts +1 -1
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.d.ts.map +1 -1
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js +3 -2
- package/dist/src/internal/LitNodeClient/LitNodeClientInstance.js.map +1 -1
- package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts +2 -2
- package/dist/src/internal/LitNodeClient/getLitNodeClient.d.ts.map +1 -1
- package/dist/src/jwt/accessors.d.ts +8 -0
- package/dist/src/jwt/accessors.d.ts.map +1 -0
- package/dist/src/jwt/accessors.js +15 -0
- package/dist/src/jwt/accessors.js.map +1 -0
- package/dist/src/jwt/core/create.d.ts +2 -19
- package/dist/src/jwt/core/create.d.ts.map +1 -1
- package/dist/src/jwt/core/create.js +9 -28
- package/dist/src/jwt/core/create.js.map +1 -1
- package/dist/src/jwt/core/isExpired.d.ts +9 -0
- package/dist/src/jwt/core/isExpired.d.ts.map +1 -0
- package/dist/src/jwt/core/{utils/isJWTExpired.js → isExpired.js} +4 -3
- package/dist/src/jwt/core/isExpired.js.map +1 -0
- package/dist/src/jwt/core/utils/base64.d.ts +14 -0
- package/dist/src/jwt/core/utils/base64.d.ts.map +1 -0
- package/dist/src/jwt/core/utils/base64.js +54 -0
- package/dist/src/jwt/core/utils/base64.js.map +1 -0
- package/dist/src/jwt/core/utils/index.d.ts +0 -1
- package/dist/src/jwt/core/utils/index.d.ts.map +1 -1
- package/dist/src/jwt/core/utils/index.js +1 -3
- package/dist/src/jwt/core/utils/index.js.map +1 -1
- package/dist/src/jwt/core/utils/processJWTSignature.d.ts.map +1 -1
- package/dist/src/jwt/core/utils/processJWTSignature.js +2 -9
- package/dist/src/jwt/core/utils/processJWTSignature.js.map +1 -1
- package/dist/src/jwt/core/validate.d.ts +28 -22
- package/dist/src/jwt/core/validate.d.ts.map +1 -1
- package/dist/src/jwt/core/validate.js +82 -35
- package/dist/src/jwt/core/validate.js.map +1 -1
- package/dist/src/jwt/index.d.ts +15 -63
- package/dist/src/jwt/index.d.ts.map +1 -1
- package/dist/src/jwt/index.js +24 -64
- package/dist/src/jwt/index.js.map +1 -1
- package/dist/src/jwt/typeGuards.d.ts +14 -0
- package/dist/src/jwt/typeGuards.d.ts.map +1 -0
- package/dist/src/jwt/typeGuards.js +32 -0
- package/dist/src/jwt/typeGuards.js.map +1 -0
- package/dist/src/jwt/types.d.ts +32 -22
- package/dist/src/jwt/types.d.ts.map +1 -1
- package/dist/src/toolClient/constants.d.ts +2 -0
- package/dist/src/toolClient/constants.d.ts.map +1 -0
- package/dist/src/toolClient/constants.js +5 -0
- package/dist/src/toolClient/constants.js.map +1 -0
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts +8 -0
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts.map +1 -0
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js +33 -0
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js.map +1 -0
- package/dist/src/toolClient/{resultCreators.d.ts → execute/resultCreators.d.ts} +22 -20
- package/dist/src/toolClient/execute/resultCreators.d.ts.map +1 -0
- package/dist/src/toolClient/{resultCreators.js → execute/resultCreators.js} +14 -12
- package/dist/src/toolClient/execute/resultCreators.js.map +1 -0
- package/dist/src/toolClient/execute/types.d.ts +38 -0
- package/dist/src/toolClient/execute/types.d.ts.map +1 -0
- package/dist/src/toolClient/execute/types.js +4 -0
- package/dist/src/toolClient/execute/types.js.map +1 -0
- package/dist/src/toolClient/index.d.ts +17 -1
- package/dist/src/toolClient/index.d.ts.map +1 -1
- package/dist/src/toolClient/index.js +21 -1
- package/dist/src/toolClient/index.js.map +1 -1
- package/dist/src/toolClient/precheck/resultCreators.d.ts +71 -0
- package/dist/src/toolClient/precheck/resultCreators.d.ts.map +1 -0
- package/dist/src/toolClient/precheck/resultCreators.js +57 -0
- package/dist/src/toolClient/precheck/resultCreators.js.map +1 -0
- package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts +14 -0
- package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts.map +1 -0
- package/dist/src/toolClient/precheck/runPolicyPrechecks.js +97 -0
- package/dist/src/toolClient/precheck/runPolicyPrechecks.js.map +1 -0
- package/dist/src/toolClient/precheck/types.d.ts +82 -0
- package/dist/src/toolClient/precheck/types.d.ts.map +1 -0
- package/dist/src/toolClient/precheck/types.js +4 -0
- package/dist/src/toolClient/precheck/types.js.map +1 -0
- package/dist/src/toolClient/typeGuards.d.ts +26 -17
- package/dist/src/toolClient/typeGuards.d.ts.map +1 -1
- package/dist/src/toolClient/typeGuards.js +32 -13
- package/dist/src/toolClient/typeGuards.js.map +1 -1
- package/dist/src/toolClient/types.d.ts +5 -35
- package/dist/src/toolClient/types.d.ts.map +1 -1
- package/dist/src/toolClient/types.js +1 -0
- package/dist/src/toolClient/types.js.map +1 -1
- package/dist/src/toolClient/vincentToolClient.d.ts +54 -6
- package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -1
- package/dist/src/toolClient/vincentToolClient.js +132 -138
- package/dist/src/toolClient/vincentToolClient.js.map +1 -1
- package/dist/src/type-inference-verification/tool-client-inference.d.ts.map +1 -1
- package/dist/src/type-inference-verification/tool-client-inference.js +11 -6
- package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -1
- package/dist/src/utils/delegation.d.ts +7 -0
- package/dist/src/utils/delegation.d.ts.map +1 -0
- package/dist/src/utils/delegation.js +18 -0
- package/dist/src/utils/delegation.js.map +1 -0
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +6 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/typedocRoot.d.ts +7 -0
- package/dist/src/utils/typedocRoot.d.ts.map +1 -0
- package/dist/src/utils/typedocRoot.js +13 -0
- package/dist/src/utils/typedocRoot.js.map +1 -0
- package/dist/src/utils/types.d.ts +15 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/{app → utils}/types.js.map +1 -1
- package/dist/src/webAuthClient/app.d.ts +7 -0
- package/dist/src/webAuthClient/app.d.ts.map +1 -0
- package/dist/src/webAuthClient/app.js +39 -0
- package/dist/src/webAuthClient/app.js.map +1 -0
- package/dist/src/webAuthClient/constants.d.ts.map +1 -0
- package/dist/src/webAuthClient/constants.js.map +1 -0
- package/dist/src/webAuthClient/index.d.ts +13 -0
- package/dist/src/webAuthClient/index.d.ts.map +1 -0
- package/dist/src/webAuthClient/index.js +15 -0
- package/dist/src/webAuthClient/index.js.map +1 -0
- package/dist/src/webAuthClient/internal/index.d.ts.map +1 -0
- package/dist/src/webAuthClient/internal/index.js.map +1 -0
- package/dist/src/webAuthClient/internal/uriHelpers.d.ts +15 -0
- package/dist/src/webAuthClient/internal/uriHelpers.d.ts.map +1 -0
- package/dist/src/{app → webAuthClient}/internal/uriHelpers.js +12 -6
- package/dist/src/webAuthClient/internal/uriHelpers.js.map +1 -0
- package/dist/src/{app → webAuthClient}/types.d.ts +33 -41
- package/dist/src/webAuthClient/types.d.ts.map +1 -0
- package/dist/src/{types.js.map → webAuthClient/types.js.map} +1 -1
- package/package.json +31 -4
- package/dist/src/app/app.d.ts +0 -9
- package/dist/src/app/app.d.ts.map +0 -1
- package/dist/src/app/app.js +0 -33
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/constants.d.ts.map +0 -1
- package/dist/src/app/constants.js.map +0 -1
- package/dist/src/app/index.d.ts +0 -3
- package/dist/src/app/index.d.ts.map +0 -1
- package/dist/src/app/index.js +0 -6
- package/dist/src/app/index.js.map +0 -1
- package/dist/src/app/internal/index.d.ts.map +0 -1
- package/dist/src/app/internal/index.js.map +0 -1
- package/dist/src/app/internal/uriHelpers.d.ts +0 -11
- package/dist/src/app/internal/uriHelpers.d.ts.map +0 -1
- package/dist/src/app/internal/uriHelpers.js.map +0 -1
- package/dist/src/app/types.d.ts.map +0 -1
- package/dist/src/express-authentication-middleware/express.d.ts +0 -79
- package/dist/src/express-authentication-middleware/express.d.ts.map +0 -1
- package/dist/src/express-authentication-middleware/express.js +0 -137
- package/dist/src/express-authentication-middleware/express.js.map +0 -1
- package/dist/src/express-authentication-middleware/index.d.ts +0 -43
- package/dist/src/express-authentication-middleware/index.d.ts.map +0 -1
- package/dist/src/express-authentication-middleware/index.js +0 -47
- package/dist/src/express-authentication-middleware/index.js.map +0 -1
- package/dist/src/express-authentication-middleware/types.d.ts +0 -25
- package/dist/src/express-authentication-middleware/types.d.ts.map +0 -1
- package/dist/src/express-authentication-middleware/types.js.map +0 -1
- package/dist/src/jwt/core/utils/isJWTExpired.d.ts +0 -8
- package/dist/src/jwt/core/utils/isJWTExpired.d.ts.map +0 -1
- package/dist/src/jwt/core/utils/isJWTExpired.js.map +0 -1
- package/dist/src/toolClient/resultCreators.d.ts.map +0 -1
- package/dist/src/toolClient/resultCreators.js.map +0 -1
- package/dist/src/types.d.ts +0 -5
- package/dist/src/types.d.ts.map +0 -1
- /package/dist/src/{app → expressMiddleware}/types.js +0 -0
- /package/dist/src/{express-authentication-middleware → utils}/types.js +0 -0
- /package/dist/src/{app → webAuthClient}/constants.d.ts +0 -0
- /package/dist/src/{app → webAuthClient}/constants.js +0 -0
- /package/dist/src/{app → webAuthClient}/internal/index.d.ts +0 -0
- /package/dist/src/{app → webAuthClient}/internal/index.js +0 -0
- /package/dist/src/{types.js → webAuthClient/types.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/jwt/core/validate.ts"],"names":[],"mappings":";;AAyEA,wBAwEC;AA+DD,wBA2BC;;AA3OD,oEAA8C;AAC9C,wDAAkC;AAClC,qCAAoC;AACpC,mCAAgC;AAChC,4CAAyD;AAIzD,8CAAqE;AACrE,2CAAwC;AACxC,mCAAyE;AA+BzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,SAAgB,MAAM,CAAC,EACrB,GAAG,EACH,gBAAgB,EAChB,aAAa,GAKd;IACC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAE1C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,kDAAkD,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,qB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AAI,KAAK,CACb,GAAG,mBAAS,CAAC,WAAW,yDAAyD,aAAa,SAAS,GAAG,CAAC,EAAE,GAAG,CACjH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/src/jwt/index.d.ts
CHANGED
|
@@ -1,69 +1,21 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The `jwt` module provides helper methods that allow you to decode and validate Vincent-specific JWTs.
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @inline
|
|
6
|
-
* @category API Methods
|
|
7
|
-
*/
|
|
8
|
-
import { createPKPSignedJWT } from './core/create';
|
|
9
|
-
import { decodeJWT, verifyJWT } from './core/validate';
|
|
10
|
-
import { isJWTExpired } from './core/utils';
|
|
11
|
-
/** @function
|
|
12
|
-
* @hidden
|
|
13
|
-
* */
|
|
14
|
-
export declare const create: typeof createPKPSignedJWT;
|
|
15
|
-
/** Decodes a Vincent JWT in string form and returns an {@link VincentJWT} decoded object for your use
|
|
16
|
-
*
|
|
17
|
-
* @function
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* try {
|
|
21
|
-
* const decodedVincentJWT = decode(jwt);
|
|
22
|
-
* } catch(e) {
|
|
23
|
-
* // Handle malformed JWT string case
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* // You still need to verify the JWT!
|
|
27
|
-
* ```
|
|
28
|
-
* */
|
|
29
|
-
export declare const decode: typeof decodeJWT;
|
|
30
|
-
/**
|
|
31
|
-
* @inline
|
|
32
|
-
* @expand
|
|
33
|
-
* @function
|
|
3
|
+
* Vincent JWTs are composed using the `did-jwt` library, but have a custom `alg` of `ES256K`, and are signed using
|
|
4
|
+
* PKP ethereum keys.
|
|
34
5
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* try {
|
|
38
|
-
* const decodedAndVerifiedVincentJWT = verify(jwt, 'https://myapp.com');
|
|
39
|
-
* } catch(e) {
|
|
40
|
-
* // Handle invalid/expired JWT casew
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
* */
|
|
44
|
-
export declare const verify: typeof verifyJWT;
|
|
45
|
-
/**
|
|
46
|
-
* When a JWT is expired, you need to use {@link VincentWebAppClient.redirectToConsentPage} to get a new JWT
|
|
47
|
-
* @inline
|
|
48
|
-
* @expand
|
|
49
|
-
* @function
|
|
6
|
+
* Vincent JWTs are issued by the Vincent Dashboard when a user provides delegation permission for your app to their agent PKP.
|
|
7
|
+
* They are passed to your web app using a redirectUri which you configure on your app.
|
|
50
8
|
*
|
|
51
|
-
* @
|
|
52
|
-
*
|
|
53
|
-
* import { jwt } from '@lit-protocol/vincent-app-sdk';
|
|
9
|
+
* The methods exported by the `jwt` module are low-level - you probably will just want to use {@link webAuthClient.getWebAuthClient | getWebAuthClient} to get
|
|
10
|
+
* a {@link webAuthClient.WebAuthClient | WebAuthClient} which handles the redirect process, parsing the JWT from the URL, and verifying it for you.
|
|
54
11
|
*
|
|
55
|
-
*
|
|
12
|
+
* @packageDocumentation
|
|
56
13
|
*
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* vincentWebAppClient.redirectToConsentPage({redirectUri: window.location.href });
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
* */
|
|
68
|
-
export declare const isExpired: typeof isJWTExpired;
|
|
14
|
+
*/
|
|
15
|
+
export { create } from './core/create';
|
|
16
|
+
export { isExpired } from './core/isExpired';
|
|
17
|
+
export { decode, verify } from './core/validate';
|
|
18
|
+
export { isGeneralJWT, isAppSpecificJWT, assertIsVincentJWT } from './typeGuards';
|
|
19
|
+
export type { JWTConfig, VincentJWT, VincentJWTAppSpecific } from './types';
|
|
20
|
+
export { getAppInfo, getPKPInfo } from './accessors';
|
|
69
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElF,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/src/jwt/index.js
CHANGED
|
@@ -1,72 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/** Helper methods for working with Vincent-issues JWTs.
|
|
3
|
-
*
|
|
4
|
-
* @module jwt
|
|
5
|
-
* @namespace
|
|
6
|
-
* @inline
|
|
7
|
-
* @category API Methods
|
|
8
|
-
*/
|
|
9
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
|
|
12
|
-
const validate_1 = require("./core/validate");
|
|
13
|
-
const utils_1 = require("./core/utils");
|
|
14
|
-
/** @function
|
|
15
|
-
* @hidden
|
|
16
|
-
* */
|
|
17
|
-
exports.create = create_1.createPKPSignedJWT;
|
|
18
|
-
/** Decodes a Vincent JWT in string form and returns an {@link VincentJWT} decoded object for your use
|
|
19
|
-
*
|
|
20
|
-
* @function
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* try {
|
|
24
|
-
* const decodedVincentJWT = decode(jwt);
|
|
25
|
-
* } catch(e) {
|
|
26
|
-
* // Handle malformed JWT string case
|
|
27
|
-
* }
|
|
3
|
+
exports.getPKPInfo = exports.getAppInfo = exports.assertIsVincentJWT = exports.isAppSpecificJWT = exports.isGeneralJWT = exports.verify = exports.decode = exports.isExpired = exports.create = void 0;
|
|
4
|
+
/** The `jwt` module provides helper methods that allow you to decode and validate Vincent-specific JWTs.
|
|
28
5
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* */
|
|
32
|
-
exports.decode = validate_1.decodeJWT;
|
|
33
|
-
/**
|
|
34
|
-
* @inline
|
|
35
|
-
* @expand
|
|
36
|
-
* @function
|
|
6
|
+
* Vincent JWTs are composed using the `did-jwt` library, but have a custom `alg` of `ES256K`, and are signed using
|
|
7
|
+
* PKP ethereum keys.
|
|
37
8
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* try {
|
|
41
|
-
* const decodedAndVerifiedVincentJWT = verify(jwt, 'https://myapp.com');
|
|
42
|
-
* } catch(e) {
|
|
43
|
-
* // Handle invalid/expired JWT casew
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
* */
|
|
47
|
-
exports.verify = validate_1.verifyJWT;
|
|
48
|
-
/**
|
|
49
|
-
* When a JWT is expired, you need to use {@link VincentWebAppClient.redirectToConsentPage} to get a new JWT
|
|
50
|
-
* @inline
|
|
51
|
-
* @expand
|
|
52
|
-
* @function
|
|
9
|
+
* Vincent JWTs are issued by the Vincent Dashboard when a user provides delegation permission for your app to their agent PKP.
|
|
10
|
+
* They are passed to your web app using a redirectUri which you configure on your app.
|
|
53
11
|
*
|
|
54
|
-
* @
|
|
55
|
-
*
|
|
56
|
-
* import { jwt } from '@lit-protocol/vincent-app-sdk';
|
|
12
|
+
* The methods exported by the `jwt` module are low-level - you probably will just want to use {@link webAuthClient.getWebAuthClient | getWebAuthClient} to get
|
|
13
|
+
* a {@link webAuthClient.WebAuthClient | WebAuthClient} which handles the redirect process, parsing the JWT from the URL, and verifying it for you.
|
|
57
14
|
*
|
|
58
|
-
*
|
|
15
|
+
* @packageDocumentation
|
|
59
16
|
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
exports
|
|
17
|
+
*/
|
|
18
|
+
var create_1 = require("./core/create");
|
|
19
|
+
Object.defineProperty(exports, "create", { enumerable: true, get: function () { return create_1.create; } });
|
|
20
|
+
var isExpired_1 = require("./core/isExpired");
|
|
21
|
+
Object.defineProperty(exports, "isExpired", { enumerable: true, get: function () { return isExpired_1.isExpired; } });
|
|
22
|
+
var validate_1 = require("./core/validate");
|
|
23
|
+
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return validate_1.decode; } });
|
|
24
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return validate_1.verify; } });
|
|
25
|
+
var typeGuards_1 = require("./typeGuards");
|
|
26
|
+
Object.defineProperty(exports, "isGeneralJWT", { enumerable: true, get: function () { return typeGuards_1.isGeneralJWT; } });
|
|
27
|
+
Object.defineProperty(exports, "isAppSpecificJWT", { enumerable: true, get: function () { return typeGuards_1.isAppSpecificJWT; } });
|
|
28
|
+
Object.defineProperty(exports, "assertIsVincentJWT", { enumerable: true, get: function () { return typeGuards_1.assertIsVincentJWT; } });
|
|
29
|
+
var accessors_1 = require("./accessors");
|
|
30
|
+
Object.defineProperty(exports, "getAppInfo", { enumerable: true, get: function () { return accessors_1.getAppInfo; } });
|
|
31
|
+
Object.defineProperty(exports, "getPKPInfo", { enumerable: true, get: function () { return accessors_1.getPKPInfo; } });
|
|
72
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/jwt/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,wCAAuC;AAA9B,gGAAA,MAAM,OAAA;AACf,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,4CAAiD;AAAxC,kGAAA,MAAM,OAAA;AAAE,kGAAA,MAAM,OAAA;AACvB,2CAAkF;AAAzE,0GAAA,YAAY,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAG3D,yCAAqD;AAA5C,uGAAA,UAAU,OAAA;AAAE,uGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JWTDecoded, VincentJWT, VincentJWTAppSpecific } from './types';
|
|
2
|
+
/** Use this typeguard function to identify if the JWT is appId specific and make subsequent type-safe
|
|
3
|
+
* references into the payload of the JWT
|
|
4
|
+
*/
|
|
5
|
+
export declare function isAppSpecificJWT(decodedJWT: VincentJWT): decodedJWT is VincentJWTAppSpecific;
|
|
6
|
+
/** Use this typeguard function to identify if the JWT is a general authentication JWT that has no specific app target */
|
|
7
|
+
export declare function isGeneralJWT(decodedJWT: VincentJWT): decodedJWT is VincentJWT;
|
|
8
|
+
/** This assert function is used internally to throw if decoding a JWT that is expected to be a VincentJWT gives a malformed response.
|
|
9
|
+
* You probably don't need it -- use `decode()` and `verify()`
|
|
10
|
+
*
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertIsVincentJWT(decodedJWT: JWTDecoded): asserts decodedJWT is VincentJWT | VincentJWTAppSpecific;
|
|
14
|
+
//# sourceMappingURL=typeGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/jwt/typeGuards.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI7E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,qBAAqB,CAE5F;AAED,yHAAyH;AACzH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,UAAU,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,UAAU,IAAI,UAAU,GAAG,qBAAqB,CAU1D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAppSpecificJWT = isAppSpecificJWT;
|
|
4
|
+
exports.isGeneralJWT = isGeneralJWT;
|
|
5
|
+
exports.assertIsVincentJWT = assertIsVincentJWT;
|
|
6
|
+
const did_jwt_1 = require("did-jwt");
|
|
7
|
+
const index_1 = require("./core/utils/index");
|
|
8
|
+
/** Use this typeguard function to identify if the JWT is appId specific and make subsequent type-safe
|
|
9
|
+
* references into the payload of the JWT
|
|
10
|
+
*/
|
|
11
|
+
function isAppSpecificJWT(decodedJWT) {
|
|
12
|
+
return decodedJWT.payload.app && decodedJWT.payload.app.id;
|
|
13
|
+
}
|
|
14
|
+
/** Use this typeguard function to identify if the JWT is a general authentication JWT that has no specific app target */
|
|
15
|
+
function isGeneralJWT(decodedJWT) {
|
|
16
|
+
return !isAppSpecificJWT(decodedJWT);
|
|
17
|
+
}
|
|
18
|
+
/** This assert function is used internally to throw if decoding a JWT that is expected to be a VincentJWT gives a malformed response.
|
|
19
|
+
* You probably don't need it -- use `decode()` and `verify()`
|
|
20
|
+
*
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
23
|
+
function assertIsVincentJWT(decodedJWT) {
|
|
24
|
+
const { authentication, pkp } = decodedJWT.payload;
|
|
25
|
+
if (!(0, index_1.isDefinedObject)(authentication)) {
|
|
26
|
+
throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "authentication" field in JWT payload.`);
|
|
27
|
+
}
|
|
28
|
+
if (!(0, index_1.isDefinedObject)(pkp)) {
|
|
29
|
+
throw new Error(`${did_jwt_1.JWT_ERROR.INVALID_JWT}: Missing "pkp" field in JWT payload.`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=typeGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/jwt/typeGuards.ts"],"names":[],"mappings":";;AASA,4CAEC;AAGD,oCAEC;AAOD,gDAYC;AAnCD,qCAAoC;AAIpC,8CAAqD;AAErD;;GAEG;AACH,SAAgB,gBAAgB,CAAC,UAAsB;IACrD,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED,yHAAyH;AACzH,SAAgB,YAAY,CAAC,UAAsB;IACjD,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,UAAsB;IAEtB,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC;IAEnD,IAAI,CAAC,IAAA,uBAAe,EAAC,cAAc,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,kDAAkD,CAAC,CAAC;IAC9F,CAAC;IAED,IAAI,CAAC,IAAA,uBAAe,EAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAS,CAAC,WAAW,uCAAuC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC"}
|
package/dist/src/jwt/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { JWTHeader, JWTPayload } from 'did-jwt';
|
|
1
2
|
import type { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
|
|
2
3
|
import type { IRelayPKP } from '@lit-protocol/types';
|
|
3
|
-
|
|
4
|
-
interface JWTDecoded {
|
|
4
|
+
export interface JWTDecoded {
|
|
5
5
|
header: JWTHeader;
|
|
6
6
|
payload: JWTPayload;
|
|
7
7
|
signature: string;
|
|
@@ -9,15 +9,18 @@ interface JWTDecoded {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Configuration interface for creating a JWT (JSON Web Token) signed by a PKP wallet.
|
|
12
|
-
* Vincent App developers will likely never need this function, as the provider of the JWT is the Vincent
|
|
12
|
+
* Vincent App developers will likely never need this function, as the provider of the JWT is the Vincent delegation auth page frontend
|
|
13
13
|
*
|
|
14
14
|
* @interface JWTConfig
|
|
15
15
|
* @hidden
|
|
16
|
-
* @property
|
|
17
|
-
* @property
|
|
18
|
-
* @property
|
|
19
|
-
* @property
|
|
20
|
-
* @property
|
|
16
|
+
* @property pkpWallet - The PKP Ethers wallet instance used for signing the JWT
|
|
17
|
+
* @property pkp - The PKP object
|
|
18
|
+
* @property payload - Custom claims to include in the JWT payload
|
|
19
|
+
* @property expiresInMinutes - Token expiration time in minutes from current time
|
|
20
|
+
* @property [app] - The app / appversion that the JWT is limited to (if it is at all)
|
|
21
|
+
* @property audience - The domain(s) this token is intended for (aud claim)
|
|
22
|
+
* @property authentication - The authentication method used to generate the JWT.
|
|
23
|
+
*
|
|
21
24
|
*/
|
|
22
25
|
export interface JWTConfig {
|
|
23
26
|
pkpWallet: PKPEthersWallet;
|
|
@@ -25,8 +28,8 @@ export interface JWTConfig {
|
|
|
25
28
|
payload: Record<string, unknown>;
|
|
26
29
|
expiresInMinutes: number;
|
|
27
30
|
audience: string | string[];
|
|
28
|
-
app
|
|
29
|
-
id:
|
|
31
|
+
app?: {
|
|
32
|
+
id: number;
|
|
30
33
|
version: number;
|
|
31
34
|
};
|
|
32
35
|
authentication: {
|
|
@@ -37,20 +40,16 @@ export interface JWTConfig {
|
|
|
37
40
|
/**
|
|
38
41
|
* Extended payload interface for Vincent-specific JWTs.
|
|
39
42
|
*
|
|
40
|
-
* @interface
|
|
43
|
+
* @interface BaseVincentJWTPayload
|
|
41
44
|
* @extends {JWTPayload} Extends the JWTPayload type from `did-jwt` with Vincent-specific properties
|
|
42
|
-
*
|
|
43
|
-
* @property
|
|
44
|
-
* @property
|
|
45
|
+
*
|
|
46
|
+
* @property pkp - The PKP details associated with the JWT.
|
|
47
|
+
* @property authentication - The authentication method that was used to authenticate with the PKP that generated the JWT.
|
|
45
48
|
*
|
|
46
49
|
* @category Interfaces
|
|
47
50
|
*/
|
|
48
|
-
export interface
|
|
51
|
+
export interface BaseVincentJWTPayload extends JWTPayload {
|
|
49
52
|
pkp: IRelayPKP;
|
|
50
|
-
app: {
|
|
51
|
-
id: string;
|
|
52
|
-
version: number;
|
|
53
|
-
};
|
|
54
53
|
authentication: {
|
|
55
54
|
type: string;
|
|
56
55
|
value?: string;
|
|
@@ -60,13 +59,24 @@ export interface VincentJWTPayload extends JWTPayload {
|
|
|
60
59
|
* Interface representing a decoded Vincent JWT
|
|
61
60
|
*
|
|
62
61
|
* @interface VincentJWT
|
|
63
|
-
* @
|
|
64
|
-
* @property {VincentJWTPayload} payload - The payload of the JWT
|
|
62
|
+
* @property { BaseVincentJWTPayload } payload - The payload of the JWT
|
|
65
63
|
*
|
|
66
64
|
* @category Interfaces
|
|
67
65
|
*/
|
|
68
66
|
export interface VincentJWT extends JWTDecoded {
|
|
69
|
-
payload:
|
|
67
|
+
payload: BaseVincentJWTPayload;
|
|
68
|
+
}
|
|
69
|
+
/** App-specific Vincent JWT payloads are used to authenticate with a specific app @ a specific version */
|
|
70
|
+
interface VincentJWTAppSpecificPayload extends BaseVincentJWTPayload {
|
|
71
|
+
app: {
|
|
72
|
+
id: number;
|
|
73
|
+
version: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** VincentJWTAppSpecific type JWTs are used to signal authorization from a user to use a specific app / appVersion
|
|
77
|
+
*/
|
|
78
|
+
export interface VincentJWTAppSpecific extends VincentJWT {
|
|
79
|
+
payload: VincentJWTAppSpecificPayload;
|
|
70
80
|
}
|
|
71
81
|
export {};
|
|
72
82
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/jwt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/jwt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,eAAe,CAAC;IAC3B,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,GAAG,CAAC,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,GAAG,EAAE,SAAS,CAAC;IACf,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED,0GAA0G;AAC1G,UAAU,4BAA6B,SAAQ,qBAAqB;IAClE,GAAG,EAAE;QACH,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;GACG;AACH,MAAM,WAAW,qBAAsB,SAAQ,UAAU;IACvD,OAAO,EAAE,4BAA4B,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/toolClient/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/toolClient/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ethers } from 'ethers';
|
|
2
|
+
import type { LitNodeClient } from '@lit-protocol/lit-node-client';
|
|
3
|
+
/** @hidden */
|
|
4
|
+
export declare const generateVincentToolSessionSigs: ({ litNodeClient, ethersSigner, }: {
|
|
5
|
+
litNodeClient: LitNodeClient;
|
|
6
|
+
ethersSigner: ethers.Signer;
|
|
7
|
+
}) => Promise<import("@lit-protocol/types").SessionSigsMap>;
|
|
8
|
+
//# sourceMappingURL=generateVincentToolSessionSigs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVincentToolSessionSigs.d.ts","sourceRoot":"","sources":["../../../../src/toolClient/execute/generateVincentToolSessionSigs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAUnE,cAAc;AACd,eAAO,MAAM,8BAA8B,GAAU,kCAGlD;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC;CAC7B,0DAyBA,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// src/toolClient/execute/generateVincentToolSessionSigs.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.generateVincentToolSessionSigs = void 0;
|
|
5
|
+
const auth_helpers_1 = require("@lit-protocol/auth-helpers");
|
|
6
|
+
const constants_1 = require("@lit-protocol/constants");
|
|
7
|
+
/** @hidden */
|
|
8
|
+
const generateVincentToolSessionSigs = async ({ litNodeClient, ethersSigner, }) => {
|
|
9
|
+
return litNodeClient.getSessionSigs({
|
|
10
|
+
chain: 'ethereum',
|
|
11
|
+
resourceAbilityRequests: [
|
|
12
|
+
{ resource: new auth_helpers_1.LitPKPResource('*'), ability: constants_1.LIT_ABILITY.PKPSigning },
|
|
13
|
+
{ resource: new auth_helpers_1.LitActionResource('*'), ability: constants_1.LIT_ABILITY.LitActionExecution },
|
|
14
|
+
],
|
|
15
|
+
authNeededCallback: async ({ resourceAbilityRequests, uri }) => {
|
|
16
|
+
const [walletAddress, nonce] = await Promise.all([
|
|
17
|
+
ethersSigner.getAddress(),
|
|
18
|
+
litNodeClient.getLatestBlockhash(),
|
|
19
|
+
]);
|
|
20
|
+
const toSign = await (0, auth_helpers_1.createSiweMessageWithRecaps)({
|
|
21
|
+
uri: uri || 'http://localhost:3000',
|
|
22
|
+
expiration: new Date(Date.now() + 1000 * 60 * 10).toISOString(),
|
|
23
|
+
resources: resourceAbilityRequests || [],
|
|
24
|
+
walletAddress,
|
|
25
|
+
nonce,
|
|
26
|
+
litNodeClient,
|
|
27
|
+
});
|
|
28
|
+
return await (0, auth_helpers_1.generateAuthSig)({ signer: ethersSigner, toSign });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.generateVincentToolSessionSigs = generateVincentToolSessionSigs;
|
|
33
|
+
//# sourceMappingURL=generateVincentToolSessionSigs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateVincentToolSessionSigs.js","sourceRoot":"","sources":["../../../../src/toolClient/execute/generateVincentToolSessionSigs.ts"],"names":[],"mappings":";AAAA,2DAA2D;;;AAM3D,6DAKoC;AACpC,uDAAsD;AAEtD,cAAc;AACP,MAAM,8BAA8B,GAAG,KAAK,EAAE,EACnD,aAAa,EACb,YAAY,GAIb,EAAE,EAAE;IACH,OAAO,aAAa,CAAC,cAAc,CAAC;QAClC,KAAK,EAAE,UAAU;QACjB,uBAAuB,EAAE;YACvB,EAAE,QAAQ,EAAE,IAAI,6BAAc,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,uBAAW,CAAC,UAAU,EAAE;YACtE,EAAE,QAAQ,EAAE,IAAI,gCAAiB,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,uBAAW,CAAC,kBAAkB,EAAE;SAClF;QACD,kBAAkB,EAAE,KAAK,EAAE,EAAE,uBAAuB,EAAE,GAAG,EAAE,EAAE,EAAE;YAC7D,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC/C,YAAY,CAAC,UAAU,EAAE;gBACzB,aAAa,CAAC,kBAAkB,EAAE;aACnC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,IAAA,0CAA2B,EAAC;gBAC/C,GAAG,EAAE,GAAG,IAAI,uBAAuB;gBACnC,UAAU,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE;gBAC/D,SAAS,EAAE,uBAAuB,IAAI,EAAE;gBACxC,aAAa;gBACb,KAAK;gBACL,aAAa;aACd,CAAC,CAAC;YAEH,OAAO,MAAM,IAAA,8BAAe,EAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA/BW,QAAA,8BAA8B,kCA+BzC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { BaseToolContext, PolicyEvaluationResultContext, SchemaValidationError } from '@lit-protocol/vincent-tool-sdk';
|
|
3
|
+
import type { ToolExecuteResponseFailure, ToolExecuteResponseFailureNoResult, ToolExecuteResponseSuccess, ToolExecuteResponseSuccessNoResult } from './types';
|
|
4
4
|
export declare function createAllowEvaluationResult<PoliciesByPackageName extends Record<string, any>>(evaluatedPolicies: Array<keyof PoliciesByPackageName>, allowedPolicies: {
|
|
5
5
|
[K in keyof PoliciesByPackageName]?: {
|
|
6
6
|
result: PoliciesByPackageName[K]['__schemaTypes'] extends {
|
|
@@ -26,11 +26,11 @@ export declare function createDenyEvaluationResult<PoliciesByPackageName extends
|
|
|
26
26
|
};
|
|
27
27
|
}, deniedPolicy: {
|
|
28
28
|
packageName: keyof PoliciesByPackageName;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
runtimeError?: string;
|
|
30
|
+
schemaValidationError?: SchemaValidationError;
|
|
31
|
+
result: PoliciesByPackageName[keyof PoliciesByPackageName]['__schemaTypes'] extends {
|
|
32
32
|
evalDenyResultSchema: infer Schema;
|
|
33
|
-
} ? Schema extends z.ZodType ? z.infer<Schema> : undefined : undefined
|
|
33
|
+
} ? Schema extends z.ZodType ? z.infer<Schema> : undefined : undefined;
|
|
34
34
|
}): {
|
|
35
35
|
allow: false;
|
|
36
36
|
evaluatedPolicies: Array<keyof PoliciesByPackageName>;
|
|
@@ -43,27 +43,29 @@ export declare function createDenyEvaluationResult<PoliciesByPackageName extends
|
|
|
43
43
|
};
|
|
44
44
|
deniedPolicy: {
|
|
45
45
|
packageName: keyof PoliciesByPackageName;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
runtimeError?: string;
|
|
47
|
+
schemaValidationError?: SchemaValidationError;
|
|
48
|
+
result: PoliciesByPackageName[keyof PoliciesByPackageName]['__schemaTypes'] extends {
|
|
49
49
|
evalDenyResultSchema: infer Schema;
|
|
50
|
-
} ? Schema extends z.ZodType ? z.infer<Schema> : undefined : undefined
|
|
50
|
+
} ? Schema extends z.ZodType ? z.infer<Schema> : undefined : undefined;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
export declare function
|
|
53
|
+
export declare function createToolExecuteResponseSuccess<Success, Policies extends Record<any, any>>(params: {
|
|
54
54
|
result: Success;
|
|
55
55
|
context?: BaseToolContext<PolicyEvaluationResultContext<Policies>>;
|
|
56
|
-
}):
|
|
57
|
-
export declare function
|
|
56
|
+
}): ToolExecuteResponseSuccess<Success, Policies>;
|
|
57
|
+
export declare function createToolExecuteResponseSuccessNoResult<Policies extends Record<any, any>>(params?: {
|
|
58
58
|
context?: BaseToolContext<PolicyEvaluationResultContext<Policies>>;
|
|
59
|
-
}):
|
|
60
|
-
export declare function
|
|
59
|
+
}): ToolExecuteResponseSuccessNoResult<Policies>;
|
|
60
|
+
export declare function createToolExecuteResponseFailure<Fail, Policies extends Record<any, any>>(params: {
|
|
61
61
|
result: Fail;
|
|
62
|
-
|
|
62
|
+
runtimeError?: string;
|
|
63
|
+
schemaValidationError?: SchemaValidationError;
|
|
63
64
|
context?: BaseToolContext<PolicyEvaluationResultContext<Policies>>;
|
|
64
|
-
}):
|
|
65
|
-
export declare function
|
|
66
|
-
|
|
65
|
+
}): ToolExecuteResponseFailure<Fail, Policies>;
|
|
66
|
+
export declare function createToolExecuteResponseFailureNoResult<Policies extends Record<any, any>>(params: {
|
|
67
|
+
runtimeError?: string;
|
|
68
|
+
schemaValidationError?: SchemaValidationError;
|
|
67
69
|
context?: BaseToolContext<PolicyEvaluationResultContext<Policies>>;
|
|
68
|
-
}):
|
|
70
|
+
}): ToolExecuteResponseFailureNoResult<Policies>;
|
|
69
71
|
//# sourceMappingURL=resultCreators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resultCreators.d.ts","sourceRoot":"","sources":["../../../../src/toolClient/execute/resultCreators.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EACV,0BAA0B,EAC1B,kCAAkC,EAClC,0BAA0B,EAC1B,kCAAkC,EACnC,MAAM,SAAS,CAAC;AAEjB,wBAAgB,2BAA2B,CAAC,qBAAqB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3F,iBAAiB,EAAE,KAAK,CAAC,MAAM,qBAAqB,CAAC,EACrD,eAAe,EAAE;KACd,CAAC,IAAI,MAAM,qBAAqB,CAAC,CAAC,EAAE;QACnC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS;YACxD,qBAAqB,EAAE,MAAM,MAAM,CAAC;SACrC,GACG,MAAM,SAAS,CAAC,CAAC,OAAO,GACtB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GACf,KAAK,GACP,KAAK,CAAC;KACX;CACF,GACA;IACD,KAAK,EAAE,IAAI,CAAC;IACZ,iBAAiB,EAAE,KAAK,CAAC,MAAM,qBAAqB,CAAC,CAAC;IACtD,eAAe,EAAE;SACd,CAAC,IAAI,MAAM,qBAAqB,CAAC,CAAC,EAAE;YACnC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS;gBACxD,qBAAqB,EAAE,MAAM,MAAM,CAAC;aACrC,GACG,MAAM,SAAS,CAAC,CAAC,O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BAA0B,CAAC,IAAI,EAAE,QAAQ,CAAC,CAQ7C;AAED,wBAAgB,wCAAwC,CACtD,QAAQ,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EACjC,MAAM,EAAE;IACR,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,OAAO,CAAC,EAAE,eAAe,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC,CAAC;CACpE,GAAG,kCAAkC,CAAC,QAAQ,CAAC,CAQ/C"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// src/
|
|
2
|
+
// src/toolClient/execute/resultCreators.ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createAllowEvaluationResult = createAllowEvaluationResult;
|
|
5
5
|
exports.createDenyEvaluationResult = createDenyEvaluationResult;
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
6
|
+
exports.createToolExecuteResponseSuccess = createToolExecuteResponseSuccess;
|
|
7
|
+
exports.createToolExecuteResponseSuccessNoResult = createToolExecuteResponseSuccessNoResult;
|
|
8
|
+
exports.createToolExecuteResponseFailure = createToolExecuteResponseFailure;
|
|
9
|
+
exports.createToolExecuteResponseFailureNoResult = createToolExecuteResponseFailureNoResult;
|
|
10
10
|
function createAllowEvaluationResult(evaluatedPolicies, allowedPolicies) {
|
|
11
11
|
return {
|
|
12
12
|
allow: true,
|
|
@@ -22,33 +22,35 @@ function createDenyEvaluationResult(evaluatedPolicies, allowedPolicies, deniedPo
|
|
|
22
22
|
deniedPolicy,
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function createToolExecuteResponseSuccess(params) {
|
|
26
26
|
return {
|
|
27
27
|
success: true,
|
|
28
28
|
result: params.result,
|
|
29
29
|
context: params.context,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function createToolExecuteResponseSuccessNoResult(params) {
|
|
33
33
|
return {
|
|
34
34
|
success: true,
|
|
35
35
|
result: undefined,
|
|
36
|
-
context: params
|
|
36
|
+
context: params?.context,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function createToolExecuteResponseFailure(params) {
|
|
40
40
|
return {
|
|
41
41
|
success: false,
|
|
42
|
+
runtimeError: params.runtimeError,
|
|
43
|
+
schemaValidationError: params.schemaValidationError,
|
|
42
44
|
result: params.result,
|
|
43
|
-
error: params.message,
|
|
44
45
|
context: params.context,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function createToolExecuteResponseFailureNoResult(params) {
|
|
48
49
|
return {
|
|
49
50
|
success: false,
|
|
51
|
+
runtimeError: params.runtimeError,
|
|
52
|
+
schemaValidationError: params.schemaValidationError,
|
|
50
53
|
result: undefined,
|
|
51
|
-
error: params.message,
|
|
52
54
|
context: params.context,
|
|
53
55
|
};
|
|
54
56
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resultCreators.js","sourceRoot":"","sources":["../../../../src/toolClient/execute/resultCreators.ts"],"names":[],"mappings":";AAAA,2CAA2C;;AAiB3C,kEAiCC;AAED,gEA0DC;AAED,4EAYC;AAED,4FAUC;AAED,4EAaC;AAED,4FAcC;AAtJD,SAAgB,2BAA2B,CACzC,iBAAqD,EACrD,eAUC;IAgBD,OAAO;QACL,KAAK,EAAE,IAAI;QACX,iBAAiB;QACjB,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,0BAA0B,CACxC,iBAAqD,EACrD,eAUC,EACD,YAWC;IA4BD,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,iBAAiB;QACjB,eAAe;QACf,YAAY;KACb,CAAC;AACJ,CAAC;AAED,SAAgB,gCAAgC,CAG9C,MAGD;IACC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC;AAED,SAAgB,wCAAwC,CAEtD,MAED;IACC,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,MAAM,EAAE,OAAO;KACzB,CAAC;AACJ,CAAC;AAED,SAAgB,gCAAgC,CAA0C,MAKzF;IACC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC;AAED,SAAgB,wCAAwC,CAEtD,MAID;IACC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC"}
|