@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/legacy-entry.js
CHANGED
|
@@ -10512,10 +10512,10 @@ var require_decrypt_transport_response_error = __commonJS({
|
|
|
10512
10512
|
var __toCommonJS = (mod3) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod3);
|
|
10513
10513
|
var DecryptTransportResponseError_exports = {};
|
|
10514
10514
|
__export4(DecryptTransportResponseError_exports, {
|
|
10515
|
-
DecryptTransportResponseError: () =>
|
|
10515
|
+
DecryptTransportResponseError: () => DecryptTransportResponseError2
|
|
10516
10516
|
});
|
|
10517
10517
|
module.exports = __toCommonJS(DecryptTransportResponseError_exports);
|
|
10518
|
-
var
|
|
10518
|
+
var DecryptTransportResponseError2 = class extends Error {
|
|
10519
10519
|
constructor(status, permissionHint) {
|
|
10520
10520
|
super("Node decrypt request failed");
|
|
10521
10521
|
this.status = status;
|
|
@@ -11764,16 +11764,16 @@ function ensureNetworkUsableForDecrypt(descriptor) {
|
|
|
11764
11764
|
})
|
|
11765
11765
|
};
|
|
11766
11766
|
}
|
|
11767
|
-
function encryptToNetwork(
|
|
11767
|
+
function encryptToNetwork(crypto22, input) {
|
|
11768
11768
|
parseNetworkId(input.networkId);
|
|
11769
11769
|
const alg = input.alg ?? DEFAULT_ENCRYPTION_ALG;
|
|
11770
11770
|
const keyVersion = input.keyVersion ?? DEFAULT_KEY_VERSION;
|
|
11771
|
-
const symmetricKey =
|
|
11772
|
-
const ciphertext =
|
|
11773
|
-
const wrapped =
|
|
11771
|
+
const symmetricKey = crypto22.randomBytes(32);
|
|
11772
|
+
const ciphertext = crypto22.authEncrypt(symmetricKey, input.plaintext, input.aad);
|
|
11773
|
+
const wrapped = crypto22.sealToNetworkKey(input.networkPublicKey, symmetricKey);
|
|
11774
11774
|
const encryptedSymmetricKey = base64Encode2(wrapped);
|
|
11775
11775
|
const encryptedSymmetricKeyHash = canonicalHashHex(
|
|
11776
|
-
|
|
11776
|
+
crypto22.sha256,
|
|
11777
11777
|
encryptedSymmetricKey
|
|
11778
11778
|
);
|
|
11779
11779
|
const envelope = {
|
|
@@ -11789,7 +11789,7 @@ function encryptToNetwork(crypto23, input) {
|
|
|
11789
11789
|
};
|
|
11790
11790
|
return { envelope, symmetricKey };
|
|
11791
11791
|
}
|
|
11792
|
-
function validateEnvelope(
|
|
11792
|
+
function validateEnvelope(crypto22, envelope) {
|
|
11793
11793
|
if (envelope === null || typeof envelope !== "object") {
|
|
11794
11794
|
return {
|
|
11795
11795
|
ok: false,
|
|
@@ -11845,7 +11845,7 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11845
11845
|
})
|
|
11846
11846
|
};
|
|
11847
11847
|
}
|
|
11848
|
-
const expectedHash = canonicalHashHex(
|
|
11848
|
+
const expectedHash = canonicalHashHex(crypto22.sha256, e.encryptedSymmetricKey);
|
|
11849
11849
|
if (expectedHash !== e.encryptedSymmetricKeyHash) {
|
|
11850
11850
|
return {
|
|
11851
11851
|
ok: false,
|
|
@@ -11857,10 +11857,10 @@ function validateEnvelope(crypto23, envelope) {
|
|
|
11857
11857
|
}
|
|
11858
11858
|
return { ok: true, data: e };
|
|
11859
11859
|
}
|
|
11860
|
-
function decryptEnvelopeWithKey(
|
|
11860
|
+
function decryptEnvelopeWithKey(crypto22, envelope, symmetricKey) {
|
|
11861
11861
|
const ciphertext = base64Decode2(envelope.ciphertext);
|
|
11862
11862
|
const aad = envelope.aad !== void 0 ? base64Decode2(envelope.aad) : void 0;
|
|
11863
|
-
return
|
|
11863
|
+
return crypto22.authDecrypt(symmetricKey, ciphertext, aad);
|
|
11864
11864
|
}
|
|
11865
11865
|
function buildCanonicalDecryptRequest(input) {
|
|
11866
11866
|
const canonicalBody = canonicalize(input.body);
|
|
@@ -11894,7 +11894,7 @@ function buildDecryptFacts(input) {
|
|
|
11894
11894
|
keyVersion: input.body.keyVersion
|
|
11895
11895
|
};
|
|
11896
11896
|
}
|
|
11897
|
-
function checkDecryptInvocationInput(
|
|
11897
|
+
function checkDecryptInvocationInput(crypto22, input) {
|
|
11898
11898
|
if (input.body.type !== DECRYPT_FACT_TYPE) {
|
|
11899
11899
|
return {
|
|
11900
11900
|
ok: false,
|
|
@@ -11999,7 +11999,7 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
11999
11999
|
const canonicalBody = canonicalize(
|
|
12000
12000
|
input.body
|
|
12001
12001
|
);
|
|
12002
|
-
const expectedBodyHash = canonicalHashHex(
|
|
12002
|
+
const expectedBodyHash = canonicalHashHex(crypto22.sha256, input.body);
|
|
12003
12003
|
if (expectedBodyHash !== input.facts.bodyHash) {
|
|
12004
12004
|
return {
|
|
12005
12005
|
ok: false,
|
|
@@ -12011,8 +12011,8 @@ function checkDecryptInvocationInput(crypto23, input) {
|
|
|
12011
12011
|
}
|
|
12012
12012
|
return { ok: true, data: input, canonicalBody };
|
|
12013
12013
|
}
|
|
12014
|
-
async function buildDecryptInvocation(
|
|
12015
|
-
const checked = checkDecryptInvocationInput(
|
|
12014
|
+
async function buildDecryptInvocation(crypto22, signer, input) {
|
|
12015
|
+
const checked = checkDecryptInvocationInput(crypto22, input);
|
|
12016
12016
|
if (!checked.ok) {
|
|
12017
12017
|
return checked;
|
|
12018
12018
|
}
|
|
@@ -12057,7 +12057,7 @@ function canonicalSignedResponse(response) {
|
|
|
12057
12057
|
return canonicalize(rest);
|
|
12058
12058
|
}
|
|
12059
12059
|
function verifyDecryptResponse(input) {
|
|
12060
|
-
const { crypto:
|
|
12060
|
+
const { crypto: crypto22, request, facts, invocationCid, requestBodyHash, response } = input;
|
|
12061
12061
|
if (response.type !== DECRYPT_RESULT_TYPE) {
|
|
12062
12062
|
return {
|
|
12063
12063
|
ok: false,
|
|
@@ -12140,7 +12140,7 @@ function verifyDecryptResponse(input) {
|
|
|
12140
12140
|
};
|
|
12141
12141
|
}
|
|
12142
12142
|
const expectedRequestHash = hexEncode2(
|
|
12143
|
-
|
|
12143
|
+
crypto22.sha256(utf8Encode(`${invocationCid}${requestBodyHash}`))
|
|
12144
12144
|
);
|
|
12145
12145
|
if (response.requestHash !== expectedRequestHash) {
|
|
12146
12146
|
return {
|
|
@@ -12164,7 +12164,7 @@ function verifyDecryptResponse(input) {
|
|
|
12164
12164
|
canonicalSignedResponse(response)
|
|
12165
12165
|
);
|
|
12166
12166
|
const signatureBytes = base64Decode2(response.nodeSignature);
|
|
12167
|
-
if (!
|
|
12167
|
+
if (!crypto22.verifyNodeSignature(response.nodeId, signedBytes, signatureBytes)) {
|
|
12168
12168
|
return {
|
|
12169
12169
|
ok: false,
|
|
12170
12170
|
error: encryptionError({
|
|
@@ -12174,9 +12174,9 @@ function verifyDecryptResponse(input) {
|
|
|
12174
12174
|
}
|
|
12175
12175
|
return { ok: true, data: response };
|
|
12176
12176
|
}
|
|
12177
|
-
function openWrappedKey(
|
|
12177
|
+
function openWrappedKey(crypto22, receiverPrivateKey, response) {
|
|
12178
12178
|
const wrapped = base64Decode2(response.wrappedKey);
|
|
12179
|
-
return
|
|
12179
|
+
return crypto22.openWithReceiverKey(receiverPrivateKey, wrapped);
|
|
12180
12180
|
}
|
|
12181
12181
|
function encOk(data) {
|
|
12182
12182
|
return { ok: true, data };
|
|
@@ -12184,7 +12184,7 @@ function encOk(data) {
|
|
|
12184
12184
|
function encErr(error) {
|
|
12185
12185
|
return { ok: false, error };
|
|
12186
12186
|
}
|
|
12187
|
-
var import_decrypt_transport_response_error,
|
|
12187
|
+
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, 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;
|
|
12188
12188
|
var init_dist2 = __esm({
|
|
12189
12189
|
"../sdk-services/dist/index.js"() {
|
|
12190
12190
|
"use strict";
|
|
@@ -12192,8 +12192,6 @@ var init_dist2 = __esm({
|
|
|
12192
12192
|
init_dist();
|
|
12193
12193
|
init_dist();
|
|
12194
12194
|
import_decrypt_transport_response_error = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12195
|
-
import_decrypt_transport_response_error2 = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12196
|
-
import_decrypt_transport_response_error3 = __toESM(require_decrypt_transport_response_error(), 1);
|
|
12197
12195
|
ErrorCodes = {
|
|
12198
12196
|
// Common errors
|
|
12199
12197
|
NOT_FOUND: "NOT_FOUND",
|
|
@@ -23958,12 +23956,6 @@ var init_dist3 = __esm({
|
|
|
23958
23956
|
|
|
23959
23957
|
// ../sdk-core/dist/index.js
|
|
23960
23958
|
import { SiweMessage } from "siwe";
|
|
23961
|
-
import crypto22 from "crypto";
|
|
23962
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
23963
|
-
import { Buffer as Buffer3 } from "buffer";
|
|
23964
|
-
import { Buffer as Buffer4 } from "buffer";
|
|
23965
|
-
import { Buffer as Buffer5 } from "buffer";
|
|
23966
|
-
import { isIPv4, isIPv6, isIP as ipVersion } from "net";
|
|
23967
23959
|
function equals5(aa, bb) {
|
|
23968
23960
|
if (aa === bb) {
|
|
23969
23961
|
return true;
|
|
@@ -24408,6 +24400,9 @@ function createDigest(digest4, code3, truncate) {
|
|
|
24408
24400
|
}
|
|
24409
24401
|
return create3(code3, digest4);
|
|
24410
24402
|
}
|
|
24403
|
+
function sha(name2) {
|
|
24404
|
+
return async (data) => new Uint8Array(await crypto.subtle.digest(name2, data));
|
|
24405
|
+
}
|
|
24411
24406
|
function parseStrictRfc33392(value) {
|
|
24412
24407
|
if (!/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(
|
|
24413
24408
|
value
|
|
@@ -24467,11 +24462,8 @@ function equals32(a, b) {
|
|
|
24467
24462
|
}
|
|
24468
24463
|
return true;
|
|
24469
24464
|
}
|
|
24470
|
-
function asUint8Array(buf) {
|
|
24471
|
-
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
24472
|
-
}
|
|
24473
24465
|
function allocUnsafe(size2 = 0) {
|
|
24474
|
-
return
|
|
24466
|
+
return new Uint8Array(size2);
|
|
24475
24467
|
}
|
|
24476
24468
|
function encodingLength22(value) {
|
|
24477
24469
|
if (value < N122) {
|
|
@@ -24635,8 +24627,20 @@ function decode62(buf, offset = 0) {
|
|
|
24635
24627
|
return decodeUint8ArrayList(buf, offset);
|
|
24636
24628
|
}
|
|
24637
24629
|
}
|
|
24630
|
+
function asUint8Array(buf) {
|
|
24631
|
+
return buf;
|
|
24632
|
+
}
|
|
24638
24633
|
function concat2(arrays, length22) {
|
|
24639
|
-
|
|
24634
|
+
if (length22 == null) {
|
|
24635
|
+
length22 = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
|
24636
|
+
}
|
|
24637
|
+
const output = allocUnsafe(length22);
|
|
24638
|
+
let offset = 0;
|
|
24639
|
+
for (const arr of arrays) {
|
|
24640
|
+
output.set(arr, offset);
|
|
24641
|
+
offset += arr.length;
|
|
24642
|
+
}
|
|
24643
|
+
return asUint8Array(output);
|
|
24640
24644
|
}
|
|
24641
24645
|
function createCodec(name2, prefix, encode52, decode72) {
|
|
24642
24646
|
return {
|
|
@@ -24657,9 +24661,6 @@ function fromString2(string2, encoding = "utf8") {
|
|
|
24657
24661
|
if (base33 == null) {
|
|
24658
24662
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
24659
24663
|
}
|
|
24660
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
24661
|
-
return asUint8Array(Buffer4.from(string2, "utf-8"));
|
|
24662
|
-
}
|
|
24663
24664
|
return base33.decoder.decode(`${base33.prefix}${string2}`);
|
|
24664
24665
|
}
|
|
24665
24666
|
function toString2(array, encoding = "utf8") {
|
|
@@ -24667,11 +24668,29 @@ function toString2(array, encoding = "utf8") {
|
|
|
24667
24668
|
if (base33 == null) {
|
|
24668
24669
|
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
24669
24670
|
}
|
|
24670
|
-
if (encoding === "utf8" || encoding === "utf-8") {
|
|
24671
|
-
return Buffer5.from(array.buffer, array.byteOffset, array.byteLength).toString("utf8");
|
|
24672
|
-
}
|
|
24673
24671
|
return base33.encoder.encode(array).substring(1);
|
|
24674
24672
|
}
|
|
24673
|
+
function parseIPv4(input) {
|
|
24674
|
+
if (input.length > MAX_IPV4_LENGTH) {
|
|
24675
|
+
return void 0;
|
|
24676
|
+
}
|
|
24677
|
+
return parser.new(input).parseWith(() => parser.readIPv4Addr());
|
|
24678
|
+
}
|
|
24679
|
+
function parseIPv6(input) {
|
|
24680
|
+
if (input.includes("%")) {
|
|
24681
|
+
input = input.split("%")[0];
|
|
24682
|
+
}
|
|
24683
|
+
if (input.length > MAX_IPV6_LENGTH) {
|
|
24684
|
+
return void 0;
|
|
24685
|
+
}
|
|
24686
|
+
return parser.new(input).parseWith(() => parser.readIPv6Addr());
|
|
24687
|
+
}
|
|
24688
|
+
function isIPv4(input) {
|
|
24689
|
+
return Boolean(parseIPv4(input));
|
|
24690
|
+
}
|
|
24691
|
+
function isIPv6(input) {
|
|
24692
|
+
return Boolean(parseIPv6(input));
|
|
24693
|
+
}
|
|
24675
24694
|
function bytesToString(base33) {
|
|
24676
24695
|
return (buf) => {
|
|
24677
24696
|
return toString2(buf, base33);
|
|
@@ -25367,7 +25386,7 @@ function decodeBase64Url(value) {
|
|
|
25367
25386
|
}
|
|
25368
25387
|
return Uint8Array.from(bytes2);
|
|
25369
25388
|
}
|
|
25370
|
-
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, code2, name, encode42, identity2,
|
|
25389
|
+
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, code2, name, encode42, identity2, sha2_browser_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_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, 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;
|
|
25371
25390
|
var init_dist4 = __esm({
|
|
25372
25391
|
"../sdk-core/dist/index.js"() {
|
|
25373
25392
|
"use strict";
|
|
@@ -25386,10 +25405,8 @@ var init_dist4 = __esm({
|
|
|
25386
25405
|
init_dist2();
|
|
25387
25406
|
init_zod();
|
|
25388
25407
|
init_dist2();
|
|
25389
|
-
init_dist();
|
|
25390
25408
|
init_dist2();
|
|
25391
25409
|
init_dist2();
|
|
25392
|
-
init_dist();
|
|
25393
25410
|
init_ed25519();
|
|
25394
25411
|
init_esm();
|
|
25395
25412
|
__defProp3 = Object.defineProperty;
|
|
@@ -26053,8 +26070,8 @@ var init_dist4 = __esm({
|
|
|
26053
26070
|
name = "identity";
|
|
26054
26071
|
encode42 = coerce4;
|
|
26055
26072
|
identity2 = { code: code2, name, encode: encode42, digest };
|
|
26056
|
-
|
|
26057
|
-
__export3(
|
|
26073
|
+
sha2_browser_exports = {};
|
|
26074
|
+
__export3(sha2_browser_exports, {
|
|
26058
26075
|
sha256: () => sha2562,
|
|
26059
26076
|
sha512: () => sha5122
|
|
26060
26077
|
});
|
|
@@ -26095,15 +26112,15 @@ var init_dist4 = __esm({
|
|
|
26095
26112
|
sha2562 = from22({
|
|
26096
26113
|
name: "sha2-256",
|
|
26097
26114
|
code: 18,
|
|
26098
|
-
encode: (
|
|
26115
|
+
encode: sha("SHA-256")
|
|
26099
26116
|
});
|
|
26100
26117
|
sha5122 = from22({
|
|
26101
26118
|
name: "sha2-512",
|
|
26102
26119
|
code: 19,
|
|
26103
|
-
encode: (
|
|
26120
|
+
encode: sha("SHA-512")
|
|
26104
26121
|
});
|
|
26105
26122
|
bases = { ...identity_exports, ...base2_exports, ...base8_exports, ...base10_exports, ...base16_exports, ...base32_exports, ...base36_exports, ...base58_exports, ...base64_exports, ...base256emoji_exports };
|
|
26106
|
-
hashes = { ...
|
|
26123
|
+
hashes = { ...sha2_browser_exports, ...identity_exports2 };
|
|
26107
26124
|
textEncoder3 = new TextEncoder();
|
|
26108
26125
|
objectHasOwn3 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
|
|
26109
26126
|
Object.prototype.hasOwnProperty
|
|
@@ -27218,6 +27235,192 @@ var init_dist4 = __esm({
|
|
|
27218
27235
|
}
|
|
27219
27236
|
};
|
|
27220
27237
|
__publicField(UnknownProtocolError, "name", "UnknownProtocolError");
|
|
27238
|
+
Parser = class {
|
|
27239
|
+
constructor() {
|
|
27240
|
+
__publicField(this, "index", 0);
|
|
27241
|
+
__publicField(this, "input", "");
|
|
27242
|
+
}
|
|
27243
|
+
new(input) {
|
|
27244
|
+
this.index = 0;
|
|
27245
|
+
this.input = input;
|
|
27246
|
+
return this;
|
|
27247
|
+
}
|
|
27248
|
+
/** Run a parser, and restore the pre-parse state if it fails. */
|
|
27249
|
+
readAtomically(fn) {
|
|
27250
|
+
const index = this.index;
|
|
27251
|
+
const result = fn();
|
|
27252
|
+
if (result === void 0) {
|
|
27253
|
+
this.index = index;
|
|
27254
|
+
}
|
|
27255
|
+
return result;
|
|
27256
|
+
}
|
|
27257
|
+
/** Run a parser, but fail if the entire input wasn't consumed. Doesn't run atomically. */
|
|
27258
|
+
parseWith(fn) {
|
|
27259
|
+
const result = fn();
|
|
27260
|
+
if (this.index !== this.input.length) {
|
|
27261
|
+
return void 0;
|
|
27262
|
+
}
|
|
27263
|
+
return result;
|
|
27264
|
+
}
|
|
27265
|
+
/** Peek the next character from the input */
|
|
27266
|
+
peekChar() {
|
|
27267
|
+
if (this.index >= this.input.length) {
|
|
27268
|
+
return void 0;
|
|
27269
|
+
}
|
|
27270
|
+
return this.input[this.index];
|
|
27271
|
+
}
|
|
27272
|
+
/** Read the next character from the input */
|
|
27273
|
+
readChar() {
|
|
27274
|
+
if (this.index >= this.input.length) {
|
|
27275
|
+
return void 0;
|
|
27276
|
+
}
|
|
27277
|
+
return this.input[this.index++];
|
|
27278
|
+
}
|
|
27279
|
+
/** Read the next character from the input if it matches the target. */
|
|
27280
|
+
readGivenChar(target) {
|
|
27281
|
+
return this.readAtomically(() => {
|
|
27282
|
+
const char = this.readChar();
|
|
27283
|
+
if (char !== target) {
|
|
27284
|
+
return void 0;
|
|
27285
|
+
}
|
|
27286
|
+
return char;
|
|
27287
|
+
});
|
|
27288
|
+
}
|
|
27289
|
+
/**
|
|
27290
|
+
* Helper for reading separators in an indexed loop. Reads the separator
|
|
27291
|
+
* character iff index > 0, then runs the parser. When used in a loop,
|
|
27292
|
+
* the separator character will only be read on index > 0 (see
|
|
27293
|
+
* readIPv4Addr for an example)
|
|
27294
|
+
*/
|
|
27295
|
+
readSeparator(sep2, index, inner) {
|
|
27296
|
+
return this.readAtomically(() => {
|
|
27297
|
+
if (index > 0) {
|
|
27298
|
+
if (this.readGivenChar(sep2) === void 0) {
|
|
27299
|
+
return void 0;
|
|
27300
|
+
}
|
|
27301
|
+
}
|
|
27302
|
+
return inner();
|
|
27303
|
+
});
|
|
27304
|
+
}
|
|
27305
|
+
/**
|
|
27306
|
+
* Read a number off the front of the input in the given radix, stopping
|
|
27307
|
+
* at the first non-digit character or eof. Fails if the number has more
|
|
27308
|
+
* digits than max_digits or if there is no number.
|
|
27309
|
+
*/
|
|
27310
|
+
readNumber(radix, maxDigits, allowZeroPrefix, maxBytes) {
|
|
27311
|
+
return this.readAtomically(() => {
|
|
27312
|
+
let result = 0;
|
|
27313
|
+
let digitCount = 0;
|
|
27314
|
+
const leadingChar = this.peekChar();
|
|
27315
|
+
if (leadingChar === void 0) {
|
|
27316
|
+
return void 0;
|
|
27317
|
+
}
|
|
27318
|
+
const hasLeadingZero = leadingChar === "0";
|
|
27319
|
+
const maxValue2 = 2 ** (8 * maxBytes) - 1;
|
|
27320
|
+
while (true) {
|
|
27321
|
+
const digit = this.readAtomically(() => {
|
|
27322
|
+
const char = this.readChar();
|
|
27323
|
+
if (char === void 0) {
|
|
27324
|
+
return void 0;
|
|
27325
|
+
}
|
|
27326
|
+
const num2 = Number.parseInt(char, radix);
|
|
27327
|
+
if (Number.isNaN(num2)) {
|
|
27328
|
+
return void 0;
|
|
27329
|
+
}
|
|
27330
|
+
return num2;
|
|
27331
|
+
});
|
|
27332
|
+
if (digit === void 0) {
|
|
27333
|
+
break;
|
|
27334
|
+
}
|
|
27335
|
+
result *= radix;
|
|
27336
|
+
result += digit;
|
|
27337
|
+
if (result > maxValue2) {
|
|
27338
|
+
return void 0;
|
|
27339
|
+
}
|
|
27340
|
+
digitCount += 1;
|
|
27341
|
+
if (maxDigits !== void 0) {
|
|
27342
|
+
if (digitCount > maxDigits) {
|
|
27343
|
+
return void 0;
|
|
27344
|
+
}
|
|
27345
|
+
}
|
|
27346
|
+
}
|
|
27347
|
+
if (digitCount === 0) {
|
|
27348
|
+
return void 0;
|
|
27349
|
+
} else if (!allowZeroPrefix && hasLeadingZero && digitCount > 1) {
|
|
27350
|
+
return void 0;
|
|
27351
|
+
} else {
|
|
27352
|
+
return result;
|
|
27353
|
+
}
|
|
27354
|
+
});
|
|
27355
|
+
}
|
|
27356
|
+
/** Read an IPv4 address. */
|
|
27357
|
+
readIPv4Addr() {
|
|
27358
|
+
return this.readAtomically(() => {
|
|
27359
|
+
const out = new Uint8Array(4);
|
|
27360
|
+
for (let i = 0; i < out.length; i++) {
|
|
27361
|
+
const ix = this.readSeparator(".", i, () => this.readNumber(10, 3, false, 1));
|
|
27362
|
+
if (ix === void 0) {
|
|
27363
|
+
return void 0;
|
|
27364
|
+
}
|
|
27365
|
+
out[i] = ix;
|
|
27366
|
+
}
|
|
27367
|
+
return out;
|
|
27368
|
+
});
|
|
27369
|
+
}
|
|
27370
|
+
/** Read an IPv6 Address. */
|
|
27371
|
+
readIPv6Addr() {
|
|
27372
|
+
const readGroups = (groups) => {
|
|
27373
|
+
for (let i = 0; i < groups.length / 2; i++) {
|
|
27374
|
+
const ix = i * 2;
|
|
27375
|
+
if (i < groups.length - 3) {
|
|
27376
|
+
const ipv4 = this.readSeparator(":", i, () => this.readIPv4Addr());
|
|
27377
|
+
if (ipv4 !== void 0) {
|
|
27378
|
+
groups[ix] = ipv4[0];
|
|
27379
|
+
groups[ix + 1] = ipv4[1];
|
|
27380
|
+
groups[ix + 2] = ipv4[2];
|
|
27381
|
+
groups[ix + 3] = ipv4[3];
|
|
27382
|
+
return [ix + 4, true];
|
|
27383
|
+
}
|
|
27384
|
+
}
|
|
27385
|
+
const group = this.readSeparator(":", i, () => this.readNumber(16, 4, true, 2));
|
|
27386
|
+
if (group === void 0) {
|
|
27387
|
+
return [ix, false];
|
|
27388
|
+
}
|
|
27389
|
+
groups[ix] = group >> 8;
|
|
27390
|
+
groups[ix + 1] = group & 255;
|
|
27391
|
+
}
|
|
27392
|
+
return [groups.length, false];
|
|
27393
|
+
};
|
|
27394
|
+
return this.readAtomically(() => {
|
|
27395
|
+
const head = new Uint8Array(16);
|
|
27396
|
+
const [headSize, headIp4] = readGroups(head);
|
|
27397
|
+
if (headSize === 16) {
|
|
27398
|
+
return head;
|
|
27399
|
+
}
|
|
27400
|
+
if (headIp4) {
|
|
27401
|
+
return void 0;
|
|
27402
|
+
}
|
|
27403
|
+
if (this.readGivenChar(":") === void 0) {
|
|
27404
|
+
return void 0;
|
|
27405
|
+
}
|
|
27406
|
+
if (this.readGivenChar(":") === void 0) {
|
|
27407
|
+
return void 0;
|
|
27408
|
+
}
|
|
27409
|
+
const tail = new Uint8Array(14);
|
|
27410
|
+
const limit = 16 - (headSize + 2);
|
|
27411
|
+
const [tailSize] = readGroups(tail.subarray(0, limit));
|
|
27412
|
+
head.set(tail.subarray(0, tailSize), 16 - tailSize);
|
|
27413
|
+
return head;
|
|
27414
|
+
});
|
|
27415
|
+
}
|
|
27416
|
+
/** Read an IP Address, either IPv4 or IPv6. */
|
|
27417
|
+
readIPAddr() {
|
|
27418
|
+
return this.readIPv4Addr() ?? this.readIPv6Addr();
|
|
27419
|
+
}
|
|
27420
|
+
};
|
|
27421
|
+
MAX_IPV6_LENGTH = 45;
|
|
27422
|
+
MAX_IPV4_LENGTH = 15;
|
|
27423
|
+
parser = new Parser();
|
|
27221
27424
|
CODE_IP4 = 4;
|
|
27222
27425
|
CODE_TCP = 6;
|
|
27223
27426
|
CODE_UDP = 273;
|