axiam-sdk 1.0.0-alpha2 → 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 (64) hide show
  1. package/README.md +219 -8
  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-xwmCivHH.d.ts → authzCore-DtSN59if.d.ts} +19 -2
  9. package/dist/{authzCore-CV-Td-V1.d.cts → authzCore-DuRI1aJf.d.cts} +19 -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 +113 -6
  15. package/dist/grpc/index.d.ts +113 -6
  16. package/dist/grpc/index.js +435 -18
  17. package/dist/grpc/index.js.map +1 -1
  18. package/dist/grpc/index.mjs +434 -19
  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 +209 -13
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +204 -14
  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 +208 -8
  29. package/dist/middleware/index.d.ts +208 -8
  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 -94
  41. package/dist/node/index.d.ts +50 -94
  42. package/dist/node/index.js +1039 -15
  43. package/dist/node/index.js.map +1 -1
  44. package/dist/node/index.mjs +1023 -16
  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 +209 -13
  51. package/dist/rest/index.js.map +1 -1
  52. package/dist/rest/index.mjs +204 -14
  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/session-BWUWhhyB.d.cts +154 -0
  57. package/dist/session-BWUWhhyB.d.ts +154 -0
  58. package/package.json +2 -2
  59. package/dist/client-BPg9kfKV.d.ts +0 -150
  60. package/dist/client-CAeQw1a-.d.cts +0 -150
  61. package/dist/jwks-CX-nhD6A.d.cts +0 -29
  62. package/dist/jwks-CX-nhD6A.d.ts +0 -29
  63. package/dist/sensitive-CWBH_tHr.d.cts +0 -12
  64. package/dist/sensitive-CWBH_tHr.d.ts +0 -12
