@tinycloud/cli 0.8.2-beta.0 → 0.8.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +662 -509
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -99,10 +99,10 @@ import ora from "ora";
|
|
|
99
99
|
function outputJson(data) {
|
|
100
100
|
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
|
|
101
101
|
}
|
|
102
|
-
function outputError(
|
|
102
|
+
function outputError(code, message, hint) {
|
|
103
103
|
if (isInteractive()) {
|
|
104
104
|
process.stderr.write(
|
|
105
|
-
`${theme.error("\u2717")} ${theme.label(
|
|
105
|
+
`${theme.error("\u2717")} ${theme.label(code)}: ${message}
|
|
106
106
|
`
|
|
107
107
|
);
|
|
108
108
|
if (hint) {
|
|
@@ -113,7 +113,7 @@ function outputError(code2, message, hint) {
|
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
115
|
const payload = {
|
|
116
|
-
error: { code
|
|
116
|
+
error: { code, message }
|
|
117
117
|
};
|
|
118
118
|
if (hint) payload.error.hint = hint;
|
|
119
119
|
process.stderr.write(JSON.stringify(payload, null, 2) + "\n");
|
|
@@ -300,9 +300,9 @@ var init_errors = __esm({
|
|
|
300
300
|
init_constants();
|
|
301
301
|
init_formatter();
|
|
302
302
|
CLIError = class extends Error {
|
|
303
|
-
constructor(
|
|
303
|
+
constructor(code, message, exitCode = ExitCode.ERROR, metadata) {
|
|
304
304
|
super(message);
|
|
305
|
-
this.code =
|
|
305
|
+
this.code = code;
|
|
306
306
|
this.exitCode = exitCode;
|
|
307
307
|
this.metadata = metadata;
|
|
308
308
|
this.name = "CLIError";
|
|
@@ -10372,6 +10372,123 @@ var init_ed25519 = __esm({
|
|
|
10372
10372
|
}
|
|
10373
10373
|
});
|
|
10374
10374
|
|
|
10375
|
+
// ../../node_modules/ms/index.js
|
|
10376
|
+
var require_ms = __commonJS({
|
|
10377
|
+
"../../node_modules/ms/index.js"(exports, module) {
|
|
10378
|
+
"use strict";
|
|
10379
|
+
var s = 1e3;
|
|
10380
|
+
var m = s * 60;
|
|
10381
|
+
var h = m * 60;
|
|
10382
|
+
var d = h * 24;
|
|
10383
|
+
var w = d * 7;
|
|
10384
|
+
var y = d * 365.25;
|
|
10385
|
+
module.exports = function(val, options) {
|
|
10386
|
+
options = options || {};
|
|
10387
|
+
var type = typeof val;
|
|
10388
|
+
if (type === "string" && val.length > 0) {
|
|
10389
|
+
return parse(val);
|
|
10390
|
+
} else if (type === "number" && isFinite(val)) {
|
|
10391
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
10392
|
+
}
|
|
10393
|
+
throw new Error(
|
|
10394
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
10395
|
+
);
|
|
10396
|
+
};
|
|
10397
|
+
function parse(str) {
|
|
10398
|
+
str = String(str);
|
|
10399
|
+
if (str.length > 100) {
|
|
10400
|
+
return;
|
|
10401
|
+
}
|
|
10402
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
10403
|
+
str
|
|
10404
|
+
);
|
|
10405
|
+
if (!match) {
|
|
10406
|
+
return;
|
|
10407
|
+
}
|
|
10408
|
+
var n = parseFloat(match[1]);
|
|
10409
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
10410
|
+
switch (type) {
|
|
10411
|
+
case "years":
|
|
10412
|
+
case "year":
|
|
10413
|
+
case "yrs":
|
|
10414
|
+
case "yr":
|
|
10415
|
+
case "y":
|
|
10416
|
+
return n * y;
|
|
10417
|
+
case "weeks":
|
|
10418
|
+
case "week":
|
|
10419
|
+
case "w":
|
|
10420
|
+
return n * w;
|
|
10421
|
+
case "days":
|
|
10422
|
+
case "day":
|
|
10423
|
+
case "d":
|
|
10424
|
+
return n * d;
|
|
10425
|
+
case "hours":
|
|
10426
|
+
case "hour":
|
|
10427
|
+
case "hrs":
|
|
10428
|
+
case "hr":
|
|
10429
|
+
case "h":
|
|
10430
|
+
return n * h;
|
|
10431
|
+
case "minutes":
|
|
10432
|
+
case "minute":
|
|
10433
|
+
case "mins":
|
|
10434
|
+
case "min":
|
|
10435
|
+
case "m":
|
|
10436
|
+
return n * m;
|
|
10437
|
+
case "seconds":
|
|
10438
|
+
case "second":
|
|
10439
|
+
case "secs":
|
|
10440
|
+
case "sec":
|
|
10441
|
+
case "s":
|
|
10442
|
+
return n * s;
|
|
10443
|
+
case "milliseconds":
|
|
10444
|
+
case "millisecond":
|
|
10445
|
+
case "msecs":
|
|
10446
|
+
case "msec":
|
|
10447
|
+
case "ms":
|
|
10448
|
+
return n;
|
|
10449
|
+
default:
|
|
10450
|
+
return void 0;
|
|
10451
|
+
}
|
|
10452
|
+
}
|
|
10453
|
+
function fmtShort(ms3) {
|
|
10454
|
+
var msAbs = Math.abs(ms3);
|
|
10455
|
+
if (msAbs >= d) {
|
|
10456
|
+
return Math.round(ms3 / d) + "d";
|
|
10457
|
+
}
|
|
10458
|
+
if (msAbs >= h) {
|
|
10459
|
+
return Math.round(ms3 / h) + "h";
|
|
10460
|
+
}
|
|
10461
|
+
if (msAbs >= m) {
|
|
10462
|
+
return Math.round(ms3 / m) + "m";
|
|
10463
|
+
}
|
|
10464
|
+
if (msAbs >= s) {
|
|
10465
|
+
return Math.round(ms3 / s) + "s";
|
|
10466
|
+
}
|
|
10467
|
+
return ms3 + "ms";
|
|
10468
|
+
}
|
|
10469
|
+
function fmtLong(ms3) {
|
|
10470
|
+
var msAbs = Math.abs(ms3);
|
|
10471
|
+
if (msAbs >= d) {
|
|
10472
|
+
return plural2(ms3, msAbs, d, "day");
|
|
10473
|
+
}
|
|
10474
|
+
if (msAbs >= h) {
|
|
10475
|
+
return plural2(ms3, msAbs, h, "hour");
|
|
10476
|
+
}
|
|
10477
|
+
if (msAbs >= m) {
|
|
10478
|
+
return plural2(ms3, msAbs, m, "minute");
|
|
10479
|
+
}
|
|
10480
|
+
if (msAbs >= s) {
|
|
10481
|
+
return plural2(ms3, msAbs, s, "second");
|
|
10482
|
+
}
|
|
10483
|
+
return ms3 + " ms";
|
|
10484
|
+
}
|
|
10485
|
+
function plural2(ms3, msAbs, n, name2) {
|
|
10486
|
+
var isPlural = msAbs >= n * 1.5;
|
|
10487
|
+
return Math.round(ms3 / n) + " " + name2 + (isPlural ? "s" : "");
|
|
10488
|
+
}
|
|
10489
|
+
}
|
|
10490
|
+
});
|
|
10491
|
+
|
|
10375
10492
|
// ../sdk-services/dist/internal/decrypt-transport-response-error.cjs
|
|
10376
10493
|
var require_decrypt_transport_response_error = __commonJS({
|
|
10377
10494
|
"../sdk-services/dist/internal/decrypt-transport-response-error.cjs"(exports, module) {
|
|
@@ -10416,9 +10533,9 @@ function ok(data) {
|
|
|
10416
10533
|
function err(error) {
|
|
10417
10534
|
return { ok: false, error };
|
|
10418
10535
|
}
|
|
10419
|
-
function serviceError(
|
|
10536
|
+
function serviceError(code, message, service, options) {
|
|
10420
10537
|
return {
|
|
10421
|
-
code
|
|
10538
|
+
code,
|
|
10422
10539
|
message,
|
|
10423
10540
|
service,
|
|
10424
10541
|
cause: options?.cause,
|
|
@@ -11647,16 +11764,16 @@ function ensureNetworkUsableForDecrypt(descriptor) {
|
|
|
11647
11764
|
})
|
|
11648
11765
|
};
|
|
11649
11766
|
}
|
|
11650
|
-
function encryptToNetwork(
|
|
11767
|
+
function encryptToNetwork(crypto23, input) {
|
|
11651
11768
|
parseNetworkId(input.networkId);
|
|
11652
11769
|
const alg = input.alg ?? DEFAULT_ENCRYPTION_ALG;
|
|
11653
11770
|
const keyVersion = input.keyVersion ?? DEFAULT_KEY_VERSION;
|
|
11654
|
-
const symmetricKey =
|
|
11655
|
-
const ciphertext =
|
|
11656
|
-
const wrapped =
|
|
11771
|
+
const symmetricKey = crypto23.randomBytes(32);
|
|
11772
|
+
const ciphertext = crypto23.authEncrypt(symmetricKey, input.plaintext, input.aad);
|
|
11773
|
+
const wrapped = crypto23.sealToNetworkKey(input.networkPublicKey, symmetricKey);
|
|
11657
11774
|
const encryptedSymmetricKey = base64Encode2(wrapped);
|
|
11658
11775
|
const encryptedSymmetricKeyHash = canonicalHashHex(
|
|
11659
|
-
|
|
11776
|
+
crypto23.sha256,
|
|
11660
11777
|
encryptedSymmetricKey
|
|
11661
11778
|
);
|
|
11662
11779
|
const envelope = {
|
|
@@ -11672,7 +11789,7 @@ function encryptToNetwork(crypto22, input) {
|
|
|
11672
11789
|
};
|
|
11673
11790
|
return { envelope, symmetricKey };
|
|
11674
11791
|
}
|
|
11675
|
-
function validateEnvelope(
|
|
11792
|
+
function validateEnvelope(crypto23, envelope) {
|
|
11676
11793
|
if (envelope === null || typeof envelope !== "object") {
|
|
11677
11794
|
return {
|
|
11678
11795
|
ok: false,
|
|
@@ -11728,7 +11845,7 @@ function validateEnvelope(crypto22, envelope) {
|
|
|
11728
11845
|
})
|
|
11729
11846
|
};
|
|
11730
11847
|
}
|
|
11731
|
-
const expectedHash = canonicalHashHex(
|
|
11848
|
+
const expectedHash = canonicalHashHex(crypto23.sha256, e.encryptedSymmetricKey);
|
|
11732
11849
|
if (expectedHash !== e.encryptedSymmetricKeyHash) {
|
|
11733
11850
|
return {
|
|
11734
11851
|
ok: false,
|
|
@@ -11740,10 +11857,10 @@ function validateEnvelope(crypto22, envelope) {
|
|
|
11740
11857
|
}
|
|
11741
11858
|
return { ok: true, data: e };
|
|
11742
11859
|
}
|
|
11743
|
-
function decryptEnvelopeWithKey(
|
|
11860
|
+
function decryptEnvelopeWithKey(crypto23, envelope, symmetricKey) {
|
|
11744
11861
|
const ciphertext = base64Decode2(envelope.ciphertext);
|
|
11745
11862
|
const aad = envelope.aad !== void 0 ? base64Decode2(envelope.aad) : void 0;
|
|
11746
|
-
return
|
|
11863
|
+
return crypto23.authDecrypt(symmetricKey, ciphertext, aad);
|
|
11747
11864
|
}
|
|
11748
11865
|
function buildCanonicalDecryptRequest(input) {
|
|
11749
11866
|
const canonicalBody = canonicalize(input.body);
|
|
@@ -11777,7 +11894,7 @@ function buildDecryptFacts(input) {
|
|
|
11777
11894
|
keyVersion: input.body.keyVersion
|
|
11778
11895
|
};
|
|
11779
11896
|
}
|
|
11780
|
-
function checkDecryptInvocationInput(
|
|
11897
|
+
function checkDecryptInvocationInput(crypto23, input) {
|
|
11781
11898
|
if (input.body.type !== DECRYPT_FACT_TYPE) {
|
|
11782
11899
|
return {
|
|
11783
11900
|
ok: false,
|
|
@@ -11882,7 +11999,7 @@ function checkDecryptInvocationInput(crypto22, input) {
|
|
|
11882
11999
|
const canonicalBody = canonicalize(
|
|
11883
12000
|
input.body
|
|
11884
12001
|
);
|
|
11885
|
-
const expectedBodyHash = canonicalHashHex(
|
|
12002
|
+
const expectedBodyHash = canonicalHashHex(crypto23.sha256, input.body);
|
|
11886
12003
|
if (expectedBodyHash !== input.facts.bodyHash) {
|
|
11887
12004
|
return {
|
|
11888
12005
|
ok: false,
|
|
@@ -11894,8 +12011,8 @@ function checkDecryptInvocationInput(crypto22, input) {
|
|
|
11894
12011
|
}
|
|
11895
12012
|
return { ok: true, data: input, canonicalBody };
|
|
11896
12013
|
}
|
|
11897
|
-
async function buildDecryptInvocation(
|
|
11898
|
-
const checked = checkDecryptInvocationInput(
|
|
12014
|
+
async function buildDecryptInvocation(crypto23, signer, input) {
|
|
12015
|
+
const checked = checkDecryptInvocationInput(crypto23, input);
|
|
11899
12016
|
if (!checked.ok) {
|
|
11900
12017
|
return checked;
|
|
11901
12018
|
}
|
|
@@ -11940,7 +12057,7 @@ function canonicalSignedResponse(response) {
|
|
|
11940
12057
|
return canonicalize(rest);
|
|
11941
12058
|
}
|
|
11942
12059
|
function verifyDecryptResponse(input) {
|
|
11943
|
-
const { crypto:
|
|
12060
|
+
const { crypto: crypto23, request, facts, invocationCid, requestBodyHash, response } = input;
|
|
11944
12061
|
if (response.type !== DECRYPT_RESULT_TYPE) {
|
|
11945
12062
|
return {
|
|
11946
12063
|
ok: false,
|
|
@@ -12023,7 +12140,7 @@ function verifyDecryptResponse(input) {
|
|
|
12023
12140
|
};
|
|
12024
12141
|
}
|
|
12025
12142
|
const expectedRequestHash = hexEncode2(
|
|
12026
|
-
|
|
12143
|
+
crypto23.sha256(utf8Encode(`${invocationCid}${requestBodyHash}`))
|
|
12027
12144
|
);
|
|
12028
12145
|
if (response.requestHash !== expectedRequestHash) {
|
|
12029
12146
|
return {
|
|
@@ -12047,7 +12164,7 @@ function verifyDecryptResponse(input) {
|
|
|
12047
12164
|
canonicalSignedResponse(response)
|
|
12048
12165
|
);
|
|
12049
12166
|
const signatureBytes = base64Decode2(response.nodeSignature);
|
|
12050
|
-
if (!
|
|
12167
|
+
if (!crypto23.verifyNodeSignature(response.nodeId, signedBytes, signatureBytes)) {
|
|
12051
12168
|
return {
|
|
12052
12169
|
ok: false,
|
|
12053
12170
|
error: encryptionError({
|
|
@@ -12057,9 +12174,9 @@ function verifyDecryptResponse(input) {
|
|
|
12057
12174
|
}
|
|
12058
12175
|
return { ok: true, data: response };
|
|
12059
12176
|
}
|
|
12060
|
-
function openWrappedKey(
|
|
12177
|
+
function openWrappedKey(crypto23, receiverPrivateKey, response) {
|
|
12061
12178
|
const wrapped = base64Decode2(response.wrappedKey);
|
|
12062
|
-
return
|
|
12179
|
+
return crypto23.openWithReceiverKey(receiverPrivateKey, wrapped);
|
|
12063
12180
|
}
|
|
12064
12181
|
function encOk(data) {
|
|
12065
12182
|
return { ok: true, data };
|
|
@@ -12285,7 +12402,9 @@ var init_dist2 = __esm({
|
|
|
12285
12402
|
GenericKVResponseSchema = createKVResponseSchema(external_exports.unknown());
|
|
12286
12403
|
KVListResponseSchema = external_exports.object({
|
|
12287
12404
|
/** Array of keys matching the list criteria */
|
|
12288
|
-
keys: external_exports.array(external_exports.string())
|
|
12405
|
+
keys: external_exports.array(external_exports.string()),
|
|
12406
|
+
truncated: external_exports.boolean().optional(),
|
|
12407
|
+
nextCursor: external_exports.string().optional()
|
|
12289
12408
|
});
|
|
12290
12409
|
KVListResultSchema = createResultSchema(KVListResponseSchema);
|
|
12291
12410
|
ServiceRequestEventSchema = external_exports.object({
|
|
@@ -13127,10 +13246,10 @@ var init_dist2 = __esm({
|
|
|
13127
13246
|
...resource && { resource }
|
|
13128
13247
|
}));
|
|
13129
13248
|
}
|
|
13130
|
-
const
|
|
13249
|
+
const code = response.status === 400 ? ErrorCodes.INVALID_INPUT : ErrorCodes.NETWORK_ERROR;
|
|
13131
13250
|
return err(
|
|
13132
13251
|
serviceError(
|
|
13133
|
-
|
|
13252
|
+
code,
|
|
13134
13253
|
`Failed to create signed read URL for key "${key}": ${response.status} - ${errorText}`,
|
|
13135
13254
|
"kv",
|
|
13136
13255
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
@@ -13437,7 +13556,10 @@ var init_dist2 = __esm({
|
|
|
13437
13556
|
KVAction.LIST,
|
|
13438
13557
|
void 0,
|
|
13439
13558
|
options?.signal,
|
|
13440
|
-
options?.limit === void 0 ? void 0 : {
|
|
13559
|
+
options?.limit === void 0 && options?.cursor === void 0 ? void 0 : {
|
|
13560
|
+
...options?.limit === void 0 ? {} : { "x-tinycloud-limit": String(options.limit) },
|
|
13561
|
+
...options?.cursor === void 0 ? {} : { "x-tinycloud-cursor": options.cursor }
|
|
13562
|
+
}
|
|
13441
13563
|
);
|
|
13442
13564
|
if (!response.ok) {
|
|
13443
13565
|
if (response.status === 401) {
|
|
@@ -13469,7 +13591,8 @@ var init_dist2 = __esm({
|
|
|
13469
13591
|
}
|
|
13470
13592
|
return ok({
|
|
13471
13593
|
keys,
|
|
13472
|
-
...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" }
|
|
13594
|
+
...response.headers.get("x-tinycloud-truncated") === null ? {} : { truncated: response.headers.get("x-tinycloud-truncated") === "true" },
|
|
13595
|
+
...response.headers.get("x-tinycloud-next-cursor") === null ? {} : { nextCursor: response.headers.get("x-tinycloud-next-cursor") ?? void 0 }
|
|
13473
13596
|
});
|
|
13474
13597
|
} catch (error) {
|
|
13475
13598
|
return err(wrapError2("kv", error));
|
|
@@ -15535,6 +15658,10 @@ var init_dist2 = __esm({
|
|
|
15535
15658
|
* @returns Result with array of key names (vault/ prefix stripped)
|
|
15536
15659
|
*/
|
|
15537
15660
|
async list(options) {
|
|
15661
|
+
const page = await this.listPage(options);
|
|
15662
|
+
return page.ok ? { ok: true, data: page.data.keys } : page;
|
|
15663
|
+
}
|
|
15664
|
+
async listPage(options) {
|
|
15538
15665
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
15539
15666
|
if (!this.isUnlocked) {
|
|
15540
15667
|
return vaultError({
|
|
@@ -15552,7 +15679,9 @@ var init_dist2 = __esm({
|
|
|
15552
15679
|
const listPrefix = options?.prefix ? `vault/${options.prefix}` : "vault/";
|
|
15553
15680
|
const listResult = await this.tc.kv.list({
|
|
15554
15681
|
prefix: listPrefix,
|
|
15555
|
-
removePrefix: true
|
|
15682
|
+
removePrefix: true,
|
|
15683
|
+
...options?.limit === void 0 ? {} : { limit: options.limit },
|
|
15684
|
+
...options?.cursor === void 0 ? {} : { cursor: options.cursor }
|
|
15556
15685
|
});
|
|
15557
15686
|
if (!listResult.ok) {
|
|
15558
15687
|
return vaultError({
|
|
@@ -15569,7 +15698,11 @@ var init_dist2 = __esm({
|
|
|
15569
15698
|
(k) => k.startsWith(userPrefix) ? k.slice(userPrefix.length) : k
|
|
15570
15699
|
);
|
|
15571
15700
|
}
|
|
15572
|
-
return ok(
|
|
15701
|
+
return ok({
|
|
15702
|
+
keys,
|
|
15703
|
+
truncated: listResult.data.truncated === true,
|
|
15704
|
+
...listResult.data.nextCursor === void 0 ? {} : { nextCursor: listResult.data.nextCursor }
|
|
15705
|
+
});
|
|
15573
15706
|
} catch (error) {
|
|
15574
15707
|
return vaultError({
|
|
15575
15708
|
code: "STORAGE_ERROR",
|
|
@@ -16348,126 +16481,9 @@ var init_dist2 = __esm({
|
|
|
16348
16481
|
}
|
|
16349
16482
|
});
|
|
16350
16483
|
|
|
16351
|
-
// ../../node_modules/ms/index.js
|
|
16352
|
-
var require_ms = __commonJS({
|
|
16353
|
-
"../../node_modules/ms/index.js"(exports, module) {
|
|
16354
|
-
"use strict";
|
|
16355
|
-
var s = 1e3;
|
|
16356
|
-
var m = s * 60;
|
|
16357
|
-
var h = m * 60;
|
|
16358
|
-
var d = h * 24;
|
|
16359
|
-
var w = d * 7;
|
|
16360
|
-
var y = d * 365.25;
|
|
16361
|
-
module.exports = function(val, options) {
|
|
16362
|
-
options = options || {};
|
|
16363
|
-
var type = typeof val;
|
|
16364
|
-
if (type === "string" && val.length > 0) {
|
|
16365
|
-
return parse(val);
|
|
16366
|
-
} else if (type === "number" && isFinite(val)) {
|
|
16367
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
16368
|
-
}
|
|
16369
|
-
throw new Error(
|
|
16370
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
16371
|
-
);
|
|
16372
|
-
};
|
|
16373
|
-
function parse(str) {
|
|
16374
|
-
str = String(str);
|
|
16375
|
-
if (str.length > 100) {
|
|
16376
|
-
return;
|
|
16377
|
-
}
|
|
16378
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
16379
|
-
str
|
|
16380
|
-
);
|
|
16381
|
-
if (!match) {
|
|
16382
|
-
return;
|
|
16383
|
-
}
|
|
16384
|
-
var n = parseFloat(match[1]);
|
|
16385
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
16386
|
-
switch (type) {
|
|
16387
|
-
case "years":
|
|
16388
|
-
case "year":
|
|
16389
|
-
case "yrs":
|
|
16390
|
-
case "yr":
|
|
16391
|
-
case "y":
|
|
16392
|
-
return n * y;
|
|
16393
|
-
case "weeks":
|
|
16394
|
-
case "week":
|
|
16395
|
-
case "w":
|
|
16396
|
-
return n * w;
|
|
16397
|
-
case "days":
|
|
16398
|
-
case "day":
|
|
16399
|
-
case "d":
|
|
16400
|
-
return n * d;
|
|
16401
|
-
case "hours":
|
|
16402
|
-
case "hour":
|
|
16403
|
-
case "hrs":
|
|
16404
|
-
case "hr":
|
|
16405
|
-
case "h":
|
|
16406
|
-
return n * h;
|
|
16407
|
-
case "minutes":
|
|
16408
|
-
case "minute":
|
|
16409
|
-
case "mins":
|
|
16410
|
-
case "min":
|
|
16411
|
-
case "m":
|
|
16412
|
-
return n * m;
|
|
16413
|
-
case "seconds":
|
|
16414
|
-
case "second":
|
|
16415
|
-
case "secs":
|
|
16416
|
-
case "sec":
|
|
16417
|
-
case "s":
|
|
16418
|
-
return n * s;
|
|
16419
|
-
case "milliseconds":
|
|
16420
|
-
case "millisecond":
|
|
16421
|
-
case "msecs":
|
|
16422
|
-
case "msec":
|
|
16423
|
-
case "ms":
|
|
16424
|
-
return n;
|
|
16425
|
-
default:
|
|
16426
|
-
return void 0;
|
|
16427
|
-
}
|
|
16428
|
-
}
|
|
16429
|
-
function fmtShort(ms3) {
|
|
16430
|
-
var msAbs = Math.abs(ms3);
|
|
16431
|
-
if (msAbs >= d) {
|
|
16432
|
-
return Math.round(ms3 / d) + "d";
|
|
16433
|
-
}
|
|
16434
|
-
if (msAbs >= h) {
|
|
16435
|
-
return Math.round(ms3 / h) + "h";
|
|
16436
|
-
}
|
|
16437
|
-
if (msAbs >= m) {
|
|
16438
|
-
return Math.round(ms3 / m) + "m";
|
|
16439
|
-
}
|
|
16440
|
-
if (msAbs >= s) {
|
|
16441
|
-
return Math.round(ms3 / s) + "s";
|
|
16442
|
-
}
|
|
16443
|
-
return ms3 + "ms";
|
|
16444
|
-
}
|
|
16445
|
-
function fmtLong(ms3) {
|
|
16446
|
-
var msAbs = Math.abs(ms3);
|
|
16447
|
-
if (msAbs >= d) {
|
|
16448
|
-
return plural2(ms3, msAbs, d, "day");
|
|
16449
|
-
}
|
|
16450
|
-
if (msAbs >= h) {
|
|
16451
|
-
return plural2(ms3, msAbs, h, "hour");
|
|
16452
|
-
}
|
|
16453
|
-
if (msAbs >= m) {
|
|
16454
|
-
return plural2(ms3, msAbs, m, "minute");
|
|
16455
|
-
}
|
|
16456
|
-
if (msAbs >= s) {
|
|
16457
|
-
return plural2(ms3, msAbs, s, "second");
|
|
16458
|
-
}
|
|
16459
|
-
return ms3 + " ms";
|
|
16460
|
-
}
|
|
16461
|
-
function plural2(ms3, msAbs, n, name2) {
|
|
16462
|
-
var isPlural = msAbs >= n * 1.5;
|
|
16463
|
-
return Math.round(ms3 / n) + " " + name2 + (isPlural ? "s" : "");
|
|
16464
|
-
}
|
|
16465
|
-
}
|
|
16466
|
-
});
|
|
16467
|
-
|
|
16468
16484
|
// ../sdk-core/dist/index.js
|
|
16469
16485
|
import { SiweMessage } from "siwe";
|
|
16470
|
-
import
|
|
16486
|
+
import crypto22 from "crypto";
|
|
16471
16487
|
import { Buffer as Buffer2 } from "buffer";
|
|
16472
16488
|
import { Buffer as Buffer3 } from "buffer";
|
|
16473
16489
|
import { Buffer as Buffer4 } from "buffer";
|
|
@@ -16755,8 +16771,8 @@ function read2(buf, offset) {
|
|
|
16755
16771
|
return res;
|
|
16756
16772
|
}
|
|
16757
16773
|
function decode3(data, offset = 0) {
|
|
16758
|
-
const
|
|
16759
|
-
return [
|
|
16774
|
+
const code3 = varint_default.decode(data, offset);
|
|
16775
|
+
return [code3, varint_default.decode.bytes];
|
|
16760
16776
|
}
|
|
16761
16777
|
function encodeTo(int, target, offset = 0) {
|
|
16762
16778
|
varint_default.encode(int, target, offset);
|
|
@@ -16765,25 +16781,25 @@ function encodeTo(int, target, offset = 0) {
|
|
|
16765
16781
|
function encodingLength(int) {
|
|
16766
16782
|
return varint_default.encodingLength(int);
|
|
16767
16783
|
}
|
|
16768
|
-
function create(
|
|
16769
|
-
const size2 =
|
|
16770
|
-
const sizeOffset = encodingLength(
|
|
16784
|
+
function create(code3, digest4) {
|
|
16785
|
+
const size2 = digest4.byteLength;
|
|
16786
|
+
const sizeOffset = encodingLength(code3);
|
|
16771
16787
|
const digestOffset = sizeOffset + encodingLength(size2);
|
|
16772
|
-
const
|
|
16773
|
-
encodeTo(
|
|
16774
|
-
encodeTo(size2,
|
|
16775
|
-
|
|
16776
|
-
return new Digest(
|
|
16788
|
+
const bytes2 = new Uint8Array(digestOffset + size2);
|
|
16789
|
+
encodeTo(code3, bytes2, 0);
|
|
16790
|
+
encodeTo(size2, bytes2, sizeOffset);
|
|
16791
|
+
bytes2.set(digest4, digestOffset);
|
|
16792
|
+
return new Digest(code3, size2, digest4, bytes2);
|
|
16777
16793
|
}
|
|
16778
16794
|
function decode4(multihash) {
|
|
16779
|
-
const
|
|
16780
|
-
const [
|
|
16781
|
-
const [size2, digestOffset] = decode3(
|
|
16782
|
-
const
|
|
16783
|
-
if (
|
|
16795
|
+
const bytes2 = coerce2(multihash);
|
|
16796
|
+
const [code3, sizeOffset] = decode3(bytes2);
|
|
16797
|
+
const [size2, digestOffset] = decode3(bytes2.subarray(sizeOffset));
|
|
16798
|
+
const digest4 = bytes2.subarray(sizeOffset + digestOffset);
|
|
16799
|
+
if (digest4.byteLength !== size2) {
|
|
16784
16800
|
throw new Error("Incorrect length");
|
|
16785
16801
|
}
|
|
16786
|
-
return new Digest(
|
|
16802
|
+
return new Digest(code3, size2, digest4, bytes2);
|
|
16787
16803
|
}
|
|
16788
16804
|
function equals2(a, b) {
|
|
16789
16805
|
if (a === b) {
|
|
@@ -16794,19 +16810,19 @@ function equals2(a, b) {
|
|
|
16794
16810
|
}
|
|
16795
16811
|
}
|
|
16796
16812
|
function format(link, base3) {
|
|
16797
|
-
const { bytes, version: version3 } = link;
|
|
16813
|
+
const { bytes: bytes2, version: version3 } = link;
|
|
16798
16814
|
switch (version3) {
|
|
16799
16815
|
case 0:
|
|
16800
|
-
return toStringV0(
|
|
16816
|
+
return toStringV0(bytes2, baseCache(link), base3 ?? base58btc.encoder);
|
|
16801
16817
|
default:
|
|
16802
|
-
return toStringV1(
|
|
16818
|
+
return toStringV1(bytes2, baseCache(link), base3 ?? base32.encoder);
|
|
16803
16819
|
}
|
|
16804
16820
|
}
|
|
16805
|
-
function baseCache(
|
|
16806
|
-
const baseCache2 = cache.get(
|
|
16821
|
+
function baseCache(cid2) {
|
|
16822
|
+
const baseCache2 = cache.get(cid2);
|
|
16807
16823
|
if (baseCache2 == null) {
|
|
16808
16824
|
const baseCache3 = /* @__PURE__ */ new Map();
|
|
16809
|
-
cache.set(
|
|
16825
|
+
cache.set(cid2, baseCache3);
|
|
16810
16826
|
return baseCache3;
|
|
16811
16827
|
}
|
|
16812
16828
|
return baseCache2;
|
|
@@ -16841,39 +16857,39 @@ function parseCIDtoBytes(source, base3) {
|
|
|
16841
16857
|
}
|
|
16842
16858
|
}
|
|
16843
16859
|
}
|
|
16844
|
-
function toStringV0(
|
|
16860
|
+
function toStringV0(bytes2, cache2, base3) {
|
|
16845
16861
|
const { prefix } = base3;
|
|
16846
16862
|
if (prefix !== base58btc.prefix) {
|
|
16847
16863
|
throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
|
|
16848
16864
|
}
|
|
16849
|
-
const
|
|
16850
|
-
if (
|
|
16851
|
-
const
|
|
16852
|
-
cache2.set(prefix,
|
|
16853
|
-
return
|
|
16865
|
+
const cid2 = cache2.get(prefix);
|
|
16866
|
+
if (cid2 == null) {
|
|
16867
|
+
const cid3 = base3.encode(bytes2).slice(1);
|
|
16868
|
+
cache2.set(prefix, cid3);
|
|
16869
|
+
return cid3;
|
|
16854
16870
|
} else {
|
|
16855
|
-
return
|
|
16871
|
+
return cid2;
|
|
16856
16872
|
}
|
|
16857
16873
|
}
|
|
16858
|
-
function toStringV1(
|
|
16874
|
+
function toStringV1(bytes2, cache2, base3) {
|
|
16859
16875
|
const { prefix } = base3;
|
|
16860
|
-
const
|
|
16861
|
-
if (
|
|
16862
|
-
const
|
|
16863
|
-
cache2.set(prefix,
|
|
16864
|
-
return
|
|
16876
|
+
const cid2 = cache2.get(prefix);
|
|
16877
|
+
if (cid2 == null) {
|
|
16878
|
+
const cid3 = base3.encode(bytes2);
|
|
16879
|
+
cache2.set(prefix, cid3);
|
|
16880
|
+
return cid3;
|
|
16865
16881
|
} else {
|
|
16866
|
-
return
|
|
16882
|
+
return cid2;
|
|
16867
16883
|
}
|
|
16868
16884
|
}
|
|
16869
|
-
function encodeCID(version3,
|
|
16885
|
+
function encodeCID(version3, code3, multihash) {
|
|
16870
16886
|
const codeOffset = encodingLength(version3);
|
|
16871
|
-
const hashOffset = codeOffset + encodingLength(
|
|
16872
|
-
const
|
|
16873
|
-
encodeTo(version3,
|
|
16874
|
-
encodeTo(
|
|
16875
|
-
|
|
16876
|
-
return
|
|
16887
|
+
const hashOffset = codeOffset + encodingLength(code3);
|
|
16888
|
+
const bytes2 = new Uint8Array(hashOffset + multihash.byteLength);
|
|
16889
|
+
encodeTo(version3, bytes2, 0);
|
|
16890
|
+
encodeTo(code3, bytes2, codeOffset);
|
|
16891
|
+
bytes2.set(multihash, hashOffset);
|
|
16892
|
+
return bytes2;
|
|
16877
16893
|
}
|
|
16878
16894
|
function encode3(data) {
|
|
16879
16895
|
return data.reduce((p, c) => {
|
|
@@ -16903,19 +16919,19 @@ function digest(input, options2) {
|
|
|
16903
16919
|
}
|
|
16904
16920
|
input = input.subarray(0, options2.truncate);
|
|
16905
16921
|
}
|
|
16906
|
-
return create(
|
|
16922
|
+
return create(code2, encode4(input));
|
|
16907
16923
|
}
|
|
16908
|
-
function from2({ name: name2, code:
|
|
16909
|
-
return new Hasher(name2,
|
|
16924
|
+
function from2({ name: name2, code: code3, encode: encode5, minDigestLength, maxDigestLength }) {
|
|
16925
|
+
return new Hasher(name2, code3, encode5, minDigestLength, maxDigestLength);
|
|
16910
16926
|
}
|
|
16911
|
-
function createDigest(
|
|
16912
|
-
if (truncate != null && truncate !==
|
|
16913
|
-
if (truncate >
|
|
16914
|
-
throw new Error(`Invalid truncate option, must be less than or equal to ${
|
|
16927
|
+
function createDigest(digest4, code3, truncate) {
|
|
16928
|
+
if (truncate != null && truncate !== digest4.byteLength) {
|
|
16929
|
+
if (truncate > digest4.byteLength) {
|
|
16930
|
+
throw new Error(`Invalid truncate option, must be less than or equal to ${digest4.byteLength}`);
|
|
16915
16931
|
}
|
|
16916
|
-
|
|
16932
|
+
digest4 = digest4.subarray(0, truncate);
|
|
16917
16933
|
}
|
|
16918
|
-
return create(
|
|
16934
|
+
return create(code3, digest4);
|
|
16919
16935
|
}
|
|
16920
16936
|
function parseStrictRfc33392(value) {
|
|
16921
16937
|
if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
|
|
@@ -17281,27 +17297,27 @@ function validate(...funcs) {
|
|
|
17281
17297
|
}
|
|
17282
17298
|
};
|
|
17283
17299
|
}
|
|
17284
|
-
function bytesToComponents(
|
|
17300
|
+
function bytesToComponents(bytes2) {
|
|
17285
17301
|
const components = [];
|
|
17286
17302
|
let i = 0;
|
|
17287
|
-
while (i <
|
|
17288
|
-
const
|
|
17289
|
-
const codec = registry.getProtocol(
|
|
17290
|
-
const codeLength = encodingLength2(
|
|
17291
|
-
const size2 = sizeForAddr(codec,
|
|
17303
|
+
while (i < bytes2.length) {
|
|
17304
|
+
const code3 = decode6(bytes2, i);
|
|
17305
|
+
const codec = registry.getProtocol(code3);
|
|
17306
|
+
const codeLength = encodingLength2(code3);
|
|
17307
|
+
const size2 = sizeForAddr(codec, bytes2, i + codeLength);
|
|
17292
17308
|
let sizeLength = 0;
|
|
17293
17309
|
if (size2 > 0 && codec.size === V) {
|
|
17294
17310
|
sizeLength = encodingLength2(size2);
|
|
17295
17311
|
}
|
|
17296
17312
|
const componentLength = codeLength + sizeLength + size2;
|
|
17297
17313
|
const component = {
|
|
17298
|
-
code:
|
|
17314
|
+
code: code3,
|
|
17299
17315
|
name: codec.name,
|
|
17300
|
-
bytes:
|
|
17316
|
+
bytes: bytes2.subarray(i, i + componentLength)
|
|
17301
17317
|
};
|
|
17302
17318
|
if (size2 > 0) {
|
|
17303
17319
|
const valueOffset = i + codeLength + sizeLength;
|
|
17304
|
-
const valueBytes =
|
|
17320
|
+
const valueBytes = bytes2.subarray(valueOffset, valueOffset + size2);
|
|
17305
17321
|
component.value = codec.bytesToValue?.(valueBytes) ?? toString2(valueBytes);
|
|
17306
17322
|
}
|
|
17307
17323
|
components.push(component);
|
|
@@ -17311,7 +17327,7 @@ function bytesToComponents(bytes) {
|
|
|
17311
17327
|
}
|
|
17312
17328
|
function componentsToBytes(components) {
|
|
17313
17329
|
let length2 = 0;
|
|
17314
|
-
const
|
|
17330
|
+
const bytes2 = [];
|
|
17315
17331
|
for (const component of components) {
|
|
17316
17332
|
if (component.bytes == null) {
|
|
17317
17333
|
const codec = registry.getProtocol(component.code);
|
|
@@ -17326,23 +17342,23 @@ function componentsToBytes(components) {
|
|
|
17326
17342
|
valueLengthLength = encodingLength2(valueLength);
|
|
17327
17343
|
}
|
|
17328
17344
|
}
|
|
17329
|
-
const
|
|
17345
|
+
const bytes3 = new Uint8Array(codecLength + valueLengthLength + valueLength);
|
|
17330
17346
|
let offset = 0;
|
|
17331
|
-
encodeUint8Array(component.code,
|
|
17347
|
+
encodeUint8Array(component.code, bytes3, offset);
|
|
17332
17348
|
offset += codecLength;
|
|
17333
17349
|
if (valueBytes != null) {
|
|
17334
17350
|
if (codec.size === V) {
|
|
17335
|
-
encodeUint8Array(valueLength,
|
|
17351
|
+
encodeUint8Array(valueLength, bytes3, offset);
|
|
17336
17352
|
offset += valueLengthLength;
|
|
17337
17353
|
}
|
|
17338
|
-
|
|
17354
|
+
bytes3.set(valueBytes, offset);
|
|
17339
17355
|
}
|
|
17340
|
-
component.bytes =
|
|
17356
|
+
component.bytes = bytes3;
|
|
17341
17357
|
}
|
|
17342
|
-
|
|
17358
|
+
bytes2.push(component.bytes);
|
|
17343
17359
|
length2 += component.bytes.byteLength;
|
|
17344
17360
|
}
|
|
17345
|
-
return concat2(
|
|
17361
|
+
return concat2(bytes2, length2);
|
|
17346
17362
|
}
|
|
17347
17363
|
function stringToComponents(string2) {
|
|
17348
17364
|
if (string2.charAt(0) !== "/") {
|
|
@@ -17416,14 +17432,14 @@ function componentsToString(components) {
|
|
|
17416
17432
|
];
|
|
17417
17433
|
}).join("/")}`;
|
|
17418
17434
|
}
|
|
17419
|
-
function sizeForAddr(codec,
|
|
17435
|
+
function sizeForAddr(codec, bytes2, offset) {
|
|
17420
17436
|
if (codec.size == null || codec.size === 0) {
|
|
17421
17437
|
return 0;
|
|
17422
17438
|
}
|
|
17423
17439
|
if (codec.size > 0) {
|
|
17424
17440
|
return codec.size / 8;
|
|
17425
17441
|
}
|
|
17426
|
-
return decode6(
|
|
17442
|
+
return decode6(bytes2, offset);
|
|
17427
17443
|
}
|
|
17428
17444
|
function toComponents(addr) {
|
|
17429
17445
|
if (addr == null) {
|
|
@@ -17476,7 +17492,7 @@ function extractTuple(name2, ma) {
|
|
|
17476
17492
|
return ma.find((component) => component.name === name2);
|
|
17477
17493
|
}
|
|
17478
17494
|
function hasTLS(ma) {
|
|
17479
|
-
return ma.some(({ code:
|
|
17495
|
+
return ma.some(({ code: code3 }) => code3 === CODE_TLS);
|
|
17480
17496
|
}
|
|
17481
17497
|
function interpretNext(head, rest) {
|
|
17482
17498
|
const interpreter = interpreters[head.name];
|
|
@@ -17843,12 +17859,12 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
17843
17859
|
"did:key must use base58btc multibase"
|
|
17844
17860
|
);
|
|
17845
17861
|
}
|
|
17846
|
-
const
|
|
17847
|
-
if (
|
|
17848
|
-
return
|
|
17862
|
+
const bytes2 = bases.base58btc.decode(identifier);
|
|
17863
|
+
if (bytes2.length === 34 && bytes2[0] === 237 && bytes2[1] === 1) {
|
|
17864
|
+
return bytes2.slice(2);
|
|
17849
17865
|
}
|
|
17850
|
-
if (
|
|
17851
|
-
return
|
|
17866
|
+
if (bytes2.length === 33 && bytes2[0] === 237) {
|
|
17867
|
+
return bytes2.slice(1);
|
|
17852
17868
|
}
|
|
17853
17869
|
throw new LocationRecordValidationError(
|
|
17854
17870
|
"did:key must be an Ed25519 public key"
|
|
@@ -17856,7 +17872,7 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
17856
17872
|
}
|
|
17857
17873
|
function decodeBase64Url(value) {
|
|
17858
17874
|
const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
17859
|
-
const
|
|
17875
|
+
const bytes2 = [];
|
|
17860
17876
|
let buffer = 0;
|
|
17861
17877
|
let bits = 0;
|
|
17862
17878
|
for (const char of value) {
|
|
@@ -17870,30 +17886,32 @@ function decodeBase64Url(value) {
|
|
|
17870
17886
|
bits += 6;
|
|
17871
17887
|
if (bits >= 8) {
|
|
17872
17888
|
bits -= 8;
|
|
17873
|
-
|
|
17889
|
+
bytes2.push(buffer >> bits & 255);
|
|
17874
17890
|
}
|
|
17875
17891
|
}
|
|
17876
|
-
return Uint8Array.from(
|
|
17892
|
+
return Uint8Array.from(bytes2);
|
|
17877
17893
|
}
|
|
17878
|
-
var import_ms, __defProp2, __typeError, __defNormalProp, __export2, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36_exports, base36, base36upper, base58_exports, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, _a, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base2, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base64, base64pad, base64url, base64urlpad, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2,
|
|
17894
|
+
var import_ms, __defProp2, __typeError, __defNormalProp, __export2, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36_exports, base36, base36upper, base58_exports, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, _a, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base2, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base64, base64pad, base64url, base64urlpad, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code2, name, encode4, identity2, sha2_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha2562, sha5122, bases, hashes, textEncoder3, objectHasOwn3, TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA, OWNER_NODE_ENDPOINT_SCHEMA, W3C_VC_CREDENTIAL_VERIFIER, objectHasOwn4, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, JsonValueSchema, Rfc3339Schema, SignedRecordSchema, PolicyEngineSchema, OwnerNodeSchema, ResourceHintSchema, BootstrapSchema, SignatureSchema, ChallengeSchema, ChallengeResponseSchema, DenialSchema, ErrorEnvelopeDenialSchema, WireDelegationSchema, ResolveResponseSchema, DelegateReceiptSchema, SqlReadResponseSchema, KvReadResponseSchema, LISTEN_SQL_STATEMENT_CATALOG, LISTEN_SQL_STATEMENT_BY_NAME, JWKSchema, KeyTypeSchema, KeyInfoSchema, DelegationErrorSchema, DelegationSchema, DelegationStatusSchema, DelegationRevocationReceiptSchema, AccountDelegationResourceSchema, AccountDelegationDateSchema, AccountDelegationRecordSchema, AccountDelegationPageSchema, AccountDelegationQueryOptionsSchema, CapabilityEntrySchema, DelegationRecordSchema, CreateDelegationParamsSchema, DelegationChainSchema, DelegationChainV2Schema, DelegationDirectionSchema, DelegationFiltersSchema, SpaceOwnershipSchema, SpaceInfoSchema, ShareSchemaSchema, ShareLinkSchema, ShareLinkDataSchema, IngestOptionsSchema, GenerateShareParamsSchema, DelegationManagerConfigSchema, KeyProviderSchema, DelegationApiResponseSchema, DelegatedResourceSchema, CreateDelegationWasmParamsSchema, CreateDelegationWasmResultSchema, EPHEMERAL_MS, SIGNED_READ_URL_MS, SESSION_MS, SHARE_MS, APP_MS, MAX_MS, EXPIRY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS2, EncodedShareDataSchema, ReceiveOptionsSchema, SharingServiceConfigSchema, DEFAULT_KNOWLEDGE_ROOT, ManifestValidationError, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, DEFAULT_MAX_INLINE_BYTES, MAX_SHARE_CONTENT_BYTES, MAX_SEALED_SHARE_CONTENT_BYTES, MAX_SHARE_ARTIFACT_BYTES, PUBLISHED_AAD, ShareRecipientTargetSchema, ShareResourceSchema, ShareActionSchema, ShareRecipientPolicySchema, ShareRecipientClientOptionsSchema, ShareNativeActionSchema, ShareWireActionSchema, ShareContentSourceSchema, ShareAddressedRecipientSchema, ShareAddressedDelegationRequestV2Schema, ShareAddressedDelegationEnvelopeV2Schema, ShareAddressedDelegationResponseV2Schema, ShareNativeResponseEntrySchema, ShareNativeResponseBase, ShareNativeResponseSchema, MAX_NATIVE_CURSOR_BYTES, DEFAULT_EXPIRY_MS2, MAX_CONTENT_BYTES, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N12, N22, N32, N42, N52, N62, N72, MSB2, REST2, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, CODE_IP4, CODE_TCP, CODE_UDP, CODE_DCCP, CODE_IP6, CODE_IP6ZONE, CODE_IPCIDR, CODE_DNS, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_SCTP, CODE_UDT, CODE_UTP, CODE_UNIX, CODE_P2P, CODE_ONION, CODE_ONION3, CODE_GARLIC64, CODE_GARLIC32, CODE_TLS, CODE_SNI, CODE_NOISE, CODE_QUIC, CODE_QUIC_V1, CODE_WEBTRANSPORT, CODE_CERTHASH, CODE_HTTP, CODE_HTTP_PATH, CODE_HTTPS, CODE_WS, CODE_WSS, CODE_P2P_WEBSOCKET_STAR, CODE_P2P_STARDUST, CODE_P2P_WEBRTC_STAR, CODE_P2P_WEBRTC_DIRECT, CODE_WEBRTC_DIRECT, CODE_WEBRTC, CODE_P2P_CIRCUIT, CODE_MEMORY, ip4ToBytes, ip6ToBytes, ip4ToString, ip6ToString, decoders, anybaseDecoder, validatePort, V, Registry, registry, codecs, inspect, symbol, _a2, _components, _string, _bytes, _Multiaddr, Multiaddr, ASSUME_HTTP_CODES, interpreters, word, boundry, v4, v6segment, v6, v46Exact, v4exact, v6exact, ipRegex, toString3, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, DEFAULT_LOCAL_NODE_URL, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
|
|
17879
17895
|
var init_dist3 = __esm({
|
|
17880
17896
|
"../sdk-core/dist/index.js"() {
|
|
17881
17897
|
"use strict";
|
|
17882
17898
|
init_zod();
|
|
17883
17899
|
init_zod();
|
|
17884
17900
|
init_dist();
|
|
17885
|
-
init_dist2();
|
|
17886
17901
|
init_zod();
|
|
17902
|
+
init_zod();
|
|
17903
|
+
import_ms = __toESM(require_ms(), 1);
|
|
17887
17904
|
init_dist2();
|
|
17888
17905
|
init_dist2();
|
|
17889
17906
|
init_zod();
|
|
17907
|
+
init_dist2();
|
|
17890
17908
|
init_zod();
|
|
17891
17909
|
init_dist2();
|
|
17892
|
-
|
|
17910
|
+
init_dist2();
|
|
17911
|
+
init_zod();
|
|
17893
17912
|
init_dist2();
|
|
17894
17913
|
init_dist();
|
|
17895
17914
|
init_dist2();
|
|
17896
|
-
init_zod();
|
|
17897
17915
|
init_dist2();
|
|
17898
17916
|
init_dist();
|
|
17899
17917
|
init_ed25519();
|
|
@@ -17961,9 +17979,9 @@ var init_dist3 = __esm({
|
|
|
17961
17979
|
this.prefix = prefix;
|
|
17962
17980
|
this.baseEncode = baseEncode;
|
|
17963
17981
|
}
|
|
17964
|
-
encode(
|
|
17965
|
-
if (
|
|
17966
|
-
return `${this.prefix}${this.baseEncode(
|
|
17982
|
+
encode(bytes2) {
|
|
17983
|
+
if (bytes2 instanceof Uint8Array) {
|
|
17984
|
+
return `${this.prefix}${this.baseEncode(bytes2)}`;
|
|
17967
17985
|
} else {
|
|
17968
17986
|
throw Error("Unknown type, must be binary type");
|
|
17969
17987
|
}
|
|
@@ -18153,15 +18171,15 @@ var init_dist3 = __esm({
|
|
|
18153
18171
|
/**
|
|
18154
18172
|
* Creates a multihash digest.
|
|
18155
18173
|
*/
|
|
18156
|
-
constructor(
|
|
18174
|
+
constructor(code3, size2, digest4, bytes2) {
|
|
18157
18175
|
__publicField(this, "code");
|
|
18158
18176
|
__publicField(this, "size");
|
|
18159
18177
|
__publicField(this, "digest");
|
|
18160
18178
|
__publicField(this, "bytes");
|
|
18161
|
-
this.code =
|
|
18179
|
+
this.code = code3;
|
|
18162
18180
|
this.size = size2;
|
|
18163
|
-
this.digest =
|
|
18164
|
-
this.bytes =
|
|
18181
|
+
this.digest = digest4;
|
|
18182
|
+
this.bytes = bytes2;
|
|
18165
18183
|
}
|
|
18166
18184
|
};
|
|
18167
18185
|
cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -18171,18 +18189,18 @@ var init_dist3 = __esm({
|
|
|
18171
18189
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
18172
18190
|
* @param multihash - (Multi)hash of the of the content.
|
|
18173
18191
|
*/
|
|
18174
|
-
constructor(version3,
|
|
18192
|
+
constructor(version3, code3, multihash, bytes2) {
|
|
18175
18193
|
__publicField(this, "code");
|
|
18176
18194
|
__publicField(this, "version");
|
|
18177
18195
|
__publicField(this, "multihash");
|
|
18178
18196
|
__publicField(this, "bytes");
|
|
18179
18197
|
__publicField(this, "/");
|
|
18180
18198
|
__publicField(this, _a, "CID");
|
|
18181
|
-
this.code =
|
|
18199
|
+
this.code = code3;
|
|
18182
18200
|
this.version = version3;
|
|
18183
18201
|
this.multihash = multihash;
|
|
18184
|
-
this.bytes =
|
|
18185
|
-
this["/"] =
|
|
18202
|
+
this.bytes = bytes2;
|
|
18203
|
+
this["/"] = bytes2;
|
|
18186
18204
|
}
|
|
18187
18205
|
/**
|
|
18188
18206
|
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
@@ -18207,8 +18225,8 @@ var init_dist3 = __esm({
|
|
|
18207
18225
|
return this;
|
|
18208
18226
|
}
|
|
18209
18227
|
case 1: {
|
|
18210
|
-
const { code:
|
|
18211
|
-
if (
|
|
18228
|
+
const { code: code3, multihash } = this;
|
|
18229
|
+
if (code3 !== DAG_PB_CODE) {
|
|
18212
18230
|
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
18213
18231
|
}
|
|
18214
18232
|
if (multihash.code !== SHA_256_CODE) {
|
|
@@ -18224,8 +18242,8 @@ var init_dist3 = __esm({
|
|
|
18224
18242
|
toV1() {
|
|
18225
18243
|
switch (this.version) {
|
|
18226
18244
|
case 0: {
|
|
18227
|
-
const { code:
|
|
18228
|
-
const multihash = create(
|
|
18245
|
+
const { code: code3, digest: digest4 } = this.multihash;
|
|
18246
|
+
const multihash = create(code3, digest4);
|
|
18229
18247
|
return _CID.createV1(this.code, multihash);
|
|
18230
18248
|
}
|
|
18231
18249
|
case 1: {
|
|
@@ -18274,12 +18292,12 @@ var init_dist3 = __esm({
|
|
|
18274
18292
|
if (value instanceof _CID) {
|
|
18275
18293
|
return value;
|
|
18276
18294
|
} else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
|
|
18277
|
-
const { version: version3, code:
|
|
18278
|
-
return new _CID(version3,
|
|
18295
|
+
const { version: version3, code: code3, multihash, bytes: bytes2 } = value;
|
|
18296
|
+
return new _CID(version3, code3, multihash, bytes2 ?? encodeCID(version3, code3, multihash.bytes));
|
|
18279
18297
|
} else if (value[cidSymbol] === true) {
|
|
18280
|
-
const { version: version3, multihash, code:
|
|
18281
|
-
const
|
|
18282
|
-
return _CID.create(version3,
|
|
18298
|
+
const { version: version3, multihash, code: code3 } = value;
|
|
18299
|
+
const digest4 = decode4(multihash);
|
|
18300
|
+
return _CID.create(version3, code3, digest4);
|
|
18283
18301
|
} else {
|
|
18284
18302
|
return null;
|
|
18285
18303
|
}
|
|
@@ -18289,24 +18307,24 @@ var init_dist3 = __esm({
|
|
|
18289
18307
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
18290
18308
|
* @param digest - (Multi)hash of the of the content.
|
|
18291
18309
|
*/
|
|
18292
|
-
static create(version3,
|
|
18293
|
-
if (typeof
|
|
18310
|
+
static create(version3, code3, digest4) {
|
|
18311
|
+
if (typeof code3 !== "number") {
|
|
18294
18312
|
throw new Error("String codecs are no longer supported");
|
|
18295
18313
|
}
|
|
18296
|
-
if (!(
|
|
18314
|
+
if (!(digest4.bytes instanceof Uint8Array)) {
|
|
18297
18315
|
throw new Error("Invalid digest");
|
|
18298
18316
|
}
|
|
18299
18317
|
switch (version3) {
|
|
18300
18318
|
case 0: {
|
|
18301
|
-
if (
|
|
18319
|
+
if (code3 !== DAG_PB_CODE) {
|
|
18302
18320
|
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
18303
18321
|
} else {
|
|
18304
|
-
return new _CID(version3,
|
|
18322
|
+
return new _CID(version3, code3, digest4, digest4.bytes);
|
|
18305
18323
|
}
|
|
18306
18324
|
}
|
|
18307
18325
|
case 1: {
|
|
18308
|
-
const
|
|
18309
|
-
return new _CID(version3,
|
|
18326
|
+
const bytes2 = encodeCID(version3, code3, digest4.bytes);
|
|
18327
|
+
return new _CID(version3, code3, digest4, bytes2);
|
|
18310
18328
|
}
|
|
18311
18329
|
default: {
|
|
18312
18330
|
throw new Error("Invalid version");
|
|
@@ -18316,8 +18334,8 @@ var init_dist3 = __esm({
|
|
|
18316
18334
|
/**
|
|
18317
18335
|
* Simplified version of `create` for CIDv0.
|
|
18318
18336
|
*/
|
|
18319
|
-
static createV0(
|
|
18320
|
-
return _CID.create(0, DAG_PB_CODE,
|
|
18337
|
+
static createV0(digest4) {
|
|
18338
|
+
return _CID.create(0, DAG_PB_CODE, digest4);
|
|
18321
18339
|
}
|
|
18322
18340
|
/**
|
|
18323
18341
|
* Simplified version of `create` for CIDv1.
|
|
@@ -18325,8 +18343,8 @@ var init_dist3 = __esm({
|
|
|
18325
18343
|
* @param code - Content encoding format code.
|
|
18326
18344
|
* @param digest - Multihash of the content.
|
|
18327
18345
|
*/
|
|
18328
|
-
static createV1(
|
|
18329
|
-
return _CID.create(1,
|
|
18346
|
+
static createV1(code3, digest4) {
|
|
18347
|
+
return _CID.create(1, code3, digest4);
|
|
18330
18348
|
}
|
|
18331
18349
|
/**
|
|
18332
18350
|
* Decoded a CID from its binary representation. The byte array must contain
|
|
@@ -18335,12 +18353,12 @@ var init_dist3 = __esm({
|
|
|
18335
18353
|
* An error will be thrown if the bytes provided do not contain a valid
|
|
18336
18354
|
* binary representation of a CID.
|
|
18337
18355
|
*/
|
|
18338
|
-
static decode(
|
|
18339
|
-
const [
|
|
18356
|
+
static decode(bytes2) {
|
|
18357
|
+
const [cid2, remainder] = _CID.decodeFirst(bytes2);
|
|
18340
18358
|
if (remainder.length !== 0) {
|
|
18341
18359
|
throw new Error("Incorrect length");
|
|
18342
18360
|
}
|
|
18343
|
-
return
|
|
18361
|
+
return cid2;
|
|
18344
18362
|
}
|
|
18345
18363
|
/**
|
|
18346
18364
|
* Decoded a CID from its binary representation at the beginning of a byte
|
|
@@ -18351,17 +18369,17 @@ var init_dist3 = __esm({
|
|
|
18351
18369
|
* will be a zero-length byte array if the provided bytes only contained a
|
|
18352
18370
|
* binary CID representation.
|
|
18353
18371
|
*/
|
|
18354
|
-
static decodeFirst(
|
|
18355
|
-
const specs = _CID.inspectBytes(
|
|
18372
|
+
static decodeFirst(bytes2) {
|
|
18373
|
+
const specs = _CID.inspectBytes(bytes2);
|
|
18356
18374
|
const prefixSize = specs.size - specs.multihashSize;
|
|
18357
|
-
const multihashBytes = coerce2(
|
|
18375
|
+
const multihashBytes = coerce2(bytes2.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
18358
18376
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
18359
18377
|
throw new Error("Incorrect length");
|
|
18360
18378
|
}
|
|
18361
18379
|
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
18362
|
-
const
|
|
18363
|
-
const
|
|
18364
|
-
return [
|
|
18380
|
+
const digest4 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
18381
|
+
const cid2 = specs.version === 0 ? _CID.createV0(digest4) : _CID.createV1(specs.codec, digest4);
|
|
18382
|
+
return [cid2, bytes2.subarray(specs.size)];
|
|
18365
18383
|
}
|
|
18366
18384
|
/**
|
|
18367
18385
|
* Inspect the initial bytes of a CID to determine its properties.
|
|
@@ -18404,13 +18422,13 @@ var init_dist3 = __esm({
|
|
|
18404
18422
|
* a default decoder).
|
|
18405
18423
|
*/
|
|
18406
18424
|
static parse(source, base3) {
|
|
18407
|
-
const [prefix,
|
|
18408
|
-
const
|
|
18409
|
-
if (
|
|
18425
|
+
const [prefix, bytes2] = parseCIDtoBytes(source, base3);
|
|
18426
|
+
const cid2 = _CID.decode(bytes2);
|
|
18427
|
+
if (cid2.version === 0 && source[0] !== "Q") {
|
|
18410
18428
|
throw Error("Version 0 CID string must not include multibase prefix");
|
|
18411
18429
|
}
|
|
18412
|
-
baseCache(
|
|
18413
|
-
return
|
|
18430
|
+
baseCache(cid2).set(prefix, source);
|
|
18431
|
+
return cid2;
|
|
18414
18432
|
}
|
|
18415
18433
|
};
|
|
18416
18434
|
DAG_PB_CODE = 112;
|
|
@@ -18555,10 +18573,10 @@ var init_dist3 = __esm({
|
|
|
18555
18573
|
__export2(identity_exports2, {
|
|
18556
18574
|
identity: () => identity2
|
|
18557
18575
|
});
|
|
18558
|
-
|
|
18576
|
+
code2 = 0;
|
|
18559
18577
|
name = "identity";
|
|
18560
18578
|
encode4 = coerce2;
|
|
18561
|
-
identity2 = { code, name, encode: encode4, digest };
|
|
18579
|
+
identity2 = { code: code2, name, encode: encode4, digest };
|
|
18562
18580
|
sha2_exports = {};
|
|
18563
18581
|
__export2(sha2_exports, {
|
|
18564
18582
|
sha256: () => sha2562,
|
|
@@ -18566,14 +18584,14 @@ var init_dist3 = __esm({
|
|
|
18566
18584
|
});
|
|
18567
18585
|
DEFAULT_MIN_DIGEST_LENGTH = 20;
|
|
18568
18586
|
Hasher = class {
|
|
18569
|
-
constructor(name2,
|
|
18587
|
+
constructor(name2, code3, encode5, minDigestLength, maxDigestLength) {
|
|
18570
18588
|
__publicField(this, "name");
|
|
18571
18589
|
__publicField(this, "code");
|
|
18572
18590
|
__publicField(this, "encode");
|
|
18573
18591
|
__publicField(this, "minDigestLength");
|
|
18574
18592
|
__publicField(this, "maxDigestLength");
|
|
18575
18593
|
this.name = name2;
|
|
18576
|
-
this.code =
|
|
18594
|
+
this.code = code3;
|
|
18577
18595
|
this.encode = encode5;
|
|
18578
18596
|
this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
|
|
18579
18597
|
this.maxDigestLength = maxDigestLength;
|
|
@@ -18592,7 +18610,7 @@ var init_dist3 = __esm({
|
|
|
18592
18610
|
if (result instanceof Uint8Array) {
|
|
18593
18611
|
return createDigest(result, this.code, options2?.truncate);
|
|
18594
18612
|
}
|
|
18595
|
-
return result.then((
|
|
18613
|
+
return result.then((digest4) => createDigest(digest4, this.code, options2?.truncate));
|
|
18596
18614
|
} else {
|
|
18597
18615
|
throw Error("Unknown type, must be binary type");
|
|
18598
18616
|
}
|
|
@@ -18601,12 +18619,12 @@ var init_dist3 = __esm({
|
|
|
18601
18619
|
sha2562 = from2({
|
|
18602
18620
|
name: "sha2-256",
|
|
18603
18621
|
code: 18,
|
|
18604
|
-
encode: (input) => coerce2(
|
|
18622
|
+
encode: (input) => coerce2(crypto22.createHash("sha256").update(input).digest())
|
|
18605
18623
|
});
|
|
18606
18624
|
sha5122 = from2({
|
|
18607
18625
|
name: "sha2-512",
|
|
18608
18626
|
code: 19,
|
|
18609
|
-
encode: (input) => coerce2(
|
|
18627
|
+
encode: (input) => coerce2(crypto22.createHash("sha512").update(input).digest())
|
|
18610
18628
|
});
|
|
18611
18629
|
bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
|
|
18612
18630
|
hashes = { ...sha2_exports, ...identity_exports2 };
|
|
@@ -18799,83 +18817,6 @@ var init_dist3 = __esm({
|
|
|
18799
18817
|
statement
|
|
18800
18818
|
])
|
|
18801
18819
|
);
|
|
18802
|
-
ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
|
|
18803
|
-
EnsDataSchema2 = external_exports.object({
|
|
18804
|
-
/** ENS name/domain. */
|
|
18805
|
-
domain: external_exports.string().nullable().optional(),
|
|
18806
|
-
/** ENS avatar URL. */
|
|
18807
|
-
avatarUrl: external_exports.string().nullable().optional()
|
|
18808
|
-
});
|
|
18809
|
-
PersistedTinyCloudSessionSchema = external_exports.object({
|
|
18810
|
-
/** The delegation header containing the UCAN */
|
|
18811
|
-
delegationHeader: external_exports.object({
|
|
18812
|
-
Authorization: external_exports.string()
|
|
18813
|
-
}),
|
|
18814
|
-
/** The delegation CID */
|
|
18815
|
-
delegationCid: external_exports.string(),
|
|
18816
|
-
/** The space ID for this session */
|
|
18817
|
-
spaceId: external_exports.string(),
|
|
18818
|
-
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
18819
|
-
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
18820
|
-
/** The verification method DID */
|
|
18821
|
-
verificationMethod: external_exports.string()
|
|
18822
|
-
});
|
|
18823
|
-
PersistedSessionDataSchema = external_exports.object({
|
|
18824
|
-
/** User's Ethereum address */
|
|
18825
|
-
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
18826
|
-
/** EIP-155 Chain ID */
|
|
18827
|
-
chainId: external_exports.number().int().positive(),
|
|
18828
|
-
/** Session key in JWK format (stringified) */
|
|
18829
|
-
sessionKey: external_exports.string(),
|
|
18830
|
-
/** The signed SIWE message */
|
|
18831
|
-
siwe: external_exports.string(),
|
|
18832
|
-
/** User's signature of the SIWE message */
|
|
18833
|
-
signature: external_exports.string(),
|
|
18834
|
-
/** TinyCloud delegation data if available */
|
|
18835
|
-
tinycloudSession: PersistedTinyCloudSessionSchema.optional(),
|
|
18836
|
-
/** Session expiration timestamp (ISO 8601 with timezone offset) */
|
|
18837
|
-
expiresAt: external_exports.string().datetime({ offset: true }),
|
|
18838
|
-
/** Session creation timestamp (ISO 8601 with timezone offset) */
|
|
18839
|
-
createdAt: external_exports.string().datetime({ offset: true }),
|
|
18840
|
-
/** Schema version for migrations */
|
|
18841
|
-
version: external_exports.string(),
|
|
18842
|
-
/** Optional ENS data */
|
|
18843
|
-
ens: EnsDataSchema2.optional(),
|
|
18844
|
-
/**
|
|
18845
|
-
* TinyCloud hosts this session was created against. Persisted so a
|
|
18846
|
-
* restored session resolves to the same node without re-running the
|
|
18847
|
-
* registry/fallback resolution (or the wallet sign-in flow). Optional
|
|
18848
|
-
* for backward compatibility with sessions persisted before this field
|
|
18849
|
-
* existed — those restore and lazily re-resolve their hosts.
|
|
18850
|
-
*/
|
|
18851
|
-
tinycloudHosts: external_exports.array(external_exports.string()).optional()
|
|
18852
|
-
});
|
|
18853
|
-
TinyCloudSessionSchema = external_exports.object({
|
|
18854
|
-
/** User's Ethereum address */
|
|
18855
|
-
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
18856
|
-
/** EIP-155 Chain ID */
|
|
18857
|
-
chainId: external_exports.number().int().positive(),
|
|
18858
|
-
/** Session key ID */
|
|
18859
|
-
sessionKey: external_exports.string(),
|
|
18860
|
-
/** The space ID for this session */
|
|
18861
|
-
spaceId: external_exports.string(),
|
|
18862
|
-
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
18863
|
-
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
18864
|
-
/** The delegation CID */
|
|
18865
|
-
delegationCid: external_exports.string(),
|
|
18866
|
-
/** The delegation header for API calls */
|
|
18867
|
-
delegationHeader: external_exports.object({
|
|
18868
|
-
Authorization: external_exports.string()
|
|
18869
|
-
}),
|
|
18870
|
-
/** The verification method DID */
|
|
18871
|
-
verificationMethod: external_exports.string(),
|
|
18872
|
-
/** The session key JWK (required for invoke operations) */
|
|
18873
|
-
jwk: external_exports.object({}).passthrough(),
|
|
18874
|
-
/** The signed SIWE message */
|
|
18875
|
-
siwe: external_exports.string(),
|
|
18876
|
-
/** User's signature of the SIWE message */
|
|
18877
|
-
signature: external_exports.string()
|
|
18878
|
-
});
|
|
18879
18820
|
JWKSchema = external_exports.object({
|
|
18880
18821
|
/** Key type (e.g., "EC", "RSA", "OKP") */
|
|
18881
18822
|
kty: external_exports.string(),
|
|
@@ -19257,112 +19198,6 @@ var init_dist3 = __esm({
|
|
|
19257
19198
|
*/
|
|
19258
19199
|
resources: external_exports.array(DelegatedResourceSchema)
|
|
19259
19200
|
});
|
|
19260
|
-
SpaceConfigSchema = external_exports.object({
|
|
19261
|
-
/** The space identifier (full URI) */
|
|
19262
|
-
id: external_exports.string(),
|
|
19263
|
-
/** The short name of the space */
|
|
19264
|
-
name: external_exports.string(),
|
|
19265
|
-
/** Factory function to create a space-scoped KV service */
|
|
19266
|
-
createKV: external_exports.function(),
|
|
19267
|
-
/** Factory function to create a space-scoped Data Vault service */
|
|
19268
|
-
createVault: external_exports.function(),
|
|
19269
|
-
/** Optional factory function to create a space-scoped secrets service */
|
|
19270
|
-
createSecrets: external_exports.function().optional(),
|
|
19271
|
-
/** Factory function to create space-scoped delegations */
|
|
19272
|
-
createDelegations: external_exports.function(),
|
|
19273
|
-
/** Factory function to create space-scoped sharing */
|
|
19274
|
-
createSharing: external_exports.function(),
|
|
19275
|
-
/** Function to get space info */
|
|
19276
|
-
getInfo: external_exports.function()
|
|
19277
|
-
});
|
|
19278
|
-
SpaceServiceConfigSchema = external_exports.object({
|
|
19279
|
-
/** TinyCloud host URLs */
|
|
19280
|
-
hosts: external_exports.array(external_exports.string()),
|
|
19281
|
-
/** Active session for authentication */
|
|
19282
|
-
session: external_exports.unknown(),
|
|
19283
|
-
/** Platform-specific invoke function */
|
|
19284
|
-
invoke: external_exports.function(),
|
|
19285
|
-
/** Optional custom fetch implementation */
|
|
19286
|
-
fetch: external_exports.function().optional(),
|
|
19287
|
-
/** Optional capability key registry for delegated space discovery */
|
|
19288
|
-
capabilityRegistry: external_exports.unknown().optional(),
|
|
19289
|
-
/** Factory function to create a space-scoped KV service */
|
|
19290
|
-
createKVService: external_exports.function().optional(),
|
|
19291
|
-
/** Factory function to create a space-scoped Data Vault service */
|
|
19292
|
-
createVaultService: external_exports.function().optional(),
|
|
19293
|
-
/** Factory function to create a space-scoped secrets service */
|
|
19294
|
-
createSecretsService: external_exports.function().optional(),
|
|
19295
|
-
/** User's PKH DID (derived from address or provided explicitly) */
|
|
19296
|
-
userDid: external_exports.string().optional(),
|
|
19297
|
-
/** Optional SharingService for v2 sharing links (client-side) */
|
|
19298
|
-
sharingService: external_exports.unknown().optional(),
|
|
19299
|
-
/** Factory function to create delegations using SIWE-based flow */
|
|
19300
|
-
createDelegation: external_exports.function().optional()
|
|
19301
|
-
});
|
|
19302
|
-
SpaceDelegationParamsSchema = CreateDelegationParamsSchema.extend({
|
|
19303
|
-
/** The space ID to create the delegation for */
|
|
19304
|
-
spaceId: external_exports.string()
|
|
19305
|
-
});
|
|
19306
|
-
ServerDelegationInfoSchema = external_exports.object({
|
|
19307
|
-
/** DID of the delegator */
|
|
19308
|
-
delegator: external_exports.string(),
|
|
19309
|
-
/** DID of the delegate */
|
|
19310
|
-
delegate: external_exports.string(),
|
|
19311
|
-
/** Parent delegation CIDs - accepts string or byte array format from server */
|
|
19312
|
-
parents: external_exports.array(external_exports.union([external_exports.string(), external_exports.array(external_exports.number())])),
|
|
19313
|
-
/** Expiration time (ISO8601 string) */
|
|
19314
|
-
expiry: external_exports.string().optional(),
|
|
19315
|
-
/** Not-before time (ISO8601 string) */
|
|
19316
|
-
not_before: external_exports.string().optional(),
|
|
19317
|
-
/** Issued-at time (ISO8601 string) */
|
|
19318
|
-
issued_at: external_exports.string().optional(),
|
|
19319
|
-
/** Capabilities granted by this delegation */
|
|
19320
|
-
capabilities: external_exports.array(
|
|
19321
|
-
external_exports.object({
|
|
19322
|
-
resource: external_exports.string(),
|
|
19323
|
-
ability: external_exports.string()
|
|
19324
|
-
})
|
|
19325
|
-
)
|
|
19326
|
-
});
|
|
19327
|
-
ServerDelegationsResponseSchema = external_exports.record(
|
|
19328
|
-
external_exports.string(),
|
|
19329
|
-
ServerDelegationInfoSchema
|
|
19330
|
-
);
|
|
19331
|
-
ServerOwnedSpaceSchema = external_exports.object({
|
|
19332
|
-
/** Space identifier */
|
|
19333
|
-
id: external_exports.string(),
|
|
19334
|
-
/** Space name (optional, can be derived from id) */
|
|
19335
|
-
name: external_exports.string().optional(),
|
|
19336
|
-
/** Owner DID */
|
|
19337
|
-
owner: external_exports.string(),
|
|
19338
|
-
/** Creation timestamp */
|
|
19339
|
-
createdAt: external_exports.string().optional()
|
|
19340
|
-
});
|
|
19341
|
-
ServerOwnedSpacesResponseSchema = external_exports.array(ServerOwnedSpaceSchema);
|
|
19342
|
-
ServerCreateSpaceResponseSchema = external_exports.object({
|
|
19343
|
-
/** Space identifier */
|
|
19344
|
-
id: external_exports.string(),
|
|
19345
|
-
/** Space name */
|
|
19346
|
-
name: external_exports.string(),
|
|
19347
|
-
/** Owner DID */
|
|
19348
|
-
owner: external_exports.string(),
|
|
19349
|
-
/** Creation timestamp */
|
|
19350
|
-
createdAt: external_exports.string().optional()
|
|
19351
|
-
});
|
|
19352
|
-
ServerSpaceInfoResponseSchema = external_exports.object({
|
|
19353
|
-
/** Space identifier */
|
|
19354
|
-
id: external_exports.string(),
|
|
19355
|
-
/** Space name (optional) */
|
|
19356
|
-
name: external_exports.string().optional(),
|
|
19357
|
-
/** Owner DID */
|
|
19358
|
-
owner: external_exports.string(),
|
|
19359
|
-
/** Ownership type */
|
|
19360
|
-
type: external_exports.enum(["owned", "delegated"]).optional(),
|
|
19361
|
-
/** Permissions the user has in this space */
|
|
19362
|
-
permissions: external_exports.array(external_exports.string()).optional(),
|
|
19363
|
-
/** Expiration for delegated access */
|
|
19364
|
-
expiresAt: external_exports.string().optional()
|
|
19365
|
-
});
|
|
19366
19201
|
EPHEMERAL_MS = 60 * 60 * 1e3;
|
|
19367
19202
|
SIGNED_READ_URL_MS = 5 * 60 * 1e3;
|
|
19368
19203
|
SESSION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
@@ -19378,27 +19213,6 @@ var init_dist3 = __esm({
|
|
|
19378
19213
|
MAX_MS
|
|
19379
19214
|
};
|
|
19380
19215
|
DEFAULT_SIGNED_READ_URL_EXPIRY_MS2 = EXPIRY.SIGNED_READ_URL_MS;
|
|
19381
|
-
DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
19382
|
-
ManifestValidationError = class extends Error {
|
|
19383
|
-
constructor(message) {
|
|
19384
|
-
super(`Manifest validation failed: ${message}`);
|
|
19385
|
-
this.name = "ManifestValidationError";
|
|
19386
|
-
}
|
|
19387
|
-
};
|
|
19388
|
-
SERVICE_SHORT_TO_LONG = Object.freeze({
|
|
19389
|
-
kv: "tinycloud.kv",
|
|
19390
|
-
sql: "tinycloud.sql",
|
|
19391
|
-
duckdb: "tinycloud.duckdb",
|
|
19392
|
-
capabilities: "tinycloud.capabilities",
|
|
19393
|
-
hooks: "tinycloud.hooks",
|
|
19394
|
-
encryption: "tinycloud.encryption",
|
|
19395
|
-
delegation: "tinycloud.delegation"
|
|
19396
|
-
});
|
|
19397
|
-
SERVICE_LONG_TO_SHORT = Object.freeze(
|
|
19398
|
-
Object.fromEntries(
|
|
19399
|
-
Object.entries(SERVICE_SHORT_TO_LONG).map(([s, l]) => [l, s])
|
|
19400
|
-
)
|
|
19401
|
-
);
|
|
19402
19216
|
EncodedShareDataSchema = external_exports.object({
|
|
19403
19217
|
/** Private key in JWK format (must include d parameter) */
|
|
19404
19218
|
key: JWKSchema.refine(
|
|
@@ -19509,7 +19323,346 @@ var init_dist3 = __esm({
|
|
|
19509
19323
|
message: "Expected an onRootDelegationNeeded function or undefined"
|
|
19510
19324
|
}).optional()
|
|
19511
19325
|
});
|
|
19326
|
+
DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
19327
|
+
ManifestValidationError = class extends Error {
|
|
19328
|
+
constructor(message) {
|
|
19329
|
+
super(`Manifest validation failed: ${message}`);
|
|
19330
|
+
this.name = "ManifestValidationError";
|
|
19331
|
+
}
|
|
19332
|
+
};
|
|
19333
|
+
SERVICE_SHORT_TO_LONG = Object.freeze({
|
|
19334
|
+
kv: "tinycloud.kv",
|
|
19335
|
+
sql: "tinycloud.sql",
|
|
19336
|
+
duckdb: "tinycloud.duckdb",
|
|
19337
|
+
capabilities: "tinycloud.capabilities",
|
|
19338
|
+
hooks: "tinycloud.hooks",
|
|
19339
|
+
encryption: "tinycloud.encryption",
|
|
19340
|
+
delegation: "tinycloud.delegation"
|
|
19341
|
+
});
|
|
19342
|
+
SERVICE_LONG_TO_SHORT = Object.freeze(
|
|
19343
|
+
Object.fromEntries(
|
|
19344
|
+
Object.entries(SERVICE_SHORT_TO_LONG).map(([s, l]) => [l, s])
|
|
19345
|
+
)
|
|
19346
|
+
);
|
|
19347
|
+
DEFAULT_MAX_INLINE_BYTES = 256 * 1024;
|
|
19348
|
+
MAX_SHARE_CONTENT_BYTES = 100 * 1024 * 1024;
|
|
19349
|
+
MAX_SEALED_SHARE_CONTENT_BYTES = MAX_SHARE_CONTENT_BYTES + 29;
|
|
19350
|
+
MAX_SHARE_ARTIFACT_BYTES = Math.ceil(MAX_SEALED_SHARE_CONTENT_BYTES * 4 / 3) + 2 * 1024 * 1024;
|
|
19351
|
+
PUBLISHED_AAD = new TextEncoder().encode("tinycloud-share-envelope-v1");
|
|
19352
|
+
ShareRecipientTargetSchema = external_exports.discriminatedUnion("kind", [
|
|
19353
|
+
external_exports.object({ kind: external_exports.literal("exactEmail"), value: external_exports.string().min(1) }).strict(),
|
|
19354
|
+
external_exports.object({ kind: external_exports.literal("emailDomain"), value: external_exports.string().min(1) }).strict(),
|
|
19355
|
+
external_exports.object({ kind: external_exports.literal("bearer") }).strict()
|
|
19356
|
+
]);
|
|
19357
|
+
ShareResourceSchema = external_exports.discriminatedUnion("kind", [
|
|
19358
|
+
external_exports.object({ kind: external_exports.literal("exact"), path: external_exports.string().min(1) }).strict(),
|
|
19359
|
+
external_exports.object({ kind: external_exports.literal("prefix"), path: external_exports.string().min(1) }).strict()
|
|
19360
|
+
]);
|
|
19361
|
+
ShareActionSchema = external_exports.enum(["read", "list", "edit"]);
|
|
19362
|
+
ShareRecipientPolicySchema = external_exports.object({
|
|
19363
|
+
recipientMatcher: ShareRecipientTargetSchema,
|
|
19364
|
+
spaceId: external_exports.string().min(1),
|
|
19365
|
+
resource: ShareResourceSchema,
|
|
19366
|
+
actions: external_exports.array(ShareActionSchema).min(1),
|
|
19367
|
+
expiresAt: external_exports.date()
|
|
19368
|
+
}).strict();
|
|
19369
|
+
ShareRecipientClientOptionsSchema = external_exports.object({
|
|
19370
|
+
trustedOrigins: external_exports.array(external_exports.string().url()).min(1),
|
|
19371
|
+
maxInlineBytes: external_exports.number().int().positive().optional(),
|
|
19372
|
+
maxArtifactBytes: external_exports.number().int().positive().optional(),
|
|
19373
|
+
maxContentBytes: external_exports.number().int().positive().optional(),
|
|
19374
|
+
maxSealedContentBytes: external_exports.number().int().positive().optional()
|
|
19375
|
+
}).strict();
|
|
19376
|
+
ShareNativeActionSchema = external_exports.enum(["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put"]);
|
|
19377
|
+
ShareWireActionSchema = external_exports.enum(["tinycloud.kv/get", "tinycloud.kv/metadata", "tinycloud.kv/list", "tinycloud.kv/put", "tinycloud.sql/read"]);
|
|
19378
|
+
ShareContentSourceSchema = external_exports.discriminatedUnion("kind", [
|
|
19379
|
+
external_exports.object({
|
|
19380
|
+
kind: external_exports.literal("kv"),
|
|
19381
|
+
action: ShareNativeActionSchema,
|
|
19382
|
+
space: external_exports.string().min(1),
|
|
19383
|
+
path: external_exports.string().min(1)
|
|
19384
|
+
}).strict(),
|
|
19385
|
+
external_exports.object({
|
|
19386
|
+
kind: external_exports.literal("sql"),
|
|
19387
|
+
action: external_exports.literal("tinycloud.sql/read"),
|
|
19388
|
+
space: external_exports.string().min(1),
|
|
19389
|
+
database: external_exports.string().min(1),
|
|
19390
|
+
path: external_exports.string().min(1),
|
|
19391
|
+
statement: external_exports.string().min(1),
|
|
19392
|
+
arguments: external_exports.record(external_exports.number().int().safe()),
|
|
19393
|
+
argumentsDigest: external_exports.string().min(1)
|
|
19394
|
+
}).strict()
|
|
19395
|
+
]);
|
|
19396
|
+
ShareAddressedRecipientSchema = external_exports.discriminatedUnion("kind", [
|
|
19397
|
+
external_exports.object({ kind: external_exports.literal("exactEmail"), value: external_exports.string().min(1) }).strict(),
|
|
19398
|
+
external_exports.object({ kind: external_exports.literal("emailDomain"), value: external_exports.string().min(1) }).strict()
|
|
19399
|
+
]);
|
|
19400
|
+
ShareAddressedDelegationRequestV2Schema = external_exports.object({
|
|
19401
|
+
version: external_exports.literal(2),
|
|
19402
|
+
nonce: external_exports.string().min(1),
|
|
19403
|
+
jti: external_exports.string().min(1),
|
|
19404
|
+
senderDid: external_exports.string().min(1),
|
|
19405
|
+
recipientMatcher: ShareAddressedRecipientSchema,
|
|
19406
|
+
targetOrigin: external_exports.string().url(),
|
|
19407
|
+
nodeAudience: external_exports.string().min(1),
|
|
19408
|
+
shareCid: external_exports.string().min(1),
|
|
19409
|
+
shareId: external_exports.string().min(1),
|
|
19410
|
+
delegationCid: external_exports.string().min(1),
|
|
19411
|
+
authorityMaterialHandle: external_exports.string().min(1),
|
|
19412
|
+
authorityMaterialDigest: external_exports.string().min(1),
|
|
19413
|
+
contentSource: ShareContentSourceSchema,
|
|
19414
|
+
contentSourceDigest: external_exports.string().min(1),
|
|
19415
|
+
actions: external_exports.array(ShareWireActionSchema).min(1).refine((actions) => new Set(actions).size === actions.length),
|
|
19416
|
+
resource: external_exports.object({ kind: external_exports.enum(["exact", "prefix"]), value: external_exports.string().min(1) }).strict(),
|
|
19417
|
+
expiresAt: external_exports.string().datetime({ offset: true }),
|
|
19418
|
+
requestBodyDigest: external_exports.string().min(1)
|
|
19419
|
+
}).strict();
|
|
19420
|
+
ShareAddressedDelegationEnvelopeV2Schema = external_exports.object({
|
|
19421
|
+
request: ShareAddressedDelegationRequestV2Schema,
|
|
19422
|
+
proof: external_exports.object({ alg: external_exports.literal("EdDSA"), kid: external_exports.string().min(1), signature: external_exports.string().min(1) }).strict()
|
|
19423
|
+
}).strict();
|
|
19424
|
+
ShareAddressedDelegationResponseV2Schema = external_exports.object({
|
|
19425
|
+
type: external_exports.literal("TinyCloudShareAddressedDelegation"),
|
|
19426
|
+
version: external_exports.literal(2),
|
|
19427
|
+
nonce: external_exports.string().min(1),
|
|
19428
|
+
jti: external_exports.string().min(1),
|
|
19429
|
+
policyCid: external_exports.string().min(1),
|
|
19430
|
+
policyBytes: external_exports.string().min(1),
|
|
19431
|
+
policyDigest: external_exports.string().min(1),
|
|
19432
|
+
delegationCid: external_exports.string().min(1),
|
|
19433
|
+
delegationBytes: external_exports.string().min(1),
|
|
19434
|
+
delegationDigest: external_exports.string().min(1),
|
|
19435
|
+
authorityMaterialHandle: external_exports.string().min(1),
|
|
19436
|
+
authorityMaterialDigest: external_exports.string().min(1),
|
|
19437
|
+
actions: external_exports.array(ShareWireActionSchema).min(1).refine((actions) => new Set(actions).size === actions.length),
|
|
19438
|
+
resource: external_exports.object({ kind: external_exports.enum(["exact", "prefix"]), value: external_exports.string().min(1) }).strict(),
|
|
19439
|
+
expiresAt: external_exports.string().datetime({ offset: true }),
|
|
19440
|
+
proof: external_exports.object({ alg: external_exports.literal("EdDSA"), kid: external_exports.string().min(1), signature: external_exports.string().min(1) }).strict()
|
|
19441
|
+
}).strict();
|
|
19442
|
+
ShareNativeResponseEntrySchema = external_exports.object({
|
|
19443
|
+
path: external_exports.string().min(1),
|
|
19444
|
+
kind: external_exports.enum(["file", "folder"])
|
|
19445
|
+
}).strict();
|
|
19446
|
+
ShareNativeResponseBase = {
|
|
19447
|
+
type: external_exports.literal("TinyCloudShareInvokeResponse"),
|
|
19448
|
+
version: external_exports.literal(2),
|
|
19449
|
+
resource: external_exports.string().min(1)
|
|
19450
|
+
};
|
|
19451
|
+
ShareNativeResponseSchema = external_exports.discriminatedUnion("action", [
|
|
19452
|
+
external_exports.object({
|
|
19453
|
+
...ShareNativeResponseBase,
|
|
19454
|
+
action: external_exports.literal("tinycloud.kv/metadata"),
|
|
19455
|
+
metadata: external_exports.record(external_exports.string()),
|
|
19456
|
+
etag: external_exports.string().min(1).nullable()
|
|
19457
|
+
}).strict(),
|
|
19458
|
+
external_exports.object({
|
|
19459
|
+
...ShareNativeResponseBase,
|
|
19460
|
+
action: external_exports.literal("tinycloud.kv/get"),
|
|
19461
|
+
mediaType: external_exports.string().min(1),
|
|
19462
|
+
content: external_exports.string(),
|
|
19463
|
+
bodyDigest: external_exports.string().min(1),
|
|
19464
|
+
etag: external_exports.string().min(1).nullable()
|
|
19465
|
+
}).strict(),
|
|
19466
|
+
external_exports.object({
|
|
19467
|
+
...ShareNativeResponseBase,
|
|
19468
|
+
action: external_exports.literal("tinycloud.kv/list"),
|
|
19469
|
+
entries: external_exports.array(ShareNativeResponseEntrySchema),
|
|
19470
|
+
nextCursor: external_exports.string().min(1).nullable()
|
|
19471
|
+
}).strict(),
|
|
19472
|
+
external_exports.object({
|
|
19473
|
+
...ShareNativeResponseBase,
|
|
19474
|
+
action: external_exports.literal("tinycloud.kv/put"),
|
|
19475
|
+
etag: external_exports.string().min(1),
|
|
19476
|
+
bodyDigest: external_exports.string().min(1),
|
|
19477
|
+
contentType: external_exports.string().min(1)
|
|
19478
|
+
}).strict()
|
|
19479
|
+
]);
|
|
19480
|
+
MAX_NATIVE_CURSOR_BYTES = 8 * 1024;
|
|
19512
19481
|
DEFAULT_EXPIRY_MS2 = EXPIRY.SHARE_MS;
|
|
19482
|
+
MAX_CONTENT_BYTES = 100 * 1024 * 1024;
|
|
19483
|
+
ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
|
|
19484
|
+
EnsDataSchema2 = external_exports.object({
|
|
19485
|
+
/** ENS name/domain. */
|
|
19486
|
+
domain: external_exports.string().nullable().optional(),
|
|
19487
|
+
/** ENS avatar URL. */
|
|
19488
|
+
avatarUrl: external_exports.string().nullable().optional()
|
|
19489
|
+
});
|
|
19490
|
+
PersistedTinyCloudSessionSchema = external_exports.object({
|
|
19491
|
+
/** The delegation header containing the UCAN */
|
|
19492
|
+
delegationHeader: external_exports.object({
|
|
19493
|
+
Authorization: external_exports.string()
|
|
19494
|
+
}),
|
|
19495
|
+
/** The delegation CID */
|
|
19496
|
+
delegationCid: external_exports.string(),
|
|
19497
|
+
/** The space ID for this session */
|
|
19498
|
+
spaceId: external_exports.string(),
|
|
19499
|
+
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
19500
|
+
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
19501
|
+
/** The verification method DID */
|
|
19502
|
+
verificationMethod: external_exports.string()
|
|
19503
|
+
});
|
|
19504
|
+
PersistedSessionDataSchema = external_exports.object({
|
|
19505
|
+
/** User's Ethereum address */
|
|
19506
|
+
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
19507
|
+
/** EIP-155 Chain ID */
|
|
19508
|
+
chainId: external_exports.number().int().positive(),
|
|
19509
|
+
/** Session key in JWK format (stringified) */
|
|
19510
|
+
sessionKey: external_exports.string(),
|
|
19511
|
+
/** The signed SIWE message */
|
|
19512
|
+
siwe: external_exports.string(),
|
|
19513
|
+
/** User's signature of the SIWE message */
|
|
19514
|
+
signature: external_exports.string(),
|
|
19515
|
+
/** TinyCloud delegation data if available */
|
|
19516
|
+
tinycloudSession: PersistedTinyCloudSessionSchema.optional(),
|
|
19517
|
+
/** Session expiration timestamp (ISO 8601 with timezone offset) */
|
|
19518
|
+
expiresAt: external_exports.string().datetime({ offset: true }),
|
|
19519
|
+
/** Session creation timestamp (ISO 8601 with timezone offset) */
|
|
19520
|
+
createdAt: external_exports.string().datetime({ offset: true }),
|
|
19521
|
+
/** Schema version for migrations */
|
|
19522
|
+
version: external_exports.string(),
|
|
19523
|
+
/** Optional ENS data */
|
|
19524
|
+
ens: EnsDataSchema2.optional(),
|
|
19525
|
+
/**
|
|
19526
|
+
* TinyCloud hosts this session was created against. Persisted so a
|
|
19527
|
+
* restored session resolves to the same node without re-running the
|
|
19528
|
+
* registry/fallback resolution (or the wallet sign-in flow). Optional
|
|
19529
|
+
* for backward compatibility with sessions persisted before this field
|
|
19530
|
+
* existed — those restore and lazily re-resolve their hosts.
|
|
19531
|
+
*/
|
|
19532
|
+
tinycloudHosts: external_exports.array(external_exports.string()).optional()
|
|
19533
|
+
});
|
|
19534
|
+
TinyCloudSessionSchema = external_exports.object({
|
|
19535
|
+
/** User's Ethereum address */
|
|
19536
|
+
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
19537
|
+
/** EIP-155 Chain ID */
|
|
19538
|
+
chainId: external_exports.number().int().positive(),
|
|
19539
|
+
/** Session key ID */
|
|
19540
|
+
sessionKey: external_exports.string(),
|
|
19541
|
+
/** The space ID for this session */
|
|
19542
|
+
spaceId: external_exports.string(),
|
|
19543
|
+
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
19544
|
+
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
19545
|
+
/** The delegation CID */
|
|
19546
|
+
delegationCid: external_exports.string(),
|
|
19547
|
+
/** The delegation header for API calls */
|
|
19548
|
+
delegationHeader: external_exports.object({
|
|
19549
|
+
Authorization: external_exports.string()
|
|
19550
|
+
}),
|
|
19551
|
+
/** The verification method DID */
|
|
19552
|
+
verificationMethod: external_exports.string(),
|
|
19553
|
+
/** The session key JWK (required for invoke operations) */
|
|
19554
|
+
jwk: external_exports.object({}).passthrough(),
|
|
19555
|
+
/** The signed SIWE message */
|
|
19556
|
+
siwe: external_exports.string(),
|
|
19557
|
+
/** User's signature of the SIWE message */
|
|
19558
|
+
signature: external_exports.string()
|
|
19559
|
+
});
|
|
19560
|
+
SpaceConfigSchema = external_exports.object({
|
|
19561
|
+
/** The space identifier (full URI) */
|
|
19562
|
+
id: external_exports.string(),
|
|
19563
|
+
/** The short name of the space */
|
|
19564
|
+
name: external_exports.string(),
|
|
19565
|
+
/** Factory function to create a space-scoped KV service */
|
|
19566
|
+
createKV: external_exports.function(),
|
|
19567
|
+
/** Factory function to create a space-scoped Data Vault service */
|
|
19568
|
+
createVault: external_exports.function(),
|
|
19569
|
+
/** Optional factory function to create a space-scoped secrets service */
|
|
19570
|
+
createSecrets: external_exports.function().optional(),
|
|
19571
|
+
/** Factory function to create space-scoped delegations */
|
|
19572
|
+
createDelegations: external_exports.function(),
|
|
19573
|
+
/** Factory function to create space-scoped sharing */
|
|
19574
|
+
createSharing: external_exports.function(),
|
|
19575
|
+
/** Function to get space info */
|
|
19576
|
+
getInfo: external_exports.function()
|
|
19577
|
+
});
|
|
19578
|
+
SpaceServiceConfigSchema = external_exports.object({
|
|
19579
|
+
/** TinyCloud host URLs */
|
|
19580
|
+
hosts: external_exports.array(external_exports.string()),
|
|
19581
|
+
/** Active session for authentication */
|
|
19582
|
+
session: external_exports.unknown(),
|
|
19583
|
+
/** Platform-specific invoke function */
|
|
19584
|
+
invoke: external_exports.function(),
|
|
19585
|
+
/** Optional custom fetch implementation */
|
|
19586
|
+
fetch: external_exports.function().optional(),
|
|
19587
|
+
/** Optional capability key registry for delegated space discovery */
|
|
19588
|
+
capabilityRegistry: external_exports.unknown().optional(),
|
|
19589
|
+
/** Factory function to create a space-scoped KV service */
|
|
19590
|
+
createKVService: external_exports.function().optional(),
|
|
19591
|
+
/** Factory function to create a space-scoped Data Vault service */
|
|
19592
|
+
createVaultService: external_exports.function().optional(),
|
|
19593
|
+
/** Factory function to create a space-scoped secrets service */
|
|
19594
|
+
createSecretsService: external_exports.function().optional(),
|
|
19595
|
+
/** User's PKH DID (derived from address or provided explicitly) */
|
|
19596
|
+
userDid: external_exports.string().optional(),
|
|
19597
|
+
/** Optional SharingService for v2 sharing links (client-side) */
|
|
19598
|
+
sharingService: external_exports.unknown().optional(),
|
|
19599
|
+
/** Factory function to create delegations using SIWE-based flow */
|
|
19600
|
+
createDelegation: external_exports.function().optional()
|
|
19601
|
+
});
|
|
19602
|
+
SpaceDelegationParamsSchema = CreateDelegationParamsSchema.extend({
|
|
19603
|
+
/** The space ID to create the delegation for */
|
|
19604
|
+
spaceId: external_exports.string()
|
|
19605
|
+
});
|
|
19606
|
+
ServerDelegationInfoSchema = external_exports.object({
|
|
19607
|
+
/** DID of the delegator */
|
|
19608
|
+
delegator: external_exports.string(),
|
|
19609
|
+
/** DID of the delegate */
|
|
19610
|
+
delegate: external_exports.string(),
|
|
19611
|
+
/** Parent delegation CIDs - accepts string or byte array format from server */
|
|
19612
|
+
parents: external_exports.array(external_exports.union([external_exports.string(), external_exports.array(external_exports.number())])),
|
|
19613
|
+
/** Expiration time (ISO8601 string) */
|
|
19614
|
+
expiry: external_exports.string().optional(),
|
|
19615
|
+
/** Not-before time (ISO8601 string) */
|
|
19616
|
+
not_before: external_exports.string().optional(),
|
|
19617
|
+
/** Issued-at time (ISO8601 string) */
|
|
19618
|
+
issued_at: external_exports.string().optional(),
|
|
19619
|
+
/** Capabilities granted by this delegation */
|
|
19620
|
+
capabilities: external_exports.array(
|
|
19621
|
+
external_exports.object({
|
|
19622
|
+
resource: external_exports.string(),
|
|
19623
|
+
ability: external_exports.string()
|
|
19624
|
+
})
|
|
19625
|
+
)
|
|
19626
|
+
});
|
|
19627
|
+
ServerDelegationsResponseSchema = external_exports.record(
|
|
19628
|
+
external_exports.string(),
|
|
19629
|
+
ServerDelegationInfoSchema
|
|
19630
|
+
);
|
|
19631
|
+
ServerOwnedSpaceSchema = external_exports.object({
|
|
19632
|
+
/** Space identifier */
|
|
19633
|
+
id: external_exports.string(),
|
|
19634
|
+
/** Space name (optional, can be derived from id) */
|
|
19635
|
+
name: external_exports.string().optional(),
|
|
19636
|
+
/** Owner DID */
|
|
19637
|
+
owner: external_exports.string(),
|
|
19638
|
+
/** Creation timestamp */
|
|
19639
|
+
createdAt: external_exports.string().optional()
|
|
19640
|
+
});
|
|
19641
|
+
ServerOwnedSpacesResponseSchema = external_exports.array(ServerOwnedSpaceSchema);
|
|
19642
|
+
ServerCreateSpaceResponseSchema = external_exports.object({
|
|
19643
|
+
/** Space identifier */
|
|
19644
|
+
id: external_exports.string(),
|
|
19645
|
+
/** Space name */
|
|
19646
|
+
name: external_exports.string(),
|
|
19647
|
+
/** Owner DID */
|
|
19648
|
+
owner: external_exports.string(),
|
|
19649
|
+
/** Creation timestamp */
|
|
19650
|
+
createdAt: external_exports.string().optional()
|
|
19651
|
+
});
|
|
19652
|
+
ServerSpaceInfoResponseSchema = external_exports.object({
|
|
19653
|
+
/** Space identifier */
|
|
19654
|
+
id: external_exports.string(),
|
|
19655
|
+
/** Space name (optional) */
|
|
19656
|
+
name: external_exports.string().optional(),
|
|
19657
|
+
/** Owner DID */
|
|
19658
|
+
owner: external_exports.string(),
|
|
19659
|
+
/** Ownership type */
|
|
19660
|
+
type: external_exports.enum(["owned", "delegated"]).optional(),
|
|
19661
|
+
/** Permissions the user has in this space */
|
|
19662
|
+
permissions: external_exports.array(external_exports.string()).optional(),
|
|
19663
|
+
/** Expiration for delegated access */
|
|
19664
|
+
expiresAt: external_exports.string().optional()
|
|
19665
|
+
});
|
|
19513
19666
|
AutoApproveSpaceCreationHandler = class {
|
|
19514
19667
|
/**
|
|
19515
19668
|
* Always returns true to auto-approve space creation.
|
|
@@ -19629,15 +19782,15 @@ var init_dist3 = __esm({
|
|
|
19629
19782
|
CODE_MEMORY = 777;
|
|
19630
19783
|
ip4ToBytes = function(ip) {
|
|
19631
19784
|
ip = ip.toString().trim();
|
|
19632
|
-
const
|
|
19785
|
+
const bytes2 = new Uint8Array(4);
|
|
19633
19786
|
ip.split(/\./g).forEach((byte, index) => {
|
|
19634
19787
|
const value = parseInt(byte, 10);
|
|
19635
19788
|
if (isNaN(value) || value < 0 || value > 255) {
|
|
19636
19789
|
throw new InvalidMultiaddrError("Invalid byte value in IP address");
|
|
19637
19790
|
}
|
|
19638
|
-
|
|
19791
|
+
bytes2[index] = value;
|
|
19639
19792
|
});
|
|
19640
|
-
return
|
|
19793
|
+
return bytes2;
|
|
19641
19794
|
};
|
|
19642
19795
|
ip6ToBytes = function(ip) {
|
|
19643
19796
|
let offset = 0;
|
|
@@ -19672,7 +19825,7 @@ var init_dist3 = __esm({
|
|
|
19672
19825
|
}
|
|
19673
19826
|
sections.splice.apply(sections, argv);
|
|
19674
19827
|
}
|
|
19675
|
-
const
|
|
19828
|
+
const bytes2 = new Uint8Array(offset + 16);
|
|
19676
19829
|
for (i = 0; i < sections.length; i++) {
|
|
19677
19830
|
if (sections[i] === "") {
|
|
19678
19831
|
sections[i] = "0";
|
|
@@ -19681,10 +19834,10 @@ var init_dist3 = __esm({
|
|
|
19681
19834
|
if (isNaN(word2) || word2 < 0 || word2 > 65535) {
|
|
19682
19835
|
throw new InvalidMultiaddrError("Invalid byte value in IP address");
|
|
19683
19836
|
}
|
|
19684
|
-
|
|
19685
|
-
|
|
19837
|
+
bytes2[offset++] = word2 >> 8 & 255;
|
|
19838
|
+
bytes2[offset++] = word2 & 255;
|
|
19686
19839
|
}
|
|
19687
|
-
return
|
|
19840
|
+
return bytes2;
|
|
19688
19841
|
};
|
|
19689
19842
|
ip4ToString = function(buf) {
|
|
19690
19843
|
if (buf.byteLength !== 4) {
|
|
@@ -19747,8 +19900,8 @@ var init_dist3 = __esm({
|
|
|
19747
19900
|
this.protocolsByName.set(alias, codec);
|
|
19748
19901
|
});
|
|
19749
19902
|
}
|
|
19750
|
-
removeProtocol(
|
|
19751
|
-
const codec = this.protocolsByCode.get(
|
|
19903
|
+
removeProtocol(code3) {
|
|
19904
|
+
const codec = this.protocolsByCode.get(code3);
|
|
19752
19905
|
if (codec == null) {
|
|
19753
19906
|
return;
|
|
19754
19907
|
}
|
|
@@ -20006,10 +20159,10 @@ var init_dist3 = __esm({
|
|
|
20006
20159
|
validate: false
|
|
20007
20160
|
});
|
|
20008
20161
|
}
|
|
20009
|
-
decapsulateCode(
|
|
20162
|
+
decapsulateCode(code3) {
|
|
20010
20163
|
let index;
|
|
20011
20164
|
for (let i = __privateGet(this, _components).length - 1; i > -1; i--) {
|
|
20012
|
-
if (__privateGet(this, _components)[i].code ===
|
|
20165
|
+
if (__privateGet(this, _components)[i].code === code3) {
|
|
20013
20166
|
index = i;
|
|
20014
20167
|
break;
|
|
20015
20168
|
}
|
|
@@ -23235,7 +23388,7 @@ function execCapturedCommand(command) {
|
|
|
23235
23388
|
stdio: "inherit"
|
|
23236
23389
|
});
|
|
23237
23390
|
child.on("error", reject);
|
|
23238
|
-
child.on("exit", (
|
|
23391
|
+
child.on("exit", (code, signal) => {
|
|
23239
23392
|
if (signal) {
|
|
23240
23393
|
reject(new CLIError(
|
|
23241
23394
|
"COMMAND_SIGNAL",
|
|
@@ -23244,8 +23397,8 @@ function execCapturedCommand(command) {
|
|
|
23244
23397
|
));
|
|
23245
23398
|
return;
|
|
23246
23399
|
}
|
|
23247
|
-
if (
|
|
23248
|
-
process.exitCode =
|
|
23400
|
+
if (code && code !== 0) {
|
|
23401
|
+
process.exitCode = code;
|
|
23249
23402
|
}
|
|
23250
23403
|
resolve3();
|
|
23251
23404
|
});
|
|
@@ -25145,8 +25298,8 @@ function shouldRequestSecretPermissions(error) {
|
|
|
25145
25298
|
function thrownPermissionError(error) {
|
|
25146
25299
|
const record = error;
|
|
25147
25300
|
const message = typeof record?.message === "string" ? record.message : String(error);
|
|
25148
|
-
const
|
|
25149
|
-
if (
|
|
25301
|
+
const code = typeof record?.code === "string" ? record.code : "PERMISSION_DENIED";
|
|
25302
|
+
if (code !== "PERMISSION_DENIED" && !/permission|session expired|autosign|capabilit/i.test(message)) {
|
|
25150
25303
|
return null;
|
|
25151
25304
|
}
|
|
25152
25305
|
return {
|
|
@@ -25354,9 +25507,9 @@ async function resolveDelegatedSecretSource(source, secretPath, space = SECRETS_
|
|
|
25354
25507
|
return { ...selected, source };
|
|
25355
25508
|
}
|
|
25356
25509
|
function mapEncryptionResultError(error) {
|
|
25357
|
-
const
|
|
25358
|
-
const exitCode =
|
|
25359
|
-
return new CLIError(
|
|
25510
|
+
const code = error.code || "DECRYPTION_FAILED";
|
|
25511
|
+
const exitCode = code === "PERMISSION_DENIED" ? ExitCode.PERMISSION_DENIED : code === "NOT_FOUND" ? ExitCode.NOT_FOUND : code === "NETWORK_ERROR" || code === "TRANSPORT_ERROR" ? ExitCode.NETWORK_ERROR : ExitCode.ERROR;
|
|
25512
|
+
return new CLIError(code, error.message, exitCode);
|
|
25360
25513
|
}
|
|
25361
25514
|
function parseDecryptedSecretPayload(data, secretPath) {
|
|
25362
25515
|
const text = new TextDecoder().decode(data);
|