@enbox/dids 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dids",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "TBD DIDs library",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -80,8 +80,8 @@
80
80
  "dependencies": {
81
81
  "@decentralized-identity/ion-sdk": "1.0.4",
82
82
  "@dnsquery/dns-packet": "6.1.1",
83
- "@enbox/common": "0.0.5",
84
- "@enbox/crypto": "0.0.6",
83
+ "@enbox/common": "0.0.6",
84
+ "@enbox/crypto": "0.0.7",
85
85
  "abstract-level": "1.0.4",
86
86
  "bencode": "4.0.0",
87
87
  "level": "8.0.1",
@@ -87,6 +87,16 @@ export class DidResolverCacheLevel implements DidResolverCache {
87
87
  this.ttl = ms(ttl);
88
88
  }
89
89
 
90
+ /**
91
+ * Opens the underlying LevelDB store.
92
+ * Calling `open()` on an already-open store is a safe no-op.
93
+ *
94
+ * @returns A promise that resolves when the store is ready for use.
95
+ */
96
+ open(): Promise<void> {
97
+ return this.cache.open();
98
+ }
99
+
90
100
  /**
91
101
  * Retrieves a DID resolution result from the cache.
92
102
  *
@@ -26,6 +26,13 @@ export class DidResolverCacheMemory implements DidResolverCache {
26
26
  this.cache = new TtlCache({ ttl: ms(ttl) });
27
27
  }
28
28
 
29
+ /**
30
+ * This method is a no-op since in-memory stores are always ready.
31
+ */
32
+ public async open(): Promise<void> {
33
+ // No-op since there is no underlying store to open.
34
+ }
35
+
29
36
  /**
30
37
  * Retrieves a DID resolution result from the cache.
31
38
  *
@@ -8,6 +8,9 @@ import type { DidResolverCache } from '../types/did-resolution.js';
8
8
  * potential for this library to be used in as many JS runtimes as possible.
9
9
  */
10
10
  export const DidResolverCacheNoop: DidResolverCache = {
11
+ open(): Promise<void> {
12
+ return Promise.resolve();
13
+ },
11
14
  get(_key: string): Promise<DidResolutionResult | void> {
12
15
  return Promise.resolve(undefined);
13
16
  },
@@ -86,6 +86,22 @@ export class UniversalResolver implements DidResolver, DidUrlDereferencer {
86
86
  }
87
87
  }
88
88
 
89
+ /**
90
+ * Opens the resolver's cache, acquiring any resources needed.
91
+ * Must be called before resolving DIDs if using a cache that requires initialization (e.g., LevelDB).
92
+ */
93
+ public async open(): Promise<void> {
94
+ await this.cache.open();
95
+ }
96
+
97
+ /**
98
+ * Closes the resolver's cache, releasing any resources held.
99
+ * Should be called during application shutdown.
100
+ */
101
+ public async close(): Promise<void> {
102
+ await this.cache.close();
103
+ }
104
+
89
105
  /**
90
106
  * Resolves a DID to a DID Resolution Result.
91
107
  *