@kubun/credential 0.14.3 → 0.16.0

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/lib/manager.d.ts CHANGED
@@ -200,7 +200,7 @@ export type CredentialManager = {
200
200
  /** Zero the cached content key. TTL eviction does the same thing. */
201
201
  lock(keyID: string): void;
202
202
  lockAll(): void;
203
- status(keyID: string): Promise<CredentialKeyStatus>;
203
+ status(keyID: string, version?: number): Promise<CredentialKeyStatus>;
204
204
  /**
205
205
  * Add a factor to THIS device's wrapping, leaving every other recipient's
206
206
  * alone. Adding a `pin` therefore gates this device and no other, which is the
package/lib/manager.js CHANGED
@@ -480,7 +480,7 @@ export function createCredentialManager(params) {
480
480
  lockAllEpoch += 1;
481
481
  cache.evictAll();
482
482
  },
483
- async status (keyID) {
483
+ async status (keyID, version) {
484
484
  const key = await store.getKey(keyID);
485
485
  if (key == null) {
486
486
  throw new CredentialNotFound('Credential key', keyID);
@@ -494,12 +494,16 @@ export function createCredentialManager(params) {
494
494
  reason: 'unsupported-suite'
495
495
  };
496
496
  }
497
- if (cache.has(keyID, key.version)) {
497
+ // Defaults to the key's current version; a caller checking a manifest
498
+ // target passes the expected version so a stale wrapping is never
499
+ // reported openable for a newer one, or vice versa.
500
+ const targetVersion = version ?? key.version;
501
+ if (cache.has(keyID, targetVersion)) {
498
502
  return {
499
503
  state: 'unlocked'
500
504
  };
501
505
  }
502
- const wrappings = await store.listWrappings(keyID, key.version);
506
+ const wrappings = await store.listWrappings(keyID, targetVersion);
503
507
  if (wrappings.length === 0) {
504
508
  return {
505
509
  state: 'unopenable',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/credential",
3
- "version": "0.14.3",
3
+ "version": "0.16.0",
4
4
  "keywords": [],
5
5
  "license": "see LICENSE.md",
6
6
  "sideEffects": false,
@@ -17,12 +17,12 @@
17
17
  "dependencies": {
18
18
  "@kokuin/jwe": "^0.1.0",
19
19
  "@kokuin/token": "^0.5.0",
20
- "@kubun/credential-types": "^0.14.0",
21
- "@kubun/db": "^0.14.0",
22
- "@kubun/hlc": "^0.14.0",
23
- "@kubun/id": "^0.14.0",
24
- "@kubun/logger": "^0.14.0",
25
- "@kubun/store-credential": "^0.14.1",
20
+ "@kubun/credential-types": "^0.16.0",
21
+ "@kubun/db": "^0.16.0",
22
+ "@kubun/hlc": "^0.16.0",
23
+ "@kubun/id": "^0.16.0",
24
+ "@kubun/logger": "^0.16.0",
25
+ "@kubun/store-credential": "^0.16.0",
26
26
  "@noble/ciphers": "^2.4.0",
27
27
  "@noble/hashes": "^2.4.0",
28
28
  "@sozai/codec": "^0.4.0",
@@ -30,7 +30,7 @@
30
30
  "@sozai/runtime": "^0.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@kubun/db-better-sqlite": "^0.14.0"
33
+ "@kubun/db-better-sqlite": "^0.16.0"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"