@xemahq/app-platform-api-client 0.3.11 → 0.3.13

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.
@@ -47,6 +47,28 @@ export interface ClientConfig {
47
47
  getAuthToken?: () => Promise<string>;
48
48
  /** Optional callback returning headers to inject on every request. Per-call headers take precedence. */
49
49
  getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
50
+ /**
51
+ * Optional resolver for the CORRELATION ID of the request being made — the
52
+ * handle that ties one causal chain together across every service hop.
53
+ *
54
+ * WHY IT IS A CALLBACK AND NOT A VALUE. `ClientConfig` is process-global
55
+ * (`configureClient` is called once at wiring time), and a correlation id is
56
+ * per-request. This is invoked INSIDE the request, so a server can point it
57
+ * at whatever carries its ambient request context and get the CURRENT id
58
+ * rather than the one that happened to be live at boot.
59
+ *
60
+ * WHY THE TRANSPORT DOES NOT MINT ONE. Returning `undefined` sends no header,
61
+ * and the receiving service's `RequestContextMiddleware` mints its own — a
62
+ * new trace, which is honest. A transport that minted per call would produce
63
+ * a FRESH id on every hop while looking like propagation, which is strictly
64
+ * worse than none: every row would carry a correlation id and no two rows
65
+ * that belong together would share one. That is the exact defect this exists
66
+ * to fix, so the transport must not reproduce it one layer down.
67
+ *
68
+ * A caller-supplied `X-Correlation-Id` header always wins, and so does one
69
+ * from `getHeaders`.
70
+ */
71
+ getCorrelationId?: () => string | undefined | Promise<string | undefined>;
50
72
  /**
51
73
  * Optional callback invoked on a 401 before ONE re-attempt. Supplying it is
52
74
  * what opts this client into that re-attempt; without it a 401 comes back to
@@ -89,6 +89,16 @@ function getClientConfig() {
89
89
  */
90
90
  /** The only statuses that state the request was NOT processed. See above. */
91
91
  const RETRYABLE_STATUSES = [429, 503];
92
+ /**
93
+ * The platform's correlation header, spelled once.
94
+ *
95
+ * Value-identical to what `RequestContextMiddleware` reads in
96
+ * `@xemahq/platform-common`. It is a literal here rather than an import
97
+ * because this file has ZERO imports on purpose: it ships byte-identical into
98
+ * browser-target clients as well as server-target ones, and a dependency on a
99
+ * NestJS-peer package would follow it into every one of them.
100
+ */
101
+ const CORRELATION_ID_HEADER = 'X-Correlation-Id';
92
102
  /** Backoff floor, doubling per attempt up to {@link MAX_BACKOFF_MS}. */
93
103
  const BASE_BACKOFF_MS = 1000;
94
104
  /** Ceiling on a single backoff, however many attempts have elapsed. */
@@ -104,6 +114,23 @@ async function buildHeaders(config, callerHeaders) {
104
114
  }
105
115
  }
106
116
  }
117
+ // Correlation id (caller and global headers still take precedence).
118
+ //
119
+ // Without this, every server-to-server hop through a generated client started
120
+ // a NEW trace: the id is read-or-minted per hop by the receiving service's
121
+ // RequestContextMiddleware, and nothing carried it outbound — so an audit
122
+ // journal could record a whole causal chain and offer no way to join it back
123
+ // together.
124
+ //
125
+ // Absent resolver, or a resolver that answers `undefined`: NO header. The
126
+ // receiver mints and a new trace begins, which is the truthful outcome when
127
+ // there is nothing to continue.
128
+ if (config.getCorrelationId && !headers.has(CORRELATION_ID_HEADER)) {
129
+ const correlationId = await Promise.resolve(config.getCorrelationId());
130
+ if (correlationId) {
131
+ headers.set(CORRELATION_ID_HEADER, correlationId);
132
+ }
133
+ }
107
134
  // Auth token (caller or global headers take precedence)
