@tinycloud/sdk-services 3.2.0-beta.3 → 3.2.0-beta.5
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.cjs +14 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/kv/index.cjs +14 -8
- package/dist/kv/index.cjs.map +1 -1
- package/dist/kv/index.d.cts +3 -2
- package/dist/kv/index.d.ts +3 -2
- package/dist/kv/index.js +14 -8
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/replication/index.cjs +42 -19
- package/dist/kv/replication/index.cjs.map +1 -1
- package/dist/kv/replication/index.d.cts +3 -2
- package/dist/kv/replication/index.d.ts +3 -2
- package/dist/kv/replication/index.js +42 -19
- package/dist/kv/replication/index.js.map +1 -1
- package/dist/kv/replication/prefix.cjs +43 -0
- package/dist/kv/replication/prefix.cjs.map +1 -0
- package/dist/kv/replication/prefix.d.cts +6 -0
- package/dist/kv/replication/prefix.d.ts +6 -0
- package/dist/kv/replication/prefix.js +17 -0
- package/dist/kv/replication/prefix.js.map +1 -0
- package/dist/{scope-BmLxwyl-.d.ts → scope-BKge7zDT.d.ts} +4 -4
- package/dist/{scope-D855kRDx.d.cts → scope-C05VVAXH.d.cts} +4 -4
- package/package.json +14 -1
package/dist/index.d.cts
CHANGED
|
@@ -5,11 +5,12 @@ import { B as BaseService } from './BaseService-BDQXjWMx.cjs';
|
|
|
5
5
|
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-BDQXjWMx.cjs';
|
|
6
6
|
import { IKVService } from './kv/index.cjs';
|
|
7
7
|
export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.cjs';
|
|
8
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING,
|
|
8
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, H as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, I as KVAction, J as KVActionType, M as KVBatchPutItem, N as KVBatchPutOptions, O as KVBatchPutResponse, Q as KVBatchReadResponse, S as KVChange, T as KVChangesAuthority, U as KVChangesOptions, V as KVChangesResponse, W as KVCreateSignedReadUrlOptions, X as KVDeleteOptions, Y as KVGetOptions, Z as KVHeadOptions, _ as KVListOptions, b as KVListPage, $ as KVListResponse, a0 as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a1 as KVResponse, a2 as KVResponseHeaders, a3 as KVServiceConfig, a4 as KVSignedReadUrlResponse, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as replicationIdentityKey, G as requiresSecretsOptIn } from './scope-C05VVAXH.cjs';
|
|
9
9
|
export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLAction, SQLActionType, SQLMigrations, SQLService, SQLServiceConfig, SqlMigration, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue } from './sql/index.cjs';
|
|
10
10
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.cjs';
|
|
11
11
|
export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, InlineEncryptedEnvelope, Json, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, base64Decode, base64Encode, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalize as canonicalizeEncryptionJson, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, encryptionError, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, openWrappedKey, parseNetworkId, utf8Decode, utf8Encode, validateEnvelope, verifyDecryptResponse } from './encryption/index.cjs';
|
|
12
12
|
export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
|
|
13
|
+
export { kvPrefixCovers } from './kv/replication/prefix.cjs';
|
|
13
14
|
|
|
14
15
|
type TinyCloudDebugLevel = "debug";
|
|
15
16
|
interface TinyCloudDebugEvent {
|
package/dist/index.d.ts
CHANGED
|
@@ -5,11 +5,12 @@ import { B as BaseService } from './BaseService-Di_hVfUV.js';
|
|
|
5
5
|
export { a as BaseServiceOptions, R as RequestSignal, S as ServiceConstructor, b as ServiceRegistration } from './BaseService-Di_hVfUV.js';
|
|
6
6
|
import { IKVService } from './kv/index.js';
|
|
7
7
|
export { IPrefixedKVService, KVService, PrefixedKVService } from './kv/index.js';
|
|
8
|
-
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING,
|
|
8
|
+
export { A as AuthorityRefusal, C as CLEAR_PENDING_WARNING, H as DEFAULT_SIGNED_READ_URL_EXPIRY_MS, I as KVAction, J as KVActionType, M as KVBatchPutItem, N as KVBatchPutOptions, O as KVBatchPutResponse, Q as KVBatchReadResponse, S as KVChange, T as KVChangesAuthority, U as KVChangesOptions, V as KVChangesResponse, W as KVCreateSignedReadUrlOptions, X as KVDeleteOptions, Y as KVGetOptions, Z as KVHeadOptions, _ as KVListOptions, b as KVListPage, $ as KVListResponse, a0 as KVPutOptions, c as KVReadThrough, d as KVReplicaHandle, e as KVReplicaSpec, f as KVReplicaStorage, a as KVReplicationController, K as KVReplicationDeps, a1 as KVResponse, a2 as KVResponseHeaders, a3 as KVServiceConfig, a4 as KVSignedReadUrlResponse, L as LocalGetResult, g as LocalListResult, h as LocalReadMeta, i as LocalReplicaStatus, j as LocalSyncResult, k as PendingWriteRecord, l as PendingWriteState, P as PendingWriteStore, m as PinnedKey, n as PurgeTarget, o as ReplicaAuthorityState, p as ReplicaCoverage, q as ReplicaDevice, r as ReplicaGrantInfo, s as ReplicaState, t as ReplicaStatusEntry, u as ReplicationAuthority, v as ReplicationControl, w as ReplicationEvent, R as ReplicationIdentity, x as ReplicationOptions, y as ReplicationPurgeReport, z as ReplicationReason, B as ReplicationScheduler, D as ResolvedReplicationOptions, E as canonicalReplicationIdentity, F as replicationIdentityKey, G as requiresSecretsOptIn } from './scope-BKge7zDT.js';
|
|
9
9
|
export { BatchOptions, BatchResponse, DatabaseHandle, ExecuteOptions, ExecuteResponse, IDatabaseHandle, ISQLMigrations, ISQLService, QueryOptions, QueryResponse, SQLAction, SQLActionType, SQLMigrations, SQLService, SQLServiceConfig, SqlMigration, SqlMigrationApplyOptions, SqlMigrationApplyResponse, SqlStatement, SqlValue } from './sql/index.js';
|
|
10
10
|
import { IEncryptionService, DecryptCapabilityProof } from './encryption/index.js';
|
|
11
11
|
export { BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, InlineEncryptedEnvelope, Json, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, SignedReceiverKeyInput, VerifyDecryptResponseInput, WellKnownDescriptorFetcher, base64Decode, base64Encode, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalize as canonicalizeEncryptionJson, checkDecryptInvocationInput, decryptEnvelopeWithKey, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, encryptionError, ensureNetworkUsableForDecrypt, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, openWrappedKey, parseNetworkId, utf8Decode, utf8Encode, validateEnvelope, verifyDecryptResponse } from './encryption/index.js';
|
|
12
12
|
export { DecryptTransportResponseError } from '@tinycloud/sdk-services/internal/decrypt-transport-response-error';
|
|
13
|
+
export { kvPrefixCovers } from './kv/replication/prefix.js';
|
|
13
14
|
|
|
14
15
|
type TinyCloudDebugLevel = "debug";
|
|
15
16
|
interface TinyCloudDebugEvent {
|
package/dist/index.js
CHANGED
|
@@ -2854,6 +2854,7 @@ var KVService = class extends BaseService {
|
|
|
2854
2854
|
"kv"
|
|
2855
2855
|
));
|
|
2856
2856
|
}
|
|
2857
|
+
const requestPrefix = options.prefix === "/" ? "" : options.prefix;
|
|
2857
2858
|
const headers = {};
|
|
2858
2859
|
if (options.limit !== void 0) headers["x-tinycloud-limit"] = String(options.limit);
|
|
2859
2860
|
if (options.cursor !== void 0) headers["x-tinycloud-cursor"] = options.cursor;
|
|
@@ -2863,7 +2864,7 @@ var KVService = class extends BaseService {
|
|
|
2863
2864
|
const request = this.createRequestSignal(options.signal, options.timeout);
|
|
2864
2865
|
try {
|
|
2865
2866
|
const response = await this.invokeOperation(
|
|
2866
|
-
|
|
2867
|
+
requestPrefix,
|
|
2867
2868
|
KVAction.SYNC,
|
|
2868
2869
|
void 0,
|
|
2869
2870
|
request.signal,
|
|
@@ -2879,7 +2880,7 @@ var KVService = class extends BaseService {
|
|
|
2879
2880
|
} catch {
|
|
2880
2881
|
body = void 0;
|
|
2881
2882
|
}
|
|
2882
|
-
const page = this.normalizeChangesResponse(body);
|
|
2883
|
+
const page = this.normalizeChangesResponse(body, options.prefix);
|
|
2883
2884
|
if (!page) {
|
|
2884
2885
|
return err(serviceError(
|
|
2885
2886
|
ErrorCodes.NETWORK_ERROR,
|
|
@@ -2959,7 +2960,7 @@ var KVService = class extends BaseService {
|
|
|
2959
2960
|
{ meta }
|
|
2960
2961
|
));
|
|
2961
2962
|
}
|
|
2962
|
-
normalizeChangesResponse(data) {
|
|
2963
|
+
normalizeChangesResponse(data, requestedPrefix) {
|
|
2963
2964
|
if (!isJsonObject(data)) return void 0;
|
|
2964
2965
|
const { changes, more, cursor, source, authority } = data;
|
|
2965
2966
|
if (!Array.isArray(changes) || typeof more !== "boolean" || typeof cursor !== "string" || !isJsonObject(source) || typeof source.nodeDid !== "string" || typeof source.space !== "string" || typeof source.prefix !== "string" || !isJsonObject(authority)) {
|
|
@@ -2991,7 +2992,11 @@ var KVService = class extends BaseService {
|
|
|
2991
2992
|
changes: parsed,
|
|
2992
2993
|
more,
|
|
2993
2994
|
cursor,
|
|
2994
|
-
source: {
|
|
2995
|
+
source: {
|
|
2996
|
+
nodeDid: source.nodeDid,
|
|
2997
|
+
space: source.space,
|
|
2998
|
+
prefix: requestedPrefix === "/" && source.prefix === "" ? "/" : source.prefix
|
|
2999
|
+
},
|
|
2995
3000
|
authority: { notBefore, expiresAt, retainUntil }
|
|
2996
3001
|
};
|
|
2997
3002
|
}
|
|
@@ -3286,13 +3291,14 @@ ${canonical.space}
|
|
|
3286
3291
|
${canonical.principal}`;
|
|
3287
3292
|
}
|
|
3288
3293
|
|
|
3289
|
-
// src/kv/replication/
|
|
3294
|
+
// src/kv/replication/prefix.ts
|
|
3290
3295
|
function kvPrefixCovers(prefix, key) {
|
|
3291
|
-
|
|
3292
|
-
if (prefix.endsWith("/")) return key.startsWith(prefix);
|
|
3293
|
-
return key === prefix || key.startsWith(`${prefix}/`);
|
|
3296
|
+
return prefix === "/" || key.startsWith(prefix);
|
|
3294
3297
|
}
|
|
3298
|
+
|
|
3299
|
+
// src/kv/replication/scope.ts
|
|
3295
3300
|
function requiresSecretsOptIn(space, prefix) {
|
|
3301
|
+
if (prefix === "/") return true;
|
|
3296
3302
|
if (space === "secrets" || space.endsWith(":secrets")) return true;
|
|
3297
3303
|
return prefix.split("/", 1)[0] === "vault";
|
|
3298
3304
|
}
|