@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/lib/protocol.cjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let _ocap_util = require("@ocap/util");
|
|
3
|
-
let _arcblock_jwt = require("@arcblock/jwt");
|
|
4
|
-
let _ocap_mcrypto_lib_crypter_aes = require("@ocap/mcrypto/lib/crypter/aes");
|
|
5
|
-
_ocap_mcrypto_lib_crypter_aes = require_rolldown_runtime.__toESM(_ocap_mcrypto_lib_crypter_aes);
|
|
6
|
-
|
|
7
|
-
//#region src/protocol.ts
|
|
8
|
-
const VERSION = "1.0.0";
|
|
9
|
-
const decrypt = (data, config = {}, dataKey = "userInfo") => {
|
|
10
|
-
try {
|
|
11
|
-
(0, _arcblock_jwt.decode)(data[dataKey]);
|
|
12
|
-
return data;
|
|
13
|
-
} catch {}
|
|
14
|
-
if (config.sharedKey && data.version === VERSION) data[dataKey] = _ocap_mcrypto_lib_crypter_aes.default.decrypt((0, _ocap_util.fromBase58)(data[dataKey]), config.sharedKey, "buffer").toString("utf8");
|
|
15
|
-
return data;
|
|
16
|
-
};
|
|
17
|
-
const encrypt = (data, config = {}, dataKey = "authInfo") => {
|
|
18
|
-
const { clientVersion, sharedKey } = config || {};
|
|
19
|
-
if (data.sensitive && sharedKey && clientVersion === VERSION) {
|
|
20
|
-
data.version = VERSION;
|
|
21
|
-
data[dataKey] = _ocap_mcrypto_lib_crypter_aes.default.encrypt(data[dataKey], sharedKey, "base58");
|
|
22
|
-
}
|
|
23
|
-
delete data.sensitive;
|
|
24
|
-
return data;
|
|
25
|
-
};
|
|
26
|
-
const PROTECTED_KEYS = [
|
|
27
|
-
"challenge",
|
|
28
|
-
"nonce",
|
|
29
|
-
"sharedKey",
|
|
30
|
-
"encryptionKey"
|
|
31
|
-
];
|
|
32
|
-
const SESSION_STATUS = {
|
|
33
|
-
CREATED: "created",
|
|
34
|
-
SUCCEED: "succeed",
|
|
35
|
-
ERROR: "error",
|
|
36
|
-
BUSY: "busy",
|
|
37
|
-
SCANNED: "scanned",
|
|
38
|
-
FORBIDDEN: "forbidden"
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
exports.PROTECTED_KEYS = PROTECTED_KEYS;
|
|
43
|
-
exports.SESSION_STATUS = SESSION_STATUS;
|
|
44
|
-
exports.VERSION = VERSION;
|
|
45
|
-
exports.decrypt = decrypt;
|
|
46
|
-
exports.encrypt = encrypt;
|
package/lib/protocol.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/protocol.d.ts
|
|
2
|
-
declare const VERSION = "1.0.0";
|
|
3
|
-
declare const decrypt: (data: any, config?: any, dataKey?: string) => any;
|
|
4
|
-
declare const encrypt: (data: any, config?: any, dataKey?: string) => any;
|
|
5
|
-
declare const PROTECTED_KEYS: string[];
|
|
6
|
-
declare const SESSION_STATUS: {
|
|
7
|
-
readonly CREATED: "created";
|
|
8
|
-
readonly SUCCEED: "succeed";
|
|
9
|
-
readonly ERROR: "error";
|
|
10
|
-
readonly BUSY: "busy";
|
|
11
|
-
readonly SCANNED: "scanned";
|
|
12
|
-
readonly FORBIDDEN: "forbidden";
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { PROTECTED_KEYS, SESSION_STATUS, VERSION, decrypt, encrypt };
|
package/lib/schema/claims.cjs
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const require_index = require('../node_modules/valibot/dist/index.cjs');
|
|
4
|
-
let _arcblock_validator = require("@arcblock/validator");
|
|
5
|
-
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
6
|
-
|
|
7
|
-
//#region src/schema/claims.ts
|
|
8
|
-
const trustedIssuerSchema = require_index.union([require_index.object({
|
|
9
|
-
did: (0, _arcblock_validator.vDID)(),
|
|
10
|
-
endpoint: require_index.pipe(require_index.string(), require_index.check((s) => {
|
|
11
|
-
try {
|
|
12
|
-
const url = new URL(s);
|
|
13
|
-
return ["http:", "https:"].includes(url.protocol);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}, "Must be a valid HTTP/HTTPS URL"))
|
|
18
|
-
}), (0, _arcblock_validator.vDID)()]);
|
|
19
|
-
const optionalUrlSchema = require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => {
|
|
20
|
-
if (s === "") return true;
|
|
21
|
-
try {
|
|
22
|
-
const url = new URL(s);
|
|
23
|
-
return ["http:", "https:"].includes(url.protocol);
|
|
24
|
-
} catch {
|
|
25
|
-
return s.startsWith("/");
|
|
26
|
-
}
|
|
27
|
-
}, "Must be a valid URL")), "");
|
|
28
|
-
const requirementSchema = require_index.object({
|
|
29
|
-
tokens: require_index.array(require_index.object({
|
|
30
|
-
address: (0, _arcblock_validator.vDID)(),
|
|
31
|
-
value: (0, _arcblock_validator.vBNPositive)()
|
|
32
|
-
})),
|
|
33
|
-
assets: require_index.optional(require_index.object({
|
|
34
|
-
address: require_index.optional(require_index.array((0, _arcblock_validator.vDID)())),
|
|
35
|
-
parent: require_index.optional(require_index.array((0, _arcblock_validator.vDID)())),
|
|
36
|
-
issuer: require_index.optional(require_index.array((0, _arcblock_validator.vDID)())),
|
|
37
|
-
amount: require_index.optional(require_index.pipe(require_index.number(), require_index.check((n) => n > 0, "Must be positive"), require_index.minValue(1)))
|
|
38
|
-
}))
|
|
39
|
-
});
|
|
40
|
-
const targetTypeSchema = require_index.optional(require_index.object({
|
|
41
|
-
key: require_index.optional(require_index.picklist(Object.keys(_ocap_mcrypto.types.KeyType).map((x) => x.toLowerCase())), "ed25519"),
|
|
42
|
-
hash: require_index.optional(require_index.picklist(Object.keys(_ocap_mcrypto.types.HashType).map((x) => x.toLowerCase())), "sha3"),
|
|
43
|
-
role: require_index.optional(require_index.picklist(Object.keys(_ocap_mcrypto.types.RoleType).map((x) => x.toLowerCase().split("_").pop())), "account"),
|
|
44
|
-
encoding: require_index.optional(require_index.picklist(Object.keys(_ocap_mcrypto.types.EncodingType).map((x) => x.toLowerCase())), "base58")
|
|
45
|
-
}));
|
|
46
|
-
var claims_default = (chainInfo) => {
|
|
47
|
-
const createStandardFields = (type, description) => ({
|
|
48
|
-
type: require_index.optional(require_index.literal(type), type),
|
|
49
|
-
description: require_index.optional(require_index.pipe(require_index.string(), require_index.minLength(1)), description),
|
|
50
|
-
chainInfo: require_index.optional(chainInfo),
|
|
51
|
-
mfaCode: require_index.optional(require_index.array(require_index.optional(require_index.pipe(require_index.number(), require_index.minValue(10), require_index.maxValue(99)))), []),
|
|
52
|
-
meta: require_index.optional(require_index.any(), {})
|
|
53
|
-
});
|
|
54
|
-
const authPrincipal = require_index.object({
|
|
55
|
-
...createStandardFields("authPrincipal", "Please continue with your account"),
|
|
56
|
-
target: require_index.optional(require_index.union([require_index.literal(""), (0, _arcblock_validator.vDID)()]), ""),
|
|
57
|
-
supervised: require_index.optional(require_index.boolean(), false),
|
|
58
|
-
targetType: targetTypeSchema
|
|
59
|
-
});
|
|
60
|
-
const keyPair = require_index.object({
|
|
61
|
-
...createStandardFields("keyPair", "Please create account to continue."),
|
|
62
|
-
moniker: require_index.pipe(require_index.string(), require_index.regex(/^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/)),
|
|
63
|
-
declare: require_index.optional(require_index.boolean(), true),
|
|
64
|
-
migrateFrom: require_index.optional(require_index.union([require_index.literal(""), (0, _arcblock_validator.vDID)()]), ""),
|
|
65
|
-
targetType: targetTypeSchema
|
|
66
|
-
});
|
|
67
|
-
const encryptionKey = require_index.object({
|
|
68
|
-
...createStandardFields("encryptionKey", "Please provide encryptionKey to continue."),
|
|
69
|
-
salt: require_index.string(),
|
|
70
|
-
delegation: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), "")
|
|
71
|
-
});
|
|
72
|
-
const profileItemValues = [
|
|
73
|
-
"did",
|
|
74
|
-
"fullName",
|
|
75
|
-
"email",
|
|
76
|
-
"phone",
|
|
77
|
-
"signature",
|
|
78
|
-
"avatar",
|
|
79
|
-
"birthday",
|
|
80
|
-
"url"
|
|
81
|
-
];
|
|
82
|
-
const profile = require_index.pipe(require_index.looseObject({ ...createStandardFields("profile", "Please provide your profile to continue.") }), require_index.transform((obj) => {
|
|
83
|
-
const { fields, ...rest } = obj;
|
|
84
|
-
if (fields !== void 0) return {
|
|
85
|
-
...rest,
|
|
86
|
-
items: fields
|
|
87
|
-
};
|
|
88
|
-
return rest;
|
|
89
|
-
}), require_index.rawTransform(({ dataset, addIssue, NEVER }) => {
|
|
90
|
-
const obj = dataset.value;
|
|
91
|
-
const items = obj.items ?? ["fullName"];
|
|
92
|
-
if (!Array.isArray(items) || items.length < 1) {
|
|
93
|
-
addIssue({ message: "\"items\" must contain at least 1 items" });
|
|
94
|
-
return NEVER;
|
|
95
|
-
}
|
|
96
|
-
const validSet = new Set(profileItemValues);
|
|
97
|
-
for (let i = 0; i < items.length; i++) if (!validSet.has(items[i])) {
|
|
98
|
-
addIssue({ message: `"items[${i}]" must be one of [${[...profileItemValues].join(", ")}]` });
|
|
99
|
-
return NEVER;
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
...obj,
|
|
103
|
-
items
|
|
104
|
-
};
|
|
105
|
-
}));
|
|
106
|
-
const signature = require_index.object({
|
|
107
|
-
...createStandardFields("signature", "Sign this transaction or message to continue."),
|
|
108
|
-
typeUrl: require_index.picklist([
|
|
109
|
-
"fg:x:delegation",
|
|
110
|
-
"fg:t:transaction",
|
|
111
|
-
"mime:text/plain",
|
|
112
|
-
"mime:text/html",
|
|
113
|
-
"eth:transaction",
|
|
114
|
-
"eth:standard-data",
|
|
115
|
-
"eth:personal-data",
|
|
116
|
-
"eth:typed-data",
|
|
117
|
-
"eth:legacy-data"
|
|
118
|
-
]),
|
|
119
|
-
display: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
120
|
-
method: require_index.optional(require_index.picklist(["none", ...Object.keys(_ocap_mcrypto.types.HashType).map((x) => x.toLowerCase())]), "sha3"),
|
|
121
|
-
digest: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
122
|
-
origin: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
123
|
-
nonce: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
124
|
-
requirement: require_index.optional(requirementSchema)
|
|
125
|
-
});
|
|
126
|
-
const prepareTx = require_index.object({
|
|
127
|
-
...createStandardFields("prepareTx", "Prepare and sign this transaction to continue."),
|
|
128
|
-
display: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
129
|
-
partialTx: require_index.string(),
|
|
130
|
-
nonce: require_index.optional(require_index.union([require_index.literal(""), require_index.string()]), ""),
|
|
131
|
-
requirement: requirementSchema
|
|
132
|
-
});
|
|
133
|
-
const agreement = require_index.object({
|
|
134
|
-
...createStandardFields("agreement", "Confirm your agreement to continue."),
|
|
135
|
-
uri: require_index.union([require_index.literal(""), require_index.pipe(require_index.string(), require_index.check((s) => {
|
|
136
|
-
try {
|
|
137
|
-
const url = new URL(s);
|
|
138
|
-
return ["http:", "https:"].includes(url.protocol);
|
|
139
|
-
} catch {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
}, "Must be a valid HTTP/HTTPS URL"))]),
|
|
143
|
-
method: require_index.optional(require_index.picklist(Object.keys(_ocap_mcrypto.types.HashType).map((x) => x.toLowerCase())), "sha2"),
|
|
144
|
-
digest: require_index.string()
|
|
145
|
-
});
|
|
146
|
-
const vcFilterSchema = require_index.object({
|
|
147
|
-
type: require_index.optional(require_index.pipe(require_index.array(require_index.pipe(require_index.string(), require_index.minLength(1))), require_index.minLength(1))),
|
|
148
|
-
target: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
149
|
-
trustedIssuers: require_index.optional(require_index.pipe(require_index.array(trustedIssuerSchema), require_index.minLength(1))),
|
|
150
|
-
tag: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
|
|
151
|
-
ownerDid: require_index.optional(require_index.array((0, _arcblock_validator.vDID)()), []),
|
|
152
|
-
claimUrl: optionalUrlSchema,
|
|
153
|
-
acquireUrl: optionalUrlSchema
|
|
154
|
-
});
|
|
155
|
-
const verifiableCredential = require_index.object({
|
|
156
|
-
...createStandardFields("verifiableCredential", "Please present a verifiable credential to continue."),
|
|
157
|
-
optional: require_index.optional(require_index.boolean(), false),
|
|
158
|
-
claimUrl: optionalUrlSchema,
|
|
159
|
-
acquireUrl: optionalUrlSchema,
|
|
160
|
-
item: require_index.optional(require_index.pipe(require_index.array(require_index.pipe(require_index.string(), require_index.minLength(1))), require_index.minLength(1))),
|
|
161
|
-
target: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
162
|
-
trustedIssuers: require_index.optional(require_index.pipe(require_index.array(trustedIssuerSchema), require_index.minLength(1))),
|
|
163
|
-
tag: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
|
|
164
|
-
ownerDid: require_index.optional(require_index.array((0, _arcblock_validator.vDID)()), []),
|
|
165
|
-
filters: require_index.optional(require_index.array(vcFilterSchema))
|
|
166
|
-
});
|
|
167
|
-
const assetFilterSchema = require_index.object({
|
|
168
|
-
address: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
169
|
-
trustedIssuers: require_index.optional(require_index.pipe(require_index.array(trustedIssuerSchema), require_index.minLength(1))),
|
|
170
|
-
trustedParents: require_index.optional(require_index.pipe(require_index.array((0, _arcblock_validator.vDID)()), require_index.minLength(1))),
|
|
171
|
-
tag: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
|
|
172
|
-
ownerDid: require_index.optional(require_index.array((0, _arcblock_validator.vDID)()), []),
|
|
173
|
-
consumed: require_index.optional(require_index.boolean()),
|
|
174
|
-
acquireUrl: optionalUrlSchema
|
|
175
|
-
});
|
|
176
|
-
const asset = require_index.object({
|
|
177
|
-
...createStandardFields("asset", "Please present an on chain asset to continue."),
|
|
178
|
-
optional: require_index.optional(require_index.boolean(), false),
|
|
179
|
-
address: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
180
|
-
trustedIssuers: require_index.optional(require_index.pipe(require_index.array(trustedIssuerSchema), require_index.minLength(1))),
|
|
181
|
-
trustedParents: require_index.optional(require_index.pipe(require_index.array((0, _arcblock_validator.vDID)()), require_index.minLength(1))),
|
|
182
|
-
tag: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
|
|
183
|
-
ownerDid: require_index.optional(require_index.array((0, _arcblock_validator.vDID)()), []),
|
|
184
|
-
consumed: require_index.optional(require_index.boolean()),
|
|
185
|
-
acquireUrl: optionalUrlSchema,
|
|
186
|
-
filters: require_index.optional(require_index.array(assetFilterSchema))
|
|
187
|
-
});
|
|
188
|
-
const assetOrVCFilterSchema = require_index.object({
|
|
189
|
-
type: require_index.optional(require_index.pipe(require_index.array(require_index.pipe(require_index.string(), require_index.minLength(1))), require_index.minLength(1))),
|
|
190
|
-
address: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
191
|
-
trustedIssuers: require_index.optional(require_index.pipe(require_index.array(trustedIssuerSchema), require_index.minLength(1))),
|
|
192
|
-
trustedParents: require_index.optional(require_index.pipe(require_index.array((0, _arcblock_validator.vDID)()), require_index.minLength(1))),
|
|
193
|
-
tag: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
|
|
194
|
-
ownerDid: require_index.optional(require_index.array((0, _arcblock_validator.vDID)()), []),
|
|
195
|
-
consumed: require_index.optional(require_index.boolean()),
|
|
196
|
-
claimUrl: optionalUrlSchema,
|
|
197
|
-
acquireUrl: optionalUrlSchema
|
|
198
|
-
});
|
|
199
|
-
return {
|
|
200
|
-
authPrincipal,
|
|
201
|
-
profile,
|
|
202
|
-
signature,
|
|
203
|
-
prepareTx,
|
|
204
|
-
agreement,
|
|
205
|
-
verifiableCredential,
|
|
206
|
-
asset,
|
|
207
|
-
assetOrVC: require_index.object({
|
|
208
|
-
...createStandardFields("assetOrVC", "Please present NFT to continue."),
|
|
209
|
-
filters: require_index.pipe(require_index.array(assetOrVCFilterSchema), require_index.minLength(1)),
|
|
210
|
-
optional: require_index.optional(require_index.boolean(), false)
|
|
211
|
-
}),
|
|
212
|
-
keyPair,
|
|
213
|
-
encryptionKey
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
//#endregion
|
|
218
|
-
exports.default = claims_default;
|
package/lib/schema/claims.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/schema/claims.d.ts
|
|
2
|
-
interface ClaimsSchema {
|
|
3
|
-
authPrincipal: any;
|
|
4
|
-
profile: any;
|
|
5
|
-
signature: any;
|
|
6
|
-
prepareTx: any;
|
|
7
|
-
agreement: any;
|
|
8
|
-
verifiableCredential: any;
|
|
9
|
-
asset: any;
|
|
10
|
-
assetOrVC: any;
|
|
11
|
-
keyPair: any;
|
|
12
|
-
encryptionKey: any;
|
|
13
|
-
}
|
|
14
|
-
declare const _default: (chainInfo: any) => ClaimsSchema;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { ClaimsSchema, _default as default };
|
package/lib/schema/index.cjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_index = require('../node_modules/valibot/dist/index.cjs');
|
|
3
|
-
const require_schema_claims = require('./claims.cjs');
|
|
4
|
-
let _arcblock_validator = require("@arcblock/validator");
|
|
5
|
-
|
|
6
|
-
//#region src/schema/index.ts
|
|
7
|
-
const isHttpUrl = (s) => {
|
|
8
|
-
try {
|
|
9
|
-
const url = new URL(s);
|
|
10
|
-
return ["http:", "https:"].includes(url.protocol);
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const chainInfo = require_index.pipe(require_index.object({
|
|
16
|
-
type: require_index.optional(require_index.picklist([
|
|
17
|
-
"arcblock",
|
|
18
|
-
"ethereum",
|
|
19
|
-
"solona"
|
|
20
|
-
]), "arcblock"),
|
|
21
|
-
id: require_index.optional(require_index.any()),
|
|
22
|
-
host: require_index.optional(require_index.any())
|
|
23
|
-
}), require_index.rawTransform(({ dataset, addIssue, NEVER }) => {
|
|
24
|
-
const obj = dataset.value;
|
|
25
|
-
let typeSchema;
|
|
26
|
-
switch (obj.type) {
|
|
27
|
-
case "arcblock":
|
|
28
|
-
typeSchema = require_index.object({
|
|
29
|
-
type: require_index.literal("arcblock"),
|
|
30
|
-
id: require_index.optional(require_index.string(), "none"),
|
|
31
|
-
host: require_index.optional(require_index.pipe(require_index.string(), require_index.check((s) => s === "none" || isHttpUrl(s), "must be a valid uri with a scheme matching the http|https pattern")), "none")
|
|
32
|
-
});
|
|
33
|
-
break;
|
|
34
|
-
case "ethereum":
|
|
35
|
-
typeSchema = require_index.object({
|
|
36
|
-
type: require_index.literal("ethereum"),
|
|
37
|
-
id: require_index.pipe(require_index.string(), require_index.regex(/^[0-9]+$/, "fails to match the numbers pattern")),
|
|
38
|
-
host: require_index.optional(require_index.string())
|
|
39
|
-
});
|
|
40
|
-
break;
|
|
41
|
-
case "solona":
|
|
42
|
-
typeSchema = require_index.object({
|
|
43
|
-
type: require_index.literal("solona"),
|
|
44
|
-
id: require_index.pipe(require_index.string(), require_index.regex(/^[0-9]+$/, "fails to match the numbers pattern")),
|
|
45
|
-
host: require_index.optional(require_index.string())
|
|
46
|
-
});
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
const result = require_index.safeParse(typeSchema, obj);
|
|
50
|
-
if (!result.success) {
|
|
51
|
-
for (const issue of result.issues) addIssue({
|
|
52
|
-
message: issue.message,
|
|
53
|
-
path: issue.path
|
|
54
|
-
});
|
|
55
|
-
return NEVER;
|
|
56
|
-
}
|
|
57
|
-
const output = {};
|
|
58
|
-
for (const [k, val] of Object.entries(result.output)) if (val !== void 0) output[k] = val;
|
|
59
|
-
return output;
|
|
60
|
-
}));
|
|
61
|
-
const appInfo = require_index.looseObject({
|
|
62
|
-
name: require_index.string(),
|
|
63
|
-
description: require_index.string(),
|
|
64
|
-
icon: require_index.pipe(require_index.string(), require_index.check(isHttpUrl, "Must be a valid HTTP/HTTPS URL")),
|
|
65
|
-
link: require_index.optional(require_index.pipe(require_index.string(), require_index.check(isHttpUrl, "Must be a valid HTTP/HTTPS URL"))),
|
|
66
|
-
path: require_index.optional(require_index.pipe(require_index.string(), require_index.check(isHttpUrl, "Must be a valid HTTP/HTTPS URL")), "https://abtwallet.io/i/"),
|
|
67
|
-
publisher: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
68
|
-
updateSubEndpoint: require_index.optional(require_index.boolean()),
|
|
69
|
-
subscriptionEndpoint: require_index.optional(require_index.string()),
|
|
70
|
-
nodeDid: require_index.optional((0, _arcblock_validator.vDID)()),
|
|
71
|
-
agentDid: require_index.optional((0, _arcblock_validator.vDID)())
|
|
72
|
-
});
|
|
73
|
-
const claims = require_schema_claims.default(chainInfo);
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
exports.appInfo = appInfo;
|
|
77
|
-
exports.chainInfo = chainInfo;
|
|
78
|
-
exports.claims = claims;
|
|
79
|
-
exports.vValidate = _arcblock_validator.vValidate;
|
package/lib/schema/index.d.cts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ClaimsSchema } from "./claims.cjs";
|
|
2
|
-
import { vValidate } from "@arcblock/validator";
|
|
3
|
-
import * as v from "valibot";
|
|
4
|
-
|
|
5
|
-
//#region src/schema/index.d.ts
|
|
6
|
-
declare const chainInfo: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
7
|
-
readonly type: v.OptionalSchema<v.PicklistSchema<["arcblock", "ethereum", "solona"], undefined>, "arcblock">;
|
|
8
|
-
readonly id: v.OptionalSchema<v.AnySchema, undefined>;
|
|
9
|
-
readonly host: v.OptionalSchema<v.AnySchema, undefined>;
|
|
10
|
-
}, undefined>, v.RawTransformAction<{
|
|
11
|
-
type: "arcblock" | "ethereum" | "solona";
|
|
12
|
-
id?: any;
|
|
13
|
-
host?: any;
|
|
14
|
-
}, any>]>;
|
|
15
|
-
declare const appInfo: v.LooseObjectSchema<{
|
|
16
|
-
readonly name: v.StringSchema<undefined>;
|
|
17
|
-
readonly description: v.StringSchema<undefined>;
|
|
18
|
-
readonly icon: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be a valid HTTP/HTTPS URL">]>;
|
|
19
|
-
readonly link: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be a valid HTTP/HTTPS URL">]>, undefined>;
|
|
20
|
-
readonly path: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be a valid HTTP/HTTPS URL">]>, "https://abtwallet.io/i/">;
|
|
21
|
-
readonly publisher: v.OptionalSchema<any, undefined>;
|
|
22
|
-
readonly updateSubEndpoint: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
23
|
-
readonly subscriptionEndpoint: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
|
-
readonly nodeDid: v.OptionalSchema<any, undefined>;
|
|
25
|
-
readonly agentDid: v.OptionalSchema<any, undefined>;
|
|
26
|
-
}, undefined>;
|
|
27
|
-
declare const claims: ClaimsSchema;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { appInfo, chainInfo, claims, vValidate };
|
package/lib/storage/kv.cjs
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
-
let events = require("events");
|
|
4
|
-
|
|
5
|
-
//#region src/storage/kv.ts
|
|
6
|
-
var CloudflareKVStorage = class extends events.EventEmitter {
|
|
7
|
-
constructor(kv, options = {}) {
|
|
8
|
-
super();
|
|
9
|
-
this.kv = kv;
|
|
10
|
-
this.ttl = options.ttl ?? 300;
|
|
11
|
-
this.prefix = options.prefix ?? "";
|
|
12
|
-
}
|
|
13
|
-
key(token) {
|
|
14
|
-
return `${this.prefix}${token}`;
|
|
15
|
-
}
|
|
16
|
-
async create(token, status = "created") {
|
|
17
|
-
const record = {
|
|
18
|
-
token,
|
|
19
|
-
status
|
|
20
|
-
};
|
|
21
|
-
await this.kv.put(this.key(token), JSON.stringify(record), { expirationTtl: this.ttl });
|
|
22
|
-
this.emit("create", record);
|
|
23
|
-
return record;
|
|
24
|
-
}
|
|
25
|
-
async read(token) {
|
|
26
|
-
const raw = await this.kv.get(this.key(token));
|
|
27
|
-
if (!raw) return null;
|
|
28
|
-
return JSON.parse(raw);
|
|
29
|
-
}
|
|
30
|
-
async update(token, updates) {
|
|
31
|
-
const existing = await this.read(token);
|
|
32
|
-
if (!existing) return null;
|
|
33
|
-
delete updates.token;
|
|
34
|
-
const merged = {
|
|
35
|
-
...existing,
|
|
36
|
-
...updates
|
|
37
|
-
};
|
|
38
|
-
await this.kv.put(this.key(token), JSON.stringify(merged), { expirationTtl: this.ttl });
|
|
39
|
-
this.emit("update", merged);
|
|
40
|
-
return merged;
|
|
41
|
-
}
|
|
42
|
-
async delete(token) {
|
|
43
|
-
const existing = await this.read(token);
|
|
44
|
-
if (existing) this.emit("destroy", existing);
|
|
45
|
-
await this.kv.delete(this.key(token));
|
|
46
|
-
}
|
|
47
|
-
async exist(token, did) {
|
|
48
|
-
const record = await this.read(token);
|
|
49
|
-
if (!record) return false;
|
|
50
|
-
if (did) return record.did === did;
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var kv_default = CloudflareKVStorage;
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
exports.default = kv_default;
|
package/lib/storage/kv.d.cts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
|
|
3
|
-
//#region src/storage/kv.d.ts
|
|
4
|
-
interface KVNamespace {
|
|
5
|
-
get(key: string): Promise<string | null>;
|
|
6
|
-
put(key: string, value: string, options?: {
|
|
7
|
-
expirationTtl?: number;
|
|
8
|
-
}): Promise<void>;
|
|
9
|
-
delete(key: string): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
interface CloudflareKVStorageOptions {
|
|
12
|
-
/** TTL in seconds for KV entries. Default: 300 (5 minutes) */
|
|
13
|
-
ttl?: number;
|
|
14
|
-
/** Key prefix for KV entries. Default: '' */
|
|
15
|
-
prefix?: string;
|
|
16
|
-
}
|
|
17
|
-
declare class CloudflareKVStorage extends EventEmitter {
|
|
18
|
-
private kv;
|
|
19
|
-
private ttl;
|
|
20
|
-
private prefix;
|
|
21
|
-
constructor(kv: KVNamespace, options?: CloudflareKVStorageOptions);
|
|
22
|
-
private key;
|
|
23
|
-
create(token: string, status?: string): Promise<{
|
|
24
|
-
token: string;
|
|
25
|
-
status: string;
|
|
26
|
-
}>;
|
|
27
|
-
read(token: string): Promise<any>;
|
|
28
|
-
update(token: string, updates: Record<string, any>): Promise<any>;
|
|
29
|
-
delete(token: string): Promise<void>;
|
|
30
|
-
exist(token: string, did?: string): Promise<boolean>;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { CloudflareKVStorage as default };
|
package/lib/types.cjs
DELETED
|
File without changes
|
package/lib/types.d.cts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Framework-agnostic request interface for DID Connect handlers.
|
|
4
|
-
*
|
|
5
|
-
* Designed to match Express's `req` shape so that Express requests
|
|
6
|
-
* satisfy it natively (zero-wrapping). Hono adapter creates a wrapper
|
|
7
|
-
* that maps Hono Context to this interface.
|
|
8
|
-
*/
|
|
9
|
-
interface ConnectRequest {
|
|
10
|
-
/** Parsed request body (from body-parser or Hono) */
|
|
11
|
-
body: Record<string, any>;
|
|
12
|
-
/** Parsed query string parameters */
|
|
13
|
-
query: Record<string, any>;
|
|
14
|
-
/** URL path parameters (e.g. :action) */
|
|
15
|
-
params: Record<string, any>;
|
|
16
|
-
/** Raw request headers */
|
|
17
|
-
headers: Record<string, string | string[] | undefined>;
|
|
18
|
-
/** Parsed cookies (from cookie-parser or manual parsing) */
|
|
19
|
-
cookies: Record<string, string>;
|
|
20
|
-
/** Request protocol ('http' or 'https') */
|
|
21
|
-
protocol: string;
|
|
22
|
-
/** Full original URL including query string */
|
|
23
|
-
originalUrl: string;
|
|
24
|
-
/** Session context, populated by ensureContext middleware */
|
|
25
|
-
context?: any;
|
|
26
|
-
/** Flag to prevent double monkey-patching in ensureSignedJson */
|
|
27
|
-
ensureSignedJson?: boolean;
|
|
28
|
-
/** Case-insensitive header getter (matches Express req.get) */
|
|
29
|
-
get(name: string): string | undefined;
|
|
30
|
-
/** Content negotiation for locale (matches Express req.acceptsLanguages) */
|
|
31
|
-
acceptsLanguages(...languages: string[]): string | false;
|
|
32
|
-
/** Original framework-specific request object (Express req or Hono Context) */
|
|
33
|
-
raw?: any;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Framework-agnostic response interface for DID Connect handlers.
|
|
37
|
-
*
|
|
38
|
-
* Express: maps directly to res.jsonp/res.json/res.status().json().
|
|
39
|
-
* Hono: uses a buffer pattern — calls are captured, then the outer
|
|
40
|
-
* Hono handler reads the buffer to return c.json().
|
|
41
|
-
*/
|
|
42
|
-
interface ConnectResponse {
|
|
43
|
-
/** Send JSON response (Express JSONP, Hono json) */
|
|
44
|
-
jsonp(data: any): void;
|
|
45
|
-
/** Send JSON response */
|
|
46
|
-
json(data: any): void;
|
|
47
|
-
/** Set status code and return object with json() method */
|
|
48
|
-
status(code: number): {
|
|
49
|
-
json(data: any): void;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
/** Middleware next() callback */
|
|
53
|
-
type NextFunction = () => void;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { ConnectRequest, ConnectResponse, NextFunction };
|