axiam-sdk 1.0.0-alpha19 → 1.0.0-alpha21

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.
Files changed (62) hide show
  1. package/README.md +155 -4
  2. package/dist/amqp/index.d.cts +1 -1
  3. package/dist/amqp/index.d.ts +1 -1
  4. package/dist/amqp/index.js +4 -0
  5. package/dist/amqp/index.js.map +1 -1
  6. package/dist/amqp/index.mjs +4 -0
  7. package/dist/amqp/index.mjs.map +1 -1
  8. package/dist/{authzCore-CcTdIf78.d.ts → authzCore-DtSN59if.d.ts} +2 -2
  9. package/dist/{authzCore-B7GSd3-t.d.cts → authzCore-DuRI1aJf.d.cts} +2 -2
  10. package/dist/client-B_FqmZ0i.d.cts +72 -0
  11. package/dist/client-Dn1fs5MH.d.ts +72 -0
  12. package/dist/cookieJar-BTDnjjbL.d.cts +122 -0
  13. package/dist/cookieJar-Cl8Lq9dL.d.ts +122 -0
  14. package/dist/grpc/index.d.cts +6 -5
  15. package/dist/grpc/index.d.ts +6 -5
  16. package/dist/grpc/index.js +178 -4
  17. package/dist/grpc/index.js.map +1 -1
  18. package/dist/grpc/index.mjs +178 -4
  19. package/dist/grpc/index.mjs.map +1 -1
  20. package/dist/index.d.cts +4 -2
  21. package/dist/index.d.ts +4 -2
  22. package/dist/index.js +76 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +71 -4
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/jwks-BgojMGC5.d.cts +152 -0
  27. package/dist/jwks-BgojMGC5.d.ts +152 -0
  28. package/dist/middleware/index.d.cts +194 -4
  29. package/dist/middleware/index.d.ts +194 -4
  30. package/dist/middleware/index.js +1107 -1
  31. package/dist/middleware/index.js.map +1 -1
  32. package/dist/middleware/index.mjs +1100 -3
  33. package/dist/middleware/index.mjs.map +1 -1
  34. package/dist/nestjs/index.d.cts +2 -2
  35. package/dist/nestjs/index.d.ts +2 -2
  36. package/dist/nestjs/index.js +3 -0
  37. package/dist/nestjs/index.js.map +1 -1
  38. package/dist/nestjs/index.mjs +3 -0
  39. package/dist/nestjs/index.mjs.map +1 -1
  40. package/dist/node/index.d.cts +50 -113
  41. package/dist/node/index.d.ts +50 -113
  42. package/dist/node/index.js +873 -4
  43. package/dist/node/index.js.map +1 -1
  44. package/dist/node/index.mjs +857 -5
  45. package/dist/node/index.mjs.map +1 -1
  46. package/dist/oidcState-BGxqWUun.d.cts +598 -0
  47. package/dist/oidcState-CkFuCjpM.d.ts +598 -0
  48. package/dist/rest/index.d.cts +107 -5
  49. package/dist/rest/index.d.ts +107 -5
  50. package/dist/rest/index.js +76 -3
  51. package/dist/rest/index.js.map +1 -1
  52. package/dist/rest/index.mjs +71 -4
  53. package/dist/rest/index.mjs.map +1 -1
  54. package/dist/sensitive-BC_s7Rrd.d.cts +39 -0
  55. package/dist/sensitive-BC_s7Rrd.d.ts +39 -0
  56. package/dist/{client-Co_baHgU.d.ts → session-BWUWhhyB.d.cts} +1 -70
  57. package/dist/{client-CzhzwRGg.d.cts → session-BWUWhhyB.d.ts} +1 -70
  58. package/package.json +2 -2
  59. package/dist/jwks-B8dPy2c6.d.cts +0 -36
  60. package/dist/jwks-B8dPy2c6.d.ts +0 -36
  61. package/dist/sensitive-CWBH_tHr.d.cts +0 -12
  62. package/dist/sensitive-CWBH_tHr.d.ts +0 -12
