@arcblock/did-connect-js 1.29.23 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{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 +221 -0
- package/dist/authenticator/wallet.d.ts.map +1 -0
- package/dist/authenticator/wallet.js +588 -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 +812 -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 +10 -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 +17 -0
- package/dist/schema/claims.d.ts.map +1 -0
- package/dist/schema/claims.js +205 -0
- package/dist/schema/claims.js.map +1 -0
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +49 -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/package.json +48 -104
- 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/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/package.mjs +0 -118
- package/esm/protocol.d.mts +0 -15
- package/esm/protocol.mjs +0 -40
- package/esm/schema/claims.d.mts +0 -18
- package/esm/schema/claims.mjs +0 -154
- package/esm/schema/index.d.mts +0 -9
- package/esm/schema/index.mjs +0 -49
- 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 -564
- package/lib/authenticator/wallet.d.cts +0 -270
- 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/package.cjs +0 -121
- package/lib/protocol.cjs +0 -46
- package/lib/protocol.d.cts +0 -15
- package/lib/schema/claims.cjs +0 -156
- package/lib/schema/claims.d.cts +0 -18
- package/lib/schema/index.cjs +0 -52
- package/lib/schema/index.d.cts +0 -9
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.js","sourceRoot":"","sources":["../../src/schema/claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAItC,MAAM,mBAAmB,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CAChD,GAAG,CAAC,MAAM,CAAC;IACT,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACzB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;SACnB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SAClC,QAAQ,EAAE;CACd,CAAC,EACF,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CACrB,C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,EAAE;YACxE,cAAc,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;YACzE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,mBAAmB;YACnE,QAAQ,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7D,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,qBAAqB;YACzD,QAAQ,EAAE,iBAAiB,EAAE,oBAAoB;YACjD,UAAU,EAAE,iBAAiB,EAAE,qBAAqB;SACrD,CAAC,CACH;aACA,QAAQ,EAAE;aACV,GAAG,CAAC,CAAC,CAAC;QAET,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;KACvC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,OAAO;QACL,aAAa;QACb,OAAO;QACP,SAAS;QACT,SAAS;QACT,SAAS;QACT,oBAAoB;QACpB,KAAK;QACL,SAAS;QACT,OAAO;QACP,aAAa;KACd,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Joi } from '@arcblock/validator';
|
|
2
|
+
type JoiObjectSchema = ReturnType<typeof Joi.object>;
|
|
3
|
+
export declare const chainInfo: JoiObjectSchema;
|
|
4
|
+
export declare const appInfo: JoiObjectSchema;
|
|
5
|
+
export declare const claims: import("./claims.js").ClaimsSchema;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAI1C,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;AAErD,eAAO,MAAM,SAAS,EAAE,eA0B6B,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,eAiBgC,CAAC;AAEvD,eAAO,MAAM,MAAM,oCAAgC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Joi } from '@arcblock/validator';
|
|
2
|
+
import createClaimsSchema from './claims.js';
|
|
3
|
+
export const chainInfo = Joi.object({
|
|
4
|
+
type: Joi.string().optional().valid('arcblock', 'ethereum', 'solona').default('arcblock'),
|
|
5
|
+
id: Joi.any()
|
|
6
|
+
.when('type', { is: 'arcblock', then: Joi.string().optional().default('none') })
|
|
7
|
+
.when('type', {
|
|
8
|
+
is: 'ethereum',
|
|
9
|
+
then: Joi.string()
|
|
10
|
+
.required()
|
|
11
|
+
.pattern(/^[0-9]+$/, 'numbers'),
|
|
12
|
+
})
|
|
13
|
+
.when('type', {
|
|
14
|
+
is: 'solona',
|
|
15
|
+
then: Joi.string()
|
|
16
|
+
.required()
|
|
17
|
+
.pattern(/^[0-9]+$/, 'numbers'),
|
|
18
|
+
}),
|
|
19
|
+
host: Joi.string()
|
|
20
|
+
.when('type', { is: 'ethereum', then: Joi.string().optional().allow('') })
|
|
21
|
+
.when('type', { is: 'solona', then: Joi.string().optional().allow('') })
|
|
22
|
+
.when('type', {
|
|
23
|
+
is: 'arcblock',
|
|
24
|
+
then: Joi.string()
|
|
25
|
+
.uri({ scheme: ['http', 'https'] })
|
|
26
|
+
.allow('none')
|
|
27
|
+
.default('none'),
|
|
28
|
+
}),
|
|
29
|
+
}).options({ stripUnknown: true, noDefaults: false });
|
|
30
|
+
export const appInfo = Joi.object({
|
|
31
|
+
name: Joi.string().required(),
|
|
32
|
+
description: Joi.string().required(),
|
|
33
|
+
icon: Joi.string()
|
|
34
|
+
.uri({ scheme: ['http', 'https'] })
|
|
35
|
+
.required(),
|
|
36
|
+
link: Joi.string()
|
|
37
|
+
.uri({ scheme: ['http', 'https'] })
|
|
38
|
+
.optional(),
|
|
39
|
+
path: Joi.string()
|
|
40
|
+
.uri({ scheme: ['http', 'https'] })
|
|
41
|
+
.default('https://abtwallet.io/i/'),
|
|
42
|
+
publisher: Joi.DID().optional(),
|
|
43
|
+
updateSubEndpoint: Joi.boolean().optional(),
|
|
44
|
+
subscriptionEndpoint: Joi.string().optional(),
|
|
45
|
+
nodeDid: Joi.DID().optional(),
|
|
46
|
+
agentDid: Joi.DID().optional(),
|
|
47
|
+
}).options({ stripUnknown: false, noDefaults: false });
|
|
48
|
+
export const claims = createClaimsSchema(chainInfo);
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,OAAO,kBAAkB,MAAM,aAAa,CAAC;AAI7C,MAAM,CAAC,MAAM,SAAS,GAAoB,GAAG,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IACzF,EAAE,EAAE,GAAG,CAAC,GAAG,EAAE;SACV,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;SAC/E,IAAI,CAAC,MAAM,EAAE;QACZ,EAAE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,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SAClC,QAAQ,EAAE;IACb,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;SACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SAClC,QAAQ,EAAE;IACb,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;SACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;SAClC,OAAO,CAAC,yBAAyB,CAAC;IACrC,SAAS,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC/B,iBAAiB,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC3C,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7C,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
interface KVNamespace {
|
|
3
|
+
get(key: string): Promise<string | null>;
|
|
4
|
+
put(key: string, value: string, options?: {
|
|
5
|
+
expirationTtl?: number;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
delete(key: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
interface CloudflareKVStorageOptions {
|
|
10
|
+
/** TTL in seconds for KV entries. Default: 300 (5 minutes) */
|
|
11
|
+
ttl?: number;
|
|
12
|
+
/** Key prefix for KV entries. Default: '' */
|
|
13
|
+
prefix?: string;
|
|
14
|
+
}
|
|
15
|
+
declare class CloudflareKVStorage extends EventEmitter {
|
|
16
|
+
private kv;
|
|
17
|
+
private ttl;
|
|
18
|
+
private prefix;
|
|
19
|
+
constructor(kv: KVNamespace, options?: CloudflareKVStorageOptions);
|
|
20
|
+
private key;
|
|
21
|
+
create(token: string, status?: string): Promise<{
|
|
22
|
+
token: string;
|
|
23
|
+
status: string;
|
|
24
|
+
}>;
|
|
25
|
+
read(token: string): Promise<any>;
|
|
26
|
+
update(token: string, updates: Record<string, any>): Promise<any>;
|
|
27
|
+
delete(token: string): Promise<void>;
|
|
28
|
+
exist(token: string, did?: string): Promise<boolean>;
|
|
29
|
+
}
|
|
30
|
+
export default CloudflareKVStorage;
|
|
31
|
+
//# sourceMappingURL=kv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kv.d.ts","sourceRoot":"","sources":["../../src/storage/kv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,UAAU,WAAW;IACnB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,UAAU,0BAA0B;IAClC,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,mBAAoB,SAAQ,YAAY;IAC5C,OAAO,CAAC,EAAE,CAAc;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,MAAM,CAAS;gBAEX,EAAE,EAAE,WAAW,EAAE,OAAO,GAAE,0BAA+B;IAOrE,OAAO,CAAC,GAAG;IAIL,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAY;;;;IAOxC,IAAI,CAAC,KAAK,EAAE,MAAM;IAMlB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAWlD,MAAM,CAAC,KAAK,EAAE,MAAM;IAQpB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;CAMxC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
class CloudflareKVStorage extends EventEmitter {
|
|
3
|
+
kv;
|
|
4
|
+
ttl;
|
|
5
|
+
prefix;
|
|
6
|
+
constructor(kv, options = {}) {
|
|
7
|
+
super();
|
|
8
|
+
this.kv = kv;
|
|
9
|
+
this.ttl = options.ttl ?? 300;
|
|
10
|
+
this.prefix = options.prefix ?? '';
|
|
11
|
+
}
|
|
12
|
+
key(token) {
|
|
13
|
+
return `${this.prefix}${token}`;
|
|
14
|
+
}
|
|
15
|
+
async create(token, status = 'created') {
|
|
16
|
+
const record = { token, status };
|
|
17
|
+
await this.kv.put(this.key(token), JSON.stringify(record), { expirationTtl: this.ttl });
|
|
18
|
+
this.emit('create', record);
|
|
19
|
+
return record;
|
|
20
|
+
}
|
|
21
|
+
async read(token) {
|
|
22
|
+
const raw = await this.kv.get(this.key(token));
|
|
23
|
+
if (!raw)
|
|
24
|
+
return null;
|
|
25
|
+
return JSON.parse(raw);
|
|
26
|
+
}
|
|
27
|
+
async update(token, updates) {
|
|
28
|
+
const existing = await this.read(token);
|
|
29
|
+
if (!existing)
|
|
30
|
+
return null;
|
|
31
|
+
delete updates.token; // prevent token field overwrite
|
|
32
|
+
const merged = { ...existing, ...updates };
|
|
33
|
+
await this.kv.put(this.key(token), JSON.stringify(merged), { expirationTtl: this.ttl });
|
|
34
|
+
this.emit('update', merged);
|
|
35
|
+
return merged;
|
|
36
|
+
}
|
|
37
|
+
async delete(token) {
|
|
38
|
+
const existing = await this.read(token);
|
|
39
|
+
if (existing) {
|
|
40
|
+
this.emit('destroy', existing);
|
|
41
|
+
}
|
|
42
|
+
await this.kv.delete(this.key(token));
|
|
43
|
+
}
|
|
44
|
+
async exist(token, did) {
|
|
45
|
+
const record = await this.read(token);
|
|
46
|
+
if (!record)
|
|
47
|
+
return false;
|
|
48
|
+
if (did)
|
|
49
|
+
return record.did === did;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export default CloudflareKVStorage;
|
|
54
|
+
//# sourceMappingURL=kv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kv.js","sourceRoot":"","sources":["../../src/storage/kv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAetC,MAAM,mBAAoB,SAAQ,YAAY;IACpC,EAAE,CAAc;IAChB,GAAG,CAAS;IACZ,MAAM,CAAS;IAEvB,YAAY,EAAe,EAAE,UAAsC,EAAE;QACnE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IACrC,CAAC;IAEO,GAAG,CAAC,KAAa;QACvB,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,MAAM,GAAG,SAAS;QAC5C,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,CAAC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AQ,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC;QACD,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,GAAY;QACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAC1B,IAAI,GAAG;YAAE,OAAO,MAAM,CAAC,GAAG,KAAK,GAAG,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,eAAe,mBAAmB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-agnostic request interface for DID Connect handlers.
|
|
3
|
+
*
|
|
4
|
+
* Designed to match Express's `req` shape so that Express requests
|
|
5
|
+
* satisfy it natively (zero-wrapping). Hono adapter creates a wrapper
|
|
6
|
+
* that maps Hono Context to this interface.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConnectRequest {
|
|
9
|
+
/** Parsed request body (from body-parser or Hono) */
|
|
10
|
+
body: Record<string, any>;
|
|
11
|
+
/** Parsed query string parameters */
|
|
12
|
+
query: Record<string, any>;
|
|
13
|
+
/** URL path parameters (e.g. :action) */
|
|
14
|
+
params: Record<string, any>;
|
|
15
|
+
/** Raw request headers */
|
|
16
|
+
headers: Record<string, string | string[] | undefined>;
|
|
17
|
+
/** Parsed cookies (from cookie-parser or manual parsing) */
|
|
18
|
+
cookies: Record<string, string>;
|
|
19
|
+
/** Request protocol ('http' or 'https') */
|
|
20
|
+
protocol: string;
|
|
21
|
+
/** Full original URL including query string */
|
|
22
|
+
originalUrl: string;
|
|
23
|
+
/** Session context, populated by ensureContext middleware */
|
|
24
|
+
context?: any;
|
|
25
|
+
/** Flag to prevent double monkey-patching in ensureSignedJson */
|
|
26
|
+
ensureSignedJson?: boolean;
|
|
27
|
+
/** Case-insensitive header getter (matches Express req.get) */
|
|
28
|
+
get(name: string): string | undefined;
|
|
29
|
+
/** Content negotiation for locale (matches Express req.acceptsLanguages) */
|
|
30
|
+
acceptsLanguages(...languages: string[]): string | false;
|
|
31
|
+
/** Original framework-specific request object (Express req or Hono Context) */
|
|
32
|
+
raw?: any;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Framework-agnostic response interface for DID Connect handlers.
|
|
36
|
+
*
|
|
37
|
+
* Express: maps directly to res.jsonp/res.json/res.status().json().
|
|
38
|
+
* Hono: uses a buffer pattern — calls are captured, then the outer
|
|
39
|
+
* Hono handler reads the buffer to return c.json().
|
|
40
|
+
*/
|
|
41
|
+
export interface ConnectResponse {
|
|
42
|
+
/** Send JSON response (Express JSONP, Hono json) */
|
|
43
|
+
jsonp(data: any): void;
|
|
44
|
+
/** Send JSON response */
|
|
45
|
+
json(data: any): void;
|
|
46
|
+
/** Set status code and return object with json() method */
|
|
47
|
+
status(code: number): {
|
|
48
|
+
json(data: any): void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Middleware next() callback */
|
|
52
|
+
export type NextFunction = () => void;
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IAEpB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtC,4EAA4E;IAC5E,gBAAgB,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC;IAEzD,+EAA+E;IAC/E,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACvB,yBAAyB;IACzB,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACtB,2DAA2D;IAC3D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAA;KAAE,CAAC;CACjD;AAED,iCAAiC;AACjC,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,126 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-connect-js",
|
|
3
|
-
"
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
|
+
"description": "Server-side DID Connect protocol — WalletAuthenticator, WalletHandlers, framework adapters",
|
|
4
5
|
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./storage/kv": {
|
|
14
|
+
"types": "./dist/storage/kv.d.ts",
|
|
15
|
+
"import": "./dist/storage/kv.js"
|
|
16
|
+
},
|
|
17
|
+
"./schema": {
|
|
18
|
+
"types": "./dist/schema/index.d.ts",
|
|
19
|
+
"import": "./dist/schema/index.js"
|
|
20
|
+
}
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@arcblock/did": "1.29.23",
|
|
23
|
-
"@arcblock/jwt": "1.29.23",
|
|
24
|
-
"@arcblock/validator": "1.29.23",
|
|
25
|
-
"@ocap/client": "1.29.23",
|
|
26
|
-
"@ocap/mcrypto": "1.29.23",
|
|
27
|
-
"@ocap/util": "1.29.23",
|
|
28
|
-
"@ocap/wallet": "1.29.23",
|
|
29
|
-
"cors": "^2.8.5",
|
|
23
|
+
"@arcblock/did": "^1.29.23",
|
|
24
|
+
"@arcblock/jwt": "^1.29.23",
|
|
25
|
+
"@arcblock/validator": "^1.29.23",
|
|
26
|
+
"@ocap/client": "^1.29.23",
|
|
27
|
+
"@ocap/mcrypto": "^1.29.23",
|
|
28
|
+
"@ocap/util": "^1.29.23",
|
|
29
|
+
"@ocap/wallet": "^1.29.23",
|
|
30
30
|
"debug": "^4.4.3",
|
|
31
31
|
"json-stable-stringify": "^1.0.1",
|
|
32
32
|
"lodash": "^4.17.23",
|
|
33
|
-
"tweetnacl-sealedbox-js": "^1.2.0"
|
|
33
|
+
"tweetnacl-sealedbox-js": "^1.2.0",
|
|
34
|
+
"@arcblock/did-connect-core": "^4.0.0-beta.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@arcblock/did-agent-storage-memory": "^1.8.0",
|
|
37
38
|
"@arcblock/did-connect-storage-memory": "^1.8.0",
|
|
38
|
-
"@
|
|
39
|
-
"@types/
|
|
39
|
+
"@types/body-parser": "^1.19.6",
|
|
40
|
+
"@types/cookie-parser": "^1.4.10",
|
|
40
41
|
"@types/debug": "^4.1.12",
|
|
42
|
+
"@types/express": "^5.0.6",
|
|
41
43
|
"@types/json-stable-stringify": "^1.0.36",
|
|
42
44
|
"@types/lodash": "^4.17.13",
|
|
43
|
-
"@types/node": "^
|
|
45
|
+
"@types/node": "^25.5.0",
|
|
46
|
+
"@types/pify": "^6.1.0",
|
|
44
47
|
"axios": "^1.13.4",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
48
|
+
"body-parser": "^2.2.2",
|
|
49
|
+
"cookie-parser": "^1.4.7",
|
|
50
|
+
"express": "^5.2.1",
|
|
47
51
|
"hono": "^4.7.0",
|
|
48
|
-
"
|
|
49
|
-
"tweetnacl": "^1.0.3"
|
|
50
|
-
|
|
51
|
-
"remarkConfig": {
|
|
52
|
-
"plugins": [
|
|
53
|
-
"preset-github",
|
|
54
|
-
[
|
|
55
|
-
{
|
|
56
|
-
"repository": "ArcBlock/blockchain"
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
"homepage": "https://www.arcblock.io/docs/did-connect-sdk",
|
|
62
|
-
"keywords": [
|
|
63
|
-
"blockchain",
|
|
64
|
-
"arcblock",
|
|
65
|
-
"sdk",
|
|
66
|
-
"nodejs"
|
|
67
|
-
],
|
|
68
|
-
"license": "Apache-2.0",
|
|
69
|
-
"sideEffects": false,
|
|
70
|
-
"main": "./lib/index.cjs",
|
|
71
|
-
"module": "./esm/index.mjs",
|
|
72
|
-
"types": "./esm/index.d.mts",
|
|
73
|
-
"exports": {
|
|
74
|
-
".": {
|
|
75
|
-
"types": "./esm/index.d.mts",
|
|
76
|
-
"import": "./esm/index.mjs",
|
|
77
|
-
"default": "./lib/index.cjs"
|
|
78
|
-
},
|
|
79
|
-
"./lib/schema": {
|
|
80
|
-
"types": "./esm/schema/index.d.mts",
|
|
81
|
-
"import": "./esm/schema/index.mjs",
|
|
82
|
-
"default": "./lib/schema/index.cjs"
|
|
83
|
-
},
|
|
84
|
-
"./lib/schema/*": {
|
|
85
|
-
"types": "./esm/schema/*.d.mts",
|
|
86
|
-
"import": "./esm/schema/*.mjs",
|
|
87
|
-
"default": "./lib/schema/*.cjs"
|
|
88
|
-
},
|
|
89
|
-
"./lib/*.js": {
|
|
90
|
-
"types": "./esm/*.d.mts",
|
|
91
|
-
"import": "./esm/*.mjs",
|
|
92
|
-
"default": "./lib/*.cjs"
|
|
93
|
-
},
|
|
94
|
-
"./lib/*": {
|
|
95
|
-
"types": "./esm/*.d.mts",
|
|
96
|
-
"import": "./esm/*.mjs",
|
|
97
|
-
"default": "./lib/*.cjs"
|
|
98
|
-
}
|
|
52
|
+
"pify": "^6.1.0",
|
|
53
|
+
"tweetnacl": "^1.0.3",
|
|
54
|
+
"vitest": "^4.1.1"
|
|
99
55
|
},
|
|
100
56
|
"files": [
|
|
101
|
-
"
|
|
102
|
-
"esm"
|
|
57
|
+
"dist"
|
|
103
58
|
],
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"url": "https://github.com/ArcBlock/blockchain/tree/master/did/did-connect"
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
107
61
|
},
|
|
62
|
+
"license": "Apache-2.0",
|
|
108
63
|
"scripts": {
|
|
109
|
-
"
|
|
110
|
-
"lint
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"test": "bun test",
|
|
117
|
-
"coverage": "npm run test -- --coverage",
|
|
118
|
-
"build": "tsdown",
|
|
119
|
-
"build:watch": "tsdown -w",
|
|
120
|
-
"clean": "rm -rf lib esm"
|
|
121
|
-
},
|
|
122
|
-
"resolutions": {
|
|
123
|
-
"tweetnacl": "1.0.3"
|
|
124
|
-
},
|
|
125
|
-
"gitHead": "87990c8b5e215107fc587c1ced0d6b3e2cd2483e"
|
|
126
|
-
}
|
|
64
|
+
"build": "tsc",
|
|
65
|
+
"lint": "biome check src/",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"test:coverage": "vitest run --coverage",
|
|
68
|
+
"typecheck": "tsc --noEmit"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Copyright 2018-2025 ArcBlock
|
|
2
|
-
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
6
|
-
|
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
See the License for the specific language governing permissions and
|
|
13
|
-
limitations under the License.
|
package/README.md
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
[](https://docs.arcblock.io)
|
|
4
|
-
[](https://gitter.im/ArcBlock/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
5
|
-
|
|
6
|
-
## Overview
|
|
7
|
-
|
|
8
|
-
This library is implemented according to [ABT-DID-Protocol](https://github.com/ArcBlock/abt-did-spec), aiming to make it easier for developers to handle customized DID Connect Sessions in Node.js applications, and should always be used together with [DID Connect UX package](https://www.npmjs.com/package/@arcblock/did-connect), if you are composing a blocklet, you may find the wrapped implementation in [Blocklet SDK](https://www.npmjs.com/package/@blocklet/sdk) more useful.
|
|
9
|
-
|
|
10
|
-
Within a typical DID Connect Session, the application may request user to sign a transaction or provide some information, such as:
|
|
11
|
-
|
|
12
|
-
- Provide a user profile, which may contain name, email
|
|
13
|
-
- Prove ownership of a NFT
|
|
14
|
-
- Prove ownership of a passport
|
|
15
|
-
|
|
16
|
-
The following diagram demonstrates how a typical DID Connect Session works:
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
`Claim` is the key concept in DID Connect Session, its used by the application to send specification of required info to finish the session. A claim is identified by `type`, and defined with a set of properties. Checkout the claim section for more information.
|
|
21
|
-
|
|
22
|
-
## Install
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
npm install @arcblock/did-connect-js
|
|
26
|
-
// or
|
|
27
|
-
bun install @arcblock/did-connect-js
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
### Basic Usage
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
const SimpleStorage = require('@arcblock/did-connect-storage-nedb');
|
|
36
|
-
const { fromRandom } = require('@ocap/wallet');
|
|
37
|
-
const { WalletAuthenticator, WalletHandlers } = require('@arcblock/did-connect-js');
|
|
38
|
-
|
|
39
|
-
// First setup authenticator and handler factory
|
|
40
|
-
const wallet = fromRandom();
|
|
41
|
-
const authenticator = new WalletAuthenticator({
|
|
42
|
-
wallet,
|
|
43
|
-
baseUrl: 'http://wangshijun.natapp1.cc',
|
|
44
|
-
appInfo: {
|
|
45
|
-
description: 'Starter projects to develop web application on forge',
|
|
46
|
-
icon: '/images/logo@2x.png',
|
|
47
|
-
name: 'Forge Web Starter',
|
|
48
|
-
},
|
|
49
|
-
chainInfo: {
|
|
50
|
-
host: 'http://did-workshop.arcblock.co:8210/api',
|
|
51
|
-
id: 'forge',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const handlers = new WalletHandlers({
|
|
56
|
-
authenticator,
|
|
57
|
-
tokenStorage: new SimpleStorage({ dbPath: '/tmp/test/auth.db' }),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Then attach handler to express server
|
|
61
|
-
const express = require('express');
|
|
62
|
-
const app = express();
|
|
63
|
-
|
|
64
|
-
// This is required if you want to use dynamic baseUrl inference
|
|
65
|
-
app.set('trust proxy', true);
|
|
66
|
-
|
|
67
|
-
handlers.attach({
|
|
68
|
-
action: 'profile',
|
|
69
|
-
claims: {
|
|
70
|
-
// This function can be async or returns a promise
|
|
71
|
-
profile: () => ({
|
|
72
|
-
fields: ['fullName', 'email'],
|
|
73
|
-
description: 'Please provide your name and email to continue',
|
|
74
|
-
}),
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
onAuth: async ({ userDid, claims, extraParams }) => {
|
|
78
|
-
// `userDid` is the current connected did
|
|
79
|
-
// `claims` contains what the user has submitted
|
|
80
|
-
// `extraParams` is set from webapp when creating the session
|
|
81
|
-
try {
|
|
82
|
-
const profile = claims.find((x) => x.type === 'profile');
|
|
83
|
-
console.info('login.success', { userDid, profile });
|
|
84
|
-
} catch (err) {
|
|
85
|
-
console.error('login.error', err);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Then your application backend is ready to handle DID Connect Session that request and accept profile from user. For frontend integration please checkout [DID Connect UX](https://www.npmjs.com/package/@arcblock/did-connect).
|
|
92
|
-
|
|
93
|
-
### Multiple Claims
|
|
94
|
-
|
|
95
|
-
You can request multiple claims in a single DID Connect Session:
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
handlers.attach({
|
|
99
|
-
action: 'multiple-claims',
|
|
100
|
-
claims: {
|
|
101
|
-
profile: () => ({
|
|
102
|
-
fields: ['fullName', 'email'],
|
|
103
|
-
description: 'Please provide your name and email to continue',
|
|
104
|
-
}),
|
|
105
|
-
asset: ({ userDid, extraParams }) => {
|
|
106
|
-
// `userDid` is the current connected did
|
|
107
|
-
// `extraParams` is set from webapp when creating the session
|
|
108
|
-
return {
|
|
109
|
-
description: 'Please provide a valid NFT',
|
|
110
|
-
trustedIssuers: ['nft-issuer-did'],
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
onAuth: async ({ claims, userDid }) => {
|
|
115
|
-
// `claims` contains both the profile and the asset claim
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
If you want to provide multiple claims of the same type:
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
handlers.attach({
|
|
124
|
-
action: 'multiple-claims',
|
|
125
|
-
claims: {
|
|
126
|
-
signText: [
|
|
127
|
-
'signature',
|
|
128
|
-
{
|
|
129
|
-
type: 'mime:text/plain',
|
|
130
|
-
data: 'xxxx',
|
|
131
|
-
description: 'sign the text to continue',
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
signHtml: [
|
|
135
|
-
'signature',
|
|
136
|
-
{
|
|
137
|
-
type: 'mime:text/html',
|
|
138
|
-
data: `<h2>This is title</h2>`,
|
|
139
|
-
description: 'sign the html to continue',
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
onAuth: async ({ claims, userDid }) => {
|
|
144
|
-
// `claims` contains both the profile and the asset claim
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Dynamic Claims
|
|
150
|
-
|
|
151
|
-
By returning a claims object from `onConnect` callback, you can provide dynamic claims for the DID Connect Session.
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
handlers.attach({
|
|
155
|
-
action: 'dynamic-claims',
|
|
156
|
-
|
|
157
|
-
// Can be async or returns a promise
|
|
158
|
-
onConnect: ({ userDid }) => {
|
|
159
|
-
// check userDid for some business logic
|
|
160
|
-
// then return the claim object
|
|
161
|
-
// you can return multiple claims here
|
|
162
|
-
return {
|
|
163
|
-
profile: () => ({
|
|
164
|
-
fields: ['fullName', 'email'],
|
|
165
|
-
description: 'Please provide your name and email to continue',
|
|
166
|
-
}),
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
onAuth: async ({ claims, userDid }) => {
|
|
171
|
-
// `claims` now contains the result for the dynamic claim
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Lifecycle Callbacks
|
|
177
|
-
|
|
178
|
-
Following callbacks are supported during the lifecycle of a DID-Connect session.
|
|
179
|
-
|
|
180
|
-
- `onStart({ req, challenge, didwallet, extraParams, updateSession })`: optional, called when a new session starts, can be async, return values from this callback will be returned to and available from browser, error thrown from `onStart` will halt the session.
|
|
181
|
-
- `onConnect({ req, challenge, userDid, userPk, extraParams, updateSession })`: optional, when wallet has selected `userDid` and `userPk`, you can return dynamic claims here, or do some permission check, error thrown from `onConnect` will halt the session.
|
|
182
|
-
- `onDecline({ req, challenge, userDid, userPk, extraParams, updateSession })`: optional, when wallet has rejected dapp request.
|
|
183
|
-
- `onAuth({ req, challenge, claims, userDid, userPk, extraParams, updateSession })`: required, when wallet has approved dapp request, and submitted info will be available in claims, which is a list of the dapp requested info.
|
|
184
|
-
- `onComplete({ req, userDid, userPk, extraParams, updateSession })`: optional, when the did connect session has completed.
|
|
185
|
-
- `onExpire({ extraParams })`: optional, when the did connect session has expired.
|
|
186
|
-
- `onError({ err, extraParams })`: optional, when the did connect session encountered some error, default to `console.error`.
|
|
187
|
-
|
|
188
|
-
Most commonly used callbacks are `onConnect` and `onAuth`.
|
|
189
|
-
|
|
190
|
-
Developer should always attach an `onAuth` callback for a DID Connect session handler. And put the business logic once user has approved and submitted the requested info in the callback.
|
|
191
|
-
|
|
192
|
-
Sometimes, developer may want to pass some information to the session storage, such as a transaction hash or login token, so that the browser can fetch for later use, developer can achieve this by call `updateSession` from `onAuth`. eg,
|
|
193
|
-
|
|
194
|
-
```js
|
|
195
|
-
handlers.attach({
|
|
196
|
-
action: 'dynamic-claims',
|
|
197
|
-
|
|
198
|
-
onAuth: ({ userDid, updateSession }) => {
|
|
199
|
-
// to persist plain non-sensible info
|
|
200
|
-
await updateSession({ key: 'non-sensible' });
|
|
201
|
-
|
|
202
|
-
// to persist sensible info: that need to be encrypted
|
|
203
|
-
await updateSession({ key: 'sensible' }, true);
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## Claims
|
|
209
|
-
|
|
210
|
-
A `claim` specifies what kind of information the application can request user to provide. specifications for each claim are defined [here](./lib/schema/claims.js), complete claim request and response specification can be found in the [ABT DID Protocol](https://github.com/ArcBlock/ABT-DID-Protocol).
|