@huaweidevtools/aishell-dsh-client-credentials 0.0.0-stage → 0.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/cordis.patch.yml +9 -0
- package/lib/client.js +1308 -0
- package/lib/index.js +1194 -0
- package/lib/types/client/AishellAccountHint.d.ts +45 -0
- package/lib/types/client/AishellCredentialsSection.d.ts +34 -0
- package/lib/types/client/AishellHeroChip.d.ts +43 -0
- package/lib/types/client/CredentialFormInteraction.d.ts +67 -0
- package/lib/types/client/CredentialRequestForm.d.ts +47 -0
- package/lib/types/client/credential-form-visibility.d.ts +51 -0
- package/lib/types/client/credential-status.d.ts +53 -0
- package/lib/types/client/huawei-mark.d.ts +37 -0
- package/lib/types/client/index.d.ts +19 -0
- package/lib/types/client/locales.d.ts +83 -0
- package/lib/types/client/open-settings.d.ts +27 -0
- package/lib/types/client/permission-mode.d.ts +53 -0
- package/lib/types/index.d.ts +148 -0
- package/package.json +75 -3
- package/README.md +0 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,1194 @@
|
|
|
1
|
+
import { createCredentialsStore } from "@huaweidevtools/aishell-dsh-credentials-store";
|
|
2
|
+
import { sign } from "@huaweidevtools/aishell-dsh-credentials-store/signer";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.5/node_modules/@deepseek-ai/cosmokit/lib/index.js
|
|
5
|
+
/** Return true when a value is `null` or `undefined`. */
|
|
6
|
+
function isNullable(value) {
|
|
7
|
+
return value === null || value === void 0;
|
|
8
|
+
}
|
|
9
|
+
/** Return true for non-array object values. */
|
|
10
|
+
function isPlainObject(data) {
|
|
11
|
+
return data && typeof data === "object" && !Array.isArray(data);
|
|
12
|
+
}
|
|
13
|
+
/** Filter object entries and return a new object. */
|
|
14
|
+
function filterKeys(object, filter) {
|
|
15
|
+
return Object.fromEntries(Object.entries(object).filter(([key, value]) => filter(key, value)));
|
|
16
|
+
}
|
|
17
|
+
/** Map object values while preserving the original key set. */
|
|
18
|
+
function mapValues(object, transform) {
|
|
19
|
+
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, transform(value, key)]));
|
|
20
|
+
}
|
|
21
|
+
/** Pick selected keys from an object, optionally including `undefined` values. */
|
|
22
|
+
function pick(source, keys, forced) {
|
|
23
|
+
if (!keys) return { ...source };
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const key of keys) if (forced || source[key] !== void 0) result[key] = source[key];
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
/** Shared config references used by schema validators and plugin runtimes. */
|
|
29
|
+
const write = Symbol.for("cosmokit.volatile.write");
|
|
30
|
+
function snapshot(value, ancestors = /* @__PURE__ */ new Set()) {
|
|
31
|
+
if (typeof value === "function") throw new TypeError("volatile config cannot contain functions");
|
|
32
|
+
if (value === null || typeof value !== "object") return value;
|
|
33
|
+
if (ancestors.has(value)) throw new TypeError("volatile config cannot contain cycles");
|
|
34
|
+
ancestors.add(value);
|
|
35
|
+
try {
|
|
36
|
+
if (Array.isArray(value)) return Object.freeze(value.map((item) => snapshot(item, ancestors)));
|
|
37
|
+
if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw new TypeError("volatile config objects must be plain objects or arrays");
|
|
38
|
+
return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, snapshot(item, ancestors)])));
|
|
39
|
+
} finally {
|
|
40
|
+
ancestors.delete(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a detached reference containing an immutable copy of the supplied data.
|
|
45
|
+
* @param value - validated config data; class instances and functions are unsupported.
|
|
46
|
+
* @returns a reference whose value is updated only by its owning runtime.
|
|
47
|
+
*/
|
|
48
|
+
function createVolatile(value) {
|
|
49
|
+
let current = snapshot(value);
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
get: () => current,
|
|
52
|
+
[write]: (value$1) => {
|
|
53
|
+
current = value$1;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Identify references across ESM/CJS copies of the shared library.
|
|
59
|
+
* @param value - a parsed config value.
|
|
60
|
+
* @returns whether the value implements the shared reference protocol.
|
|
61
|
+
*/
|
|
62
|
+
function isVolatile(value) {
|
|
63
|
+
return typeof value === "object" && value !== null && write in value;
|
|
64
|
+
}
|
|
65
|
+
/** Test values using `instanceof` with a `toStringTag` fallback. */
|
|
66
|
+
function is(type, value) {
|
|
67
|
+
if (arguments.length === 1) return (value$1) => is(type, value$1);
|
|
68
|
+
return type in globalThis && value instanceof globalThis[type] || Object.prototype.toString.call(value).slice(8, -1) === type;
|
|
69
|
+
}
|
|
70
|
+
function isArrayBufferLike(value) {
|
|
71
|
+
return is("ArrayBuffer", value) || is("SharedArrayBuffer", value);
|
|
72
|
+
}
|
|
73
|
+
function isArrayBufferSource(value) {
|
|
74
|
+
return isArrayBufferLike(value) || ArrayBuffer.isView(value);
|
|
75
|
+
}
|
|
76
|
+
/** Binary source detection and base64/hex conversion helpers. */
|
|
77
|
+
var Binary;
|
|
78
|
+
(function(Binary$1) {
|
|
79
|
+
Binary$1.is = isArrayBufferLike;
|
|
80
|
+
Binary$1.isSource = isArrayBufferSource;
|
|
81
|
+
function fromSource(source) {
|
|
82
|
+
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
83
|
+
else return source;
|
|
84
|
+
}
|
|
85
|
+
Binary$1.fromSource = fromSource;
|
|
86
|
+
function toBase64(source) {
|
|
87
|
+
source = fromSource(source);
|
|
88
|
+
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("base64");
|
|
89
|
+
let binary = "";
|
|
90
|
+
const bytes = new Uint8Array(source);
|
|
91
|
+
for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
|
|
92
|
+
return btoa(binary);
|
|
93
|
+
}
|
|
94
|
+
Binary$1.toBase64 = toBase64;
|
|
95
|
+
function fromBase64(source) {
|
|
96
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "base64"));
|
|
97
|
+
return Uint8Array.from(atob(source), (c) => c.charCodeAt(0));
|
|
98
|
+
}
|
|
99
|
+
Binary$1.fromBase64 = fromBase64;
|
|
100
|
+
function toHex(source) {
|
|
101
|
+
source = fromSource(source);
|
|
102
|
+
if (typeof Buffer !== "undefined") return Buffer.from(source).toString("hex");
|
|
103
|
+
return Array.from(new Uint8Array(source), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
104
|
+
}
|
|
105
|
+
Binary$1.toHex = toHex;
|
|
106
|
+
function fromHex(source) {
|
|
107
|
+
if (typeof Buffer !== "undefined") return fromSource(Buffer.from(source, "hex"));
|
|
108
|
+
const hex = source.length % 2 === 0 ? source : source.slice(0, source.length - 1);
|
|
109
|
+
const buffer = [];
|
|
110
|
+
for (let i = 0; i < hex.length; i += 2) buffer.push(parseInt(`${hex[i]}${hex[i + 1]}`, 16));
|
|
111
|
+
return Uint8Array.from(buffer).buffer;
|
|
112
|
+
}
|
|
113
|
+
Binary$1.fromHex = fromHex;
|
|
114
|
+
})(Binary || (Binary = {}));
|
|
115
|
+
/** Decode a base64 string into binary data. */
|
|
116
|
+
const base64ToArrayBuffer = Binary.fromBase64;
|
|
117
|
+
/** Encode binary data as base64. */
|
|
118
|
+
const arrayBufferToBase64 = Binary.toBase64;
|
|
119
|
+
/** Decode a hex string into binary data. */
|
|
120
|
+
const hexToArrayBuffer = Binary.fromHex;
|
|
121
|
+
/** Encode binary data as hex. */
|
|
122
|
+
const arrayBufferToHex = Binary.toHex;
|
|
123
|
+
/** Deep-clone common JavaScript values while preserving prototypes and cycles. */
|
|
124
|
+
function clone(source, refs = /* @__PURE__ */ new Map()) {
|
|
125
|
+
if (!source || typeof source !== "object") return source;
|
|
126
|
+
if (is("Date", source)) return new Date(source.valueOf());
|
|
127
|
+
if (is("RegExp", source)) return new RegExp(source.source, source.flags);
|
|
128
|
+
if (isArrayBufferLike(source)) return source.slice(0);
|
|
129
|
+
if (ArrayBuffer.isView(source)) return source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength);
|
|
130
|
+
const cached = refs.get(source);
|
|
131
|
+
if (cached) return cached;
|
|
132
|
+
if (Array.isArray(source)) {
|
|
133
|
+
const result$1 = [];
|
|
134
|
+
refs.set(source, result$1);
|
|
135
|
+
source.forEach((value, index) => {
|
|
136
|
+
result$1[index] = Reflect.apply(clone, null, [value, refs]);
|
|
137
|
+
});
|
|
138
|
+
return result$1;
|
|
139
|
+
}
|
|
140
|
+
const result = Object.create(Object.getPrototypeOf(source));
|
|
141
|
+
refs.set(source, result);
|
|
142
|
+
for (const key of Reflect.ownKeys(source)) {
|
|
143
|
+
const descriptor = { ...Reflect.getOwnPropertyDescriptor(source, key) };
|
|
144
|
+
if ("value" in descriptor) descriptor.value = Reflect.apply(clone, null, [descriptor.value, refs]);
|
|
145
|
+
Reflect.defineProperty(result, key, descriptor);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Compare values recursively, treating two volatile references as equal regardless of value.
|
|
151
|
+
* Strict comparison distinguishes null/undefined, treats opaque objects by identity,
|
|
152
|
+
* compares URLs by normalized href, treats array holes as undefined, and considers distinct cyclic structures unequal.
|
|
153
|
+
* @param a - first value.
|
|
154
|
+
* @param b - second value.
|
|
155
|
+
* @param strict - whether to require strict data equality outside volatile references.
|
|
156
|
+
* @returns whether the values compare equal.
|
|
157
|
+
*/
|
|
158
|
+
function deepEqual(a, b, strict) {
|
|
159
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
160
|
+
function compare(a$1, b$1) {
|
|
161
|
+
if (a$1 === b$1) return true;
|
|
162
|
+
if (isVolatile(a$1) || isVolatile(b$1)) return isVolatile(a$1) && isVolatile(b$1);
|
|
163
|
+
if (!strict && isNullable(a$1) && isNullable(b$1)) return true;
|
|
164
|
+
if (typeof a$1 !== typeof b$1 || typeof a$1 !== "object" || !a$1 || !b$1) return false;
|
|
165
|
+
if (ancestors.has(a$1)) return false;
|
|
166
|
+
function check(test, then) {
|
|
167
|
+
return test(a$1) ? test(b$1) ? then(a$1, b$1) : false : test(b$1) ? false : void 0;
|
|
168
|
+
}
|
|
169
|
+
ancestors.add(a$1);
|
|
170
|
+
try {
|
|
171
|
+
return check(Array.isArray, (a$2, b$2) => {
|
|
172
|
+
if (a$2.length !== b$2.length) return false;
|
|
173
|
+
for (let index = 0; index < a$2.length; index++) if (!compare(a$2[index], b$2[index])) return false;
|
|
174
|
+
return true;
|
|
175
|
+
}) ?? check(is("Date"), (a$2, b$2) => a$2.valueOf() === b$2.valueOf()) ?? check(is("URL"), (a$2, b$2) => a$2.href === b$2.href) ?? check(is("RegExp"), (a$2, b$2) => a$2.source === b$2.source && a$2.flags === b$2.flags) ?? check(isArrayBufferLike, (a$2, b$2) => {
|
|
176
|
+
if (a$2.byteLength !== b$2.byteLength) return false;
|
|
177
|
+
const viewA = new Uint8Array(a$2);
|
|
178
|
+
const viewB = new Uint8Array(b$2);
|
|
179
|
+
for (let i = 0; i < viewA.length; i++) if (viewA[i] !== viewB[i]) return false;
|
|
180
|
+
return true;
|
|
181
|
+
}) ?? ((!strict || [a$1, b$1].every((value) => Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) && Object.keys({
|
|
182
|
+
...a$1,
|
|
183
|
+
...b$1
|
|
184
|
+
}).every((key) => compare(a$1[key], b$1[key])));
|
|
185
|
+
} finally {
|
|
186
|
+
ancestors.delete(a$1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return compare(a, b);
|
|
190
|
+
}
|
|
191
|
+
/** Time constants plus parsing and formatting helpers. */
|
|
192
|
+
var Time;
|
|
193
|
+
(function(Time$1) {
|
|
194
|
+
Time$1.millisecond = 1;
|
|
195
|
+
Time$1.second = 1e3;
|
|
196
|
+
Time$1.minute = Time$1.second * 60;
|
|
197
|
+
Time$1.hour = Time$1.minute * 60;
|
|
198
|
+
Time$1.day = Time$1.hour * 24;
|
|
199
|
+
Time$1.week = Time$1.day * 7;
|
|
200
|
+
let timezoneOffset = (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
201
|
+
function setTimezoneOffset(offset) {
|
|
202
|
+
timezoneOffset = offset;
|
|
203
|
+
}
|
|
204
|
+
Time$1.setTimezoneOffset = setTimezoneOffset;
|
|
205
|
+
function getTimezoneOffset() {
|
|
206
|
+
return timezoneOffset;
|
|
207
|
+
}
|
|
208
|
+
Time$1.getTimezoneOffset = getTimezoneOffset;
|
|
209
|
+
function getDateNumber(date = /* @__PURE__ */ new Date(), offset) {
|
|
210
|
+
if (typeof date === "number") date = new Date(date);
|
|
211
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
212
|
+
return Math.floor((date.valueOf() / Time$1.minute - offset) / 1440);
|
|
213
|
+
}
|
|
214
|
+
Time$1.getDateNumber = getDateNumber;
|
|
215
|
+
function fromDateNumber(value, offset) {
|
|
216
|
+
const date = new Date(value * Time$1.day);
|
|
217
|
+
if (offset === void 0) offset = timezoneOffset;
|
|
218
|
+
return new Date(+date + offset * Time$1.minute);
|
|
219
|
+
}
|
|
220
|
+
Time$1.fromDateNumber = fromDateNumber;
|
|
221
|
+
const numeric = /\d+(?:\.\d+)?/.source;
|
|
222
|
+
const timeRegExp = new RegExp(`^${[
|
|
223
|
+
"w(?:eek(?:s)?)?",
|
|
224
|
+
"d(?:ay(?:s)?)?",
|
|
225
|
+
"h(?:our(?:s)?)?",
|
|
226
|
+
"m(?:in(?:ute)?(?:s)?)?",
|
|
227
|
+
"s(?:ec(?:ond)?(?:s)?)?"
|
|
228
|
+
].map((unit) => `(${numeric}${unit})?`).join("")}$`);
|
|
229
|
+
function parseTime(source) {
|
|
230
|
+
const capture = timeRegExp.exec(source);
|
|
231
|
+
if (!capture) return 0;
|
|
232
|
+
return (parseFloat(capture[1]) * Time$1.week || 0) + (parseFloat(capture[2]) * Time$1.day || 0) + (parseFloat(capture[3]) * Time$1.hour || 0) + (parseFloat(capture[4]) * Time$1.minute || 0) + (parseFloat(capture[5]) * Time$1.second || 0);
|
|
233
|
+
}
|
|
234
|
+
Time$1.parseTime = parseTime;
|
|
235
|
+
function parseDate(date) {
|
|
236
|
+
const parsed = parseTime(date);
|
|
237
|
+
if (parsed) date = Date.now() + parsed;
|
|
238
|
+
else if (/^\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).toLocaleDateString()}-${date}`;
|
|
239
|
+
else if (/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(date)) date = `${(/* @__PURE__ */ new Date()).getFullYear()}-${date}`;
|
|
240
|
+
return date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
241
|
+
}
|
|
242
|
+
Time$1.parseDate = parseDate;
|
|
243
|
+
function format(ms) {
|
|
244
|
+
const abs = Math.abs(ms);
|
|
245
|
+
if (abs >= Time$1.day - Time$1.hour / 2) return Math.round(ms / Time$1.day) + "d";
|
|
246
|
+
else if (abs >= Time$1.hour - Time$1.minute / 2) return Math.round(ms / Time$1.hour) + "h";
|
|
247
|
+
else if (abs >= Time$1.minute - Time$1.second / 2) return Math.round(ms / Time$1.minute) + "m";
|
|
248
|
+
else if (abs >= Time$1.second) return Math.round(ms / Time$1.second) + "s";
|
|
249
|
+
return ms + "ms";
|
|
250
|
+
}
|
|
251
|
+
Time$1.format = format;
|
|
252
|
+
function toDigits(source, length = 2) {
|
|
253
|
+
return source.toString().padStart(length, "0");
|
|
254
|
+
}
|
|
255
|
+
Time$1.toDigits = toDigits;
|
|
256
|
+
function template(template$1, time = /* @__PURE__ */ new Date()) {
|
|
257
|
+
return template$1.replace("yyyy", time.getFullYear().toString()).replace("yy", time.getFullYear().toString().slice(2)).replace("MM", toDigits(time.getMonth() + 1)).replace("dd", toDigits(time.getDate())).replace("hh", toDigits(time.getHours())).replace("mm", toDigits(time.getMinutes())).replace("ss", toDigits(time.getSeconds())).replace("SSS", toDigits(time.getMilliseconds(), 3));
|
|
258
|
+
}
|
|
259
|
+
Time$1.template = template;
|
|
260
|
+
})(Time || (Time = {}));
|
|
261
|
+
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region ../../node_modules/.pnpm/@deepseek-ai+schemastery@3.18.4/node_modules/@deepseek-ai/schemastery/lib/index.mjs
|
|
264
|
+
const kSchema = Symbol.for("schemastery");
|
|
265
|
+
const kValidationError = Symbol.for("ValidationError");
|
|
266
|
+
globalThis.__schemastery_index__ ??= 0;
|
|
267
|
+
globalThis.__schemastery_refs__ = void 0;
|
|
268
|
+
var ValidationError = class extends TypeError {
|
|
269
|
+
options;
|
|
270
|
+
name = "ValidationError";
|
|
271
|
+
constructor(message, options) {
|
|
272
|
+
let prefix = "$";
|
|
273
|
+
for (const segment of options.path || []) if (typeof segment === "string") prefix += "." + segment;
|
|
274
|
+
else if (typeof segment === "number") prefix += "[" + segment + "]";
|
|
275
|
+
else if (typeof segment === "symbol") prefix += `[Symbol(${segment.toString()})]`;
|
|
276
|
+
if (prefix.startsWith(".")) prefix = prefix.slice(1);
|
|
277
|
+
super((prefix === "$" ? "" : `${prefix} `) + message);
|
|
278
|
+
this.options = options;
|
|
279
|
+
}
|
|
280
|
+
static is(error) {
|
|
281
|
+
return !!error?.[kValidationError];
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
Object.defineProperty(ValidationError.prototype, kValidationError, { value: true });
|
|
285
|
+
const Schema = function(options) {
|
|
286
|
+
const schema = function(data, options$1 = {}) {
|
|
287
|
+
return Schema.resolve(data, schema, options$1)[0];
|
|
288
|
+
};
|
|
289
|
+
if (options.refs) {
|
|
290
|
+
const refs = mapValues(options.refs, (options$1) => new Schema(options$1));
|
|
291
|
+
const getRef = (uid) => refs[uid];
|
|
292
|
+
for (const key in refs) {
|
|
293
|
+
const options$1 = refs[key];
|
|
294
|
+
options$1.sKey = getRef(options$1.sKey);
|
|
295
|
+
options$1.inner = getRef(options$1.inner);
|
|
296
|
+
options$1.list = options$1.list && options$1.list.map(getRef);
|
|
297
|
+
options$1.dict = options$1.dict && mapValues(options$1.dict, getRef);
|
|
298
|
+
}
|
|
299
|
+
return refs[options.uid];
|
|
300
|
+
}
|
|
301
|
+
Object.assign(schema, options);
|
|
302
|
+
if (typeof schema.callback === "string") try {
|
|
303
|
+
schema.callback = new Function("return " + schema.callback)();
|
|
304
|
+
} catch {}
|
|
305
|
+
Object.defineProperty(schema, "uid", { value: globalThis.__schemastery_index__++ });
|
|
306
|
+
Object.setPrototypeOf(schema, Schema.prototype);
|
|
307
|
+
schema.meta ||= {};
|
|
308
|
+
schema.toString = schema.toString.bind(schema);
|
|
309
|
+
return schema;
|
|
310
|
+
};
|
|
311
|
+
Schema.prototype = Object.create(Function.prototype);
|
|
312
|
+
Schema.prototype[kSchema] = true;
|
|
313
|
+
Object.defineProperty(Schema.prototype, "~standard", { get() {
|
|
314
|
+
return {
|
|
315
|
+
version: 1,
|
|
316
|
+
vendor: "schemastery",
|
|
317
|
+
validate: (value) => {
|
|
318
|
+
try {
|
|
319
|
+
return { value: Schema.resolve(value, this, {})[0] };
|
|
320
|
+
} catch (error) {
|
|
321
|
+
if (ValidationError.is(error)) return { issues: [{
|
|
322
|
+
message: error.message,
|
|
323
|
+
path: error.options.path
|
|
324
|
+
}] };
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
} });
|
|
330
|
+
Schema.ValidationError = ValidationError;
|
|
331
|
+
Schema.prototype.toJSON = function toJSON() {
|
|
332
|
+
if (globalThis.__schemastery_refs__) {
|
|
333
|
+
globalThis.__schemastery_refs__[this.uid] ??= JSON.parse(JSON.stringify({ ...this }));
|
|
334
|
+
return this.uid;
|
|
335
|
+
}
|
|
336
|
+
globalThis.__schemastery_refs__ = { [this.uid]: { ...this } };
|
|
337
|
+
globalThis.__schemastery_refs__[this.uid] = JSON.parse(JSON.stringify({ ...this }));
|
|
338
|
+
const result = {
|
|
339
|
+
uid: this.uid,
|
|
340
|
+
refs: globalThis.__schemastery_refs__
|
|
341
|
+
};
|
|
342
|
+
globalThis.__schemastery_refs__ = void 0;
|
|
343
|
+
return result;
|
|
344
|
+
};
|
|
345
|
+
Schema.prototype.set = function set(key, value) {
|
|
346
|
+
this.dict[key] = value;
|
|
347
|
+
return this;
|
|
348
|
+
};
|
|
349
|
+
Schema.prototype.push = function push(value) {
|
|
350
|
+
this.list.push(value);
|
|
351
|
+
return this;
|
|
352
|
+
};
|
|
353
|
+
function mergeDesc(original, messages) {
|
|
354
|
+
const result = typeof original === "string" ? { "": original } : { ...original };
|
|
355
|
+
for (const locale in messages) {
|
|
356
|
+
const value = messages[locale];
|
|
357
|
+
if (value?.$description || value?.$desc) result[locale] = value.$description || value.$desc;
|
|
358
|
+
else if (typeof value === "string") result[locale] = value;
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
}
|
|
362
|
+
function getInner(value) {
|
|
363
|
+
return value?.$value ?? value?.$inner;
|
|
364
|
+
}
|
|
365
|
+
function extractKeys(data) {
|
|
366
|
+
return filterKeys(data ?? {}, (key) => !key.startsWith("$"));
|
|
367
|
+
}
|
|
368
|
+
Schema.prototype.i18n = function i18n(messages) {
|
|
369
|
+
const schema = Schema(this);
|
|
370
|
+
const desc = mergeDesc(schema.meta.description, messages);
|
|
371
|
+
if (Object.keys(desc).length) schema.meta.description = desc;
|
|
372
|
+
if (schema.dict) schema.dict = mapValues(schema.dict, (inner, key) => {
|
|
373
|
+
return inner.i18n(mapValues(messages, (data) => getInner(data)?.[key] ?? data?.[key]));
|
|
374
|
+
});
|
|
375
|
+
if (schema.list) schema.list = schema.list.map((inner, index) => {
|
|
376
|
+
return inner.i18n(mapValues(messages, (data = {}) => {
|
|
377
|
+
if (Array.isArray(getInner(data))) return getInner(data)[index];
|
|
378
|
+
if (Array.isArray(data)) return data[index];
|
|
379
|
+
return extractKeys(data);
|
|
380
|
+
}));
|
|
381
|
+
});
|
|
382
|
+
if (schema.inner) schema.inner = schema.inner.i18n(mapValues(messages, (data) => {
|
|
383
|
+
if (getInner(data)) return getInner(data);
|
|
384
|
+
return extractKeys(data);
|
|
385
|
+
}));
|
|
386
|
+
if (schema.sKey) schema.sKey = schema.sKey.i18n(mapValues(messages, (data) => data?.$key));
|
|
387
|
+
return schema;
|
|
388
|
+
};
|
|
389
|
+
Schema.prototype.extra = function extra(key, value) {
|
|
390
|
+
const schema = Schema(this);
|
|
391
|
+
schema.meta = {
|
|
392
|
+
...schema.meta,
|
|
393
|
+
[key]: value
|
|
394
|
+
};
|
|
395
|
+
return schema;
|
|
396
|
+
};
|
|
397
|
+
for (const key of [
|
|
398
|
+
"required",
|
|
399
|
+
"disabled",
|
|
400
|
+
"collapse",
|
|
401
|
+
"hidden",
|
|
402
|
+
"loose"
|
|
403
|
+
]) Object.assign(Schema.prototype, { [key](value = true) {
|
|
404
|
+
const schema = Schema(this);
|
|
405
|
+
schema.meta = {
|
|
406
|
+
...schema.meta,
|
|
407
|
+
[key]: value
|
|
408
|
+
};
|
|
409
|
+
return schema;
|
|
410
|
+
} });
|
|
411
|
+
Schema.prototype.deprecated = function deprecated() {
|
|
412
|
+
const schema = Schema(this);
|
|
413
|
+
schema.meta.badges ||= [];
|
|
414
|
+
schema.meta.badges.push({
|
|
415
|
+
text: "deprecated",
|
|
416
|
+
type: "danger"
|
|
417
|
+
});
|
|
418
|
+
return schema;
|
|
419
|
+
};
|
|
420
|
+
Schema.prototype.experimental = function experimental() {
|
|
421
|
+
const schema = Schema(this);
|
|
422
|
+
schema.meta.badges ||= [];
|
|
423
|
+
schema.meta.badges.push({
|
|
424
|
+
text: "experimental",
|
|
425
|
+
type: "warning"
|
|
426
|
+
});
|
|
427
|
+
return schema;
|
|
428
|
+
};
|
|
429
|
+
Schema.prototype.pattern = function pattern(regexp) {
|
|
430
|
+
const schema = Schema(this);
|
|
431
|
+
const pattern$1 = pick(regexp, ["source", "flags"]);
|
|
432
|
+
schema.meta = {
|
|
433
|
+
...schema.meta,
|
|
434
|
+
pattern: pattern$1
|
|
435
|
+
};
|
|
436
|
+
return schema;
|
|
437
|
+
};
|
|
438
|
+
Schema.prototype.simplify = function simplify(value) {
|
|
439
|
+
if (isVolatile(value)) value = value.get();
|
|
440
|
+
if (deepEqual(value, this.meta.default, this.type === "dict")) return null;
|
|
441
|
+
if (isNullable(value)) return value;
|
|
442
|
+
if (this.type === "object" || this.type === "dict") {
|
|
443
|
+
const result = {};
|
|
444
|
+
for (const key in value) {
|
|
445
|
+
const item = (this.type === "object" ? this.dict[key] : this.inner)?.simplify(value[key]);
|
|
446
|
+
if (this.type === "dict" || !isNullable(item)) result[key] = item;
|
|
447
|
+
}
|
|
448
|
+
if (deepEqual(result, this.meta.default, this.type === "dict")) return null;
|
|
449
|
+
return result;
|
|
450
|
+
} else if (this.type === "array" || this.type === "tuple") {
|
|
451
|
+
const result = [];
|
|
452
|
+
value.forEach((value$1, index) => {
|
|
453
|
+
const schema = this.type === "array" ? this.inner : this.list[index];
|
|
454
|
+
const item = schema ? schema.simplify(value$1) : value$1;
|
|
455
|
+
result.push(item);
|
|
456
|
+
});
|
|
457
|
+
return result;
|
|
458
|
+
} else if (this.type === "intersect") {
|
|
459
|
+
const result = {};
|
|
460
|
+
for (const item of this.list) Object.assign(result, item.simplify(value));
|
|
461
|
+
return result;
|
|
462
|
+
} else if (this.type === "union") for (const schema of this.list) try {
|
|
463
|
+
Schema.resolve(value, schema, {});
|
|
464
|
+
return schema.simplify(value);
|
|
465
|
+
} catch {}
|
|
466
|
+
return value;
|
|
467
|
+
};
|
|
468
|
+
Schema.prototype.toString = function toString(inline) {
|
|
469
|
+
return formatters[this.type]?.(this, inline) ?? `Schema<${this.type}>`;
|
|
470
|
+
};
|
|
471
|
+
Schema.prototype.role = function role(role$1, extra) {
|
|
472
|
+
const schema = Schema(this);
|
|
473
|
+
schema.meta = {
|
|
474
|
+
...schema.meta,
|
|
475
|
+
role: role$1,
|
|
476
|
+
extra
|
|
477
|
+
};
|
|
478
|
+
return schema;
|
|
479
|
+
};
|
|
480
|
+
for (const key of [
|
|
481
|
+
"default",
|
|
482
|
+
"link",
|
|
483
|
+
"comment",
|
|
484
|
+
"description",
|
|
485
|
+
"max",
|
|
486
|
+
"min",
|
|
487
|
+
"step"
|
|
488
|
+
]) Object.assign(Schema.prototype, { [key](value) {
|
|
489
|
+
const schema = Schema(this);
|
|
490
|
+
schema.meta = {
|
|
491
|
+
...schema.meta,
|
|
492
|
+
[key]: value
|
|
493
|
+
};
|
|
494
|
+
return schema;
|
|
495
|
+
} });
|
|
496
|
+
Schema.prototype.volatile = function volatile() {
|
|
497
|
+
if (this.meta.volatile) throw new TypeError("volatile schema is already wrapped");
|
|
498
|
+
return this.extra("volatile", true);
|
|
499
|
+
};
|
|
500
|
+
const resolvers = {};
|
|
501
|
+
const checkedVolatile = Symbol("checked-volatile-schema");
|
|
502
|
+
function validateVolatileSchema(schema, path = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
|
|
503
|
+
const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
|
|
504
|
+
if (states.has(blocked)) return;
|
|
505
|
+
states.add(blocked);
|
|
506
|
+
seen.set(schema, states);
|
|
507
|
+
if (schema.meta?.volatile && blocked) throw new ValidationError("volatile fields require a fixed object path without an enclosing volatile field", { path });
|
|
508
|
+
const nested = blocked || !!schema.meta?.volatile;
|
|
509
|
+
if (schema.dict) for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path, key], nested, seen);
|
|
510
|
+
if (schema.sKey) validateVolatileSchema(schema.sKey, [...path, "<key>"], true, seen);
|
|
511
|
+
if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) validateVolatileSchema(schema.inner, [...path, "*"], true, seen);
|
|
512
|
+
if (schema.list) for (let index = 0; index < schema.list.length; index++) validateVolatileSchema(schema.list[index], [...path, String(index)], true, seen);
|
|
513
|
+
}
|
|
514
|
+
Schema.extend = function extend(type, resolve) {
|
|
515
|
+
resolvers[type] = resolve;
|
|
516
|
+
};
|
|
517
|
+
Schema.resolve = function resolve(data, schema, options = {}, strict = false) {
|
|
518
|
+
if (!schema) return [data];
|
|
519
|
+
if (!options[checkedVolatile]) {
|
|
520
|
+
validateVolatileSchema(schema, options.path);
|
|
521
|
+
options = {
|
|
522
|
+
...options,
|
|
523
|
+
[checkedVolatile]: true
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
if (schema.meta?.volatile) {
|
|
527
|
+
const inner = Schema(schema);
|
|
528
|
+
inner.meta = {
|
|
529
|
+
...schema.meta,
|
|
530
|
+
volatile: false
|
|
531
|
+
};
|
|
532
|
+
const [value, adapted] = Schema.resolve(data, inner, options, strict);
|
|
533
|
+
try {
|
|
534
|
+
return [createVolatile(value), adapted];
|
|
535
|
+
} catch (error) {
|
|
536
|
+
throw new ValidationError(error instanceof Error ? error.message : String(error), options);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (options.ignore?.(data, schema)) return [data];
|
|
540
|
+
if (isNullable(data) && schema.type !== "lazy") {
|
|
541
|
+
if (schema.meta.required) throw new ValidationError(`missing required value`, options);
|
|
542
|
+
let current = schema;
|
|
543
|
+
let fallback = schema.meta.default;
|
|
544
|
+
while (current?.type === "intersect" && isNullable(fallback)) {
|
|
545
|
+
current = current.list[0];
|
|
546
|
+
fallback = current?.meta.default;
|
|
547
|
+
}
|
|
548
|
+
if (isNullable(fallback)) return [data];
|
|
549
|
+
data = clone(fallback);
|
|
550
|
+
}
|
|
551
|
+
const callback = resolvers[schema.type];
|
|
552
|
+
if (!callback) throw new ValidationError(`unsupported type "${schema.type}"`, options);
|
|
553
|
+
try {
|
|
554
|
+
return callback(data, schema, options, strict);
|
|
555
|
+
} catch (error) {
|
|
556
|
+
if (!schema.meta.loose) throw error;
|
|
557
|
+
return [schema.meta.default];
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
Schema.from = function from(source) {
|
|
561
|
+
if (isNullable(source)) return Schema.any();
|
|
562
|
+
else if ([
|
|
563
|
+
"string",
|
|
564
|
+
"number",
|
|
565
|
+
"boolean"
|
|
566
|
+
].includes(typeof source)) return Schema.const(source).required();
|
|
567
|
+
else if (source[kSchema]) return source;
|
|
568
|
+
else if (typeof source === "function") switch (source) {
|
|
569
|
+
case String: return Schema.string().required();
|
|
570
|
+
case Number: return Schema.number().required();
|
|
571
|
+
case Boolean: return Schema.boolean().required();
|
|
572
|
+
case Function: return Schema.function().required();
|
|
573
|
+
default: return Schema.is(source).required();
|
|
574
|
+
}
|
|
575
|
+
else throw new TypeError(`cannot infer schema from ${source}`);
|
|
576
|
+
};
|
|
577
|
+
Schema.lazy = function lazy(builder) {
|
|
578
|
+
const toJSON = () => {
|
|
579
|
+
if (!schema.inner[kSchema]) {
|
|
580
|
+
schema.inner = schema.builder();
|
|
581
|
+
schema.inner.meta = {
|
|
582
|
+
...schema.meta,
|
|
583
|
+
...schema.inner.meta
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
return schema.inner.toJSON();
|
|
587
|
+
};
|
|
588
|
+
const schema = new Schema({
|
|
589
|
+
type: "lazy",
|
|
590
|
+
builder,
|
|
591
|
+
inner: { toJSON }
|
|
592
|
+
});
|
|
593
|
+
return schema;
|
|
594
|
+
};
|
|
595
|
+
Schema.natural = function natural() {
|
|
596
|
+
return Schema.number().step(1).min(0);
|
|
597
|
+
};
|
|
598
|
+
Schema.percent = function percent() {
|
|
599
|
+
return Schema.number().step(.01).min(0).max(1).role("slider");
|
|
600
|
+
};
|
|
601
|
+
Schema.date = function date() {
|
|
602
|
+
return Schema.union([Schema.is(Date), Schema.transform(Schema.string().role("datetime"), (value, options) => {
|
|
603
|
+
const date$1 = new Date(value);
|
|
604
|
+
if (isNaN(+date$1)) throw new ValidationError(`invalid date "${value}"`, options);
|
|
605
|
+
return date$1;
|
|
606
|
+
}, true)]);
|
|
607
|
+
};
|
|
608
|
+
Schema.regExp = function regExp(flag = "") {
|
|
609
|
+
return Schema.union([Schema.is(RegExp), Schema.transform(Schema.string().role("regexp", { flag }), (value, options) => {
|
|
610
|
+
try {
|
|
611
|
+
return new RegExp(value, flag);
|
|
612
|
+
} catch (e) {
|
|
613
|
+
throw new ValidationError(e.message, options);
|
|
614
|
+
}
|
|
615
|
+
}, true)]);
|
|
616
|
+
};
|
|
617
|
+
Schema.arrayBuffer = function arrayBuffer(encoding) {
|
|
618
|
+
return Schema.union([
|
|
619
|
+
Schema.is(ArrayBuffer),
|
|
620
|
+
Schema.is(SharedArrayBuffer),
|
|
621
|
+
Schema.transform(Schema.any(), (value, options) => {
|
|
622
|
+
if (Binary.isSource(value)) return Binary.fromSource(value);
|
|
623
|
+
throw new ValidationError(`expected ArrayBufferSource but got ${value}`, options);
|
|
624
|
+
}, true),
|
|
625
|
+
...encoding ? [Schema.transform(Schema.string(), (value, options) => {
|
|
626
|
+
try {
|
|
627
|
+
return encoding === "base64" ? Binary.fromBase64(value) : Binary.fromHex(value);
|
|
628
|
+
} catch (e) {
|
|
629
|
+
throw new ValidationError(e.message, options);
|
|
630
|
+
}
|
|
631
|
+
}, true)] : []
|
|
632
|
+
]);
|
|
633
|
+
};
|
|
634
|
+
Schema.extend("lazy", (data, schema, options, strict) => {
|
|
635
|
+
if (!schema.inner[kSchema]) {
|
|
636
|
+
schema.inner = schema.builder();
|
|
637
|
+
schema.inner.meta = {
|
|
638
|
+
...schema.meta,
|
|
639
|
+
...schema.inner.meta
|
|
640
|
+
};
|
|
641
|
+
validateVolatileSchema(schema.inner, options.path, true);
|
|
642
|
+
}
|
|
643
|
+
return Schema.resolve(data, schema.inner, options, strict);
|
|
644
|
+
});
|
|
645
|
+
Schema.extend("any", (data) => {
|
|
646
|
+
return [data];
|
|
647
|
+
});
|
|
648
|
+
Schema.extend("never", (data, _, options) => {
|
|
649
|
+
throw new ValidationError(`expected nullable but got ${data}`, options);
|
|
650
|
+
});
|
|
651
|
+
Schema.extend("const", (data, { value }, options) => {
|
|
652
|
+
if (deepEqual(data, value)) return [value];
|
|
653
|
+
throw new ValidationError(`expected ${value} but got ${data}`, options);
|
|
654
|
+
});
|
|
655
|
+
function checkWithinRange(data, meta, description, options, skipMin = false) {
|
|
656
|
+
const { max = Infinity, min = -Infinity } = meta;
|
|
657
|
+
if (data > max) throw new ValidationError(`expected ${description} <= ${max} but got ${data}`, options);
|
|
658
|
+
if (data < min && !skipMin) throw new ValidationError(`expected ${description} >= ${min} but got ${data}`, options);
|
|
659
|
+
}
|
|
660
|
+
Schema.extend("string", (data, { meta }, options) => {
|
|
661
|
+
if (typeof data !== "string") throw new ValidationError(`expected string but got ${data}`, options);
|
|
662
|
+
if (meta.pattern) {
|
|
663
|
+
const regexp = new RegExp(meta.pattern.source, meta.pattern.flags);
|
|
664
|
+
if (!regexp.test(data)) throw new ValidationError(`expect string to match regexp ${regexp}`, options);
|
|
665
|
+
}
|
|
666
|
+
checkWithinRange(data.length, meta, "string length", options);
|
|
667
|
+
return [data];
|
|
668
|
+
});
|
|
669
|
+
function decimalShift(data, digits) {
|
|
670
|
+
const str = data.toString();
|
|
671
|
+
if (str.includes("e")) return data * Math.pow(10, digits);
|
|
672
|
+
const index = str.indexOf(".");
|
|
673
|
+
if (index === -1) return data * Math.pow(10, digits);
|
|
674
|
+
const frac = str.slice(index + 1);
|
|
675
|
+
const integer = str.slice(0, index);
|
|
676
|
+
if (frac.length <= digits) return +(integer + frac.padEnd(digits, "0"));
|
|
677
|
+
return +(integer + frac.slice(0, digits) + "." + frac.slice(digits));
|
|
678
|
+
}
|
|
679
|
+
function isMultipleOf(data, min, step) {
|
|
680
|
+
step = Math.abs(step);
|
|
681
|
+
if (!/^\d+\.\d+$/.test(step.toString())) return (data - min) % step === 0;
|
|
682
|
+
const index = step.toString().indexOf(".");
|
|
683
|
+
const digits = step.toString().slice(index + 1).length;
|
|
684
|
+
return Math.abs(decimalShift(data, digits) - decimalShift(min, digits)) % decimalShift(step, digits) === 0;
|
|
685
|
+
}
|
|
686
|
+
Schema.extend("number", (data, { meta }, options) => {
|
|
687
|
+
if (typeof data !== "number") throw new ValidationError(`expected number but got ${data}`, options);
|
|
688
|
+
checkWithinRange(data, meta, "number", options);
|
|
689
|
+
const { step } = meta;
|
|
690
|
+
if (step && !isMultipleOf(data, meta.min ?? 0, step)) throw new ValidationError(`expected number multiple of ${step} but got ${data}`, options);
|
|
691
|
+
return [data];
|
|
692
|
+
});
|
|
693
|
+
Schema.extend("boolean", (data, _, options) => {
|
|
694
|
+
if (typeof data === "boolean") return [data];
|
|
695
|
+
throw new ValidationError(`expected boolean but got ${data}`, options);
|
|
696
|
+
});
|
|
697
|
+
Schema.extend("bitset", (data, { bits, meta }, options) => {
|
|
698
|
+
let value = 0, keys = [];
|
|
699
|
+
if (typeof data === "number") {
|
|
700
|
+
value = data;
|
|
701
|
+
for (const key in bits) if (data & bits[key]) keys.push(key);
|
|
702
|
+
} else if (Array.isArray(data)) {
|
|
703
|
+
keys = data;
|
|
704
|
+
for (const key of keys) {
|
|
705
|
+
if (typeof key !== "string") throw new ValidationError(`expected string but got ${key}`, options);
|
|
706
|
+
if (key in bits) value |= bits[key];
|
|
707
|
+
}
|
|
708
|
+
} else throw new ValidationError(`expected number or array but got ${data}`, options);
|
|
709
|
+
if (value === meta.default) return [value];
|
|
710
|
+
return [value, keys];
|
|
711
|
+
});
|
|
712
|
+
Schema.extend("function", (data, _, options) => {
|
|
713
|
+
if (typeof data === "function") return [data];
|
|
714
|
+
throw new ValidationError(`expected function but got ${data}`, options);
|
|
715
|
+
});
|
|
716
|
+
Schema.extend("is", (data, { constructor }, options) => {
|
|
717
|
+
if (typeof constructor === "function") {
|
|
718
|
+
if (data instanceof constructor) return [data];
|
|
719
|
+
throw new ValidationError(`expected ${constructor.name} but got ${data}`, options);
|
|
720
|
+
} else {
|
|
721
|
+
if (isNullable(data)) throw new ValidationError(`expected ${constructor} but got ${data}`, options);
|
|
722
|
+
let prototype = Object.getPrototypeOf(data);
|
|
723
|
+
while (prototype) {
|
|
724
|
+
if (prototype.constructor?.name === constructor) return [data];
|
|
725
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
726
|
+
}
|
|
727
|
+
throw new ValidationError(`expected ${constructor} but got ${data}`, options);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
function property(data, key, schema, options) {
|
|
731
|
+
try {
|
|
732
|
+
const [value, adapted] = Schema.resolve(data[key], schema, {
|
|
733
|
+
...options,
|
|
734
|
+
path: [...options.path || [], key]
|
|
735
|
+
});
|
|
736
|
+
if (adapted !== void 0) data[key] = adapted;
|
|
737
|
+
return value;
|
|
738
|
+
} catch (e) {
|
|
739
|
+
if (!options?.autofix) throw e;
|
|
740
|
+
delete data[key];
|
|
741
|
+
return schema.meta.volatile ? createVolatile(schema.meta.default) : schema.meta.default;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
Schema.extend("array", (data, { inner, meta }, options) => {
|
|
745
|
+
if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
|
|
746
|
+
checkWithinRange(data.length, meta, "array length", options, !isNullable(inner.meta.default));
|
|
747
|
+
return [data.map((_, index) => property(data, index, inner, options))];
|
|
748
|
+
});
|
|
749
|
+
Schema.extend("dict", (data, { inner, sKey }, options, strict) => {
|
|
750
|
+
if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
|
|
751
|
+
const result = {};
|
|
752
|
+
for (const key in data) {
|
|
753
|
+
let rKey;
|
|
754
|
+
try {
|
|
755
|
+
rKey = Schema.resolve(key, sKey, options)[0];
|
|
756
|
+
} catch (error) {
|
|
757
|
+
if (strict) continue;
|
|
758
|
+
throw error;
|
|
759
|
+
}
|
|
760
|
+
result[rKey] = property(data, key, inner, options);
|
|
761
|
+
data[rKey] = data[key];
|
|
762
|
+
if (key !== rKey) delete data[key];
|
|
763
|
+
}
|
|
764
|
+
return [result];
|
|
765
|
+
});
|
|
766
|
+
Schema.extend("tuple", (data, { list }, options, strict) => {
|
|
767
|
+
if (!Array.isArray(data)) throw new ValidationError(`expected array but got ${data}`, options);
|
|
768
|
+
const result = list.map((inner, index) => property(data, index, inner, options));
|
|
769
|
+
if (strict) return [result];
|
|
770
|
+
result.push(...data.slice(list.length));
|
|
771
|
+
return [result];
|
|
772
|
+
});
|
|
773
|
+
function merge(result, data) {
|
|
774
|
+
for (const key in data) {
|
|
775
|
+
if (key in result) continue;
|
|
776
|
+
result[key] = data[key];
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
Schema.extend("object", (data, { dict }, options, strict) => {
|
|
780
|
+
if (!isPlainObject(data)) throw new ValidationError(`expected object but got ${data}`, options);
|
|
781
|
+
const result = {};
|
|
782
|
+
for (const key in dict) {
|
|
783
|
+
const value = property(data, key, dict[key], options);
|
|
784
|
+
if (!isNullable(value) || key in data) result[key] = value;
|
|
785
|
+
}
|
|
786
|
+
if (!strict) merge(result, data);
|
|
787
|
+
return [result];
|
|
788
|
+
});
|
|
789
|
+
Schema.extend("union", (data, { list, toString }, options, strict) => {
|
|
790
|
+
const messages = [];
|
|
791
|
+
for (const inner of list) try {
|
|
792
|
+
return Schema.resolve(data, inner, options, strict);
|
|
793
|
+
} catch (error) {
|
|
794
|
+
messages.push(error);
|
|
795
|
+
}
|
|
796
|
+
throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
797
|
+
});
|
|
798
|
+
Schema.extend("intersect", (data, { list, toString }, options, strict) => {
|
|
799
|
+
if (!list.length) return [data];
|
|
800
|
+
let result;
|
|
801
|
+
for (const inner of list) {
|
|
802
|
+
const value = Schema.resolve(data, inner, options, true)[0];
|
|
803
|
+
if (isNullable(value)) continue;
|
|
804
|
+
if (isNullable(result)) result = value;
|
|
805
|
+
else if (typeof result !== typeof value) throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
806
|
+
else if (typeof value === "object") merge(result ??= {}, value);
|
|
807
|
+
else if (result !== value) throw new ValidationError(`expected ${toString()} but got ${JSON.stringify(data)}`, options);
|
|
808
|
+
}
|
|
809
|
+
if (!strict && isPlainObject(data)) merge(result, data);
|
|
810
|
+
return [result];
|
|
811
|
+
});
|
|
812
|
+
Schema.extend("transform", (data, { inner, callback, preserve }, options) => {
|
|
813
|
+
const [result, adapted = data] = Schema.resolve(data, inner, options, true);
|
|
814
|
+
if (preserve) return [callback(result)];
|
|
815
|
+
else return [callback(result), callback(adapted)];
|
|
816
|
+
});
|
|
817
|
+
const formatters = {};
|
|
818
|
+
function defineMethod(name$1, keys, format) {
|
|
819
|
+
formatters[name$1] = format;
|
|
820
|
+
Object.assign(Schema, { [name$1](...args) {
|
|
821
|
+
const schema = new Schema({ type: name$1 });
|
|
822
|
+
keys.forEach((key, index) => {
|
|
823
|
+
switch (key) {
|
|
824
|
+
case "sKey":
|
|
825
|
+
schema.sKey = args[index] ?? Schema.string();
|
|
826
|
+
break;
|
|
827
|
+
case "inner":
|
|
828
|
+
schema.inner = Schema.from(args[index]);
|
|
829
|
+
break;
|
|
830
|
+
case "list":
|
|
831
|
+
schema.list = args[index].map(Schema.from);
|
|
832
|
+
break;
|
|
833
|
+
case "dict":
|
|
834
|
+
schema.dict = mapValues(args[index], Schema.from);
|
|
835
|
+
break;
|
|
836
|
+
case "bits":
|
|
837
|
+
schema.bits = {};
|
|
838
|
+
for (const key$1 in args[index]) {
|
|
839
|
+
if (typeof args[index][key$1] !== "number") continue;
|
|
840
|
+
schema.bits[key$1] = args[index][key$1];
|
|
841
|
+
}
|
|
842
|
+
break;
|
|
843
|
+
case "callback": {
|
|
844
|
+
const callback = schema.callback = args[index];
|
|
845
|
+
callback["toJSON"] ||= () => callback.toString();
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
case "constructor": {
|
|
849
|
+
const constructor = schema.constructor = args[index];
|
|
850
|
+
if (typeof constructor === "function") constructor["toJSON"] ||= () => constructor["name"];
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
default: schema[key] = args[index];
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
if (name$1 === "object" || name$1 === "dict") schema.meta.default = {};
|
|
857
|
+
else if (name$1 === "array" || name$1 === "tuple") schema.meta.default = [];
|
|
858
|
+
else if (name$1 === "bitset") schema.meta.default = 0;
|
|
859
|
+
return schema;
|
|
860
|
+
} });
|
|
861
|
+
}
|
|
862
|
+
defineMethod("is", ["constructor"], ({ constructor }) => {
|
|
863
|
+
if (typeof constructor === "function") return constructor.name;
|
|
864
|
+
else return constructor;
|
|
865
|
+
});
|
|
866
|
+
defineMethod("any", [], () => "any");
|
|
867
|
+
defineMethod("never", [], () => "never");
|
|
868
|
+
defineMethod("const", ["value"], ({ value }) => typeof value === "string" ? JSON.stringify(value) : value);
|
|
869
|
+
defineMethod("string", [], () => "string");
|
|
870
|
+
defineMethod("number", [], () => "number");
|
|
871
|
+
defineMethod("boolean", [], () => "boolean");
|
|
872
|
+
defineMethod("bitset", ["bits"], () => "bitset");
|
|
873
|
+
defineMethod("function", [], () => "function");
|
|
874
|
+
defineMethod("array", ["inner"], ({ inner }) => `${inner.toString(true)}[]`);
|
|
875
|
+
defineMethod("dict", ["inner", "sKey"], ({ inner, sKey }) => `{ [key: ${sKey.toString()}]: ${inner.toString()} }`);
|
|
876
|
+
defineMethod("tuple", ["list"], ({ list }) => `[${list.map((inner) => inner.toString()).join(", ")}]`);
|
|
877
|
+
defineMethod("object", ["dict"], ({ dict }) => {
|
|
878
|
+
if (Object.keys(dict).length === 0) return "{}";
|
|
879
|
+
return `{ ${Object.entries(dict).map(([key, inner]) => {
|
|
880
|
+
return `${key}${inner.meta.required ? "" : "?"}: ${inner.toString()}`;
|
|
881
|
+
}).join(", ")} }`;
|
|
882
|
+
});
|
|
883
|
+
defineMethod("union", ["list"], ({ list }, inline) => {
|
|
884
|
+
const result = list.map(({ toString: format }) => format()).join(" | ");
|
|
885
|
+
return inline ? `(${result})` : result;
|
|
886
|
+
});
|
|
887
|
+
defineMethod("intersect", ["list"], ({ list }) => {
|
|
888
|
+
return `${list.map((inner) => inner.toString(true)).join(" & ")}`;
|
|
889
|
+
});
|
|
890
|
+
defineMethod("transform", [
|
|
891
|
+
"inner",
|
|
892
|
+
"callback",
|
|
893
|
+
"preserve"
|
|
894
|
+
], ({ inner }, isInner) => inner.toString(isInner));
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/index.ts
|
|
898
|
+
/**
|
|
899
|
+
* Settings schema for this entry. Secrets are deliberately absent: they travel
|
|
900
|
+
* over the credential route into the credential store, never through a
|
|
901
|
+
* settings document.
|
|
902
|
+
*/
|
|
903
|
+
const Config = Schema.object({
|
|
904
|
+
credentialsStored: Schema.boolean().default(false).volatile(),
|
|
905
|
+
accessKeyIdHint: Schema.string().default("").volatile(),
|
|
906
|
+
lastError: Schema.string().default("").volatile(),
|
|
907
|
+
credentialRequestSession: Schema.string().default("").volatile()
|
|
908
|
+
});
|
|
909
|
+
/** Credential store account names for Huawei Cloud credentials. */
|
|
910
|
+
const AK_ACCOUNT = "HW_ACCESS_KEY";
|
|
911
|
+
const SK_ACCOUNT = "HW_SECRET_KEY";
|
|
912
|
+
const TOKEN_ACCOUNT = "HW_SECURITY_TOKEN";
|
|
913
|
+
/** IAM endpoint host. */
|
|
914
|
+
const IAM_HOST = "iam.myhuaweicloud.com";
|
|
915
|
+
/** Route the browser half reads status from and saves credentials to. */
|
|
916
|
+
const CREDENTIALS_PATH = "/api/aishell/credentials";
|
|
917
|
+
/** Route the browser half clears credentials through (fetch routes have no DELETE). */
|
|
918
|
+
const CLEAR_PATH = "/api/aishell/credentials/clear";
|
|
919
|
+
/**
|
|
920
|
+
* Route the browser calls to decline the credential form.
|
|
921
|
+
*
|
|
922
|
+
* Separate from `clear`: clearing removes stored credentials, while this ends a
|
|
923
|
+
* request without touching the store — a person who already has credentials for
|
|
924
|
+
* something else, or who would rather set them up in Settings, must be able to
|
|
925
|
+
* say "not now" without wiping anything.
|
|
926
|
+
*/
|
|
927
|
+
const DISMISS_PATH = "/api/aishell/credentials/dismiss";
|
|
928
|
+
/** Largest credential body accepted; a real payload is well under 1 KiB. */
|
|
929
|
+
const MAX_BODY_BYTES = 8 * 1024;
|
|
930
|
+
/**
|
|
931
|
+
* Verify credentials against Huawei Cloud IAM and return the account name.
|
|
932
|
+
*
|
|
933
|
+
* Calls `GET https://iam.myhuaweicloud.com/v3/auth/domains` signed with the
|
|
934
|
+
* AK/SK (and SecurityToken if present — STS temporary credentials carry the
|
|
935
|
+
* same full IAM scope as the permanent credential that minted them). A 200
|
|
936
|
+
* proves the credentials are valid and returns the domain (account) name;
|
|
937
|
+
* a 401/403 rejects them.
|
|
938
|
+
*
|
|
939
|
+
* @returns the account name (domain name).
|
|
940
|
+
* @throws Error with a user-readable message when verification fails.
|
|
941
|
+
*/
|
|
942
|
+
async function verifyCredentials(ak, sk, securityToken) {
|
|
943
|
+
const path = "/v3/auth/domains";
|
|
944
|
+
const signed = sign("GET", IAM_HOST, path, {}, "", {
|
|
945
|
+
ak,
|
|
946
|
+
sk,
|
|
947
|
+
...securityToken ? { securityToken } : {}
|
|
948
|
+
});
|
|
949
|
+
const resp = await fetch(`https://${IAM_HOST}${path}`, { headers: { ...signed } });
|
|
950
|
+
if (resp.status === 401) throw new Error("凭据验证失败:华为云返回未授权(401),请检查 AK/SK 或 Security Token 是否正确");
|
|
951
|
+
if (resp.status === 403) throw new Error("凭据验证失败:该凭据无 IAM 读取权限(403)");
|
|
952
|
+
if (!resp.ok) throw new Error(`凭据验证失败:华为云返回 ${resp.status}`);
|
|
953
|
+
const body = await resp.json();
|
|
954
|
+
const name$1 = body.domains?.[0]?.name;
|
|
955
|
+
if (!name$1) throw new Error("验证成功但未返回账号名");
|
|
956
|
+
return name$1;
|
|
957
|
+
}
|
|
958
|
+
/** One JSON error response the browser half renders verbatim. */
|
|
959
|
+
function jsonError(status, message) {
|
|
960
|
+
return Response.json({
|
|
961
|
+
ok: false,
|
|
962
|
+
error: message
|
|
963
|
+
}, { status });
|
|
964
|
+
}
|
|
965
|
+
/** Read a bounded JSON object body, or throw a user-readable message. */
|
|
966
|
+
async function readJsonBody(request) {
|
|
967
|
+
const text = await request.text();
|
|
968
|
+
if (text.length > MAX_BODY_BYTES) throw new Error("请求体过大");
|
|
969
|
+
let parsed;
|
|
970
|
+
try {
|
|
971
|
+
parsed = JSON.parse(text);
|
|
972
|
+
} catch {
|
|
973
|
+
throw new Error("请求体不是合法 JSON");
|
|
974
|
+
}
|
|
975
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("请求体必须是 JSON 对象");
|
|
976
|
+
return parsed;
|
|
977
|
+
}
|
|
978
|
+
/** Narrow one optional string field; absent and empty both read as undefined. */
|
|
979
|
+
function optionalString(value) {
|
|
980
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* The three credential routes, bound to their collaborators.
|
|
984
|
+
*
|
|
985
|
+
* Returned as plain `(request) => Promise<Response>` handlers so a test can
|
|
986
|
+
* drive them with a real `Request` and assert on the `Response` alone — the
|
|
987
|
+
* behavior worth pinning is that a rejected credential stores nothing and that
|
|
988
|
+
* no response ever carries a secret.
|
|
989
|
+
*/
|
|
990
|
+
function createCredentialRoutes(deps) {
|
|
991
|
+
const { store, verify, recordStatus, hint, notifyChanged } = deps;
|
|
992
|
+
return {
|
|
993
|
+
get: () => Promise.resolve(Response.json({
|
|
994
|
+
configured: Boolean(store.get(AK_ACCOUNT) && store.get(SK_ACCOUNT)),
|
|
995
|
+
accountName: hint()
|
|
996
|
+
}, { headers: { "cache-control": "no-store" } })),
|
|
997
|
+
save: async (request) => {
|
|
998
|
+
let body;
|
|
999
|
+
try {
|
|
1000
|
+
body = await readJsonBody(request);
|
|
1001
|
+
} catch (error) {
|
|
1002
|
+
return jsonError(400, error instanceof Error ? error.message : String(error));
|
|
1003
|
+
}
|
|
1004
|
+
const ak = optionalString(body.accessKeyId);
|
|
1005
|
+
const sk = optionalString(body.secretAccessKey);
|
|
1006
|
+
const token = optionalString(body.securityToken);
|
|
1007
|
+
if (!ak || !sk) return jsonError(400, "Access Key 与 Secret Key 均为必填");
|
|
1008
|
+
let accountName;
|
|
1009
|
+
try {
|
|
1010
|
+
accountName = await verify(ak, sk, token);
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1013
|
+
recordStatus([{
|
|
1014
|
+
op: "set",
|
|
1015
|
+
path: ["lastError"],
|
|
1016
|
+
value: message
|
|
1017
|
+
}]);
|
|
1018
|
+
return Response.json({
|
|
1019
|
+
ok: false,
|
|
1020
|
+
error: message
|
|
1021
|
+
}, { status: 422 });
|
|
1022
|
+
}
|
|
1023
|
+
try {
|
|
1024
|
+
store.delete(AK_ACCOUNT);
|
|
1025
|
+
store.delete(SK_ACCOUNT);
|
|
1026
|
+
store.delete(TOKEN_ACCOUNT);
|
|
1027
|
+
store.set(AK_ACCOUNT, ak);
|
|
1028
|
+
store.set(SK_ACCOUNT, sk);
|
|
1029
|
+
if (token) store.set(TOKEN_ACCOUNT, token);
|
|
1030
|
+
} catch (error) {
|
|
1031
|
+
const message = `凭据已验证,但写入凭据存储失败:${error instanceof Error ? error.message : String(error)}`;
|
|
1032
|
+
recordStatus([{
|
|
1033
|
+
op: "set",
|
|
1034
|
+
path: ["lastError"],
|
|
1035
|
+
value: message
|
|
1036
|
+
}]);
|
|
1037
|
+
return jsonError(500, message);
|
|
1038
|
+
}
|
|
1039
|
+
recordStatus([
|
|
1040
|
+
{
|
|
1041
|
+
op: "set",
|
|
1042
|
+
path: ["credentialsStored"],
|
|
1043
|
+
value: true
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
op: "set",
|
|
1047
|
+
path: ["accessKeyIdHint"],
|
|
1048
|
+
value: accountName
|
|
1049
|
+
},
|
|
1050
|
+
{
|
|
1051
|
+
op: "unset",
|
|
1052
|
+
path: ["lastError"]
|
|
1053
|
+
}
|
|
1054
|
+
]);
|
|
1055
|
+
notifyChanged();
|
|
1056
|
+
return Response.json({
|
|
1057
|
+
ok: true,
|
|
1058
|
+
accountName
|
|
1059
|
+
});
|
|
1060
|
+
},
|
|
1061
|
+
clear: () => {
|
|
1062
|
+
store.delete(AK_ACCOUNT);
|
|
1063
|
+
store.delete(SK_ACCOUNT);
|
|
1064
|
+
store.delete(TOKEN_ACCOUNT);
|
|
1065
|
+
recordStatus([
|
|
1066
|
+
{
|
|
1067
|
+
op: "set",
|
|
1068
|
+
path: ["credentialsStored"],
|
|
1069
|
+
value: false
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
op: "unset",
|
|
1073
|
+
path: ["accessKeyIdHint"]
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
op: "unset",
|
|
1077
|
+
path: ["lastError"]
|
|
1078
|
+
}
|
|
1079
|
+
]);
|
|
1080
|
+
notifyChanged();
|
|
1081
|
+
return Promise.resolve(Response.json({ ok: true }));
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
const name = "aishell-client-credentials";
|
|
1086
|
+
const inject = ["settings", "connection"];
|
|
1087
|
+
function apply(ctx, config) {
|
|
1088
|
+
const store = createCredentialsStore();
|
|
1089
|
+
const ns = ctx.fiber.entry?.options.id;
|
|
1090
|
+
/** Record the non-secret status the browser half reads; a refused write only logs. */
|
|
1091
|
+
const recordStatus = (ops) => {
|
|
1092
|
+
if (ns === void 0) return;
|
|
1093
|
+
ctx.settings.mutate(ns, ops).catch((error) => {
|
|
1094
|
+
ctx.logger.warn(error);
|
|
1095
|
+
});
|
|
1096
|
+
};
|
|
1097
|
+
const routes = createCredentialRoutes({
|
|
1098
|
+
store,
|
|
1099
|
+
verify: verifyCredentials,
|
|
1100
|
+
recordStatus,
|
|
1101
|
+
hint: () => config.accessKeyIdHint.get(),
|
|
1102
|
+
notifyChanged: () => {
|
|
1103
|
+
ctx.emit("aishell/credentials-updated");
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
let settlePrompt;
|
|
1107
|
+
/**
|
|
1108
|
+
* End the open form, if any: clear the flag the browser renders from and
|
|
1109
|
+
* hand the credential back to the waiting call.
|
|
1110
|
+
*/
|
|
1111
|
+
const settleCredentialForm = (credentials) => {
|
|
1112
|
+
const settle = settlePrompt;
|
|
1113
|
+
settlePrompt = void 0;
|
|
1114
|
+
recordStatus([{
|
|
1115
|
+
op: "set",
|
|
1116
|
+
path: ["credentialRequestSession"],
|
|
1117
|
+
value: ""
|
|
1118
|
+
}]);
|
|
1119
|
+
settle?.(credentials);
|
|
1120
|
+
};
|
|
1121
|
+
ctx.effect(() => ctx.on("aishell/credential-request", (request) => {
|
|
1122
|
+
settlePrompt?.(void 0);
|
|
1123
|
+
settlePrompt = request.settle;
|
|
1124
|
+
recordStatus([{
|
|
1125
|
+
op: "set",
|
|
1126
|
+
path: ["credentialRequestSession"],
|
|
1127
|
+
value: request.sessionId ?? ""
|
|
1128
|
+
}]);
|
|
1129
|
+
request.signal?.addEventListener("abort", () => {
|
|
1130
|
+
if (settlePrompt === request.settle) settleCredentialForm(void 0);
|
|
1131
|
+
}, { once: true });
|
|
1132
|
+
}), "aishell-credentials: credential form requests");
|
|
1133
|
+
ctx.effect(() => ctx.on("aishell/credentials-updated", () => {
|
|
1134
|
+
if (settlePrompt === void 0) return;
|
|
1135
|
+
const ak$1 = store.get(AK_ACCOUNT);
|
|
1136
|
+
const sk$1 = store.get(SK_ACCOUNT);
|
|
1137
|
+
if (!ak$1 || !sk$1) return;
|
|
1138
|
+
const securityToken = store.get(TOKEN_ACCOUNT);
|
|
1139
|
+
settleCredentialForm({
|
|
1140
|
+
ak: ak$1,
|
|
1141
|
+
sk: sk$1,
|
|
1142
|
+
...securityToken === void 0 ? {} : { securityToken }
|
|
1143
|
+
});
|
|
1144
|
+
}), "aishell-credentials: resume the waiting call");
|
|
1145
|
+
ctx.effect(() => ctx.connection.fetch.register({
|
|
1146
|
+
path: CREDENTIALS_PATH,
|
|
1147
|
+
methods: ["GET", "POST"],
|
|
1148
|
+
requestBody: "buffered",
|
|
1149
|
+
fetch: (request) => request.method === "GET" ? routes.get() : routes.save(request)
|
|
1150
|
+
}), "aishell-credentials: credentials route");
|
|
1151
|
+
ctx.effect(() => ctx.connection.fetch.register({
|
|
1152
|
+
path: CLEAR_PATH,
|
|
1153
|
+
methods: ["POST"],
|
|
1154
|
+
requestBody: "buffered",
|
|
1155
|
+
fetch: routes.clear
|
|
1156
|
+
}), "aishell-credentials: clear route");
|
|
1157
|
+
ctx.effect(() => ctx.connection.fetch.register({
|
|
1158
|
+
path: DISMISS_PATH,
|
|
1159
|
+
methods: ["POST"],
|
|
1160
|
+
requestBody: "buffered",
|
|
1161
|
+
fetch: () => {
|
|
1162
|
+
settleCredentialForm(void 0);
|
|
1163
|
+
return Promise.resolve(Response.json({ ok: true }));
|
|
1164
|
+
}
|
|
1165
|
+
}), "aishell-credentials: dismiss route");
|
|
1166
|
+
const stored = config.credentialsStored.get();
|
|
1167
|
+
const ak = store.get(AK_ACCOUNT);
|
|
1168
|
+
const sk = store.get(SK_ACCOUNT);
|
|
1169
|
+
if (stored && !(ak && sk)) recordStatus([{
|
|
1170
|
+
op: "set",
|
|
1171
|
+
path: ["credentialsStored"],
|
|
1172
|
+
value: false
|
|
1173
|
+
}, {
|
|
1174
|
+
op: "unset",
|
|
1175
|
+
path: ["accessKeyIdHint"]
|
|
1176
|
+
}]);
|
|
1177
|
+
else if (!stored && ak && sk) recordStatus([{
|
|
1178
|
+
op: "set",
|
|
1179
|
+
path: ["credentialsStored"],
|
|
1180
|
+
value: true
|
|
1181
|
+
}]);
|
|
1182
|
+
else if (ak && sk && config.accessKeyIdHint.get() === "") verifyCredentials(ak, sk, store.get(TOKEN_ACCOUNT)).then((accountName) => {
|
|
1183
|
+
recordStatus([{
|
|
1184
|
+
op: "set",
|
|
1185
|
+
path: ["accessKeyIdHint"],
|
|
1186
|
+
value: accountName
|
|
1187
|
+
}]);
|
|
1188
|
+
}).catch(() => {});
|
|
1189
|
+
ctx.effect(() => ctx.settings.configure({ auto: false }, ctx.fiber));
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
//#endregion
|
|
1193
|
+
export { Config, apply, createCredentialRoutes, inject, name };
|
|
1194
|
+
//# sourceMappingURL=index.js.map
|