@owlmeans/auth-common 0.2.4-rc.0 → 0.2.4

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/README.md CHANGED
@@ -12,7 +12,7 @@ Predefined authentication protocols, guards, and constants shared between server
12
12
  ## Installation
13
13
 
14
14
  ```bash
15
- bun add @owlmeans/auth-common@^0.2.4-rc.0
15
+ bun add @owlmeans/auth-common@^0.2.4
16
16
  ```
17
17
 
18
18
  ## Usage
@@ -74,6 +74,7 @@ GUARD_ED25519 // guard name for Basic ED25519 signature authentication
74
74
  ```typescript
75
75
  BED255_NONCE_HEADER // 'X-Auth-Nonce'
76
76
  BED255_TIME_HEADER // 'X-Auth-Time'
77
+ BED255_AUTH_SCHEME // 'ED25519-BASIC-SIGNATURE', the Authorization scheme of a signed request
77
78
  BED255_CASHE_RESOURCE // resource alias for nonce cache
78
79
  ```
79
80
 
@@ -84,6 +85,10 @@ BED255_CASHE_RESOURCE // resource alias for nonce cache
84
85
  signer's trusted-record `id`, `key` a `KeyPairModel` with the private key. It answers
85
86
  `{ authorization, headers }` — send both, with the body unchanged.
86
87
 
88
+ A request the guard refuses — a malformed signature header, a timestamp that is not an exact ISO
89
+ instant, a missing or replayed nonce, a signature outside its window — throws `AuthenSignatureError`
90
+ from `@owlmeans/auth`, which `@owlmeans/server-api` answers with 401.
91
+
87
92
  A body of raw bytes (a `Blob`, an `ArrayBuffer`, a typed array, a Node stream — what a streamed-body
88
93
  route carries) is signed as `{}` by both the signer and the guard: the signature proves the caller and
89
94
  the moment, never the bytes. A route that must prove its bytes declares their digest (in the query)
@@ -101,7 +106,7 @@ await fetch(url, {
101
106
  })
102
107
  ```
103
108
 
104
- ## Product-Viable Integration Notes
109
+ ## OwlMeans Platform integration notes
105
110
 
106
111
  - `DEFAULT_GUARD` protects manager routes after bearer authentication is installed by `@owlmeans/server-auth`.
107
112
  - Product authorization composes a custom gate in the protocol options rather than using `OIDC_GATE` for Google login flows.
@@ -122,7 +127,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
122
127
  your project's skill store (`.agents/skills/`):
123
128
 
124
129
  ```sh
125
- npx @owlmeans/agent-skills@^0.2.4-rc.1
130
+ npx @owlmeans/agent-skills@^0.2.4
126
131
  ```
127
132
 
128
133
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 3,
3
3
  "package": "@owlmeans/auth-common",
4
- "version": "0.2.4-rc.0",
5
- "generatedAt": "2026-11-25T14:32:53.671Z",
4
+ "version": "0.2.4",
5
+ "generatedAt": "2026-12-03T17:23:31.441Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/auth-common
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/auth-common": "^0.2.4-rc.0"` in `dependencies`
11
+ **Install:** `"@owlmeans/auth-common": "^0.2.4"` in `dependencies`
12
12
 
13
13
  Everything a server and a browser must agree on to talk authentication: aliases, the shared
14
14
  protocol declarations, the signature guard, and the contract for resolving the organization
@@ -29,6 +29,7 @@ entity a token names.
29
29
  | `ENTITY_SLUG_PATTERN` | A lowercase DNS label. Slugs compose hostnames, cluster object names and OIDC client ids, so anything needing sanitising is rejected where it is chosen |
30
30
  | `RELY_PIN_PERFIX`, `RELY_TOKEN_PREFIX`, `RELY_CALL_TIMEOUT`, `RELY_ACTION_TIMEOUT` | Rely-handshake constants |
31
31
  | `BED255_TIME_HEADER`, `BED255_NONCE_HEADER`, `BED255_SIG_TTL`, `BED255_DELIVERY_TTL`, `BED255_CASHE_RESOURCE` | Ed25519 signature-guard headers, replay window, a queued claim's lifetime and nonce-cache alias |
