@fireproof/core 0.20.0-dev-preview-25 → 0.20.0-dev-preview-26
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 +0 -1
- package/index.cjs +17 -13
- package/index.cjs.map +1 -1
- package/index.d.cts +4 -2
- package/index.d.ts +4 -2
- package/index.js +17 -13
- package/index.js.map +1 -1
- package/metafile-cjs.json +1 -1
- package/metafile-esm.json +1 -1
- package/package.json +2 -2
- package/tests/blockstore/keyed-crypto.test.ts +39 -4
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
@@ -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
|
-
|
765
|
-
|
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
|
-
|
771
|
+
throw this.keybag.logger.Error().Msg("KeyBag: keysByFingerprint: no default").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
|
-
|
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
|
-
|
794
|
-
this.keys[kfp.fingerPrint] = out;
|
796
|
+
this.keys[kfp.fingerPrint] = found;
|
795
797
|
if (def) {
|
796
|
-
this.keys["*"] =
|
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:
|
805
|
+
kfp: found
|
804
806
|
});
|
805
807
|
}
|
806
808
|
async asKeysItem() {
|
@@ -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());
|
@@ -3173,6 +3176,7 @@ var noCrypto = class {
|
|
3173
3176
|
this.logger = ensureLogger(sthis, "noCrypto");
|
3174
3177
|
this.crypto = cyrt;
|
3175
3178
|
this.key = {
|
3179
|
+
id: sthis.nextId().str,
|
3176
3180
|
name: "noCrypto",
|
3177
3181
|
get: () => {
|
3178
3182
|
throw this.logger.Error().Msg("noCrypto.get not implemented").AsError();
|
@@ -4946,6 +4950,6 @@ __export(file_exports, {
|
|
4946
4950
|
|
4947
4951
|
// src/version.ts
|
4948
4952
|
var PACKAGE_VERSION = Object.keys({
|
4949
|
-
"0.20.0-dev-preview-
|
4953
|
+
"0.20.0-dev-preview-26": "xxxx"
|
4950
4954
|
})[0];
|
4951
4955
|
//# sourceMappingURL=index.cjs.map
|