@arcblock/did-connect-js 1.29.27 → 1.30.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.
@@ -1,18 +1,16 @@
1
- import { ObjectSchema } from "joi";
2
-
3
1
  //#region src/schema/claims.d.ts
4
2
  interface ClaimsSchema {
5
- authPrincipal: ObjectSchema;
6
- profile: ObjectSchema;
7
- signature: ObjectSchema;
8
- prepareTx: ObjectSchema;
9
- agreement: ObjectSchema;
10
- verifiableCredential: ObjectSchema;
11
- asset: ObjectSchema;
12
- assetOrVC: ObjectSchema;
13
- keyPair: ObjectSchema;
14
- encryptionKey: ObjectSchema;
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;
15
13
  }
16
- declare const _default: (chainInfo: ObjectSchema) => ClaimsSchema;
14
+ declare const _default: (chainInfo: any) => ClaimsSchema;
17
15
  //#endregion
18
16
  export { ClaimsSchema, _default as default };
@@ -1,150 +1,212 @@
1
- import { Joi } from "@arcblock/validator";
1
+ import { any, array, boolean, check, literal, looseObject, maxValue, minLength, minValue, number, object, optional, picklist, pipe, rawTransform, regex, string, transform, union } from "../node_modules/valibot/dist/index.mjs";
2
+ import { vBNPositive, vDID } from "@arcblock/validator";
2
3
  import { types } from "@ocap/mcrypto";
3
4
 
4
5
  //#region src/schema/claims.ts
