axiam-sdk 1.0.0-alpha23 → 1.0.0-alpha24
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 +93 -2
- package/dist/{authzCore-DuRI1aJf.d.cts → authzCore-CA9zFm1n.d.cts} +38 -4
- package/dist/{authzCore-DtSN59if.d.ts → authzCore-a-wZL2P3.d.ts} +38 -4
- package/dist/{client-jcu7cvt2.d.cts → client-CtT9nHQP.d.cts} +1 -1
- package/dist/{client-Bvq888vU.d.ts → client-utwuwc9m.d.ts} +1 -1
- package/dist/{cookieJar-BNQRJ1-1.d.ts → cookieJar-C9fqLqbh.d.ts} +3 -3
- package/dist/{cookieJar-pfVRO-Vj.d.cts → cookieJar-DeJKczxD.d.cts} +3 -3
- package/dist/grpc/index.d.cts +5 -5
- package/dist/grpc/index.d.ts +5 -5
- package/dist/grpc/index.js +45 -1
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +45 -1
- package/dist/grpc/index.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/dist/{jwks-BgojMGC5.d.cts → jwks-DEiwxlku.d.cts} +84 -3
- package/dist/{jwks-BgojMGC5.d.ts → jwks-DEiwxlku.d.ts} +84 -3
- package/dist/middleware/index.d.cts +6 -6
- package/dist/middleware/index.d.ts +6 -6
- package/dist/middleware/index.js +177 -138
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +176 -139
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/nestjs/index.d.cts +2 -2
- package/dist/nestjs/index.d.ts +2 -2
- package/dist/node/index.d.cts +94 -6
- package/dist/node/index.d.ts +94 -6
- package/dist/node/index.js +147 -3
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +143 -5
- package/dist/node/index.mjs.map +1 -1
- package/dist/{oidcState-BXrGx6Qu.d.ts → oidcState-CfebuJ0n.d.ts} +2 -2
- package/dist/{oidcState-BeB2oC6X.d.cts → oidcState-tHRAg5bu.d.cts} +2 -2
- package/dist/rest/index.d.cts +2 -2
- package/dist/rest/index.d.ts +2 -2
- package/dist/rest/index.js +6 -0
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +6 -0
- package/dist/rest/index.mjs.map +1 -1
- package/dist/{session-9-H_BWCN.d.cts → session-ti3C9ZJU.d.cts} +19 -0
- package/dist/{session-9-H_BWCN.d.ts → session-ti3C9ZJU.d.ts} +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,37 @@ Official TypeScript/JavaScript client SDK for [AXIAM](https://github.com/ilpanic
|
|
|
17
17
|
|
|
18
18
|
## Contract conformance
|
|
19
19
|
|
|
20
|
-
This SDK conforms to CONTRACT.md §1–§
|
|
21
|
-
OIDC/SSO relying-party helpers
|
|
20
|
+
This SDK conforms to CONTRACT.md §1–§13 (including §6.1 mTLS client certificates, the
|
|
21
|
+
§10.1 minimum local-verification set, the §12 OIDC/SSO relying-party helpers, and the §13
|
|
22
|
+
`verifyWebhook` signature verifier).
|
|
23
|
+
|
|
24
|
+
### §10.1 minimum local-verification set
|
|
25
|
+
|
|
26
|
+
`axiamMiddleware` / `axiamPlugin` (and the `requireAuth` / `requireAccess` / `requireRole`
|
|
27
|
+
helpers built on them) funnel through `authenticateRequest`, which applies **every** §10.1
|
|
28
|
+
rule on every inbound token: EdDSA `alg` pinned before the JWKS is consulted, a REQUIRED
|
|
29
|
+
`exp` (`jose` only checks `exp` *if present*, so `requiredClaims: ['exp']` is passed
|
|
30
|
+
explicitly), `nbf` honoured when present, `tenant_id` asserted against the session's
|
|
31
|
+
configured tenant, `iss`/`aud` checked when configured, all under a named 60-second
|
|
32
|
+
`CLOCK_SKEW_LEEWAY_SEC`.
|
|
33
|
+
|
|
34
|
+
Because the `/oauth2/jwks` trust anchor is **organization-wide**, the session guarding a
|
|
35
|
+
resource server must be configured with the tenant **UUID** (`tenantId`), since that is
|
|
36
|
+
what the `tenant_id` claim carries. `expectedIssuer` / `expectedAudience` are optional and
|
|
37
|
+
unset by default:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const client = createNodeClient({
|
|
41
|
+
baseUrl: 'https://iam.example.com',
|
|
42
|
+
tenantId: '…-uuid-…', // §10.1 rule 4 — compared against the tenant_id claim
|
|
43
|
+
expectedAudience: 'axiam:user', // §10.1 rule 6 — optional, recommended
|
|
44
|
+
});
|
|
45
|
+
app.use(axiamMiddleware(client.session));
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`verifier.verifySignatureOnlyUnchecked(token)` is the §10.1 raw signature-only primitive,
|
|
49
|
+
for integrators implementing their own policy. It checks the signature and nothing else —
|
|
50
|
+
never use it to guard a route.
|
|
22
51
|
|
|
23
52
|
See [`CONTRACT.md`](./CONTRACT.md) for the full cross-language behavioral contract.
|
|
24
53
|
|
|
@@ -478,6 +507,68 @@ strings.
|
|
|
478
507
|
|
|
479
508
|
See `examples/express-oidc-login.ts` for a complete, runnable example.
|
|
480
509
|
|
|
510
|
+
## Webhook signature verification (`axiam-sdk/node`, CONTRACT.md §13)
|
|
511
|
+
|
|
512
|
+
AXIAM signs every webhook delivery with a Stripe-style signed timestamp:
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
X-Axiam-Signature: t=<unix_seconds>,v1=<hex_lowercase_hmac>
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
where `v1 = HMAC-SHA256(secret_utf8_bytes, "<timestamp>.<raw_body>")`. `verifyWebhook`
|
|
519
|
+
recomputes and checks that signature — in constant time, with a two-sided freshness window —
|
|
520
|
+
so integrators never hand-roll (or skip) the comparison.
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
import { verifyWebhook, WebhookVerifyError, Sensitive } from 'axiam-sdk/node';
|
|
524
|
+
|
|
525
|
+
const secret = new Sensitive(process.env.AXIAM_WEBHOOK_SECRET!);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
const { event, id } = verifyWebhook(secret, req.header('X-Axiam-Signature')!, req.rawBody);
|
|
529
|
+
// `event`/`id` come from the verified body's own `event`/`id` fields; `X-Axiam-Delivery`
|
|
530
|
+
// is the at-least-once dedup key — keep a short-lived seen-set, since a retry replays a
|
|
531
|
+
// validly-signed request inside the freshness window.
|
|
532
|
+
console.log('verified webhook:', event, id);
|
|
533
|
+
} catch (err) {
|
|
534
|
+
if (err instanceof WebhookVerifyError) {
|
|
535
|
+
res.status(400).end(); // err.reason is a stable code; err.message never
|
|
536
|
+
// contains the secret or the expected signature
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
**The raw body is load-bearing.** `verifyWebhook` MUST receive the *exact* bytes AXIAM sent —
|
|
542
|
+
`Buffer`, `Uint8Array`, or the identical raw string — never a `JSON.stringify` of the parsed
|
|
543
|
+
body. Re-serializing changes key order/whitespace and silently breaks the MAC; this is the
|
|
544
|
+
single most common integration mistake. Most JSON body-parsing middleware discards the raw
|
|
545
|
+
bytes by default, so capture them explicitly on the webhook route. With Express,
|
|
546
|
+
`express.json()` alone does **not** keep them — use its `verify` callback, or mount
|
|
547
|
+
`express.raw({ type: 'application/json' })` on that one route instead:
|
|
548
|
+
|
|
549
|
+
```typescript
|
|
550
|
+
import express from 'express';
|
|
551
|
+
|
|
552
|
+
app.post(
|
|
553
|
+
'/webhooks/axiam',
|
|
554
|
+
express.json({
|
|
555
|
+
verify: (req, _res, buf) => {
|
|
556
|
+
(req as express.Request & { rawBody: Buffer }).rawBody = buf;
|
|
557
|
+
},
|
|
558
|
+
}),
|
|
559
|
+
(req, res) => {
|
|
560
|
+
const { rawBody } = req as express.Request & { rawBody: Buffer };
|
|
561
|
+
const event = verifyWebhook(secret, req.header('X-Axiam-Signature')!, rawBody);
|
|
562
|
+
// ...
|
|
563
|
+
},
|
|
564
|
+
);
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
The freshness window defaults to 300 s and is two-sided — a future-dated `t=` is rejected just
|
|
568
|
+
like a stale one — and accepts a `tolerance` override plus a `now` injection seam for tests. A
|
|
569
|
+
failure always raises the typed `WebhookVerifyError` (never a generic exception whose message
|
|
570
|
+
could leak the expected signature).
|
|
571
|
+
|
|
481
572
|
## Error handling
|
|
482
573
|
|
|
483
574
|
Every persona throws the three CONTRACT.md §2 error types — `AuthError`, `AuthzError`,
|
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
import { A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.cjs';
|
|
2
|
-
import { V as Verifier } from './jwks-
|
|
2
|
+
import { V as Verifier } from './jwks-DEiwxlku.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Minimal session shape the middleware needs: a JWKS verifier (D-11) and the
|
|
6
6
|
* tenant this resource server is configured for (CR-03). JWKS is org-wide,
|
|
7
7
|
* not tenant-scoped (node/jwks.ts) — `tenantHeaderValue` is what lets
|
|
8
8
|
* `authenticateRequest` reject a validly-signed token minted for a
|
|
9
|
-
* DIFFERENT tenant in the same org.
|
|
9
|
+
* DIFFERENT tenant in the same org (CONTRACT.md §10.1 rule 4).
|
|
10
10
|
*/
|
|
11
11
|
interface VerifiableSession {
|
|
12
12
|
/** Local JWKS verifier (D-11) — validates the token's EdDSA signature against the org-wide cached JWKS, offline on a cache hit. */
|
|
13
13
|
jwksVerifier: Verifier;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The tenant this resource server is configured for (CR-03, §10.1 rule 4);
|
|
16
|
+
* a validly-signed token minted for a different tenant in the same org is
|
|
17
|
+
* rejected.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The claim it is compared against is the token's `tenant_id`, which is
|
|
21
|
+
* always a UUID — so a resource server guarding routes MUST be configured
|
|
22
|
+
* with `tenantId` (the UUID form), not `tenantSlug`. A slug-configured
|
|
23
|
+
* session can never match and therefore rejects every request; that is
|
|
24
|
+
* fail-closed by design, not a silent pass.
|
|
25
|
+
*/
|
|
15
26
|
tenantHeaderValue: string;
|
|
27
|
+
/**
|
|
28
|
+
* CONTRACT.md §10.1 rule 5 — expected token issuer. Optional and unset by
|
|
29
|
+
* default: the rule is conditional on configuration, and the SDK never
|
|
30
|
+
* hardcodes an issuer. When set, a token whose `iss` differs is rejected.
|
|
31
|
+
* Populated from `AxiamClientOptions.expectedIssuer`.
|
|
32
|
+
*/
|
|
33
|
+
expectedIssuer?: string;
|
|
34
|
+
/**
|
|
35
|
+
* CONTRACT.md §10.1 rule 6 — expected token audience. Optional and unset by
|
|
36
|
+
* default. A resource server guarding user-facing routes SHOULD set
|
|
37
|
+
* `"axiam:user"`. Populated from `AxiamClientOptions.expectedAudience`.
|
|
38
|
+
*/
|
|
39
|
+
expectedAudience?: string;
|
|
16
40
|
}
|
|
17
41
|
/** Authenticated identity injected as req.axiamUser / request.axiamUser (§10). */
|
|
18
42
|
interface AxiamIdentity {
|
|
@@ -30,8 +54,18 @@ interface AxiamIdentity {
|
|
|
30
54
|
* AXIAM's access token carries no dedicated `roles` claim server-side
|
|
31
55
|
* (mirrors the Rust SDK's src/middleware/actix.rs).
|
|
32
56
|
*
|
|
57
|
+
* This is the SDK's **documented §10 guard entry point** for TypeScript, and
|
|
58
|
+
* it applies the complete CONTRACT.md §10.1 minimum local-verification set:
|
|
59
|
+
* rules 1/2/3/5/6/7 inside `verifyAccessToken` (EdDSA `alg` pinned before key
|
|
60
|
+
* lookup, REQUIRED numeric `exp`, `nbf` when present, conditional `iss`/`aud`,
|
|
61
|
+
* a named bounded clock skew) and rule 4 — the `tenant_id` assertion — both
|
|
62
|
+
* there and again here, so a caller-supplied `Verifier` implementation that
|
|
63
|
+
* ignores its expectations still cannot get a cross-tenant token past the
|
|
64
|
+
* middleware.
|
|
65
|
+
*
|
|
33
66
|
* Throws `AuthError` on any verification failure (missing/invalid/expired
|
|
34
|
-
* token, or a malformed
|
|
67
|
+
* token, a token with no `exp`, a not-yet-valid `nbf`, or a malformed /
|
|
68
|
+
* mismatched sub/tenant_id claim).
|
|
35
69
|
*/
|
|
36
70
|
declare function authenticateRequest(session: VerifiableSession, token: string): Promise<AxiamIdentity>;
|
|
37
71
|
|
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
import { A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.js';
|
|
2
|
-
import { V as Verifier } from './jwks-
|
|
2
|
+
import { V as Verifier } from './jwks-DEiwxlku.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Minimal session shape the middleware needs: a JWKS verifier (D-11) and the
|
|
6
6
|
* tenant this resource server is configured for (CR-03). JWKS is org-wide,
|
|
7
7
|
* not tenant-scoped (node/jwks.ts) — `tenantHeaderValue` is what lets
|
|
8
8
|
* `authenticateRequest` reject a validly-signed token minted for a
|
|
9
|
-
* DIFFERENT tenant in the same org.
|
|
9
|
+
* DIFFERENT tenant in the same org (CONTRACT.md §10.1 rule 4).
|
|
10
10
|
*/
|
|
11
11
|
interface VerifiableSession {
|
|
12
12
|
/** Local JWKS verifier (D-11) — validates the token's EdDSA signature against the org-wide cached JWKS, offline on a cache hit. */
|
|
13
13
|
jwksVerifier: Verifier;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The tenant this resource server is configured for (CR-03, §10.1 rule 4);
|
|
16
|
+
* a validly-signed token minted for a different tenant in the same org is
|
|
17
|
+
* rejected.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The claim it is compared against is the token's `tenant_id`, which is
|
|
21
|
+
* always a UUID — so a resource server guarding routes MUST be configured
|
|
22
|
+
* with `tenantId` (the UUID form), not `tenantSlug`. A slug-configured
|
|
23
|
+
* session can never match and therefore rejects every request; that is
|
|
24
|
+
* fail-closed by design, not a silent pass.
|
|
25
|
+
*/
|
|
15
26
|
tenantHeaderValue: string;
|
|
27
|
+
/**
|
|
28
|
+
* CONTRACT.md §10.1 rule 5 — expected token issuer. Optional and unset by
|
|
29
|
+
* default: the rule is conditional on configuration, and the SDK never
|
|
30
|
+
* hardcodes an issuer. When set, a token whose `iss` differs is rejected.
|
|
31
|
+
* Populated from `AxiamClientOptions.expectedIssuer`.
|
|
32
|
+
*/
|
|
33
|
+
expectedIssuer?: string;
|
|
34
|
+
/**
|
|
35
|
+
* CONTRACT.md §10.1 rule 6 — expected token audience. Optional and unset by
|
|
36
|
+
* default. A resource server guarding user-facing routes SHOULD set
|
|
37
|
+
* `"axiam:user"`. Populated from `AxiamClientOptions.expectedAudience`.
|
|
38
|
+
*/
|
|
39
|
+
expectedAudience?: string;
|
|
16
40
|
}
|
|
17
41
|
/** Authenticated identity injected as req.axiamUser / request.axiamUser (§10). */
|
|
18
42
|
interface AxiamIdentity {
|
|
@@ -30,8 +54,18 @@ interface AxiamIdentity {
|
|
|
30
54
|
* AXIAM's access token carries no dedicated `roles` claim server-side
|
|
31
55
|
* (mirrors the Rust SDK's src/middleware/actix.rs).
|
|
32
56
|
*
|
|
57
|
+
* This is the SDK's **documented §10 guard entry point** for TypeScript, and
|
|
58
|
+
* it applies the complete CONTRACT.md §10.1 minimum local-verification set:
|
|
59
|
+
* rules 1/2/3/5/6/7 inside `verifyAccessToken` (EdDSA `alg` pinned before key
|
|
60
|
+
* lookup, REQUIRED numeric `exp`, `nbf` when present, conditional `iss`/`aud`,
|
|
61
|
+
* a named bounded clock skew) and rule 4 — the `tenant_id` assertion — both
|
|
62
|
+
* there and again here, so a caller-supplied `Verifier` implementation that
|
|
63
|
+
* ignores its expectations still cannot get a cross-tenant token past the
|
|
64
|
+
* middleware.
|
|
65
|
+
*
|
|
33
66
|
* Throws `AuthError` on any verification failure (missing/invalid/expired
|
|
34
|
-
* token, or a malformed
|
|
67
|
+
* token, a token with no `exp`, a not-yet-valid `nbf`, or a malformed /
|
|
68
|
+
* mismatched sub/tenant_id claim).
|
|
35
69
|
*/
|
|
36
70
|
declare function authenticateRequest(session: VerifiableSession, token: string): Promise<AxiamIdentity>;
|
|
37
71
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SharedSession, A as AxiamClientOptions } from './session-
|
|
1
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-ti3C9ZJU.cjs';
|
|
2
2
|
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SharedSession, A as AxiamClientOptions } from './session-
|
|
1
|
+
import { S as SharedSession, A as AxiamClientOptions } from './session-ti3C9ZJU.js';
|
|
2
2
|
import { L as LoginResult, A as AccessCheck, a as AccessDecision } from './types-BVkMoqLU.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CookieJar } from 'tough-cookie';
|
|
2
|
-
import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-
|
|
3
|
-
import { A as AxiamClient } from './client-
|
|
2
|
+
import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-ti3C9ZJU.js';
|
|
3
|
+
import { A as AxiamClient } from './client-utwuwc9m.js';
|
|
4
4
|
import { S as Sensitive } from './sensitive-BC_s7Rrd.js';
|
|
5
|
-
import { V as Verifier } from './jwks-
|
|
5
|
+
import { V as Verifier } from './jwks-DEiwxlku.js';
|
|
6
6
|
import { AxiosInstance } from 'axios';
|
|
7
7
|
|
|
8
8
|
/** Tracks the access/refresh token pair for a Node session, kept in sync with the cookie jar after each REST call/refresh. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CookieJar } from 'tough-cookie';
|
|
2
|
-
import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-
|
|
3
|
-
import { A as AxiamClient } from './client-
|
|
2
|
+
import { S as SharedSession, A as AxiamClientOptions, N as NodeTlsOptions } from './session-ti3C9ZJU.cjs';
|
|
3
|
+
import { A as AxiamClient } from './client-CtT9nHQP.cjs';
|
|
4
4
|
import { S as Sensitive } from './sensitive-BC_s7Rrd.cjs';
|
|
5
|
-
import { V as Verifier } from './jwks-
|
|
5
|
+
import { V as Verifier } from './jwks-DEiwxlku.cjs';
|
|
6
6
|
import { AxiosInstance } from 'axios';
|
|
7
7
|
|
|
8
8
|
/** Tracks the access/refresh token pair for a Node session, kept in sync with the cookie jar after each REST call/refresh. */
|
package/dist/grpc/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
2
|
import { Interceptor } from '@grpc/grpc-js';
|
|
3
|
-
import { N as NodeSession } from '../cookieJar-
|
|
4
|
-
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-
|
|
3
|
+
import { N as NodeSession } from '../cookieJar-DeJKczxD.cjs';
|
|
4
|
+
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-DeJKczxD.cjs';
|
|
5
5
|
import { a as AccessDecision } from '../types-BVkMoqLU.cjs';
|
|
6
|
-
export {
|
|
6
|
+
export { a as AxiamClaims, J as JWKS_PATH, V as Verifier, h as createVerifier } from '../jwks-DEiwxlku.cjs';
|
|
7
7
|
import 'tough-cookie';
|
|
8
|
-
import '../session-
|
|
8
|
+
import '../session-ti3C9ZJU.cjs';
|
|
9
9
|
import 'axios';
|
|
10
|
-
import '../client-
|
|
10
|
+
import '../client-CtT9nHQP.cjs';
|
|
11
11
|
import '../sensitive-BC_s7Rrd.cjs';
|
|
12
12
|
|
|
13
13
|
/**
|
package/dist/grpc/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
2
|
import { Interceptor } from '@grpc/grpc-js';
|
|
3
|
-
import { N as NodeSession } from '../cookieJar-
|
|
4
|
-
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-
|
|
3
|
+
import { N as NodeSession } from '../cookieJar-C9fqLqbh.js';
|
|
4
|
+
export { A as ACCESS_COOKIE, C as CSRF_COOKIE, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-C9fqLqbh.js';
|
|
5
5
|
import { a as AccessDecision } from '../types-BVkMoqLU.js';
|
|
6
|
-
export {
|
|
6
|
+
export { a as AxiamClaims, J as JWKS_PATH, V as Verifier, h as createVerifier } from '../jwks-DEiwxlku.js';
|
|
7
7
|
import 'tough-cookie';
|
|
8
|
-
import '../session-
|
|
8
|
+
import '../session-ti3C9ZJU.js';
|
|
9
9
|
import 'axios';
|
|
10
|
-
import '../client-
|
|
10
|
+
import '../client-utwuwc9m.js';
|
|
11
11
|
import '../sensitive-BC_s7Rrd.js';
|
|
12
12
|
|
|
13
13
|
/**
|
package/dist/grpc/index.js
CHANGED
|
@@ -537,6 +537,10 @@ var SharedSession = class {
|
|
|
537
537
|
orgId;
|
|
538
538
|
/** Configured organization slug (`AxiamClientOptions.orgSlug`), if supplied (§5). */
|
|
539
539
|
orgSlug;
|
|
540
|
+
/** Expected `iss` for locally-verified access tokens (§10.1 rule 5), if configured; `undefined` means no issuer check. */
|
|
541
|
+
expectedIssuer;
|
|
542
|
+
/** Expected `aud` for locally-verified access tokens (§10.1 rule 6), if configured; `undefined` means no audience check. */
|
|
543
|
+
expectedAudience;
|
|
540
544
|
/**
|
|
541
545
|
* Resolved tenant UUID used to build the `refresh` body (`RefreshRequest`
|
|
542
546
|
* requires the UUID form, not a slug). Seeded from `orgId`/`tenantId` config
|
|
@@ -574,6 +578,8 @@ var SharedSession = class {
|
|
|
574
578
|
this.tenantSlug = options.tenantSlug;
|
|
575
579
|
this.orgId = options.orgId;
|
|
576
580
|
this.orgSlug = options.orgSlug;
|
|
581
|
+
this.expectedIssuer = options.expectedIssuer;
|
|
582
|
+
this.expectedAudience = options.expectedAudience;
|
|
577
583
|
this.resolvedTenantId = options.tenantId;
|
|
578
584
|
this.resolvedOrgId = options.orgId;
|
|
579
585
|
this.refreshGuard = createRefreshGuard();
|
|
@@ -1189,6 +1195,7 @@ function checkIdTokenClaims(claims, expectations, nowSec = Math.floor(Date.now()
|
|
|
1189
1195
|
var JWKS_PATH = "/oauth2/jwks";
|
|
1190
1196
|
var COOLDOWN_DURATION_MS = 6e4;
|
|
1191
1197
|
var TIMEOUT_DURATION_MS = 5e3;
|
|
1198
|
+
var CLOCK_SKEW_LEEWAY_SEC = 60;
|
|
1192
1199
|
function createVerifier(baseUrl) {
|
|
1193
1200
|
return createJwksVerifier(`${baseUrl}${JWKS_PATH}`);
|
|
1194
1201
|
}
|
|
@@ -1206,7 +1213,20 @@ function createJwksVerifier(jwksUri) {
|
|
|
1206
1213
|
return jwksPromise;
|
|
1207
1214
|
}
|
|
1208
1215
|
return {
|
|
1209
|
-
async verifyAccessToken(token) {
|
|
1216
|
+
async verifyAccessToken(token, expectations) {
|
|
1217
|
+
const { jwtVerify } = await import('jose');
|
|
1218
|
+
const jwks = await getJwks();
|
|
1219
|
+
const { payload } = await jwtVerify(token, jwks, {
|
|
1220
|
+
algorithms: ["EdDSA"],
|
|
1221
|
+
requiredClaims: ["exp"],
|
|
1222
|
+
clockTolerance: CLOCK_SKEW_LEEWAY_SEC,
|
|
1223
|
+
...expectations.expectedIssuer !== void 0 ? { issuer: expectations.expectedIssuer } : {},
|
|
1224
|
+
...expectations.expectedAudience !== void 0 ? { audience: expectations.expectedAudience } : {}
|
|
1225
|
+
});
|
|
1226
|
+
assertTenantClaim(payload.tenant_id, expectations.expectedTenantId);
|
|
1227
|
+
return payload;
|
|
1228
|
+
},
|
|
1229
|
+
async verifySignatureOnlyUnchecked(token) {
|
|
1210
1230
|
const { jwtVerify } = await import('jose');
|
|
1211
1231
|
const jwks = await getJwks();
|
|
1212
1232
|
const { payload } = await jwtVerify(token, jwks, { algorithms: ["EdDSA"] });
|
|
@@ -1240,6 +1260,30 @@ function createJwksVerifier(jwksUri) {
|
|
|
1240
1260
|
}
|
|
1241
1261
|
};
|
|
1242
1262
|
}
|
|
1263
|
+
function assertTenantClaim(claim, expected) {
|
|
1264
|
+
if (typeof expected !== "string" || expected === "") {
|
|
1265
|
+
throw new AuthError(
|
|
1266
|
+
"no configured tenant to verify the token against; refusing the request (CONTRACT.md \xA710.1 rule 4 fails closed)"
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
if (typeof claim !== "string" || claim === "") {
|
|
1270
|
+
throw new AuthError("invalid tenant_id claim");
|
|
1271
|
+
}
|
|
1272
|
+
if (claim !== expected) {
|
|
1273
|
+
warnOnceIfComparandLooksLikeASlug(claim, expected);
|
|
1274
|
+
throw new AuthError("token tenant_id does not match configured tenant");
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1278
|
+
var slugComparandWarned = false;
|
|
1279
|
+
function warnOnceIfComparandLooksLikeASlug(claim, expected) {
|
|
1280
|
+
if (slugComparandWarned) return;
|
|
1281
|
+
if (!UUID_RE.test(claim) || UUID_RE.test(expected)) return;
|
|
1282
|
+
slugComparandWarned = true;
|
|
1283
|
+
console.warn(
|
|
1284
|
+
`AXIAM: the tenant this guard was configured with ("${expected}") is not a UUID, but access tokens carry the tenant UUID in their \`tenant_id\` claim, so this guard will reject every request. Configure it with the tenant UUID, not the slug. (CONTRACT.md \xA710.1 rule 4; logged once per process, and it does not affect the rejection itself.)`
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1243
1287
|
function mapJoseVerifyError(err) {
|
|
1244
1288
|
const code = typeof err === "object" && err !== null && "code" in err ? String(err.code) : "";
|
|
1245
1289
|
switch (code) {
|