@tinycloud/cli 0.9.0-beta.6 → 0.9.0-beta.8
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 +270 -101
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +251 -48
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -10398,41 +10398,41 @@ var require_ms = __commonJS({
|
|
|
10398
10398
|
return void 0;
|
|
10399
10399
|
}
|
|
10400
10400
|
}
|
|
10401
|
-
function fmtShort(
|
|
10402
|
-
var msAbs = Math.abs(
|
|
10401
|
+
function fmtShort(ms2) {
|
|
10402
|
+
var msAbs = Math.abs(ms2);
|
|
10403
10403
|
if (msAbs >= d) {
|
|
10404
|
-
return Math.round(
|
|
10404
|
+
return Math.round(ms2 / d) + "d";
|
|
10405
10405
|
}
|
|
10406
10406
|
if (msAbs >= h) {
|
|
10407
|
-
return Math.round(
|
|
10407
|
+
return Math.round(ms2 / h) + "h";
|
|
10408
10408
|
}
|
|
10409
10409
|
if (msAbs >= m) {
|
|
10410
|
-
return Math.round(
|
|
10410
|
+
return Math.round(ms2 / m) + "m";
|
|
10411
10411
|
}
|
|
10412
10412
|
if (msAbs >= s) {
|
|
10413
|
-
return Math.round(
|
|
10413
|
+
return Math.round(ms2 / s) + "s";
|
|
10414
10414
|
}
|
|
10415
|
-
return
|
|
10415
|
+
return ms2 + "ms";
|
|
10416
10416
|
}
|
|
10417
|
-
function fmtLong(
|
|
10418
|
-
var msAbs = Math.abs(
|
|
10417
|
+
function fmtLong(ms2) {
|
|
10418
|
+
var msAbs = Math.abs(ms2);
|
|
10419
10419
|
if (msAbs >= d) {
|
|
10420
|
-
return plural(
|
|
10420
|
+
return plural(ms2, msAbs, d, "day");
|
|
10421
10421
|
}
|
|
10422
10422
|
if (msAbs >= h) {
|
|
10423
|
-
return plural(
|
|
10423
|
+
return plural(ms2, msAbs, h, "hour");
|
|
10424
10424
|
}
|
|
10425
10425
|
if (msAbs >= m) {
|
|
10426
|
-
return plural(
|
|
10426
|
+
return plural(ms2, msAbs, m, "minute");
|
|
10427
10427
|
}
|
|
10428
10428
|
if (msAbs >= s) {
|
|
10429
|
-
return plural(
|
|
10429
|
+
return plural(ms2, msAbs, s, "second");
|
|
10430
10430
|
}
|
|
10431
|
-
return
|
|
10431
|
+
return ms2 + " ms";
|
|
10432
10432
|
}
|
|
10433
|
-
function plural(
|
|
10433
|
+
function plural(ms2, msAbs, n, name2) {
|
|
10434
10434
|
var isPlural = msAbs >= n * 1.5;
|
|
10435
|
-
return Math.round(
|
|
10435
|
+
return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
|
|
10436
10436
|
}
|
|
10437
10437
|
}
|
|
10438
10438
|
});
|
|
@@ -10460,10 +10460,10 @@ var require_decrypt_transport_response_error = __commonJS({
|
|
|
10460
10460
|
var __toCommonJS = (mod3) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod3);
|
|
10461
10461
|
var DecryptTransportResponseError_exports = {};
|
|
10462
10462
|
__export4(DecryptTransportResponseError_exports, {
|
|
10463
|
-
DecryptTransportResponseError: () =>
|
|
10463
|
+
DecryptTransportResponseError: () => DecryptTransportResponseError2
|
|
10464
10464
|
});
|
|
10465
10465
|
module.exports = __toCommonJS(DecryptTransportResponseError_exports);
|
|
10466
|
-
var
|
|
10466
|
+
var DecryptTransportResponseError2 = class extends Error {
|
|
10467
10467
|
constructor(status, permissionHint) {
|
|
10468
10468
|
super("Node decrypt request failed");
|
|
10469
10469
|
this.status = status;
|
|
@@ -11675,16 +11675,16 @@ function ensureNetworkUsableForDecrypt(descriptor) {
|
|
|
11675
11675
|
})
|
|
11676
11676
|
};
|
|
11677
11677
|
}
|
|
11678
|
-
function encryptToNetwork(
|
|
11678
|
+
function encryptToNetwork(crypto22, input) {
|
|
11679
11679
|
parseNetworkId(input.networkId);
|
|
11680
11680
|
const alg = input.alg ?? DEFAULT_ENCRYPTION_ALG;
|
|
11681
11681
|
const keyVersion = input.keyVersion ?? DEFAULT_KEY_VERSION;
|
|
11682
|
-
const symmetricKey =
|
|
11683
|
-
const ciphertext =
|
|
11684
|
-
const wrapped =
|
|
11682
|
+
const symmetricKey = crypto22.randomBytes(32);
|
|
11683
|
+
const ciphertext = crypto22.authEncrypt(symmetricKey, input.plaintext, input.aad);
|
|
11684
|
+
const wrapped = crypto22.sealToNetworkKey(input.networkPublicKey, symmetricKey);
|
|
11685
11685
|
const encryptedSymmetricKey = base64Encode2(wrapped);
|
|
11686
11686
|
const encryptedSymmetricKeyHash = canonicalHashHex(
|
|
11687
|
-
|
|
11687
|
+
crypto22.sha256,
|
|
11688
11688
|
encryptedSymmetricKey
|
|
11689
11689
|
);
|
|
11690
11690
|
const envelope = {
|
|
@@ -11700,7 +11700,7 @@ function encryptToNetwork(crypto23, input) {
|
|
|
11700
11700
|
};
|
|
11701
11701
|
return { envelope, symmetricKey };
|
|
11702
11702
|
}
|
|
11703
|
-
function validateEnvelope(
|
|
11703
|
+
function validateEnvelope(crypto22, envelope) {
|
|
11704
11704
|
if (envelope === null || typeof envelope !== "object") {
|
|
11705
11705
|
return {
|
|
11706
11706
|
ok: false,
|
|
@@ -11756,7 +11756,7 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11756
11756
|
})
|
|
11757
11757
|
};
|
|
11758
11758
|
}
|
|
11759
|
-
const expectedHash = canonicalHashHex(
|
|
11759
|
+
const expectedHash = canonicalHashHex(crypto22.sha256, e.encryptedSymmetricKey);
|
|
11760
11760
|
if (expectedHash !== e.encryptedSymmetricKeyHash) {
|
|
11761
11761
|
return {
|
|
11762
11762
|
ok: false,
|
|
@@ -11768,10 +11768,10 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11768
11768
|
}
|
|
11769
11769
|
return { ok: true, data: e };
|
|
11770
11770
|
}
|
|
11771
|
-
function decryptEnvelopeWithKey(
|
|
11771
|
+
function decryptEnvelopeWithKey(crypto22, envelope, symmetricKey) {
|
|
11772
11772
|
const ciphertext = base64Decode2(envelope.ciphertext);
|
|
11773
11773
|
const aad = envelope.aad !== void 0 ? base64Decode2(envelope.aad) : void 0;
|
|
11774
|
-
return
|
|
11774
|
+
return crypto22.authDecrypt(symmetricKey, ciphertext, aad);
|
|
11775
11775
|
}
|
|
11776
11776
|
function buildCanonicalDecryptRequest(input) {
|
|
11777
11777
|
const canonicalBody = canonicalize(input.body);
|
|
@@ -11805,7 +11805,7 @@ function buildDecryptFacts(input) {
|
|
|
11805
11805
|
keyVersion: input.body.keyVersion
|
|
11806
11806
|
};
|
|
11807
11807
|
}
|
|
11808
|
-
function checkDecryptInvocationInput(
|
|
11808
|
+
function checkDecryptInvocationInput(crypto22, input) {
|
|
11809
11809
|
if (input.body.type !== DECRYPT_FACT_TYPE) {
|
|
11810
11810
|
return {
|
|
11811
11811
|
ok: false,
|
|
@@ -11910,7 +11910,7 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
11910
11910
|
const canonicalBody = canonicalize(
|
|
11911
11911
|
input.body
|
|
11912
11912
|
);
|
|
11913
|
-
const expectedBodyHash = canonicalHashHex(
|
|
11913
|
+
const expectedBodyHash = canonicalHashHex(crypto22.sha256, input.body);
|
|
11914
11914
|
if (expectedBodyHash !== input.facts.bodyHash) {
|
|
11915
11915
|
return {
|
|
11916
11916
|
ok: false,
|
|
@@ -11922,8 +11922,8 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
11922
11922
|
}
|
|
11923
11923
|
return { ok: true, data: input, canonicalBody };
|
|
11924
11924
|
}
|
|
11925
|
-
async function buildDecryptInvocation(
|
|
11926
|
-
const checked = checkDecryptInvocationInput(
|
|
11925
|
+
async function buildDecryptInvocation(crypto22, signer, input) {
|
|
11926
|
+
const checked = checkDecryptInvocationInput(crypto22, input);
|
|
11927
11927
|
if (!checked.ok) {
|
|
11928
11928
|
return checked;
|
|
11929
11929
|
}
|
|
@@ -11968,7 +11968,7 @@ function canonicalSignedResponse(response) {
|
|
|
11968
11968
|
return canonicalize(rest);
|
|
11969
11969
|
}
|
|
11970
11970
|
function verifyDecryptResponse(input) {
|
|
11971
|
-
const { crypto:
|
|
11971
|
+
const { crypto: crypto22, request, facts, invocationCid, requestBodyHash, response } = input;
|
|
11972
11972
|
if (response.type !== DECRYPT_RESULT_TYPE) {
|
|
11973
11973
|
return {
|
|
11974
11974
|
ok: false,
|
|
@@ -12051,7 +12051,7 @@ function verifyDecryptResponse(input) {
|
|
|
12051
12051
|
};
|
|
12052
12052
|
}
|
|
12053
12053
|
const expectedRequestHash = hexEncode2(
|
|
12054
|
-
|
|
12054
|
+
crypto22.sha256(utf8Encode(`${invocationCid}${requestBodyHash}`))
|
|
12055
12055
|
);
|
|
12056
12056
|
if (response.requestHash !== expectedRequestHash) {
|
|
12057
12057
|
return {
|
|
@@ -12075,7 +12075,7 @@ function verifyDecryptResponse(input) {
|
|
|
12075
12075
|
canonicalSignedResponse(response)
|
|
12076
12076
|
);
|
|
12077
12077
|
const signatureBytes = base64Decode2(response.nodeSignature);
|
|
12078
|
-
if (!
|
|
12078
|
+
if (!crypto22.verifyNodeSignature(response.nodeId, signedBytes, signatureBytes)) {
|
|
12079
12079
|
return {
|
|
12080
12080
|
ok: false,
|
|
12081
12081
|
error: encryptionError({
|
|
@@ -12085,9 +12085,9 @@ function verifyDecryptResponse(input) {
|
|
|
12085
12085
|
}
|
|
12086
12086
|
return { ok: true, data: response };
|
|
12087
12087
|
}
|
|
12088
|
-
function openWrappedKey(
|
|
12088
|
+
function openWrappedKey(crypto22, receiverPrivateKey, response) {
|
|
12089
12089
|
const wrapped = base64Decode2(response.wrappedKey);
|
|
12090
|
-
return
|
|
12090
|
+
return crypto22.openWithReceiverKey(receiverPrivateKey, wrapped);
|
|
12091
12091
|
}
|
|
12092
12092
|
function encOk(data) {
|
|
12093
12093
|
return { ok: true, data };
|
|
@@ -12095,7 +12095,7 @@ function encOk(data) {
|
|
|
12095
12095
|
function encErr(error) {
|
|
12096
12096
|
return { ok: false, error };
|
|
12097
12097
|
}
|
|
12098
|
-
var import_decrypt_transport_response_error,
|
|
12098
|
+
var import_decrypt_transport_response_error, 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, 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;
|
|
12099
12099
|
var init_dist2 = __esm({
|
|
12100
12100
|
"../sdk-services/dist/index.js"() {
|
|
12101
12101
|
"use strict";
|
|
@@ -12103,8 +12103,6 @@ var init_dist2 = __esm({
|
|
|
12103
12103
|
init_dist();
|
|
12104
12104
|
init_dist();
|
|
12105
12105
|
import_decrypt_transport_response_error = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12106
|
-
import_decrypt_transport_response_error2 = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12107
|
-
import_decrypt_transport_response_error3 = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12108
12106
|
ErrorCodes = {
|
|
12109
12107
|
// Common errors
|
|
12110
12108
|
NOT_FOUND: "NOT_FOUND",
|
|
@@ -24689,12 +24687,6 @@ var init_dist3 = __esm({
|
|
|
24689
24687
|
|
|
24690
24688
|
// ../sdk-core/dist/index.js
|
|
24691
24689
|
import { SiweMessage } from "siwe";
|
|
24692
|
-
import crypto22 from "crypto";
|
|
24693
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
24694
|
-
import { Buffer as Buffer3 } from "buffer";
|
|
24695
|
-
import { Buffer as Buffer4 } from "buffer";
|
|
24696
|
-
import { Buffer as Buffer5 } from "buffer";
|
|
24697
|
-
import { isIPv4, isIPv6, isIP as ipVersion } from "net";
|
|
24698
24690
|
function equals5(aa, bb) {
|
|
24699
24691
|
if (aa === bb) {
|
|
24700
24692
|
return true;
|
|
@@ -25139,6 +25131,9 @@ function createDigest(digest4, code32, truncate) {
|
|
|
25139
25131
|
}
|
|
25140
25132
|
return create3(code32, digest4);
|
|
25141
25133
|
}
|
|
25134
|
+
function sha(name2) {
|
|
25135
|
+
return async (data) => new Uint8Array(await crypto.subtle.digest(name2, data));
|
|
25136
|
+
}
|
|
25142
25137
|
function parseStrictRfc33392(value) {
|
|
25143
25138
|
if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
|
|
25144
25139
|
value
|
|
@@ -25237,11 +25232,8 @@ function equals32(a, b) {
|
|
|
25237
25232
|
}
|
|
25238
25233
|
return true;
|
|
25239
25234
|
}
|
|
25240
|
-
function asUint8Array(buf) {
|
|
25241
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
25242
|
-
}
|
|
25243
25235
|
function allocUnsafe(size2 = 0) {
|
|
25244
|
-
return
|
|
25236
|
+
return new Uint8Array(size2);
|
|
25245
25237
|
}
|
|
25246
25238
|
function encodingLength22(value) {
|
|
25247
25239
|
if (value < N122) {
|
|
@@ -25405,8 +25397,20 @@ function decode62(buf, offset = 0) {
|
|
|
25405
25397
|
return decodeUint8ArrayList(buf, offset);
|
|
25406
25398
|
}
|
|
25407
25399
|
}
|
|
25400
|
+
function asUint8Array(buf) {
|
|
25401
|
+
return buf;
|
|
25402
|
+
}
|
|
25408
25403
|
function concat2(arrays, length22) {
|
|
25409
|
-
|
|
25404
|
+
if (length22 == null) {
|
|
25405
|
+
length22 = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
|
25406
|
+
}
|
|
25407
|
+
const output = allocUnsafe(length22);
|
|
25408
|
+
let offset = 0;
|
|
25409
|
+
for (const arr of arrays) {
|
|
25410
|
+
output.set(arr, offset);
|
|
25411
|
+
offset += arr.length;
|
|
25412
|
+
}
|
|
25413
|
+
return asUint8Array(output);
|
|
25410
25414
|
}
|
|
25411
25415
|
function createCodec(name2, prefix, encode52, decode72) {
|
|
25412
25416
|
return {
|
|
@@ -25427,9 +25431,6 @@ function fromString2(string2, encoding = "utf8") {
|
|
|
25427
25431
|
if (base33 == null) {
|
|
25428
25432
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
25429
25433
|
}
|
|
25430
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
25431
|
-
return asUint8Array(Buffer4.from(string2, "utf-8"));
|
|
25432
|
-
}
|
|
25433
25434
|
return base33.decoder.decode(`${base33.prefix}${string2}`);
|
|
25434
25435
|
}
|
|
25435
25436
|
function toString2(array, encoding = "utf8") {
|
|
@@ -25437,11 +25438,29 @@ function toString2(array, encoding = "utf8") {
|
|
|
25437
25438
|
if (base33 == null) {
|
|
25438
25439
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
25439
25440
|
}
|
|
25440
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
25441
|
-
return Buffer5.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8");
|
|
25442
|
-
}
|
|
25443
25441
|
return base33.encoder.encode(array).substring(1);
|
|
25444
25442
|
}
|
|
25443
|
+
function parseIPv4(input) {
|
|
25444
|
+
if (input.length > MAX_IPV4_LENGTH) {
|
|
25445
|
+
return void 0;
|
|
25446
|
+
}
|
|
25447
|
+
return parser.new(input).parseWith(() => parser.readIPv4Addr());
|
|
25448
|
+
}
|
|
25449
|
+
function parseIPv6(input) {
|
|
25450
|
+
if (input.includes("%")) {
|
|
25451
|
+
input = input.split("%")[0];
|
|
25452
|
+
}
|
|
25453
|
+
if (input.length > MAX_IPV6_LENGTH) {
|
|
25454
|
+
return void 0;
|
|
25455
|
+
}
|
|
25456
|
+
return parser.new(input).parseWith(() => parser.readIPv6Addr());
|
|
25457
|
+
}
|
|
25458
|
+
function isIPv4(input) {
|
|
25459
|
+
return Boolean(parseIPv4(input));
|
|
25460
|
+
}
|
|
25461
|
+
function isIPv6(input) {
|
|
25462
|
+
return Boolean(parseIPv6(input));
|
|
25463
|
+
}
|
|
25445
25464
|
function bytesToString(base33) {
|
|
25446
25465
|
return (buf) => {
|
|
25447
25466
|
return toString2(buf, base33);
|
|
@@ -26137,7 +26156,7 @@ function decodeBase64Url(value) {
|
|
|
26137
26156
|
}
|
|
26138
26157
|
return Uint8Array.from(bytes22);
|
|
26139
26158
|
}
|
|
26140
|
-
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code22, name, encode42, identity2,
|
|
26159
|
+
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, objectHasOwn, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code22, name, encode42, identity2, sha2_browser_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha25622, 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, 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_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, inFlightActivations, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N122, N222, N322, N422, N522, N622, N722, MSB22, REST22, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, Parser, MAX_IPV6_LENGTH, MAX_IPV4_LENGTH, parser, 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, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
|
|
26141
26160
|
var init_dist4 = __esm({
|
|
26142
26161
|
"../sdk-core/dist/index.js"() {
|
|
26143
26162
|
"use strict";
|
|
@@ -26156,10 +26175,8 @@ var init_dist4 = __esm({
|
|
|
26156
26175
|
init_dist2();
|
|
26157
26176
|
init_zod();
|
|
26158
26177
|
init_dist2();
|
|
26159
|
-
init_dist();
|
|
26160
26178
|
init_dist2();
|
|
26161
26179
|
init_dist2();
|
|
26162
|
-
init_dist();
|
|
26163
26180
|
init_ed25519();
|
|
26164
26181
|
init_esm();
|
|
26165
26182
|
__defProp3 = Object.defineProperty;
|
|
@@ -26823,8 +26840,8 @@ var init_dist4 = __esm({
|
|
|
26823
26840
|
name = "identity";
|
|
26824
26841
|
encode42 = coerce4;
|
|
26825
26842
|
identity2 = { code: code22, name, encode: encode42, digest: digest2 };
|
|
26826
|
-
|
|
26827
|
-
__export3(
|
|
26843
|
+
sha2_browser_exports = {};
|
|
26844
|
+
__export3(sha2_browser_exports, {
|
|
26828
26845
|
sha256: () => sha25622,
|
|
26829
26846
|
sha512: () => sha5122
|
|
26830
26847
|
});
|
|
@@ -26865,15 +26882,15 @@ var init_dist4 = __esm({
|
|
|
26865
26882
|
sha25622 = from22({
|
|
26866
26883
|
name: "sha2-256",
|
|
26867
26884
|
code: 18,
|
|
26868
|
-
encode: (
|
|
26885
|
+
encode: sha("SHA-256")
|
|
26869
26886
|
});
|
|
26870
26887
|
sha5122 = from22({
|
|
26871
26888
|
name: "sha2-512",
|
|
26872
26889
|
code: 19,
|
|
26873
|
-
encode: (
|
|
26890
|
+
encode: sha("SHA-512")
|
|
26874
26891
|
});
|
|
26875
26892
|
bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
|
|
26876
|
-
hashes = { ...
|
|
26893
|
+
hashes = { ...sha2_browser_exports, ...identity_exports2 };
|
|
26877
26894
|
textEncoder3 = new TextEncoder();
|
|
26878
26895
|
objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
|
|
26879
26896
|
Object.prototype.hasOwnProperty
|
|
@@ -27982,6 +27999,192 @@ var init_dist4 = __esm({
|
|
|
27982
27999
|
}
|
|
27983
28000
|
};
|
|
27984
28001
|
__publicField(UnknownProtocolError, "name", "UnknownProtocolError");
|
|
28002
|
+
Parser = class {
|
|
28003
|
+
constructor() {
|
|
28004
|
+
__publicField(this, "index", 0);
|
|
28005
|
+
__publicField(this, "input", "");
|
|
28006
|
+
}
|
|
28007
|
+
new(input) {
|
|
28008
|
+
this.index = 0;
|
|
28009
|
+
this.input = input;
|
|
28010
|
+
return this;
|
|
28011
|
+
}
|
|
28012
|
+
/** Run a parser, and restore the pre-parse state if it fails. */
|
|
28013
|
+
readAtomically(fn) {
|
|
28014
|
+
const index = this.index;
|
|
28015
|
+
const result = fn();
|
|
28016
|
+
if (result === void 0) {
|
|
28017
|
+
this.index = index;
|
|
28018
|
+
}
|
|
28019
|
+
return result;
|
|
28020
|
+
}
|
|
28021
|
+
/** Run a parser, but fail if the entire input wasn't consumed. Doesn't run atomically. */
|
|
28022
|
+
parseWith(fn) {
|
|
28023
|
+
const result = fn();
|
|
28024
|
+
if (this.index !== this.input.length) {
|
|
28025
|
+
return void 0;
|
|
28026
|
+
}
|
|
28027
|
+
return result;
|
|
28028
|
+
}
|
|
28029
|
+
/** Peek the next character from the input */
|
|
28030
|
+
peekChar() {
|
|
28031
|
+
if (this.index >= this.input.length) {
|
|
28032
|
+
return void 0;
|
|
28033
|
+
}
|
|
28034
|
+
return this.input[this.index];
|
|
28035
|
+
}
|
|
28036
|
+
/** Read the next character from the input */
|
|
28037
|
+
readChar() {
|
|
28038
|
+
if (this.index >= this.input.length) {
|
|
28039
|
+
return void 0;
|
|
28040
|
+
}
|
|
28041
|
+
return this.input[this.index++];
|
|
28042
|
+
}
|
|
28043
|
+
/** Read the next character from the input if it matches the target. */
|
|
28044
|
+
readGivenChar(target) {
|
|
28045
|
+
return this.readAtomically(() => {
|
|
28046
|
+
const char = this.readChar();
|
|
28047
|
+
if (char !== target) {
|
|
28048
|
+
return void 0;
|
|
28049
|
+
}
|
|
28050
|
+
return char;
|
|
28051
|
+
});
|
|
28052
|
+
}
|
|
28053
|
+
/**
|
|
28054
|
+
* Helper for reading separators in an indexed loop. Reads the separator
|
|
28055
|
+
* character iff index > 0, then runs the parser. When used in a loop,
|
|
28056
|
+
* the separator character will only be read on index > 0 (see
|
|
28057
|
+
* readIPv4Addr for an example)
|
|
28058
|
+
*/
|
|
28059
|
+
readSeparator(sep2, index, inner) {
|
|
28060
|
+
return this.readAtomically(() => {
|
|
28061
|
+
if (index > 0) {
|
|
28062
|
+
if (this.readGivenChar(sep2) === void 0) {
|
|
28063
|
+
return void 0;
|
|
28064
|
+
}
|
|
28065
|
+
}
|
|
28066
|
+
return inner();
|
|
28067
|
+
});
|
|
28068
|
+
}
|
|
28069
|
+
/**
|
|
28070
|
+
* Read a number off the front of the input in the given radix, stopping
|
|
28071
|
+
* at the first non-digit character or eof. Fails if the number has more
|
|
28072
|
+
* digits than max_digits or if there is no number.
|
|
28073
|
+
*/
|
|
28074
|
+
readNumber(radix, maxDigits, allowZeroPrefix, maxBytes) {
|
|
28075
|
+
return this.readAtomically(() => {
|
|
28076
|
+
let result = 0;
|
|
28077
|
+
let digitCount = 0;
|
|
28078
|
+
const leadingChar = this.peekChar();
|
|
28079
|
+
if (leadingChar === void 0) {
|
|
28080
|
+
return void 0;
|
|
28081
|
+
}
|
|
28082
|
+
const hasLeadingZero = leadingChar === "0";
|
|
28083
|
+
const maxValue2 = 2 ** (8 * maxBytes) - 1;
|
|
28084
|
+
while (true) {
|
|
28085
|
+
const digit = this.readAtomically(() => {
|
|
28086
|
+
const char = this.readChar();
|
|
28087
|
+
if (char === void 0) {
|
|
28088
|
+
return void 0;
|
|
28089
|
+
}
|
|
28090
|
+
const num2 = Number.parseInt(char, radix);
|
|
28091
|
+
if (Number.isNaN(num2)) {
|
|
28092
|
+
return void 0;
|
|
28093
|
+
}
|
|
28094
|
+
return num2;
|
|
28095
|
+
});
|
|
28096
|
+
if (digit === void 0) {
|
|
28097
|
+
break;
|
|
28098
|
+
}
|
|
28099
|
+
result *= radix;
|
|
28100
|
+
result += digit;
|
|
28101
|
+
if (result > maxValue2) {
|
|
28102
|
+
return void 0;
|
|
28103
|
+
}
|
|
28104
|
+
digitCount += 1;
|
|
28105
|
+
if (maxDigits !== void 0) {
|
|
28106
|
+
if (digitCount > maxDigits) {
|
|
28107
|
+
return void 0;
|
|
28108
|
+
}
|
|
28109
|
+
}
|
|
28110
|
+
}
|
|
28111
|
+
if (digitCount === 0) {
|
|
28112
|
+
return void 0;
|
|
28113
|
+
} else if (!allowZeroPrefix && hasLeadingZero && digitCount > 1) {
|
|
28114
|
+
return void 0;
|
|
28115
|
+
} else {
|
|
28116
|
+
return result;
|
|
28117
|
+
}
|
|
28118
|
+
});
|
|
28119
|
+
}
|
|
28120
|
+
/** Read an IPv4 address. */
|
|
28121
|
+
readIPv4Addr() {
|
|
28122
|
+
return this.readAtomically(() => {
|
|
28123
|
+
const out = new Uint8Array(4);
|
|
28124
|
+
for (let i = 0; i < out.length; i++) {
|
|
28125
|
+
const ix = this.readSeparator(".", i, () => this.readNumber(10, 3, false, 1));
|
|
28126
|
+
if (ix === void 0) {
|
|
28127
|
+
return void 0;
|
|
28128
|
+
}
|
|
28129
|
+
out[i] = ix;
|
|
28130
|
+
}
|
|
28131
|
+
return out;
|
|
28132
|
+
});
|
|
28133
|
+
}
|
|
28134
|
+
/** Read an IPv6 Address. */
|
|
28135
|
+
readIPv6Addr() {
|
|
28136
|
+
const readGroups = (groups) => {
|
|
28137
|
+
for (let i = 0; i < groups.length / 2; i++) {
|
|
28138
|
+
const ix = i * 2;
|
|
28139
|
+
if (i < groups.length - 3) {
|
|
28140
|
+
const ipv4 = this.readSeparator(":", i, () => this.readIPv4Addr());
|
|
28141
|
+
if (ipv4 !== void 0) {
|
|
28142
|
+
groups[ix] = ipv4[0];
|
|
28143
|
+
groups[ix + 1] = ipv4[1];
|
|
28144
|
+
groups[ix + 2] = ipv4[2];
|
|
28145
|
+
groups[ix + 3] = ipv4[3];
|
|
28146
|
+
return [ix + 4, true];
|
|
28147
|
+
}
|
|
28148
|
+
}
|
|
28149
|
+
const group = this.readSeparator(":", i, () => this.readNumber(16, 4, true, 2));
|
|
28150
|
+
if (group === void 0) {
|
|
28151
|
+
return [ix, false];
|
|
28152
|
+
}
|
|
28153
|
+
groups[ix] = group >> 8;
|
|
28154
|
+
groups[ix + 1] = group & 255;
|
|
28155
|
+
}
|
|
28156
|
+
return [groups.length, false];
|
|
28157
|
+
};
|
|
28158
|
+
return this.readAtomically(() => {
|
|
28159
|
+
const head = new Uint8Array(16);
|
|
28160
|
+
const [headSize, headIp4] = readGroups(head);
|
|
28161
|
+
if (headSize === 16) {
|
|
28162
|
+
return head;
|
|
28163
|
+
}
|
|
28164
|
+
if (headIp4) {
|
|
28165
|
+
return void 0;
|
|
28166
|
+
}
|
|
28167
|
+
if (this.readGivenChar(":") === void 0) {
|
|
28168
|
+
return void 0;
|
|
28169
|
+
}
|
|
28170
|
+
if (this.readGivenChar(":") === void 0) {
|
|
28171
|
+
return void 0;
|
|
28172
|
+
}
|
|
28173
|
+
const tail = new Uint8Array(14);
|
|
28174
|
+
const limit = 16 - (headSize + 2);
|
|
28175
|
+
const [tailSize] = readGroups(tail.subarray(0, limit));
|
|
28176
|
+
head.set(tail.subarray(0, tailSize), 16 - tailSize);
|
|
28177
|
+
return head;
|
|
28178
|
+
});
|
|
28179
|
+
}
|
|
28180
|
+
/** Read an IP Address, either IPv4 or IPv6. */
|
|
28181
|
+
readIPAddr() {
|
|
28182
|
+
return this.readIPv4Addr() ?? this.readIPv6Addr();
|
|
28183
|
+
}
|
|
28184
|
+
};
|
|
28185
|
+
MAX_IPV6_LENGTH = 45;
|
|
28186
|
+
MAX_IPV4_LENGTH = 15;
|
|
28187
|
+
parser = new Parser();
|
|
27985
28188
|
CODE_IP4 = 4;
|
|
27986
28189
|
CODE_TCP = 6;
|
|
27987
28190
|
CODE_UDP = 273;
|
|
@@ -29009,38 +29212,6 @@ var init_profiles = __esm({
|
|
|
29009
29212
|
}
|
|
29010
29213
|
});
|
|
29011
29214
|
|
|
29012
|
-
// ../sdk-core/src/manifest.ts
|
|
29013
|
-
var import_ms2, SERVICE_SHORT_TO_LONG2, SERVICE_LONG_TO_SHORT2;
|
|
29014
|
-
var init_manifest = __esm({
|
|
29015
|
-
"../sdk-core/src/manifest.ts"() {
|
|
29016
|
-
"use strict";
|
|
29017
|
-
import_ms2 = __toESM(require_ms(), 1);
|
|
29018
|
-
init_dist2();
|
|
29019
|
-
SERVICE_SHORT_TO_LONG2 = Object.freeze({
|
|
29020
|
-
kv: "tinycloud.kv",
|
|
29021
|
-
sql: "tinycloud.sql",
|
|
29022
|
-
duckdb: "tinycloud.duckdb",
|
|
29023
|
-
capabilities: "tinycloud.capabilities",
|
|
29024
|
-
hooks: "tinycloud.hooks",
|
|
29025
|
-
encryption: "tinycloud.encryption",
|
|
29026
|
-
delegation: "tinycloud.delegation"
|
|
29027
|
-
});
|
|
29028
|
-
SERVICE_LONG_TO_SHORT2 = Object.freeze(
|
|
29029
|
-
Object.fromEntries(
|
|
29030
|
-
Object.entries(SERVICE_SHORT_TO_LONG2).map(([s, l]) => [l, s])
|
|
29031
|
-
)
|
|
29032
|
-
);
|
|
29033
|
-
}
|
|
29034
|
-
});
|
|
29035
|
-
|
|
29036
|
-
// ../sdk-core/src/capabilities.ts
|
|
29037
|
-
var init_capabilities = __esm({
|
|
29038
|
-
"../sdk-core/src/capabilities.ts"() {
|
|
29039
|
-
"use strict";
|
|
29040
|
-
init_manifest();
|
|
29041
|
-
}
|
|
29042
|
-
});
|
|
29043
|
-
|
|
29044
29215
|
// src/lib/permissions.ts
|
|
29045
29216
|
import { appendFile, readFile as readFile4 } from "fs/promises";
|
|
29046
29217
|
import { join as join5 } from "path";
|
|
@@ -29079,8 +29250,6 @@ async function replayAdditionalDelegations(node, profile) {
|
|
|
29079
29250
|
var init_permissions = __esm({
|
|
29080
29251
|
"src/lib/permissions.ts"() {
|
|
29081
29252
|
"use strict";
|
|
29082
|
-
init_manifest();
|
|
29083
|
-
init_capabilities();
|
|
29084
29253
|
init_constants();
|
|
29085
29254
|
init_storage();
|
|
29086
29255
|
init_profiles();
|
|
@@ -29370,11 +29539,11 @@ function parseDuration(input) {
|
|
|
29370
29539
|
}
|
|
29371
29540
|
const date = new Date(input);
|
|
29372
29541
|
if (!isNaN(date.getTime())) {
|
|
29373
|
-
const
|
|
29374
|
-
if (
|
|
29542
|
+
const ms2 = date.getTime() - Date.now();
|
|
29543
|
+
if (ms2 <= 0) {
|
|
29375
29544
|
throw new Error(`Expiry date "${input}" is in the past`);
|
|
29376
29545
|
}
|
|
29377
|
-
return
|
|
29546
|
+
return ms2;
|
|
29378
29547
|
}
|
|
29379
29548
|
throw new Error(`Invalid duration: "${input}". Use format like "1h", "7d", or an ISO date.`);
|
|
29380
29549
|
}
|