@@ -1,123 +1,60 @@
1
- import { CookieJar } from 'tough-cookie';
2
- import { S as SharedSession, A as AxiamClientOptions, a as AxiamClient } from '../client-Co_baHgU.js';
3
- import { S as Sensitive } from '../sensitive-CWBH_tHr.js';
4
- import { V as Verifier } from '../jwks-B8dPy2c6.js';
5
- export { A as AxiamClaims, J as JWKS_PATH, c as createVerifier } from '../jwks-B8dPy2c6.js';
6
- import { AxiosInstance } from 'axios';
1
+ export { A as ACCESS_COOKIE, C as CSRF_COOKIE, N as NodeSession, R as REFRESH_COOKIE, T as TokenManager, c as createJar, a as createNodeClient, b as createNodeSession, e as extractCookieValue, w as wrapAxios } from '../cookieJar-Cl8Lq9dL.js';
2
+ export { A as AxiamClaims, I as ID_TOKEN_ALG, a as IdTokenClaims, b as IdTokenExpectations, c as IdTokenVerifier, J as JWKS_PATH, d as JwksVerifier, M as MAX_CLOCK_SKEW_SEC, V as Verifier, e as createJwksVerifier, f as createVerifier } from '../jwks-BgojMGC5.js';
3
+ export { A as AuthorizationRequest, D as DISCOVERY_PATH, I as IntrospectParams, a as IntrospectionResult, L as LoginClientCredentialsParams, M as MIN_DISCOVERY_TTL_MS, b as MemoryOidcStateStore, O as OIDC_STATE_TTL_MS, c as OidcBeginParams, d as OidcClient, e as OidcClientOptions, f as OidcConfiguration, g as OidcExchangeParams, h as OidcRefreshParams, i as OidcStateEntry, j as OidcStateStore, k as OidcTokenSet, R as RevokeParams, S as SSO_CALLBACK_PATH, l as SSO_START_PATH, m as SsoCompleteParams, n as SsoCompleteResult, o as SsoStartParams, p as SsoStartResult, q as createOidcClient, r as normalizeOrigin } from '../oidcState-CkFuCjpM.js';
4
+ import { S as Sensitive } from '../sensitive-BC_s7Rrd.js';
5
+ import 'tough-cookie';
6
+ import '../session-BWUWhhyB.js';
7
+ import 'axios';
8
+ import '../client-Dn1fs5MH.js';
7
9
  import '../types-BVkMoqLU.js';
8
10
 