108
135
  if (config.getAuthToken && !headers.has('Authorization')) {
109
136
  const token = await config.getAuthToken();
@@ -0,0 +1,5 @@
1
+ export declare const getDelegatedSessionJwksControllerJwksUrl: () => string;
2
+ /**
3
+ * @summary Public signing keys for delegated-session JWTs. Contains the ACTIVE key plus any key rotated out but still inside its publication window.
4
+ */
5
+ export declare const delegatedSessionJwksControllerJwks: (options?: RequestInit) => Promise<void>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.delegatedSessionJwksControllerJwks = exports.getDelegatedSessionJwksControllerJwksUrl = void 0;
4
+ /**
5
+ * Generated by @xemahq/api-client-generator — do not edit manually.
6
+ * App Runtime API
7
+ * OpenAPI spec version: 0.1.2
8
+ */
9
+ const custom_fetch_1 = require("../../custom-fetch");
10
+ const getDelegatedSessionJwksControllerJwksUrl = () => {
11
+ return `/public/.well-known/delegated-session-jwks.json`;
12
+ };
13
+ exports.getDelegatedSessionJwksControllerJwksUrl = getDelegatedSessionJwksControllerJwksUrl;
14
+ /**
15
+ * @summary Public signing keys for delegated-session JWTs. Contains the ACTIVE key plus any key rotated out but still inside its publication window.
16
+ */
17
+ const delegatedSessionJwksControllerJwks = async (options) => {
18
+ return (0, custom_fetch_1.customFetch)((0, exports.getDelegatedSessionJwksControllerJwksUrl)(), {
19
+ ...options,
20
+ method: 'GET'
21
+ });
22
+ };
23
+ exports.delegatedSessionJwksControllerJwks = delegatedSessionJwksControllerJwks;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { configureClient, getClientConfig, ClientError, customFetch, type ClientConfig, type RetryNotice } from './custom-fetch';
2
2
  export * from './models';
3
+ export * from './endpoints/delegated-session-keys/delegated-session-keys';
3
4
  export * from './endpoints/delegated-sessions/delegated-sessions';
4
5
  export * from './endpoints/project-apps/project-apps';
5
6
  export * from './endpoints/public-ingress/public-ingress';
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "getClientConfig", { enumerable: true, get: funct
22
22
  Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return custom_fetch_1.ClientError; } });
23
23
  Object.defineProperty(exports, "customFetch", { enumerable: true, get: function () { return custom_fetch_1.customFetch; } });
24
24
  __exportStar(require("./models"), exports);
25
+ __exportStar(require("./endpoints/delegated-session-keys/delegated-session-keys"), exports);
25
26
  __exportStar(require("./endpoints/delegated-sessions/delegated-sessions"), exports);
26
27
  __exportStar(require("./endpoints/project-apps/project-apps"), exports);
27
28
  __exportStar(require("./endpoints/public-ingress/public-ingress"), exports);
@@ -4,8 +4,12 @@
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
6
  export interface AnonAuthDto {
7
+ /** AppClient public identifier. */
8
+ clientId: string;
9
+ /** Plaintext AppClient secret. Required on EVERY external-auth door, the anonymous one included: "anonymous" describes the subject, never the caller — the App owner controls who may open sessions in its name. */
10
+ clientSecret: string;
7
11
  /** Optional client-supplied hint used for logging / debugging purposes. Not used for identity resolution — every call creates a fresh anon subject. */
8
12
  sessionHint?: string;
9
- /** AppClient id issuing this auth request. */
10
- appClientId: string;
13
+ /** Requested ExecutionEnvironment slug. Defaults to the App’s `defaultZone`, and either way must be in the resolved AudiencePolicy.allowedEnvironments[]. */
14
+ requestedZone?: string;
11
15
  }
@@ -12,4 +12,6 @@ export interface AnonAuthResultDto {
12
12
  sessionId: string;
13
13
  /** Subject ref minted into the token. */
14
14
  subjectRef: string;
15
+ /** ExecutionEnvironment slug the session was minted into. */
16
+ environment: string;
15
17
  }
@@ -4,7 +4,6 @@
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
6
  import type { AudienceKind } from './audienceKind.js';
7
- import type { AudiencePolicyDtoRateLimitPerHourPerSubject } from './audiencePolicyDtoRateLimitPerHourPerSubject.js';
8
7
  import type { AudienceUpstreamDto } from './audienceUpstreamDto.js';
