@verne-software/sdk 1.3.0 → 1.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/README.md +240 -77
- package/dist/index.d.mts +868 -75
- package/dist/index.d.ts +868 -75
- package/dist/index.js +789 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +788 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/errors.ts","../src/core/http.ts","../src/resources/clockwork/delayed.ts","../src/resources/clockwork/jobs.ts","../src/resources/clockwork/clockwork.ts","../src/resources/gate/identities.ts","../src/resources/gate/settings.ts","../src/resources/gate/tokens.ts","../src/resources/gate/gate.ts","../src/resources/passepartout/passepartout.ts","../src/resources/relay/messages.ts","../src/resources/relay/relay.ts","../src/verne.ts"],"names":[],"mappings":";;;AAGO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACd;AACF;AAMO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,UAAA,CAAW;AAAA,EAQ5C,WAAA,CAAY;AAAA,IACV,IAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,GACF,EAKG;AACD,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AAAA,EACnB;AAAA,EAEA,OAAO,YAAA,CAAa,MAAA,EAAgB,IAAA,EAAmC;AACrE,IAAA,OAAO,IAAI,cAAA,CAAc;AAAA,MACvB,IAA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C/B,IAAA,IAAI,CAAC,IAAA,CAAK,MAAA,CAAO,YAAA,EAAc;AAC7B,MAAA,MAAM,IAAI,UAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAA,CAAK,aAAA,KAAL,IAAA,CAAK,aAAA,GAAkB,IAAI,YAAA,CAAa;AAAA,MACtC,MAAA,EAAQ,KAAK,MAAA,CAAO,YAAA;AAAA,MACpB,OAAA,EAAS,KAAK,MAAA,CAAO,OAAA;AAAA,MACrB,SAAA,EAAW,KAAK,MAAA,CAAO;AAAA,KACxB,CAAA,CAAA;AACD,IAAA,OAAO,IAAA,CAAK,aAAA;AAAA,EACd;AAAA,EAEA,IAAI,SAAA,GAAuB;AACzB,IAAA,IAAI,CAAC,IAAA,CAAK,MAAA,CAAO,SAAA,EAAW;AAC1B,MAAA,MAAM,IAAI,UAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,IAAA,CAAK,UAAA,KAAL,IAAA,CAAK,UAAA,GAAe,IAAI,SAAA,CAAU;AAAA,MAChC,MAAA,EAAQ,KAAK,MAAA,CAAO,SAAA;AAAA,MACpB,OAAA,EAAS,KAAK,MAAA,CAAO,OAAA;AAAA,MACrB,SAAA,EAAW,KAAK,MAAA,CAAO;AAAA,KACxB,CAAA,CAAA;AACD,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AACF","file":"index.js","sourcesContent":["/**\n * Base class for all errors thrown by the Verne SDK.\n */\nexport class VerneError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'VerneError';\n }\n}\n\n/**\n * Thrown when the Verne API returns an error response.\n * Contains structured information from the API error envelope.\n */\nexport class VerneAPIError extends VerneError {\n /** Machine-readable error code (e.g. 'invalid_payload', 'unauthorized'). */\n readonly code: string;\n /** HTTP status code. */\n readonly status: number;\n /** Request ID to include when contacting support. */\n readonly requestId: string;\n\n constructor({\n code,\n message,\n status,\n requestId,\n }: {\n code: string;\n message: string;\n status: number;\n requestId: string;\n }) {\n super(message);\n this.name = 'VerneAPIError';\n this.code = code;\n this.status = status;\n this.requestId = requestId;\n }\n\n static fromResponse(status: number, body: APIErrorBody): VerneAPIError {\n return new VerneAPIError({\n code: body.error.code,\n message: body.error.message,\n status,\n requestId: body.error.request_id,\n });\n }\n}\n\n/** Shape of the API error envelope returned by all Verne services. */\nexport interface APIErrorBody {\n error: {\n code: string;\n message: string;\n request_id: string;\n };\n}\n","import { VerneAPIError, VerneError, type APIErrorBody } from './errors.js';\nimport type { RequestOptions } from './types.js';\n\nconst DEFAULT_BASE_URL = 'https://api.vernesoft.com';\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nexport interface HttpClientConfig {\n apiKey: string;\n baseUrl?: string;\n timeoutMs?: number;\n}\n\nexport interface HttpRequestOptions extends RequestOptions {\n /** When true, omit the Authorization header (used by gate.tokens.create). */\n skipAuth?: boolean;\n /** Body to send as JSON. */\n body?: unknown;\n}\n\nexport class HttpClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n private readonly timeoutMs: number;\n\n constructor(config: HttpClientConfig) {\n this.apiKey = config.apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '');\n this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n }\n\n async get<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n async post<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('POST', path, options);\n }\n\n async put<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('PUT', path, options);\n }\n\n async patch<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, options);\n }\n\n async delete<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n private async request<T>(\n method: string,\n path: string,\n options: HttpRequestOptions = {},\n attempt = 1,\n ): Promise<T> {\n const { skipAuth, body, signal, headers: extraHeaders, timeoutMs } = options;\n\n const url = `${this.baseUrl}${path}`;\n const timeout = timeoutMs ?? this.timeoutMs;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...extraHeaders,\n };\n\n if (!skipAuth) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n // Allow external signal to also abort the request\n const combinedSignal = signal\n ? AbortSignal.any([signal, controller.signal])\n : controller.signal;\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: combinedSignal,\n });\n } catch (err) {\n clearTimeout(timeoutId);\n if (err instanceof Error && err.name === 'AbortError') {\n throw new VerneError(`Request timed out after ${timeout}ms: ${method} ${path}`);\n }\n throw new VerneError(`Network error: ${err instanceof Error ? err.message : String(err)}`);\n } finally {\n clearTimeout(timeoutId);\n }\n\n // Retry on 429 with Retry-After header (only one retry, only for send-type requests)\n if (response.status === 429 && attempt === 1 && method === 'POST') {\n const retryAfter = response.headers.get('Retry-After');\n const waitMs = retryAfter ? parseFloat(retryAfter) * 1000 : 1000;\n await sleep(waitMs);\n return this.request<T>(method, path, options, 2);\n }\n\n if (!response.ok) {\n let errorBody: APIErrorBody;\n try {\n errorBody = (await response.json()) as APIErrorBody;\n } catch {\n throw new VerneError(`HTTP ${response.status}: ${method} ${path}`);\n }\n throw VerneAPIError.fromResponse(response.status, errorBody);\n }\n\n // 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n return response.json() as Promise<T>;\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { CreateDelayedJobParams, DelayedJob, Execution } from './types.js';\n\nexport class ClockworkDelayedResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns all delayed (one-shot) jobs for the current tenant.\n */\n async list(options?: RequestOptions): Promise<DelayedJob[]> {\n return this.http.get<DelayedJob[]>('/v1/clockwork/delayed', options);\n }\n\n /**\n * Schedules a new delayed job to run once at the given `run_at` time.\n *\n * @example\n * const job = await clockwork.delayed.create({\n * name: 'send-reminder',\n * run_at: '2026-01-01T09:00:00Z',\n * url: 'https://example.com/hooks/reminder',\n * });\n */\n async create(params: CreateDelayedJobParams, options?: RequestOptions): Promise<DelayedJob> {\n return this.http.post<DelayedJob>('/v1/clockwork/delayed', { body: params, ...options });\n }\n\n /**\n * Cancels a pending delayed job. Resolves on `204 No Content`.\n */\n async cancel(jobId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/clockwork/delayed/${jobId}`, options);\n }\n\n /**\n * Returns the execution history for a delayed job.\n */\n async executions(jobId: string, options?: RequestOptions): Promise<Execution[]> {\n return this.http.get<Execution[]>(`/v1/clockwork/delayed/${jobId}/executions`, options);\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { CreateCronJobParams, CronJob, Execution, UpdateCronJobParams } from './types.js';\n\nexport class ClockworkJobsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns all cron jobs for the current tenant.\n */\n async list(options?: RequestOptions): Promise<CronJob[]> {\n return this.http.get<CronJob[]>('/v1/clockwork/jobs', options);\n }\n\n /**\n * Creates a new recurring cron job.\n *\n * @example\n * const job = await clockwork.jobs.create({\n * name: 'nightly-report',\n * schedule: '0 2 * * *',\n * url: 'https://example.com/hooks/report',\n * });\n */\n async create(params: CreateCronJobParams, options?: RequestOptions): Promise<CronJob> {\n return this.http.post<CronJob>('/v1/clockwork/jobs', { body: params, ...options });\n }\n\n /**\n * Partially updates an existing cron job. Only the fields you provide are changed.\n */\n async update(\n jobId: string,\n params: UpdateCronJobParams,\n options?: RequestOptions,\n ): Promise<CronJob> {\n return this.http.patch<CronJob>(`/v1/clockwork/jobs/${jobId}`, { body: params, ...options });\n }\n\n /**\n * Deletes a cron job. Resolves on `204 No Content`.\n */\n async delete(jobId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/clockwork/jobs/${jobId}`, options);\n }\n\n /**\n * Returns the execution history for a cron job (most recent runs first).\n */\n async executions(jobId: string, options?: RequestOptions): Promise<Execution[]> {\n return this.http.get<Execution[]>(`/v1/clockwork/jobs/${jobId}/executions`, options);\n }\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { ServiceConfig } from '../../core/types.js';\nimport { ClockworkDelayedResource } from './delayed.js';\nimport { ClockworkJobsResource } from './jobs.js';\n\nexport class Clockwork {\n readonly jobs: ClockworkJobsResource;\n readonly delayed: ClockworkDelayedResource;\n\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.jobs = new ClockworkJobsResource(this.http);\n this.delayed = new ClockworkDelayedResource(this.http);\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { CreateIdentityParams, Identity, JsonPatchOp } from './types.js';\n\nexport class IdentitiesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Creates a new identity (end-user) bound to your tenant.\n * The `traits.tenant_id` is injected automatically by the Edge Gateway.\n */\n async create(params: CreateIdentityParams, options?: RequestOptions): Promise<Identity> {\n return this.http.post<Identity>('/v1/gate/identities', { body: params, ...options });\n }\n\n /**\n * Returns an identity by ID.\n * The Gateway will reject the request if the identity does not belong to your tenant.\n */\n async get(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.http.get<Identity>(`/v1/gate/identities/${identityId}`, options);\n }\n\n /**\n * Partially updates an identity using a JSON Patch document (RFC 6902).\n *\n * @example\n * await gate.identities.patch('identity_123', [\n * { op: 'replace', path: '/traits/custom_data/role', value: 'admin' }\n * ]);\n */\n async patch(\n identityId: string,\n ops: JsonPatchOp[],\n options?: RequestOptions,\n ): Promise<Identity> {\n return this.http.patch<Identity>(`/v1/gate/identities/${identityId}`, {\n body: ops,\n ...options,\n });\n }\n\n /**\n * Deletes an identity from Kratos.\n * The Gateway will reject the request if the identity does not belong to your tenant.\n */\n async delete(identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/gate/identities/${identityId}`, options);\n }\n\n /**\n * Activates or deactivates an identity. An `inactive` identity cannot log in —\n * Kratos rejects its credentials automatically — until it is reactivated.\n * The identity is not deleted. Fires the `identity.state_changed` webhook event.\n *\n * @example\n * await gate.identities.setState('identity_123', 'inactive');\n */\n async setState(\n identityId: string,\n state: 'active' | 'inactive',\n options?: RequestOptions,\n ): Promise<Identity> {\n return this.http.patch<Identity>(`/v1/gate/identities/${identityId}/state`, {\n body: { state },\n ...options,\n });\n }\n\n /** Convenience wrapper for {@link setState}(identityId, 'active'). */\n async activate(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.setState(identityId, 'active', options);\n }\n\n /** Convenience wrapper for {@link setState}(identityId, 'inactive'). */\n async deactivate(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.setState(identityId, 'inactive', options);\n }\n\n /**\n * Triggers a new email verification flow for an identity — useful when the\n * original verification email expired or was never received. The user receives\n * a fresh verification email. Resolves on `204 No Content`.\n */\n async resendVerification(identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.post<void>(\n `/v1/gate/identities/${identityId}/resend-verification`,\n options,\n );\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { OidcProvider, SecuritySettings } from './types.js';\n\nexport class SettingsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns the tenant's security settings (passwordless / MFA).\n */\n async getSecurity(options?: RequestOptions): Promise<SecuritySettings> {\n return this.http.get<SecuritySettings>('/v1/gate/settings/security', options);\n }\n\n /**\n * Replaces the tenant's security settings. Both fields are required — the\n * update is a full replacement, not a merge.\n *\n * @example\n * await gate.settings.updateSecurity({ passwordless_enabled: true, mfa_enabled: false });\n */\n async updateSecurity(\n settings: SecuritySettings,\n options?: RequestOptions,\n ): Promise<void> {\n return this.http.put<void>('/v1/gate/settings/security', {\n body: settings,\n ...options,\n });\n }\n\n /**\n * Returns the tenant's social login (OIDC) providers and whether each is\n * enabled. Covers all providers Gate supports, regardless of state.\n */\n async getOidcProviders(options?: RequestOptions): Promise<OidcProvider[]> {\n const res = await this.http.get<{ providers: OidcProvider[] }>(\n '/v1/gate/settings/oidc-providers',\n options,\n );\n return res.providers;\n }\n\n /**\n * Sets the `enabled` flag for one or more social login providers. Any\n * provider omitted from `providers` is left unchanged. Returns the full,\n * updated provider list.\n *\n * @example\n * await gate.settings.updateOidcProviders([\n * { provider: 'github', enabled: true },\n * { provider: 'google', enabled: true },\n * ]);\n */\n async updateOidcProviders(\n providers: OidcProvider[],\n options?: RequestOptions,\n ): Promise<OidcProvider[]> {\n const res = await this.http.put<{ providers: OidcProvider[] }>(\n '/v1/gate/settings/oidc-providers',\n { body: { providers }, ...options },\n );\n return res.providers;\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { AccessToken, CreateTokenParams, IntrospectResult } from './types.js';\n\nexport class TokensResource {\n constructor(\n private readonly http: HttpClient,\n private readonly apiKey: string,\n ) {}\n\n /**\n * Exchanges the Gate API key for a short-lived access token.\n *\n * Note: This endpoint does not use the Authorization header — the API key\n * is passed in the request body per the Gate API specification.\n */\n async create(params: CreateTokenParams, options?: RequestOptions): Promise<AccessToken> {\n return this.http.post<AccessToken>('/v1/gate/tokens', {\n body: { api_key: this.apiKey, ...params },\n skipAuth: true,\n ...options,\n });\n }\n\n /**\n * Validates a Gate access token and returns its decoded attributes.\n */\n async introspect(accessToken: string, options?: RequestOptions): Promise<IntrospectResult> {\n return this.http.post<IntrospectResult>('/v1/gate/tokens/introspect', {\n body: { access_token: accessToken },\n ...options,\n });\n }\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { RequestOptions, ServiceConfig } from '../../core/types.js';\nimport { IdentitiesResource } from './identities.js';\nimport { SettingsResource } from './settings.js';\nimport { TokensResource } from './tokens.js';\nimport type { AuthorizeParams, AuthorizeResult, LoginFlow } from './types.js';\n\nexport class Gate {\n readonly identities: IdentitiesResource;\n readonly tokens: TokensResource;\n readonly settings: SettingsResource;\n\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.identities = new IdentitiesResource(this.http);\n this.tokens = new TokensResource(this.http, config.apiKey);\n this.settings = new SettingsResource(this.http);\n }\n\n /**\n * Checks whether a given subject is allowed to perform an action on a resource.\n * This is the core building block for enforcing authorization in your services.\n *\n * @example\n * const result = await gate.authorize({\n * subject: 'usr_123',\n * action: 'relay.messages.read',\n * resource: 'tenant:ten_001',\n * });\n * if (!result.allowed) throw new Error('Forbidden');\n */\n async authorize(params: AuthorizeParams, options?: RequestOptions): Promise<AuthorizeResult> {\n return this.http.post<AuthorizeResult>('/v1/gate/authorize', { body: params, ...options });\n }\n\n /**\n * Returns the list of social login providers currently enabled for a tenant.\n * This is a public, unauthenticated endpoint — call it from your login /\n * registration page to decide which social buttons to render.\n *\n * @example\n * const providers = await gate.getEnabledProviders('ten_001');\n * // → ['github', 'google']\n */\n async getEnabledProviders(tenantId: string, options?: RequestOptions): Promise<string[]> {\n const res = await this.http.get<{ providers: string[] }>(\n `/public/gate/providers/${encodeURIComponent(tenantId)}`,\n { skipAuth: true, ...options },\n );\n return res.providers;\n }\n\n /**\n * Initializes a Kratos login flow using your Gate API key. Call this from\n * your server and pass the returned flow JSON to your browser-side code to\n * render social login buttons. The flow already contains only the providers\n * your tenant has enabled.\n *\n * @example\n * const flow = await gate.createLoginFlow();\n * // send `flow` to the browser as JSON\n */\n async createLoginFlow(options?: RequestOptions): Promise<LoginFlow> {\n return this.http.get<LoginFlow>('/v1/gate/auth/login', options);\n }\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { RequestOptions, ServiceConfig } from '../../core/types.js';\nimport type { LoginStart, LoginStatus, TokenIntrospection } from './types.js';\n\n/**\n * Verne Passepartout — Telegram Auth-as-a-Service.\n *\n * Lets your end-users sign in with Telegram: start a login to get a deep link,\n * send the user to it, then poll for completion to receive an access token.\n */\nexport class Passepartout {\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n }\n\n /**\n * Starts a Telegram login and returns a nonce + deep link. Send the user to\n * `deep_link`, then poll {@link loginStatus} with `nonce` until it completes.\n *\n * @example\n * const { nonce, deep_link } = await passepartout.loginStart();\n * // redirect the user to `deep_link`, then poll:\n * const status = await passepartout.loginStatus(nonce);\n */\n async loginStart(options?: RequestOptions): Promise<LoginStart> {\n return this.http.post<LoginStart>('/v1/passepartout/login/start', options);\n }\n\n /**\n * Returns the current state of a login attempt. While the user hasn't\n * finished, `status` is `pending`; once done it becomes `completed` and\n * carries the `access_token` and `user`.\n */\n async loginStatus(nonce: string, options?: RequestOptions): Promise<LoginStatus> {\n return this.http.get<LoginStatus>(\n `/v1/passepartout/login/status?nonce=${encodeURIComponent(nonce)}`,\n options,\n );\n }\n\n /**\n * Validates a Passepartout access token and returns its attributes.\n * Tokens owned by another tenant are reported as `{ active: false }`.\n */\n async introspect(accessToken: string, options?: RequestOptions): Promise<TokenIntrospection> {\n return this.http.post<TokenIntrospection>('/v1/passepartout/tokens/introspect', {\n body: { access_token: accessToken },\n ...options,\n });\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type {\n ListMessagesParams,\n ListMessagesResponse,\n Message,\n SendMessageParams,\n} from './types.js';\n\nexport class MessagesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Publish an event to all endpoints subscribed to the given event_type.\n * Automatically retries once on 429 (respects Retry-After header).\n *\n * @returns The accepted message with its assigned ID and timestamp.\n */\n async send(params: SendMessageParams, options?: RequestOptions): Promise<Message> {\n return this.http.post<Message>('/v1/relay/messages', { body: params, ...options });\n }\n\n /**\n * Returns a paginated list of previously sent events for the current tenant.\n */\n async list(params?: ListMessagesParams, options?: RequestOptions): Promise<ListMessagesResponse> {\n const query = buildQuery(params);\n const path = query ? `/v1/relay/messages?${query}` : '/v1/relay/messages';\n return this.http.get<ListMessagesResponse>(path, options);\n }\n}\n\nfunction buildQuery(params?: ListMessagesParams): string {\n if (!params) return '';\n const searchParams = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) searchParams.set(k, String(v));\n }\n return searchParams.toString();\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { ServiceConfig } from '../../core/types.js';\nimport { MessagesResource } from './messages.js';\n\nexport class Relay {\n readonly messages: MessagesResource;\n\n constructor(config: ServiceConfig) {\n const http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.messages = new MessagesResource(http);\n }\n}\n","import { VerneError } from './core/errors.js';\nimport type { VerneConfig } from './core/types.js';\nimport { Clockwork } from './resources/clockwork/clockwork.js';\nimport { Gate } from './resources/gate/gate.js';\nimport { Passepartout } from './resources/passepartout/passepartout.js';\nimport { Relay } from './resources/relay/relay.js';\n\nexport class Verne {\n private readonly config: VerneConfig;\n private _relay?: Relay;\n private _gate?: Gate;\n private _passepartout?: Passepartout;\n private _clockwork?: Clockwork;\n\n constructor(config: VerneConfig) {\n if (!config.relay && !config.gate && !config.passepartout && !config.clockwork) {\n throw new VerneError(\n 'At least one service key (relay, gate, passepartout, or clockwork) must be provided.',\n );\n }\n this.config = config;\n }\n\n get relay(): Relay {\n if (!this.config.relay) {\n throw new VerneError(\n 'Relay API key not provided. Pass `relay` in the Verne constructor config.',\n );\n }\n this._relay ??= new Relay({\n apiKey: this.config.relay,\n baseUrl: this.config.baseUrl,\n timeoutMs: this.config.timeoutMs,\n });\n return this._relay;\n }\n\n get gate(): Gate {\n if (!this.config.gate) {\n throw new VerneError(\n 'Gate API key not provided. Pass `gate` in the Verne constructor config.',\n );\n }\n this._gate ??= new Gate({\n apiKey: this.config.gate,\n baseUrl: this.config.baseUrl,\n timeoutMs: this.config.timeoutMs,\n });\n return this._gate;\n }\n\n get passepartout(): Passepartout {\n if (!this.config.passepartout) {\n throw new VerneError(\n 'Passepartout API key not provided. Pass `passepartout` in the Verne constructor config.',\n );\n }\n this._passepartout ??= new Passepartout({\n apiKey: this.config.passepartout,\n baseUrl: this.config.baseUrl,\n timeoutMs: this.config.timeoutMs,\n });\n return this._passepartout;\n }\n\n get clockwork(): Clockwork {\n if (!this.config.clockwork) {\n throw new VerneError(\n 'Clockwork API key not provided. Pass `clockwork` in the Verne constructor config.',\n );\n }\n this._clockwork ??= new Clockwork({\n apiKey: this.config.clockwork,\n baseUrl: this.config.baseUrl,\n timeoutMs: this.config.timeoutMs,\n });\n return this._clockwork;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.ts","../src/core/http.ts","../src/resources/clockwork/delayed.ts","../src/resources/clockwork/jobs.ts","../src/resources/clockwork/clockwork.ts","../src/resources/gate/audit-log.ts","../src/resources/gate/identities.ts","../src/resources/gate/lifecycle.ts","../src/resources/gate/organizations.ts","../src/resources/gate/sessions.ts","../src/resources/gate/settings.ts","../src/resources/gate/verifier.ts","../src/resources/gate/tokens.ts","../src/resources/gate/gate.ts","../src/resources/passepartout/passepartout.ts","../src/resources/relay/messages.ts","../src/resources/relay/relay.ts","../src/verne.ts"],"names":["DEFAULT_TIMEOUT_MS","buildQuery"],"mappings":";;;AAGO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACd;AACF;AAMO,IAAM,aAAA,GAAN,MAAM,cAAA,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f,IAAA,IAAA,CAAK,KAAA,KAAL,KAAK,KAAA,GAAU,IAAI,KAAK,IAAA,CAAK,aAAA,CAAc,MAAM,CAAC,CAAA,CAAA;AAClD,IAAA,OAAO,IAAA,CAAK,KAAA;AAAA,EACd;AAAA,EAEA,IAAI,YAAA,GAA6B;AAC/B,IAAA,IAAA,CAAK,aAAA,KAAL,KAAK,aAAA,GAAkB,IAAI,aAAa,IAAA,CAAK,aAAA,CAAc,cAAc,CAAC,CAAA,CAAA;AAC1E,IAAA,OAAO,IAAA,CAAK,aAAA;AAAA,EACd;AAAA,EAEA,IAAI,SAAA,GAAuB;AACzB,IAAA,IAAA,CAAK,UAAA,KAAL,KAAK,UAAA,GAAe,IAAI,UAAU,IAAA,CAAK,aAAA,CAAc,WAAW,CAAC,CAAA,CAAA;AACjE,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AAAA,EAEQ,cAAc,OAAA,EAAsB;AAC1C,IAAA,MAAM,SAAS,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA,IAAK,KAAK,MAAA,CAAO,MAAA;AACnD,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,UAAA;AAAA,QACR,CAAA,EAAG,cAAA,CAAe,OAAO,CAAC,gDAAgD,OAAO,CAAA,oCAAA;AAAA,OACnF;AAAA,IACF;AACA,IAAA,OAAO,EAAE,QAAQ,OAAA,EAAS,IAAA,CAAK,OAAO,OAAA,EAAS,SAAA,EAAW,IAAA,CAAK,MAAA,CAAO,SAAA,EAAU;AAAA,EAClF;AACF","file":"index.js","sourcesContent":["/**\n * Base class for all errors thrown by the Verne SDK.\n */\nexport class VerneError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'VerneError';\n }\n}\n\n/**\n * Thrown when the Verne API returns an error response.\n * Contains structured information from the API error envelope.\n */\nexport class VerneAPIError extends VerneError {\n /**\n * Machine-readable error code, e.g. `'invalid_payload'`, `'forbidden'`, `'conflict'`,\n * `'mfa_required'`, `'ACTIVE_USER_LIMIT_REACHED'`. Codes are an open set: compare\n * against the ones you handle and treat the rest generically. `'unknown'` when the\n * response carried no string code — which the API's own routes no longer do; it is\n * left for a body that did not come from the gateway (a proxy in between, an identity\n * service response passed through on `/auth/*`).\n */\n readonly code: string;\n /** HTTP status code. */\n readonly status: number;\n /**\n * Request ID to include when contacting support.\n * Undefined when the response did not carry one.\n */\n readonly requestId?: string;\n /**\n * The members of `error` other than `code`, `message` and `request_id` — for example\n * `plan`, `limit` and `current` on a `402` limit refusal, `kind` on a Clockwork one,\n * `required_aal` and `current_aal` on `403 mfa_required`. Empty when there are none.\n */\n readonly details: Record<string, unknown>;\n /**\n * Seconds from the `Retry-After` header, when the response had one — on a `429` it is\n * how long to wait. For `RELAY_MESSAGE_LIMIT_REACHED` it runs to the 1st of next month.\n */\n readonly retryAfter?: number;\n /** Raw parsed error body, kept so unrecognised shapes stay diagnosable. */\n readonly body?: unknown;\n\n constructor({\n code,\n message,\n status,\n requestId,\n details,\n retryAfter,\n body,\n }: {\n code: string;\n message: string;\n status: number;\n requestId?: string;\n details?: Record<string, unknown>;\n retryAfter?: number;\n body?: unknown;\n }) {\n super(message);\n this.name = 'VerneAPIError';\n this.code = code;\n this.status = status;\n this.requestId = requestId;\n this.details = details ?? {};\n this.retryAfter = retryAfter;\n this.body = body;\n }\n\n /**\n * Builds an error from a parsed response body of *unknown* shape.\n *\n * Every API route answers with the envelope `{ error: { code, message, request_id,\n * ...extra } }`. Other shapes are still read, as a fallback that costs nothing: the\n * string form `{ error: \"<sentence>\" }` Clockwork used before October 2026, and an\n * identity-service body whose `code` is a number (still what Kratos' own `/auth/*`\n * self-service routes answer). Anything unrecognised degrades — to code `'unknown'`,\n * to `HTTP <status>` — rather than throwing: an error path must never be the thing\n * that fails.\n */\n static fromResponse(status: number, body: unknown, retryAfter?: number): VerneAPIError {\n const envelope = isRecord(body) && isRecord(body.error) ? body.error : undefined;\n const details: Record<string, unknown> = {};\n if (envelope) {\n for (const [key, value] of Object.entries(envelope)) {\n if (key !== 'code' && key !== 'message' && key !== 'request_id') details[key] = value;\n }\n }\n return new VerneAPIError({\n code: typeof envelope?.code === 'string' ? envelope.code : 'unknown',\n message: extractMessage(body, status),\n status,\n requestId: typeof envelope?.request_id === 'string' ? envelope.request_id : undefined,\n details,\n retryAfter,\n body,\n });\n }\n}\n\n/** Why a signed token was refused by {@link VerneTokenError}. */\nexport type TokenErrorReason =\n | 'malformed'\n | 'unsupported_alg'\n | 'unknown_kid'\n | 'bad_signature'\n | 'wrong_issuer'\n | 'expired'\n | 'not_yet_valid'\n | 'missing_claim'\n | 'jwks_unavailable';\n\n/**\n * Thrown by signed-token verification (`GateTokenVerifier`, `gate.tokens.verifySigned`)\n * when a token must not be trusted. `reason` says why.\n */\nexport class VerneTokenError extends VerneError {\n readonly reason: TokenErrorReason;\n\n constructor(reason: TokenErrorReason, message: string) {\n super(message);\n this.name = 'VerneTokenError';\n this.reason = reason;\n }\n}\n\n/** Shape of the API error envelope documented for all Verne services. */\nexport interface APIErrorBody {\n error: {\n code: string;\n message: string;\n request_id: string;\n [extra: string]: unknown;\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Best-effort human-readable message from an arbitrary error body.\n * Recognises the documented envelope first, then a string `error` (Clockwork), then the\n * `{ detail: ... }` shape validation errors can arrive in, then a bare `message` field.\n */\nfunction extractMessage(body: unknown, status: number): string {\n if (isRecord(body)) {\n const envelope = body.error;\n if (isRecord(envelope) && typeof envelope.message === 'string') {\n return envelope.message;\n }\n if (typeof envelope === 'string' && envelope.trim() !== '') {\n return envelope;\n }\n\n const { detail } = body;\n if (typeof detail === 'string') return detail;\n if (Array.isArray(detail)) {\n const messages = detail\n .map((item) => (isRecord(item) && typeof item.msg === 'string' ? item.msg : null))\n .filter((msg): msg is string => msg !== null);\n if (messages.length > 0) return messages.join('; ');\n }\n\n if (typeof body.message === 'string') return body.message;\n }\n\n return `HTTP ${status}`;\n}\n","import { VerneAPIError, VerneError } from './errors.js';\nimport type { RequestOptions } from './types.js';\n\nexport const DEFAULT_BASE_URL = 'https://api.vernesoft.com';\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\n/**\n * The longest `Retry-After` the client waits out on its own before retrying a `429`.\n * Anything longer — Relay's monthly limit answers with the seconds until the 1st of next\n * month — is raised at once, with `retryAfter` on the error, for the caller to decide.\n */\nconst MAX_AUTO_RETRY_AFTER_SECONDS = 60;\n\n/** A `429` that waiting a few seconds does not lift. */\nconst NON_RETRYABLE_429_CODES = new Set(['RELAY_MESSAGE_LIMIT_REACHED']);\n\nexport interface HttpClientConfig {\n apiKey: string;\n baseUrl?: string;\n timeoutMs?: number;\n}\n\nexport interface HttpRequestOptions extends RequestOptions {\n /** When true, omit the Authorization header (calls authenticated by something else). */\n skipAuth?: boolean;\n /** Body to send as JSON. */\n body?: unknown;\n /** Query parameters. `undefined` and `null` values are dropped. */\n query?: QueryParams;\n /** An end user's session token, sent as `X-Session-Token`. */\n sessionToken?: string;\n}\n\nexport type QueryParams = Record<string, string | number | boolean | Date | null | undefined>;\n\nexport class HttpClient {\n private readonly apiKey: string;\n readonly baseUrl: string;\n private readonly timeoutMs: number;\n\n constructor(config: HttpClientConfig) {\n this.apiKey = config.apiKey;\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '');\n this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n }\n\n async get<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('GET', path, options);\n }\n\n async post<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('POST', path, options);\n }\n\n async put<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('PUT', path, options);\n }\n\n async patch<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('PATCH', path, options);\n }\n\n async delete<T>(path: string, options?: HttpRequestOptions): Promise<T> {\n return this.request<T>('DELETE', path, options);\n }\n\n private async request<T>(\n method: string,\n path: string,\n options: HttpRequestOptions = {},\n attempt = 1,\n ): Promise<T> {\n const {\n skipAuth,\n body,\n signal,\n headers: extraHeaders,\n timeoutMs,\n query,\n sessionToken,\n } = options;\n\n const qs = buildQuery(query);\n const url = `${this.baseUrl}${path}${qs ? (path.includes('?') ? '&' : '?') + qs : ''}`;\n const timeout = timeoutMs ?? this.timeoutMs;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n ...extraHeaders,\n };\n\n if (!skipAuth) {\n headers['Authorization'] = `Bearer ${this.apiKey}`;\n }\n if (sessionToken !== undefined) {\n headers['X-Session-Token'] = sessionToken;\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n // Allow external signal to also abort the request\n const combinedSignal = signal\n ? AbortSignal.any([signal, controller.signal])\n : controller.signal;\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers,\n body: body !== undefined ? JSON.stringify(body) : undefined,\n signal: combinedSignal,\n });\n } catch (err) {\n clearTimeout(timeoutId);\n if (err instanceof Error && err.name === 'AbortError') {\n throw new VerneError(`Request timed out after ${timeout}ms: ${method} ${path}`);\n }\n throw new VerneError(`Network error: ${err instanceof Error ? err.message : String(err)}`);\n } finally {\n clearTimeout(timeoutId);\n }\n\n if (!response.ok) {\n const retryAfter = parseRetryAfter(response.headers.get('Retry-After'));\n let errorBody: unknown;\n try {\n errorBody = await response.json();\n } catch {\n throw VerneAPIError.fromResponse(response.status, undefined, retryAfter);\n }\n const error = VerneAPIError.fromResponse(response.status, errorBody, retryAfter);\n\n // One retry of a POST on a short 429 (the per-minute burst ceilings). Never on a\n // limit that lifts at the end of the month, and never on a 402.\n const wait = retryAfter ?? 1;\n if (\n response.status === 429 &&\n attempt === 1 &&\n method === 'POST' &&\n wait <= MAX_AUTO_RETRY_AFTER_SECONDS &&\n !NON_RETRYABLE_429_CODES.has(error.code)\n ) {\n await sleep(wait * 1000);\n return this.request<T>(method, path, options, 2);\n }\n throw error;\n }\n\n // 204 No Content\n if (response.status === 204) {\n return undefined as T;\n }\n\n return response.json() as Promise<T>;\n }\n}\n\n/** Seconds from a `Retry-After` header (delta-seconds or an HTTP date), or undefined. */\nfunction parseRetryAfter(raw: string | null): number | undefined {\n if (raw === null || raw.trim() === '') return undefined;\n const seconds = Number(raw);\n if (Number.isFinite(seconds) && seconds >= 0) return seconds;\n const at = Date.parse(raw);\n if (!Number.isNaN(at)) return Math.max(0, Math.ceil((at - Date.now()) / 1000));\n return undefined;\n}\n\n/** `a=1&b=2` from a params object; `undefined`/`null` dropped, a `Date` as RFC 3339. */\nexport function buildQuery(params?: QueryParams): string {\n if (!params) return '';\n const search = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null) continue;\n search.set(key, value instanceof Date ? value.toISOString() : String(value));\n }\n return search.toString();\n}\n\n/** One path segment, URL-encoded: ids come from callers and must not reshape the path. */\nexport function seg(value: string): string {\n return encodeURIComponent(value);\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { CreateDelayedJobParams, DelayedJob, Execution } from './types.js';\n\nexport class ClockworkDelayedResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns all delayed (one-shot) jobs for the current tenant.\n */\n async list(options?: RequestOptions): Promise<DelayedJob[]> {\n return this.http.get<DelayedJob[]>('/v1/clockwork/delayed', options);\n }\n\n /**\n * Schedules a new delayed job to run once at the given `run_at` time.\n *\n * @example\n * const job = await clockwork.delayed.create({\n * name: 'send-reminder',\n * run_at: '2026-01-01T09:00:00Z',\n * url: 'https://example.com/hooks/reminder',\n * });\n */\n async create(params: CreateDelayedJobParams, options?: RequestOptions): Promise<DelayedJob> {\n return this.http.post<DelayedJob>('/v1/clockwork/delayed', { body: params, ...options });\n }\n\n /**\n * Cancels a pending delayed job. Resolves on `204 No Content`.\n */\n async cancel(jobId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/clockwork/delayed/${jobId}`, options);\n }\n\n /**\n * Returns the execution history for a delayed job.\n */\n async executions(jobId: string, options?: RequestOptions): Promise<Execution[]> {\n return this.http.get<Execution[]>(`/v1/clockwork/delayed/${jobId}/executions`, options);\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { CreateCronJobParams, CronJob, Execution, UpdateCronJobParams } from './types.js';\n\nexport class ClockworkJobsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns all cron jobs for the current tenant.\n */\n async list(options?: RequestOptions): Promise<CronJob[]> {\n return this.http.get<CronJob[]>('/v1/clockwork/jobs', options);\n }\n\n /**\n * Creates a new recurring cron job.\n *\n * @example\n * const job = await clockwork.jobs.create({\n * name: 'nightly-report',\n * schedule: '0 2 * * *',\n * url: 'https://example.com/hooks/report',\n * });\n */\n async create(params: CreateCronJobParams, options?: RequestOptions): Promise<CronJob> {\n return this.http.post<CronJob>('/v1/clockwork/jobs', { body: params, ...options });\n }\n\n /**\n * Partially updates an existing cron job. Only the fields you provide are changed.\n */\n async update(\n jobId: string,\n params: UpdateCronJobParams,\n options?: RequestOptions,\n ): Promise<CronJob> {\n return this.http.patch<CronJob>(`/v1/clockwork/jobs/${jobId}`, { body: params, ...options });\n }\n\n /**\n * Deletes a cron job. Resolves on `204 No Content`.\n */\n async delete(jobId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/clockwork/jobs/${jobId}`, options);\n }\n\n /**\n * Returns the execution history for a cron job (most recent runs first).\n */\n async executions(jobId: string, options?: RequestOptions): Promise<Execution[]> {\n return this.http.get<Execution[]>(`/v1/clockwork/jobs/${jobId}/executions`, options);\n }\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { RequestOptions, ServiceConfig } from '../../core/types.js';\nimport { ClockworkDelayedResource } from './delayed.js';\nimport { ClockworkJobsResource } from './jobs.js';\nimport type { ClockworkUsage } from './types.js';\n\nexport class Clockwork {\n readonly jobs: ClockworkJobsResource;\n readonly delayed: ClockworkDelayedResource;\n\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.jobs = new ClockworkJobsResource(this.http);\n this.delayed = new ClockworkDelayedResource(this.http);\n }\n\n /**\n * How many jobs exist against the plan's limits. Creating a job over a limit, or\n * resuming a paused one, is refused with `402` (`UPGRADE_REQUIRED` or\n * `JOB_LIMIT_REACHED`) — never retried.\n */\n async usage(options?: RequestOptions): Promise<ClockworkUsage> {\n return this.http.get<ClockworkUsage>('/v1/clockwork/usage', options);\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { Paginated, RequestOptions } from '../../core/types.js';\nimport type { AuditLogEntry, ListAuditLogParams } from './types.js';\n\n/**\n * The account's audit log, read-only: who did what, to what, when and from where. The\n * key reads its own project's entries and the account-wide ones.\n *\n * Any key with the `gate` scope reads the whole log, including the IP addresses and\n * user agents of your team members. Keep `gate` keys on your backend.\n */\nexport class AuditLogResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * One page of entries, newest first. Filters combine; keep the same filters while\n * paging with `cursor`.\n *\n * @example\n * const page = await gate.auditLog.list({ action: 'identity.login', actor_id: userId });\n */\n async list(\n params?: ListAuditLogParams,\n options?: RequestOptions,\n ): Promise<Paginated<AuditLogEntry>> {\n return this.http.get<Paginated<AuditLogEntry>>('/v1/gate/audit-log', {\n query: { ...params },\n ...options,\n });\n }\n}\n","import { seg } from '../../core/http.js';\nimport type { HttpClient } from '../../core/http.js';\nimport type { ListParams, Paginated, RequestOptions } from '../../core/types.js';\nimport type { CreateIdentityParams, Identity, JsonPatchOp, OrgClaim } from './types.js';\n\nexport class IdentitiesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Creates a new identity (end user) bound to your tenant. Answers `201`.\n *\n * A `409 conflict` means you already have an end user with this address; the same\n * address at another tenant is a different person and does not conflict. Traits are\n * `email` and `locale` only — keep your own fields in custom metadata.\n */\n async create(params: CreateIdentityParams, options?: RequestOptions): Promise<Identity> {\n return this.http.post<Identity>('/v1/gate/identities', { body: params, ...options });\n }\n\n /**\n * Returns an identity by ID. An identity of another tenant is refused.\n */\n async get(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.http.get<Identity>(`/v1/gate/identities/${seg(identityId)}`, options);\n }\n\n /**\n * Partially updates an identity using a JSON Patch document (RFC 6902).\n *\n * @example\n * await gate.identities.patch('identity_123', [\n * { op: 'replace', path: '/traits/email', value: 'new@example.com' },\n * ]);\n */\n async patch(identityId: string, ops: JsonPatchOp[], options?: RequestOptions): Promise<Identity> {\n return this.http.patch<Identity>(`/v1/gate/identities/${seg(identityId)}`, {\n body: ops,\n ...options,\n });\n }\n\n /**\n * Deletes an identity, its sessions and its memberships. Fires `identity.deleted`.\n */\n async delete(identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/gate/identities/${seg(identityId)}`, options);\n }\n\n /**\n * Activates or deactivates an identity. An `inactive` identity cannot sign in, its\n * sessions stop working (until it is active again), its access tokens introspect as\n * `active: false`, and no signed token is issued for it. Nothing is deleted. Fires the\n * `identity.state_changed` webhook event.\n *\n * @example\n * await gate.identities.setState('identity_123', 'inactive');\n */\n async setState(\n identityId: string,\n state: 'active' | 'inactive',\n options?: RequestOptions,\n ): Promise<Identity> {\n return this.http.patch<Identity>(`/v1/gate/identities/${seg(identityId)}/state`, {\n body: { state },\n ...options,\n });\n }\n\n /** Convenience wrapper for {@link setState}(identityId, 'active'). */\n async activate(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.setState(identityId, 'active', options);\n }\n\n /** Convenience wrapper for {@link setState}(identityId, 'inactive'). */\n async deactivate(identityId: string, options?: RequestOptions): Promise<Identity> {\n return this.setState(identityId, 'inactive', options);\n }\n\n /**\n * Triggers a new email verification flow for an identity — useful when the\n * original verification email expired or was never received. The user receives\n * a fresh verification email. Resolves on `204 No Content`.\n */\n async resendVerification(identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.post<void>(\n `/v1/gate/identities/${seg(identityId)}/resend-verification`,\n options,\n );\n }\n\n /**\n * Reads an identity's custom metadata (`metadata_public`) — the place for your own\n * fields about a user. `{}` when nothing is set.\n */\n async getMetadata(\n identityId: string,\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const res = await this.http.get<{ metadata_public: Record<string, unknown> }>(\n `/v1/gate/identities/${seg(identityId)}/metadata`,\n options,\n );\n return res.metadata_public;\n }\n\n /**\n * Merges `patch` into an identity's custom metadata and returns the result. Keys you\n * leave out are kept; a key set to `null` is removed.\n *\n * @example\n * await gate.identities.updateMetadata(id, { plan: 'pro', seats: null });\n */\n async updateMetadata(\n identityId: string,\n patch: Record<string, unknown>,\n options?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n const res = await this.http.patch<{ metadata_public: Record<string, unknown> }>(\n `/v1/gate/identities/${seg(identityId)}/metadata`,\n { body: patch, ...options },\n );\n return res.metadata_public;\n }\n\n /**\n * The organizations of the key's project that an end user belongs to, with the role\n * held in each and its permissions — live, oldest membership first, cursor-paged. This\n * is the complete list that `orgs_truncated: true` (in a token, an introspection or a\n * session check) points to.\n */\n async listOrganizations(\n identityId: string,\n params?: ListParams,\n options?: RequestOptions,\n ): Promise<Paginated<OrgClaim>> {\n return this.http.get<Paginated<OrgClaim>>(\n `/v1/gate/identities/${seg(identityId)}/organizations`,\n { query: { limit: params?.limit, cursor: params?.cursor }, ...options },\n );\n }\n}\n","import { seg } from '../../core/http.js';\nimport type { HttpClient } from '../../core/http.js';\nimport type { Paginated, RequestOptions } from '../../core/types.js';\nimport type {\n LifecycleAction,\n LifecycleRule,\n LifecycleRuleKind,\n LifecycleRuleParamsByKind,\n LifecycleRulePreview,\n LifecycleRules,\n ListLifecycleActionsParams,\n SetLifecycleRuleParams,\n} from './types.js';\n\nconst rulePath = (kind: LifecycleRuleKind) => `/v1/gate/lifecycle/rules/${seg(kind)}`;\n\n/**\n * Automatic deletion of unconfirmed and inactive accounts, and removal of expired roles —\n * four rules per project, all off until you switch them on. Only `delete_unverified` is\n * in the Free plan; switching on another is `403 plan_required`.\n */\nexport class LifecycleResource {\n constructor(private readonly http: HttpClient) {}\n\n /** All four rules of the key's project, set up or not, and the plan. */\n async listRules(options?: RequestOptions): Promise<LifecycleRules> {\n return this.http.get<LifecycleRules>('/v1/gate/lifecycle/rules', options);\n }\n\n /**\n * Creates, changes, or switches a rule on or off. Leave `params` out to keep the saved\n * settings. Switching off or changing settings cancels what the rule had scheduled.\n *\n * @example\n * await gate.lifecycle.setRule('delete_unverified', {\n * enabled: true,\n * params: { delete_after_days: 14, warn_before_days: 3 },\n * });\n */\n async setRule<K extends LifecycleRuleKind>(\n kind: K,\n params: SetLifecycleRuleParams<K>,\n options?: RequestOptions,\n ): Promise<LifecycleRule> {\n const body: Record<string, unknown> = { enabled: params.enabled };\n if (params.params !== undefined) body.params = params.params;\n return this.http.put<LifecycleRule>(rulePath(kind), { body, ...options });\n }\n\n /** Removes a rule and cancels what it scheduled. Succeeds also when there was none. */\n async deleteRule(kind: LifecycleRuleKind, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(rulePath(kind), options);\n }\n\n /**\n * How many people a rule with these settings would affect right now. Writes nothing;\n * works whether or not the rule is on or in your plan. `expire_roles` takes `{}`.\n */\n async previewRule<K extends LifecycleRuleKind>(\n kind: K,\n params: LifecycleRuleParamsByKind[K],\n options?: RequestOptions,\n ): Promise<LifecycleRulePreview> {\n return this.http.post<LifecycleRulePreview>(`${rulePath(kind)}/preview`, {\n body: { params },\n ...options,\n });\n }\n\n /** What the rules have scheduled and done, oldest first, cursor-paged. */\n async listActions(\n params?: ListLifecycleActionsParams,\n options?: RequestOptions,\n ): Promise<Paginated<LifecycleAction>> {\n return this.http.get<Paginated<LifecycleAction>>('/v1/gate/lifecycle/actions', {\n query: { ...params },\n ...options,\n });\n }\n}\n","import { seg } from '../../core/http.js';\nimport type { HttpClient } from '../../core/http.js';\nimport type { ListParams, Paginated, RequestOptions } from '../../core/types.js';\nimport type {\n AddMemberParams,\n AuthorizeResult,\n CreateOrganizationParams,\n CreateRoleParams,\n Member,\n Organization,\n Role,\n UpdateMemberParams,\n UpdateOrganizationParams,\n UpdateRoleParams,\n} from './types.js';\n\nconst orgPath = (orgId: string) => `/v1/gate/organizations/${seg(orgId)}`;\nconst pageQuery = (params?: ListParams) => ({ limit: params?.limit, cursor: params?.cursor });\nconst isoOrNull = (value: string | Date | null) =>\n value instanceof Date ? value.toISOString() : value;\n\n/**\n * Organizations of your end users — their teams, workspaces, companies — with named\n * roles and members. Everything here acts on **the project the API key belongs to**.\n *\n * Gate keeps the data and reports it (introspection, the session check, the signed\n * token's `orgs` claim); it does not enforce permissions. Ask with {@link can}.\n */\nexport class OrganizationsResource {\n readonly roles: RolesResource;\n readonly members: MembersResource;\n\n constructor(private readonly http: HttpClient) {\n this.roles = new RolesResource(http);\n this.members = new MembersResource(http);\n }\n\n /** Creates an organization. `name` is free text, 1–120 characters, not unique. */\n async create(params: CreateOrganizationParams, options?: RequestOptions): Promise<Organization> {\n return this.http.post<Organization>('/v1/gate/organizations', { body: params, ...options });\n }\n\n /** Lists the project's organizations, oldest first, cursor-paged. */\n async list(params?: ListParams, options?: RequestOptions): Promise<Paginated<Organization>> {\n return this.http.get<Paginated<Organization>>('/v1/gate/organizations', {\n query: pageQuery(params),\n ...options,\n });\n }\n\n async get(orgId: string, options?: RequestOptions): Promise<Organization> {\n return this.http.get<Organization>(orgPath(orgId), options);\n }\n\n /** Renames an organization. */\n async update(\n orgId: string,\n params: UpdateOrganizationParams,\n options?: RequestOptions,\n ): Promise<Organization> {\n return this.http.patch<Organization>(orgPath(orgId), { body: params, ...options });\n }\n\n /** Deletes an organization with its roles and memberships. */\n async delete(orgId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(orgPath(orgId), options);\n }\n\n /**\n * *May this end user do this in this organization?* — answered from the role the user\n * holds there and its permissions, as they are now. `permission` must match exactly\n * (no wildcards). An organization of another project looks like a missing one\n * (`no_such_organization`). An invalid permission (upper case, `*`, the `nautilus:`\n * prefix) is a `400` error, never `allowed: false`. Not billed, not audited.\n */\n async authorize(\n orgId: string,\n identityId: string,\n permission: string,\n options?: RequestOptions,\n ): Promise<AuthorizeResult> {\n return this.http.post<AuthorizeResult>('/v1/gate/authorize', {\n body: { subject: identityId, action: permission, resource: `organization:${orgId}` },\n ...options,\n });\n }\n\n /**\n * `true` when the end user holds `permission` in the organization — the boolean of\n * {@link authorize}. Errors are thrown, not turned into `false`.\n *\n * @example\n * if (!(await gate.organizations.can(orgId, userId, 'invoices:write'))) {\n * throw new Error('Forbidden');\n * }\n */\n async can(\n orgId: string,\n identityId: string,\n permission: string,\n options?: RequestOptions,\n ): Promise<boolean> {\n const decision = await this.authorize(orgId, identityId, permission, options);\n return decision.allowed === true;\n }\n}\n\n/** Roles of one organization: named sets of permissions. */\nexport class RolesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Defines a role. `409 conflict` if the name is taken in the organization,\n * `409 limit_reached` past 100 roles.\n */\n async create(orgId: string, params: CreateRoleParams, options?: RequestOptions): Promise<Role> {\n return this.http.post<Role>(`${orgPath(orgId)}/roles`, { body: params, ...options });\n }\n\n async list(\n orgId: string,\n params?: ListParams,\n options?: RequestOptions,\n ): Promise<Paginated<Role>> {\n return this.http.get<Paginated<Role>>(`${orgPath(orgId)}/roles`, {\n query: pageQuery(params),\n ...options,\n });\n }\n\n async get(orgId: string, roleId: string, options?: RequestOptions): Promise<Role> {\n return this.http.get<Role>(`${orgPath(orgId)}/roles/${seg(roleId)}`, options);\n }\n\n /**\n * Renames a role and/or **replaces** its permissions. Everyone who holds it has the new\n * permissions the next time they are read.\n */\n async update(\n orgId: string,\n roleId: string,\n params: UpdateRoleParams,\n options?: RequestOptions,\n ): Promise<Role> {\n return this.http.patch<Role>(`${orgPath(orgId)}/roles/${seg(roleId)}`, {\n body: params,\n ...options,\n });\n }\n\n /** Deletes a role. A role someone holds is refused with `409 conflict`. */\n async delete(orgId: string, roleId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`${orgPath(orgId)}/roles/${seg(roleId)}`, options);\n }\n}\n\n/** Members of one organization: end users holding one role each. */\nexport class MembersResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Gives an end user a role in the organization. `404` if the identity is not one of\n * your end users, `409` if they already are a member (change the role with\n * {@link update}).\n */\n async add(orgId: string, params: AddMemberParams, options?: RequestOptions): Promise<Member> {\n const body: Record<string, unknown> = {\n identity_id: params.identity_id,\n role_id: params.role_id,\n };\n if (params.expires_at !== undefined) body.expires_at = isoOrNull(params.expires_at);\n return this.http.post<Member>(`${orgPath(orgId)}/members`, { body, ...options });\n }\n\n async list(\n orgId: string,\n params?: ListParams,\n options?: RequestOptions,\n ): Promise<Paginated<Member>> {\n return this.http.get<Paginated<Member>>(`${orgPath(orgId)}/members`, {\n query: pageQuery(params),\n ...options,\n });\n }\n\n /**\n * Changes a member's role and/or deadline. `expires_at`: leave it out to keep the\n * deadline, `null` to remove it, a time to set it.\n */\n async update(\n orgId: string,\n identityId: string,\n params: UpdateMemberParams,\n options?: RequestOptions,\n ): Promise<Member> {\n const body: Record<string, unknown> = {};\n if (params.role_id !== undefined) body.role_id = params.role_id;\n if (params.expires_at !== undefined) body.expires_at = isoOrNull(params.expires_at);\n return this.http.patch<Member>(`${orgPath(orgId)}/members/${seg(identityId)}`, {\n body,\n ...options,\n });\n }\n\n /** Removes the membership. The person stays your end user. */\n async remove(orgId: string, identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`${orgPath(orgId)}/members/${seg(identityId)}`, options);\n }\n}\n","import { seg } from '../../core/http.js';\nimport type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { GateSession, SessionCheck } from './types.js';\n\n/** End users' sessions: list, revoke, and check one is good enough to act on. */\nexport class SessionsResource {\n constructor(private readonly http: HttpClient) {}\n\n /** The active sessions of one of your end users (a bare array, not paged). */\n async list(identityId: string, options?: RequestOptions): Promise<GateSession[]> {\n return this.http.get<GateSession[]>(`/v1/gate/identities/${seg(identityId)}/sessions`, options);\n }\n\n /**\n * Revokes every session of an end user — \"log out everywhere\". Signed tokens already\n * issued keep verifying until their own `exp` (at most 15 minutes).\n *\n * Idempotent: a user of yours with no session at all is a success too. An id that is not\n * one of your users — another account's, unknown, or one you deleted — is\n * `403 forbidden`. `404 not_found` is rare: a user removed from the identity service\n * other than through `identities.delete()`, which Gate still remembered as yours.\n */\n async revokeAll(identityId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/gate/identities/${seg(identityId)}/sessions`, options);\n }\n\n /**\n * Revokes one session by its id. Revoking an already revoked session of your user is a\n * success too; an id that is not one of your users' sessions is `404`.\n */\n async revoke(sessionId: string, options?: RequestOptions): Promise<void> {\n return this.http.delete<void>(`/v1/gate/sessions/${seg(sessionId)}`, options);\n }\n\n /**\n * Whether an end user's session meets what your tenant requires — the one call to\n * gate your own routes on. Gate on `mfa_satisfied`. Also lists the user's\n * organizations in the key's project, read now.\n *\n * Throws `VerneAPIError` with `status 401` for a dead, foreign or unknown session, and\n * `code 'mfa_required'` (`403`) when a second factor is owed: start a step-up flow with\n * `gate.createLoginFlow({ aal: 'aal2', session_token })`.\n */\n async check(sessionToken: string, options?: RequestOptions): Promise<SessionCheck> {\n return this.http.get<SessionCheck>('/v1/gate/auth/session', { sessionToken, ...options });\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type { OidcProvider, SecuritySettings } from './types.js';\n\nexport class SettingsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Returns the tenant's security settings (passwordless / MFA). With `mfa_enabled`,\n * `sessions.check()` refuses a session without a second factor (`403 mfa_required`).\n */\n async getSecurity(options?: RequestOptions): Promise<SecuritySettings> {\n return this.http.get<SecuritySettings>('/v1/gate/settings/security', options);\n }\n\n /**\n * Replaces the tenant's security settings. Both fields are required — the\n * update is a full replacement, not a merge.\n *\n * @example\n * await gate.settings.updateSecurity({ passwordless_enabled: true, mfa_enabled: false });\n */\n async updateSecurity(settings: SecuritySettings, options?: RequestOptions): Promise<void> {\n return this.http.put<void>('/v1/gate/settings/security', {\n body: settings,\n ...options,\n });\n }\n\n /**\n * Returns the tenant's social login (OIDC) providers and whether each is\n * enabled. Covers all providers Gate supports, regardless of state.\n */\n async getOidcProviders(options?: RequestOptions): Promise<OidcProvider[]> {\n const res = await this.http.get<{ providers: OidcProvider[] }>(\n '/v1/gate/settings/oidc-providers',\n options,\n );\n return res.providers;\n }\n\n /**\n * Sets the `enabled` flag for one or more social login providers. Any\n * provider omitted from `providers` is left unchanged. Returns the full,\n * updated provider list.\n *\n * @example\n * await gate.settings.updateOidcProviders([\n * { provider: 'github', enabled: true },\n * { provider: 'google', enabled: true },\n * ]);\n */\n async updateOidcProviders(\n providers: OidcProvider[],\n options?: RequestOptions,\n ): Promise<OidcProvider[]> {\n const res = await this.http.put<{ providers: OidcProvider[] }>(\n '/v1/gate/settings/oidc-providers',\n { body: { providers }, ...options },\n );\n return res.providers;\n }\n\n /**\n * The project's social-login return URLs — the addresses on your backend that receive\n * the user (with a one-time `code`) after a social login. The first is the default.\n */\n async getReturnUrls(options?: RequestOptions): Promise<string[]> {\n const res = await this.http.get<{ return_urls: string[] }>(\n '/v1/gate/settings/return-urls',\n options,\n );\n return res.return_urls;\n }\n\n /**\n * Replaces the project's return URLs (at most 10; an empty list switches the feature\n * off) and returns them as they will be matched — exactly, never by prefix. `https`\n * only, except `http://localhost` and `http://127.0.0.1`; no query, fragment, `@` or\n * wildcard (`400 invalid_payload` names the entry).\n */\n async updateReturnUrls(urls: string[], options?: RequestOptions): Promise<string[]> {\n const res = await this.http.put<{ return_urls: string[] }>('/v1/gate/settings/return-urls', {\n body: { return_urls: urls },\n ...options,\n });\n return res.return_urls;\n }\n}\n","import type { webcrypto } from 'node:crypto';\nimport { VerneError, VerneTokenError } from '../../core/errors.js';\nimport { DEFAULT_BASE_URL } from '../../core/http.js';\nimport type { SignedTokenClaims } from './types.js';\n\ntype SubtleCrypto = webcrypto.SubtleCrypto;\ntype CryptoKey = webcrypto.CryptoKey;\ntype JsonWebKey = webcrypto.JsonWebKey;\n\n/** Cache lifetime when the key set answers without `Cache-Control: max-age`. */\nconst DEFAULT_JWKS_MAX_AGE_MS = 300_000;\n/** An unknown `kid` refetches the key set at most this often. */\nconst MIN_REFETCH_INTERVAL_MS = 30_000;\nconst DEFAULT_CLOCK_TOLERANCE_SECONDS = 10;\nconst DEFAULT_TIMEOUT_MS = 10_000;\n\nexport interface GateTokenVerifierConfig {\n /** Your tenant id. The issuer is `<baseUrl>/auth/<tenantId>`. */\n tenantId: string;\n /** Defaults to https://api.vernesoft.com — the same base URL as the API client. */\n baseUrl?: string;\n /** Allowed clock skew in seconds for `exp` and `nbf`. Default 10. */\n clockToleranceSeconds?: number;\n /** Timeout of a key-set request in milliseconds. Default 10000. */\n timeoutMs?: number;\n}\n\n/**\n * Verifies Gate signed tokens (ES256 JWTs) offline, against your tenant's published\n * public keys. No API key is involved: anything that receives a token can verify it.\n *\n * What it checks: the algorithm is ES256 (anything else, `none` included, is refused),\n * the key is the one the token's `kid` names in your tenant's key set, the signature,\n * `iss` is **your** issuer (a token of another Gate tenant is refused even though its\n * signature is valid), `exp` and `nbf`, and that `sub` is present.\n *\n * What it cannot check: whether the session behind the token is still alive. A signed\n * token lives 15 minutes and cannot be revoked; for anything that must follow a\n * revocation or a role change at once, ask `gate.sessions.check()` or introspection.\n *\n * The key set is cached for its `Cache-Control: max-age` (five minutes) and refetched\n * once when a token names a key it has not seen — which is how a key rotation is\n * followed. Keep one verifier per tenant and reuse it.\n *\n * @example\n * const verifier = new GateTokenVerifier({ tenantId: process.env.VERNE_TENANT_ID! });\n * const claims = await verifier.verify(token);\n * claims.sub; // the end user's id\n * claims.orgs; // [{ id, role, permissions }]\n */\nexport class GateTokenVerifier {\n readonly issuer: string;\n readonly jwksUrl: string;\n\n private readonly toleranceSeconds: number;\n private readonly timeoutMs: number;\n private keys = new Map<string, CryptoKey>();\n private fetchedAt = 0;\n private maxAgeMs = DEFAULT_JWKS_MAX_AGE_MS;\n private inflight?: Promise<void>;\n\n constructor(config: GateTokenVerifierConfig) {\n if (!config.tenantId) {\n throw new VerneError('GateTokenVerifier needs your tenantId.');\n }\n const base = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '');\n this.issuer = `${base}/auth/${config.tenantId}`;\n this.jwksUrl = `${this.issuer}/.well-known/jwks.json`;\n this.toleranceSeconds = config.clockToleranceSeconds ?? DEFAULT_CLOCK_TOLERANCE_SECONDS;\n this.timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n }\n\n /**\n * Verifies `token` and returns its claims. Throws {@link VerneTokenError} (with a\n * `reason`) when the token must not be trusted.\n */\n async verify(token: string): Promise<SignedTokenClaims> {\n const parts = typeof token === 'string' ? token.split('.') : [];\n if (parts.length !== 3) {\n throw new VerneTokenError('malformed', 'Not a compact JWT.');\n }\n const [rawHeader, rawPayload, rawSignature] = parts;\n const header = decodeJson(rawHeader, 'header');\n const payload = decodeJson(rawPayload, 'payload');\n\n if (header.alg !== 'ES256') {\n throw new VerneTokenError(\n 'unsupported_alg',\n `Token algorithm ${JSON.stringify(header.alg)} is not accepted; Gate signs with ES256.`,\n );\n }\n if (typeof header.kid !== 'string' || header.kid === '') {\n throw new VerneTokenError('malformed', 'Token header has no `kid`.');\n }\n\n const key = await this.keyFor(header.kid);\n const signature = base64UrlDecode(rawSignature);\n if (!signature || signature.length !== 64) {\n throw new VerneTokenError('bad_signature', 'Token signature is not a P-256 signature.');\n }\n const subtle = await subtleCrypto();\n const valid = await subtle.verify(\n { name: 'ECDSA', hash: 'SHA-256' },\n key,\n signature,\n new TextEncoder().encode(`${rawHeader}.${rawPayload}`),\n );\n if (!valid) {\n throw new VerneTokenError('bad_signature', 'Token signature does not verify.');\n }\n\n if (payload.iss !== this.issuer) {\n throw new VerneTokenError(\n 'wrong_issuer',\n `Token issuer ${JSON.stringify(payload.iss)} is not ${this.issuer}.`,\n );\n }\n const now = Math.floor(Date.now() / 1000);\n if (typeof payload.exp !== 'number') {\n throw new VerneTokenError('missing_claim', 'Token has no `exp`.');\n }\n if (now > payload.exp + this.toleranceSeconds) {\n throw new VerneTokenError('expired', 'Token has expired.');\n }\n if (typeof payload.nbf === 'number' && payload.nbf > now + this.toleranceSeconds) {\n throw new VerneTokenError('not_yet_valid', 'Token is not valid yet.');\n }\n if (typeof payload.sub !== 'string' || payload.sub === '') {\n throw new VerneTokenError('missing_claim', 'Token has no `sub`.');\n }\n\n return payload as SignedTokenClaims;\n }\n\n private async keyFor(kid: string): Promise<CryptoKey> {\n const stale = Date.now() - this.fetchedAt > this.maxAgeMs;\n if (stale) {\n await this.refresh(this.keys.size === 0);\n }\n let key = this.keys.get(kid);\n if (!key && Date.now() - this.fetchedAt >= MIN_REFETCH_INTERVAL_MS) {\n // A kid we have not seen: a new key may have started signing. Ask once.\n await this.refresh(true);\n key = this.keys.get(kid);\n }\n if (!key) {\n throw new VerneTokenError('unknown_kid', `No key ${kid} in ${this.jwksUrl}.`);\n }\n return key;\n }\n\n /**\n * Fetches the key set. With `required` false a failure keeps the keys already cached\n * (a stale key set is still the right one unless a token says otherwise).\n */\n private async refresh(required: boolean): Promise<void> {\n this.inflight ??= this.load().finally(() => {\n this.inflight = undefined;\n });\n try {\n await this.inflight;\n } catch (err) {\n if (required) throw err;\n }\n }\n\n private async load(): Promise<void> {\n let response: Response;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeoutMs);\n try {\n response = await fetch(this.jwksUrl, {\n headers: { Accept: 'application/json' },\n signal: controller.signal,\n });\n } catch (err) {\n throw new VerneTokenError(\n 'jwks_unavailable',\n `Could not fetch ${this.jwksUrl}: ${err instanceof Error ? err.message : String(err)}`,\n );\n } finally {\n clearTimeout(timer);\n }\n if (!response.ok) {\n throw new VerneTokenError(\n 'jwks_unavailable',\n `${this.jwksUrl} answered HTTP ${response.status}.`,\n );\n }\n let body: unknown;\n try {\n body = await response.json();\n } catch {\n throw new VerneTokenError('jwks_unavailable', `${this.jwksUrl} did not answer JSON.`);\n }\n const jwks = (body as { keys?: unknown }).keys;\n if (!Array.isArray(jwks)) {\n throw new VerneTokenError('jwks_unavailable', `${this.jwksUrl} has no \\`keys\\`.`);\n }\n\n const subtle = await subtleCrypto();\n const keys = new Map<string, CryptoKey>();\n for (const jwk of jwks as Array<JsonWebKey & { kid?: string; use?: string }>) {\n if (jwk.kty !== 'EC' || jwk.crv !== 'P-256' || typeof jwk.kid !== 'string') continue;\n if (jwk.use !== undefined && jwk.use !== 'sig') continue;\n const { kty, crv, x, y } = jwk;\n try {\n keys.set(\n jwk.kid,\n await subtle.importKey(\n 'jwk',\n { kty, crv, x, y },\n { name: 'ECDSA', namedCurve: 'P-256' },\n false,\n ['verify'],\n ),\n );\n } catch {\n // A key we cannot import is a key we cannot verify with; skip it.\n }\n }\n this.keys = keys;\n this.fetchedAt = Date.now();\n this.maxAgeMs = maxAgeMs(response.headers.get('Cache-Control'));\n }\n}\n\nfunction maxAgeMs(cacheControl: string | null): number {\n const match = cacheControl ? /max-age=(\\d+)/i.exec(cacheControl) : null;\n return match ? Number(match[1]) * 1000 : DEFAULT_JWKS_MAX_AGE_MS;\n}\n\nfunction decodeJson(segment: string, what: string): Record<string, unknown> {\n const bytes = base64UrlDecode(segment);\n if (bytes) {\n try {\n const value: unknown = JSON.parse(new TextDecoder().decode(bytes));\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n return value as Record<string, unknown>;\n }\n } catch {\n // fall through\n }\n }\n throw new VerneTokenError('malformed', `Token ${what} is not base64url JSON.`);\n}\n\nfunction base64UrlDecode(segment: string): Uint8Array | null {\n if (!/^[A-Za-z0-9_-]*$/.test(segment)) return null;\n const base64 = segment.replace(/-/g, '+').replace(/_/g, '/');\n const padded = base64 + '='.repeat((4 - (base64.length % 4)) % 4);\n try {\n const binary = atob(padded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return bytes;\n } catch {\n return null;\n }\n}\n\nlet subtlePromise: Promise<SubtleCrypto> | undefined;\n\n/** WebCrypto: global in Node 19+, Deno, Bun and edge runtimes; `node:crypto` on Node 18. */\nfunction subtleCrypto(): Promise<SubtleCrypto> {\n subtlePromise ??= (async () => {\n const global = (globalThis as { crypto?: { subtle?: SubtleCrypto } }).crypto;\n if (global?.subtle) return global.subtle;\n const nodeCrypto = await import('node:crypto');\n return nodeCrypto.webcrypto.subtle as SubtleCrypto;\n })();\n return subtlePromise;\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type {\n AccessToken,\n CreateTokenParams,\n GateSession,\n IntrospectResult,\n SignedToken,\n SignedTokenClaims,\n VerifySignedOptions,\n} from './types.js';\nimport { GateTokenVerifier } from './verifier.js';\n\nexport class TokensResource {\n private readonly verifiers = new Map<string, GateTokenVerifier>();\n\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Exchanges the Gate API key for a short-lived access token (`gat_live_…`), for\n * `subject` — a user or a service account. Answers `201`.\n *\n * The key travels in the `Authorization` header like on every other call. (Until 1.4.0\n * this SDK sent it in the body without the header, which the API refuses with `401`.)\n */\n async create(params: CreateTokenParams, options?: RequestOptions): Promise<AccessToken> {\n return this.http.post<AccessToken>('/v1/gate/tokens', { body: params, ...options });\n }\n\n /**\n * Validates a Gate access token and returns its attributes. An unknown, expired or\n * foreign token, or one whose user you deactivated or deleted, is `{ active: false }`.\n *\n * When the subject is an end user, `orgs` lists their organizations in the key's\n * project, read at the moment you ask.\n */\n async introspect(accessToken: string, options?: RequestOptions): Promise<IntrospectResult> {\n return this.http.post<IntrospectResult>('/v1/gate/tokens/introspect', {\n body: { access_token: accessToken },\n ...options,\n });\n }\n\n /**\n * Gets a **signed JWT** (ES256) for a signed-in end user's session, for a platform that\n * verifies signatures instead of calling Gate (Supabase, an API gateway). The session\n * token is the credential: no API key is sent.\n *\n * The token is valid for 15 minutes and **cannot be revoked**; its `orgs` claim is as old\n * as the token. Every call mints a new one — ask again before the one you hold expires.\n * A revoked or expired session, or a deactivated user, is a `401`.\n *\n * @example\n * const { token } = await gate.tokens.createSigned(sessionToken);\n */\n async createSigned(sessionToken: string, options?: RequestOptions): Promise<SignedToken> {\n const res = await this.http.get<GateSession & { tokenized: string }>('/auth/sessions/whoami', {\n query: { tokenize_as: 'gate_jwt' },\n sessionToken,\n skipAuth: true,\n ...options,\n });\n const { tokenized, ...session } = res;\n return { token: tokenized, session: session as GateSession };\n }\n\n /**\n * Verifies a Gate signed token offline against your tenant's public keys (fetched once\n * and cached) and returns its claims. Throws `VerneTokenError` when the token must not\n * be trusted — wrong issuer (another tenant), bad signature, expired, any algorithm but\n * ES256. See {@link GateTokenVerifier} to verify without a Gate client.\n *\n * @example\n * const claims = await gate.tokens.verifySigned(token, { tenantId: 'your-tenant-id' });\n * claims.sub; // the end user's id\n */\n async verifySigned(token: string, options: VerifySignedOptions): Promise<SignedTokenClaims> {\n const cacheKey = `${options.tenantId}|${options.clockToleranceSeconds ?? ''}`;\n let verifier = this.verifiers.get(cacheKey);\n if (!verifier) {\n verifier = new GateTokenVerifier({\n tenantId: options.tenantId,\n baseUrl: this.http.baseUrl,\n clockToleranceSeconds: options.clockToleranceSeconds,\n });\n this.verifiers.set(cacheKey, verifier);\n }\n return verifier.verify(token);\n }\n}\n","import { HttpClient, seg } from '../../core/http.js';\nimport type { RequestOptions, ServiceConfig } from '../../core/types.js';\nimport { AuditLogResource } from './audit-log.js';\nimport { IdentitiesResource } from './identities.js';\nimport { LifecycleResource } from './lifecycle.js';\nimport { OrganizationsResource } from './organizations.js';\nimport { SessionsResource } from './sessions.js';\nimport { SettingsResource } from './settings.js';\nimport { TokensResource } from './tokens.js';\nimport type {\n AuthorizeParams,\n AuthorizeResult,\n LoginFlow,\n LoginFlowParams,\n OidcExchangeResult,\n RegistrationFlowParams,\n} from './types.js';\n\nexport class Gate {\n readonly identities: IdentitiesResource;\n readonly tokens: TokensResource;\n readonly settings: SettingsResource;\n readonly organizations: OrganizationsResource;\n readonly sessions: SessionsResource;\n readonly auditLog: AuditLogResource;\n readonly lifecycle: LifecycleResource;\n\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.identities = new IdentitiesResource(this.http);\n this.tokens = new TokensResource(this.http);\n this.settings = new SettingsResource(this.http);\n this.organizations = new OrganizationsResource(this.http);\n this.sessions = new SessionsResource(this.http);\n this.auditLog = new AuditLogResource(this.http);\n this.lifecycle = new LifecycleResource(this.http);\n }\n\n /**\n * Asks whether a subject may perform an action on a resource. The answer is a decision;\n * your service enforces it.\n *\n * - `resource: 'organization:<id>'` — may this end user do `action` (a permission) in\n * that organization? `reason` is one of a fixed set and `role` is the role they hold.\n * Prefer `gate.organizations.authorize()` / `can()`, which build the resource.\n * - any other resource — only *is `subject` one of your active end users?*; `reason` is\n * `owned_by_tenant` (allowed), `subject_inactive`, `not_owned_by_tenant` or\n * `not_a_known_identity`, and `message` says it in a sentence for your logs.\n *\n * @example\n * const decision = await gate.authorize({\n * subject: userId,\n * action: 'invoices:write',\n * resource: `organization:${orgId}`,\n * });\n * if (!decision.allowed) throw new Error('Forbidden');\n */\n async authorize(params: AuthorizeParams, options?: RequestOptions): Promise<AuthorizeResult> {\n return this.http.post<AuthorizeResult>('/v1/gate/authorize', { body: params, ...options });\n }\n\n /**\n * Returns the list of social login providers currently enabled for a tenant.\n * This is a public, unauthenticated endpoint — call it from your login /\n * registration page to decide which social buttons to render.\n *\n * @example\n * const providers = await gate.getEnabledProviders('ten_001');\n * // → ['github', 'google']\n */\n async getEnabledProviders(tenantId: string, options?: RequestOptions): Promise<string[]> {\n const res = await this.http.get<{ providers: string[] }>(\n `/public/gate/providers/${seg(tenantId)}`,\n { skipAuth: true, ...options },\n );\n return res.providers;\n }\n\n /**\n * Starts a Kratos login flow with your Gate API key and returns it; render its\n * `ui.nodes` or post credentials to its `ui.action`. With a return URL registered,\n * pass `return_to` and always a `state` for social login. A step-up (second factor) is\n * `{ aal: 'aal2', session_token }`.\n *\n * @example\n * const flow = await gate.createLoginFlow({ state: csrfBoundValue });\n */\n async createLoginFlow(params?: LoginFlowParams, options?: RequestOptions): Promise<LoginFlow> {\n return this.http.get<LoginFlow>('/v1/gate/auth/login', {\n query: { return_to: params?.return_to, state: params?.state, aal: params?.aal },\n sessionToken: params?.session_token,\n ...options,\n });\n }\n\n /**\n * Starts a Kratos registration flow. Refused with `402 ACTIVE_USER_LIMIT_REACHED` when\n * the account is past its active-user limit and the month to move up has ended.\n */\n async createRegistrationFlow(\n params?: RegistrationFlowParams,\n options?: RequestOptions,\n ): Promise<LoginFlow> {\n return this.http.get<LoginFlow>('/v1/gate/auth/registration', {\n query: { return_to: params?.return_to, state: params?.state },\n ...options,\n });\n }\n\n /**\n * Exchanges the one-time `code` your return URL received after a social login for the\n * user's session. The code works once, for about 60 seconds, and only with a key of the\n * project that started the login (otherwise `404`). Keep the session token server-side.\n */\n async exchangeOidcCode(code: string, options?: RequestOptions): Promise<OidcExchangeResult> {\n return this.http.post<OidcExchangeResult>('/v1/gate/auth/oidc/exchange', {\n body: { code },\n ...options,\n });\n }\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { RequestOptions, ServiceConfig } from '../../core/types.js';\nimport type { LoginStart, LoginStatus, TokenIntrospection } from './types.js';\n\n/**\n * Verne Passepartout — Telegram Auth-as-a-Service.\n *\n * Lets your end-users sign in with Telegram: start a login to get a deep link,\n * send the user to it, then poll for completion to receive an access token.\n */\nexport class Passepartout {\n private readonly http: HttpClient;\n\n constructor(config: ServiceConfig) {\n this.http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n }\n\n /**\n * Starts a Telegram login and returns a nonce + deep link. Send the user to\n * `deep_link`, then poll {@link loginStatus} with `nonce` until it completes.\n *\n * @example\n * const { nonce, deep_link } = await passepartout.loginStart();\n * // redirect the user to `deep_link`, then poll:\n * const status = await passepartout.loginStatus(nonce);\n */\n async loginStart(options?: RequestOptions): Promise<LoginStart> {\n return this.http.post<LoginStart>('/v1/passepartout/login/start', options);\n }\n\n /**\n * Returns the current state of a login attempt. While the user hasn't\n * finished, `status` is `pending`; once done it becomes `completed` and\n * carries the `access_token` and `user`.\n *\n * Throws `VerneAPIError` with `403 account_disabled` when the person is deactivated,\n * and `402 ACTIVE_USER_LIMIT_REACHED` when a *new* person signs in past the account's\n * active-user limit (retrying does not help; existing users are unaffected).\n */\n async loginStatus(nonce: string, options?: RequestOptions): Promise<LoginStatus> {\n return this.http.get<LoginStatus>(\n `/v1/passepartout/login/status?nonce=${encodeURIComponent(nonce)}`,\n options,\n );\n }\n\n /**\n * Validates a Passepartout access token and returns its attributes.\n * Tokens owned by another tenant are reported as `{ active: false }`.\n */\n async introspect(accessToken: string, options?: RequestOptions): Promise<TokenIntrospection> {\n return this.http.post<TokenIntrospection>('/v1/passepartout/tokens/introspect', {\n body: { access_token: accessToken },\n ...options,\n });\n }\n}\n","import type { HttpClient } from '../../core/http.js';\nimport type { RequestOptions } from '../../core/types.js';\nimport type {\n ListMessagesParams,\n ListMessagesResponse,\n Message,\n SendMessageParams,\n} from './types.js';\n\nexport class MessagesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Publish an event to all endpoints subscribed to the given event_type.\n * Retries once on a short `429` (a `Retry-After` of a minute or less). The monthly\n * message limit (`429 RELAY_MESSAGE_LIMIT_REACHED`, `Retry-After` until the 1st) is\n * thrown at once, with `retryAfter` on the error.\n *\n * Safe to retry beyond that, if you pass an `idempotency_key`: a repeat\n * returns the originally accepted message rather than creating a second event\n * or failing.\n *\n * @returns The accepted message with its assigned ID and timestamp.\n */\n async send(params: SendMessageParams, options?: RequestOptions): Promise<Message> {\n return this.http.post<Message>('/v1/relay/messages', { body: params, ...options });\n }\n\n /**\n * Returns a paginated list of previously sent events for the current tenant.\n */\n async list(params?: ListMessagesParams, options?: RequestOptions): Promise<ListMessagesResponse> {\n const query = buildQuery(params);\n const path = query ? `/v1/relay/messages?${query}` : '/v1/relay/messages';\n return this.http.get<ListMessagesResponse>(path, options);\n }\n}\n\nfunction buildQuery(params?: ListMessagesParams): string {\n if (!params) return '';\n const searchParams = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) searchParams.set(k, String(v));\n }\n return searchParams.toString();\n}\n","import { HttpClient } from '../../core/http.js';\nimport type { ServiceConfig } from '../../core/types.js';\nimport { MessagesResource } from './messages.js';\n\nexport class Relay {\n readonly messages: MessagesResource;\n\n constructor(config: ServiceConfig) {\n const http = new HttpClient({\n apiKey: config.apiKey,\n baseUrl: config.baseUrl,\n timeoutMs: config.timeoutMs,\n });\n this.messages = new MessagesResource(http);\n }\n}\n","import { VerneError } from './core/errors.js';\nimport type { VerneConfig } from './core/types.js';\nimport { Clockwork } from './resources/clockwork/clockwork.js';\nimport { Gate } from './resources/gate/gate.js';\nimport { Passepartout } from './resources/passepartout/passepartout.js';\nimport { Relay } from './resources/relay/relay.js';\n\ntype ServiceName = 'relay' | 'gate' | 'passepartout' | 'clockwork';\n\nconst SERVICE_LABELS: Record<ServiceName, string> = {\n relay: 'Relay',\n gate: 'Gate',\n passepartout: 'Passepartout',\n clockwork: 'Clockwork',\n};\n\n/**\n * The unified client. Pass one API key (`apiKey`) and use any service its scopes allow;\n * a call to a service the key has no scope for is refused by the API with `403 forbidden`.\n *\n * @example\n * const verne = new Verne({ apiKey: process.env.VERNE_API_KEY });\n * await verne.gate.organizations.create({ name: 'Acme' });\n */\nexport class Verne {\n private readonly config: VerneConfig;\n private _relay?: Relay;\n private _gate?: Gate;\n private _passepartout?: Passepartout;\n private _clockwork?: Clockwork;\n\n constructor(config: VerneConfig) {\n if (\n !config.apiKey &&\n !config.relay &&\n !config.gate &&\n !config.passepartout &&\n !config.clockwork\n ) {\n throw new VerneError(\n 'No API key provided. Pass `apiKey` (or a per-service key: relay, gate, passepartout, clockwork).',\n );\n }\n this.config = config;\n }\n\n get relay(): Relay {\n this._relay ??= new Relay(this.serviceConfig('relay'));\n return this._relay;\n }\n\n get gate(): Gate {\n this._gate ??= new Gate(this.serviceConfig('gate'));\n return this._gate;\n }\n\n get passepartout(): Passepartout {\n this._passepartout ??= new Passepartout(this.serviceConfig('passepartout'));\n return this._passepartout;\n }\n\n get clockwork(): Clockwork {\n this._clockwork ??= new Clockwork(this.serviceConfig('clockwork'));\n return this._clockwork;\n }\n\n private serviceConfig(service: ServiceName) {\n const apiKey = this.config[service] ?? this.config.apiKey;\n if (!apiKey) {\n throw new VerneError(\n `${SERVICE_LABELS[service]} API key not provided. Pass \\`apiKey\\` (or \\`${service}\\`) in the Verne constructor config.`,\n );\n }\n return { apiKey, baseUrl: this.config.baseUrl, timeoutMs: this.config.timeoutMs };\n }\n}\n"]}
|