@kubun/store-delegation 0.12.0 → 0.13.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/revocation-checker.d.ts +7 -1
- package/lib/revocation-checker.js +14 -3
- package/package.json +12 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type VerifyTokenHook } from '@kokuin/capability';
|
|
2
|
+
import { type MethodRegistry } from '@kokuin/token';
|
|
2
3
|
import type { DelegationStoreAPI } from './api.js';
|
|
3
4
|
export type RevocationClaims = {
|
|
4
5
|
jti: string;
|
|
@@ -17,5 +18,10 @@ export type RevocationClaims = {
|
|
|
17
18
|
* kokuin's checker still re-verifies the record's signature and re-compares the
|
|
18
19
|
* issuer, so a row this device could not cross-check against a locally held
|
|
19
20
|
* grant is safe to hand over.
|
|
21
|
+
*
|
|
22
|
+
* `methods` resolves the record's issuer: a revocation whose `iss` is a
|
|
23
|
+
* `did:kokuin:` controller DID cannot verify from the identifier alone, so
|
|
24
|
+
* without the registry it fails to resolve, is dropped, and the revoked
|
|
25
|
+
* capability passes (fail-open). Optional so non-controller callers stay 1-arg.
|
|
20
26
|
*/
|
|
21
|
-
export declare function createDelegationRevocationChecker(api: DelegationStoreAPI): VerifyTokenHook;
|
|
27
|
+
export declare function createDelegationRevocationChecker(api: DelegationStoreAPI, methods?: MethodRegistry): VerifyTokenHook;
|
|
@@ -11,7 +11,12 @@ import { verifyToken } from '@kokuin/token';
|
|
|
11
11
|
* kokuin's checker still re-verifies the record's signature and re-compares the
|
|
12
12
|
* issuer, so a row this device could not cross-check against a locally held
|
|
13
13
|
* grant is safe to hand over.
|
|
14
|
-
|
|
14
|
+
*
|
|
15
|
+
* `methods` resolves the record's issuer: a revocation whose `iss` is a
|
|
16
|
+
* `did:kokuin:` controller DID cannot verify from the identifier alone, so
|
|
17
|
+
* without the registry it fails to resolve, is dropped, and the revoked
|
|
18
|
+
* capability passes (fail-open). Optional so non-controller callers stay 1-arg.
|
|
19
|
+
*/ export function createDelegationRevocationChecker(api, methods) {
|
|
15
20
|
// The backend is per-token: its `get` closes over the issuer of the
|
|
16
21
|
// capability being checked, which is only known once the hook is called.
|
|
17
22
|
return async (token, raw)=>{
|
|
@@ -30,7 +35,11 @@ import { verifyToken } from '@kokuin/token';
|
|
|
30
35
|
return undefined;
|
|
31
36
|
}
|
|
32
37
|
try {
|
|
33
|
-
|
|
38
|
+
// Carries `methods` so a controller-issued (`did:kokuin:`) record can
|
|
39
|
+
// resolve; must match the checker's own verify below or the two drift.
|
|
40
|
+
return await verifyToken(row.revocation_token, {
|
|
41
|
+
methods
|
|
42
|
+
});
|
|
34
43
|
} catch {
|
|
35
44
|
// A stored record that no longer verifies revokes nothing. The checker
|
|
36
45
|
// re-verifies too, but failing here keeps a corrupt row from surfacing.
|
|
@@ -38,6 +47,8 @@ import { verifyToken } from '@kokuin/token';
|
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
};
|
|
41
|
-
await createRevocationChecker(backend
|
|
50
|
+
await createRevocationChecker(backend, {
|
|
51
|
+
methods
|
|
52
|
+
})(token, raw);
|
|
42
53
|
};
|
|
43
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/store-delegation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"license": "see LICENSE.md",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -15,17 +15,20 @@
|
|
|
15
15
|
"LICENSE.md"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@kokuin/capability": "^0.
|
|
19
|
-
"@kokuin/token": "^0.
|
|
20
|
-
"kysely": "^0.29.
|
|
21
|
-
"@kubun/db": "^0.
|
|
22
|
-
"@kubun/db
|
|
23
|
-
"@kubun/logger": "^0.
|
|
18
|
+
"@kokuin/capability": "^0.3.0",
|
|
19
|
+
"@kokuin/token": "^0.5.0",
|
|
20
|
+
"kysely": "^0.29.5",
|
|
21
|
+
"@kubun/db-adapter": "^0.13.0",
|
|
22
|
+
"@kubun/db": "^0.13.0",
|
|
23
|
+
"@kubun/logger": "^0.13.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@testcontainers/postgresql": "^12.1.0",
|
|
27
|
-
"@kubun/db-
|
|
28
|
-
"@kubun/db-
|
|
27
|
+
"@kubun/db-postgres": "^0.13.0",
|
|
28
|
+
"@kubun/db-better-sqlite": "^0.13.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
29
32
|
},
|
|
30
33
|
"scripts": {
|
|
31
34
|
"build": "pnpm run build:clean && pnpm run build:js && pnpm run build:types",
|