9
- /** Tracks the access/refresh token pair for a Node session, kept in sync with the cookie jar after each REST call/refresh. */
10
- declare class TokenManager {
11
- #private;
12
- constructor(jar: CookieJar, baseUrl: string, tenantId?: string);
13
- /**
14
- * Synchronous, best-effort read of the last-known access token. Returns
15
- * `null` if no token has been cached yet (no request/refresh has
16
- * completed since construction, or `syncFromJar()` was never called).
17
- */
18
- cachedAccessToken(): Sensitive<string> | null;
19
- /**
20
- * Async read of the current `axiam_refresh` cookie value from the jar,
21
- * wrapped in Sensitive<T>. Queried against the refresh endpoint's URL
22
- * since the cookie is path-scoped to `/api/v1/auth/refresh` (not visible
23
- * at the bare base URL).
24
- */
25
- refreshTokenValue(): Promise<Sensitive<string> | null>;
26
- /**
27
- * Refresh the in-memory cached access token from the jar. Call this after
28
- * every REST request/refresh so the synchronous gRPC-interceptor fast-path
29
- * (`cachedAccessToken()`) stays current (Pitfall 3).
30
- */
31
- syncFromJar(): Promise<void>;
32
- /** The resolved tenant identifier (slug or UUID form), if known. */
33
- tenantId(): string | undefined;
34
- /** Set/update the resolved tenant identifier (e.g. after decoding the access token's tenant_id claim). */
35
- setTenantId(tenantId: string): void;
36
- /**
37
- * Best-effort decode of the `tenant_id`/`org_id` claims out of the cached
38
- * access token, WITHOUT signature verification. Used only to populate the
39
- * `refresh` request body (`RefreshRequest` requires both UUIDs) — never as a
40
- * trust decision: the actual credential is the httpOnly `axiam_access` cookie
41
- * the server verifies, and the server re-derives the authoritative `org_id`
42
- * from the tenant on refresh (see crates/axiam-api-rest handlers/auth.rs),
43
- * so echoing these values back carries no security weight. A malformed or
44
- * absent token yields an empty result (the caller then keeps whatever UUIDs
45
- * were resolved from construction options).
46
- */
47
- claimsFromCachedToken(): {
48
- tenantId?: string;
49
- orgId?: string;
50
- };
51
- /** Clear all cached token state (used by logout()). */
52
- clear(): void;
53
- }
54
-
55
- /** Node-only {@link SharedSession} adding a {@link TokenManager} and a JWKS {@link Verifier} for local (offline) access-token verification. */
56
- declare class NodeSession extends SharedSession {
57
- #private;
58
- /** Manages the access/refresh token pair backing this session. */
59
- readonly tokenManager: TokenManager;
60
- /** Local JWKS verifier for validating access tokens without a server round-trip. */
61
- readonly jwksVerifier: Verifier;
62
- constructor(options: AxiamClientOptions, base: SharedSession, tokenManager: TokenManager, jwksVerifier: Verifier, jar: CookieJar);
63
- /**
64
- * Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
65
- * session's per-instance `refreshGuard` (inherited from SharedSession) by
66
- * both REST's reactive interceptor (rest/interceptors.ts) and gRPC's
67
- * callWithRefresh — since `refreshGuard` is scoped to THIS session
68
- * instance (CR-02, D-13), both transports share exactly one in-flight
69
- * refresh for this session regardless of which one triggers it, while
70
- * remaining fully independent from any other session's guard.
71
- */
72
- doRefresh: () => Promise<void>;
73
- /**
74
- * Session-level hook (CR-01, D-05) invoked by rest/auth.ts after a
75
- * successful login()/verifyMfa(). Refreshes the cached access token (so
76
- * the gRPC interceptor's synchronous fast-path is current immediately
77
- * after login) and reads the `axiam_csrf` cookie out of the jar into
78
- * `session.csrfToken`, mirroring TokenManager.syncFromJar()'s pattern.
79
- */
80
- onAuthenticated: () => Promise<void>;
81
- }
82
- /** Build the Node persona's session: REST SharedSession + cookie jar + TokenManager + JWKS verifier. */
83
- declare function createNodeSession(options: AxiamClientOptions): NodeSession;
84
11
  /**
85
- * Build an `AxiamClient` wired to the Node persona (SDK-Q05). This is the Node
86
- * counterpart to `new AxiamClient(options)` (which builds the browser
87
- * `SharedSession` with no cookie jar): it constructs a `NodeSession`
88
- * (tough-cookie jar + CSRF/refresh token sync) and adopts it via the
89
- * `AxiamClient` session-injection constructor, so httpOnly `Set-Cookie` tokens
90
- * from login/refresh persist and every post-login REST call authenticates
91
- * correctly under Node.
12
+ * The only PKCE code-challenge method this SDK emits (RFC 7636 §4.2,
13
+ * CONTRACT.md §12.1 rule 3). `plain` is intentionally absent.
14
+ */
15
+ declare const CODE_CHALLENGE_METHOD_S256 = "S256";
16
+ /**
17
+ * Entropy, in bytes, of a generated `state` / `nonce` / `code_verifier`.
92
18
  *
93
- * Lives in this Node-only module (reachable via the `axiam-sdk/node` and
94
- * `axiam-sdk/grpc` subpaths) rather than in the browser-safe `axiam-sdk/rest`
95
- * entry, so browser bundles never pull in tough-cookie/jose/node:https (SC#1).
96
- * The returned client shares the single session with any `AuthzGrpcClient`
97
- * built from the same `NodeSession`.
19
+ * §12.1 rule 1 requires at least 16 bytes (128 bits) and RECOMMENDS 32;
20
+ * rule 2 RECOMMENDS 32 bytes for the verifier, which base64url-encodes to
21
+ * exactly 43 characters — the minimum RFC 7636 §4.1 length, drawn only from
22
+ * the unreserved set `[A-Za-z0-9-._~]`.
98
23
  */