@@ -1,104 +1,60 @@
1
- import { CookieJar } from 'tough-cookie';
2
- import { S as SharedSession, A as AxiamClientOptions, a as AxiamClient } from '../client-BPg9kfKV.js';
3
- import { S as Sensitive } from '../sensitive-CWBH_tHr.js';
4
- import { V as Verifier } from '../jwks-CX-nhD6A.js';
5
- export { A as AxiamClaims, J as JWKS_PATH, c as createVerifier } from '../jwks-CX-nhD6A.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
- declare class TokenManager {
10
- #private;
11
- constructor(jar: CookieJar, baseUrl: string, tenantId?: string);
12
- /**
13
- * Synchronous, best-effort read of the last-known access token. Returns
14
- * `null` if no token has been cached yet (no request/refresh has
15
- * completed since construction, or `syncFromJar()` was never called).
16
- */
17
- cachedAccessToken(): Sensitive<string> | null;
18
- /**
19
- * Async read of the current `axiam_refresh` cookie value from the jar,
20
- * wrapped in Sensitive<T>. Queried against the refresh endpoint's URL
21
- * since the cookie is path-scoped to `/api/v1/auth/refresh` (not visible
22
- * at the bare base URL).
23
- */
24
- refreshTokenValue(): Promise<Sensitive<string> | null>;
25
- /**
26
- * Refresh the in-memory cached access token from the jar. Call this after
27
- * every REST request/refresh so the synchronous gRPC-interceptor fast-path
28
- * (`cachedAccessToken()`) stays current (Pitfall 3).
29
- */
30
- syncFromJar(): Promise<void>;
31
- /** The resolved tenant identifier (slug or UUID form), if known. */
32
- tenantId(): string | undefined;
33
- /** Set/update the resolved tenant identifier (e.g. after decoding the access token's tenant_id claim). */
34
- setTenantId(tenantId: string): void;
35
- /** Clear all cached token state (used by logout()). */
36
- clear(): void;
37
- }
38
-
39
- declare class NodeSession extends SharedSession {
40
- #private;
41
- readonly tokenManager: TokenManager;
42
- readonly jwksVerifier: Verifier;
43
- constructor(options: AxiamClientOptions, base: SharedSession, tokenManager: TokenManager, jwksVerifier: Verifier, jar: CookieJar);
44
- /**
45
- * Drives the actual `POST /api/v1/auth/refresh` HTTP call. Passed to this
46
- * session's per-instance `refreshGuard` (inherited from SharedSession) by
47
- * both REST's reactive interceptor (rest/interceptors.ts) and gRPC's
48
- * callWithRefresh — since `refreshGuard` is scoped to THIS session
49
- * instance (CR-02, D-13), both transports share exactly one in-flight
50
- * refresh for this session regardless of which one triggers it, while
51
- * remaining fully independent from any other session's guard.
52
- */
53
- doRefresh: () => Promise<void>;
54
- /**
55
- * Session-level hook (CR-01, D-05) invoked by rest/auth.ts after a
56
- * successful login()/verifyMfa(). Refreshes the cached access token (so
57
- * the gRPC interceptor's synchronous fast-path is current immediately
58
- * after login) and reads the `axiam_csrf` cookie out of the jar into
59
- * `session.csrfToken`, mirroring TokenManager.syncFromJar()'s pattern.
60
- */
61
- onAuthenticated: () => Promise<void>;
62
- }
63
- /** Build the Node persona's session: REST SharedSession + cookie jar + TokenManager + JWKS verifier. */
64
- declare function createNodeSession(options: AxiamClientOptions): NodeSession;
65
11
  /**
66
- * Build an `AxiamClient` wired to the Node persona (SDK-Q05). This is the Node
67
- * counterpart to `new AxiamClient(options)` (which builds the browser
68
- * `SharedSession` with no cookie jar): it constructs a `NodeSession`
69
- * (tough-cookie jar + CSRF/refresh token sync) and adopts it via the
70
- * `AxiamClient` session-injection constructor, so httpOnly `Set-Cookie` tokens
71
- * from login/refresh persist and every post-login REST call authenticates
72
- * 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`.
73
18
  *
74
- * Lives in this Node-only module (reachable via the `axiam-sdk/node` and
75
- * `axiam-sdk/grpc` subpaths) rather than in the browser-safe `axiam-sdk/rest`
76
- * entry, so browser bundles never pull in tough-cookie/jose/node:https (SC#1).
77
- * The returned client shares the single session with any `AuthzGrpcClient`
78
- * 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-._~]`.
79
23
  */
80
- declare function createNodeClient(options: AxiamClientOptions): AxiamClient;
81
-
82
- /** The `axiam_access` cookie name (httpOnly, path `/`). */
83
- declare const ACCESS_COOKIE = "axiam_access";
84
- /** The `axiam_refresh` cookie name (httpOnly, path-scoped to `/api/v1/auth/refresh`). */
85
- declare const REFRESH_COOKIE = "axiam_refresh";
86
- /** The `axiam_csrf` cookie name (JS-readable, path `/`). */
87
- declare const CSRF_COOKIE = "axiam_csrf";
88
- /** Construct a fresh, per-client-instance cookie jar (§4 — never process-global). */
89
- 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;
90
35
  /**
91
- * Wrap an axios instance with `axios-cookiejar-support` so the jar persists
92
- * `Set-Cookie` responses across requests and replays them on subsequent
93
- * requests to the same origin/path (§4). Mutates and returns the same
94
- * 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.
95
44
  */
96
- declare function wrapAxios(instance: AxiosInstance, jar: CookieJar): AxiosInstance;
45
+ declare function generateCodeVerifier(): Sensitive<string>;
97
46
  /**
98
- * Read a single cookie's value out of the jar by name, for the given URL.
99
- * This is the ONLY token-source path (RESEARCH.md Area 3 — no JSON-body
100
- * 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.
101
57
  */
102
- declare function extractCookieValue(jar: CookieJar, url: string, name: string): Promise<string | undefined>;
58
+ declare function computeCodeChallenge(codeVerifier: string): string;
103
59
 
104
- 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 };