@tinycloud/cli 0.8.3-beta.2 → 0.8.3-beta.4
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 +90 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -13465,6 +13465,7 @@ var init_dist2 = __esm({
|
|
|
13465
13465
|
}
|
|
13466
13466
|
seen.add(path);
|
|
13467
13467
|
}
|
|
13468
|
+
let requestMayHaveDispatched = false;
|
|
13468
13469
|
try {
|
|
13469
13470
|
const body = new FormData();
|
|
13470
13471
|
for (let index = 0; index < items.length; index++) {
|
|
@@ -13482,14 +13483,31 @@ var init_dist2 = __esm({
|
|
|
13482
13483
|
action: KVAction.PUT
|
|
13483
13484
|
}))
|
|
13484
13485
|
);
|
|
13485
|
-
const
|
|
13486
|
+
const url = `${this.host}/invoke`;
|
|
13487
|
+
const init = {
|
|
13486
13488
|
method: "POST",
|
|
13487
13489
|
headers,
|
|
13488
13490
|
body,
|
|
13489
13491
|
signal: this.combineSignals(options?.signal)
|
|
13490
|
-
}
|
|
13492
|
+
};
|
|
13493
|
+
const fetchFn = this.context.fetch;
|
|
13494
|
+
requestMayHaveDispatched = true;
|
|
13495
|
+
const response = await fetchFn(url, init);
|
|
13491
13496
|
if (!response.ok) {
|
|
13492
|
-
|
|
13497
|
+
let errorText;
|
|
13498
|
+
try {
|
|
13499
|
+
errorText = await response.text();
|
|
13500
|
+
} catch (textError) {
|
|
13501
|
+
const cause = textError instanceof Error ? textError : new Error(String(textError));
|
|
13502
|
+
return err(
|
|
13503
|
+
serviceError(
|
|
13504
|
+
ErrorCodes.KV_WRITE_FAILED,
|
|
13505
|
+
`Failed to batch put ${items.length} key(s): ${response.status} - <response body could not be read: ${cause.message}>`,
|
|
13506
|
+
"kv",
|
|
13507
|
+
{ cause, meta: { status: response.status, statusText: response.statusText } }
|
|
13508
|
+
)
|
|
13509
|
+
);
|
|
13510
|
+
}
|
|
13493
13511
|
if (response.status === 401 || response.status === 403) {
|
|
13494
13512
|
const { resource, action } = parseAuthError(errorText);
|
|
13495
13513
|
return err(authUnauthorizedError("kv", errorText, {
|
|
@@ -13515,19 +13533,73 @@ var init_dist2 = __esm({
|
|
|
13515
13533
|
)
|
|
13516
13534
|
);
|
|
13517
13535
|
}
|
|
13518
|
-
|
|
13519
|
-
|
|
13536
|
+
let rawBody;
|
|
13537
|
+
try {
|
|
13538
|
+
rawBody = await response.json();
|
|
13539
|
+
} catch (jsonError) {
|
|
13540
|
+
const cause = jsonError instanceof Error ? jsonError : new Error(String(jsonError));
|
|
13541
|
+
return err(
|
|
13542
|
+
serviceError(
|
|
13543
|
+
ErrorCodes.NETWORK_ERROR,
|
|
13544
|
+
`KV batchPut response was not valid JSON: ${cause.message}`,
|
|
13545
|
+
"kv",
|
|
13546
|
+
{
|
|
13547
|
+
cause,
|
|
13548
|
+
meta: {
|
|
13549
|
+
requestMayHaveDispatched: true,
|
|
13550
|
+
responseReceived: true,
|
|
13551
|
+
status: response.status,
|
|
13552
|
+
outcome: "batch-unconfirmed"
|
|
13553
|
+
}
|
|
13554
|
+
}
|
|
13555
|
+
)
|
|
13556
|
+
);
|
|
13557
|
+
}
|
|
13558
|
+
const batchResponse = this.normalizeBatchPutResponse(rawBody);
|
|
13559
|
+
if (!batchResponse) {
|
|
13520
13560
|
return err(
|
|
13521
13561
|
serviceError(
|
|
13522
13562
|
ErrorCodes.NETWORK_ERROR,
|
|
13523
13563
|
"KV batchPut response did not include matching written keys and count",
|
|
13524
|
-
"kv"
|
|
13564
|
+
"kv",
|
|
13565
|
+
{
|
|
13566
|
+
meta: {
|
|
13567
|
+
requestMayHaveDispatched: true,
|
|
13568
|
+
responseReceived: true,
|
|
13569
|
+
status: response.status,
|
|
13570
|
+
outcome: "batch-unconfirmed"
|
|
13571
|
+
}
|
|
13572
|
+
}
|
|
13573
|
+
)
|
|
13574
|
+
);
|
|
13575
|
+
}
|
|
13576
|
+
const requestedPaths = new Set(paths);
|
|
13577
|
+
const writtenPaths = new Set(batchResponse.written);
|
|
13578
|
+
const matchesRequest = batchResponse.count === paths.length && batchResponse.written.length === paths.length && writtenPaths.size === paths.length && batchResponse.written.every((key) => requestedPaths.has(key));
|
|
13579
|
+
if (!matchesRequest) {
|
|
13580
|
+
return err(
|
|
13581
|
+
serviceError(
|
|
13582
|
+
ErrorCodes.NETWORK_ERROR,
|
|
13583
|
+
`KV batchPut response did not confirm all ${paths.length} requested key(s) were written`,
|
|
13584
|
+
"kv",
|
|
13585
|
+
{
|
|
13586
|
+
meta: {
|
|
13587
|
+
requestMayHaveDispatched: true,
|
|
13588
|
+
responseReceived: true,
|
|
13589
|
+
status: response.status,
|
|
13590
|
+
outcome: "batch-unconfirmed"
|
|
13591
|
+
}
|
|
13592
|
+
}
|
|
13525
13593
|
)
|
|
13526
13594
|
);
|
|
13527
13595
|
}
|
|
13528
13596
|
return ok(batchResponse);
|
|
13529
13597
|
} catch (error) {
|
|
13530
|
-
|
|
13598
|
+
const wrapped = wrapError2("kv", error);
|
|
13599
|
+
return err({
|
|
13600
|
+
...wrapped,
|
|
13601
|
+
meta: { ...wrapped.meta, requestMayHaveDispatched }
|
|
13602
|
+
});
|
|
13531
13603
|
}
|
|
13532
13604
|
});
|
|
13533
13605
|
}
|
|
@@ -17630,13 +17702,14 @@ async function discoverLocalTinyCloudNode(options2 = {}) {
|
|
|
17630
17702
|
}
|
|
17631
17703
|
const fetchFn = options2.fetch ?? globalThis.fetch;
|
|
17632
17704
|
const identityStore = options2.identityStore ?? defaultLocalNodeIdentityStore;
|
|
17633
|
-
const staticCandidates = [
|
|
17634
|
-
|
|
17705
|
+
const staticCandidates = [];
|
|
17706
|
+
if (options2.localNodeUrl) {
|
|
17707
|
+
staticCandidates.push({
|
|
17635
17708
|
source: "local-loopback",
|
|
17636
|
-
url: options2.localNodeUrl
|
|
17709
|
+
url: options2.localNodeUrl,
|
|
17637
17710
|
timeoutMs: LOCAL_LOOPBACK_PROBE_TIMEOUT_MS
|
|
17638
|
-
}
|
|
17639
|
-
|
|
17711
|
+
});
|
|
17712
|
+
}
|
|
17640
17713
|
if (options2.localLinkName) {
|
|
17641
17714
|
if (isValidDnsLabel(options2.localLinkName)) {
|
|
17642
17715
|
staticCandidates.push({
|
|
@@ -17891,7 +17964,7 @@ function decodeBase64Url(value) {
|
|
|
17891
17964
|
}
|
|
17892
17965
|
return Uint8Array.from(bytes2);
|
|
17893
17966
|
}
|
|
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,
|
|
17967
|
+
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, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
|
|
17895
17968
|
var init_dist3 = __esm({
|
|
17896
17969
|
"../sdk-core/dist/index.js"() {
|
|
17897
17970
|
"use strict";
|
|
@@ -20339,7 +20412,6 @@ var init_dist3 = __esm({
|
|
|
20339
20412
|
ipRegex.v6 = (options2) => options2 && options2.exact ? v6exact : new RegExp(`${boundry(options2)}${v6}${boundry(options2)}`, "g");
|
|
20340
20413
|
({ toString: toString3 } = Object.prototype);
|
|
20341
20414
|
DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL = "https://registry.tinycloud.xyz";
|
|
20342
|
-
DEFAULT_LOCAL_NODE_URL = "http://127.0.0.1:8000";
|
|
20343
20415
|
LOCAL_LOOPBACK_PROBE_TIMEOUT_MS = 250;
|
|
20344
20416
|
LOCAL_LINK_PROBE_TIMEOUT_MS = 750;
|
|
20345
20417
|
LOCAL_LINK_HOST_SUFFIX = ".local.tinycloud.link";
|
|
@@ -20739,9 +20811,10 @@ var init_profiles = __esm({
|
|
|
20739
20811
|
* Host resolution: options.host > TC_HOST env > discovered local node > profile.host > DEFAULT_HOST
|
|
20740
20812
|
*
|
|
20741
20813
|
* Local-node discovery (TC-106) only runs when no explicit host was given
|
|
20742
|
-
* (`--host` / `TC_HOST`); it probes
|
|
20743
|
-
* after DID verification against the profile's pinned identity, prefers
|
|
20744
|
-
* over the stored/default host.
|
|
20814
|
+
* (`--host` / `TC_HOST`); it probes configured or registered local nodes and,
|
|
20815
|
+
* after DID verification against the profile's pinned identity, prefers one
|
|
20816
|
+
* over the stored/default host. Loopback requires an explicit `localNodeUrl`.
|
|
20817
|
+
* Disable discovery per profile with
|
|
20745
20818
|
* `autoDiscoverLocalNode: false` in profile.json.
|
|
20746
20819
|
*/
|
|
20747
20820
|
static async resolveContext(options) {
|