@lit-protocol/vincent-app-sdk 1.0.2 → 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/CONTRIBUTING.md +2 -2
- package/README.md +12 -11
- package/dist/CONTRIBUTING.md +2 -2
- package/dist/README.md +12 -11
- package/dist/package.json +31 -2
- 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 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -19
- 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 +1 -1
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.d.ts.map +1 -1
- package/dist/src/toolClient/execute/generateVincentToolSessionSigs.js.map +1 -1
- package/dist/src/toolClient/execute/resultCreators.d.ts +13 -11
- package/dist/src/toolClient/execute/resultCreators.d.ts.map +1 -1
- package/dist/src/toolClient/execute/resultCreators.js +5 -3
- package/dist/src/toolClient/execute/resultCreators.js.map +1 -1
- package/dist/src/toolClient/execute/types.d.ts +6 -3
- package/dist/src/toolClient/execute/types.d.ts.map +1 -1
- package/dist/src/toolClient/index.d.ts +13 -1
- package/dist/src/toolClient/index.d.ts.map +1 -1
- package/dist/src/toolClient/index.js +19 -2
- package/dist/src/toolClient/index.js.map +1 -1
- package/dist/src/toolClient/precheck/resultCreators.d.ts +13 -9
- package/dist/src/toolClient/precheck/resultCreators.d.ts.map +1 -1
- package/dist/src/toolClient/precheck/resultCreators.js +5 -3
- package/dist/src/toolClient/precheck/resultCreators.js.map +1 -1
- package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts +4 -3
- package/dist/src/toolClient/precheck/runPolicyPrechecks.d.ts.map +1 -1
- package/dist/src/toolClient/precheck/runPolicyPrechecks.js +31 -20
- package/dist/src/toolClient/precheck/runPolicyPrechecks.js.map +1 -1
- package/dist/src/toolClient/precheck/types.d.ts +8 -6
- package/dist/src/toolClient/precheck/types.d.ts.map +1 -1
- package/dist/src/toolClient/typeGuards.d.ts +22 -13
- 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.map +1 -1
- package/dist/src/toolClient/vincentToolClient.d.ts +53 -5
- package/dist/src/toolClient/vincentToolClient.d.ts.map +1 -1
- package/dist/src/toolClient/vincentToolClient.js +102 -25
- 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 +7 -6
- package/dist/src/type-inference-verification/tool-client-inference.js.map +1 -1
- package/dist/src/utils/delegation.d.ts +4 -18
- package/dist/src/utils/delegation.d.ts.map +1 -1
- package/dist/src/utils/delegation.js +10 -79
- package/dist/src/utils/delegation.js.map +1 -1
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/index.js.map +1 -1
- 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 +30 -3
- 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/types.d.ts +0 -5
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/contracts.d.ts +0 -49
- package/dist/src/utils/contracts.d.ts.map +0 -1
- package/dist/src/utils/contracts.js +0 -92
- package/dist/src/utils/contracts.js.map +0 -1
- package/dist/src/utils/pkp.d.ts +0 -12
- package/dist/src/utils/pkp.d.ts.map +0 -1
- package/dist/src/utils/pkp.js +0 -19
- package/dist/src/utils/pkp.js.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,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAuthenticateUserExpressHandler = exports.authenticatedRequestHandler = void 0;
|
|
4
|
-
const __1 = require("..");
|
|
5
|
-
const utils_1 = require("../jwt/core/utils");
|
|
6
|
-
const { verify } = __1.jwt;
|
|
7
|
-
function assertAuthenticatedRequest(req) {
|
|
8
|
-
if (!('user' in req) || typeof req.user !== 'object' || !req.user) {
|
|
9
|
-
throw new Error('Request is not an AuthenticatedRequest: Missing or invalid "user" property');
|
|
10
|
-
}
|
|
11
|
-
// Cast with a type assertion
|
|
12
|
-
const user = req.user;
|
|
13
|
-
const { decodedJWT, rawJWT } = user;
|
|
14
|
-
if (typeof rawJWT !== 'string' || !(0, utils_1.isDefinedObject)(decodedJWT)) {
|
|
15
|
-
throw new Error('Request is not an AuthenticatedRequest: Invalid "user" properties');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Higher-order helper function to enforce authentication on a request handler and assert the type of `Request` that is
|
|
20
|
-
* passed into your authenticated Express routes.
|
|
21
|
-
*
|
|
22
|
-
* This function takes an `AuthenticatedRequestHandler` and returns a new request handler
|
|
23
|
-
* that verifies that the request has a 'user' property with the correct shape on it before calling the original handler.
|
|
24
|
-
* If the `req.user` property isn't the correct shape, it sends a `401 Unauthorized` response to the client.
|
|
25
|
-
*
|
|
26
|
-
* NOTE: This does not verify signatures or any other content -- use `getAuthenticateUserExpressHandler` to create a
|
|
27
|
-
* middleware that does those things and ensure that your routes use it.
|
|
28
|
-
*
|
|
29
|
-
* See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
33
|
-
* const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
|
|
34
|
-
*
|
|
35
|
-
* import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
36
|
-
*
|
|
37
|
-
* // Define an authenticated route handler
|
|
38
|
-
* const getUserProfile = async (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
|
|
39
|
-
* // Access authenticated user information
|
|
40
|
-
* const { pkpAddress } = req.user;
|
|
41
|
-
*
|
|
42
|
-
* // Fetch and return user data
|
|
43
|
-
* const userData = await userRepository.findByAddress(pkpAddress);
|
|
44
|
-
* res.json(userData);
|
|
45
|
-
* };
|
|
46
|
-
*
|
|
47
|
-
* // Use in Express route with authentication
|
|
48
|
-
* app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
const authenticatedRequestHandler = (handler) => (req, res, next) => {
|
|
52
|
-
try {
|
|
53
|
-
assertAuthenticatedRequest(req);
|
|
54
|
-
return handler(req, res, next);
|
|
55
|
-
}
|
|
56
|
-
catch (_a) {
|
|
57
|
-
res.status(401).json({ error: 'Not authenticated' });
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.authenticatedRequestHandler = authenticatedRequestHandler;
|
|
61
|
-
/**
|
|
62
|
-
* Creates an Express middleware function to authenticate a user using a JWT token.
|
|
63
|
-
*
|
|
64
|
-
* This middleware checks the `Authorization` header for a Bearer token, verifies the token, and checks its audience.
|
|
65
|
-
* If the token is valid, it attaches the user information (decoded JWT, raw token, and PKP address) to the request object as `req.user`.
|
|
66
|
-
* If the token is missing or invalid, it returns a 401 Unauthorized response with an error message.
|
|
67
|
-
*
|
|
68
|
-
* NOTE: Wrap your route handler functions with `authenticatedRequestHandler()` to assert the type of `Request` and to
|
|
69
|
-
* ensure that `req.user` was correctly set before your route handler is run.
|
|
70
|
-
*
|
|
71
|
-
* See [express.js documentation](https://expressjs.com/en/guide/writing-middleware.html) for details on writing your route handler
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
76
|
-
* const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
|
|
77
|
-
*
|
|
78
|
-
* import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
79
|
-
*
|
|
80
|
-
* // In your environment configuration
|
|
81
|
-
* const ALLOWED_AUDIENCE = 'https://yourapp.example.com';
|
|
82
|
-
*
|
|
83
|
-
* // Create the authentication middleware
|
|
84
|
-
* const authenticateUser = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
|
|
85
|
-
*
|
|
86
|
-
* // Define a handler that requires authentication
|
|
87
|
-
* const getProtectedResource = (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
|
|
88
|
-
* // The request is now authenticated
|
|
89
|
-
* // No need for type casting as the handler is properly typed
|
|
90
|
-
* const { pkpAddress } = req.user;
|
|
91
|
-
* res.json({ message: `Hello, user with PKP address ${pkpAddress}` });
|
|
92
|
-
* };
|
|
93
|
-
*
|
|
94
|
-
* // Apply to routes that require authentication by using authenticatedRequestHandler
|
|
95
|
-
* app.get('/protected-resource', authenticateUser, authenticatedRequestHandler(getProtectedResource));
|
|
96
|
-
* ```
|
|
97
|
-
*
|
|
98
|
-
* You can see the source for `getAuthenticateUserExpressHandler()` below; use this as a reference to implement
|
|
99
|
-
* your own midddleware/authentication for other frameworks! Pull requests are welcome.
|
|
100
|
-
* {@includeCode ./express.ts#expressHandlerTSDocExample}
|
|
101
|
-
*/
|
|
102
|
-
// #region expressHandlerTSDocExample
|
|
103
|
-
const getAuthenticateUserExpressHandler = (allowedAudience) => async (req, res, next) => {
|
|
104
|
-
const authHeader = req.headers.authorization;
|
|
105
|
-
if (!authHeader) {
|
|
106
|
-
res.status(401).json({ error: 'No token provided' });
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const parts = authHeader.split(' ');
|
|
110
|
-
if (parts.length !== 2) {
|
|
111
|
-
res.status(401).json({ error: `Invalid authorization header - expected "Bearer <token>"` });
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const [scheme, rawJWT] = parts;
|
|
115
|
-
if (!/^Bearer$/i.test(scheme)) {
|
|
116
|
-
res.status(401).json({ error: `Expected "Bearer" scheme, got "${scheme}"` });
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
try {
|
|
120
|
-
const decodedJWT = verify(rawJWT, allowedAudience);
|
|
121
|
-
if (!decodedJWT) {
|
|
122
|
-
res.status(401).json({ error: 'Invalid token' });
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
req.user = {
|
|
126
|
-
decodedJWT,
|
|
127
|
-
rawJWT,
|
|
128
|
-
};
|
|
129
|
-
next();
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
res.status(401).json({ error: `Invalid token: ${e.message}` });
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
exports.getAuthenticateUserExpressHandler = getAuthenticateUserExpressHandler;
|
|
136
|
-
// #endregion expressHandlerTSDocExample
|
|
137
|
-
//# sourceMappingURL=express.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../../src/express-authentication-middleware/express.ts"],"names":[],"mappings":";;;AAEA,0BAAyB;AACzB,6CAAoD;AAIpD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAG,CAAC;AAEvB,SAAS,0BAA0B,CAAC,GAAY;IAC9C,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,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3
|
-
* - Create an express middleware using {@link getAuthenticateUserExpressHandler}
|
|
4
|
-
* - Once you have added the middleware to your route, use {@link authenticatedRequestHandler} to provide
|
|
5
|
-
* type-safe access to `req.user` in your downstream RequestHandler functions.
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
9
|
-
* const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
|
|
10
|
-
*
|
|
11
|
-
* import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
12
|
-
*
|
|
13
|
-
* const { ALLOWED_AUDIENCE } = process.env;
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* const authenticateUserMiddleware = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* // Define an authenticated route handler
|
|
20
|
-
* const getUserProfile = async (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
|
|
21
|
-
* // Access authenticated user information
|
|
22
|
-
* const { pkpAddress } = req.user;
|
|
23
|
-
*
|
|
24
|
-
* // Fetch and return user data
|
|
25
|
-
* const userData = await userRepository.findByAddress(pkpAddress);
|
|
26
|
-
* res.json(userData);
|
|
27
|
-
* };
|
|
28
|
-
*
|
|
29
|
-
* // Use in Express route with authentication
|
|
30
|
-
* app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* You can see the source for `getAuthenticateUserExpressHandler()` below; use this as a reference to implement
|
|
34
|
-
* your own midddleware/authentication for other frameworks! Pull requests are welcome.
|
|
35
|
-
*
|
|
36
|
-
* {@includeCode ./express.ts#expressHandlerTSDocExample}
|
|
37
|
-
*
|
|
38
|
-
* @module expressAuthHelpers
|
|
39
|
-
* @category API Methods
|
|
40
|
-
* */
|
|
41
|
-
import { authenticatedRequestHandler, getAuthenticateUserExpressHandler } from './express';
|
|
42
|
-
export { authenticatedRequestHandler, getAuthenticateUserExpressHandler };
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/express-authentication-middleware/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCK;AAEL,OAAO,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,MAAM,WAAW,CAAC;AAE3F,OAAO,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** expressAuthHelpers are used to add a VincentJWT-specific authentication to your Express.js server routes
|
|
3
|
-
*
|
|
4
|
-
* - Create an express middleware using {@link getAuthenticateUserExpressHandler}
|
|
5
|
-
* - Once you have added the middleware to your route, use {@link authenticatedRequestHandler} to provide
|
|
6
|
-
* type-safe access to `req.user` in your downstream RequestHandler functions.
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { expressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
10
|
-
* const { authenticatedRequestHandler, getAuthenticateUserExpressHandler } = expressAuthHelpers;
|
|
11
|
-
*
|
|
12
|
-
* import type { ExpressAuthHelpers } from '@lit-protocol/vincent-app-sdk';
|
|
13
|
-
*
|
|
14
|
-
* const { ALLOWED_AUDIENCE } = process.env;
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* const authenticateUserMiddleware = getAuthenticateUserExpressHandler(ALLOWED_AUDIENCE);
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* // Define an authenticated route handler
|
|
21
|
-
* const getUserProfile = async (req: ExpressAuthHelpers['AuthenticatedRequest'], res: Response) => {
|
|
22
|
-
* // Access authenticated user information
|
|
23
|
-
* const { pkpAddress } = req.user;
|
|
24
|
-
*
|
|
25
|
-
* // Fetch and return user data
|
|
26
|
-
* const userData = await userRepository.findByAddress(pkpAddress);
|
|
27
|
-
* res.json(userData);
|
|
28
|
-
* };
|
|
29
|
-
*
|
|
30
|
-
* // Use in Express route with authentication
|
|
31
|
-
* app.get('/profile', authenticateUser, authenticatedRequestHandler(getUserProfile));
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* You can see the source for `getAuthenticateUserExpressHandler()` below; use this as a reference to implement
|
|
35
|
-
* your own midddleware/authentication for other frameworks! Pull requests are welcome.
|
|
36
|
-
*
|
|
37
|
-
* {@includeCode ./express.ts#expressHandlerTSDocExample}
|
|
38
|
-
*
|
|
39
|
-
* @module expressAuthHelpers
|
|
40
|
-
* @category API Methods
|
|
41
|
-
* */
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.getAuthenticateUserExpressHandler = exports.authenticatedRequestHandler = void 0;
|
|
44
|
-
const express_1 = require("./express");
|
|
45
|
-
Object.defineProperty(exports, "authenticatedRequestHandler", { enumerable: true, get: function () { return express_1.authenticatedRequestHandler; } });
|
|
46
|
-
Object.defineProperty(exports, "getAuthenticateUserExpressHandler", { enumerable: true, get: function () { return express_1.getAuthenticateUserExpressHandler; } });
|
|
47
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/express-authentication-middleware/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCK;;;AAEL,uCAA2F;AAElF,4GAFA,qCAA2B,OAEA;AAAE,kHAFA,2CAAiC,OAEA"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, RequestHandler, Response } from 'express';
|
|
2
|
-
import { VincentJWT } from '../jwt/types';
|
|
3
|
-
/** Extract the parameters type from the original RequestHandler */
|
|
4
|
-
type ExtractRequestHandlerParams<T> = T extends RequestHandler<infer P, infer ResBody, infer ReqBody, infer ReqQuery, infer Locals> ? [P, ResBody, ReqBody, ReqQuery, Locals] : never;
|
|
5
|
-
/**
|
|
6
|
-
* A RequestHandler that guarantees the request is authenticated with a PKP address
|
|
7
|
-
* */
|
|
8
|
-
export type AuthenticatedRequestHandler<P = ExtractRequestHandlerParams<RequestHandler>[0], ResBody = ExtractRequestHandlerParams<RequestHandler>[1], ReqBody = ExtractRequestHandlerParams<RequestHandler>[2], ReqQuery = ExtractRequestHandlerParams<RequestHandler>[3], Locals extends Record<string, any> = ExtractRequestHandlerParams<RequestHandler>[4]> = (req: AuthenticatedRequest<P, ResBody, ReqBody, ReqQuery>, res: Response<ResBody, Locals>, next: NextFunction) => void | Promise<void>;
|
|
9
|
-
/** Interface that extends Express Request to include authenticated user data
|
|
10
|
-
* */
|
|
11
|
-
export interface AuthenticatedRequest<P = any, ResBody = any, ReqBody = any, ReqQuery = any> extends Request<P, ResBody, ReqBody, ReqQuery> {
|
|
12
|
-
user: {
|
|
13
|
-
decodedJWT: VincentJWT;
|
|
14
|
-
rawJWT: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @category Interfaces
|
|
19
|
-
*/
|
|
20
|
-
export interface ExpressAuthHelpers {
|
|
21
|
-
AuthenticatedRequestHandler: AuthenticatedRequestHandler;
|
|
22
|
-
AuthenticatedRequest: AuthenticatedRequest;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/express-authentication-middleware/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,mEAAmE;AACnE,KAAK,2BAA2B,CAAC,CAAC,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AC;CAC5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/express-authentication-middleware/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VincentJWT } from '../../types';
|
|
2
|
-
/** Checks if a JWT is expired based on its 'exp' claim
|
|
3
|
-
*
|
|
4
|
-
* @returns true if expired, false otherwise
|
|
5
|
-
* @param decodedJWT
|
|
6
|
-
*/
|
|
7
|
-
export declare function isJWTExpired(decodedJWT: VincentJWT): boolean;
|
|
8
|
-
//# sourceMappingURL=isJWTExpired.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isJWTExpired.d.ts","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/isJWTExpired.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAW5D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isJWTExpired.js","sourceRoot":"","sources":["../../../../../src/jwt/core/utils/isJWTExpired.ts"],"names":[],"mappings":";;AAOA,oCAWC;AAhBD;;;;GAIG;AACH,SAAgB,YAAY,CAAC,UAAsB;IACjD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAE/B,gEAAgE;IAChE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uDAAuD;IACvD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,OAAO,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;AACpC,CAAC"}
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export type { JWTConfig, VincentJWT, VincentJWTPayload } from './jwt/types';
|
|
2
|
-
export type { VincentWebAppClient, VincentAppClientConfig, RedirectToVincentConsentPageParams, } from './app/types';
|
|
3
|
-
export type { BaseToolContext } from './toolClient';
|
|
4
|
-
export type { ExpressAuthHelpers } from './express-authentication-middleware/types';
|
|
5
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,kCAAkC,GACnC,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract interaction utilities for Vincent MCP
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for interacting with the Vincent Diamond contract
|
|
5
|
-
* on the Lit Network. It includes constants, contract ABIs, and functions for
|
|
6
|
-
* fetching data from the contract.
|
|
7
|
-
*
|
|
8
|
-
* @module contracts
|
|
9
|
-
* @category Vincent MCP
|
|
10
|
-
*/
|
|
11
|
-
import { LIT_NETWORK } from '@lit-protocol/constants';
|
|
12
|
-
import { ethers } from 'ethers';
|
|
13
|
-
/**
|
|
14
|
-
* RPC endpoint for interacting with the Lit Network Contracts in Yellowstone
|
|
15
|
-
*/
|
|
16
|
-
export declare const rpc: "https://yellowstone-rpc.litprotocol.com";
|
|
17
|
-
/**
|
|
18
|
-
* Type representing the supported network for Vincent MCP
|
|
19
|
-
* Currently only supports the Datil network
|
|
20
|
-
*/
|
|
21
|
-
export type Network = typeof LIT_NETWORK.Datil;
|
|
22
|
-
export declare const PUBKEY_ROUTER_ABI: readonly ["function getEthAddress(uint256 tokenId) public view returns (address)", "function getPubkey(uint256 tokenId) public view returns (bytes memory)"];
|
|
23
|
-
export declare const APP_VIEW_ABI: readonly ["function getAppVersion(\n uint256 tokenId,\n uint256 version\n ) view returns (\n (\n uint256 id,\n string name,\n string description,\n bool isDeleted,\n uint8 deploymentStatus,\n address manager,\n uint256 latestVersion,\n address[] delegatees,\n string[] authorizedRedirectUris\n ) app,\n (\n uint256 version,\n bool enabled,\n uint256[] delegatedAgentPkpTokenIds,\n (\n string toolIpfsCid,\n (\n string policyIpfsCid,\n string[] parameterNames,\n uint8[] parameterTypes\n )[] policies\n )[] tools\n ) appVersion\n )"];
|
|
24
|
-
/**
|
|
25
|
-
* ABIs for different facets of the Vincent Diamond contract
|
|
26
|
-
* Each facet provides specific functionality of the contract
|
|
27
|
-
*/
|
|
28
|
-
export declare const FACET_ABIS: {
|
|
29
|
-
AppView: readonly ["function getAppVersion(\n uint256 tokenId,\n uint256 version\n ) view returns (\n (\n uint256 id,\n string name,\n string description,\n bool isDeleted,\n uint8 deploymentStatus,\n address manager,\n uint256 latestVersion,\n address[] delegatees,\n string[] authorizedRedirectUris\n ) app,\n (\n uint256 version,\n bool enabled,\n uint256[] delegatedAgentPkpTokenIds,\n (\n string toolIpfsCid,\n (\n string policyIpfsCid,\n string[] parameterNames,\n uint8[] parameterTypes\n )[] policies\n )[] tools\n ) appVersion\n )"];
|
|
30
|
-
PubKeyRouter: readonly ["function getEthAddress(uint256 tokenId) public view returns (address)", "function getPubkey(uint256 tokenId) public view returns (bytes memory)"];
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Type representing the available facets of the Vincent Diamond contract
|
|
34
|
-
* Used to specify which facet to interact with
|
|
35
|
-
*/
|
|
36
|
-
export type ContractFacet = keyof typeof FACET_ABIS;
|
|
37
|
-
/**
|
|
38
|
-
* Mapping of network to Vincent Diamond contract address
|
|
39
|
-
* Used to interact with the correct contract based on the network
|
|
40
|
-
*/
|
|
41
|
-
export declare const VINCENT_ADDRESSES: Record<Network, Record<ContractFacet, string>>;
|
|
42
|
-
/**
|
|
43
|
-
* Get a contract instance for a specific facet of the Vincent Diamond
|
|
44
|
-
* @param network The network to connect to
|
|
45
|
-
* @param facet The contract facet to use
|
|
46
|
-
* @returns A contract instance for the specified facet
|
|
47
|
-
*/
|
|
48
|
-
export declare function getContract(network: Network, facet: ContractFacet): ethers.Contract;
|
|
49
|
-
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/utils/contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAW,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,GAAG,2CAAgC,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,WAAW,CAAC,KAAK,CAAC;AAE/C,eAAO,MAAM,iBAAiB,8JAGpB,CAAC;AAEX,eAAO,MAAM,YAAY,wtBA8Bf,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,UAAU;;;CAGtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,UAAU,CAAC;AAUpD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAKnE,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,mBAKjE"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Contract interaction utilities for Vincent MCP
|
|
4
|
-
*
|
|
5
|
-
* This module provides utilities for interacting with the Vincent Diamond contract
|
|
6
|
-
* on the Lit Network. It includes constants, contract ABIs, and functions for
|
|
7
|
-
* fetching data from the contract.
|
|
8
|
-
*
|
|
9
|
-
* @module contracts
|
|
10
|
-
* @category Vincent MCP
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.VINCENT_ADDRESSES = exports.FACET_ABIS = exports.APP_VIEW_ABI = exports.PUBKEY_ROUTER_ABI = exports.rpc = void 0;
|
|
14
|
-
exports.getContract = getContract;
|
|
15
|
-
const constants_1 = require("@lit-protocol/constants");
|
|
16
|
-
const ethers_1 = require("ethers");
|
|
17
|
-
/**
|
|
18
|
-
* RPC endpoint for interacting with the Lit Network Contracts in Yellowstone
|
|
19
|
-
*/
|
|
20
|
-
exports.rpc = constants_1.LIT_RPC.CHRONICLE_YELLOWSTONE;
|
|
21
|
-
exports.PUBKEY_ROUTER_ABI = [
|
|
22
|
-
'function getEthAddress(uint256 tokenId) public view returns (address)',
|
|
23
|
-
'function getPubkey(uint256 tokenId) public view returns (bytes memory)',
|
|
24
|
-
];
|
|
25
|
-
exports.APP_VIEW_ABI = [
|
|
26
|
-
`function getAppVersion(
|
|
27
|
-
uint256 tokenId,
|
|
28
|
-
uint256 version
|
|
29
|
-
) view returns (
|
|
30
|
-
(
|
|
31
|
-
uint256 id,
|
|
32
|
-
string name,
|
|
33
|
-
string description,
|
|
34
|
-
bool isDeleted,
|
|
35
|
-
uint8 deploymentStatus,
|
|
36
|
-
address manager,
|
|
37
|
-
uint256 latestVersion,
|
|
38
|
-
address[] delegatees,
|
|
39
|
-
string[] authorizedRedirectUris
|
|
40
|
-
) app,
|
|
41
|
-
(
|
|
42
|
-
uint256 version,
|
|
43
|
-
bool enabled,
|
|
44
|
-
uint256[] delegatedAgentPkpTokenIds,
|
|
45
|
-
(
|
|
46
|
-
string toolIpfsCid,
|
|
47
|
-
(
|
|
48
|
-
string policyIpfsCid,
|
|
49
|
-
string[] parameterNames,
|
|
50
|
-
uint8[] parameterTypes
|
|
51
|
-
)[] policies
|
|
52
|
-
)[] tools
|
|
53
|
-
) appVersion
|
|
54
|
-
)`,
|
|
55
|
-
];
|
|
56
|
-
/**
|
|
57
|
-
* ABIs for different facets of the Vincent Diamond contract
|
|
58
|
-
* Each facet provides specific functionality of the contract
|
|
59
|
-
*/
|
|
60
|
-
exports.FACET_ABIS = {
|
|
61
|
-
AppView: exports.APP_VIEW_ABI,
|
|
62
|
-
PubKeyRouter: exports.PUBKEY_ROUTER_ABI,
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Vincent diamond address. This is the main address that redirects to any other contract involved in Vincent system
|
|
66
|
-
* If included in the diamond, the contract should be accessed through it to guarantee the last version is being used
|
|
67
|
-
*/
|
|
68
|
-
const VINCENT_DIAMOND_ADDRESSES = {
|
|
69
|
-
[constants_1.LIT_NETWORK.Datil]: '0x78Cd1d270Ff12BA55e98BDff1f3646426E25D932',
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Mapping of network to Vincent Diamond contract address
|
|
73
|
-
* Used to interact with the correct contract based on the network
|
|
74
|
-
*/
|
|
75
|
-
exports.VINCENT_ADDRESSES = {
|
|
76
|
-
[constants_1.LIT_NETWORK.Datil]: {
|
|
77
|
-
AppView: VINCENT_DIAMOND_ADDRESSES.datil,
|
|
78
|
-
PubKeyRouter: '0xF182d6bEf16Ba77e69372dD096D8B70Bc3d5B475',
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Get a contract instance for a specific facet of the Vincent Diamond
|
|
83
|
-
* @param network The network to connect to
|
|
84
|
-
* @param facet The contract facet to use
|
|
85
|
-
* @returns A contract instance for the specified facet
|
|
86
|
-
*/
|
|
87
|
-
function getContract(network, facet) {
|
|
88
|
-
const abi = exports.FACET_ABIS[facet];
|
|
89
|
-
const provider = new ethers_1.ethers.providers.JsonRpcProvider(exports.rpc);
|
|
90
|
-
return new ethers_1.ethers.Contract(exports.VINCENT_ADDRESSES[network][facet], abi, provider);
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=contracts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/utils/contracts.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA6FH,kCAKC;AAhGD,uDAA+D;AAC/D,mCAAgC;AAEhC;;GAEG;AACU,QAAA,GAAG,GAAG,mBAAO,CAAC,qBAAqB,CAAC;AAQpC,QAAA,iBAAiB,GAAG;IAC/B,uEAAuE;IACvE,wEAAwE;CAChE,CAAC;AAEE,QAAA,YAAY,GAAG;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4BI;CACI,CAAC;AAEX;;;GAGG;AACU,QAAA,UAAU,GAAG;IACxB,OAAO,EAAE,oBAAY;IACrB,YAAY,EAAE,yBAAiB;CAChC,CAAC;AAQF;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,CAAC,uBAAW,CAAC,KAAK,CAAC,EAAE,4CAA4C;CACzD,CAAC;AAEX;;;GAGG;AACU,QAAA,iBAAiB,GAAmD;IAC/E,CAAC,uBAAW,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,EAAE,yBAAyB,CAAC,KAAK;QACxC,YAAY,EAAE,4CAA4C;KAC3D;CACO,CAAC;AAEX;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,OAAgB,EAAE,KAAoB;IAChE,MAAM,GAAG,GAAG,kBAAU,CAAC,KAAK,CAAC,CAAC;IAE9B,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,WAAG,CAAC,CAAC;IAC3D,OAAO,IAAI,eAAM,CAAC,QAAQ,CAAC,yBAAiB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC/E,CAAC"}
|
package/dist/src/utils/pkp.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves PKP Eth Address
|
|
4
|
-
*
|
|
5
|
-
* This function queries the PKP Router contract to get the Ethereum address
|
|
6
|
-
* associated with a PKP token ID.
|
|
7
|
-
*
|
|
8
|
-
* @param pkpTokenId - The PKP token ID as ethers.BigNumber
|
|
9
|
-
* @returns The PKP Eth address
|
|
10
|
-
*/
|
|
11
|
-
export declare function getPkpEthAddress(pkpTokenId: ethers.BigNumber): Promise<string>;
|
|
12
|
-
//# sourceMappingURL=pkp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pkp.d.ts","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAIpF"}
|
package/dist/src/utils/pkp.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPkpEthAddress = getPkpEthAddress;
|
|
4
|
-
const constants_1 = require("@lit-protocol/constants");
|
|
5
|
-
const contracts_1 = require("./contracts");
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves PKP Eth Address
|
|
8
|
-
*
|
|
9
|
-
* This function queries the PKP Router contract to get the Ethereum address
|
|
10
|
-
* associated with a PKP token ID.
|
|
11
|
-
*
|
|
12
|
-
* @param pkpTokenId - The PKP token ID as ethers.BigNumber
|
|
13
|
-
* @returns The PKP Eth address
|
|
14
|
-
*/
|
|
15
|
-
async function getPkpEthAddress(pkpTokenId) {
|
|
16
|
-
const pubkeyRouter = (0, contracts_1.getContract)(constants_1.LIT_NETWORK.Datil, 'PubKeyRouter');
|
|
17
|
-
return await pubkeyRouter.getEthAddress(pkpTokenId);
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=pkp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pkp.js","sourceRoot":"","sources":["../../../src/utils/pkp.ts"],"names":[],"mappings":";;AAcA,4CAIC;AAlBD,uDAAsD;AAGtD,2CAA0C;AAE1C;;;;;;;;GAQG;AACI,KAAK,UAAU,gBAAgB,CAAC,UAA4B;IACjE,MAAM,YAAY,GAAG,IAAA,uBAAW,EAAC,uBAAW,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAEpE,OAAO,MAAM,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|