@fireproof/core 0.20.0-dev-preview-25 → 0.20.0-dev-preview-27

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/deno.json CHANGED
@@ -7,7 +7,6 @@
7
7
  "@fireproof/vendor": "npm:@fireproof/vendor@^1.1.0-dev",
8
8
  "cborg": "npm:cborg@^4.2.8",
9
9
  "ipfs-unixfs-exporter": "npm:ipfs-unixfs-exporter@^13.6.1",
10
- "@adviser/cement": "npm:@adviser/cement@^0.3.11",
11
10
  "multiformats": "npm:multiformats@^13.3.1",
12
11
  "@ipld/unixfs": "npm:@ipld/unixfs@^3.0.0",
13
12
  "charwise": "npm:charwise@^3.0.1",
package/index.cjs CHANGED
@@ -637,7 +637,7 @@ var KeyBagProviderFile = class {
637
637
  if (isNotFoundError(e)) {
638
638
  return void 0;
639
639
  }
640
- throw this.logger.Error().Err(e).Str("file", ctx.dirName).Msg("read bag failed").AsError();
640
+ throw this.logger.Error().Err(e).Any("file", ctx).Msg("read bag failed").AsError();
641
641
  }
642
642
  }
643
643
  async set(item) {
@@ -737,6 +737,7 @@ var keysByFingerprint = class _keysByFingerprint {
737
737
  this.keys = {};
738
738
  this.keybag = keyBag;
739
739
  this.name = name;
740
+ this.id = keyBag.rt.sthis.nextId(4).str;
740
741
  }
741
742
  static async from(keyBag, named) {
742
743
  const kbf = new _keysByFingerprint(keyBag, named.name);
@@ -760,23 +761,23 @@ var keysByFingerprint = class _keysByFingerprint {
760
761
  async get(fingerPrint) {
761
762
  if (fingerPrint instanceof Uint8Array) {
762
763
  fingerPrint = import_base582.base58btc.encode(fingerPrint);
764
+ } else {
765
+ fingerPrint = fingerPrint || "*";
763
766
  }
764
- if (fingerPrint) {
765
- return this.keys[fingerPrint];
766
- }
767
- const def = this.keys["*"];
768
- if (!def) {
769
- throw this.keybag.logger.Error().Msg("KeyBag: keysByFingerprint: no default").AsError();
767
+ const found = this.keys[fingerPrint];
768
+ if (found) {
769
+ return found;
770
770
  }
771
- return def;
771
+ throw this.keybag.logger.Error().Str("fpr", fingerPrint).Any("fprs", Object.keys(this.keys)).Msg("keysByFingerprint: not found").AsError();
772
772
  }
773
773
  async upsert(materialStrOrUint8, def, keyBagAction = true) {
774
+ def = !!def;
774
775
  const rKfp = await toKeyWithFingerPrint(this.keybag, materialStrOrUint8);
775
776
  if (rKfp.isErr()) {
776
777
  return import_cement4.Result.Err(rKfp);
777
778
  }
778
779
  const kfp = rKfp.Ok();
779
- const found = this.keys[kfp.fingerPrint];
780
+ let found = this.keys[kfp.fingerPrint];
780
781
  if (found) {
781
782
  if (found.default === def) {
782
783
  return import_cement4.Result.Ok({
@@ -784,23 +785,24 @@ var keysByFingerprint = class _keysByFingerprint {
784
785
  kfp: found
785
786
  });
786
787
  }
788
+ } else {
789
+ found = new keyWithFingerPrint(kfp, materialStrOrUint8, def);
787
790
  }
788
791
  if (def) {
789
792
  for (const i of Object.values(this.keys)) {
790
793
  i.default = false;
791
794
  }
792
795
  }
793
- const out = new keyWithFingerPrint(kfp, materialStrOrUint8, def);
794
- this.keys[kfp.fingerPrint] = out;
796
+ this.keys[kfp.fingerPrint] = found;
795
797
  if (def) {
796
- this.keys["*"] = out;
798
+ this.keys["*"] = found;
797
799
  }
798
800
  if (keyBagAction) {
799
801
  this.keybag._upsertNamedKey(this);
800
802
  }
801
803
  return import_cement4.Result.Ok({
802
804
  modified: keyBagAction && true,
803
- kfp: out
805
+ kfp: found
804
806
  });
805
807
  }
806
808
  async asKeysItem() {
@@ -883,7 +885,7 @@ var KeyBag = class {
883
885
  const keyName = `@${keyFactory()}@`;
884
886
  const ret = await this.getNamedKey(keyName);
885
887
  if (ret.isErr()) {
886
- return ret;
888
+ return import_cement4.Result.Err(ret);
887
889
  }
888
890
  const urb = url.build().setParam(PARAM.STORE_KEY, keyName);
889
891
  return import_cement4.Result.Ok(urb.URI());
@@ -891,7 +893,7 @@ var KeyBag = class {
891
893
  if (storeKey.startsWith("@") && storeKey.endsWith("@")) {
892
894
  const ret = await this.getNamedKey(storeKey);
893
895
  if (ret.isErr()) {
894
- return ret;
896
+ return import_cement4.Result.Err(ret);
895
897
  }
896
898
  }
897
899
  return import_cement4.Result.Ok(url);
@@ -949,6 +951,7 @@ var KeyBag = class {
949
951
  return this._seq.add(async () => {
950
952
  const rKbf = await this._getNamedKey(ksi.name, true);
951
953
  if (rKbf.isErr()) {
954
+ this.logger.Error().Err(rKbf).Str("name", ksi.name).Msg("_upsertNamedKey: getNamedKey failed");
952
955
  this._namedKeyCache.unget(ksi.name);
953
956
  }
954
957
  await bag.set(await ksi.asKeysItem());
@@ -1254,6 +1257,7 @@ var MEMORY_VERSION = "v0.19-memory";
1254
1257
 
1255
1258
  // src/runtime/gateways/memory/gateway.ts
1256
1259
  var MemoryGateway = class {
1260
+ // readonly logger: Logger;
1257
1261
  constructor(sthis, memorys) {
1258
1262
  this.memorys = memorys;
1259
1263
  this.sthis = sthis;
@@ -3173,6 +3177,7 @@ var noCrypto = class {
3173
3177
  this.logger = ensureLogger(sthis, "noCrypto");
3174
3178
  this.crypto = cyrt;
3175
3179
  this.key = {
3180
+ id: sthis.nextId().str,
3176
3181
  name: "noCrypto",
3177
3182
  get: () => {
3178
3183
  throw this.logger.Error().Msg("noCrypto.get not implemented").AsError();
@@ -4748,7 +4753,7 @@ var LedgerImpl = class {
4748
4753
  this.crdt.clock.onTock(() => this._no_update_notify());
4749
4754
  }
4750
4755
  get name() {
4751
- return this.opts.storeUrls.data.data.getParam(PARAM.NAME) ?? "default";
4756
+ return this.opts.name;
4752
4757
  }
4753
4758
  addShell(shell) {
4754
4759
  this.shells.add(shell);
@@ -4946,6 +4951,6 @@ __export(file_exports, {
4946
4951
 
4947
4952
  // src/version.ts
4948
4953
  var PACKAGE_VERSION = Object.keys({
4949
- "0.20.0-dev-preview-25": "xxxx"
4954
+ "0.20.0-dev-preview-27": "xxxx"
4950
4955
  })[0];
4951
4956
  //# sourceMappingURL=index.cjs.map