99
- declare function createNodeClient(options: AxiamClientOptions): AxiamClient;
100
-
101
- /** The `axiam_access` cookie name (httpOnly, path `/`). */
102
- declare const ACCESS_COOKIE = "axiam_access";
103
- /** The `axiam_refresh` cookie name (httpOnly, path-scoped to `/api/v1/auth/refresh`). */
104
- declare const REFRESH_COOKIE = "axiam_refresh";
105
- /** The `axiam_csrf` cookie name (JS-readable, path `/`). */
106
- declare const CSRF_COOKIE = "axiam_csrf";
107
- /** Construct a fresh, per-client-instance cookie jar (§4 — never process-global). */
108
- declare function createJar(): CookieJar;
24
+ declare const CSPRNG_BYTES = 32;
25
+ /**
26
+ * Generate a URL-safe random token: `bytes` CSPRNG bytes, base64url-encoded
27
+ * **without** padding (RFC 4648 §5 — Node's `'base64url'` encoding never
28
+ * emits `=`).
29
+ *
30
+ * Used for both `state` and `nonce`, which §12.3 rule 2 classes as
31
+ * **non-secret**: they are returned as plain strings, are echoed through the
32
+ * browser's address bar by construction, and are safe to log.
33
+ */
34
+ declare function randomUrlSafeToken(bytes?: number): string;
109
35
  /**
110
- * Wrap an axios instance with `axios-cookiejar-support` so the jar persists
111
- * `Set-Cookie` responses across requests and replays them on subsequent
112
- * requests to the same origin/path (§4). Mutates and returns the same
113
- * instance (matches `axios-cookiejar-support`'s documented in-place wrap).
36
+ * Generate a fresh PKCE `code_verifier` (RFC 7636 §4.1): 32 CSPRNG bytes
37
+ * base64url-encoded without padding, i.e. 43 characters from the unreserved
38
+ * set.
39
+ *
40
+ * Returned already wrapped in {@link Sensitive} — §12.5 makes the verifier
41
+ * secret **for its whole lifetime**, including while it sits in the
42
+ * `AuthorizationRequest` handed back to the caller and in any
43
+ * `OidcStateStore` entry.
114
44
  */
115
- declare function wrapAxios(instance: AxiosInstance, jar: CookieJar): AxiosInstance;
45
+ declare function generateCodeVerifier(): Sensitive<string>;
116
46
  /**
117
- * Read a single cookie's value out of the jar by name, for the given URL.
118
- * This is the ONLY token-source path (RESEARCH.md Area 3 — no JSON-body
119
- * fallback exists on the wire).
47
+ * Derive the PKCE `code_challenge` from a verifier:
48
+ * `BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))`, unpadded
49
+ * (RFC 7636 §4.2, CONTRACT.md §12.1 rule 3).
50
+ *
51
+ * The verifier is hashed as ASCII exactly as the RFC specifies. Verified
52
+ * against the RFC 7636 Appendix B test vector in
53
+ * `test/node/oidcPkce.test.ts`, which every SDK must carry (§12.1 rule 3).
54
+ *
55
+ * The challenge is a one-way digest and is **not** secret — it travels in the
56
+ * authorization URL — so it is returned as a plain string.
120
57
  */
121
- declare function extractCookieValue(jar: CookieJar, url: string, name: string): Promise<string | undefined>;
58
+ declare function computeCodeChallenge(codeVerifier: string): string;
122
59
 
123
- export { ACCESS_COOKIE, CSRF_COOKIE, NodeSession, REFRESH_COOKIE, TokenManager, Verifier, createJar, createNodeClient, createNodeSession, extractCookieValue, wrapAxios };
60
+ export { CODE_CHALLENGE_METHOD_S256, CSPRNG_BYTES, computeCodeChallenge, generateCodeVerifier, randomUrlSafeToken };