5
- const trustedIssuerSchema = Joi.alternatives().try(Joi.object({
6
- did: Joi.DID().required(),
7
- endpoint: Joi.string().uri({ scheme: ["http", "https"] }).required()
8
- }), Joi.DID().required());
9
- const optionalUrlSchema = Joi.string().uri({
10
- scheme: ["http", "https"],
11
- allowRelative: true
12
- }).optional().default("").allow("");
13
- const requirementSchema = Joi.object({
14
- tokens: Joi.array().items(Joi.object({
15
- address: Joi.DID().required(),
16
- value: Joi.BN().positive().required()
17
- })).required(),
18
- assets: Joi.object({
19
- address: Joi.array().items(Joi.DID()).optional(),
20
- parent: Joi.array().items(Joi.DID()).optional(),
21
- issuer: Joi.array().items(Joi.DID()).optional(),
22
- amount: Joi.number().positive().min(1)
23
- }).optional()
6
+ const trustedIssuerSchema = union([object({
7
+ did: vDID(),
8
+ endpoint: pipe(string(), check((s) => {
9
+ try {
10
+ const url = new URL(s);
11
+ return ["http:", "https:"].includes(url.protocol);
12
+ } catch {
13
+ return false;
14
+ }
15
+ }, "Must be a valid HTTP/HTTPS URL"))
16
+ }), vDID()]);
17
+ const optionalUrlSchema = optional(pipe(string(), check((s) => {
18
+ if (s === "") return true;
19
+ try {
20
+ const url = new URL(s);
21
+ return ["http:", "https:"].includes(url.protocol);
22
+ } catch {
23
+ return s.startsWith("/");
24
+ }
25
+ }, "Must be a valid URL")), "");
26
+ const requirementSchema = object({
27
+ tokens: array(object({
28
+ address: vDID(),
29
+ value: vBNPositive()
30
+ })),
31
+ assets: optional(object({
32
+ address: optional(array(vDID())),
33
+ parent: optional(array(vDID())),
34
+ issuer: optional(array(vDID())),
35
+ amount: optional(pipe(number(), check((n) => n > 0, "Must be positive"), minValue(1)))
36
+ }))
24
37
  });
25
- const targetTypeSchema = Joi.object({
26
- key: Joi.string().valid(...Object.keys(types.KeyType).map((x) => x.toLowerCase())).default("ed25519"),
27
- hash: Joi.string().valid(...Object.keys(types.HashType).map((x) => x.toLowerCase())).default("sha3"),
28
- role: Joi.string().valid(...Object.keys(types.RoleType).map((x) => x.toLowerCase().split("_").pop())).default("account"),
29
- encoding: Joi.string().valid(...Object.keys(types.EncodingType).map((x) => x.toLowerCase())).default("base58")
30
- }).optional();
38
+ const targetTypeSchema = optional(object({
39
+ key: optional(picklist(Object.keys(types.KeyType).map((x) => x.toLowerCase())), "ed25519"),
40
+ hash: optional(picklist(Object.keys(types.HashType).map((x) => x.toLowerCase())), "sha3"),
41
+ role: optional(picklist(Object.keys(types.RoleType).map((x) => x.toLowerCase().split("_").pop())), "account"),
42
+ encoding: optional(picklist(Object.keys(types.EncodingType).map((x) => x.toLowerCase())), "base58")
43
+ }));
31
44
  var claims_default = (chainInfo) => {
32
- const options = {
33
- stripUnknown: true,
34
- noDefaults: false
35
- };
36
45
  const createStandardFields = (type, description) => ({
37
- type: Joi.string().valid(type).default(type),
38
- description: Joi.string().min(1).default(description),
39
- chainInfo,
40
- mfaCode: Joi.array().items(Joi.number().min(10).max(99).optional()).default([]),
41
- meta: Joi.any().optional().default({})
46
+ type: optional(literal(type), type),
47
+ description: optional(pipe(string(), minLength(1)), description),
48
+ chainInfo: optional(chainInfo),
49
+ mfaCode: optional(array(optional(pipe(number(), minValue(10), maxValue(99)))), []),
50
+ meta: optional(any(), {})
42
51
  });
43
- const authPrincipal = Joi.object({
52
+ const authPrincipal = object({
44
53
  ...createStandardFields("authPrincipal", "Please continue with your account"),
45
- target: Joi.DID().optional().allow("").default(""),
46
- supervised: Joi.boolean().default(false),
54
+ target: optional(union([literal(""), vDID()]), ""),
55
+ supervised: optional(boolean(), false),
47
56
  targetType: targetTypeSchema
48
- }).options(options);
49
- const keyPair = Joi.object({
57
+ });
58
+ const keyPair = object({
50
59
  ...createStandardFields("keyPair", "Please create account to continue."),
51
- moniker: Joi.string().regex(/^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/).required(),
52
- declare: Joi.boolean().optional().default(true),
53
- migrateFrom: Joi.DID().optional().allow("").default(""),
60
+ moniker: pipe(string(), regex(/^[a-zA-Z0-9][-a-zA-Z0-9_]{2,128}$/)),
61
+ declare: optional(boolean(), true),
62
+ migrateFrom: optional(union([literal(""), vDID()]), ""),
54
63
  targetType: targetTypeSchema
55
- }).options(options);
56
- const encryptionKey = Joi.object({
64
+ });
65
+ const encryptionKey = object({
57
66
  ...createStandardFields("encryptionKey", "Please provide encryptionKey to continue."),
58
- salt: Joi.string().required(),
59
- delegation: Joi.string().optional().allow("").default("")
60
- }).options(options);
67
+ salt: string(),
68
+ delegation: optional(union([literal(""), string()]), "")
69
+ });
70
+ const profileItemValues = [
71
+ "did",
72
+ "fullName",
73
+ "email",
74
+ "phone",
75
+ "signature",
76
+ "avatar",
77
+ "birthday",
78
+ "url"
79
+ ];
80
+ const profile = pipe(looseObject({ ...createStandardFields("profile", "Please provide your profile to continue.") }), transform((obj) => {
81
+ const { fields, ...rest } = obj;
82
+ if (fields !== void 0) return {
83
+ ...rest,
84
+ items: fields
85
+ };
86
+ return rest;
87
+ }), rawTransform(({ dataset, addIssue, NEVER }) => {
88
+ const obj = dataset.value;
89
+ const items = obj.items ?? ["fullName"];
90
+ if (!Array.isArray(items) || items.length < 1) {
91
+ addIssue({ message: "\"items\" must contain at least 1 items" });
92
+ return NEVER;
93
+ }
94
+ const validSet = new Set(profileItemValues);
95
+ for (let i = 0; i < items.length; i++) if (!validSet.has(items[i])) {
96
+ addIssue({ message: `"items[${i}]" must be one of [${[...profileItemValues].join(", ")}]` });
97
+ return NEVER;
98
+ }
99
+ return {
100
+ ...obj,
101
+ items
102
+ };
103
+ }));
104
+ const signature = object({
105
+ ...createStandardFields("signature", "Sign this transaction or message to continue."),
106
+ typeUrl: picklist([
107
+ "fg:x:delegation",
108
+ "fg:t:transaction",
109
+ "mime:text/plain",
110
+ "mime:text/html",
111
+ "eth:transaction",
112
+ "eth:standard-data",
113
+ "eth:personal-data",
114
+ "eth:typed-data",
115
+ "eth:legacy-data"
116
+ ]),
117
+ display: optional(union([literal(""), string()]), ""),
118
+ method: optional(picklist(["none", ...Object.keys(types.HashType).map((x) => x.toLowerCase())]), "sha3"),
119
+ digest: optional(union([literal(""), string()]), ""),
120
+ origin: optional(union([literal(""), string()]), ""),
121
+ nonce: optional(union([literal(""), string()]), ""),
122
+ requirement: optional(requirementSchema)
123
+ });
124
+ const prepareTx = object({
125
+ ...createStandardFields("prepareTx", "Prepare and sign this transaction to continue."),
126
+ display: optional(union([literal(""), string()]), ""),
127
+ partialTx: string(),
128
+ nonce: optional(union([literal(""), string()]), ""),
129
+ requirement: requirementSchema
130
+ });
131
+ const agreement = object({
132
+ ...createStandardFields("agreement", "Confirm your agreement to continue."),
133
+ uri: union([literal(""), pipe(string(), check((s) => {
134
+ try {
135
+ const url = new URL(s);
136
+ return ["http:", "https:"].includes(url.protocol);
137
+ } catch {
138
+ return false;
139
+ }
140
+ }, "Must be a valid HTTP/HTTPS URL"))]),
141
+ method: optional(picklist(Object.keys(types.HashType).map((x) => x.toLowerCase())), "sha2"),
142
+ digest: string()
143
+ });
144
+ const vcFilterSchema = object({
145
+ type: optional(pipe(array(pipe(string(), minLength(1))), minLength(1))),
146
+ target: optional(vDID()),
147
+ trustedIssuers: optional(pipe(array(trustedIssuerSchema), minLength(1))),
148
+ tag: optional(pipe(string(), check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
149
+ ownerDid: optional(array(vDID()), []),
150
+ claimUrl: optionalUrlSchema,
151
+ acquireUrl: optionalUrlSchema
152
+ });
153
+ const verifiableCredential = object({
154
+ ...createStandardFields("verifiableCredential", "Please present a verifiable credential to continue."),
155
+ optional: optional(boolean(), false),
156
+ claimUrl: optionalUrlSchema,
157
+ acquireUrl: optionalUrlSchema,
158
+ item: optional(pipe(array(pipe(string(), minLength(1))), minLength(1))),
159
+ target: optional(vDID()),
160
+ trustedIssuers: optional(pipe(array(trustedIssuerSchema), minLength(1))),
161
+ tag: optional(pipe(string(), check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
162
+ ownerDid: optional(array(vDID()), []),
163
+ filters: optional(array(vcFilterSchema))
164
+ });
165
+ const assetFilterSchema = object({
166
+ address: optional(vDID()),
167
+ trustedIssuers: optional(pipe(array(trustedIssuerSchema), minLength(1))),
168
+ trustedParents: optional(pipe(array(vDID()), minLength(1))),
169
+ tag: optional(pipe(string(), check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
170
+ ownerDid: optional(array(vDID()), []),
171
+ consumed: optional(boolean()),
172
+ acquireUrl: optionalUrlSchema
173
+ });
174
+ const asset = object({
175
+ ...createStandardFields("asset", "Please present an on chain asset to continue."),
176
+ optional: optional(boolean(), false),
177
+ address: optional(vDID()),
178
+ trustedIssuers: optional(pipe(array(trustedIssuerSchema), minLength(1))),
179
+ trustedParents: optional(pipe(array(vDID()), minLength(1))),
180
+ tag: optional(pipe(string(), check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
181
+ ownerDid: optional(array(vDID()), []),
182
+ consumed: optional(boolean()),
183
+ acquireUrl: optionalUrlSchema,
184
+ filters: optional(array(assetFilterSchema))
185
+ });
186
+ const assetOrVCFilterSchema = object({
187
+ type: optional(pipe(array(pipe(string(), minLength(1))), minLength(1))),
188
+ address: optional(vDID()),
189
+ trustedIssuers: optional(pipe(array(trustedIssuerSchema), minLength(1))),
190
+ trustedParents: optional(pipe(array(vDID()), minLength(1))),
191
+ tag: optional(pipe(string(), check((s) => s === "" || s.length >= 1, "Must be non-empty or empty string")), ""),
192
+ ownerDid: optional(array(vDID()), []),
193
+ consumed: optional(boolean()),
194
+ claimUrl: optionalUrlSchema,
195
+ acquireUrl: optionalUrlSchema
196
+ });
61
197
  return {
62
198
  authPrincipal,
63
- profile: Joi.object({
64
- ...createStandardFields("profile", "Please provide your profile to continue."),
65
- items: Joi.array().items(Joi.string().valid("did", "fullName", "email", "phone", "signature", "avatar", "birthday", "url")).min(1).default(["fullName"])
66
- }).rename("fields", "items", {
67
- ignoreUndefined: true,
68
- override: true
69
- }).options(options),
70
- signature: Joi.object({
71
- ...createStandardFields("signature", "Sign this transaction or message to continue."),
72
- typeUrl: Joi.string().valid("fg:x:delegation", "fg:t:transaction", "mime:text/plain", "mime:text/html", "eth:transaction", "eth:standard-data", "eth:personal-data", "eth:typed-data", "eth:legacy-data").required(),
73
- display: Joi.string().allow("").default(""),
74
- method: Joi.string().allow("none", ...Object.keys(types.HashType).map((x) => x.toLowerCase())).optional().default("sha3"),
75
- digest: Joi.string().allow("").default(""),
76
- origin: Joi.string().allow("").default(""),
77
- nonce: Joi.string().allow("").default(""),
78
- requirement: requirementSchema.optional()
79
- }).options(options),
80
- prepareTx: Joi.object({
81
- ...createStandardFields("prepareTx", "Prepare and sign this transaction to continue."),
82
- display: Joi.string().allow("").default(""),
83
- partialTx: Joi.string().required(),
84
- nonce: Joi.string().allow("").default(""),
85
- requirement: requirementSchema.required()
86
- }).options(options),
87
- agreement: Joi.object({
88
- ...createStandardFields("agreement", "Confirm your agreement to continue."),
89
- uri: Joi.string().uri({ scheme: ["http", "https"] }).required().allow(""),
90
- method: Joi.string().allow(...Object.keys(types.HashType).map((x) => x.toLowerCase())).optional().default("sha2"),
91
- digest: Joi.string().required()
92
- }).options(options),
93
- verifiableCredential: Joi.object({
94
- ...createStandardFields("verifiableCredential", "Please present a verifiable credential to continue."),
95
- optional: Joi.boolean().default(false),
96
- claimUrl: optionalUrlSchema,
97
- acquireUrl: optionalUrlSchema,
98
- item: Joi.array().items(Joi.string().min(1).required()).min(1).optional(),
99
- target: Joi.DID().optional(),
100
- trustedIssuers: Joi.array().items(trustedIssuerSchema).min(1).optional(),
101
- tag: Joi.string().min(1).allow("").default(""),
102
- ownerDid: Joi.array().items(Joi.DID()).optional().default([]),
103
- filters: Joi.array().items(Joi.object({
104
- type: Joi.array().items(Joi.string().min(1).required()).min(1).optional(),
105
- target: Joi.DID().optional(),
106
- trustedIssuers: Joi.array().items(trustedIssuerSchema).min(1).optional(),
107
- tag: Joi.string().min(1).allow("").default(""),
108
- ownerDid: Joi.array().items(Joi.DID()).optional().default([]),
109
- claimUrl: optionalUrlSchema,
110
- acquireUrl: optionalUrlSchema
111
- })).optional()
112
- }).options(options),
113
- asset: Joi.object({
114
- ...createStandardFields("asset", "Please present an on chain asset to continue."),
115
- optional: Joi.boolean().default(false),
116
- address: Joi.DID().optional(),
117
- trustedIssuers: Joi.array().items(trustedIssuerSchema).min(1).optional(),
118
- trustedParents: Joi.array().items(Joi.DID().required()).min(1).optional(),
119
- tag: Joi.string().min(1).allow("").default(""),
120
- ownerDid: Joi.array().items(Joi.DID()).optional().default([]),
121
- consumed: Joi.boolean().optional(),
122
- acquireUrl: optionalUrlSchema,
123
- filters: Joi.array().items(Joi.object({
124
- address: Joi.DID().optional(),
125
- trustedIssuers: Joi.array().items(trustedIssuerSchema).min(1).optional(),
126
- trustedParents: Joi.array().items(Joi.DID().required()).min(1).optional(),
127
- tag: Joi.string().min(1).allow("").default(""),
128
- ownerDid: Joi.array().items(Joi.DID()).optional().default([]),
129
- consumed: Joi.boolean().optional(),
130
- acquireUrl: optionalUrlSchema
131
- })).optional()
132
- }).options(options),
133
- assetOrVC: Joi.object({
199
+ profile,
200
+ signature,
201
+ prepareTx,
202
+ agreement,
203
+ verifiableCredential,
204
+ asset,
205
+ assetOrVC: object({
134
206
  ...createStandardFields("assetOrVC", "Please present NFT to continue."),
135
- filters: Joi.array().items(Joi.object({
136
- type: Joi.array().items(Joi.string().min(1).required()).min(1).optional(),
137
- address: Joi.DID().optional(),
138
- trustedIssuers: Joi.array().items(trustedIssuerSchema).min(1).optional(),
139
- trustedParents: Joi.array().items(Joi.DID().required()).min(1).optional(),
140
- tag: Joi.string().min(1).allow("").default(""),
141
- ownerDid: Joi.array().items(Joi.DID()).optional().default([]),
142
- consumed: Joi.boolean().optional(),
143
- claimUrl: optionalUrlSchema,
144
- acquireUrl: optionalUrlSchema
145
- })).required().min(1),
146
- optional: Joi.boolean().default(false)
147
- }).options(options),
207
+ filters: pipe(array(assetOrVCFilterSchema), minLength(1)),
208
+ optional: optional(boolean(), false)
209
+ }),
148
210
  keyPair,
149
211
  encryptionKey
150
212
  };
@@ -1,9 +1,29 @@
1
1
  import { ClaimsSchema } from "./claims.mjs";
2
- import * as joi0 from "joi";
2
+ import { vValidate } from "@arcblock/validator";
3
+ import * as v from "valibot";
3
4
 
4
5
  //#region src/schema/index.d.ts
5
- declare const chainInfo: joi0.ObjectSchema<any>;
6
- declare const appInfo: joi0.ObjectSchema<any>;
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>;
7
27
  declare const claims: ClaimsSchema;
8
28
  //#endregion
9
- export { appInfo, chainInfo, claims };
29
+ export { appInfo, chainInfo, claims, vValidate };
@@ -1,49 +1,75 @@
1
+ import { any, boolean, check, literal, looseObject, object, optional, picklist, pipe, rawTransform, regex, safeParse, string } from "../node_modules/valibot/dist/index.mjs";
1
2
  import claims_default from "./claims.mjs";
2
- import { Joi } from "@arcblock/validator";
3
+ import { vDID, vValidate } from "@arcblock/validator";
3
4
 
4
5
  //#region src/schema/index.ts
5
- const chainInfo = Joi.object({
6
- type: Joi.string().optional().valid("arcblock", "ethereum", "solona").default("arcblock"),
7
- id: Joi.any().when("type", {
8
- is: "arcblock",
9
- then: Joi.string().optional().default("none")
10
- }).when("type", {
11
- is: "ethereum",
12
- then: Joi.string().required().pattern(/^[0-9]+$/, "numbers")
13
- }).when("type", {
14
- is: "solona",
15
- then: Joi.string().required().pattern(/^[0-9]+$/, "numbers")
16
- }),
17
- host: Joi.string().when("type", {
18
- is: "ethereum",
19
- then: Joi.string().optional().allow("")
20
- }).when("type", {
21
- is: "solona",
22
- then: Joi.string().optional().allow("")
23
- }).when("type", {
24
- is: "arcblock",
25
- then: Joi.string().uri({ scheme: ["http", "https"] }).allow("none").default("none")
26
- })
27
- }).options({
28
- stripUnknown: true,
29
- noDefaults: false
30
- });
31
- const appInfo = Joi.object({
32
- name: Joi.string().required(),
33
- description: Joi.string().required(),
34
- icon: Joi.string().uri({ scheme: ["http", "https"] }).required(),
35
- link: Joi.string().uri({ scheme: ["http", "https"] }).optional(),
36
- path: Joi.string().uri({ scheme: ["http", "https"] }).default("https://abtwallet.io/i/"),
37
- publisher: Joi.DID().optional(),
38
- updateSubEndpoint: Joi.boolean().optional(),
39
- subscriptionEndpoint: Joi.string().optional(),
40
- nodeDid: Joi.DID().optional(),
41
- agentDid: Joi.DID().optional()
42
- }).options({
43
- stripUnknown: false,
44
- noDefaults: false
6
+ const isHttpUrl = (s) => {
7
+ try {
8
+ const url = new URL(s);
9
+ return ["http:", "https:"].includes(url.protocol);
10
+ } catch {
11
+ return false;
12
+ }
13
+ };
14
+ const chainInfo = pipe(object({
15
+ type: optional(picklist([
16
+ "arcblock",
17
+ "ethereum",
18
+ "solona"
19
+ ]), "arcblock"),
20
+ id: optional(any()),
21
+ host: optional(any())
22
+ }), rawTransform(({ dataset, addIssue, NEVER }) => {
23
+ const obj = dataset.value;
24
+ let typeSchema;
25
+ switch (obj.type) {
26
+ case "arcblock":
27
+ typeSchema = object({
28
+ type: literal("arcblock"),
29
+ id: optional(string(), "none"),
30
+ host: optional(pipe(string(), check((s) => s === "none" || isHttpUrl(s), "must be a valid uri with a scheme matching the http|https pattern")), "none")
31
+ });
32
+ break;
33
+ case "ethereum":
34
+ typeSchema = object({
35
+ type: literal("ethereum"),
36
+ id: pipe(string(), regex(/^[0-9]+$/, "fails to match the numbers pattern")),
37
+ host: optional(string())
38
+ });
39
+ break;
40
+ case "solona":
41
+ typeSchema = object({
42
+ type: literal("solona"),
43
+ id: pipe(string(), regex(/^[0-9]+$/, "fails to match the numbers pattern")),
44
+ host: optional(string())
45
+ });
46
+ break;
47
+ }
48
+ const result = safeParse(typeSchema, obj);
49
+ if (!result.success) {
50
+ for (const issue of result.issues) addIssue({
51
+ message: issue.message,
52
+ path: issue.path
53
+ });
54
+ return NEVER;
55
+ }
56
+ const output = {};
57
+ for (const [k, val] of Object.entries(result.output)) if (val !== void 0) output[k] = val;
58
+ return output;
59
+ }));
60
+ const appInfo = looseObject({
61
+ name: string(),
62
+ description: string(),
63
+ icon: pipe(string(), check(isHttpUrl, "Must be a valid HTTP/HTTPS URL")),
64
+ link: optional(pipe(string(), check(isHttpUrl, "Must be a valid HTTP/HTTPS URL"))),
65
+ path: optional(pipe(string(), check(isHttpUrl, "Must be a valid HTTP/HTTPS URL")), "https://abtwallet.io/i/"),
66
+ publisher: optional(vDID()),
67
+ updateSubEndpoint: optional(boolean()),
68
+ subscriptionEndpoint: optional(string()),
69
+ nodeDid: optional(vDID()),
70
+ agentDid: optional(vDID())
45
71
  });
46
72
  const claims = claims_default(chainInfo);
47
73
 
48
74
  //#endregion
49
- export { appInfo, chainInfo, claims };
75
+ export { appInfo, chainInfo, claims, vValidate };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
- const require_package$1 = require('../package.cjs');
3
+ const require_package$1 = require('../did/did-connect/package.cjs');
4
4
  let _ocap_wallet = require("@ocap/wallet");
5
5
  let _arcblock_jwt = require("@arcblock/jwt");
6
6
  _arcblock_jwt = require_rolldown_runtime.__toESM(_arcblock_jwt);
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
- const require_package$1 = require('../package.cjs');
3
+ const require_package$1 = require('../did/did-connect/package.cjs');
4
4
  const require_authenticator_base = require('./base.cjs');
5
5
  const require_schema_index = require('../schema/index.cjs');
6
6
  let node_querystring = require("node:querystring");
@@ -20,6 +20,7 @@ let lodash_random = require("lodash/random");
20
20
  lodash_random = require_rolldown_runtime.__toESM(lodash_random);
21
21
  let lodash_shuffle = require("lodash/shuffle");
22
22
  lodash_shuffle = require_rolldown_runtime.__toESM(lodash_shuffle);
23
+ let _arcblock_validator = require("@arcblock/validator");
23
24
 
24
25
  //#region src/authenticator/wallet.ts
25
26
  const debug = require("debug")(`${require_package$1.default.name}:authenticator:wallet`);
@@ -369,7 +370,7 @@ var WalletAuthenticator = class WalletAuthenticator extends require_authenticato
369
370
  }
370
371
  result.mfaCode = (0, lodash_shuffle.default)(result.mfaCode);
371
372
  }
372
- const { value, error } = require_schema_index.claims[name].validate(result);
373
+ const { value, error } = (0, _arcblock_validator.vValidate)(require_schema_index.claims[name], result);
373
374
  if (error) throw new Error(`Invalid ${name} claim: ${error.message}`);
374
375
  return value;
375
376
  }));
@@ -528,12 +529,12 @@ var WalletAuthenticator = class WalletAuthenticator extends require_authenticato
528
529
  if (allowEmpty === false) throw new Error("Wallet authenticator can not work with invalid appInfo: empty");
529
530
  return null;
530
531
  }
531
- const { value, error } = require_schema_index.appInfo.validate(info);
532
+ const { value, error } = (0, _arcblock_validator.vValidate)(require_schema_index.appInfo, info);
532
533
  if (error) throw new Error(`Wallet authenticator can not work with invalid appInfo: ${error.message}`);
533
534
  return value;
534
535
  }
535
536
  _isValidChainInfo(x) {
536
- const { error } = require_schema_index.chainInfo.validate(x);
537
+ const { error } = (0, _arcblock_validator.vValidate)(require_schema_index.chainInfo, x);
537
538
  return !error;
538
539
  }
539
540
  tryWithTimeout(asyncFn, label = "") {
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
2
 
3
3
  //#region package.json
4
4
  var require_package = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports, module) => {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
- const require_package$1 = require('../package.cjs');
3
+ const require_package$1 = require('../did/did-connect/package.cjs');
4
4
  const require_protocol = require('../protocol.cjs');
5
5
  let _arcblock_did = require("@arcblock/did");
6
6
  let _ocap_util = require("@ocap/util");
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_package$1 = require('../package.cjs');
2
+ const require_package$1 = require('../did/did-connect/package.cjs');
3
3
  const require_adapters_detect = require('../adapters/detect.cjs');
4
4
  const require_adapters_express = require('../adapters/express.cjs');
5
5
  const require_adapters_hono = require('../adapters/hono.cjs');