9
8
  export interface AudiencePolicyDto {
10
9
  id: string;
@@ -12,8 +11,10 @@ export interface AudiencePolicyDto {
12
11
  kind: AudienceKind;
13
12
  allowedEnvironments: string[];
14
13
  authUpstream?: AudienceUpstreamDto | null;
15
- /** @nullable */
16
- rateLimitPerHourPerSubject?: AudiencePolicyDtoRateLimitPerHourPerSubject;
14
+ /** Session opens per hour for ONE identified external subject. Never null: a null used to mean "no limit", so an audience created without one was uncapped while reading as configured. */
15
+ rateLimitPerHourPerSubject: number;
16
+ /** Session opens per hour for the whole AppClient, across subjects. This is the cap the ANONYMOUS door is measured against — an anon subject is minted fresh on every call, so no per-subject bucket can bound it. */
17
+ rateLimitPerHourPerClient: number;
17
18
  createdAt: string;
18
19
  updatedAt: string;
19
20
  }
@@ -10,6 +10,8 @@ export interface CreateAudiencePolicyDto {
10
10
  /** ExecutionEnvironmentRef slugs this audience may invoke. Required. */
11
11
  allowedEnvironments: string[];
12
12
  authUpstream?: AudienceUpstreamDto;
13
- /** Rate cap (calls/hour/subject). */
13
+ /** Session opens per hour for ONE identified external subject. Omitted means the column default, NOT "unlimited" — there is no value that means unlimited. */
14
14
  rateLimitPerHourPerSubject?: number;
15
+ /** Session opens per hour for the whole AppClient, across subjects. This is the cap the ANONYMOUS door is measured against — an anon subject is minted fresh on every call, so no per-subject bucket can bound it. Omitted means the column default, NOT "unlimited". */
16
+ rateLimitPerHourPerClient?: number;
15
17
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ import type { SubjectKind } from './subjectKind.js';
7
+ export interface DelegatedSessionActorDto {
8
+ /** The acting party’s BARE identifier — an `AppClient.clientId`, never a `"<kind>:<id>"` composite. */
9
+ sub: string;
10
+ /** The acting party’s subject kind, stated explicitly by the issuer (wire claim `subject_kind`). Always `app-client` for a delegated session minted by app-platform-api. */
11
+ subjectKind: SubjectKind;
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -30,7 +30,6 @@ export * from './audienceKind';
30
30
  export * from './audiencePolicyDto';
31
31
  export * from './audiencePolicyDtoDataArrayEnvelope';
32
32
  export * from './audiencePolicyDtoDataEnvelope';
33
- export * from './audiencePolicyDtoRateLimitPerHourPerSubject';
34
33
  export * from './audienceUpstreamDto';
35
34
  export * from './audienceUpstreamDtoMetadata';
36
35
  export * from './audienceUpstreamType';
@@ -49,6 +48,7 @@ export * from './createdAppClientDtoDataEnvelope';
49
48
  export * from './createdAppClientDtoRevokedAt';
50
49
  export * from './createdPublicSessionDto';
51
50
  export * from './createdPublicSessionDtoDataEnvelope';
51
+ export * from './delegatedSessionActorDto';
52
52
  export * from './delegatedSessionDto';
53
53
  export * from './delegatedSessionDtoDataEnvelope';
54
54
  export * from './delegatedSessionDtoExternalSubjectId';
@@ -80,7 +80,6 @@ export * from './surfaceKind';
80
80
  export * from './tokenClass';
81
81
  export * from './unarchivePortalDto';
82
82
  export * from './updateAudiencePolicyDto';
83
- export * from './updateAudiencePolicyDtoRateLimitPerHourPerSubject';
84
83
  export * from './updatePortalDto';
85
84
  export * from './verifyDelegatedSessionRequestDto';
86
85
  export * from './verifyDelegatedSessionResponseDto';
@@ -47,7 +47,6 @@ __exportStar(require("./audienceKind"), exports);
47
47
  __exportStar(require("./audiencePolicyDto"), exports);
48
48
  __exportStar(require("./audiencePolicyDtoDataArrayEnvelope"), exports);
49
49
  __exportStar(require("./audiencePolicyDtoDataEnvelope"), exports);
50
- __exportStar(require("./audiencePolicyDtoRateLimitPerHourPerSubject"), exports);
51
50
  __exportStar(require("./audienceUpstreamDto"), exports);
52
51
  __exportStar(require("./audienceUpstreamDtoMetadata"), exports);
53
52
  __exportStar(require("./audienceUpstreamType"), exports);
@@ -66,6 +65,7 @@ __exportStar(require("./createdAppClientDtoDataEnvelope"), exports);
66
65
  __exportStar(require("./createdAppClientDtoRevokedAt"), exports);
67
66
  __exportStar(require("./createdPublicSessionDto"), exports);
68
67
  __exportStar(require("./createdPublicSessionDtoDataEnvelope"), exports);
68
+ __exportStar(require("./delegatedSessionActorDto"), exports);
69
69
  __exportStar(require("./delegatedSessionDto"), exports);
70
70
  __exportStar(require("./delegatedSessionDtoDataEnvelope"), exports);
71
71
  __exportStar(require("./delegatedSessionDtoExternalSubjectId"), exports);
@@ -97,7 +97,6 @@ __exportStar(require("./surfaceKind"), exports);
97
97
  __exportStar(require("./tokenClass"), exports);
98
98
  __exportStar(require("./unarchivePortalDto"), exports);
99
99
  __exportStar(require("./updateAudiencePolicyDto"), exports);
100
- __exportStar(require("./updateAudiencePolicyDtoRateLimitPerHourPerSubject"), exports);
101
100
  __exportStar(require("./updatePortalDto"), exports);
102
101
  __exportStar(require("./verifyDelegatedSessionRequestDto"), exports);
103
102
  __exportStar(require("./verifyDelegatedSessionResponseDto"), exports);
@@ -4,8 +4,12 @@
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
6
  export interface OidcAuthDto {
7
+ /** AppClient public identifier. */
8
+ clientId: string;
9
+ /** Plaintext AppClient secret. Required on EVERY external-auth door, the anonymous one included: "anonymous" describes the subject, never the caller — the App owner controls who may open sessions in its name. */
10
+ clientSecret: string;
7
11
  /** OIDC id_token issued by the upstream identity provider configured for this App. */
8
12
  idToken: string;
9
- /** AppClient id issuing this auth request. */
10
- appClientId: string;
13
+ /** Requested ExecutionEnvironment slug. Defaults to the App’s `defaultZone`, and either way must be in the resolved AudiencePolicy.allowedEnvironments[]. */
14
+ requestedZone?: string;
11
15
  }
@@ -12,4 +12,6 @@ export interface OidcAuthResultDto {
12
12
  sessionId: string;
13
13
  /** Subject ref minted into the token. */
14
14
  subjectRef: string;
15
+ /** ExecutionEnvironment slug the session was minted into. */
16
+ environment: string;
15
17
  }
@@ -4,8 +4,10 @@
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
6
  export interface RequestMagicLinkDto {
7
+ /** AppClient public identifier. */
8
+ clientId: string;
9
+ /** Plaintext AppClient secret. Required on EVERY external-auth door, the anonymous one included: "anonymous" describes the subject, never the caller — the App owner controls who may open sessions in its name. */
10
+ clientSecret: string;
7
11
  /** Email address to send the magic-link to. Used as the external subject identifier. */
8
12
  email: string;
9
- /** AppClient id issuing this auth request. */
10
- appClientId: string;
11
13
  }
@@ -4,10 +4,9 @@
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
6
  import type { AudienceUpstreamDto } from './audienceUpstreamDto.js';
7
- import type { UpdateAudiencePolicyDtoRateLimitPerHourPerSubject } from './updateAudiencePolicyDtoRateLimitPerHourPerSubject.js';
8
7
  export interface UpdateAudiencePolicyDto {
9
8
  allowedEnvironments?: string[];
10
9
  authUpstream?: AudienceUpstreamDto | null;
11
- /** @nullable */
12
- rateLimitPerHourPerSubject?: UpdateAudiencePolicyDtoRateLimitPerHourPerSubject;
10
+ rateLimitPerHourPerSubject?: number;
11
+ rateLimitPerHourPerClient?: number;
13
12
  }
@@ -3,12 +3,13 @@
3
3
  * App Runtime API
4
4
  * OpenAPI spec version: 0.1.2
5
5
  */
6
+ import type { DelegatedSessionActorDto } from './delegatedSessionActorDto.js';
6
7
  import type { TokenClass } from './tokenClass.js';
7
8
  export interface VerifyDelegatedSessionResponseDto {
8
9
  /** Id of the App this delegated session was minted FOR (the owning `App.id`, resolved from the backing session row). A consumer edge MUST bind the session to exactly this app before serving app data. */
9
10
  appId: string;
10
11
  sub: string;
11
- act: string;
12
+ act: DelegatedSessionActorDto;
12
13
  org: string;
13
14
  project: string;
14
15
  session: string;
@@ -12,4 +12,6 @@ export interface VerifyMagicLinkResultDto {
12
12
  sessionId: string;
13
13
  /** Subject ref minted into the token. */
14
14
  subjectRef: string;
15
+ /** ExecutionEnvironment slug the session was minted into. */
16
+ environment: string;
15
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/app-platform-api-client",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -20,7 +20,7 @@
20
20
  "service": "app-platform-api",
21
21
  "biome": "app-platform",
22
22
  "target": "server",
23
- "generator": "@xemahq/api-client-generator@0.12.1",
23
+ "generator": "@xemahq/api-client-generator@0.14.1",
24
24
  "source": "openapi.public.json"
25
25
  },
26
26
  "license": "LicenseRef-Xema-BSL-1.1",
@@ -1,11 +0,0 @@
1
- /**
2
- * Generated by @xemahq/api-client-generator — do not edit manually.
3
- * App Runtime API
4
- * OpenAPI spec version: 0.1.2
5
- */
6
- /**
7
- * @nullable
8
- */
9
- export type AudiencePolicyDtoRateLimitPerHourPerSubject = {
10
- [key: string]: unknown;
11
- } | null;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * Generated by @xemahq/api-client-generator — do not edit manually.
4
- * App Runtime API
5
- * OpenAPI spec version: 0.1.2
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- /**
2
- * Generated by @xemahq/api-client-generator — do not edit manually.
3
- * App Runtime API
4
- * OpenAPI spec version: 0.1.2
5
- */
6
- /**
7
- * @nullable
8
- */
9
- export type UpdateAudiencePolicyDtoRateLimitPerHourPerSubject = {
10
- [key: string]: unknown;
11
- } | null;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * Generated by @xemahq/api-client-generator — do not edit manually.
4
- * App Runtime API
5
- * OpenAPI spec version: 0.1.2
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });