@tinycloud/node-sdk 3.7.0 → 3.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
2
2
  export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
3
- import { T as TinyCloudNode } from './TinyCloudNode-DD7qjyLU.cjs';
3
+ import { T as TinyCloudNode } from './TinyCloudNode-DDfx8Fx5.cjs';
4
4
  import '@tinycloud/sdk-core';
5
5
  import '@tinycloud/sdk-services/kv/replication';
6
6
  import '@tinycloud/sdk-services';
@@ -1,6 +1,6 @@
1
1
  import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
2
2
  export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
3
- import { T as TinyCloudNode } from './TinyCloudNode-Cw00iiSP.js';
3
+ import { T as TinyCloudNode } from './TinyCloudNode-Ckqu_fqH.js';
4
4
  import '@tinycloud/sdk-core';
5
5
  import '@tinycloud/sdk-services/kv/replication';
6
6
  import '@tinycloud/sdk-services';
package/dist/index.cjs CHANGED
@@ -17053,7 +17053,7 @@ function augmentSignInEntriesWithReplication(input) {
17053
17053
  }
17054
17054
  eligiblePaths.push(path);
17055
17055
  }
17056
- if (eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
17056
+ if (replication.syncScope !== "prefixes" && eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
17057
17057
  return [{
17058
17058
  service: KV_SERVICE,
17059
17059
  space: input.primarySpaceId,
@@ -17086,6 +17086,9 @@ var init_authority_sign_in = __esm({
17086
17086
 
17087
17087
  // src/replication/config.ts
17088
17088
  function assertValidReplicationConfig(replication) {
17089
+ if (replication?.syncScope !== void 0 && replication.syncScope !== "prefixes") {
17090
+ throw new TypeError('replication.syncScope must be "prefixes"');
17091
+ }
17089
17092
  if (replication === void 0 || !replication.enabled) return;
17090
17093
  if (replication.storage === void 0 || replication.storage === null) {
17091
17094
  throw new TypeError("replication.enabled requires replication.storage");
@@ -19019,6 +19022,7 @@ var NodeUserAuthorization = class {
19019
19022
  this.includeAccountRegistryPermissions = config.includeAccountRegistryPermissions ?? true;
19020
19023
  this.replication = config.replication?.enabled === true ? config.replication : void 0;
19021
19024
  this.establishReplicaStamp = config.establishReplicaStamp;
19025
+ this.additionalRawAbilities = config.additionalRawAbilities;
19022
19026
  this._manifest = config.manifest;
19023
19027
  this._capabilityRequest = config.capabilityRequest;
19024
19028
  this.sessionManager = config.sessionManager ?? this.wasm.createSessionManager();
@@ -19449,7 +19453,18 @@ var NodeUserAuthorization = class {
19449
19453
  defaultEncryptionNetworkId(address, chainId) {
19450
19454
  return `urn:tinycloud:encryption:${(0, import_sdk_core5.pkhDid)(address, chainId)}:default`;
19451
19455
  }
19456
+ /** Sign-in capabilities plus the caller's additional top-level resource abilities. */
19452
19457
  resolveSignInCapabilities(address, chainId) {
19458
+ const base2 = this.resolveBaseSignInCapabilities(address, chainId);
19459
+ const extra = this.additionalRawAbilities;
19460
+ if (extra === void 0 || Object.keys(extra).length === 0) return base2;
19461
+ const rawAbilities = { ...base2.rawAbilities ?? {} };
19462
+ for (const [resource, actions] of Object.entries(extra)) {
19463
+ for (const action of actions) addRawAbility(rawAbilities, resource, action);
19464
+ }
19465
+ return { ...base2, rawAbilities };
19466
+ }
19467
+ resolveBaseSignInCapabilities(address, chainId) {
19453
19468
  const request = this.getCapabilityRequest();
19454
19469
  if (request === void 0) {
19455
19470
  const defaultNetworkId = this.defaultEncryptionNetworkId(address, chainId);
@@ -21676,6 +21691,7 @@ var _TinyCloudNode = class _TinyCloudNode {
21676
21691
  this._bootstrapStatus = {
21677
21692
  skipped: false
21678
21693
  };
21694
+ this._freshEncryptionNetworkCreated = false;
21679
21695
  /**
21680
21696
  * Turns every service's storage rejections into one `storage.full` event,
21681
21697
  * and remembers whose storage is full so sign-in and listing skip their
@@ -21839,6 +21855,10 @@ var _TinyCloudNode = class _TinyCloudNode {
21839
21855
  get bootstrapStatus() {
21840
21856
  return this._bootstrapStatus;
21841
21857
  }
21858
+ /** Whether the last sign-in's fresh account bootstrap created its encryption network. */
21859
+ get freshEncryptionNetworkCreated() {
21860
+ return this._freshEncryptionNetworkCreated;
21861
+ }
21842
21862
  /**
21843
21863
  * Subscribe to `storage.full`. It fires on the first write any service had
21844
21864
  * rejected because the owner's TinyCloud storage is full
@@ -22041,6 +22061,7 @@ var _TinyCloudNode = class _TinyCloudNode {
22041
22061
  signStrategy: config.signStrategy ?? { type: "auto-sign" },
22042
22062
  wasmBindings: this.wasmBindings,
22043
22063
  ...config.replication?.enabled === true ? { establishReplicaStamp: this.establishReplicaStamp } : {},
22064
+ ...config.additionalRawAbilities === void 0 ? {} : { additionalRawAbilities: config.additionalRawAbilities },
22044
22065
  sessionManager: this.sessionManager,
22045
22066
  sessionStorage: config.sessionStorage ?? new MemorySessionStorage(),
22046
22067
  domain: this.siweDomain,
@@ -22069,7 +22090,8 @@ var _TinyCloudNode = class _TinyCloudNode {
22069
22090
  replication: config.replication?.enabled === true ? {
22070
22091
  enabled: true,
22071
22092
  prefixes: config.replication.prefixes,
22072
- allowSecrets: config.replication.allowSecrets === true
22093
+ allowSecrets: config.replication.allowSecrets === true,
22094
+ syncScope: config.replication.syncScope
22073
22095
  } : void 0
22074
22096
  });
22075
22097
  this.tc = new import_sdk_core10.TinyCloud(this.auth, {
@@ -22606,6 +22628,7 @@ var _TinyCloudNode = class _TinyCloudNode {
22606
22628
  async bootstrapAccountIfNeeded() {
22607
22629
  this._bootstrapSkipped = false;
22608
22630
  this._bootstrapStatus = { skipped: false };
22631
+ this._freshEncryptionNetworkCreated = false;
22609
22632
  if (this.config.autoBootstrapAccount === false) {
22610
22633
  this._bootstrapStatus = { skipped: true, reason: "auto-bootstrap-disabled" };
22611
22634
  return false;
@@ -22895,6 +22918,7 @@ var _TinyCloudNode = class _TinyCloudNode {
22895
22918
  }
22896
22919
  if (step.kind === "encryption-network-create") {
22897
22920
  await this.ensureEncryptionNetwork(step.networkId, { assumeMissing: mode === "fresh" });
22921
+ if (mode === "fresh") this._freshEncryptionNetworkCreated = true;
22898
22922
  }
22899
22923
  if (step.kind === "secret-records-schema") {
22900
22924
  const db = this.sqlForSpace(step.spaceId).db(step.database);
@@ -24489,7 +24513,8 @@ var _TinyCloudNode = class _TinyCloudNode {
24489
24513
  replication: this.config.replication?.enabled === true ? {
24490
24514
  enabled: true,
24491
24515
  prefixes: this.config.replication.prefixes,
24492
- allowSecrets: this.config.replication.allowSecrets === true
24516
+ allowSecrets: this.config.replication.allowSecrets === true,
24517
+ syncScope: this.config.replication.syncScope
24493
24518
  } : void 0
24494
24519
  });
24495
24520
  this.tc = new import_sdk_core10.TinyCloud(this.auth, {
@@ -24551,7 +24576,8 @@ var _TinyCloudNode = class _TinyCloudNode {
24551
24576
  replication: this.config.replication?.enabled === true ? {
24552
24577
  enabled: true,
24553
24578
  prefixes: this.config.replication.prefixes,
24554
- allowSecrets: this.config.replication.allowSecrets === true
24579
+ allowSecrets: this.config.replication.allowSecrets === true,
24580
+ syncScope: this.config.replication.syncScope
24555
24581
  } : void 0
24556
24582
  });
24557
24583
  this.tc = new import_sdk_core10.TinyCloud(this.auth, {