@teikyo/access 0.4.0 → 0.5.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/patterns.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { hasPartsMatch } from '@kokuin/capability';
2
2
  /** Whether an access pattern covers a procedure, using the matcher Enkaku applies to access rules. */ export function patternMatches(pattern, procedure) {
3
- return hasPartsMatch(procedure, pattern);
3
+ return hasPartsMatch({
4
+ expected: procedure,
5
+ actual: pattern
6
+ });
4
7
  }
5
8
  function baseOf(pattern) {
6
9
  return pattern.endsWith('/*') ? pattern.slice(0, -2) : pattern;
@@ -25,4 +25,7 @@ export type RevocationHookParams = {
25
25
  * a revocation are logged through `onError` and surface as `Access denied`, because Enkaku copies
26
26
  * error messages to the client.
27
27
  */
28
- export declare function createRevocationHook(params: RevocationHookParams): (token: SignedToken, raw: string) => Promise<void>;
28
+ export declare function createRevocationHook(params: RevocationHookParams): (params: {
29
+ token: SignedToken;
30
+ raw: string;
31
+ }) => Promise<void>;
@@ -21,8 +21,10 @@ function toRecord(row) {
21
21
  return (db)=>{
22
22
  return {
23
23
  async add (record) {
24
- const verified = await verifyToken(record, {
24
+ const verified = await verifyToken({
25
+ token: record,
25
26
  historic: true,
27
+ crypto: options.crypto,
26
28
  resolver: options.resolver,
27
29
  cache: options.cache,
28
30
  methods: options.methods
@@ -44,7 +46,7 @@ function toRecord(row) {
44
46
  'jti'
45
47
  ]).doNothing()).execute();
46
48
  },
47
- async get (jti, issuer) {
49
+ async get ({ jti, issuer }) {
48
50
  const row = await db.selectFrom('revocations').select([
49
51
  'data',
50
52
  'signature'
@@ -67,12 +69,18 @@ function toRecord(row) {
67
69
  * error messages to the client.
68
70
  */ export function createRevocationHook(params) {
69
71
  // Parameter widened to any signed token so plain invocation tokens can be checked too.
70
- return async (token, raw)=>{
72
+ return async ({ token, raw })=>{
71
73
  if (params.requireJTI && token.payload.jti == null) {
72
74
  throw new Error('Token without jti rejected');
73
75
  }
74
76
  try {
75
- await createRevocationChecker(params.backend, params.options)(token, raw);
77
+ await createRevocationChecker({
78
+ ...params.options,
79
+ backend: params.backend
80
+ })({
81
+ token: token,
82
+ raw
83
+ });
76
84
  } catch (cause) {
77
85
  if (cause instanceof Error && cause.message.startsWith('Token revoked:')) {
78
86
  throw cause;
@@ -6,7 +6,10 @@ import { type RevocationStoreAPI } from './backend.js';
6
6
  export type AccessRevocation = {
7
7
  backend: RevocationStoreAPI;
8
8
  /** Enkaku `verifyToken` hook rejecting revoked signed tokens. */
9
- verifyToken: (token: SignedToken, raw: string) => Promise<void>;
9
+ verifyToken: (params: {
10
+ token: SignedToken;
11
+ raw: string;
12
+ }) => Promise<void>;
10
13
  };
11
14
  export declare const ACCESS_REVOCATION: import("@sozai/http-server").PluginName<"access:revocation", AccessRevocation>;
12
15
  export type AccessRevocationPluginParams = RevocationOptions & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teikyo/access",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Access grants and revocation for Enkaku servers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,20 +19,21 @@
19
19
  "lib/*"
20
20
  ],
21
21
  "dependencies": {
22
- "@enkaku/server": "^0.22.2",
23
- "@hozon/db": "^0.5.0",
24
- "@kokuin/capability": "^0.5.2",
25
- "@kokuin/token": "^0.6.2",
26
- "@sozai/codec": "^0.4.3",
22
+ "@enkaku/server": "^0.23.0",
23
+ "@hozon/db": "^0.5.1",
24
+ "@kokuin/capability": "^0.7.0",
25
+ "@kokuin/token": "^0.7.0",
26
+ "@sozai/codec": "^0.4.4",
27
27
  "@sozai/http-server": "^0.2.1",
28
28
  "@sozai/log": "^0.4.0",
29
29
  "@teikyo/hozon": "^0.4.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@hozon/provider": "^0.3.0",
33
- "@types/node": "^26.6.5",
32
+ "@hozon/provider": "^0.3.1",
33
+ "@kokuin/crypto": "^0.7.0",
34
+ "@types/node": "^26.6.6",
34
35
  "del-cli": "^8.0.1",
35
- "vitest": "5.0.5"
36
+ "vitest": "5.1.0"
36
37
  },
37
38
  "engines": {
38
39
  "node": ">=24"