@arcblock/did-connect-js 1.30.0 → 4.0.0-beta.10
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/{lib/adapters/detect.d.cts → dist/adapters/detect.d.ts} +3 -5
- package/dist/adapters/detect.d.ts.map +1 -0
- package/dist/adapters/detect.js +13 -0
- package/dist/adapters/detect.js.map +1 -0
- package/dist/adapters/express.d.ts +40 -0
- package/dist/adapters/express.d.ts.map +1 -0
- package/dist/adapters/express.js +30 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/hono.d.ts +49 -0
- package/dist/adapters/hono.d.ts.map +1 -0
- package/dist/adapters/hono.js +176 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/authenticator/base.d.ts +21 -0
- package/dist/authenticator/base.d.ts.map +1 -0
- package/dist/authenticator/base.js +109 -0
- package/dist/authenticator/base.js.map +1 -0
- package/dist/authenticator/wallet.d.ts +252 -0
- package/dist/authenticator/wallet.d.ts.map +1 -0
- package/dist/authenticator/wallet.js +590 -0
- package/dist/authenticator/wallet.js.map +1 -0
- package/dist/handlers/base.d.ts +25 -0
- package/dist/handlers/base.d.ts.map +1 -0
- package/dist/handlers/base.js +48 -0
- package/dist/handlers/base.js.map +1 -0
- package/dist/handlers/util.d.ts +48 -0
- package/dist/handlers/util.d.ts.map +1 -0
- package/dist/handlers/util.js +805 -0
- package/dist/handlers/util.js.map +1 -0
- package/dist/handlers/wallet.d.ts +96 -0
- package/dist/handlers/wallet.d.ts.map +1 -0
- package/dist/handlers/wallet.js +129 -0
- package/dist/handlers/wallet.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +37 -0
- package/dist/protocol.js.map +1 -0
- package/dist/schema/claims.d.ts +11 -0
- package/dist/schema/claims.d.ts.map +1 -0
- package/dist/schema/claims.js +226 -0
- package/dist/schema/claims.js.map +1 -0
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +89 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/storage/kv.d.ts +31 -0
- package/dist/storage/kv.d.ts.map +1 -0
- package/dist/storage/kv.js +54 -0
- package/dist/storage/kv.js.map +1 -0
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/helpers.d.ts +19 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +77 -0
- package/dist/utils/helpers.js.map +1 -0
- package/package.json +51 -107
- package/LICENSE +0 -13
- package/README.md +0 -210
- package/esm/_virtual/rolldown_runtime.mjs +0 -8
- package/esm/adapters/detect.d.mts +0 -11
- package/esm/adapters/detect.mjs +0 -16
- package/esm/adapters/express.d.mts +0 -48
- package/esm/adapters/express.mjs +0 -39
- package/esm/adapters/hono.d.mts +0 -57
- package/esm/adapters/hono.mjs +0 -164
- package/esm/authenticator/base.d.mts +0 -23
- package/esm/authenticator/base.mjs +0 -88
- package/esm/authenticator/wallet.d.mts +0 -270
- package/esm/authenticator/wallet.mjs +0 -556
- package/esm/did/did-connect/package.mjs +0 -118
- package/esm/handlers/base.d.mts +0 -32
- package/esm/handlers/base.mjs +0 -37
- package/esm/handlers/util.d.mts +0 -70
- package/esm/handlers/util.mjs +0 -739
- package/esm/handlers/wallet.d.mts +0 -120
- package/esm/handlers/wallet.mjs +0 -139
- package/esm/index.d.mts +0 -8
- package/esm/index.mjs +0 -8
- package/esm/node_modules/valibot/dist/index.mjs +0 -736
- package/esm/protocol.d.mts +0 -15
- package/esm/protocol.mjs +0 -40
- package/esm/schema/claims.d.mts +0 -16
- package/esm/schema/claims.mjs +0 -216
- package/esm/schema/index.d.mts +0 -29
- package/esm/schema/index.mjs +0 -75
- package/esm/storage/kv.d.mts +0 -33
- package/esm/storage/kv.mjs +0 -55
- package/esm/types.d.mts +0 -55
- package/esm/types.mjs +0 -1
- package/lib/_virtual/rolldown_runtime.cjs +0 -31
- package/lib/adapters/detect.cjs +0 -18
- package/lib/adapters/express.cjs +0 -41
- package/lib/adapters/express.d.cts +0 -48
- package/lib/adapters/hono.cjs +0 -167
- package/lib/adapters/hono.d.cts +0 -57
- package/lib/authenticator/base.cjs +0 -91
- package/lib/authenticator/base.d.cts +0 -23
- package/lib/authenticator/wallet.cjs +0 -565
- package/lib/authenticator/wallet.d.cts +0 -270
- package/lib/did/did-connect/package.cjs +0 -121
- package/lib/handlers/base.cjs +0 -40
- package/lib/handlers/base.d.cts +0 -32
- package/lib/handlers/util.cjs +0 -759
- package/lib/handlers/util.d.cts +0 -70
- package/lib/handlers/wallet.cjs +0 -139
- package/lib/handlers/wallet.d.cts +0 -119
- package/lib/index.cjs +0 -16
- package/lib/index.d.cts +0 -8
- package/lib/node_modules/valibot/dist/index.cjs +0 -756
- package/lib/protocol.cjs +0 -46
- package/lib/protocol.d.cts +0 -15
- package/lib/schema/claims.cjs +0 -218
- package/lib/schema/claims.d.cts +0 -16
- package/lib/schema/index.cjs +0 -79
- package/lib/schema/index.d.cts +0 -29
- package/lib/storage/kv.cjs +0 -57
- package/lib/storage/kv.d.cts +0 -33
- package/lib/types.cjs +0 -0
- package/lib/types.d.cts +0 -55
package/esm/handlers/base.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { PROTECTED_KEYS } from "../protocol.mjs";
|
|
2
|
-
import { EventEmitter } from "node:events";
|
|
3
|
-
import omit from "lodash/omit.js";
|
|
4
|
-
|
|
5
|
-
//#region src/handlers/base.ts
|
|
6
|
-
var BaseHandler = class extends EventEmitter {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of DID Auth Handlers.
|
|
9
|
-
*
|
|
10
|
-
* @class
|
|
11
|
-
* @param {object} config
|
|
12
|
-
* @param {function} config.pathTransformer - function to transform path when generate action;
|
|
13
|
-
* @param {object} config.tokenStorage - function to generate action token
|
|
14
|
-
* @param {object} config.authenticator - Authenticator instance that can to jwt sign/verify
|
|
15
|
-
* @param {function} [config.onConnect=noop] - function called when wallet selected did
|
|
16
|
-
*/
|
|
17
|
-
constructor({ pathTransformer, tokenStorage, authenticator, onConnect }) {
|
|
18
|
-
super();
|
|
19
|
-
this.authenticator = authenticator;
|
|
20
|
-
this.tokenStorage = tokenStorage;
|
|
21
|
-
this.tokenStorage.on("create", (data) => this.emit("created", data));
|
|
22
|
-
this.tokenStorage.on("destroy", (token) => this.emit("deleted", { token }));
|
|
23
|
-
this.tokenStorage.on("update", async (data) => {
|
|
24
|
-
if (!data) return;
|
|
25
|
-
const payload = await this.tokenStorage.read(data.token);
|
|
26
|
-
this.emit("updated", omit(payload, PROTECTED_KEYS));
|
|
27
|
-
});
|
|
28
|
-
if (typeof pathTransformer === "function") this.pathTransformer = pathTransformer;
|
|
29
|
-
else this.pathTransformer = (v) => v;
|
|
30
|
-
if (typeof onConnect === "function") this.onConnect = onConnect;
|
|
31
|
-
else this.onConnect = () => {};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
var base_default = BaseHandler;
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { base_default as default };
|
package/esm/handlers/util.d.mts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ConnectRequest, ConnectResponse, NextFunction } from "../types.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/handlers/util.d.ts
|
|
4
|
-
declare const errors: Record<string, Record<string, string>>;
|
|
5
|
-
declare const preparePathname: (path: string, req: ConnectRequest) => string;
|
|
6
|
-
declare const prepareBaseUrl: (req: ConnectRequest, params?: Record<string, any>) => string;
|
|
7
|
-
declare const getStepChallenge: () => any;
|
|
8
|
-
declare const parseWalletUA: (userAgent: string) => {
|
|
9
|
-
os: string;
|
|
10
|
-
version: string;
|
|
11
|
-
jwt: string;
|
|
12
|
-
};
|
|
13
|
-
declare const isDeepLink: (str: string) => boolean;
|
|
14
|
-
declare const isConnectedOnly: (params: any, sessionUserDid?: string) => boolean | string;
|
|
15
|
-
interface CreateHandlersOptions {
|
|
16
|
-
action: string;
|
|
17
|
-
pathname: string;
|
|
18
|
-
claims: any;
|
|
19
|
-
onStart: (...args: any[]) => any;
|
|
20
|
-
onConnect: (...args: any[]) => any;
|
|
21
|
-
onAuth: (...args: any[]) => any;
|
|
22
|
-
onDecline: (...args: any[]) => any;
|
|
23
|
-
onComplete: (...args: any[]) => any;
|
|
24
|
-
onExpire: (...args: any[]) => any;
|
|
25
|
-
onError: (...args: any[]) => any;
|
|
26
|
-
pathTransformer: (v: string) => string;
|
|
27
|
-
tokenStorage: any;
|
|
28
|
-
authenticator: any;
|
|
29
|
-
authPrincipal: any;
|
|
30
|
-
persistentDynamicClaims?: boolean;
|
|
31
|
-
getSignParams?: (req: ConnectRequest) => any;
|
|
32
|
-
getPathName?: (pathname: string, req: ConnectRequest) => string;
|
|
33
|
-
options: {
|
|
34
|
-
tokenKey: string;
|
|
35
|
-
encKey: string;
|
|
36
|
-
versionKey: string;
|
|
37
|
-
cleanupDelay: number;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
declare function createHandlers({
|
|
41
|
-
action,
|
|
42
|
-
pathname,
|
|
43
|
-
claims,
|
|
44
|
-
onStart,
|
|
45
|
-
onConnect,
|
|
46
|
-
onAuth,
|
|
47
|
-
onDecline,
|
|
48
|
-
onComplete,
|
|
49
|
-
onExpire,
|
|
50
|
-
onError,
|
|
51
|
-
pathTransformer,
|
|
52
|
-
tokenStorage,
|
|
53
|
-
authenticator,
|
|
54
|
-
authPrincipal,
|
|
55
|
-
persistentDynamicClaims,
|
|
56
|
-
getSignParams,
|
|
57
|
-
getPathName,
|
|
58
|
-
options
|
|
59
|
-
}: CreateHandlersOptions): {
|
|
60
|
-
generateSession: (req: ConnectRequest, res: ConnectResponse) => Promise<void>;
|
|
61
|
-
expireSession: (req: ConnectRequest, res: ConnectResponse) => Promise<void>;
|
|
62
|
-
checkSession: (req: ConnectRequest, res: ConnectResponse) => Promise<void>;
|
|
63
|
-
onAuthRequest: (req: ConnectRequest, res: ConnectResponse) => Promise<void>;
|
|
64
|
-
onAuthResponse: (req: ConnectRequest, res: ConnectResponse) => Promise<void>;
|
|
65
|
-
ensureContext: (req: ConnectRequest, _res: ConnectResponse, next: NextFunction) => Promise<void>;
|
|
66
|
-
ensureSignedJson: (req: ConnectRequest, res: ConnectResponse, next: NextFunction) => void;
|
|
67
|
-
createExtraParams: (locale: string, params: any, extra?: any) => any;
|
|
68
|
-
};
|
|
69
|
-
//#endregion
|
|
70
|
-
export { CreateHandlersOptions, createHandlers as default, errors, getStepChallenge, isConnectedOnly, isDeepLink, parseWalletUA, prepareBaseUrl, preparePathname };
|