@kubun/credential 0.14.2 → 0.15.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/api.d.ts +9 -0
- package/lib/api.js +3 -0
- package/lib/manager.d.ts +1 -1
- package/lib/manager.js +7 -3
- package/package.json +8 -8
package/lib/api.d.ts
CHANGED
|
@@ -37,6 +37,15 @@ export type CredentialAPI = {
|
|
|
37
37
|
credential: string;
|
|
38
38
|
}) => Promise<void>;
|
|
39
39
|
deleteCredential: (providerName: string, ownerDID: string) => Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* The normalized owner DIDs that currently hold a credential for `providerName`.
|
|
42
|
+
*
|
|
43
|
+
* A credential is pointed at by an alias keyed `(providerName, normalizeDID(
|
|
44
|
+
* ownerDID))`, so the alias keys under a provider namespace are exactly its
|
|
45
|
+
* authenticated owners — already normalized, so a caller can key sync state or
|
|
46
|
+
* a schedule on them directly. Empty when no owner holds one.
|
|
47
|
+
*/
|
|
48
|
+
listSubjects: (providerName: string) => Promise<Array<string>>;
|
|
40
49
|
/**
|
|
41
50
|
* The controller resolvers for this API's (request-scoped) transaction
|
|
42
51
|
* provider — the exact `methods` the credential mint passes to `createKey`.
|
package/lib/api.js
CHANGED
|
@@ -6,6 +6,9 @@ export function createCredentialAPI(params) {
|
|
|
6
6
|
const getAliasStore = ()=>getCredentialStore(params.stores);
|
|
7
7
|
const getCredentials = ()=>params.getCredentialManager(params.stores);
|
|
8
8
|
return {
|
|
9
|
+
async listSubjects (providerName) {
|
|
10
|
+
return (await getAliasStore()).listAliasKeys(providerName);
|
|
11
|
+
},
|
|
9
12
|
async getCredential (providerName, ownerDID) {
|
|
10
13
|
const store = await getAliasStore();
|
|
11
14
|
const entryID = await store.getAliasEntryID(providerName, normalizeDID(ownerDID));
|
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
|
-
|
|
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,
|
|
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.
|
|
3
|
+
"version": "0.15.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.
|
|
21
|
-
"@kubun/db": "^0.
|
|
22
|
-
"@kubun/hlc": "^0.
|
|
23
|
-
"@kubun/id": "^0.
|
|
24
|
-
"@kubun/logger": "^0.
|
|
25
|
-
"@kubun/store-credential": "^0.
|
|
20
|
+
"@kubun/credential-types": "^0.15.0",
|
|
21
|
+
"@kubun/db": "^0.15.0",
|
|
22
|
+
"@kubun/hlc": "^0.15.0",
|
|
23
|
+
"@kubun/id": "^0.15.0",
|
|
24
|
+
"@kubun/logger": "^0.15.0",
|
|
25
|
+
"@kubun/store-credential": "^0.15.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.
|
|
33
|
+
"@kubun/db-better-sqlite": "^0.15.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|