32
+ | `BED255_AUTH_SCHEME` | `'ED25519-BASIC-SIGNATURE'` — the `Authorization` scheme of a signed request; `@owlmeans/api` reads it to keep a refused signature from ending a session |
32
33
  | `authApi` | Alias tree for the manager API entrypoints (`profile`, `entity`, `auth`) |
33
34
 
34
35
  ### Entrypoints, guard and middleware
@@ -151,6 +152,7 @@ token's slug only; both write `'-'` when neither is available. Read the gate you
151
152
  the same job's first attempt, or over HTTP stays a replay (`nonce`), and a request past the window
152
153
  with no such claim stays `expired`. A custom `SignedRequestReplayStore` without `holder` (or a
153
154
  resource without `load`) recognises no redelivery.
155
+ - **Every refusal the guard throws is an `AuthenSignatureError`** (`signature`, `timestamp`, `nonce`, `expired`): an `AuthenPayloadError` that declares `httpStatus = 401`, so a refused signature answers 401 like one that fails to verify (the guard returns `false` for that, and server-api answers 401). Match the family with `AuthenPayloadError` or the class itself; never compare the message.
154
156
  - **A queued request is judged fresh at its enqueue.** A delivery carrying `enqueuedAt` (the broker's
155
157
  own stamp) AND `maxAge` (the queue's `envelopeTtl`) is fresh when its signature lies within 60 s of
156
158
  that enqueue and the enqueue within `maxAge` of now — a job that waited behind a backlog or a deploy
@@ -1,4 +1,6 @@
1
1
  export declare const GUARD_ED25519 = "guard:ed25519-basic-signature";
2
+ /** The `Authorization` scheme of a request signed with this guard's Ed25519 signature. */
3
+ export declare const BED255_AUTH_SCHEME: string;
2
4
  export declare const BED255_TIME_HEADER = "X-Auth-Time";
3
5
  export declare const BED255_NONCE_HEADER = "X-Auth-Nonce";
4
6
  export declare const BED255_SIG_TTL: number;
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,kCAAqD,CAAA;AAE/E,eAAO,MAAM,kBAAkB,gBAAgB,CAAA;AAC/C,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AAEjD,eAAO,MAAM,cAAc,QAAY,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAiB,CAAA;AAEjD,eAAO,MAAM,qBAAqB,8BAA8B,CAAA"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,kCAAqD,CAAA;AAE/E,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB,QAAwD,CAAA;AAEvF,eAAO,MAAM,kBAAkB,gBAAgB,CAAA;AAC/C,eAAO,MAAM,mBAAmB,iBAAiB,CAAA;AAEjD,eAAO,MAAM,cAAc,QAAY,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAiB,CAAA;AAEjD,eAAO,MAAM,qBAAqB,8BAA8B,CAAA"}
@@ -1,5 +1,7 @@
1
1
  import { AuthroizationType } from '@owlmeans/auth';
2
2
  export const GUARD_ED25519 = `guard:${AuthroizationType.Ed25519BasicSignature}`;
3
+ /** The `Authorization` scheme of a request signed with this guard's Ed25519 signature. */
4
+ export const BED255_AUTH_SCHEME = AuthroizationType.Ed25519BasicSignature.toUpperCase();
3
5
  export const BED255_TIME_HEADER = 'X-Auth-Time';
4
6
  export const BED255_NONCE_HEADER = 'X-Auth-Nonce';
5
7
  export const BED255_SIG_TTL = 60 * 1000;
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,iBAAiB,CAAC,qBAAqB,EAAE,CAAA;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAA;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAA"}
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,iBAAiB,CAAC,qBAAqB,EAAE,CAAA;AAE/E,0FAA0F;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,WAAW,EAAE,CAAA;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAA;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAA;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAA"}
@@ -3,7 +3,7 @@ import { assertContext } from '@owlmeans/context';
3
3
  import { BED255_CASHE_RESOURCE, BED255_DELIVERY_TTL, GUARD_ED25519, BED255_SIG_TTL } from './consts.js';
4
4
  import { nonceKey, timeKey } from './consts.local.js';
5
5
  import { trust } from '../../utils/trusted.js';
6
- import { AuthenPayloadError, AuthroizationType, AuthRole } from '@owlmeans/auth';
6
+ import { AuthenSignatureError, AuthroizationType, AuthRole } from '@owlmeans/auth';
7
7
  import { extractAuthToken } from '@owlmeans/auth-common/utils';
8
8
  import { makeMemorySignedRequestReplayStore, makeResourceSignedRequestReplayStore } from './replay.js';
9
9
  import { signBasicEd25519Request } from './sign.js';
@@ -52,7 +52,7 @@ export const makeBasicEd25519Guard = (resource, opts) => {
52
52
  }, {});
53
53
  if (typeof signature.credential !== 'string' || signature.credential.length === 0
54
54
  || typeof signature.signature !== 'string' || signature.signature.length === 0) {
55
- throw new AuthenPayloadError('signature');
55
+ throw new AuthenSignatureError('signature');
56
56
  }
57
57
  const trusted = await trust(context, resource, signature.credential, "id");
58
58
  if (trusted.user.credential == null) {
@@ -65,12 +65,12 @@ export const makeBasicEd25519Guard = (resource, opts) => {
65
65
  return false;
66
66
  }
67
67
  if (typeof timestamp !== 'string') {
68
- throw new AuthenPayloadError('timestamp');
68
+ throw new AuthenSignatureError('timestamp');
69
69
  }
70
70
  const createdAt = new Date(timestamp);
71
71
  const signedAt = createdAt.getTime();
72
72
  if (!Number.isFinite(signedAt) || createdAt.toISOString() !== timestamp) {
73
- throw new AuthenPayloadError('timestamp');
73
+ throw new AuthenSignatureError('timestamp');
74
74
  }
75
75
  const now = Date.now();
76
76
  const delivery = req.delivery;
@@ -86,7 +86,7 @@ export const makeBasicEd25519Guard = (resource, opts) => {
86
86
  || now - queued.enqueuedAt > queued.maxAge
87
87
  : Math.abs(now - signedAt) > BED255_SIG_TTL;
88
88
  if (typeof nonce !== 'string' || nonce.length === 0) {
89
- throw new AuthenPayloadError(expired ? 'expired' : 'nonce');
89
+ throw new AuthenSignatureError(expired ? 'expired' : 'nonce');
90
90
  }
91
91
  // The replay identity is the signing credential plus its nonce. A nonce used by one trusted
92
92
  // service does not block another, while a captured request can be admitted once.
@@ -102,7 +102,7 @@ export const makeBasicEd25519Guard = (resource, opts) => {
102
102
  // Past the window only a redelivery stands, and only where the queue sets no window of its
103
103
  // own: its claim proves the job was admitted inside the signature's.
104
104
  if (queued != null || !await redelivered().catch(() => false)) {
105
- throw new AuthenPayloadError('expired');
105
+ throw new AuthenSignatureError('expired');
106
106
  }
107
107
  }
108
108
  else {
@@ -114,11 +114,11 @@ export const makeBasicEd25519Guard = (resource, opts) => {
114
114
  ? new Date(Math.max(signedAt + BED255_SIG_TTL + (queued?.maxAge ?? 0), now + (opts?.deliveryTtl ?? BED255_DELIVERY_TTL)))
115
115
  : new Date(signedAt + BED255_SIG_TTL), delivery?.id);
116
116
  if (!claimed && !await redelivered()) {
117
- throw new AuthenPayloadError('nonce');
117
+ throw new AuthenSignatureError('nonce');
118
118
  }
119
119
  }
120
120
  catch {
121
- throw new AuthenPayloadError('nonce');
121
+ throw new AuthenSignatureError('nonce');
122
122
  }
123
123
  }
124
124
  res.resolve({
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/guards/basic-ed25519/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACvG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAG9C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,kCAAkC,EAAE,oCAAoC,EACzE,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,IAA+B,EAAqB,EAAE;IAC5G,MAAM,YAAY,GAAG,kCAAkC,EAAE,CAAA;IAEzD,MAAM,MAAM,GAAG,CAAC,OAAgB,EAA4B,EAAE;QAC5D,IAAI,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,qBAAqB,CAAA;QAClD,IAAI,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,oCAAoC,CACzC,OA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,OAAO,CAAC,GAAG,CAAC,OAAO;gBAC3B;;mBAEG;gBACH,IAAI,EAAE,QAAQ,CAAC,OAAO;gBACtB,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC,CAAA;YAEF,OAAO,IAAS,CAAA;QAClB,CAAC;KACF,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE;QACrB,KAAK,CAAC,WAAW,GAAG,IAAI,CAAA;IAC1B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/auth-common",
3
- "version": "0.2.4-rc.0",
3
+ "version": "0.2.4",
4
4
  "license": "MIT",
5
5
  "homepage": "https://owlmeans.com/docs/",
6
6
  "repository": {
@@ -39,19 +39,19 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@owlmeans/auth": "^0.2.4-rc.0",
43
- "@owlmeans/auth-common": "^0.2.4-rc.0",
44
- "@owlmeans/basic-ids": "^0.2.4-rc.0",
45
- "@owlmeans/basic-keys": "^0.2.4-rc.0",
46
- "@owlmeans/client-entrypoint": "^0.2.4-rc.0",
47
- "@owlmeans/context": "^0.2.4-rc.0",
48
- "@owlmeans/entrypoint": "^0.2.4-rc.0",
49
- "@owlmeans/resource": "^0.2.4-rc.0",
50
- "@owlmeans/route": "^0.2.4-rc.0"
42
+ "@owlmeans/auth": "^0.2.4",
43
+ "@owlmeans/auth-common": "^0.2.4",
44
+ "@owlmeans/basic-ids": "^0.2.4",
45
+ "@owlmeans/basic-keys": "^0.2.4",
46
+ "@owlmeans/client-entrypoint": "^0.2.4",
47
+ "@owlmeans/context": "^0.2.4",
48
+ "@owlmeans/entrypoint": "^0.2.4",
49
+ "@owlmeans/resource": "^0.2.4",
50
+ "@owlmeans/route": "^0.2.4"
51
51
  },
52
52
  "devDependencies": {
53
- "@owlmeans/dep-config": "^0.2.4-rc.0",
54
- "@owlmeans/test-auth": "^0.2.4-rc.0",
53
+ "@owlmeans/dep-config": "^0.2.4",
54
+ "@owlmeans/test-auth": "^0.2.4",
55
55
  "@types/bun": "^1.4.4",
56
56
  "nodemon": "^3.1.14",
57
57
  "typescript": "^7.0.2"
@@ -2,6 +2,9 @@ import { AuthroizationType } from '@owlmeans/auth'
2
2
 
3
3
  export const GUARD_ED25519 = `guard:${AuthroizationType.Ed25519BasicSignature}`
4
4
 
5
+ /** The `Authorization` scheme of a request signed with this guard's Ed25519 signature. */
6
+ export const BED255_AUTH_SCHEME = AuthroizationType.Ed25519BasicSignature.toUpperCase()
7
+
5
8
  export const BED255_TIME_HEADER = 'X-Auth-Time'
6
9
  export const BED255_NONCE_HEADER = 'X-Auth-Nonce'
7
10
 
@@ -6,7 +6,7 @@ import { nonceKey, timeKey } from './consts.local.js'
6
6
  import { trust } from '../../utils/trusted.js'
7
7
  import type { Config, Context } from '../../utils/types.js'
8
8
  import type { BasicEd25519Guard, BasicEd25519GuardOptions } from './types.js'
9
- import { AuthenPayloadError, AuthroizationType, AuthRole } from '@owlmeans/auth'
9
+ import { AuthenSignatureError, AuthroizationType, AuthRole } from '@owlmeans/auth'
10
10
  import type { Auth } from '@owlmeans/auth'
11
11
  import { extractAuthToken } from '@owlmeans/auth-common/utils'
12
12
  import {
@@ -73,7 +73,7 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
73
73
 
74
74
  if (typeof signature.credential !== 'string' || signature.credential.length === 0
75
75
  || typeof signature.signature !== 'string' || signature.signature.length === 0) {
76
- throw new AuthenPayloadError('signature')
76
+ throw new AuthenSignatureError('signature')
77
77
  }
78
78
 
79
79
  const trusted = await trust(context, resource, signature.credential, "id")
@@ -90,13 +90,13 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
90
90
  }
91
91
 
92
92
  if (typeof timestamp !== 'string') {
93
- throw new AuthenPayloadError('timestamp')
93
+ throw new AuthenSignatureError('timestamp')
94
94
  }
95
95
 
96
96
  const createdAt = new Date(timestamp)
97
97
  const signedAt = createdAt.getTime()
98
98
  if (!Number.isFinite(signedAt) || createdAt.toISOString() !== timestamp) {
99
- throw new AuthenPayloadError('timestamp')
99
+ throw new AuthenSignatureError('timestamp')
100
100
  }
101
101
 
102
102
  const now = Date.now()
@@ -113,7 +113,7 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
113
113
  || now - queued.enqueuedAt > queued.maxAge
114
114
  : Math.abs(now - signedAt) > BED255_SIG_TTL
115
115
  if (typeof nonce !== 'string' || nonce.length === 0) {
116
- throw new AuthenPayloadError(expired ? 'expired' : 'nonce')
116
+ throw new AuthenSignatureError(expired ? 'expired' : 'nonce')
117
117
  }
118
118
 
119
119
  // The replay identity is the signing credential plus its nonce. A nonce used by one trusted
@@ -132,7 +132,7 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
132
132
  // Past the window only a redelivery stands, and only where the queue sets no window of its
133
133
  // own: its claim proves the job was admitted inside the signature's.
134
134
  if (queued != null || !await redelivered().catch(() => false)) {
135
- throw new AuthenPayloadError('expired')
135
+ throw new AuthenSignatureError('expired')
136
136
  }
137
137
  } else {
138
138
  try {
@@ -146,10 +146,10 @@ export const makeBasicEd25519Guard = (resource: string, opts?: BasicEd25519Guard
146
146
  ))
147
147
  : new Date(signedAt + BED255_SIG_TTL), delivery?.id)
148
148
  if (!claimed && !await redelivered()) {
149
- throw new AuthenPayloadError('nonce')
149
+ throw new AuthenSignatureError('nonce')
150
150
  }
151
151
  } catch {
152
- throw new AuthenPayloadError('nonce')
152
+ throw new AuthenSignatureError('nonce')
153
153
  }
154
154
  }
155
155
 
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, test } from 'bun:test'
2
2
  import { Readable } from 'node:stream'
3
- import { AuthenPayloadError, AuthroizationType } from '@owlmeans/auth'
3
+ import { AuthenPayloadError, AuthenSignatureError, AuthroizationType } from '@owlmeans/auth'
4
4
  import {
5
5
  BED255_DELIVERY_TTL, BED255_NONCE_HEADER, BED255_SIG_TTL, BED255_TIME_HEADER, makeBasicEd25519Guard,
6
6
  makeMemorySignedRequestReplayStore, makeResourceSignedRequestReplayStore, signBasicEd25519Request
@@ -53,6 +53,7 @@ describe('@owlmeans/auth-common — signed request freshness and replay protecti
53
53
 
54
54
  expect((await handle(signed.guard, signed.req))?.userId).toBe(signed.fixture.authRecord.id)
55
55
  await expect(handle(signed.guard, signed.req)).rejects.toBeInstanceOf(AuthenPayloadError)
56
+ await expect(handle(signed.guard, signed.req)).rejects.toBeInstanceOf(AuthenSignatureError)
56
57
  })
57
58
 
58
59
  test('rejects parseable but non-canonical timestamps', async () => {
@@ -67,6 +68,8 @@ describe('@owlmeans/auth-common — signed request freshness and replay protecti
67
68
 
68
69
  await expect(handle(past.guard, past.req)).rejects.toBeInstanceOf(AuthenPayloadError)
69
70
  await expect(handle(future.guard, future.req)).rejects.toBeInstanceOf(AuthenPayloadError)
71
+ await expect(handle(past.guard, past.req)).rejects.toBeInstanceOf(AuthenSignatureError)
72
+ expect(AuthenSignatureError.httpStatus).toBe(401)
70
73
  })
71
74
 
72
75
  test('rejects authentication when an injected replay store fails', async () => {
@@ -1,3 +0,0 @@
1
- export declare const modules: import("@owlmeans/entrypoint").CommonEntrypoint[];
2
- export declare const managerModules: import("@owlmeans/entrypoint").CommonEntrypoint[];
3
- //# sourceMappingURL=modules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO,mDAuBnB,CAAA;AAED,eAAO,MAAM,cAAc,mDAW1B,CAAA"}
package/build/modules.js DELETED
@@ -1,38 +0,0 @@
1
- import { AUTHEN, AUTHEN_AUTHEN, AUTHEN_INIT, AUTHEN_RELY, AllowanceRequestSchema, AuthCredentialsSchema, AuthTokenSchema, CAUTHEN, CAUTHEN_AUTHEN, CAUTHEN_AUTHEN_DEFAULT, CAUTHEN_AUTHEN_TYPED, DISPATCHER, DISPATCHER_AUTHEN, OptionalAuthTokenSchema, CAUTHEN_FLOW_ENTER } from '@owlmeans/auth';
2
- // import { AppType } from '@owlmeans/context'
3
- import { body, filter, entrypoint, query } from '@owlmeans/entrypoint';
4
- import { route, RouteMethod, frontend, backend, socket } from '@owlmeans/route';
5
- import { DISPATCHER_PATH, WEB_API, authApi } from './consts.js';
6
- export const modules = [
7
- entrypoint(route(AUTHEN, '/authentication', backend())),
8
- entrypoint(route(AUTHEN_INIT, '/init', backend(AUTHEN, RouteMethod.POST)), filter(body(AllowanceRequestSchema))),
9
- entrypoint(route(AUTHEN_AUTHEN, '/authenticate', backend(AUTHEN, RouteMethod.POST)), filter(body(AuthCredentialsSchema))),
10
- entrypoint(route(AUTHEN_RELY, '/rely', socket(AUTHEN)), filter(query(OptionalAuthTokenSchema))),
11
- entrypoint(route(CAUTHEN, '/authentication', frontend())),
12
- entrypoint(route(CAUTHEN_AUTHEN, '/login', frontend(CAUTHEN))),
13
- entrypoint(route(CAUTHEN_AUTHEN_DEFAULT, '/', frontend(CAUTHEN_AUTHEN, true))),
14
- entrypoint(route(CAUTHEN_AUTHEN_TYPED, '/:type', frontend(CAUTHEN_AUTHEN))),
15
- // This is a helper route that is used by service providers to redirect to an external authentication service.
16
- entrypoint(route(CAUTHEN_FLOW_ENTER, '/', frontend())),
17
- // This is a helper route that is useb by service providres to process authentication provisioning via redirect.
18
- // Also it can be default starting point to be redirected to an external identity provider.
19
- entrypoint(route(DISPATCHER, DISPATCHER_PATH, frontend({ service: DISPATCHER })),
20
- // This module is sticky - it means it's always attach to client router.
21
- // It's required here cause every web app needs dispatcher route to authorize
22
- // rediected users.
23
- filter(query(AuthTokenSchema), { sticky: true })),
24
- // This is a helper route that representes a API endpoint of service provider that wants to authenticate
25
- // a user with OwlMeans server-auth library.
26
- entrypoint(route(DISPATCHER_AUTHEN, '/authenticate', backend(null, RouteMethod.POST)), filter(body(AuthTokenSchema))),
27
- ];
28
- export const managerModules = [
29
- entrypoint(route(authApi.profile.base, '/profile', backend({ service: WEB_API }))),
30
- entrypoint(route(authApi.profile.toEntityId, '/to-entity-id', backend(authApi.profile.base, RouteMethod.POST))),
31
- entrypoint(route(authApi.auth.base, '/auth', backend({ service: WEB_API }))),
32
- entrypoint(route(authApi.auth.delegate, '/delegate', backend(authApi.auth.base, RouteMethod.POST))),
33
- ];
34
- // const skipModules = [DISPATCHER]
35
- // export const authBackendModules = modules.filter(
36
- // module => !skipModules.includes(module.alias) && module.route.route.type === AppType.Backend
37
- // ).map(module => module.alias)
38
- //# sourceMappingURL=modules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,sBAAsB,EAAE,qBAAqB,EAC9F,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,UAAU,EAClG,iBAAiB,EAAE,uBAAuB,EAAE,kBAAkB,EAC/D,MAAM,gBAAgB,CAAA;AACvB,8CAA8C;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC;IACvD,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAA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