@auth-craft/backend-sdk 0.16.0 → 0.18.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/README.md +85 -0
- package/dist/access-token-verifier.d.ts +51 -0
- package/dist/access-token-verifier.d.ts.map +1 -1
- package/dist/access-token-verifier.js +43 -0
- package/dist/access-token-verifier.js.map +1 -1
- package/dist/app-hook-verifier.d.ts +56 -0
- package/dist/app-hook-verifier.d.ts.map +1 -0
- package/dist/app-hook-verifier.js +129 -0
- package/dist/app-hook-verifier.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -192,6 +192,75 @@ Reset account credentials (requires `RESET_ACCOUNT_CREDENTIALS` permission).
|
|
|
192
192
|
|
|
193
193
|
Hard-delete a user account (requires `REMOVE_ACCOUNTS` permission).
|
|
194
194
|
|
|
195
|
+
## Tokens of a storefront (`org`) and of an OAuth client (`client_id`)
|
|
196
|
+
|
|
197
|
+
With `BIND_SESSION_TO_ORIGIN` on the auth server, an access token carries the origin its
|
|
198
|
+
session was created through. On every store-scoped route, refuse a token of another store:
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
const claims = await verifier.verify(token);
|
|
202
|
+
if (!claims.ok) return unauthorized();
|
|
203
|
+
// The host your proxy was reached on, never a value the client can choose.
|
|
204
|
+
if (!requireOrigin(claims.data, storeOrigin).ok) return unauthorized(); // TOKEN_WRONG_ORIGIN
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
A token without `org` is refused too: turn this check on once sessions from before the
|
|
208
|
+
switch have expired.
|
|
209
|
+
|
|
210
|
+
## Answering the auth server's questions
|
|
211
|
+
|
|
212
|
+
`createAppHookVerifier({ publicKey, issuer, url })` proves a request to your
|
|
213
|
+
`OAUTH_CONFIG_URL` / `AUTH_CLIENTS_URL` endpoint comes from your auth server.
|
|
214
|
+
|
|
215
|
+
The server `POST`s `{ hook, input }` with an Ed25519 service token (one minute, bound to
|
|
216
|
+
the URL and the exact body) and expects `200 { "result": … }`; `null` is "no". Verify with
|
|
217
|
+
`createAppHookVerifier` from `@auth-craft/backend-sdk`:
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
const hook = createAppHookVerifier({ publicKey: env.APP_HOOK_PUBLIC_KEY, issuer: AUTH_SYSTEM_NAME, url: HOOK_URL });
|
|
221
|
+
|
|
222
|
+
const asked = await hook.verify(request);
|
|
223
|
+
if (!asked.ok) return new Response(null, { status: 404 });
|
|
224
|
+
switch (asked.data.hook) {
|
|
225
|
+
case 'oauth-config': // { provider, appId, origin, supports } → { clientId, clientSecret, redirectUri, scopes?, trust? } | null
|
|
226
|
+
case 'auth-client': // { clientId, appId, issuerOrigin } → { redirectUris, scopes } | null
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
A client someone other than the platform holds (a store's own Google client) is answered
|
|
231
|
+
with `trust: { linkScope }`: your own name for the holder (`[A-Za-z0-9_-]{1,32}`, e.g. the
|
|
232
|
+
store id; never the client id, which is public). Whoever holds such a client can collect the
|
|
233
|
+
ID token of anyone who clicks its button, so the auth server keeps its links in that scope,
|
|
234
|
+
asks for an emailed code the first time, and limits its sessions until they step up. Send
|
|
235
|
+
`trust` only when `supports` lists `link-scope`; otherwise answer `null`. A server older than
|
|
236
|
+
`supports` (it arrives as `[]`) would drop `trust` and trust the client as its own. A malformed
|
|
237
|
+
`trust` refuses the sign-in.
|
|
238
|
+
|
|
239
|
+
Answer `auth-client` only when `issuerOrigin` (the proven origin of the sign-in page) may
|
|
240
|
+
sign users in for that client. Anything but a well-formed 200 within 3 seconds (a
|
|
241
|
+
redirect, over 16 KB, another shape) refuses: new sign-ins through a provider or another
|
|
242
|
+
origin stop, existing sessions keep refreshing. Answers are reused for 60 seconds, a `null`
|
|
243
|
+
for 10. Neither questions nor answers are logged.
|
|
244
|
+
|
|
245
|
+
Access tokens of an OAuth client's session carry `client_id` and `scope`: a site that must
|
|
246
|
+
not act on the account. Check them, like `org` (`requireOrigin`), on every route that
|
|
247
|
+
should be closed to it.
|
|
248
|
+
|
|
249
|
+
Every session records how it was proven (`amr`: `pwd`, `otp`, `mfa`, `fed`). A session that
|
|
250
|
+
came only through a client someone else holds (answered with `trust` above) carries
|
|
251
|
+
`acr: "0"` and `lsc` (your `linkScope`): whoever holds that client can sign in as any
|
|
252
|
+
customer already linked through it, without a code. auth-craft's own routes refuse such a
|
|
253
|
+
session except refresh, logout, a reduced `/auth/me` and step-up; your routes decide:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
if (!requireAuthenticationLevel(claims.data).ok) return insufficientAuthenticationResponse();
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
That is a 401 with `WWW-Authenticate: Bearer error="insufficient_user_authentication"`
|
|
260
|
+
(RFC 9470), not a signed-out session: the client steps up (`POST /auth/step-up`, then
|
|
261
|
+
`/auth/step-up/complete`), refreshes, and retries. The step-up lifts the limit of that
|
|
262
|
+
session only; `lsc` stays.
|
|
263
|
+
|
|
195
264
|
## Error Handling
|
|
196
265
|
|
|
197
266
|
All methods return `Result<T>` from `ts-micro-result`.
|
|
@@ -281,6 +350,22 @@ await client.updateTenantMemberPermission({
|
|
|
281
350
|
|
|
282
351
|
## Changelog
|
|
283
352
|
|
|
353
|
+
### 0.18.0
|
|
354
|
+
|
|
355
|
+
Additive; requires `@auth-craft/api-contract` 0.10.0 (installed with it). Needs
|
|
356
|
+
server-postgres 3.3.0, aws-cf-stack 2.4.0 or worker-d1-stack 0.4.0 for the new claims and `supports`.
|
|
357
|
+
|
|
358
|
+
- Claims `amr`, `acr`, `lsc`; `requireAuthenticationLevel(claims)` and `insufficientAuthenticationResponse()` (RFC 9470).
|
|
359
|
+
- `createAppHookVerifier`: oauth-config questions carry `supports` (`[]` from older servers); answer `trust: { linkScope }` only when it lists `link-scope`.
|
|
360
|
+
|
|
361
|
+
### 0.17.0
|
|
362
|
+
|
|
363
|
+
Additive; requires `@auth-craft/api-contract` 0.9.0 (installed with it). Needs
|
|
364
|
+
server-postgres 3.2.0, aws-cf-stack 2.3.0 or worker-d1-stack 0.3.0 with the feature on.
|
|
365
|
+
|
|
366
|
+
- `requireOrigin(claims, origin)` and the claims `org`, `client_id`, `scope`.
|
|
367
|
+
- `createAppHookVerifier`: verify the auth server's signed questions (`OAUTH_CONFIG_URL`, `AUTH_CLIENTS_URL`).
|
|
368
|
+
|
|
284
369
|
### 0.16.0
|
|
285
370
|
|
|
286
371
|
Additive; requires `@auth-craft/api-contract` 0.8.0 (installed with it).
|
|
@@ -16,6 +16,9 @@ export declare const verifierErrors: {
|
|
|
16
16
|
readonly WRONG_AUDIENCE: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
17
17
|
readonly NOT_ACCESS_TOKEN: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
18
18
|
readonly NO_TENANT: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
19
|
+
readonly WRONG_ORIGIN: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
20
|
+
/** RFC 9470: the session is limited (`acr: "0"`); it must step up, then refresh. */
|
|
21
|
+
readonly INSUFFICIENT_USER_AUTHENTICATION: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
19
22
|
readonly KEY_IMPORT_FAILED: (params?: ({
|
|
20
23
|
message: string | number;
|
|
21
24
|
} & Partial<import("ts-micro-result").BaseErrorParams>) | undefined) => import("ts-micro-result").ErrorDetail;
|
|
@@ -51,10 +54,58 @@ export interface AccessTokenClaims {
|
|
|
51
54
|
aud?: string | string[];
|
|
52
55
|
tid?: string;
|
|
53
56
|
tty?: string;
|
|
57
|
+
/** Origin the session is bound to (auth-craft `bindSessionToOrigin`). */
|
|
58
|
+
org?: string;
|
|
59
|
+
/**
|
|
60
|
+
* OAuth client the session was issued to: a site that must not act on the account.
|
|
61
|
+
* Absent on an ordinary sign-in. Decide per route what such a session may do.
|
|
62
|
+
*/
|
|
63
|
+
client_id?: string;
|
|
64
|
+
/** Scope granted to `client_id`, space-separated. */
|
|
65
|
+
scope?: string;
|
|
66
|
+
/**
|
|
67
|
+
* How the session was proven (RFC 8176): `pwd`, `otp` (emailed code or TOTP), `mfa`
|
|
68
|
+
* (after auth-craft's MFA step), `fed` (through a sign-in provider; not in RFC 8176,
|
|
69
|
+
* same meaning as Microsoft Entra's). Absent on tokens of sessions older than it.
|
|
70
|
+
*/
|
|
71
|
+
amr?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* `"0"` (OIDC Core §2): the session came only through an OAuth client someone else
|
|
74
|
+
* holds (e.g. a store's own Google client) and has not stepped up. Whoever holds that
|
|
75
|
+
* client can sign in as anyone already linked through it. `requireAuthenticationLevel`.
|
|
76
|
+
*/
|
|
77
|
+
acr?: string;
|
|
78
|
+
/** Link scope of that client (the app's own name for its holder, e.g. a store id). Kept after a step-up. */
|
|
79
|
+
lsc?: string;
|
|
54
80
|
roles?: string[];
|
|
55
81
|
perms?: Record<string, number>;
|
|
56
82
|
[claim: string]: unknown;
|
|
57
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Refuse a token issued on another storefront. A platform serving many stores under one
|
|
86
|
+
* app checks this on every store-scoped route: with `bindSessionToOrigin` the token
|
|
87
|
+
* carries the origin its session was created through (`org`), and a token taken from
|
|
88
|
+
* store A must not act at store B. `origin` is the store the request is for, from
|
|
89
|
+
* something the client cannot choose (the host your proxy was reached on).
|
|
90
|
+
*
|
|
91
|
+
* A token without `org` is refused too: it was issued before binding was turned on, or
|
|
92
|
+
* by a deployment without it, and proves nothing about the store.
|
|
93
|
+
*/
|
|
94
|
+
export declare function requireOrigin(claims: Pick<AccessTokenClaims, 'org'>, origin: string): Result<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Refuse a limited session (`acr: "0"`) on a route that reads or changes what its client's
|
|
97
|
+
* holder must not reach: data shared across stores, stored value, anything personal the
|
|
98
|
+
* provider did not already tell them. auth-craft's own routes refuse it by default; yours
|
|
99
|
+
* decide per route. Answer the refusal with `insufficientAuthenticationResponse()`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function requireAuthenticationLevel(claims: Pick<AccessTokenClaims, 'acr'>): Result<void>;
|
|
102
|
+
/**
|
|
103
|
+
* The RFC 9470 §3 answer to a limited session: 401 with `WWW-Authenticate: Bearer
|
|
104
|
+
* error="insufficient_user_authentication"`, and the same code in the body for a client
|
|
105
|
+
* that cannot read the header. The client steps up (`POST /auth/step-up`), refreshes and
|
|
106
|
+
* retries; it must not treat this 401 as a signed-out session.
|
|
107
|
+
*/
|
|
108
|
+
export declare function insufficientAuthenticationResponse(): Response;
|
|
58
109
|
export interface AccessTokenVerifier {
|
|
59
110
|
verify(token: string): Promise<Result<AccessTokenClaims>>;
|
|
60
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-token-verifier.d.ts","sourceRoot":"","sources":["../src/access-token-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA6C,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAKzF,eAAO,MAAM,cAAc;aACzB,SAAS;aACT,kBAAkB;aAClB,aAAa;aACb,OAAO;aACP,aAAa;aACb,YAAY;aACZ,cAAc;aACd,gBAAgB;aAChB,SAAS;aACT,iBAAiB;;;CACT,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzE,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,oBAAoB,CAAC;IAChC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,8FAA8F;IAC9F,QAAQ,CAAC,EAA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B,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAElG;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAE/F;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,IAAI,QAAQ,CAe7D;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;CAC3D;AAiED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,mBAAmB,CA4DhG"}
|
|
@@ -18,8 +18,51 @@ export const verifierErrors = {
|
|
|
18
18
|
WRONG_AUDIENCE: defineError('TOKEN_WRONG_AUDIENCE', 'Token audience is not accepted'),
|
|
19
19
|
NOT_ACCESS_TOKEN: defineError('TOKEN_NOT_ACCESS_TOKEN', 'Token is not an access token'),
|
|
20
20
|
NO_TENANT: defineError('TOKEN_NO_TENANT', 'Token has no tenant selected'),
|
|
21
|
+
WRONG_ORIGIN: defineError('TOKEN_WRONG_ORIGIN', 'Token belongs to another site'),
|
|
22
|
+
/** RFC 9470: the session is limited (`acr: "0"`); it must step up, then refresh. */
|
|
23
|
+
INSUFFICIENT_USER_AUTHENTICATION: defineError('INSUFFICIENT_USER_AUTHENTICATION', 'Confirm it is you to continue'),
|
|
21
24
|
KEY_IMPORT_FAILED: defineErrorAdvanced('TOKEN_KEY_IMPORT_FAILED', 'Cannot import verification key: {message}'),
|
|
22
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Refuse a token issued on another storefront. A platform serving many stores under one
|
|
28
|
+
* app checks this on every store-scoped route: with `bindSessionToOrigin` the token
|
|
29
|
+
* carries the origin its session was created through (`org`), and a token taken from
|
|
30
|
+
* store A must not act at store B. `origin` is the store the request is for, from
|
|
31
|
+
* something the client cannot choose (the host your proxy was reached on).
|
|
32
|
+
*
|
|
33
|
+
* A token without `org` is refused too: it was issued before binding was turned on, or
|
|
34
|
+
* by a deployment without it, and proves nothing about the store.
|
|
35
|
+
*/
|
|
36
|
+
export function requireOrigin(claims, origin) {
|
|
37
|
+
return claims.org !== undefined && claims.org === origin ? ok(undefined) : err(verifierErrors.WRONG_ORIGIN());
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Refuse a limited session (`acr: "0"`) on a route that reads or changes what its client's
|
|
41
|
+
* holder must not reach: data shared across stores, stored value, anything personal the
|
|
42
|
+
* provider did not already tell them. auth-craft's own routes refuse it by default; yours
|
|
43
|
+
* decide per route. Answer the refusal with `insufficientAuthenticationResponse()`.
|
|
44
|
+
*/
|
|
45
|
+
export function requireAuthenticationLevel(claims) {
|
|
46
|
+
return claims.acr === '0' ? err(verifierErrors.INSUFFICIENT_USER_AUTHENTICATION()) : ok(undefined);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The RFC 9470 §3 answer to a limited session: 401 with `WWW-Authenticate: Bearer
|
|
50
|
+
* error="insufficient_user_authentication"`, and the same code in the body for a client
|
|
51
|
+
* that cannot read the header. The client steps up (`POST /auth/step-up`), refreshes and
|
|
52
|
+
* retries; it must not treat this 401 as a signed-out session.
|
|
53
|
+
*/
|
|
54
|
+
export function insufficientAuthenticationResponse() {
|
|
55
|
+
return new Response(JSON.stringify({
|
|
56
|
+
ok: false,
|
|
57
|
+
errors: [{ code: 'INSUFFICIENT_USER_AUTHENTICATION', message: 'Confirm it is you to continue' }],
|
|
58
|
+
}), {
|
|
59
|
+
status: 401,
|
|
60
|
+
headers: {
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'WWW-Authenticate': 'Bearer error="insufficient_user_authentication", error_description="Confirm it is you to continue"',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
23
66
|
const HEX_ED25519_RE = /^[0-9a-fA-F]{64}$/;
|
|
24
67
|
const HMAC_HASH = { HS256: 'SHA-256', HS384: 'SHA-384', HS512: 'SHA-512' };
|
|
25
68
|
function base64Decode(base64) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-token-verifier.js","sourceRoot":"","sources":["../src/access-token-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,iBAAiB,CAAC;AAEzF,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS,EAAE,WAAW,CAAC,iBAAiB,EAAE,gCAAgC,CAAC;IAC3E,kBAAkB,EAAE,WAAW,CAAC,0BAA0B,EAAE,6CAA6C,CAAC;IAC1G,aAAa,EAAE,WAAW,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;IAC/E,OAAO,EAAE,WAAW,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAC1D,aAAa,EAAE,WAAW,CAAC,qBAAqB,EAAE,wBAAwB,CAAC;IAC3E,YAAY,EAAE,WAAW,CAAC,oBAAoB,EAAE,8BAA8B,CAAC;IAC/E,cAAc,EAAE,WAAW,CAAC,sBAAsB,EAAE,gCAAgC,CAAC;IACrF,gBAAgB,EAAE,WAAW,CAAC,wBAAwB,EAAE,8BAA8B,CAAC;IACvF,SAAS,EAAE,WAAW,CAAC,iBAAiB,EAAE,8BAA8B,CAAC;IACzE,iBAAiB,EAAE,mBAAmB,CAAC,yBAAyB,EAAE,2CAA2C,CAAC;CACtG,CAAC;
|
|
1
|
+
{"version":3,"file":"access-token-verifier.js","sourceRoot":"","sources":["../src/access-token-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,E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,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app side of Auth Craft's HTTP hooks (`OAUTH_CONFIG_URL`, `AUTH_CLIENTS_URL`): prove
|
|
3
|
+
* a question comes from your auth server before answering it. Web Crypto only.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const hook = createAppHookVerifier({ publicKey: env.APP_HOOK_PUBLIC_KEY, issuer: 'my-auth', url: 'https://api.example/hooks/auth' });
|
|
7
|
+
* const question = await hook.verify(request); // reads the body
|
|
8
|
+
* if (!question.ok) return new Response(null, { status: 404 });
|
|
9
|
+
* if (question.data.hook === 'auth-client') return Response.json({ result: await findClient(question.data.input) });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* `result: null` means "no": the provider is off there, or there is no such client.
|
|
13
|
+
*
|
|
14
|
+
* A client someone other than the platform holds (a store's own Google client) is answered
|
|
15
|
+
* with `trust: { linkScope }`, and only when `input.supports` lists `link-scope`. An auth
|
|
16
|
+
* server that does not list it would drop `trust` and trust that client like its own:
|
|
17
|
+
* answer `null` (provider off) instead.
|
|
18
|
+
*/
|
|
19
|
+
import { type Result } from 'ts-micro-result';
|
|
20
|
+
export declare const appHookVerifierErrors: {
|
|
21
|
+
readonly UNAUTHORIZED: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
22
|
+
readonly BAD_REQUEST: (params?: import("ts-micro-result").BaseErrorParams) => import("ts-micro-result").ErrorDetail;
|
|
23
|
+
readonly KEY_IMPORT_FAILED: (params?: ({
|
|
24
|
+
message: string | number;
|
|
25
|
+
} & Partial<import("ts-micro-result").BaseErrorParams>) | undefined) => import("ts-micro-result").ErrorDetail;
|
|
26
|
+
};
|
|
27
|
+
export type AppHookQuestion = {
|
|
28
|
+
hook: 'oauth-config';
|
|
29
|
+
/** `supports`: what the auth server understands in an answer; `[]` from a server older than it. */
|
|
30
|
+
input: {
|
|
31
|
+
provider: string;
|
|
32
|
+
appId: string;
|
|
33
|
+
origin: string;
|
|
34
|
+
supports: string[];
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
hook: 'auth-client';
|
|
38
|
+
input: {
|
|
39
|
+
clientId: string;
|
|
40
|
+
appId: string;
|
|
41
|
+
issuerOrigin: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export interface AppHookVerifierConfig {
|
|
45
|
+
/** Ed25519 public JWK (or its JSON). Two during a key rotation. */
|
|
46
|
+
publicKey: JsonWebKey | string | (JsonWebKey | string)[];
|
|
47
|
+
/** The auth server's AUTH_SYSTEM_NAME. */
|
|
48
|
+
issuer: string;
|
|
49
|
+
/** The URL the auth server is configured with, exactly. */
|
|
50
|
+
url: string;
|
|
51
|
+
}
|
|
52
|
+
export interface AppHookVerifier {
|
|
53
|
+
verify(request: Request): Promise<Result<AppHookQuestion>>;
|
|
54
|
+
}
|
|
55
|
+
export declare function createAppHookVerifier(config: AppHookVerifierConfig): AppHookVerifier;
|
|
56
|
+
//# sourceMappingURL=app-hook-verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-hook-verifier.d.ts","sourceRoot":"","sources":["../src/app-hook-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAA6C,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzF,eAAO,MAAM,qBAAqB;aAChC,YAAY;aACZ,WAAW;aACX,iBAAiB;;;CACT,CAAC;AAEX,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,cAAc,CAAC;IACrB,mGAAmG;IACnG,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAChF,GACD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9F,MAAM,WAAW,qBAAqB;IACpC,mEAAmE;IACnE,SAAS,EAAE,UAAU,GAAG,MAAM,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC;IACzD,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;CAC5D;AAqDD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAgDpF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app side of Auth Craft's HTTP hooks (`OAUTH_CONFIG_URL`, `AUTH_CLIENTS_URL`): prove
|
|
3
|
+
* a question comes from your auth server before answering it. Web Crypto only.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* const hook = createAppHookVerifier({ publicKey: env.APP_HOOK_PUBLIC_KEY, issuer: 'my-auth', url: 'https://api.example/hooks/auth' });
|
|
7
|
+
* const question = await hook.verify(request); // reads the body
|
|
8
|
+
* if (!question.ok) return new Response(null, { status: 404 });
|
|
9
|
+
* if (question.data.hook === 'auth-client') return Response.json({ result: await findClient(question.data.input) });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* `result: null` means "no": the provider is off there, or there is no such client.
|
|
13
|
+
*
|
|
14
|
+
* A client someone other than the platform holds (a store's own Google client) is answered
|
|
15
|
+
* with `trust: { linkScope }`, and only when `input.supports` lists `link-scope`. An auth
|
|
16
|
+
* server that does not list it would drop `trust` and trust that client like its own:
|
|
17
|
+
* answer `null` (provider off) instead.
|
|
18
|
+
*/
|
|
19
|
+
import { defineError, defineErrorAdvanced, err, ok } from 'ts-micro-result';
|
|
20
|
+
export const appHookVerifierErrors = {
|
|
21
|
+
UNAUTHORIZED: defineError('APP_HOOK_UNAUTHORIZED', 'Not a question from the auth server'),
|
|
22
|
+
BAD_REQUEST: defineError('APP_HOOK_BAD_REQUEST', 'Unknown hook or malformed question'),
|
|
23
|
+
KEY_IMPORT_FAILED: defineErrorAdvanced('APP_HOOK_KEY_IMPORT_FAILED', 'Cannot import verification key: {message}'),
|
|
24
|
+
};
|
|
25
|
+
const MAX_BODY_BYTES = 16_384;
|
|
26
|
+
const MAX_LIFETIME_SECONDS = 60;
|
|
27
|
+
const SKEW_SECONDS = 30;
|
|
28
|
+
const ED25519 = { name: 'Ed25519' };
|
|
29
|
+
const INPUTS = {
|
|
30
|
+
'oauth-config': ['provider', 'appId', 'origin'],
|
|
31
|
+
'auth-client': ['clientId', 'appId', 'issuerOrigin'],
|
|
32
|
+
};
|
|
33
|
+
const utf8 = (text) => new TextEncoder().encode(text);
|
|
34
|
+
function base64UrlDecode(input) {
|
|
35
|
+
return Uint8Array.from(atob(input.replace(/-/g, '+').replace(/_/g, '/')), (c) => c.charCodeAt(0));
|
|
36
|
+
}
|
|
37
|
+
function base64UrlEncode(bytes) {
|
|
38
|
+
let bin = '';
|
|
39
|
+
for (const b of bytes)
|
|
40
|
+
bin += String.fromCharCode(b);
|
|
41
|
+
return btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
42
|
+
}
|
|
43
|
+
function importKey(input) {
|
|
44
|
+
const { kty, crv, x } = (typeof input === 'string' ? JSON.parse(input) : input);
|
|
45
|
+
return crypto.subtle.importKey('jwk', { kty, crv, x }, ED25519, false, ['verify']);
|
|
46
|
+
}
|
|
47
|
+
function parseObject(text) {
|
|
48
|
+
try {
|
|
49
|
+
const value = JSON.parse(text);
|
|
50
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
51
|
+
? value
|
|
52
|
+
: null;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function question(body) {
|
|
59
|
+
const parsed = parseObject(body);
|
|
60
|
+
const hook = parsed?.hook;
|
|
61
|
+
if (hook !== 'oauth-config' && hook !== 'auth-client')
|
|
62
|
+
return null;
|
|
63
|
+
const input = parsed?.input;
|
|
64
|
+
if (!input || INPUTS[hook].some((name) => typeof input[name] !== 'string'))
|
|
65
|
+
return null;
|
|
66
|
+
if (hook === 'oauth-config') {
|
|
67
|
+
const supports = input.supports ?? [];
|
|
68
|
+
if (!Array.isArray(supports) || supports.some((s) => typeof s !== 'string'))
|
|
69
|
+
return null;
|
|
70
|
+
return { hook, input: { ...input, supports } };
|
|
71
|
+
}
|
|
72
|
+
return { hook, input };
|
|
73
|
+
}
|
|
74
|
+
export function createAppHookVerifier(config) {
|
|
75
|
+
const inputs = Array.isArray(config.publicKey) ? config.publicKey : [config.publicKey];
|
|
76
|
+
let keys;
|
|
77
|
+
async function authentic(token, body, imported) {
|
|
78
|
+
try {
|
|
79
|
+
const [header, payload, signature, extra] = token.split('.');
|
|
80
|
+
if (!header || !payload || !signature || extra !== undefined)
|
|
81
|
+
return false;
|
|
82
|
+
const text = (segment) => new TextDecoder().decode(base64UrlDecode(segment));
|
|
83
|
+
if (parseObject(text(header))?.alg !== 'EdDSA')
|
|
84
|
+
return false;
|
|
85
|
+
let signed = false;
|
|
86
|
+
for (const key of imported) {
|
|
87
|
+
signed ||= await crypto.subtle.verify(ED25519, key, base64UrlDecode(signature), utf8(`${header}.${payload}`));
|
|
88
|
+
}
|
|
89
|
+
const claims = parseObject(text(payload));
|
|
90
|
+
if (!signed || !claims || claims.iss !== config.issuer || claims.aud !== config.url)
|
|
91
|
+
return false;
|
|
92
|
+
const { iat, exp } = claims;
|
|
93
|
+
if (typeof iat !== 'number' || typeof exp !== 'number')
|
|
94
|
+
return false;
|
|
95
|
+
const now = Math.floor(Date.now() / 1000);
|
|
96
|
+
if (exp <= iat || exp - iat > MAX_LIFETIME_SECONDS)
|
|
97
|
+
return false;
|
|
98
|
+
if (iat > now + SKEW_SECONDS || exp + SKEW_SECONDS < now)
|
|
99
|
+
return false;
|
|
100
|
+
const hash = new Uint8Array(await crypto.subtle.digest('SHA-256', utf8(body)));
|
|
101
|
+
return claims.bh === base64UrlEncode(hash);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
async verify(request) {
|
|
109
|
+
const auth = request.headers.get('authorization') ?? '';
|
|
110
|
+
const body = request.method === 'POST' && auth.startsWith('Bearer ') ? await request.text() : '';
|
|
111
|
+
if (body === '' || body.length > MAX_BODY_BYTES)
|
|
112
|
+
return err(appHookVerifierErrors.UNAUTHORIZED());
|
|
113
|
+
let imported;
|
|
114
|
+
try {
|
|
115
|
+
keys ??= Promise.all(inputs.map(importKey));
|
|
116
|
+
imported = await keys;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
keys = undefined;
|
|
120
|
+
return err(appHookVerifierErrors.KEY_IMPORT_FAILED({ message: error instanceof Error ? error.message : String(error) }));
|
|
121
|
+
}
|
|
122
|
+
if (!(await authentic(auth.slice(7).trim(), body, imported)))
|
|
123
|
+
return err(appHookVerifierErrors.UNAUTHORIZED());
|
|
124
|
+
const asked = question(body);
|
|
125
|
+
return asked ? ok(asked) : err(appHookVerifierErrors.BAD_REQUEST());
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=app-hook-verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-hook-verifier.js","sourceRoot":"","sources":["../src/app-hook-verifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,WAAW,EAAE,mBAAmB,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AC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC;QACtE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,9 @@ import type { InternalClientConfig } from './types.js';
|
|
|
28
28
|
*/
|
|
29
29
|
export declare function createInternalClient(config: InternalClientConfig): InternalClient;
|
|
30
30
|
export type { AccessTokenAlgorithm, AccessTokenClaims, AccessTokenVerifier, AccessTokenVerifierConfig, } from './access-token-verifier.js';
|
|
31
|
-
export { createAccessTokenVerifier, verifierErrors } from './access-token-verifier.js';
|
|
31
|
+
export { createAccessTokenVerifier, insufficientAuthenticationResponse, requireAuthenticationLevel, requireOrigin, verifierErrors, } from './access-token-verifier.js';
|
|
32
|
+
export type { AppHookQuestion, AppHookVerifier, AppHookVerifierConfig } from './app-hook-verifier.js';
|
|
33
|
+
export { appHookVerifierErrors, createAppHookVerifier } from './app-hook-verifier.js';
|
|
32
34
|
export { InternalClient } from './client.js';
|
|
33
35
|
export { sdkErrors } from './errors.js';
|
|
34
36
|
export type { RevocableClaims, RevocationChecker, RevocationCheckerConfig } from './revocation-checker.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CAEjF;AAED,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","source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B,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,4BAA4B,EAC5B,6BAA6B,EAC7B,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,+BAA+B,EAC/B,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,8 @@ import { InternalClient } from './client.js';
|
|
|
28
28
|
export function createInternalClient(config) {
|
|
29
29
|
return new InternalClient(config);
|
|
30
30
|
}
|
|
31
|
-
export { createAccessTokenVerifier, verifierErrors } from './access-token-verifier.js';
|
|
31
|
+
export { createAccessTokenVerifier, insufficientAuthenticationResponse, requireAuthenticationLevel, requireOrigin, verifierErrors, } from './access-token-verifier.js';
|
|
32
|
+
export { appHookVerifierErrors, createAppHookVerifier } from './app-hook-verifier.js';
|
|
32
33
|
export { InternalClient } from './client.js';
|
|
33
34
|
export { sdkErrors } from './errors.js';
|
|
34
35
|
export { createRevocationChecker, revocationCheckErrors } from './revocation-checker.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAQD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAA4B;IAC/D,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAQD,OAAO,EACL,yBAAyB,EACzB,kCAAkC,EAClC,0BAA0B,EAC1B,aAAa,EACb,cAAc,GACf,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAsEzF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth-craft/backend-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Type-safe internal service SDK for Auth-Craft service-to-service calls",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"ts-micro-result": "^3.3.0",
|
|
15
15
|
"valibot": "^1.5.0",
|
|
16
|
-
"@auth-craft/api-contract": "^0.
|
|
16
|
+
"@auth-craft/api-contract": "^0.10.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"typescript": "^7.0.2",
|