@tinycloud/cli 0.8.1 → 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 +873 -510
- 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 };
|
|
@@ -12067,7 +12184,7 @@ function encOk(data) {
|
|
|
12067
12184
|
function encErr(error) {
|
|
12068
12185
|
return { ok: false, error };
|
|
12069
12186
|
}
|
|
12070
|
-
var import_decrypt_transport_response_error, import_decrypt_transport_response_error2, import_decrypt_transport_response_error3, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HooksService, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, HEX, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
|
|
12187
|
+
var import_decrypt_transport_response_error, import_decrypt_transport_response_error2, import_decrypt_transport_response_error3, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, MAX_KV_BATCH_READ_ITEMS, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HooksService, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, HEX, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
|
|
12071
12188
|
var init_dist2 = __esm({
|
|
12072
12189
|
"../sdk-services/dist/index.js"() {
|
|
12073
12190
|
"use strict";
|
|
@@ -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({
|
|
@@ -12585,6 +12704,20 @@ var init_dist2 = __esm({
|
|
|
12585
12704
|
const fullKey = this.getFullKey(key);
|
|
12586
12705
|
return this._kv.get(fullKey, { ...options, prefix: "" });
|
|
12587
12706
|
}
|
|
12707
|
+
async batchGet(keys, options) {
|
|
12708
|
+
const response = await this._kv.batchGet(
|
|
12709
|
+
keys.map((key) => this.getFullKey(key)),
|
|
12710
|
+
{ ...options, prefix: "" }
|
|
12711
|
+
);
|
|
12712
|
+
if (!response.ok) return response;
|
|
12713
|
+
return ok({
|
|
12714
|
+
...response.data,
|
|
12715
|
+
results: response.data.results.map((item, index) => ({
|
|
12716
|
+
...item,
|
|
12717
|
+
key: keys[index]
|
|
12718
|
+
}))
|
|
12719
|
+
});
|
|
12720
|
+
}
|
|
12588
12721
|
/**
|
|
12589
12722
|
* Store a value at a key.
|
|
12590
12723
|
*/
|
|
@@ -12629,6 +12762,20 @@ var init_dist2 = __esm({
|
|
|
12629
12762
|
const fullKey = this.getFullKey(key);
|
|
12630
12763
|
return this._kv.head(fullKey, { ...options, prefix: "" });
|
|
12631
12764
|
}
|
|
12765
|
+
async batchHead(keys, options) {
|
|
12766
|
+
const response = await this._kv.batchHead(
|
|
12767
|
+
keys.map((key) => this.getFullKey(key)),
|
|
12768
|
+
{ ...options, prefix: "" }
|
|
12769
|
+
);
|
|
12770
|
+
if (!response.ok) return response;
|
|
12771
|
+
return ok({
|
|
12772
|
+
...response.data,
|
|
12773
|
+
results: response.data.results.map((item, index) => ({
|
|
12774
|
+
...item,
|
|
12775
|
+
key: keys[index]
|
|
12776
|
+
}))
|
|
12777
|
+
});
|
|
12778
|
+
}
|
|
12632
12779
|
/**
|
|
12633
12780
|
* Create a short-lived signed URL for reading a KV object.
|
|
12634
12781
|
*/
|
|
@@ -12653,6 +12800,7 @@ var init_dist2 = __esm({
|
|
|
12653
12800
|
DELETE: "tinycloud.kv/del",
|
|
12654
12801
|
HEAD: "tinycloud.kv/metadata"
|
|
12655
12802
|
};
|
|
12803
|
+
MAX_KV_BATCH_READ_ITEMS = 100;
|
|
12656
12804
|
KVService = class extends BaseService {
|
|
12657
12805
|
/**
|
|
12658
12806
|
* Create a new KVService instance.
|
|
@@ -12881,6 +13029,173 @@ var init_dist2 = __esm({
|
|
|
12881
13029
|
get: (name2) => headers.get(name2)
|
|
12882
13030
|
};
|
|
12883
13031
|
}
|
|
13032
|
+
createBatchResponseHeaders(values) {
|
|
13033
|
+
const normalized = new Map(
|
|
13034
|
+
Object.entries(values).map(([name2, value]) => [name2.toLowerCase(), value])
|
|
13035
|
+
);
|
|
13036
|
+
return this.createResponseHeaders({
|
|
13037
|
+
get: (name2) => normalized.get(name2.toLowerCase()) ?? null
|
|
13038
|
+
});
|
|
13039
|
+
}
|
|
13040
|
+
parseBatchValue(dataBase64, headers, raw = false, binary = false) {
|
|
13041
|
+
const encoded = globalThis.atob(dataBase64);
|
|
13042
|
+
const bytes = Uint8Array.from(encoded, (character) => character.charCodeAt(0));
|
|
13043
|
+
if (binary) return bytes;
|
|
13044
|
+
const text = new TextDecoder().decode(bytes);
|
|
13045
|
+
if (raw) return text;
|
|
13046
|
+
const contentType = Object.entries(headers).find(
|
|
13047
|
+
([name2]) => name2.toLowerCase() === "content-type"
|
|
13048
|
+
)?.[1];
|
|
13049
|
+
return contentType?.includes("application/json") ? JSON.parse(text) : text;
|
|
13050
|
+
}
|
|
13051
|
+
normalizeBatchReadResponse(data, paths, requireData) {
|
|
13052
|
+
if (!data || typeof data !== "object") return void 0;
|
|
13053
|
+
const response = data;
|
|
13054
|
+
if (!Array.isArray(response.results) || response.results.length !== paths.length) {
|
|
13055
|
+
return void 0;
|
|
13056
|
+
}
|
|
13057
|
+
for (let index = 0; index < response.results.length; index++) {
|
|
13058
|
+
const item = response.results[index];
|
|
13059
|
+
if (!item || typeof item !== "object" || item.key !== paths[index] || typeof item.ok !== "boolean") {
|
|
13060
|
+
return void 0;
|
|
13061
|
+
}
|
|
13062
|
+
if (item.ok && (!item.headers || typeof item.headers !== "object" || Object.values(item.headers).some((value) => typeof value !== "string") || requireData && typeof item.dataBase64 !== "string")) {
|
|
13063
|
+
return void 0;
|
|
13064
|
+
}
|
|
13065
|
+
if (!item.ok && (!item.error || typeof item.error.code !== "string" || typeof item.error.message !== "string")) {
|
|
13066
|
+
return void 0;
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
return response;
|
|
13070
|
+
}
|
|
13071
|
+
async batchRead(keys, action, options) {
|
|
13072
|
+
if (!this.requireAuth()) return err(authRequiredError("kv"));
|
|
13073
|
+
if (keys.length === 0) return ok({ results: [], count: 0 });
|
|
13074
|
+
if (keys.length > MAX_KV_BATCH_READ_ITEMS) {
|
|
13075
|
+
return err(serviceError(
|
|
13076
|
+
ErrorCodes.INVALID_INPUT,
|
|
13077
|
+
`KV batch reads accept at most ${MAX_KV_BATCH_READ_ITEMS} keys`,
|
|
13078
|
+
"kv"
|
|
13079
|
+
));
|
|
13080
|
+
}
|
|
13081
|
+
if (keys.length === 1) {
|
|
13082
|
+
const key = keys[0];
|
|
13083
|
+
const result = action === KVAction.GET ? await this.get(key, options) : await this.head(key, options);
|
|
13084
|
+
return ok({
|
|
13085
|
+
results: [{ key, result }],
|
|
13086
|
+
count: 1
|
|
13087
|
+
});
|
|
13088
|
+
}
|
|
13089
|
+
if (!this.context.invokeAny) {
|
|
13090
|
+
return err(serviceError(
|
|
13091
|
+
ErrorCodes.INVALID_INPUT,
|
|
13092
|
+
"KV batch reads require SDK runtime support for multi-resource invocations",
|
|
13093
|
+
"kv"
|
|
13094
|
+
));
|
|
13095
|
+
}
|
|
13096
|
+
const getOptions = action === KVAction.GET ? options : void 0;
|
|
13097
|
+
if (getOptions?.maxResponseBytes !== void 0 && (!Number.isSafeInteger(getOptions.maxResponseBytes) || getOptions.maxResponseBytes <= 0)) {
|
|
13098
|
+
return err(serviceError(
|
|
13099
|
+
ErrorCodes.INVALID_INPUT,
|
|
13100
|
+
"KV maxResponseBytes must be a positive safe integer",
|
|
13101
|
+
"kv"
|
|
13102
|
+
));
|
|
13103
|
+
}
|
|
13104
|
+
const paths = keys.map((key) => this.getFullPath(key, options?.prefix));
|
|
13105
|
+
if (new Set(paths).size !== paths.length) {
|
|
13106
|
+
return err(serviceError(
|
|
13107
|
+
ErrorCodes.INVALID_INPUT,
|
|
13108
|
+
"KV batch read received duplicate keys after prefix resolution",
|
|
13109
|
+
"kv"
|
|
13110
|
+
));
|
|
13111
|
+
}
|
|
13112
|
+
try {
|
|
13113
|
+
const session = this.context.session;
|
|
13114
|
+
const invocationHeaders = this.context.invokeAny(
|
|
13115
|
+
session,
|
|
13116
|
+
paths.map((path) => ({
|
|
13117
|
+
spaceId: session.spaceId,
|
|
13118
|
+
service: "kv",
|
|
13119
|
+
path,
|
|
13120
|
+
action
|
|
13121
|
+
}))
|
|
13122
|
+
);
|
|
13123
|
+
const limitHeaders = {};
|
|
13124
|
+
if (getOptions?.maxResponseBytes !== void 0) {
|
|
13125
|
+
limitHeaders["x-tinycloud-max-response-bytes"] = String(
|
|
13126
|
+
getOptions.maxResponseBytes
|
|
13127
|
+
);
|
|
13128
|
+
}
|
|
13129
|
+
const headers = Array.isArray(invocationHeaders) ? [...invocationHeaders, ...Object.entries(limitHeaders)] : { ...invocationHeaders, ...limitHeaders };
|
|
13130
|
+
const response = await this.context.fetch(`${this.host}/invoke`, {
|
|
13131
|
+
method: "POST",
|
|
13132
|
+
headers,
|
|
13133
|
+
signal: this.combineSignals(options?.signal)
|
|
13134
|
+
});
|
|
13135
|
+
if (!response.ok) {
|
|
13136
|
+
const errorText = await response.text();
|
|
13137
|
+
if (response.status === 401 || response.status === 403) {
|
|
13138
|
+
const { resource, action: requiredAction } = parseAuthError(errorText);
|
|
13139
|
+
return err(authUnauthorizedError("kv", errorText, {
|
|
13140
|
+
status: response.status,
|
|
13141
|
+
...requiredAction && { requiredAction },
|
|
13142
|
+
...resource && { resource }
|
|
13143
|
+
}));
|
|
13144
|
+
}
|
|
13145
|
+
if (response.status === 413) {
|
|
13146
|
+
return err(serviceError(
|
|
13147
|
+
ErrorCodes.KV_RESPONSE_TOO_LARGE,
|
|
13148
|
+
"A KV batch value exceeds the requested response limit",
|
|
13149
|
+
"kv",
|
|
13150
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
13151
|
+
));
|
|
13152
|
+
}
|
|
13153
|
+
return err(serviceError(
|
|
13154
|
+
ErrorCodes.NETWORK_ERROR,
|
|
13155
|
+
`Failed to batch read ${keys.length} key(s): ${response.status} - ${errorText}`,
|
|
13156
|
+
"kv",
|
|
13157
|
+
{ meta: { status: response.status, statusText: response.statusText } }
|
|
13158
|
+
));
|
|
13159
|
+
}
|
|
13160
|
+
const payload = this.normalizeBatchReadResponse(
|
|
13161
|
+
await response.json(),
|
|
13162
|
+
paths,
|
|
13163
|
+
action === KVAction.GET
|
|
13164
|
+
);
|
|
13165
|
+
if (!payload) {
|
|
13166
|
+
return err(serviceError(
|
|
13167
|
+
ErrorCodes.NETWORK_ERROR,
|
|
13168
|
+
"KV batch read response did not match the requested keys",
|
|
13169
|
+
"kv"
|
|
13170
|
+
));
|
|
13171
|
+
}
|
|
13172
|
+
const results = payload.results.map((item, index) => {
|
|
13173
|
+
if (!item.ok) {
|
|
13174
|
+
return {
|
|
13175
|
+
key: keys[index],
|
|
13176
|
+
result: err(serviceError(item.error.code, item.error.message, "kv"))
|
|
13177
|
+
};
|
|
13178
|
+
}
|
|
13179
|
+
const headers2 = item.headers;
|
|
13180
|
+
const data = action === KVAction.HEAD ? void 0 : this.parseBatchValue(
|
|
13181
|
+
item.dataBase64,
|
|
13182
|
+
headers2,
|
|
13183
|
+
getOptions?.raw,
|
|
13184
|
+
getOptions?.binary
|
|
13185
|
+
);
|
|
13186
|
+
return {
|
|
13187
|
+
key: keys[index],
|
|
13188
|
+
result: ok({
|
|
13189
|
+
data,
|
|
13190
|
+
headers: this.createBatchResponseHeaders(headers2)
|
|
13191
|
+
})
|
|
13192
|
+
};
|
|
13193
|
+
});
|
|
13194
|
+
return ok({ results, count: results.length });
|
|
13195
|
+
} catch (error) {
|
|
13196
|
+
return err(wrapError2("kv", error));
|
|
13197
|
+
}
|
|
13198
|
+
}
|
|
12884
13199
|
/**
|
|
12885
13200
|
* Parse response body based on content type.
|
|
12886
13201
|
*
|
|
@@ -12931,10 +13246,10 @@ var init_dist2 = __esm({
|
|
|
12931
13246
|
...resource && { resource }
|
|
12932
13247
|
}));
|
|
12933
13248
|
}
|
|
12934
|
-
const
|
|
13249
|
+
const code = response.status === 400 ? ErrorCodes.INVALID_INPUT : ErrorCodes.NETWORK_ERROR;
|
|
12935
13250
|
return err(
|
|
12936
13251
|
serviceError(
|
|
12937
|
-
|
|
13252
|
+
code,
|
|
12938
13253
|
`Failed to create signed read URL for key "${key}": ${response.status} - ${errorText}`,
|
|
12939
13254
|
"kv",
|
|
12940
13255
|
{ meta: { status: response.status, statusText: response.statusText } }
|
|
@@ -13027,6 +13342,13 @@ var init_dist2 = __esm({
|
|
|
13027
13342
|
}
|
|
13028
13343
|
});
|
|
13029
13344
|
}
|
|
13345
|
+
async batchGet(keys, options) {
|
|
13346
|
+
return this.withTelemetry(
|
|
13347
|
+
"batchGet",
|
|
13348
|
+
String(keys.length),
|
|
13349
|
+
() => this.batchRead(keys, KVAction.GET, options)
|
|
13350
|
+
);
|
|
13351
|
+
}
|
|
13030
13352
|
/**
|
|
13031
13353
|
* Store a value at a key.
|
|
13032
13354
|
*/
|
|
@@ -13234,7 +13556,10 @@ var init_dist2 = __esm({
|
|
|
13234
13556
|
KVAction.LIST,
|
|
13235
13557
|
void 0,
|
|
13236
13558
|
options?.signal,
|
|
13237
|
-
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
|
+
}
|
|
13238
13563
|
);
|
|
13239
13564
|
if (!response.ok) {
|
|
13240
13565
|
if (response.status === 401) {
|
|
@@ -13266,7 +13591,8 @@ var init_dist2 = __esm({
|
|
|
13266
13591
|
}
|
|
13267
13592
|
return ok({
|
|
13268
13593
|
keys,
|
|
13269
|
-
...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 }
|
|
13270
13596
|
});
|
|
13271
13597
|
} catch (error) {
|
|
13272
13598
|
return err(wrapError2("kv", error));
|
|
@@ -13386,6 +13712,13 @@ var init_dist2 = __esm({
|
|
|
13386
13712
|
}
|
|
13387
13713
|
});
|
|
13388
13714
|
}
|
|
13715
|
+
async batchHead(keys, options) {
|
|
13716
|
+
return this.withTelemetry(
|
|
13717
|
+
"batchHead",
|
|
13718
|
+
String(keys.length),
|
|
13719
|
+
() => this.batchRead(keys, KVAction.HEAD, options)
|
|
13720
|
+
);
|
|
13721
|
+
}
|
|
13389
13722
|
/**
|
|
13390
13723
|
* Create a short-lived signed URL for reading a KV object.
|
|
13391
13724
|
*/
|
|
@@ -15325,6 +15658,10 @@ var init_dist2 = __esm({
|
|
|
15325
15658
|
* @returns Result with array of key names (vault/ prefix stripped)
|
|
15326
15659
|
*/
|
|
15327
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) {
|
|
15328
15665
|
return this.withTelemetry("list", options?.prefix, async () => {
|
|
15329
15666
|
if (!this.isUnlocked) {
|
|
15330
15667
|
return vaultError({
|
|
@@ -15342,7 +15679,9 @@ var init_dist2 = __esm({
|
|
|
15342
15679
|
const listPrefix = options?.prefix ? `vault/${options.prefix}` : "vault/";
|
|
15343
15680
|
const listResult = await this.tc.kv.list({
|
|
15344
15681
|
prefix: listPrefix,
|
|
15345
|
-
removePrefix: true
|
|
15682
|
+
removePrefix: true,
|
|
15683
|
+
...options?.limit === void 0 ? {} : { limit: options.limit },
|
|
15684
|
+
...options?.cursor === void 0 ? {} : { cursor: options.cursor }
|
|
15346
15685
|
});
|
|
15347
15686
|
if (!listResult.ok) {
|
|
15348
15687
|
return vaultError({
|
|
@@ -15359,7 +15698,11 @@ var init_dist2 = __esm({
|
|
|
15359
15698
|
(k) => k.startsWith(userPrefix) ? k.slice(userPrefix.length) : k
|
|
15360
15699
|
);
|
|
15361
15700
|
}
|
|
15362
|
-
return ok(
|
|
15701
|
+
return ok({
|
|
15702
|
+
keys,
|
|
15703
|
+
truncated: listResult.data.truncated === true,
|
|
15704
|
+
...listResult.data.nextCursor === void 0 ? {} : { nextCursor: listResult.data.nextCursor }
|
|
15705
|
+
});
|
|
15363
15706
|
} catch (error) {
|
|
15364
15707
|
return vaultError({
|
|
15365
15708
|
code: "STORAGE_ERROR",
|
|
@@ -16138,126 +16481,9 @@ var init_dist2 = __esm({
|
|
|
16138
16481
|
}
|
|
16139
16482
|
});
|
|
16140
16483
|
|
|
16141
|
-
// ../../node_modules/ms/index.js
|
|
16142
|
-
var require_ms = __commonJS({
|
|
16143
|
-
"../../node_modules/ms/index.js"(exports, module) {
|
|
16144
|
-
"use strict";
|
|
16145
|
-
var s = 1e3;
|
|
16146
|
-
var m = s * 60;
|
|
16147
|
-
var h = m * 60;
|
|
16148
|
-
var d = h * 24;
|
|
16149
|
-
var w = d * 7;
|
|
16150
|
-
var y = d * 365.25;
|
|
16151
|
-
module.exports = function(val, options) {
|
|
16152
|
-
options = options || {};
|
|
16153
|
-
var type = typeof val;
|
|
16154
|
-
if (type === "string" && val.length > 0) {
|
|
16155
|
-
return parse(val);
|
|
16156
|
-
} else if (type === "number" && isFinite(val)) {
|
|
16157
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
16158
|
-
}
|
|
16159
|
-
throw new Error(
|
|
16160
|
-
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
16161
|
-
);
|
|
16162
|
-
};
|
|
16163
|
-
function parse(str) {
|
|
16164
|
-
str = String(str);
|
|
16165
|
-
if (str.length > 100) {
|
|
16166
|
-
return;
|
|
16167
|
-
}
|
|
16168
|
-
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(
|
|
16169
|
-
str
|
|
16170
|
-
);
|
|
16171
|
-
if (!match) {
|
|
16172
|
-
return;
|
|
16173
|
-
}
|
|
16174
|
-
var n = parseFloat(match[1]);
|
|
16175
|
-
var type = (match[2] || "ms").toLowerCase();
|
|
16176
|
-
switch (type) {
|
|
16177
|
-
case "years":
|
|
16178
|
-
case "year":
|
|
16179
|
-
case "yrs":
|
|
16180
|
-
case "yr":
|
|
16181
|
-
case "y":
|
|
16182
|
-
return n * y;
|
|
16183
|
-
case "weeks":
|
|
16184
|
-
case "week":
|
|
16185
|
-
case "w":
|
|
16186
|
-
return n * w;
|
|
16187
|
-
case "days":
|
|
16188
|
-
case "day":
|
|
16189
|
-
case "d":
|
|
16190
|
-
return n * d;
|
|
16191
|
-
case "hours":
|
|
16192
|
-
case "hour":
|
|
16193
|
-
case "hrs":
|
|
16194
|
-
case "hr":
|
|
16195
|
-
case "h":
|
|
16196
|
-
return n * h;
|
|
16197
|
-
case "minutes":
|
|
16198
|
-
case "minute":
|
|
16199
|
-
case "mins":
|
|
16200
|
-
case "min":
|
|
16201
|
-
case "m":
|
|
16202
|
-
return n * m;
|
|
16203
|
-
case "seconds":
|
|
16204
|
-
case "second":
|
|
16205
|
-
case "secs":
|
|
16206
|
-
case "sec":
|
|
16207
|
-
case "s":
|
|
16208
|
-
return n * s;
|
|
16209
|
-
case "milliseconds":
|
|
16210
|
-
case "millisecond":
|
|
16211
|
-
case "msecs":
|
|
16212
|
-
case "msec":
|
|
16213
|
-
case "ms":
|
|
16214
|
-
return n;
|
|
16215
|
-
default:
|
|
16216
|
-
return void 0;
|
|
16217
|
-
}
|
|
16218
|
-
}
|
|
16219
|
-
function fmtShort(ms3) {
|
|
16220
|
-
var msAbs = Math.abs(ms3);
|
|
16221
|
-
if (msAbs >= d) {
|
|
16222
|
-
return Math.round(ms3 / d) + "d";
|
|
16223
|
-
}
|
|
16224
|
-
if (msAbs >= h) {
|
|
16225
|
-
return Math.round(ms3 / h) + "h";
|
|
16226
|
-
}
|
|
16227
|
-
if (msAbs >= m) {
|
|
16228
|
-
return Math.round(ms3 / m) + "m";
|
|
16229
|
-
}
|
|
16230
|
-
if (msAbs >= s) {
|
|
16231
|
-
return Math.round(ms3 / s) + "s";
|
|
16232
|
-
}
|
|
16233
|
-
return ms3 + "ms";
|
|
16234
|
-
}
|
|
16235
|
-
function fmtLong(ms3) {
|
|
16236
|
-
var msAbs = Math.abs(ms3);
|
|
16237
|
-
if (msAbs >= d) {
|
|
16238
|
-
return plural2(ms3, msAbs, d, "day");
|
|
16239
|
-
}
|
|
16240
|
-
if (msAbs >= h) {
|
|
16241
|
-
return plural2(ms3, msAbs, h, "hour");
|
|
16242
|
-
}
|
|
16243
|
-
if (msAbs >= m) {
|
|
16244
|
-
return plural2(ms3, msAbs, m, "minute");
|
|
16245
|
-
}
|
|
16246
|
-
if (msAbs >= s) {
|
|
16247
|
-
return plural2(ms3, msAbs, s, "second");
|
|
16248
|
-
}
|
|
16249
|
-
return ms3 + " ms";
|
|
16250
|
-
}
|
|
16251
|
-
function plural2(ms3, msAbs, n, name2) {
|
|
16252
|
-
var isPlural = msAbs >= n * 1.5;
|
|
16253
|
-
return Math.round(ms3 / n) + " " + name2 + (isPlural ? "s" : "");
|
|
16254
|
-
}
|
|
16255
|
-
}
|
|
16256
|
-
});
|
|
16257
|
-
|
|
16258
16484
|
// ../sdk-core/dist/index.js
|
|
16259
16485
|
import { SiweMessage } from "siwe";
|
|
16260
|
-
import
|
|
16486
|
+
import crypto22 from "crypto";
|
|
16261
16487
|
import { Buffer as Buffer2 } from "buffer";
|
|
16262
16488
|
import { Buffer as Buffer3 } from "buffer";
|
|
16263
16489
|
import { Buffer as Buffer4 } from "buffer";
|
|
@@ -16545,8 +16771,8 @@ function read2(buf, offset) {
|
|
|
16545
16771
|
return res;
|
|
16546
16772
|
}
|
|
16547
16773
|
function decode3(data, offset = 0) {
|
|
16548
|
-
const
|
|
16549
|
-
return [
|
|
16774
|
+
const code3 = varint_default.decode(data, offset);
|
|
16775
|
+
return [code3, varint_default.decode.bytes];
|
|
16550
16776
|
}
|
|
16551
16777
|
function encodeTo(int, target, offset = 0) {
|
|
16552
16778
|
varint_default.encode(int, target, offset);
|
|
@@ -16555,25 +16781,25 @@ function encodeTo(int, target, offset = 0) {
|
|
|
16555
16781
|
function encodingLength(int) {
|
|
16556
16782
|
return varint_default.encodingLength(int);
|
|
16557
16783
|
}
|
|
16558
|
-
function create(
|
|
16559
|
-
const size2 =
|
|
16560
|
-
const sizeOffset = encodingLength(
|
|
16784
|
+
function create(code3, digest4) {
|
|
16785
|
+
const size2 = digest4.byteLength;
|
|
16786
|
+
const sizeOffset = encodingLength(code3);
|
|
16561
16787
|
const digestOffset = sizeOffset + encodingLength(size2);
|
|
16562
|
-
const
|
|
16563
|
-
encodeTo(
|
|
16564
|
-
encodeTo(size2,
|
|
16565
|
-
|
|
16566
|
-
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);
|
|
16567
16793
|
}
|
|
16568
16794
|
function decode4(multihash) {
|
|
16569
|
-
const
|
|
16570
|
-
const [
|
|
16571
|
-
const [size2, digestOffset] = decode3(
|
|
16572
|
-
const
|
|
16573
|
-
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) {
|
|
16574
16800
|
throw new Error("Incorrect length");
|
|
16575
16801
|
}
|
|
16576
|
-
return new Digest(
|
|
16802
|
+
return new Digest(code3, size2, digest4, bytes2);
|
|
16577
16803
|
}
|
|
16578
16804
|
function equals2(a, b) {
|
|
16579
16805
|
if (a === b) {
|
|
@@ -16584,19 +16810,19 @@ function equals2(a, b) {
|
|
|
16584
16810
|
}
|
|
16585
16811
|
}
|
|
16586
16812
|
function format(link, base3) {
|
|
16587
|
-
const { bytes, version: version3 } = link;
|
|
16813
|
+
const { bytes: bytes2, version: version3 } = link;
|
|
16588
16814
|
switch (version3) {
|
|
16589
16815
|
case 0:
|
|
16590
|
-
return toStringV0(
|
|
16816
|
+
return toStringV0(bytes2, baseCache(link), base3 ?? base58btc.encoder);
|
|
16591
16817
|
default:
|
|
16592
|
-
return toStringV1(
|
|
16818
|
+
return toStringV1(bytes2, baseCache(link), base3 ?? base32.encoder);
|
|
16593
16819
|
}
|
|
16594
16820
|
}
|
|
16595
|
-
function baseCache(
|
|
16596
|
-
const baseCache2 = cache.get(
|
|
16821
|
+
function baseCache(cid2) {
|
|
16822
|
+
const baseCache2 = cache.get(cid2);
|
|
16597
16823
|
if (baseCache2 == null) {
|
|
16598
16824
|
const baseCache3 = /* @__PURE__ */ new Map();
|
|
16599
|
-
cache.set(
|
|
16825
|
+
cache.set(cid2, baseCache3);
|
|
16600
16826
|
return baseCache3;
|
|
16601
16827
|
}
|
|
16602
16828
|
return baseCache2;
|
|
@@ -16631,39 +16857,39 @@ function parseCIDtoBytes(source, base3) {
|
|
|
16631
16857
|
}
|
|
16632
16858
|
}
|
|
16633
16859
|
}
|
|
16634
|
-
function toStringV0(
|
|
16860
|
+
function toStringV0(bytes2, cache2, base3) {
|
|
16635
16861
|
const { prefix } = base3;
|
|
16636
16862
|
if (prefix !== base58btc.prefix) {
|
|
16637
16863
|
throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
|
|
16638
16864
|
}
|
|
16639
|
-
const
|
|
16640
|
-
if (
|
|
16641
|
-
const
|
|
16642
|
-
cache2.set(prefix,
|
|
16643
|
-
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;
|
|
16644
16870
|
} else {
|
|
16645
|
-
return
|
|
16871
|
+
return cid2;
|
|
16646
16872
|
}
|
|
16647
16873
|
}
|
|
16648
|
-
function toStringV1(
|
|
16874
|
+
function toStringV1(bytes2, cache2, base3) {
|
|
16649
16875
|
const { prefix } = base3;
|
|
16650
|
-
const
|
|
16651
|
-
if (
|
|
16652
|
-
const
|
|
16653
|
-
cache2.set(prefix,
|
|
16654
|
-
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;
|
|
16655
16881
|
} else {
|
|
16656
|
-
return
|
|
16882
|
+
return cid2;
|
|
16657
16883
|
}
|
|
16658
16884
|
}
|
|
16659
|
-
function encodeCID(version3,
|
|
16885
|
+
function encodeCID(version3, code3, multihash) {
|
|
16660
16886
|
const codeOffset = encodingLength(version3);
|
|
16661
|
-
const hashOffset = codeOffset + encodingLength(
|
|
16662
|
-
const
|
|
16663
|
-
encodeTo(version3,
|
|
16664
|
-
encodeTo(
|
|
16665
|
-
|
|
16666
|
-
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;
|
|
16667
16893
|
}
|
|
16668
16894
|
function encode3(data) {
|
|
16669
16895
|
return data.reduce((p, c) => {
|
|
@@ -16693,19 +16919,19 @@ function digest(input, options2) {
|
|
|
16693
16919
|
}
|
|
16694
16920
|
input = input.subarray(0, options2.truncate);
|
|
16695
16921
|
}
|
|
16696
|
-
return create(
|
|
16922
|
+
return create(code2, encode4(input));
|
|
16697
16923
|
}
|
|
16698
|
-
function from2({ name: name2, code:
|
|
16699
|
-
return new Hasher(name2,
|
|
16924
|
+
function from2({ name: name2, code: code3, encode: encode5, minDigestLength, maxDigestLength }) {
|
|
16925
|
+
return new Hasher(name2, code3, encode5, minDigestLength, maxDigestLength);
|
|
16700
16926
|
}
|
|
16701
|
-
function createDigest(
|
|
16702
|
-
if (truncate != null && truncate !==
|
|
16703
|
-
if (truncate >
|
|
16704
|
-
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}`);
|
|
16705
16931
|
}
|
|
16706
|
-
|
|
16932
|
+
digest4 = digest4.subarray(0, truncate);
|
|
16707
16933
|
}
|
|
16708
|
-
return create(
|
|
16934
|
+
return create(code3, digest4);
|
|
16709
16935
|
}
|
|
16710
16936
|
function parseStrictRfc33392(value) {
|
|
16711
16937
|
if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
|
|
@@ -17071,27 +17297,27 @@ function validate(...funcs) {
|
|
|
17071
17297
|
}
|
|
17072
17298
|
};
|
|
17073
17299
|
}
|
|
17074
|
-
function bytesToComponents(
|
|
17300
|
+
function bytesToComponents(bytes2) {
|
|
17075
17301
|
const components = [];
|
|
17076
17302
|
let i = 0;
|
|
17077
|
-
while (i <
|
|
17078
|
-
const
|
|
17079
|
-
const codec = registry.getProtocol(
|
|
17080
|
-
const codeLength = encodingLength2(
|
|
17081
|
-
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);
|
|
17082
17308
|
let sizeLength = 0;
|
|
17083
17309
|
if (size2 > 0 && codec.size === V) {
|
|
17084
17310
|
sizeLength = encodingLength2(size2);
|
|
17085
17311
|
}
|
|
17086
17312
|
const componentLength = codeLength + sizeLength + size2;
|
|
17087
17313
|
const component = {
|
|
17088
|
-
code:
|
|
17314
|
+
code: code3,
|
|
17089
17315
|
name: codec.name,
|
|
17090
|
-
bytes:
|
|
17316
|
+
bytes: bytes2.subarray(i, i + componentLength)
|
|
17091
17317
|
};
|
|
17092
17318
|
if (size2 > 0) {
|
|
17093
17319
|
const valueOffset = i + codeLength + sizeLength;
|
|
17094
|
-
const valueBytes =
|
|
17320
|
+
const valueBytes = bytes2.subarray(valueOffset, valueOffset + size2);
|
|
17095
17321
|
component.value = codec.bytesToValue?.(valueBytes) ?? toString2(valueBytes);
|
|
17096
17322
|
}
|
|
17097
17323
|
components.push(component);
|
|
@@ -17101,7 +17327,7 @@ function bytesToComponents(bytes) {
|
|
|
17101
17327
|
}
|
|
17102
17328
|
function componentsToBytes(components) {
|
|
17103
17329
|
let length2 = 0;
|
|
17104
|
-
const
|
|
17330
|
+
const bytes2 = [];
|
|
17105
17331
|
for (const component of components) {
|
|
17106
17332
|
if (component.bytes == null) {
|
|
17107
17333
|
const codec = registry.getProtocol(component.code);
|
|
@@ -17116,23 +17342,23 @@ function componentsToBytes(components) {
|
|
|
17116
17342
|
valueLengthLength = encodingLength2(valueLength);
|
|
17117
17343
|
}
|
|
17118
17344
|
}
|
|
17119
|
-
const
|
|
17345
|
+
const bytes3 = new Uint8Array(codecLength + valueLengthLength + valueLength);
|
|
17120
17346
|
let offset = 0;
|
|
17121
|
-
encodeUint8Array(component.code,
|
|
17347
|
+
encodeUint8Array(component.code, bytes3, offset);
|
|
17122
17348
|
offset += codecLength;
|
|
17123
17349
|
if (valueBytes != null) {
|
|
17124
17350
|
if (codec.size === V) {
|
|
17125
|
-
encodeUint8Array(valueLength,
|
|
17351
|
+
encodeUint8Array(valueLength, bytes3, offset);
|
|
17126
17352
|
offset += valueLengthLength;
|
|
17127
17353
|
}
|
|
17128
|
-
|
|
17354
|
+
bytes3.set(valueBytes, offset);
|
|
17129
17355
|
}
|
|
17130
|
-
component.bytes =
|
|
17356
|
+
component.bytes = bytes3;
|
|
17131
17357
|
}
|
|
17132
|
-
|
|
17358
|
+
bytes2.push(component.bytes);
|
|
17133
17359
|
length2 += component.bytes.byteLength;
|
|
17134
17360
|
}
|
|
17135
|
-
return concat2(
|
|
17361
|
+
return concat2(bytes2, length2);
|
|
17136
17362
|
}
|
|
17137
17363
|
function stringToComponents(string2) {
|
|
17138
17364
|
if (string2.charAt(0) !== "/") {
|
|
@@ -17206,14 +17432,14 @@ function componentsToString(components) {
|
|
|
17206
17432
|
];
|
|
17207
17433
|
}).join("/")}`;
|
|
17208
17434
|
}
|
|
17209
|
-
function sizeForAddr(codec,
|
|
17435
|
+
function sizeForAddr(codec, bytes2, offset) {
|
|
17210
17436
|
if (codec.size == null || codec.size === 0) {
|
|
17211
17437
|
return 0;
|
|
17212
17438
|
}
|
|
17213
17439
|
if (codec.size > 0) {
|
|
17214
17440
|
return codec.size / 8;
|
|
17215
17441
|
}
|
|
17216
|
-
return decode6(
|
|
17442
|
+
return decode6(bytes2, offset);
|
|
17217
17443
|
}
|
|
17218
17444
|
function toComponents(addr) {
|
|
17219
17445
|
if (addr == null) {
|
|
@@ -17266,7 +17492,7 @@ function extractTuple(name2, ma) {
|
|
|
17266
17492
|
return ma.find((component) => component.name === name2);
|
|
17267
17493
|
}
|
|
17268
17494
|
function hasTLS(ma) {
|
|
17269
|
-
return ma.some(({ code:
|
|
17495
|
+
return ma.some(({ code: code3 }) => code3 === CODE_TLS);
|
|
17270
17496
|
}
|
|
17271
17497
|
function interpretNext(head, rest) {
|
|
17272
17498
|
const interpreter = interpreters[head.name];
|
|
@@ -17633,12 +17859,12 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
17633
17859
|
"did:key must use base58btc multibase"
|
|
17634
17860
|
);
|
|
17635
17861
|
}
|
|
17636
|
-
const
|
|
17637
|
-
if (
|
|
17638
|
-
return
|
|
17862
|
+
const bytes2 = bases.base58btc.decode(identifier);
|
|
17863
|
+
if (bytes2.length === 34 && bytes2[0] === 237 && bytes2[1] === 1) {
|
|
17864
|
+
return bytes2.slice(2);
|
|
17639
17865
|
}
|
|
17640
|
-
if (
|
|
17641
|
-
return
|
|
17866
|
+
if (bytes2.length === 33 && bytes2[0] === 237) {
|
|
17867
|
+
return bytes2.slice(1);
|
|
17642
17868
|
}
|
|
17643
17869
|
throw new LocationRecordValidationError(
|
|
17644
17870
|
"did:key must be an Ed25519 public key"
|
|
@@ -17646,7 +17872,7 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
17646
17872
|
}
|
|
17647
17873
|
function decodeBase64Url(value) {
|
|
17648
17874
|
const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
17649
|
-
const
|
|
17875
|
+
const bytes2 = [];
|
|
17650
17876
|
let buffer = 0;
|
|
17651
17877
|
let bits = 0;
|
|
17652
17878
|
for (const char of value) {
|
|
@@ -17660,30 +17886,32 @@ function decodeBase64Url(value) {
|
|
|
17660
17886
|
bits += 6;
|
|
17661
17887
|
if (bits >= 8) {
|
|
17662
17888
|
bits -= 8;
|
|
17663
|
-
|
|
17889
|
+
bytes2.push(buffer >> bits & 255);
|
|
17664
17890
|
}
|
|
17665
17891
|
}
|
|
17666
|
-
return Uint8Array.from(
|
|
17892
|
+
return Uint8Array.from(bytes2);
|
|
17667
17893
|
}
|
|
17668
|
-
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;
|
|
17669
17895
|
var init_dist3 = __esm({
|
|
17670
17896
|
"../sdk-core/dist/index.js"() {
|
|
17671
17897
|
"use strict";
|
|
17672
17898
|
init_zod();
|
|
17673
17899
|
init_zod();
|
|
17674
17900
|
init_dist();
|
|
17675
|
-
init_dist2();
|
|
17676
17901
|
init_zod();
|
|
17902
|
+
init_zod();
|
|
17903
|
+
import_ms = __toESM(require_ms(), 1);
|
|
17677
17904
|
init_dist2();
|
|
17678
17905
|
init_dist2();
|
|
17679
17906
|
init_zod();
|
|
17907
|
+
init_dist2();
|
|
17680
17908
|
init_zod();
|
|
17681
17909
|
init_dist2();
|
|
17682
|
-
|
|
17910
|
+
init_dist2();
|
|
17911
|
+
init_zod();
|
|
17683
17912
|
init_dist2();
|
|
17684
17913
|
init_dist();
|
|
17685
17914
|
init_dist2();
|
|
17686
|
-
init_zod();
|
|
17687
17915
|
init_dist2();
|
|
17688
17916
|
init_dist();
|
|
17689
17917
|
init_ed25519();
|
|
@@ -17751,9 +17979,9 @@ var init_dist3 = __esm({
|
|
|
17751
17979
|
this.prefix = prefix;
|
|
17752
17980
|
this.baseEncode = baseEncode;
|
|
17753
17981
|
}
|
|
17754
|
-
encode(
|
|
17755
|
-
if (
|
|
17756
|
-
return `${this.prefix}${this.baseEncode(
|
|
17982
|
+
encode(bytes2) {
|
|
17983
|
+
if (bytes2 instanceof Uint8Array) {
|
|
17984
|
+
return `${this.prefix}${this.baseEncode(bytes2)}`;
|
|
17757
17985
|
} else {
|
|
17758
17986
|
throw Error("Unknown type, must be binary type");
|
|
17759
17987
|
}
|
|
@@ -17943,15 +18171,15 @@ var init_dist3 = __esm({
|
|
|
17943
18171
|
/**
|
|
17944
18172
|
* Creates a multihash digest.
|
|
17945
18173
|
*/
|
|
17946
|
-
constructor(
|
|
18174
|
+
constructor(code3, size2, digest4, bytes2) {
|
|
17947
18175
|
__publicField(this, "code");
|
|
17948
18176
|
__publicField(this, "size");
|
|
17949
18177
|
__publicField(this, "digest");
|
|
17950
18178
|
__publicField(this, "bytes");
|
|
17951
|
-
this.code =
|
|
18179
|
+
this.code = code3;
|
|
17952
18180
|
this.size = size2;
|
|
17953
|
-
this.digest =
|
|
17954
|
-
this.bytes =
|
|
18181
|
+
this.digest = digest4;
|
|
18182
|
+
this.bytes = bytes2;
|
|
17955
18183
|
}
|
|
17956
18184
|
};
|
|
17957
18185
|
cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -17961,18 +18189,18 @@ var init_dist3 = __esm({
|
|
|
17961
18189
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
17962
18190
|
* @param multihash - (Multi)hash of the of the content.
|
|
17963
18191
|
*/
|
|
17964
|
-
constructor(version3,
|
|
18192
|
+
constructor(version3, code3, multihash, bytes2) {
|
|
17965
18193
|
__publicField(this, "code");
|
|
17966
18194
|
__publicField(this, "version");
|
|
17967
18195
|
__publicField(this, "multihash");
|
|
17968
18196
|
__publicField(this, "bytes");
|
|
17969
18197
|
__publicField(this, "/");
|
|
17970
18198
|
__publicField(this, _a, "CID");
|
|
17971
|
-
this.code =
|
|
18199
|
+
this.code = code3;
|
|
17972
18200
|
this.version = version3;
|
|
17973
18201
|
this.multihash = multihash;
|
|
17974
|
-
this.bytes =
|
|
17975
|
-
this["/"] =
|
|
18202
|
+
this.bytes = bytes2;
|
|
18203
|
+
this["/"] = bytes2;
|
|
17976
18204
|
}
|
|
17977
18205
|
/**
|
|
17978
18206
|
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
@@ -17997,8 +18225,8 @@ var init_dist3 = __esm({
|
|
|
17997
18225
|
return this;
|
|
17998
18226
|
}
|
|
17999
18227
|
case 1: {
|
|
18000
|
-
const { code:
|
|
18001
|
-
if (
|
|
18228
|
+
const { code: code3, multihash } = this;
|
|
18229
|
+
if (code3 !== DAG_PB_CODE) {
|
|
18002
18230
|
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
18003
18231
|
}
|
|
18004
18232
|
if (multihash.code !== SHA_256_CODE) {
|
|
@@ -18014,8 +18242,8 @@ var init_dist3 = __esm({
|
|
|
18014
18242
|
toV1() {
|
|
18015
18243
|
switch (this.version) {
|
|
18016
18244
|
case 0: {
|
|
18017
|
-
const { code:
|
|
18018
|
-
const multihash = create(
|
|
18245
|
+
const { code: code3, digest: digest4 } = this.multihash;
|
|
18246
|
+
const multihash = create(code3, digest4);
|
|
18019
18247
|
return _CID.createV1(this.code, multihash);
|
|
18020
18248
|
}
|
|
18021
18249
|
case 1: {
|
|
@@ -18064,12 +18292,12 @@ var init_dist3 = __esm({
|
|
|
18064
18292
|
if (value instanceof _CID) {
|
|
18065
18293
|
return value;
|
|
18066
18294
|
} else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
|
|
18067
|
-
const { version: version3, code:
|
|
18068
|
-
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));
|
|
18069
18297
|
} else if (value[cidSymbol] === true) {
|
|
18070
|
-
const { version: version3, multihash, code:
|
|
18071
|
-
const
|
|
18072
|
-
return _CID.create(version3,
|
|
18298
|
+
const { version: version3, multihash, code: code3 } = value;
|
|
18299
|
+
const digest4 = decode4(multihash);
|
|
18300
|
+
return _CID.create(version3, code3, digest4);
|
|
18073
18301
|
} else {
|
|
18074
18302
|
return null;
|
|
18075
18303
|
}
|
|
@@ -18079,24 +18307,24 @@ var init_dist3 = __esm({
|
|
|
18079
18307
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
18080
18308
|
* @param digest - (Multi)hash of the of the content.
|
|
18081
18309
|
*/
|
|
18082
|
-
static create(version3,
|
|
18083
|
-
if (typeof
|
|
18310
|
+
static create(version3, code3, digest4) {
|
|
18311
|
+
if (typeof code3 !== "number") {
|
|
18084
18312
|
throw new Error("String codecs are no longer supported");
|
|
18085
18313
|
}
|
|
18086
|
-
if (!(
|
|
18314
|
+
if (!(digest4.bytes instanceof Uint8Array)) {
|
|
18087
18315
|
throw new Error("Invalid digest");
|
|
18088
18316
|
}
|
|
18089
18317
|
switch (version3) {
|
|
18090
18318
|
case 0: {
|
|
18091
|
-
if (
|
|
18319
|
+
if (code3 !== DAG_PB_CODE) {
|
|
18092
18320
|
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
18093
18321
|
} else {
|
|
18094
|
-
return new _CID(version3,
|
|
18322
|
+
return new _CID(version3, code3, digest4, digest4.bytes);
|
|
18095
18323
|
}
|
|
18096
18324
|
}
|
|
18097
18325
|
case 1: {
|
|
18098
|
-
const
|
|
18099
|
-
return new _CID(version3,
|
|
18326
|
+
const bytes2 = encodeCID(version3, code3, digest4.bytes);
|
|
18327
|
+
return new _CID(version3, code3, digest4, bytes2);
|
|
18100
18328
|
}
|
|
18101
18329
|
default: {
|
|
18102
18330
|
throw new Error("Invalid version");
|
|
@@ -18106,8 +18334,8 @@ var init_dist3 = __esm({
|
|
|
18106
18334
|
/**
|
|
18107
18335
|
* Simplified version of `create` for CIDv0.
|
|
18108
18336
|
*/
|
|
18109
|
-
static createV0(
|
|
18110
|
-
return _CID.create(0, DAG_PB_CODE,
|
|
18337
|
+
static createV0(digest4) {
|
|
18338
|
+
return _CID.create(0, DAG_PB_CODE, digest4);
|
|
18111
18339
|
}
|
|
18112
18340
|
/**
|
|
18113
18341
|
* Simplified version of `create` for CIDv1.
|
|
@@ -18115,8 +18343,8 @@ var init_dist3 = __esm({
|
|
|
18115
18343
|
* @param code - Content encoding format code.
|
|
18116
18344
|
* @param digest - Multihash of the content.
|
|
18117
18345
|
*/
|
|
18118
|
-
static createV1(
|
|
18119
|
-
return _CID.create(1,
|
|
18346
|
+
static createV1(code3, digest4) {
|
|
18347
|
+
return _CID.create(1, code3, digest4);
|
|
18120
18348
|
}
|
|
18121
18349
|
/**
|
|
18122
18350
|
* Decoded a CID from its binary representation. The byte array must contain
|
|
@@ -18125,12 +18353,12 @@ var init_dist3 = __esm({
|
|
|
18125
18353
|
* An error will be thrown if the bytes provided do not contain a valid
|
|
18126
18354
|
* binary representation of a CID.
|
|
18127
18355
|
*/
|
|
18128
|
-
static decode(
|
|
18129
|
-
const [
|
|
18356
|
+
static decode(bytes2) {
|
|
18357
|
+
const [cid2, remainder] = _CID.decodeFirst(bytes2);
|
|
18130
18358
|
if (remainder.length !== 0) {
|
|
18131
18359
|
throw new Error("Incorrect length");
|
|
18132
18360
|
}
|
|
18133
|
-
return
|
|
18361
|
+
return cid2;
|
|
18134
18362
|
}
|
|
18135
18363
|
/**
|
|
18136
18364
|
* Decoded a CID from its binary representation at the beginning of a byte
|
|
@@ -18141,17 +18369,17 @@ var init_dist3 = __esm({
|
|
|
18141
18369
|
* will be a zero-length byte array if the provided bytes only contained a
|
|
18142
18370
|
* binary CID representation.
|
|
18143
18371
|
*/
|
|
18144
|
-
static decodeFirst(
|
|
18145
|
-
const specs = _CID.inspectBytes(
|
|
18372
|
+
static decodeFirst(bytes2) {
|
|
18373
|
+
const specs = _CID.inspectBytes(bytes2);
|
|
18146
18374
|
const prefixSize = specs.size - specs.multihashSize;
|
|
18147
|
-
const multihashBytes = coerce2(
|
|
18375
|
+
const multihashBytes = coerce2(bytes2.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
18148
18376
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
18149
18377
|
throw new Error("Incorrect length");
|
|
18150
18378
|
}
|
|
18151
18379
|
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
18152
|
-
const
|
|
18153
|
-
const
|
|
18154
|
-
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)];
|
|
18155
18383
|
}
|
|
18156
18384
|
/**
|
|
18157
18385
|
* Inspect the initial bytes of a CID to determine its properties.
|
|
@@ -18194,13 +18422,13 @@ var init_dist3 = __esm({
|
|
|
18194
18422
|
* a default decoder).
|
|
18195
18423
|
*/
|
|
18196
18424
|
static parse(source, base3) {
|
|
18197
|
-
const [prefix,
|
|
18198
|
-
const
|
|
18199
|
-
if (
|
|
18425
|
+
const [prefix, bytes2] = parseCIDtoBytes(source, base3);
|
|
18426
|
+
const cid2 = _CID.decode(bytes2);
|
|
18427
|
+
if (cid2.version === 0 && source[0] !== "Q") {
|
|
18200
18428
|
throw Error("Version 0 CID string must not include multibase prefix");
|
|
18201
18429
|
}
|
|
18202
|
-
baseCache(
|
|
18203
|
-
return
|
|
18430
|
+
baseCache(cid2).set(prefix, source);
|
|
18431
|
+
return cid2;
|
|
18204
18432
|
}
|
|
18205
18433
|
};
|
|
18206
18434
|
DAG_PB_CODE = 112;
|
|
@@ -18345,10 +18573,10 @@ var init_dist3 = __esm({
|
|
|
18345
18573
|
__export2(identity_exports2, {
|
|
18346
18574
|
identity: () => identity2
|
|
18347
18575
|
});
|
|
18348
|
-
|
|
18576
|
+
code2 = 0;
|
|
18349
18577
|
name = "identity";
|
|
18350
18578
|
encode4 = coerce2;
|
|
18351
|
-
identity2 = { code, name, encode: encode4, digest };
|
|
18579
|
+
identity2 = { code: code2, name, encode: encode4, digest };
|
|
18352
18580
|
sha2_exports = {};
|
|
18353
18581
|
__export2(sha2_exports, {
|
|
18354
18582
|
sha256: () => sha2562,
|
|
@@ -18356,14 +18584,14 @@ var init_dist3 = __esm({
|
|
|
18356
18584
|
});
|
|
18357
18585
|
DEFAULT_MIN_DIGEST_LENGTH = 20;
|
|
18358
18586
|
Hasher = class {
|
|
18359
|
-
constructor(name2,
|
|
18587
|
+
constructor(name2, code3, encode5, minDigestLength, maxDigestLength) {
|
|
18360
18588
|
__publicField(this, "name");
|
|
18361
18589
|
__publicField(this, "code");
|
|
18362
18590
|
__publicField(this, "encode");
|
|
18363
18591
|
__publicField(this, "minDigestLength");
|
|
18364
18592
|
__publicField(this, "maxDigestLength");
|
|
18365
18593
|
this.name = name2;
|
|
18366
|
-
this.code =
|
|
18594
|
+
this.code = code3;
|
|
18367
18595
|
this.encode = encode5;
|
|
18368
18596
|
this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
|
|
18369
18597
|
this.maxDigestLength = maxDigestLength;
|
|
@@ -18382,7 +18610,7 @@ var init_dist3 = __esm({
|
|
|
18382
18610
|
if (result instanceof Uint8Array) {
|
|
18383
18611
|
return createDigest(result, this.code, options2?.truncate);
|
|
18384
18612
|
}
|
|
18385
|
-
return result.then((
|
|
18613
|
+
return result.then((digest4) => createDigest(digest4, this.code, options2?.truncate));
|
|
18386
18614
|
} else {
|
|
18387
18615
|
throw Error("Unknown type, must be binary type");
|
|
18388
18616
|
}
|
|
@@ -18391,12 +18619,12 @@ var init_dist3 = __esm({
|
|
|
18391
18619
|
sha2562 = from2({
|
|
18392
18620
|
name: "sha2-256",
|
|
18393
18621
|
code: 18,
|
|
18394
|
-
encode: (input) => coerce2(
|
|
18622
|
+
encode: (input) => coerce2(crypto22.createHash("sha256").update(input).digest())
|
|
18395
18623
|
});
|
|
18396
18624
|
sha5122 = from2({
|
|
18397
18625
|
name: "sha2-512",
|
|
18398
18626
|
code: 19,
|
|
18399
|
-
encode: (input) => coerce2(
|
|
18627
|
+
encode: (input) => coerce2(crypto22.createHash("sha512").update(input).digest())
|
|
18400
18628
|
});
|
|
18401
18629
|
bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
|
|
18402
18630
|
hashes = { ...sha2_exports, ...identity_exports2 };
|
|
@@ -18589,83 +18817,6 @@ var init_dist3 = __esm({
|
|
|
18589
18817
|
statement
|
|
18590
18818
|
])
|
|
18591
18819
|
);
|
|
18592
|
-
ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
|
|
18593
|
-
EnsDataSchema2 = external_exports.object({
|
|
18594
|
-
/** ENS name/domain. */
|
|
18595
|
-
domain: external_exports.string().nullable().optional(),
|
|
18596
|
-
/** ENS avatar URL. */
|
|
18597
|
-
avatarUrl: external_exports.string().nullable().optional()
|
|
18598
|
-
});
|
|
18599
|
-
PersistedTinyCloudSessionSchema = external_exports.object({
|
|
18600
|
-
/** The delegation header containing the UCAN */
|
|
18601
|
-
delegationHeader: external_exports.object({
|
|
18602
|
-
Authorization: external_exports.string()
|
|
18603
|
-
}),
|
|
18604
|
-
/** The delegation CID */
|
|
18605
|
-
delegationCid: external_exports.string(),
|
|
18606
|
-
/** The space ID for this session */
|
|
18607
|
-
spaceId: external_exports.string(),
|
|
18608
|
-
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
18609
|
-
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
18610
|
-
/** The verification method DID */
|
|
18611
|
-
verificationMethod: external_exports.string()
|
|
18612
|
-
});
|
|
18613
|
-
PersistedSessionDataSchema = external_exports.object({
|
|
18614
|
-
/** User's Ethereum address */
|
|
18615
|
-
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
18616
|
-
/** EIP-155 Chain ID */
|
|
18617
|
-
chainId: external_exports.number().int().positive(),
|
|
18618
|
-
/** Session key in JWK format (stringified) */
|
|
18619
|
-
sessionKey: external_exports.string(),
|
|
18620
|
-
/** The signed SIWE message */
|
|
18621
|
-
siwe: external_exports.string(),
|
|
18622
|
-
/** User's signature of the SIWE message */
|
|
18623
|
-
signature: external_exports.string(),
|
|
18624
|
-
/** TinyCloud delegation data if available */
|
|
18625
|
-
tinycloudSession: PersistedTinyCloudSessionSchema.optional(),
|
|
18626
|
-
/** Session expiration timestamp (ISO 8601 with timezone offset) */
|
|
18627
|
-
expiresAt: external_exports.string().datetime({ offset: true }),
|
|
18628
|
-
/** Session creation timestamp (ISO 8601 with timezone offset) */
|
|
18629
|
-
createdAt: external_exports.string().datetime({ offset: true }),
|
|
18630
|
-
/** Schema version for migrations */
|
|
18631
|
-
version: external_exports.string(),
|
|
18632
|
-
/** Optional ENS data */
|
|
18633
|
-
ens: EnsDataSchema2.optional(),
|
|
18634
|
-
/**
|
|
18635
|
-
* TinyCloud hosts this session was created against. Persisted so a
|
|
18636
|
-
* restored session resolves to the same node without re-running the
|
|
18637
|
-
* registry/fallback resolution (or the wallet sign-in flow). Optional
|
|
18638
|
-
* for backward compatibility with sessions persisted before this field
|
|
18639
|
-
* existed — those restore and lazily re-resolve their hosts.
|
|
18640
|
-
*/
|
|
18641
|
-
tinycloudHosts: external_exports.array(external_exports.string()).optional()
|
|
18642
|
-
});
|
|
18643
|
-
TinyCloudSessionSchema = external_exports.object({
|
|
18644
|
-
/** User's Ethereum address */
|
|
18645
|
-
address: external_exports.string().regex(ethereumAddressPattern, "Invalid Ethereum address"),
|
|
18646
|
-
/** EIP-155 Chain ID */
|
|
18647
|
-
chainId: external_exports.number().int().positive(),
|
|
18648
|
-
/** Session key ID */
|
|
18649
|
-
sessionKey: external_exports.string(),
|
|
18650
|
-
/** The space ID for this session */
|
|
18651
|
-
spaceId: external_exports.string(),
|
|
18652
|
-
/** Additional spaces included in this session's capabilities. Key is logical name, value is full spaceId URI */
|
|
18653
|
-
spaces: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
18654
|
-
/** The delegation CID */
|
|
18655
|
-
delegationCid: external_exports.string(),
|
|
18656
|
-
/** The delegation header for API calls */
|
|
18657
|
-
delegationHeader: external_exports.object({
|
|
18658
|
-
Authorization: external_exports.string()
|
|
18659
|
-
}),
|
|
18660
|
-
/** The verification method DID */
|
|
18661
|
-
verificationMethod: external_exports.string(),
|
|
18662
|
-
/** The session key JWK (required for invoke operations) */
|
|
18663
|
-
jwk: external_exports.object({}).passthrough(),
|
|
18664
|
-
/** The signed SIWE message */
|
|
18665
|
-
siwe: external_exports.string(),
|
|
18666
|
-
/** User's signature of the SIWE message */
|
|
18667
|
-
signature: external_exports.string()
|
|
18668
|
-
});
|
|
18669
18820
|
JWKSchema = external_exports.object({
|
|
18670
18821
|
/** Key type (e.g., "EC", "RSA", "OKP") */
|
|
18671
18822
|
kty: external_exports.string(),
|
|
@@ -19047,112 +19198,6 @@ var init_dist3 = __esm({
|
|
|
19047
19198
|
*/
|
|
19048
19199
|
resources: external_exports.array(DelegatedResourceSchema)
|
|
19049
19200
|
});
|
|
19050
|
-
SpaceConfigSchema = external_exports.object({
|
|
19051
|
-
/** The space identifier (full URI) */
|
|
19052
|
-
id: external_exports.string(),
|
|
19053
|
-
/** The short name of the space */
|
|
19054
|
-
name: external_exports.string(),
|
|
19055
|
-
/** Factory function to create a space-scoped KV service */
|
|
19056
|
-
createKV: external_exports.function(),
|
|
19057
|
-
/** Factory function to create a space-scoped Data Vault service */
|
|
19058
|
-
createVault: external_exports.function(),
|
|
19059
|
-
/** Optional factory function to create a space-scoped secrets service */
|
|
19060
|
-
createSecrets: external_exports.function().optional(),
|
|
19061
|
-
/** Factory function to create space-scoped delegations */
|
|
19062
|
-
createDelegations: external_exports.function(),
|
|
19063
|
-
/** Factory function to create space-scoped sharing */
|
|
19064
|
-
createSharing: external_exports.function(),
|
|
19065
|
-
/** Function to get space info */
|
|
19066
|
-
getInfo: external_exports.function()
|
|
19067
|
-
});
|
|
19068
|
-
SpaceServiceConfigSchema = external_exports.object({
|
|
19069
|
-
/** TinyCloud host URLs */
|
|
19070
|
-
hosts: external_exports.array(external_exports.string()),
|
|
19071
|
-
/** Active session for authentication */
|
|
19072
|
-
session: external_exports.unknown(),
|
|
19073
|
-
/** Platform-specific invoke function */
|
|
19074
|
-
invoke: external_exports.function(),
|
|
19075
|
-
/** Optional custom fetch implementation */
|
|
19076
|
-
fetch: external_exports.function().optional(),
|
|
19077
|
-
/** Optional capability key registry for delegated space discovery */
|
|
19078
|
-
capabilityRegistry: external_exports.unknown().optional(),
|
|
19079
|
-
/** Factory function to create a space-scoped KV service */
|
|
19080
|
-
createKVService: external_exports.function().optional(),
|
|
19081
|
-
/** Factory function to create a space-scoped Data Vault service */
|
|
19082
|
-
createVaultService: external_exports.function().optional(),
|
|
19083
|
-
/** Factory function to create a space-scoped secrets service */
|
|
19084
|
-
createSecretsService: external_exports.function().optional(),
|
|
19085
|
-
/** User's PKH DID (derived from address or provided explicitly) */
|
|
19086
|
-
userDid: external_exports.string().optional(),
|
|
19087
|
-
/** Optional SharingService for v2 sharing links (client-side) */
|
|
19088
|
-
sharingService: external_exports.unknown().optional(),
|
|
19089
|
-
/** Factory function to create delegations using SIWE-based flow */
|
|
19090
|
-
createDelegation: external_exports.function().optional()
|
|
19091
|
-
});
|
|
19092
|
-
SpaceDelegationParamsSchema = CreateDelegationParamsSchema.extend({
|
|
19093
|
-
/** The space ID to create the delegation for */
|
|
19094
|
-
spaceId: external_exports.string()
|
|
19095
|
-
});
|
|
19096
|
-
ServerDelegationInfoSchema = external_exports.object({
|
|
19097
|
-
/** DID of the delegator */
|
|
19098
|
-
delegator: external_exports.string(),
|
|
19099
|
-
/** DID of the delegate */
|
|
19100
|
-
delegate: external_exports.string(),
|
|
19101
|
-
/** Parent delegation CIDs - accepts string or byte array format from server */
|
|
19102
|
-
parents: external_exports.array(external_exports.union([external_exports.string(), external_exports.array(external_exports.number())])),
|
|
19103
|
-
/** Expiration time (ISO8601 string) */
|
|
19104
|
-
expiry: external_exports.string().optional(),
|
|
19105
|
-
/** Not-before time (ISO8601 string) */
|
|
19106
|
-
not_before: external_exports.string().optional(),
|
|
19107
|
-
/** Issued-at time (ISO8601 string) */
|
|
19108
|
-
issued_at: external_exports.string().optional(),
|
|
19109
|
-
/** Capabilities granted by this delegation */
|
|
19110
|
-
capabilities: external_exports.array(
|
|
19111
|
-
external_exports.object({
|
|
19112
|
-
resource: external_exports.string(),
|
|
19113
|
-
ability: external_exports.string()
|
|
19114
|
-
})
|
|
19115
|
-
)
|
|
19116
|
-
});
|
|
19117
|
-
ServerDelegationsResponseSchema = external_exports.record(
|
|
19118
|
-
external_exports.string(),
|
|
19119
|
-
ServerDelegationInfoSchema
|
|
19120
|
-
);
|
|
19121
|
-
ServerOwnedSpaceSchema = external_exports.object({
|
|
19122
|
-
/** Space identifier */
|
|
19123
|
-
id: external_exports.string(),
|
|
19124
|
-
/** Space name (optional, can be derived from id) */
|
|
19125
|
-
name: external_exports.string().optional(),
|
|
19126
|
-
/** Owner DID */
|
|
19127
|
-
owner: external_exports.string(),
|
|
19128
|
-
/** Creation timestamp */
|
|
19129
|
-
createdAt: external_exports.string().optional()
|
|
19130
|
-
});
|
|
19131
|
-
ServerOwnedSpacesResponseSchema = external_exports.array(ServerOwnedSpaceSchema);
|
|
19132
|
-
ServerCreateSpaceResponseSchema = external_exports.object({
|
|
19133
|
-
/** Space identifier */
|
|
19134
|
-
id: external_exports.string(),
|
|
19135
|
-
/** Space name */
|
|
19136
|
-
name: external_exports.string(),
|
|
19137
|
-
/** Owner DID */
|
|
19138
|
-
owner: external_exports.string(),
|
|
19139
|
-
/** Creation timestamp */
|
|
19140
|
-
createdAt: external_exports.string().optional()
|
|
19141
|
-
});
|
|
19142
|
-
ServerSpaceInfoResponseSchema = external_exports.object({
|
|
19143
|
-
/** Space identifier */
|
|
19144
|
-
id: external_exports.string(),
|
|
19145
|
-
/** Space name (optional) */
|
|
19146
|
-
name: external_exports.string().optional(),
|
|
19147
|
-
/** Owner DID */
|
|
19148
|
-
owner: external_exports.string(),
|
|
19149
|
-
/** Ownership type */
|
|
19150
|
-
type: external_exports.enum(["owned", "delegated"]).optional(),
|
|
19151
|
-
/** Permissions the user has in this space */
|
|
19152
|
-
permissions: external_exports.array(external_exports.string()).optional(),
|
|
19153
|
-
/** Expiration for delegated access */
|
|
19154
|
-
expiresAt: external_exports.string().optional()
|
|
19155
|
-
});
|
|
19156
19201
|
EPHEMERAL_MS = 60 * 60 * 1e3;
|
|
19157
19202
|
SIGNED_READ_URL_MS = 5 * 60 * 1e3;
|
|
19158
19203
|
SESSION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
@@ -19168,27 +19213,6 @@ var init_dist3 = __esm({
|
|
|
19168
19213
|
MAX_MS
|
|
19169
19214
|
};
|
|
19170
19215
|
DEFAULT_SIGNED_READ_URL_EXPIRY_MS2 = EXPIRY.SIGNED_READ_URL_MS;
|
|
19171
|
-
DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
19172
|
-
ManifestValidationError = class extends Error {
|
|
19173
|
-
constructor(message) {
|
|
19174
|
-
super(`Manifest validation failed: ${message}`);
|
|
19175
|
-
this.name = "ManifestValidationError";
|
|
19176
|
-
}
|
|
19177
|
-
};
|
|
19178
|
-
SERVICE_SHORT_TO_LONG = Object.freeze({
|
|
19179
|
-
kv: "tinycloud.kv",
|
|
19180
|
-
sql: "tinycloud.sql",
|
|
19181
|
-
duckdb: "tinycloud.duckdb",
|
|
19182
|
-
capabilities: "tinycloud.capabilities",
|
|
19183
|
-
hooks: "tinycloud.hooks",
|
|
19184
|
-
encryption: "tinycloud.encryption",
|
|
19185
|
-
delegation: "tinycloud.delegation"
|
|
19186
|
-
});
|
|
19187
|
-
SERVICE_LONG_TO_SHORT = Object.freeze(
|
|
19188
|
-
Object.fromEntries(
|
|
19189
|
-
Object.entries(SERVICE_SHORT_TO_LONG).map(([s, l]) => [l, s])
|
|
19190
|
-
)
|
|
19191
|
-
);
|
|
19192
19216
|
EncodedShareDataSchema = external_exports.object({
|
|
19193
19217
|
/** Private key in JWK format (must include d parameter) */
|
|
19194
19218
|
key: JWKSchema.refine(
|
|
@@ -19299,7 +19323,346 @@ var init_dist3 = __esm({
|
|
|
19299
19323
|
message: "Expected an onRootDelegationNeeded function or undefined"
|
|
19300
19324
|
}).optional()
|
|
19301
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;
|
|
19302
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
|
+
});
|
|
19303
19666
|
AutoApproveSpaceCreationHandler = class {
|
|
19304
19667
|
/**
|
|
19305
19668
|
* Always returns true to auto-approve space creation.
|
|
@@ -19419,15 +19782,15 @@ var init_dist3 = __esm({
|
|
|
19419
19782
|
CODE_MEMORY = 777;
|
|
19420
19783
|
ip4ToBytes = function(ip) {
|
|
19421
19784
|
ip = ip.toString().trim();
|
|
19422
|
-
const
|
|
19785
|
+
const bytes2 = new Uint8Array(4);
|
|
19423
19786
|
ip.split(/\./g).forEach((byte, index) => {
|
|
19424
19787
|
const value = parseInt(byte, 10);
|
|
19425
19788
|
if (isNaN(value) || value < 0 || value > 255) {
|
|
19426
19789
|
throw new InvalidMultiaddrError("Invalid byte value in IP address");
|
|
19427
19790
|
}
|
|
19428
|
-
|
|
19791
|
+
bytes2[index] = value;
|
|
19429
19792
|
});
|
|
19430
|
-
return
|
|
19793
|
+
return bytes2;
|
|
19431
19794
|
};
|
|
19432
19795
|
ip6ToBytes = function(ip) {
|
|
19433
19796
|
let offset = 0;
|
|
@@ -19462,7 +19825,7 @@ var init_dist3 = __esm({
|
|
|
19462
19825
|
}
|
|
19463
19826
|
sections.splice.apply(sections, argv);
|
|
19464
19827
|
}
|
|
19465
|
-
const
|
|
19828
|
+
const bytes2 = new Uint8Array(offset + 16);
|
|
19466
19829
|
for (i = 0; i < sections.length; i++) {
|
|
19467
19830
|
if (sections[i] === "") {
|
|
19468
19831
|
sections[i] = "0";
|
|
@@ -19471,10 +19834,10 @@ var init_dist3 = __esm({
|
|
|
19471
19834
|
if (isNaN(word2) || word2 < 0 || word2 > 65535) {
|
|
19472
19835
|
throw new InvalidMultiaddrError("Invalid byte value in IP address");
|
|
19473
19836
|
}
|
|
19474
|
-
|
|
19475
|
-
|
|
19837
|
+
bytes2[offset++] = word2 >> 8 & 255;
|
|
19838
|
+
bytes2[offset++] = word2 & 255;
|
|
19476
19839
|
}
|
|
19477
|
-
return
|
|
19840
|
+
return bytes2;
|
|
19478
19841
|
};
|
|
19479
19842
|
ip4ToString = function(buf) {
|
|
19480
19843
|
if (buf.byteLength !== 4) {
|
|
@@ -19537,8 +19900,8 @@ var init_dist3 = __esm({
|
|
|
19537
19900
|
this.protocolsByName.set(alias, codec);
|
|
19538
19901
|
});
|
|
19539
19902
|
}
|
|
19540
|
-
removeProtocol(
|
|
19541
|
-
const codec = this.protocolsByCode.get(
|
|
19903
|
+
removeProtocol(code3) {
|
|
19904
|
+
const codec = this.protocolsByCode.get(code3);
|
|
19542
19905
|
if (codec == null) {
|
|
19543
19906
|
return;
|
|
19544
19907
|
}
|
|
@@ -19796,10 +20159,10 @@ var init_dist3 = __esm({
|
|
|
19796
20159
|
validate: false
|
|
19797
20160
|
});
|
|
19798
20161
|
}
|
|
19799
|
-
decapsulateCode(
|
|
20162
|
+
decapsulateCode(code3) {
|
|
19800
20163
|
let index;
|
|
19801
20164
|
for (let i = __privateGet(this, _components).length - 1; i > -1; i--) {
|
|
19802
|
-
if (__privateGet(this, _components)[i].code ===
|
|
20165
|
+
if (__privateGet(this, _components)[i].code === code3) {
|
|
19803
20166
|
index = i;
|
|
19804
20167
|
break;
|
|
19805
20168
|
}
|
|
@@ -23025,7 +23388,7 @@ function execCapturedCommand(command) {
|
|
|
23025
23388
|
stdio: "inherit"
|
|
23026
23389
|
});
|
|
23027
23390
|
child.on("error", reject);
|
|
23028
|
-
child.on("exit", (
|
|
23391
|
+
child.on("exit", (code, signal) => {
|
|
23029
23392
|
if (signal) {
|
|
23030
23393
|
reject(new CLIError(
|
|
23031
23394
|
"COMMAND_SIGNAL",
|
|
@@ -23034,8 +23397,8 @@ function execCapturedCommand(command) {
|
|
|
23034
23397
|
));
|
|
23035
23398
|
return;
|
|
23036
23399
|
}
|
|
23037
|
-
if (
|
|
23038
|
-
process.exitCode =
|
|
23400
|
+
if (code && code !== 0) {
|
|
23401
|
+
process.exitCode = code;
|
|
23039
23402
|
}
|
|
23040
23403
|
resolve3();
|
|
23041
23404
|
});
|
|
@@ -24935,8 +25298,8 @@ function shouldRequestSecretPermissions(error) {
|
|
|
24935
25298
|
function thrownPermissionError(error) {
|
|
24936
25299
|
const record = error;
|
|
24937
25300
|
const message = typeof record?.message === "string" ? record.message : String(error);
|
|
24938
|
-
const
|
|
24939
|
-
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)) {
|
|
24940
25303
|
return null;
|
|
24941
25304
|
}
|
|
24942
25305
|
return {
|
|
@@ -25144,9 +25507,9 @@ async function resolveDelegatedSecretSource(source, secretPath, space = SECRETS_
|
|
|
25144
25507
|
return { ...selected, source };
|
|
25145
25508
|
}
|
|
25146
25509
|
function mapEncryptionResultError(error) {
|
|
25147
|
-
const
|
|
25148
|
-
const exitCode =
|
|
25149
|
-
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);
|
|
25150
25513
|
}
|
|
25151
25514
|
function parseDecryptedSecretPayload(data, secretPath) {
|
|
25152
25515
|
const text = new TextDecoder().decode(data);
|