@centrali-io/centrali-sdk 9.3.3 → 9.4.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/dist/index.d.ts +1 -150
- package/dist/index.js +2 -138
- package/index.ts +0 -2
- package/package.json +1 -1
- package/src/client.ts +0 -25
- package/src/internal/auth.ts +0 -14
- package/src/managers/embed.ts +0 -180
- package/src/types/embed.ts +0 -59
package/dist/index.d.ts
CHANGED
|
@@ -3155,59 +3155,6 @@ interface AddAllowedDomainOptions {
|
|
|
3155
3155
|
domain: string;
|
|
3156
3156
|
}
|
|
3157
3157
|
|
|
3158
|
-
/**
|
|
3159
|
-
* Types for the Event Log embed surface (CEN-1301).
|
|
3160
|
-
*
|
|
3161
|
-
* Mirrors the request/response shapes defined by IAM at
|
|
3162
|
-
* services/backend/iam/src/controllers/embedTokenController.ts.
|
|
3163
|
-
* Keep field names in sync with that controller's Zod schemas.
|
|
3164
|
-
*/
|
|
3165
|
-
/**
|
|
3166
|
-
* Capabilities that can be encoded into an embed token.
|
|
3167
|
-
*
|
|
3168
|
-
* - `events:read` — list + retrieve the workspace's event-log rows.
|
|
3169
|
-
* IAM unconditionally injects this on every minted token, so omitting
|
|
3170
|
-
* `capabilities` is equivalent to `['events:read']`.
|
|
3171
|
-
* - `events:replay` — allow the iframe to replay a failed delivery. The
|
|
3172
|
-
* issuing service account must also hold `webhook-subscriptions:replay`.
|
|
3173
|
-
*/
|
|
3174
|
-
type EmbedCapability = 'events:read' | 'events:replay';
|
|
3175
|
-
interface IssueEmbedTokenInput {
|
|
3176
|
-
/**
|
|
3177
|
-
* Defaults to `['events:read']`. Pass `['events:read', 'events:replay']`
|
|
3178
|
-
* to allow the iframe's "Replay" action. The issuing service account
|
|
3179
|
-
* must already hold the corresponding capability.
|
|
3180
|
-
*/
|
|
3181
|
-
capabilities?: EmbedCapability[];
|
|
3182
|
-
/**
|
|
3183
|
-
* Optional cohort id. Useful if you want to revoke every token issued
|
|
3184
|
-
* for one of your end-users on logout — mint each with the same
|
|
3185
|
-
* `sessionId`, then call `revokeSession({ sessionId })` later. Server
|
|
3186
|
-
* mints a random one if omitted (returned in the response).
|
|
3187
|
-
*/
|
|
3188
|
-
sessionId?: string;
|
|
3189
|
-
/**
|
|
3190
|
-
* Token TTL in seconds. Defaults to 600 (10 min). Capped at 3600 (1h)
|
|
3191
|
-
* server-side; out-of-range values 400.
|
|
3192
|
-
*/
|
|
3193
|
-
ttlSeconds?: number;
|
|
3194
|
-
}
|
|
3195
|
-
interface IssueEmbedTokenResult {
|
|
3196
|
-
/** `ev_…` JWT for the iframe's URL fragment. */
|
|
3197
|
-
token: string;
|
|
3198
|
-
/** Echo of the input sessionId, or the server-minted one if omitted. */
|
|
3199
|
-
sessionId: string;
|
|
3200
|
-
/** ISO-8601 timestamp at which the token's `exp` claim fires. */
|
|
3201
|
-
expiresAt: string;
|
|
3202
|
-
}
|
|
3203
|
-
interface RevokeEmbedSessionInput {
|
|
3204
|
-
sessionId: string;
|
|
3205
|
-
}
|
|
3206
|
-
interface RevokeEmbedSessionResult {
|
|
3207
|
-
sessionId: string;
|
|
3208
|
-
revokedAt: string;
|
|
3209
|
-
}
|
|
3210
|
-
|
|
3211
3158
|
/**
|
|
3212
3159
|
* Internal configuration for realtime connections.
|
|
3213
3160
|
*/
|
|
@@ -5800,90 +5747,6 @@ declare class SubscribersManager {
|
|
|
5800
5747
|
publish(externalId: string, input: PublishToSubscriberInput): Promise<ApiResponse<PublishToSubscriberResult>>;
|
|
5801
5748
|
}
|
|
5802
5749
|
|
|
5803
|
-
/**
|
|
5804
|
-
* Embed manager — server-side helpers for the white-label Event Log iframe
|
|
5805
|
-
* (`embed.centrali.io/v1/event-log`, CEN-1301).
|
|
5806
|
-
*
|
|
5807
|
-
* Why this lives outside the main axios instance:
|
|
5808
|
-
* The shared client mints workspace JWTs with `resource=<data-service>`,
|
|
5809
|
-
* so its `aud` claim is the data plane. IAM's embed issuance endpoint
|
|
5810
|
-
* explicitly rejects data-audienced tokens (`audience_mismatch`) — see
|
|
5811
|
-
* services/backend/iam/src/controllers/embedTokenController.ts. This
|
|
5812
|
-
* manager keeps its own axios instance pointed at the IAM host and its
|
|
5813
|
-
* own cached IAM-audienced workspace JWT, minted via
|
|
5814
|
-
* `fetchIamAudiencedToken`.
|
|
5815
|
-
*
|
|
5816
|
-
* Confidential credentials only: IAM also rejects publishable keys and
|
|
5817
|
-
* service-account dev tokens. The manager throws up front if the SDK was
|
|
5818
|
-
* constructed without `clientId` + `clientSecret`.
|
|
5819
|
-
*/
|
|
5820
|
-
|
|
5821
|
-
interface EmbedManagerOptions {
|
|
5822
|
-
baseUrl: string;
|
|
5823
|
-
workspaceId: string;
|
|
5824
|
-
clientId?: string;
|
|
5825
|
-
clientSecret?: string;
|
|
5826
|
-
/**
|
|
5827
|
-
* Pass-through of the SDK's `axiosConfig` (custom CA, agent, timeouts,
|
|
5828
|
-
* etc.). The manager always disables HTTP_PROXY/HTTPS_PROXY env vars
|
|
5829
|
-
* to match the main client + token mint, but caller-supplied fields
|
|
5830
|
-
* are merged on top — including an explicit `proxy` override.
|
|
5831
|
-
*/
|
|
5832
|
-
axiosConfig?: AxiosRequestConfig;
|
|
5833
|
-
}
|
|
5834
|
-
/**
|
|
5835
|
-
* Server-side helpers for the Event Log embed iframe. Access via
|
|
5836
|
-
* `client.embed.eventLog`.
|
|
5837
|
-
*
|
|
5838
|
-
* @example
|
|
5839
|
-
* ```ts
|
|
5840
|
-
* const { token, sessionId, expiresAt } = await client.embed.eventLog.issueToken({
|
|
5841
|
-
* capabilities: ['events:read', 'events:replay'],
|
|
5842
|
-
* ttlSeconds: 900,
|
|
5843
|
-
* });
|
|
5844
|
-
*
|
|
5845
|
-
* // The token is workspace-scoped (it exposes the whole workspace's event
|
|
5846
|
-
* // log), so render it only in your own internal/admin tooling.
|
|
5847
|
-
* // <iframe src={`https://embed.centrali.io/v1/event-log#token=${token}&o=${origin}`} />
|
|
5848
|
-
*
|
|
5849
|
-
* // On user logout:
|
|
5850
|
-
* await client.embed.eventLog.revokeSession({ sessionId });
|
|
5851
|
-
* ```
|
|
5852
|
-
*/
|
|
5853
|
-
declare class EmbedManager {
|
|
5854
|
-
private readonly _eventLog;
|
|
5855
|
-
constructor(opts: EmbedManagerOptions);
|
|
5856
|
-
get eventLog(): EventLogEmbed;
|
|
5857
|
-
}
|
|
5858
|
-
declare class EventLogEmbed {
|
|
5859
|
-
private readonly baseUrl;
|
|
5860
|
-
private readonly workspaceId;
|
|
5861
|
-
private readonly clientId?;
|
|
5862
|
-
private readonly clientSecret?;
|
|
5863
|
-
private readonly axios;
|
|
5864
|
-
/**
|
|
5865
|
-
* Cached IAM-audienced workspace JWT. Reused across calls; refreshed
|
|
5866
|
-
* lazily on 401 (which is what IAM returns when `exp` fires).
|
|
5867
|
-
*/
|
|
5868
|
-
private iamToken;
|
|
5869
|
-
private inflightTokenMint;
|
|
5870
|
-
constructor(opts: EmbedManagerOptions);
|
|
5871
|
-
/**
|
|
5872
|
-
* Mint a short-lived `ev_…` embed token. Hand the result to your
|
|
5873
|
-
* frontend and drop it into the iframe URL fragment as `#token=…&o=…`.
|
|
5874
|
-
*/
|
|
5875
|
-
issueToken(input?: IssueEmbedTokenInput): Promise<IssueEmbedTokenResult>;
|
|
5876
|
-
/**
|
|
5877
|
-
* Revoke an embed session (typically tied to your user's logout).
|
|
5878
|
-
* Every embed token carrying this `sessionId` is rejected by
|
|
5879
|
-
* data-service until the entry expires (max token TTL).
|
|
5880
|
-
*/
|
|
5881
|
-
revokeSession(input: RevokeEmbedSessionInput): Promise<RevokeEmbedSessionResult>;
|
|
5882
|
-
private serializeIssueBody;
|
|
5883
|
-
private postWithIamToken;
|
|
5884
|
-
private getIamToken;
|
|
5885
|
-
}
|
|
5886
|
-
|
|
5887
5750
|
/** Mirror of `@centrali/query`'s `ValidateOptions`. */
|
|
5888
5751
|
type QueryValidateOptions = {
|
|
5889
5752
|
rejectReservedClauses?: boolean;
|
|
@@ -6009,7 +5872,6 @@ declare class CentraliSDK {
|
|
|
6009
5872
|
private _webhookSubscriptions;
|
|
6010
5873
|
private _subscribers;
|
|
6011
5874
|
private _query;
|
|
6012
|
-
private _embed;
|
|
6013
5875
|
private isRefreshingToken;
|
|
6014
5876
|
private tokenRefreshPromise;
|
|
6015
5877
|
constructor(options: CentraliSDKOptions);
|
|
@@ -6490,17 +6352,6 @@ declare class CentraliSDK {
|
|
|
6490
6352
|
* ```
|
|
6491
6353
|
*/
|
|
6492
6354
|
get subscribers(): SubscribersManager;
|
|
6493
|
-
/**
|
|
6494
|
-
* Server-side helpers for the white-label Event Log embed
|
|
6495
|
-
* (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
|
|
6496
|
-
* short-lived tokens that scope the iframe to one of your end-user
|
|
6497
|
-
* tenants, and to revoke them on logout.
|
|
6498
|
-
*
|
|
6499
|
-
* Requires the SDK to be constructed with `clientId` + `clientSecret`
|
|
6500
|
-
* (service-account client credentials). Publishable keys and
|
|
6501
|
-
* supplied bearer tokens are rejected by IAM for this surface.
|
|
6502
|
-
*/
|
|
6503
|
-
get embed(): EmbedManager;
|
|
6504
6355
|
/**
|
|
6505
6356
|
* Manually set or update the bearer token for subsequent requests.
|
|
6506
6357
|
*/
|
|
@@ -6860,4 +6711,4 @@ declare class CentraliSDK {
|
|
|
6860
6711
|
checkAuthorization(options: CheckAuthorizationOptions): Promise<ApiResponse<AuthorizationResult>>;
|
|
6861
6712
|
}
|
|
6862
6713
|
|
|
6863
|
-
export { type AcceptSuggestionResult, type AddAllowedDomainOptions, type AlertComparisonOp, type AlertCondition, type AlertDefinition, AlertDefinitionsManager, type AlertRecipient, type AllowedDomain, type AllowedDomainsListResponse, AllowedDomainsManager, type AnomalyAnalysisResult, type AnomalyDetectionData, type AnomalyEventType, type AnomalyInsight, type AnomalyInsightData, AnomalyInsightsManager, type ApiResponse, type ArrayPropertyDefinition, AuditLogManager, type AuthorizationResult, type BasePropertyDefinition, type BatchScanResult, type BatchScanStatus, type BooleanPropertyDefinition, type BulkOperationResult, CANONICAL_OPERATORS, type CanonicalOperator, CentraliError, CentraliSDK, type CentraliSDKOptions, type CheckAuthorizationOptions, CollectionsManager, type ComputeEventType, type ComputeFunction, ComputeFunctionsManager, type ComputeJobStatus, type ComputeJobStatusResponse, type ConditionOperator, type CreateAlertDefinitionInput, type CreateComputeFunctionInput, type CreateOrchestrationInput, type CreateSmartQueryInput, type CreateStructureInput, type CreateSubscriberInput, type CreateTriggerInput, type CreateWebhookSubscriptionInput, type DateTimePropertyDefinition, type DateWindowOption, type DeleteRecordOptions, type
|
|
6714
|
+
export { type AcceptSuggestionResult, type AddAllowedDomainOptions, type AlertComparisonOp, type AlertCondition, type AlertDefinition, AlertDefinitionsManager, type AlertRecipient, type AllowedDomain, type AllowedDomainsListResponse, AllowedDomainsManager, type AnomalyAnalysisResult, type AnomalyDetectionData, type AnomalyEventType, type AnomalyInsight, type AnomalyInsightData, AnomalyInsightsManager, type ApiResponse, type ArrayPropertyDefinition, AuditLogManager, type AuthorizationResult, type BasePropertyDefinition, type BatchScanResult, type BatchScanStatus, type BooleanPropertyDefinition, type BulkOperationResult, CANONICAL_OPERATORS, type CanonicalOperator, CentraliError, CentraliSDK, type CentraliSDKOptions, type CheckAuthorizationOptions, CollectionsManager, type ComputeEventType, type ComputeFunction, ComputeFunctionsManager, type ComputeJobStatus, type ComputeJobStatusResponse, type ConditionOperator, type CreateAlertDefinitionInput, type CreateComputeFunctionInput, type CreateOrchestrationInput, type CreateSmartQueryInput, type CreateStructureInput, type CreateSubscriberInput, type CreateTriggerInput, type CreateWebhookSubscriptionInput, type DateTimePropertyDefinition, type DateWindowOption, type DeleteRecordOptions, type EndpointResponse, type EventLogSourceTable, type EventLogSubscribeOptions, type ExecuteSavedQueryValues, type ExecuteSmartQueryOptions, type ExpandOptions, type FieldCondition, type FieldConditionMap, type FileMetadata, FilesManager, type FilterOperators, type FilterValue, type FunctionMemoryUsage, type FunctionRun, type FunctionRunError, type FunctionRunExecutionSource, type FunctionRunStatus, FunctionRunsManager, type FunctionTrigger, type GetRecordOptions, type IncludeClause, type InsightSeverity, type InsightStatus, type InsightType, type InsightsSummary, type InvokeEndpointOptions, type InvokeTriggerOptions, JOINS_MAX_LENGTH, type JoinClause, type JoinType, type LegacyTranslateOptions, type LegacyTranslateResult, type LegacyTranslateWarning, type ListAlertDefinitionsOptions, type ListAllTriggersOptions, type ListCollectionsOptions, type ListComputeFunctionsOptions, type ListFunctionRunsOptions, type ListInsightsOptions, type ListOrchestrationRunsOptions, type ListOrchestrationsOptions, type ListSmartQueryOptions, type ListStructuresOptions, type ListValidationSuggestionsOptions, type ListWebhookDeliveriesOptions, type NumberPropertyDefinition, OPERATOR_METADATA, type ObjectPropertyDefinition, type OperatorMeta, type OperatorTypeApplicability, type OperatorValueShape, type Orchestration, type OrchestrationCaseEvaluation, type OrchestrationCondition, type OrchestrationConditionEvaluation, type OrchestrationDecisionCase, type OrchestrationDecisionResult, type OrchestrationDelayConfig, type OrchestrationEventType, type OrchestrationFailureReason, type OrchestrationOnFailure, type OrchestrationOnSuccess, type OrchestrationRetryConfig, type OrchestrationRun, type OrchestrationRunStatus, type OrchestrationRunStep, OrchestrationRunsManager, type OrchestrationScheduleType, type OrchestrationStatus, type OrchestrationStep, type OrchestrationStepError, type OrchestrationStepStatus, type OrchestrationStepType, type OrchestrationTrigger, type OrchestrationTriggerMetadata, type OrchestrationTriggerType, OrchestrationsManager, type PageClause, type PaginatedResponse, type ParsedUrlQuery, type PropertyDefinition, type PropertyType, type PublishToSubscriberInput, type PublishToSubscriberResult, type PublishWebhookEventInput, type PublishWebhookEventResult, type QueryDefinition, type QueryError, type QueryErrorCode, type QueryExecutionMode, type QueryHttpError, type QueryHttpErrorCode, QueryManager, type QueryRecordOptions, type QueryResult, type QueryResultMeta, type QueryValidateOptions, type QueryVariableDefinition, RECORDS_PAGE_DEFAULT_LIMIT, RECORDS_PAGE_MAX_LIMIT, type RealtimeAnomalyDetectionEvent, type RealtimeAnomalyInsightEvent, type RealtimeCloseEvent, type RealtimeError, type RealtimeEvent, type RealtimeEventLogEntry, type RealtimeEventType, type RealtimeFunctionRunEvent, RealtimeManager, type RealtimeOrchestrationRunEvent, type RealtimeRecordEvent, type RealtimeSubscribeOptions, type RealtimeSubscription, type RealtimeValidationBatchEvent, type RealtimeValidationSuggestionEvent, type RecordEventType, RecordEvents, type RecordTtlOptions, RecordsManager, type ReferencePropertyDefinition, type ResourceCategory, type SavedQueryDefinition, type SavedQueryScalarBinding, type ScalarValue, type SchemaDiscoveryMode, type SelectClause, SmartQueriesManager, type SmartQuery, type SmartQueryDefinition, type SmartQueryExecuteResult, type SmartQueryFieldCondition, type SmartQueryJoin, type SmartQuerySort, type SmartQueryWhereClause, type SortClause, type StepEncryptedParam, type StringPropertyDefinition, type Structure, StructuresManager, type Subscriber, SubscribersManager, type TestComputeFunctionInput, type TestComputeFunctionResult, type TestSmartQueryInput, type TextSearchClause, type TriggerExecutionType, type TriggerHealthMetrics, type TriggerHealthStatus, type TriggerInvokeResponse, type TriggerOrchestrationRunOptions, type TriggerScanOptions, type TriggerWithHealth, TriggersManager, type UpdateAlertDefinitionInput, type UpdateComputeFunctionInput, type UpdateOrchestrationInput, type UpdateSmartQueryInput, type UpdateStructureInput, type UpdateSubscriberInput, type UpdateTriggerInput, type UpdateWebhookSubscriptionInput, type UrlParserOptions, type ValidateStructureInput, type ValidationBatchData, type ValidationEventType, type ValidationIssueType, ValidationManager, type ValidationResult, type ValidationSuggestion, type ValidationSuggestionData, type ValidationSuggestionStatus, type ValidationSummary, type VariableType, type WaitForScanOptions, type WebhookCancelResponse, type WebhookDeliveriesListMeta, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookDeliverySummary, type WebhookEventName, type WebhookPayloadVersions, type WebhookPublishDelivery, type WebhookReplayResponse, type WebhookSubscription, WebhookSubscriptionsManager, type WhereExpression, fetchClientToken, getAlertDefinitionByIdApiPath, getAlertDefinitionsApiPath, getAllowedDomainsApiPath, getAnomalyAnalysisTriggerApiPath, getAnomalyInsightAcknowledgeApiPath, getAnomalyInsightDismissApiPath, getAnomalyInsightsApiPath, getAnomalyInsightsBulkAcknowledgeApiPath, getAnomalyInsightsSummaryApiPath, getApiUrl, getAuthUrl, getCollectionBySlugApiPath, getCollectionInsightsApiPath, getCollectionValidateApiPath, getCollectionsApiPath, getComputeFunctionTestApiPath, getComputeFunctionsApiPath, getComputeJobStatusApiPath, getEndpointApiPath, getFileUploadApiPath, getFilesCanonicalApiPath, getFunctionRunsApiPath, getFunctionRunsByFunctionApiPath, getFunctionRunsByTriggerApiPath, getFunctionTriggerExecuteApiPath, getFunctionTriggerPauseApiPath, getFunctionTriggerResumeApiPath, getFunctionTriggersApiPath, getOrchestrationRunStepsApiPath, getOrchestrationRunsApiPath, getOrchestrationRunsCanonicalApiPath, getOrchestrationsApiPath, getRealtimeUrl, getRecordApiPath, getSavedQueryCanonicalByIdPath, getSavedQueryCanonicalCollectionPath, getSavedQueryCanonicalExecutePath, getSavedQueryCanonicalTestPath, getSmartQueriesApiPath, getSmartQueriesStructureApiPath, getSmartQueryByNameApiPath, getSmartQueryExecuteApiPath, getSmartQueryTestApiPath, getStructureBySlugApiPath, getStructureInsightsApiPath, getStructureValidateApiPath, getStructuresApiPath, getSubscriberPublishApiPath, getSubscriberSubscriptionsApiPath, getSubscribersApiPath, getValidationBulkAcceptApiPath, getValidationBulkRejectApiPath, getValidationPendingCountApiPath, getValidationRecordSuggestionsApiPath, getValidationScanApiPath, getValidationSuggestionAcceptApiPath, getValidationSuggestionRejectApiPath, getValidationSuggestionsApiPath, getValidationSummaryApiPath, getWebhookDeliveryCancelApiPath, getWebhookDeliveryRetryApiPath, getWebhookPayloadVersionsApiPath, getWebhookPublishApiPath, getWebhookSubscriptionDeliveriesApiPath, getWebhookSubscriptionRotateSecretApiPath, getWebhookSubscriptionsApiPath, isCentraliError, operatorsForFieldType };
|
package/dist/index.js
CHANGED
|
@@ -76,8 +76,6 @@ __export(index_exports, {
|
|
|
76
76
|
CentraliSDK: () => CentraliSDK,
|
|
77
77
|
CollectionsManager: () => CollectionsManager,
|
|
78
78
|
ComputeFunctionsManager: () => ComputeFunctionsManager,
|
|
79
|
-
EmbedManager: () => EmbedManager,
|
|
80
|
-
EventLogEmbed: () => EventLogEmbed,
|
|
81
79
|
FilesManager: () => FilesManager,
|
|
82
80
|
FunctionRunsManager: () => FunctionRunsManager,
|
|
83
81
|
JOINS_MAX_LENGTH: () => JOINS_MAX_LENGTH,
|
|
@@ -439,12 +437,6 @@ function fetchClientToken(clientId, clientSecret, baseUrl) {
|
|
|
439
437
|
return fetchClientTokenForResource(clientId, clientSecret, baseUrl, `${apiUrl}/data`);
|
|
440
438
|
});
|
|
441
439
|
}
|
|
442
|
-
function fetchIamAudiencedToken(clientId, clientSecret, baseUrl) {
|
|
443
|
-
return __async(this, null, function* () {
|
|
444
|
-
const authUrl = getAuthUrl(baseUrl);
|
|
445
|
-
return fetchClientTokenForResource(clientId, clientSecret, baseUrl, authUrl);
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
440
|
function fetchClientTokenForResource(clientId, clientSecret, baseUrl, resource) {
|
|
449
441
|
return __async(this, null, function* () {
|
|
450
442
|
const authUrl = getAuthUrl(baseUrl);
|
|
@@ -8329,111 +8321,8 @@ var SubscribersManager = class {
|
|
|
8329
8321
|
}
|
|
8330
8322
|
};
|
|
8331
8323
|
|
|
8332
|
-
// src/managers/embed.ts
|
|
8333
|
-
var import_axios3 = __toESM(require("axios"));
|
|
8334
|
-
var EmbedManager = class {
|
|
8335
|
-
constructor(opts) {
|
|
8336
|
-
this._eventLog = new EventLogEmbed(opts);
|
|
8337
|
-
}
|
|
8338
|
-
get eventLog() {
|
|
8339
|
-
return this._eventLog;
|
|
8340
|
-
}
|
|
8341
|
-
};
|
|
8342
|
-
var EventLogEmbed = class {
|
|
8343
|
-
constructor(opts) {
|
|
8344
|
-
/**
|
|
8345
|
-
* Cached IAM-audienced workspace JWT. Reused across calls; refreshed
|
|
8346
|
-
* lazily on 401 (which is what IAM returns when `exp` fires).
|
|
8347
|
-
*/
|
|
8348
|
-
this.iamToken = null;
|
|
8349
|
-
this.inflightTokenMint = null;
|
|
8350
|
-
this.baseUrl = opts.baseUrl;
|
|
8351
|
-
this.workspaceId = opts.workspaceId;
|
|
8352
|
-
this.clientId = opts.clientId;
|
|
8353
|
-
this.clientSecret = opts.clientSecret;
|
|
8354
|
-
this.axios = import_axios3.default.create(__spreadValues({
|
|
8355
|
-
baseURL: getAuthUrl(opts.baseUrl),
|
|
8356
|
-
headers: { "Content-Type": "application/json" },
|
|
8357
|
-
proxy: false
|
|
8358
|
-
}, opts.axiosConfig));
|
|
8359
|
-
}
|
|
8360
|
-
/**
|
|
8361
|
-
* Mint a short-lived `ev_…` embed token. Hand the result to your
|
|
8362
|
-
* frontend and drop it into the iframe URL fragment as `#token=…&o=…`.
|
|
8363
|
-
*/
|
|
8364
|
-
issueToken() {
|
|
8365
|
-
return __async(this, arguments, function* (input = {}) {
|
|
8366
|
-
const path = `/workspace/${this.workspaceId}/embed/event-log/issue-token`;
|
|
8367
|
-
return this.postWithIamToken(path, this.serializeIssueBody(input));
|
|
8368
|
-
});
|
|
8369
|
-
}
|
|
8370
|
-
/**
|
|
8371
|
-
* Revoke an embed session (typically tied to your user's logout).
|
|
8372
|
-
* Every embed token carrying this `sessionId` is rejected by
|
|
8373
|
-
* data-service until the entry expires (max token TTL).
|
|
8374
|
-
*/
|
|
8375
|
-
revokeSession(input) {
|
|
8376
|
-
return __async(this, null, function* () {
|
|
8377
|
-
const path = `/workspace/${this.workspaceId}/embed/event-log/revoke-session`;
|
|
8378
|
-
return this.postWithIamToken(path, { sessionId: input.sessionId });
|
|
8379
|
-
});
|
|
8380
|
-
}
|
|
8381
|
-
serializeIssueBody(input) {
|
|
8382
|
-
const body = {};
|
|
8383
|
-
if (input.capabilities) body.capabilities = input.capabilities;
|
|
8384
|
-
if (input.sessionId) body.sessionId = input.sessionId;
|
|
8385
|
-
if (input.ttlSeconds !== void 0) body.ttlSeconds = input.ttlSeconds;
|
|
8386
|
-
return body;
|
|
8387
|
-
}
|
|
8388
|
-
postWithIamToken(path, body) {
|
|
8389
|
-
return __async(this, null, function* () {
|
|
8390
|
-
var _a;
|
|
8391
|
-
const token = yield this.getIamToken();
|
|
8392
|
-
try {
|
|
8393
|
-
const resp = yield this.axios.post(path, body, {
|
|
8394
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
8395
|
-
});
|
|
8396
|
-
return resp.data;
|
|
8397
|
-
} catch (err) {
|
|
8398
|
-
const status = (_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status;
|
|
8399
|
-
if (status === 401) {
|
|
8400
|
-
this.iamToken = null;
|
|
8401
|
-
const fresh = yield this.getIamToken();
|
|
8402
|
-
const resp = yield this.axios.post(path, body, {
|
|
8403
|
-
headers: { Authorization: `Bearer ${fresh}` }
|
|
8404
|
-
});
|
|
8405
|
-
return resp.data;
|
|
8406
|
-
}
|
|
8407
|
-
throw err;
|
|
8408
|
-
}
|
|
8409
|
-
});
|
|
8410
|
-
}
|
|
8411
|
-
getIamToken() {
|
|
8412
|
-
return __async(this, null, function* () {
|
|
8413
|
-
if (this.iamToken) return this.iamToken;
|
|
8414
|
-
if (this.inflightTokenMint) return this.inflightTokenMint;
|
|
8415
|
-
if (!this.clientId || !this.clientSecret) {
|
|
8416
|
-
throw new Error(
|
|
8417
|
-
"Embed token issuance requires the SDK to be configured with clientId + clientSecret (service-account client credentials). Publishable keys and supplied bearer tokens are not accepted by IAM for this endpoint."
|
|
8418
|
-
);
|
|
8419
|
-
}
|
|
8420
|
-
this.inflightTokenMint = fetchIamAudiencedToken(
|
|
8421
|
-
this.clientId,
|
|
8422
|
-
this.clientSecret,
|
|
8423
|
-
this.baseUrl
|
|
8424
|
-
);
|
|
8425
|
-
try {
|
|
8426
|
-
this.iamToken = yield this.inflightTokenMint;
|
|
8427
|
-
return this.iamToken;
|
|
8428
|
-
} finally {
|
|
8429
|
-
this.inflightTokenMint = null;
|
|
8430
|
-
}
|
|
8431
|
-
});
|
|
8432
|
-
}
|
|
8433
|
-
};
|
|
8434
|
-
|
|
8435
8324
|
// src/client.ts
|
|
8436
|
-
var
|
|
8325
|
+
var import_axios3 = __toESM(require("axios"));
|
|
8437
8326
|
var import_qs = __toESM(require("qs"));
|
|
8438
8327
|
|
|
8439
8328
|
// src/internal/queryGuard.ts
|
|
@@ -8465,7 +8354,6 @@ var CentraliSDK = class {
|
|
|
8465
8354
|
this._webhookSubscriptions = null;
|
|
8466
8355
|
this._subscribers = null;
|
|
8467
8356
|
this._query = null;
|
|
8468
|
-
this._embed = null;
|
|
8469
8357
|
this.isRefreshingToken = false;
|
|
8470
8358
|
this.tokenRefreshPromise = null;
|
|
8471
8359
|
this.options = options;
|
|
@@ -8482,7 +8370,7 @@ var CentraliSDK = class {
|
|
|
8482
8370
|
throw new Error("Cannot use getToken with clientId/clientSecret. Use one auth method.");
|
|
8483
8371
|
}
|
|
8484
8372
|
const apiUrl = getApiUrl(options.baseUrl);
|
|
8485
|
-
this.axios =
|
|
8373
|
+
this.axios = import_axios3.default.create(__spreadValues({
|
|
8486
8374
|
baseURL: apiUrl,
|
|
8487
8375
|
paramsSerializer: (params) => import_qs.default.stringify(params, { arrayFormat: "repeat" }),
|
|
8488
8376
|
proxy: false
|
|
@@ -9224,28 +9112,6 @@ var CentraliSDK = class {
|
|
|
9224
9112
|
}
|
|
9225
9113
|
return this._subscribers;
|
|
9226
9114
|
}
|
|
9227
|
-
/**
|
|
9228
|
-
* Server-side helpers for the white-label Event Log embed
|
|
9229
|
-
* (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
|
|
9230
|
-
* short-lived tokens that scope the iframe to one of your end-user
|
|
9231
|
-
* tenants, and to revoke them on logout.
|
|
9232
|
-
*
|
|
9233
|
-
* Requires the SDK to be constructed with `clientId` + `clientSecret`
|
|
9234
|
-
* (service-account client credentials). Publishable keys and
|
|
9235
|
-
* supplied bearer tokens are rejected by IAM for this surface.
|
|
9236
|
-
*/
|
|
9237
|
-
get embed() {
|
|
9238
|
-
if (!this._embed) {
|
|
9239
|
-
this._embed = new EmbedManager({
|
|
9240
|
-
baseUrl: this.options.baseUrl,
|
|
9241
|
-
workspaceId: this.options.workspaceId,
|
|
9242
|
-
clientId: this.options.clientId,
|
|
9243
|
-
clientSecret: this.options.clientSecret,
|
|
9244
|
-
axiosConfig: this.options.axiosConfig
|
|
9245
|
-
});
|
|
9246
|
-
}
|
|
9247
|
-
return this._embed;
|
|
9248
|
-
}
|
|
9249
9115
|
/**
|
|
9250
9116
|
* Manually set or update the bearer token for subsequent requests.
|
|
9251
9117
|
*/
|
|
@@ -9713,8 +9579,6 @@ var CentraliSDK = class {
|
|
|
9713
9579
|
CentraliSDK,
|
|
9714
9580
|
CollectionsManager,
|
|
9715
9581
|
ComputeFunctionsManager,
|
|
9716
|
-
EmbedManager,
|
|
9717
|
-
EventLogEmbed,
|
|
9718
9582
|
FilesManager,
|
|
9719
9583
|
FunctionRunsManager,
|
|
9720
9584
|
JOINS_MAX_LENGTH,
|
package/index.ts
CHANGED
|
@@ -33,7 +33,6 @@ export * from './src/types/validation';
|
|
|
33
33
|
export * from './src/types/webhooks';
|
|
34
34
|
export * from './src/types/subscribers';
|
|
35
35
|
export * from './src/types/allowedDomains';
|
|
36
|
-
export * from './src/types/embed';
|
|
37
36
|
|
|
38
37
|
// Realtime
|
|
39
38
|
export { RealtimeManager } from './src/realtime/manager';
|
|
@@ -56,7 +55,6 @@ export { OrchestrationRunsManager } from './src/managers/orchestrationRuns';
|
|
|
56
55
|
export { FilesManager, FileMetadata } from './src/managers/files';
|
|
57
56
|
export { WebhookSubscriptionsManager } from './src/managers/webhookSubscriptions';
|
|
58
57
|
export { SubscribersManager } from './src/managers/subscribers';
|
|
59
|
-
export { EmbedManager, EventLogEmbed } from './src/managers/embed';
|
|
60
58
|
export {
|
|
61
59
|
QueryManager,
|
|
62
60
|
type QueryValidateOptions,
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -36,7 +36,6 @@ import { FilesManager } from './managers/files';
|
|
|
36
36
|
import { WebhookSubscriptionsManager } from './managers/webhookSubscriptions';
|
|
37
37
|
import { SubscribersManager } from './managers/subscribers';
|
|
38
38
|
import { QueryManager } from './managers/query';
|
|
39
|
-
import { EmbedManager } from './managers/embed';
|
|
40
39
|
|
|
41
40
|
export class CentraliSDK {
|
|
42
41
|
private axios: AxiosInstance;
|
|
@@ -62,7 +61,6 @@ export class CentraliSDK {
|
|
|
62
61
|
private _webhookSubscriptions: WebhookSubscriptionsManager | null = null;
|
|
63
62
|
private _subscribers: SubscribersManager | null = null;
|
|
64
63
|
private _query: QueryManager | null = null;
|
|
65
|
-
private _embed: EmbedManager | null = null;
|
|
66
64
|
private isRefreshingToken: boolean = false;
|
|
67
65
|
private tokenRefreshPromise: Promise<string> | null = null;
|
|
68
66
|
|
|
@@ -879,29 +877,6 @@ export class CentraliSDK {
|
|
|
879
877
|
return this._subscribers;
|
|
880
878
|
}
|
|
881
879
|
|
|
882
|
-
/**
|
|
883
|
-
* Server-side helpers for the white-label Event Log embed
|
|
884
|
-
* (CEN-1301 — see `embed.centrali.io/v1/event-log`). Use to mint
|
|
885
|
-
* short-lived tokens that scope the iframe to one of your end-user
|
|
886
|
-
* tenants, and to revoke them on logout.
|
|
887
|
-
*
|
|
888
|
-
* Requires the SDK to be constructed with `clientId` + `clientSecret`
|
|
889
|
-
* (service-account client credentials). Publishable keys and
|
|
890
|
-
* supplied bearer tokens are rejected by IAM for this surface.
|
|
891
|
-
*/
|
|
892
|
-
public get embed(): EmbedManager {
|
|
893
|
-
if (!this._embed) {
|
|
894
|
-
this._embed = new EmbedManager({
|
|
895
|
-
baseUrl: this.options.baseUrl,
|
|
896
|
-
workspaceId: this.options.workspaceId,
|
|
897
|
-
clientId: this.options.clientId,
|
|
898
|
-
clientSecret: this.options.clientSecret,
|
|
899
|
-
axiosConfig: this.options.axiosConfig,
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return this._embed;
|
|
903
|
-
}
|
|
904
|
-
|
|
905
880
|
/**
|
|
906
881
|
* Manually set or update the bearer token for subsequent requests.
|
|
907
882
|
*/
|
package/src/internal/auth.ts
CHANGED
|
@@ -18,20 +18,6 @@ export async function fetchClientToken(
|
|
|
18
18
|
return fetchClientTokenForResource(clientId, clientSecret, baseUrl, `${apiUrl}/data`);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Mint an IAM-audienced workspace JWT. Required for the embed-token issuance
|
|
23
|
-
* endpoint, which rejects data-audienced tokens with `audience_mismatch`
|
|
24
|
-
* (see services/backend/iam/src/controllers/embedTokenController.ts).
|
|
25
|
-
*/
|
|
26
|
-
export async function fetchIamAudiencedToken(
|
|
27
|
-
clientId: string,
|
|
28
|
-
clientSecret: string,
|
|
29
|
-
baseUrl: string
|
|
30
|
-
): Promise<string> {
|
|
31
|
-
const authUrl = getAuthUrl(baseUrl);
|
|
32
|
-
return fetchClientTokenForResource(clientId, clientSecret, baseUrl, authUrl);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
21
|
async function fetchClientTokenForResource(
|
|
36
22
|
clientId: string,
|
|
37
23
|
clientSecret: string,
|
package/src/managers/embed.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Embed manager — server-side helpers for the white-label Event Log iframe
|
|
3
|
-
* (`embed.centrali.io/v1/event-log`, CEN-1301).
|
|
4
|
-
*
|
|
5
|
-
* Why this lives outside the main axios instance:
|
|
6
|
-
* The shared client mints workspace JWTs with `resource=<data-service>`,
|
|
7
|
-
* so its `aud` claim is the data plane. IAM's embed issuance endpoint
|
|
8
|
-
* explicitly rejects data-audienced tokens (`audience_mismatch`) — see
|
|
9
|
-
* services/backend/iam/src/controllers/embedTokenController.ts. This
|
|
10
|
-
* manager keeps its own axios instance pointed at the IAM host and its
|
|
11
|
-
* own cached IAM-audienced workspace JWT, minted via
|
|
12
|
-
* `fetchIamAudiencedToken`.
|
|
13
|
-
*
|
|
14
|
-
* Confidential credentials only: IAM also rejects publishable keys and
|
|
15
|
-
* service-account dev tokens. The manager throws up front if the SDK was
|
|
16
|
-
* constructed without `clientId` + `clientSecret`.
|
|
17
|
-
*/
|
|
18
|
-
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
19
|
-
|
|
20
|
-
import { fetchIamAudiencedToken } from '../internal/auth';
|
|
21
|
-
import { getAuthUrl } from '../urls';
|
|
22
|
-
import type {
|
|
23
|
-
IssueEmbedTokenInput,
|
|
24
|
-
IssueEmbedTokenResult,
|
|
25
|
-
RevokeEmbedSessionInput,
|
|
26
|
-
RevokeEmbedSessionResult,
|
|
27
|
-
} from '../types/embed';
|
|
28
|
-
|
|
29
|
-
interface EmbedManagerOptions {
|
|
30
|
-
baseUrl: string;
|
|
31
|
-
workspaceId: string;
|
|
32
|
-
clientId?: string;
|
|
33
|
-
clientSecret?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Pass-through of the SDK's `axiosConfig` (custom CA, agent, timeouts,
|
|
36
|
-
* etc.). The manager always disables HTTP_PROXY/HTTPS_PROXY env vars
|
|
37
|
-
* to match the main client + token mint, but caller-supplied fields
|
|
38
|
-
* are merged on top — including an explicit `proxy` override.
|
|
39
|
-
*/
|
|
40
|
-
axiosConfig?: AxiosRequestConfig;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Server-side helpers for the Event Log embed iframe. Access via
|
|
45
|
-
* `client.embed.eventLog`.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const { token, sessionId, expiresAt } = await client.embed.eventLog.issueToken({
|
|
50
|
-
* capabilities: ['events:read', 'events:replay'],
|
|
51
|
-
* ttlSeconds: 900,
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* // The token is workspace-scoped (it exposes the whole workspace's event
|
|
55
|
-
* // log), so render it only in your own internal/admin tooling.
|
|
56
|
-
* // <iframe src={`https://embed.centrali.io/v1/event-log#token=${token}&o=${origin}`} />
|
|
57
|
-
*
|
|
58
|
-
* // On user logout:
|
|
59
|
-
* await client.embed.eventLog.revokeSession({ sessionId });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export class EmbedManager {
|
|
63
|
-
private readonly _eventLog: EventLogEmbed;
|
|
64
|
-
|
|
65
|
-
constructor(opts: EmbedManagerOptions) {
|
|
66
|
-
this._eventLog = new EventLogEmbed(opts);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public get eventLog(): EventLogEmbed {
|
|
70
|
-
return this._eventLog;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export class EventLogEmbed {
|
|
75
|
-
private readonly baseUrl: string;
|
|
76
|
-
private readonly workspaceId: string;
|
|
77
|
-
private readonly clientId?: string;
|
|
78
|
-
private readonly clientSecret?: string;
|
|
79
|
-
private readonly axios: AxiosInstance;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Cached IAM-audienced workspace JWT. Reused across calls; refreshed
|
|
83
|
-
* lazily on 401 (which is what IAM returns when `exp` fires).
|
|
84
|
-
*/
|
|
85
|
-
private iamToken: string | null = null;
|
|
86
|
-
private inflightTokenMint: Promise<string> | null = null;
|
|
87
|
-
|
|
88
|
-
constructor(opts: EmbedManagerOptions) {
|
|
89
|
-
this.baseUrl = opts.baseUrl;
|
|
90
|
-
this.workspaceId = opts.workspaceId;
|
|
91
|
-
this.clientId = opts.clientId;
|
|
92
|
-
this.clientSecret = opts.clientSecret;
|
|
93
|
-
// Mirror the main client + `fetchClientToken`: disable HTTP_PROXY/
|
|
94
|
-
// HTTPS_PROXY env-var pickup by default so embed-token traffic doesn't
|
|
95
|
-
// get silently routed through an outbound proxy a caller hasn't
|
|
96
|
-
// opted into. Caller-supplied `axiosConfig` (custom CA, agent,
|
|
97
|
-
// timeouts, explicit `proxy`) is merged on top.
|
|
98
|
-
this.axios = axios.create({
|
|
99
|
-
baseURL: getAuthUrl(opts.baseUrl),
|
|
100
|
-
headers: { 'Content-Type': 'application/json' },
|
|
101
|
-
proxy: false,
|
|
102
|
-
...opts.axiosConfig,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Mint a short-lived `ev_…` embed token. Hand the result to your
|
|
108
|
-
* frontend and drop it into the iframe URL fragment as `#token=…&o=…`.
|
|
109
|
-
*/
|
|
110
|
-
public async issueToken(input: IssueEmbedTokenInput = {}): Promise<IssueEmbedTokenResult> {
|
|
111
|
-
const path = `/workspace/${this.workspaceId}/embed/event-log/issue-token`;
|
|
112
|
-
return this.postWithIamToken<IssueEmbedTokenResult>(path, this.serializeIssueBody(input));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Revoke an embed session (typically tied to your user's logout).
|
|
117
|
-
* Every embed token carrying this `sessionId` is rejected by
|
|
118
|
-
* data-service until the entry expires (max token TTL).
|
|
119
|
-
*/
|
|
120
|
-
public async revokeSession(input: RevokeEmbedSessionInput): Promise<RevokeEmbedSessionResult> {
|
|
121
|
-
const path = `/workspace/${this.workspaceId}/embed/event-log/revoke-session`;
|
|
122
|
-
return this.postWithIamToken<RevokeEmbedSessionResult>(path, { sessionId: input.sessionId });
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private serializeIssueBody(input: IssueEmbedTokenInput): Record<string, unknown> {
|
|
126
|
-
const body: Record<string, unknown> = {};
|
|
127
|
-
if (input.capabilities) body.capabilities = input.capabilities;
|
|
128
|
-
if (input.sessionId) body.sessionId = input.sessionId;
|
|
129
|
-
if (input.ttlSeconds !== undefined) body.ttlSeconds = input.ttlSeconds;
|
|
130
|
-
return body;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private async postWithIamToken<T>(path: string, body: Record<string, unknown>): Promise<T> {
|
|
134
|
-
const token = await this.getIamToken();
|
|
135
|
-
try {
|
|
136
|
-
const resp = await this.axios.post<T>(path, body, {
|
|
137
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
138
|
-
});
|
|
139
|
-
return resp.data;
|
|
140
|
-
} catch (err) {
|
|
141
|
-
// Refresh-on-401 once. Any subsequent 401 is propagated so the
|
|
142
|
-
// caller sees the real reason (missing capability, revoked SA,
|
|
143
|
-
// misconfigured audience, etc.) instead of a silent loop.
|
|
144
|
-
const status = (err as AxiosError)?.response?.status;
|
|
145
|
-
if (status === 401) {
|
|
146
|
-
this.iamToken = null;
|
|
147
|
-
const fresh = await this.getIamToken();
|
|
148
|
-
const resp = await this.axios.post<T>(path, body, {
|
|
149
|
-
headers: { Authorization: `Bearer ${fresh}` },
|
|
150
|
-
});
|
|
151
|
-
return resp.data;
|
|
152
|
-
}
|
|
153
|
-
throw err;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private async getIamToken(): Promise<string> {
|
|
158
|
-
if (this.iamToken) return this.iamToken;
|
|
159
|
-
if (this.inflightTokenMint) return this.inflightTokenMint;
|
|
160
|
-
if (!this.clientId || !this.clientSecret) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
'Embed token issuance requires the SDK to be configured with ' +
|
|
163
|
-
'clientId + clientSecret (service-account client credentials). ' +
|
|
164
|
-
'Publishable keys and supplied bearer tokens are not accepted by ' +
|
|
165
|
-
'IAM for this endpoint.',
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
this.inflightTokenMint = fetchIamAudiencedToken(
|
|
169
|
-
this.clientId,
|
|
170
|
-
this.clientSecret,
|
|
171
|
-
this.baseUrl,
|
|
172
|
-
);
|
|
173
|
-
try {
|
|
174
|
-
this.iamToken = await this.inflightTokenMint;
|
|
175
|
-
return this.iamToken;
|
|
176
|
-
} finally {
|
|
177
|
-
this.inflightTokenMint = null;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
package/src/types/embed.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for the Event Log embed surface (CEN-1301).
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the request/response shapes defined by IAM at
|
|
5
|
-
* services/backend/iam/src/controllers/embedTokenController.ts.
|
|
6
|
-
* Keep field names in sync with that controller's Zod schemas.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Capabilities that can be encoded into an embed token.
|
|
11
|
-
*
|
|
12
|
-
* - `events:read` — list + retrieve the workspace's event-log rows.
|
|
13
|
-
* IAM unconditionally injects this on every minted token, so omitting
|
|
14
|
-
* `capabilities` is equivalent to `['events:read']`.
|
|
15
|
-
* - `events:replay` — allow the iframe to replay a failed delivery. The
|
|
16
|
-
* issuing service account must also hold `webhook-subscriptions:replay`.
|
|
17
|
-
*/
|
|
18
|
-
export type EmbedCapability = 'events:read' | 'events:replay';
|
|
19
|
-
|
|
20
|
-
export interface IssueEmbedTokenInput {
|
|
21
|
-
/**
|
|
22
|
-
* Defaults to `['events:read']`. Pass `['events:read', 'events:replay']`
|
|
23
|
-
* to allow the iframe's "Replay" action. The issuing service account
|
|
24
|
-
* must already hold the corresponding capability.
|
|
25
|
-
*/
|
|
26
|
-
capabilities?: EmbedCapability[];
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Optional cohort id. Useful if you want to revoke every token issued
|
|
30
|
-
* for one of your end-users on logout — mint each with the same
|
|
31
|
-
* `sessionId`, then call `revokeSession({ sessionId })` later. Server
|
|
32
|
-
* mints a random one if omitted (returned in the response).
|
|
33
|
-
*/
|
|
34
|
-
sessionId?: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Token TTL in seconds. Defaults to 600 (10 min). Capped at 3600 (1h)
|
|
38
|
-
* server-side; out-of-range values 400.
|
|
39
|
-
*/
|
|
40
|
-
ttlSeconds?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface IssueEmbedTokenResult {
|
|
44
|
-
/** `ev_…` JWT for the iframe's URL fragment. */
|
|
45
|
-
token: string;
|
|
46
|
-
/** Echo of the input sessionId, or the server-minted one if omitted. */
|
|
47
|
-
sessionId: string;
|
|
48
|
-
/** ISO-8601 timestamp at which the token's `exp` claim fires. */
|
|
49
|
-
expiresAt: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface RevokeEmbedSessionInput {
|
|
53
|
-
sessionId: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface RevokeEmbedSessionResult {
|
|
57
|
-
sessionId: string;
|
|
58
|
-
revokedAt: string;
|
|
59
|
-
}
|