@workos-inc/node 8.0.0-rc.2 → 8.0.0-rc.3
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/lib/cjs/client/sso.cjs +2 -2
- package/lib/cjs/client/sso.cjs.map +1 -1
- package/lib/cjs/client/user-management.cjs +2 -2
- package/lib/cjs/client/user-management.cjs.map +1 -1
- package/lib/cjs/common/exceptions/unprocessable-entity.exception.cjs +1 -12
- package/lib/cjs/common/exceptions/unprocessable-entity.exception.cjs.map +1 -1
- package/lib/cjs/common/net/fetch-client.cjs +4 -4
- package/lib/cjs/common/net/fetch-client.cjs.map +1 -1
- package/lib/cjs/common/net/http-client.cjs +4 -1
- package/lib/cjs/common/net/http-client.cjs.map +1 -1
- package/lib/cjs/common/net/http-client.d.cts +1 -0
- package/lib/cjs/common/utils/leb128.cjs +101 -0
- package/lib/cjs/common/utils/leb128.cjs.map +1 -0
- package/lib/cjs/common/utils/leb128.d.cts +24 -0
- package/lib/cjs/common/utils/query-string.cjs +66 -0
- package/lib/cjs/common/utils/query-string.cjs.map +1 -0
- package/lib/cjs/common/utils/query-string.d.cts +11 -0
- package/lib/cjs/vault/vault.cjs +3 -3
- package/lib/cjs/vault/vault.cjs.map +1 -1
- package/lib/cjs/widgets/interfaces/get-token.cjs.map +1 -1
- package/lib/cjs/widgets/interfaces/get-token.d.cts +1 -1
- package/lib/cjs/workos.cjs +1 -1
- package/lib/cjs/workos.cjs.map +1 -1
- package/lib/esm/client/sso.js +1 -1
- package/lib/esm/client/sso.js.map +1 -1
- package/lib/esm/client/user-management.js +1 -1
- package/lib/esm/client/user-management.js.map +1 -1
- package/lib/esm/common/exceptions/unprocessable-entity.exception.js +1 -2
- package/lib/esm/common/exceptions/unprocessable-entity.exception.js.map +1 -1
- package/lib/esm/common/net/fetch-client.js +4 -4
- package/lib/esm/common/net/fetch-client.js.map +1 -1
- package/lib/esm/common/net/http-client.d.ts +1 -0
- package/lib/esm/common/net/http-client.js +4 -1
- package/lib/esm/common/net/http-client.js.map +1 -1
- package/lib/esm/common/utils/leb128.d.ts +24 -0
- package/lib/esm/common/utils/leb128.js +77 -0
- package/lib/esm/common/utils/leb128.js.map +1 -0
- package/lib/esm/common/utils/query-string.d.ts +11 -0
- package/lib/esm/common/utils/query-string.js +43 -0
- package/lib/esm/common/utils/query-string.js.map +1 -0
- package/lib/esm/vault/vault.js +1 -1
- package/lib/esm/vault/vault.js.map +1 -1
- package/lib/esm/widgets/interfaces/get-token.d.ts +1 -1
- package/lib/esm/widgets/interfaces/get-token.js.map +1 -1
- package/lib/esm/workos.js +1 -1
- package/lib/esm/workos.js.map +1 -1
- package/package.json +2 -6
- package/lib/cjs/client/utils.cjs +0 -49
- package/lib/cjs/client/utils.cjs.map +0 -1
- package/lib/cjs/client/utils.d.cts +0 -7
- package/lib/cjs/common/interfaces/delete-options.interface.cjs +0 -17
- package/lib/cjs/common/interfaces/delete-options.interface.cjs.map +0 -1
- package/lib/cjs/common/interfaces/delete-options.interface.d.cts +0 -8
- package/lib/cjs/workos-BcNRiAbw.d.cts +0 -398
- package/lib/cjs/workos-BjsIEalN.d.cts +0 -399
- package/lib/cjs/workos-ZPbUKdml.d.cts +0 -397
- package/lib/esm/client/utils.d.ts +0 -7
- package/lib/esm/client/utils.js +0 -16
- package/lib/esm/client/utils.js.map +0 -1
package/lib/esm/workos.js
CHANGED
|
@@ -33,7 +33,7 @@ import { ConflictException } from "./common/exceptions/conflict.exception.js";
|
|
|
33
33
|
import { ParseError } from "./common/exceptions/parse-error.js";
|
|
34
34
|
import { getEnv } from "./common/utils/env.js";
|
|
35
35
|
import { getRuntimeInfo } from "./common/utils/runtime-info.js";
|
|
36
|
-
const VERSION = "8.0.0-rc.
|
|
36
|
+
const VERSION = "8.0.0-rc.3";
|
|
37
37
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
38
38
|
const HEADER_AUTHORIZATION = "Authorization";
|
|
39
39
|
const HEADER_IDEMPOTENCY_KEY = "Idempotency-Key";
|
package/lib/esm/workos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workos.ts"],"sourcesContent":["import {\n GenericServerException,\n NoApiKeyProvidedException,\n NotFoundException,\n UnauthorizedException,\n UnprocessableEntityException,\n OauthException,\n RateLimitExceededException,\n} from './common/exceptions';\nimport {\n GetOptions,\n HttpClientResponseInterface,\n PostOptions,\n PutOptions,\n WorkOSOptions,\n WorkOSResponseError,\n} from './common/interfaces';\nimport { ApiKeys } from './api-keys/api-keys';\nimport { DirectorySync } from './directory-sync/directory-sync';\nimport { Events } from './events/events';\nimport { Organizations } from './organizations/organizations';\nimport { OrganizationDomains } from './organization-domains/organization-domains';\nimport { Passwordless } from './passwordless/passwordless';\nimport { Portal } from './portal/portal';\nimport { SSO } from './sso/sso';\nimport { Webhooks } from './webhooks/webhooks';\nimport { Mfa } from './mfa/mfa';\nimport { AuditLogs } from './audit-logs/audit-logs';\nimport { UserManagement } from './user-management/user-management';\nimport { FGA } from './fga/fga';\nimport { BadRequestException } from './common/exceptions/bad-request.exception';\n\nimport { HttpClient, HttpClientError } from './common/net/http-client';\nimport { SubtleCryptoProvider } from './common/crypto/subtle-crypto-provider';\nimport { FetchHttpClient } from './common/net/fetch-client';\nimport { Widgets } from './widgets/widgets';\nimport { Actions } from './actions/actions';\nimport { Vault } from './vault/vault';\nimport { ConflictException } from './common/exceptions/conflict.exception';\nimport { CryptoProvider } from './common/crypto/crypto-provider';\nimport { ParseError } from './common/exceptions/parse-error';\nimport { getEnv } from './common/utils/env';\nimport { getRuntimeInfo } from './common/utils/runtime-info';\n\nconst VERSION = '8.0.0-rc.2';\n\nconst DEFAULT_HOSTNAME = 'api.workos.com';\n\nconst HEADER_AUTHORIZATION = 'Authorization';\nconst HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';\nconst HEADER_WARRANT_TOKEN = 'Warrant-Token';\n\nexport class WorkOS {\n readonly baseURL: string;\n readonly client: HttpClient;\n readonly clientId?: string;\n\n readonly actions: Actions;\n readonly apiKeys = new ApiKeys(this);\n readonly auditLogs = new AuditLogs(this);\n readonly directorySync = new DirectorySync(this);\n readonly organizations = new Organizations(this);\n readonly organizationDomains = new OrganizationDomains(this);\n readonly passwordless = new Passwordless(this);\n readonly portal = new Portal(this);\n readonly sso = new SSO(this);\n readonly webhooks: Webhooks;\n readonly mfa = new Mfa(this);\n readonly events = new Events(this);\n readonly userManagement: UserManagement;\n readonly fga = new FGA(this);\n readonly widgets = new Widgets(this);\n readonly vault = new Vault(this);\n\n constructor(\n readonly key?: string,\n readonly options: WorkOSOptions = {},\n ) {\n if (!key) {\n this.key = getEnv('WORKOS_API_KEY');\n\n if (!this.key) {\n throw new NoApiKeyProvidedException();\n }\n }\n\n if (this.options.https === undefined) {\n this.options.https = true;\n }\n\n this.clientId = this.options.clientId;\n if (!this.clientId) {\n this.clientId = getEnv('WORKOS_CLIENT_ID');\n }\n\n const protocol: string = this.options.https ? 'https' : 'http';\n const apiHostname: string = this.options.apiHostname || DEFAULT_HOSTNAME;\n const port: number | undefined = this.options.port;\n this.baseURL = `${protocol}://${apiHostname}`;\n\n if (port) {\n this.baseURL = this.baseURL + `:${port}`;\n }\n\n this.webhooks = this.createWebhookClient();\n this.actions = this.createActionsClient();\n\n // Must initialize UserManagement after baseURL is configured\n this.userManagement = new UserManagement(this);\n\n const userAgent = this.createUserAgent(options);\n\n this.client = this.createHttpClient(options, userAgent);\n }\n\n private createUserAgent(options: WorkOSOptions): string {\n let userAgent: string = `workos-node/${VERSION}`;\n\n const { name: runtimeName, version: runtimeVersion } = getRuntimeInfo();\n userAgent += ` (${runtimeName}${runtimeVersion ? `/${runtimeVersion}` : ''})`;\n\n if (options.appInfo) {\n const { name, version } = options.appInfo;\n userAgent += ` ${name}: ${version}`;\n }\n\n return userAgent;\n }\n\n createWebhookClient() {\n return new Webhooks(this.getCryptoProvider());\n }\n\n createActionsClient() {\n return new Actions(this.getCryptoProvider());\n }\n\n getCryptoProvider(): CryptoProvider {\n return new SubtleCryptoProvider();\n }\n\n createHttpClient(options: WorkOSOptions, userAgent: string) {\n return new FetchHttpClient(this.baseURL, {\n ...options.config,\n timeout: options.timeout,\n headers: {\n ...options.config?.headers,\n Authorization: `Bearer ${this.key}`,\n 'User-Agent': userAgent,\n },\n }) as HttpClient;\n }\n\n get version() {\n return VERSION;\n }\n\n async post<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PostOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.post<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async get<Result = any>(\n path: string,\n options: GetOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.accessToken) {\n requestHeaders[HEADER_AUTHORIZATION] = `Bearer ${options.accessToken}`;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n try {\n res = await this.client.get(path, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async put<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PutOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.put<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async delete(path: string, query?: any): Promise<void> {\n try {\n await this.client.delete(path, {\n params: query,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n }\n\n emitWarning(warning: string) {\n // tslint:disable-next-line:no-console\n console.warn(`WorkOS: ${warning}`);\n }\n\n private async handleParseError(\n error: unknown,\n res: HttpClientResponseInterface,\n ) {\n if (error instanceof SyntaxError) {\n const rawResponse = res.getRawResponse() as Response;\n const requestID = rawResponse.headers.get('X-Request-ID') ?? '';\n const rawStatus = rawResponse.status;\n const rawBody = await rawResponse.text();\n throw new ParseError({\n message: error.message,\n rawBody,\n rawStatus,\n requestID,\n });\n }\n }\n\n private handleHttpError({ path, error }: { path: string; error: unknown }) {\n if (!(error instanceof HttpClientError)) {\n throw new Error(`Unexpected error: ${error}`, { cause: error });\n }\n\n const { response } = error as HttpClientError<WorkOSResponseError>;\n\n if (response) {\n const { status, data, headers } = response;\n\n const requestID = headers['X-Request-ID'] ?? '';\n const {\n code,\n error_description: errorDescription,\n error,\n errors,\n message,\n } = data;\n\n switch (status) {\n case 401: {\n throw new UnauthorizedException(requestID);\n }\n case 409: {\n throw new ConflictException({ requestID, message, error });\n }\n case 422: {\n throw new UnprocessableEntityException({\n code,\n errors,\n message,\n requestID,\n });\n }\n case 404: {\n throw new NotFoundException({\n code,\n message,\n path,\n requestID,\n });\n }\n case 429: {\n const retryAfter = headers.get('Retry-After');\n\n throw new RateLimitExceededException(\n data.message,\n requestID,\n retryAfter ? Number(retryAfter) : null,\n );\n }\n default: {\n if (error || errorDescription) {\n throw new OauthException(\n status,\n requestID,\n error,\n errorDescription,\n data,\n );\n } else if (code && errors) {\n // Note: ideally this should be mapped directly with a `400` status code.\n // However, this would break existing logic for the `OauthException` exception.\n throw new BadRequestException({\n code,\n errors,\n message,\n requestID,\n });\n } else {\n throw new GenericServerException(\n status,\n data.message,\n data,\n requestID,\n );\n }\n }\n }\n }\n }\n}\n"],"mappings":";;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,2BAA2B;AAEpC,SAAqB,uBAAuB;AAC5C,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAElC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAE/B,MAAM,UAAU;AAEhB,MAAM,mBAAmB;AAEzB,MAAM,uBAAuB;AAC7B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAEtB,MAAM,OAAO;AAAA,EAsBlB,YACW,KACA,UAAyB,CAAC,GACnC;AAFS;AACA;AAET,QAAI,CAAC,KAAK;AACR,WAAK,MAAM,OAAO,gBAAgB;AAElC,UAAI,CAAC,KAAK,KAAK;AACb,cAAM,IAAI,0BAA0B;AAAA,MACtC;AAAA,IACF;AAEA,QAAI,KAAK,QAAQ,UAAU,QAAW;AACpC,WAAK,QAAQ,QAAQ;AAAA,IACvB;AAEA,SAAK,WAAW,KAAK,QAAQ;AAC7B,QAAI,CAAC,KAAK,UAAU;AAClB,WAAK,WAAW,OAAO,kBAAkB;AAAA,IAC3C;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CAAC;AAAA,QACH;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,IAAI,kBAAkB;AAAA,YAC1B;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,CAAC;AAAA,QACH;AAAA,QACA,KAAK,KAAK;AACR,gBAAM,aAAa,QAAQ,IAAI,aAAa;AAE5C,gBAAM,IAAI;AAAA,YACR,KAAK;AAAA,YACL;AAAA,YACA,aAAa,OAAO,UAAU,IAAI;AAAA,UACpC;AAAA,QACF;AAAA,QACA,SAAS;AACP,cAAIA,UAAS,kBAAkB;AAC7B,kBAAM,IAAI;AAAA,cACR;AAAA,cACA;AAAA,cACAA;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF,WAAW,QAAQ,QAAQ;AAGzB,kBAAM,IAAI,oBAAoB;AAAA,cAC5B;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YACF,CAAC;AAAA,UACH,OAAO;AACL,kBAAM,IAAI;AAAA,cACR;AAAA,cACA,KAAK;AAAA,cACL;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["error"]}
|
|
1
|
+
{"version":3,"sources":["../../src/workos.ts"],"sourcesContent":["import {\n GenericServerException,\n NoApiKeyProvidedException,\n NotFoundException,\n UnauthorizedException,\n UnprocessableEntityException,\n OauthException,\n RateLimitExceededException,\n} from './common/exceptions';\nimport {\n GetOptions,\n HttpClientResponseInterface,\n PostOptions,\n PutOptions,\n WorkOSOptions,\n WorkOSResponseError,\n} from './common/interfaces';\nimport { ApiKeys } from './api-keys/api-keys';\nimport { DirectorySync } from './directory-sync/directory-sync';\nimport { Events } from './events/events';\nimport { Organizations } from './organizations/organizations';\nimport { OrganizationDomains } from './organization-domains/organization-domains';\nimport { Passwordless } from './passwordless/passwordless';\nimport { Portal } from './portal/portal';\nimport { SSO } from './sso/sso';\nimport { Webhooks } from './webhooks/webhooks';\nimport { Mfa } from './mfa/mfa';\nimport { AuditLogs } from './audit-logs/audit-logs';\nimport { UserManagement } from './user-management/user-management';\nimport { FGA } from './fga/fga';\nimport { BadRequestException } from './common/exceptions/bad-request.exception';\n\nimport { HttpClient, HttpClientError } from './common/net/http-client';\nimport { SubtleCryptoProvider } from './common/crypto/subtle-crypto-provider';\nimport { FetchHttpClient } from './common/net/fetch-client';\nimport { Widgets } from './widgets/widgets';\nimport { Actions } from './actions/actions';\nimport { Vault } from './vault/vault';\nimport { ConflictException } from './common/exceptions/conflict.exception';\nimport { CryptoProvider } from './common/crypto/crypto-provider';\nimport { ParseError } from './common/exceptions/parse-error';\nimport { getEnv } from './common/utils/env';\nimport { getRuntimeInfo } from './common/utils/runtime-info';\n\nconst VERSION = '8.0.0-rc.3';\n\nconst DEFAULT_HOSTNAME = 'api.workos.com';\n\nconst HEADER_AUTHORIZATION = 'Authorization';\nconst HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';\nconst HEADER_WARRANT_TOKEN = 'Warrant-Token';\n\nexport class WorkOS {\n readonly baseURL: string;\n readonly client: HttpClient;\n readonly clientId?: string;\n\n readonly actions: Actions;\n readonly apiKeys = new ApiKeys(this);\n readonly auditLogs = new AuditLogs(this);\n readonly directorySync = new DirectorySync(this);\n readonly organizations = new Organizations(this);\n readonly organizationDomains = new OrganizationDomains(this);\n readonly passwordless = new Passwordless(this);\n readonly portal = new Portal(this);\n readonly sso = new SSO(this);\n readonly webhooks: Webhooks;\n readonly mfa = new Mfa(this);\n readonly events = new Events(this);\n readonly userManagement: UserManagement;\n readonly fga = new FGA(this);\n readonly widgets = new Widgets(this);\n readonly vault = new Vault(this);\n\n constructor(\n readonly key?: string,\n readonly options: WorkOSOptions = {},\n ) {\n if (!key) {\n this.key = getEnv('WORKOS_API_KEY');\n\n if (!this.key) {\n throw new NoApiKeyProvidedException();\n }\n }\n\n if (this.options.https === undefined) {\n this.options.https = true;\n }\n\n this.clientId = this.options.clientId;\n if (!this.clientId) {\n this.clientId = getEnv('WORKOS_CLIENT_ID');\n }\n\n const protocol: string = this.options.https ? 'https' : 'http';\n const apiHostname: string = this.options.apiHostname || DEFAULT_HOSTNAME;\n const port: number | undefined = this.options.port;\n this.baseURL = `${protocol}://${apiHostname}`;\n\n if (port) {\n this.baseURL = this.baseURL + `:${port}`;\n }\n\n this.webhooks = this.createWebhookClient();\n this.actions = this.createActionsClient();\n\n // Must initialize UserManagement after baseURL is configured\n this.userManagement = new UserManagement(this);\n\n const userAgent = this.createUserAgent(options);\n\n this.client = this.createHttpClient(options, userAgent);\n }\n\n private createUserAgent(options: WorkOSOptions): string {\n let userAgent: string = `workos-node/${VERSION}`;\n\n const { name: runtimeName, version: runtimeVersion } = getRuntimeInfo();\n userAgent += ` (${runtimeName}${runtimeVersion ? `/${runtimeVersion}` : ''})`;\n\n if (options.appInfo) {\n const { name, version } = options.appInfo;\n userAgent += ` ${name}: ${version}`;\n }\n\n return userAgent;\n }\n\n createWebhookClient() {\n return new Webhooks(this.getCryptoProvider());\n }\n\n createActionsClient() {\n return new Actions(this.getCryptoProvider());\n }\n\n getCryptoProvider(): CryptoProvider {\n return new SubtleCryptoProvider();\n }\n\n createHttpClient(options: WorkOSOptions, userAgent: string) {\n return new FetchHttpClient(this.baseURL, {\n ...options.config,\n timeout: options.timeout,\n headers: {\n ...options.config?.headers,\n Authorization: `Bearer ${this.key}`,\n 'User-Agent': userAgent,\n },\n }) as HttpClient;\n }\n\n get version() {\n return VERSION;\n }\n\n async post<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PostOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.post<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async get<Result = any>(\n path: string,\n options: GetOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.accessToken) {\n requestHeaders[HEADER_AUTHORIZATION] = `Bearer ${options.accessToken}`;\n }\n\n if (options.warrantToken) {\n requestHeaders[HEADER_WARRANT_TOKEN] = options.warrantToken;\n }\n\n let res: HttpClientResponseInterface;\n try {\n res = await this.client.get(path, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async put<Result = any, Entity = any>(\n path: string,\n entity: Entity,\n options: PutOptions = {},\n ): Promise<{ data: Result }> {\n const requestHeaders: Record<string, string> = {};\n\n if (options.idempotencyKey) {\n requestHeaders[HEADER_IDEMPOTENCY_KEY] = options.idempotencyKey;\n }\n\n let res: HttpClientResponseInterface;\n\n try {\n res = await this.client.put<Entity>(path, entity, {\n params: options.query,\n headers: requestHeaders,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n\n try {\n return { data: await res.toJSON() };\n } catch (error) {\n await this.handleParseError(error, res);\n throw error;\n }\n }\n\n async delete(path: string, query?: any): Promise<void> {\n try {\n await this.client.delete(path, {\n params: query,\n });\n } catch (error) {\n this.handleHttpError({ path, error });\n\n throw error;\n }\n }\n\n emitWarning(warning: string) {\n // tslint:disable-next-line:no-console\n console.warn(`WorkOS: ${warning}`);\n }\n\n private async handleParseError(\n error: unknown,\n res: HttpClientResponseInterface,\n ) {\n if (error instanceof SyntaxError) {\n const rawResponse = res.getRawResponse() as Response;\n const requestID = rawResponse.headers.get('X-Request-ID') ?? '';\n const rawStatus = rawResponse.status;\n const rawBody = await rawResponse.text();\n throw new ParseError({\n message: error.message,\n rawBody,\n rawStatus,\n requestID,\n });\n }\n }\n\n private handleHttpError({ path, error }: { path: string; error: unknown }) {\n if (!(error instanceof HttpClientError)) {\n throw new Error(`Unexpected error: ${error}`, { cause: error });\n }\n\n const { response } = error as HttpClientError<WorkOSResponseError>;\n\n if (response) {\n const { status, data, headers } = response;\n\n const requestID = headers['X-Request-ID'] ?? '';\n const {\n code,\n error_description: errorDescription,\n error,\n errors,\n message,\n } = data;\n\n switch (status) {\n case 401: {\n throw new UnauthorizedException(requestID);\n }\n case 409: {\n throw new ConflictException({ requestID, message, error });\n }\n case 422: {\n throw new UnprocessableEntityException({\n code,\n errors,\n message,\n requestID,\n });\n }\n case 404: {\n throw new NotFoundException({\n code,\n message,\n path,\n requestID,\n });\n }\n case 429: {\n const retryAfter = headers.get('Retry-After');\n\n throw new RateLimitExceededException(\n data.message,\n requestID,\n retryAfter ? Number(retryAfter) : null,\n );\n }\n default: {\n if (error || errorDescription) {\n throw new OauthException(\n status,\n requestID,\n error,\n errorDescription,\n data,\n );\n } else if (code && errors) {\n // Note: ideally this should be mapped directly with a `400` status code.\n // However, this would break existing logic for the `OauthException` exception.\n throw new BadRequestException({\n code,\n errors,\n message,\n requestID,\n });\n } else {\n throw new GenericServerException(\n status,\n data.message,\n data,\n requestID,\n );\n }\n }\n }\n }\n }\n}\n"],"mappings":";;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,SAAS,WAAW;AACpB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AACpB,SAAS,2BAA2B;AAEpC,SAAqB,uBAAuB;AAC5C,SA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OAAO;AACL,kBAAM,IAAI;AAAA,cACR;AAAA,cACA,KAAK;AAAA,cACL;AAAA,cACA;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["error"]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "8.0.0-rc.
|
|
2
|
+
"version": "8.0.0-rc.3",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -41,10 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"iron-session": "^8.0.4",
|
|
44
|
-
"jose": "~6.1.0"
|
|
45
|
-
"leb": "^1.0.0",
|
|
46
|
-
"pluralize": "8.0.0",
|
|
47
|
-
"qs": "6.14.0"
|
|
44
|
+
"jose": "~6.1.0"
|
|
48
45
|
},
|
|
49
46
|
"devDependencies": {
|
|
50
47
|
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
@@ -55,7 +52,6 @@
|
|
|
55
52
|
"@types/glob": "^8.1.0",
|
|
56
53
|
"@types/jest": "^30.0.0",
|
|
57
54
|
"@types/node": "~20",
|
|
58
|
-
"@types/pluralize": "0.0.33",
|
|
59
55
|
"@types/qs": "^6.14.0",
|
|
60
56
|
"@typescript-eslint/parser": "^8.46.0",
|
|
61
57
|
"babel-jest": "^30.2.0",
|
package/lib/cjs/client/utils.cjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var utils_exports = {};
|
|
31
|
-
__export(utils_exports, {
|
|
32
|
-
toQueryString: () => toQueryString
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(utils_exports);
|
|
35
|
-
var import_qs = __toESM(require("qs"), 1);
|
|
36
|
-
const toQueryString = /* @__PURE__ */ __name((options) => {
|
|
37
|
-
return import_qs.default.stringify(options, {
|
|
38
|
-
arrayFormat: "repeat",
|
|
39
|
-
// sorts the keys alphabetically to maintain backwards compatibility
|
|
40
|
-
sort: /* @__PURE__ */ __name((a, b) => a.localeCompare(b), "sort"),
|
|
41
|
-
// encodes space as + instead of %20 to maintain backwards compatibility
|
|
42
|
-
format: "RFC1738"
|
|
43
|
-
});
|
|
44
|
-
}, "toQueryString");
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
toQueryString
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/utils.ts"],"sourcesContent":["import qs from 'qs';\n\n/**\n * Converts an options object to a query string using qs library.\n * Maintains backwards compatibility with existing URL formatting.\n */\nexport const toQueryString = (\n options: Record<\n string,\n string | string[] | Record<string, string | boolean | number> | undefined\n >,\n): string => {\n return qs.stringify(options, {\n arrayFormat: 'repeat',\n // sorts the keys alphabetically to maintain backwards compatibility\n sort: (a, b) => a.localeCompare(b),\n // encodes space as + instead of %20 to maintain backwards compatibility\n format: 'RFC1738',\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AAMR,MAAM,gBAAgB,wBAC3B,YAIW;AACX,SAAO,UAAAA,QAAG,UAAU,SAAS;AAAA,IAC3B,aAAa;AAAA;AAAA,IAEb,MAAM,wBAAC,GAAG,MAAM,EAAE,cAAc,CAAC,GAA3B;AAAA;AAAA,IAEN,QAAQ;AAAA,EACV,CAAC;AACH,GAb6B;","names":["qs"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts an options object to a query string using qs library.
|
|
3
|
-
* Maintains backwards compatibility with existing URL formatting.
|
|
4
|
-
*/
|
|
5
|
-
declare const toQueryString: (options: Record<string, string | string[] | Record<string, string | boolean | number> | undefined>) => string;
|
|
6
|
-
|
|
7
|
-
export { toQueryString };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var delete_options_interface_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(delete_options_interface_exports);
|
|
17
|
-
//# sourceMappingURL=delete-options.interface.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/common/interfaces/delete-options.interface.ts"],"sourcesContent":["export interface DeleteOptions {\n query?: { [key: string]: any };\n signal?: AbortSignal;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
import { GetOptions } from './common/interfaces/get-options.interface.cjs';
|
|
2
|
-
import { PostOptions } from './common/interfaces/post-options.interface.cjs';
|
|
3
|
-
import { PutOptions } from './common/interfaces/put-options.interface.cjs';
|
|
4
|
-
import { WorkOSOptions } from './common/interfaces/workos-options.interface.cjs';
|
|
5
|
-
import { ListEventOptions } from './events/interfaces/list-events-options.interface.cjs';
|
|
6
|
-
import { Event } from './common/interfaces/event.interface.cjs';
|
|
7
|
-
import { List } from './common/interfaces/list.interface.cjs';
|
|
8
|
-
import { AutoPaginatable } from './common/utils/pagination.cjs';
|
|
9
|
-
import { CreateOrganizationOptions, CreateOrganizationRequestOptions } from './organizations/interfaces/create-organization-options.interface.cjs';
|
|
10
|
-
import { ListOrganizationFeatureFlagsOptions } from './organizations/interfaces/list-organization-feature-flags-options.interface.cjs';
|
|
11
|
-
import { ListOrganizationsOptions } from './organizations/interfaces/list-organizations-options.interface.cjs';
|
|
12
|
-
import { Organization } from './organizations/interfaces/organization.interface.cjs';
|
|
13
|
-
import { UpdateOrganizationOptions } from './organizations/interfaces/update-organization-options.interface.cjs';
|
|
14
|
-
import { FeatureFlag } from './feature-flags/interfaces/feature-flag.interface.cjs';
|
|
15
|
-
import { RoleList } from './roles/interfaces/role.interface.cjs';
|
|
16
|
-
import { ListOrganizationRolesOptions } from './organizations/interfaces/list-organization-roles-options.interface.cjs';
|
|
17
|
-
import { CreateOrganizationDomainOptions } from './organization-domains/interfaces/create-organization-domain-options.interface.cjs';
|
|
18
|
-
import { OrganizationDomain } from './organization-domains/interfaces/organization-domain.interface.cjs';
|
|
19
|
-
import { PasswordlessSession } from './passwordless/interfaces/passwordless-session.interface.cjs';
|
|
20
|
-
import { CreatePasswordlessSessionOptions } from './passwordless/interfaces/create-passwordless-session-options.interface.cjs';
|
|
21
|
-
import { SendSessionResponse } from './passwordless/interfaces/send-session-response.interface.cjs';
|
|
22
|
-
import { GeneratePortalLinkIntent } from './portal/interfaces/generate-portal-link-intent.interface.cjs';
|
|
23
|
-
import { UnknownRecord } from './common/interfaces/unknown-record.interface.cjs';
|
|
24
|
-
import { SSOAuthorizationURLOptions } from './sso/interfaces/authorization-url-options.interface.cjs';
|
|
25
|
-
import { Connection } from './sso/interfaces/connection.interface.cjs';
|
|
26
|
-
import { GetProfileOptions } from './sso/interfaces/get-profile-options.interface.cjs';
|
|
27
|
-
import { GetProfileAndTokenOptions } from './sso/interfaces/get-profile-and-token-options.interface.cjs';
|
|
28
|
-
import { ListConnectionsOptions, SerializedListConnectionsOptions } from './sso/interfaces/list-connections-options.interface.cjs';
|
|
29
|
-
import { ProfileAndToken } from './sso/interfaces/profile-and-token.interface.cjs';
|
|
30
|
-
import { Profile } from './sso/interfaces/profile.interface.cjs';
|
|
31
|
-
import { Webhooks } from './webhooks/webhooks.cjs';
|
|
32
|
-
import { ChallengeFactorOptions } from './mfa/interfaces/challenge-factor-options.cjs';
|
|
33
|
-
import { Challenge } from './mfa/interfaces/challenge.interface.cjs';
|
|
34
|
-
import { EnrollFactorOptions } from './mfa/interfaces/enroll-factor-options.cjs';
|
|
35
|
-
import { Factor, FactorWithSecrets } from './mfa/interfaces/factor.interface.cjs';
|
|
36
|
-
import { VerifyChallengeOptions } from './mfa/interfaces/verify-challenge-options.cjs';
|
|
37
|
-
import { VerifyResponse } from './mfa/interfaces/verify-challenge-response.cjs';
|
|
38
|
-
import { AuditLogExportOptions } from './audit-logs/interfaces/audit-log-export-options.interface.cjs';
|
|
39
|
-
import { AuditLogExport } from './audit-logs/interfaces/audit-log-export.interface.cjs';
|
|
40
|
-
import { CreateAuditLogEventOptions, CreateAuditLogEventRequestOptions } from './audit-logs/interfaces/create-audit-log-event-options.interface.cjs';
|
|
41
|
-
import { CreateAuditLogSchemaOptions, CreateAuditLogSchemaRequestOptions, AuditLogSchema } from './audit-logs/interfaces/create-audit-log-schema-options.interface.cjs';
|
|
42
|
-
import { createRemoteJWKSet } from 'jose';
|
|
43
|
-
import { L as LogoutURLOptions } from './user-management-qKHMGyQi.cjs';
|
|
44
|
-
import { PaginationOptions } from './common/interfaces/pagination-options.interface.cjs';
|
|
45
|
-
import { AuthenticateWithCodeOptions } from './user-management/interfaces/authenticate-with-code-options.interface.cjs';
|
|
46
|
-
import { AuthenticateWithCodeAndVerifierOptions } from './user-management/interfaces/authenticate-with-code-and-verifier-options.interface.cjs';
|
|
47
|
-
import { AuthenticateWithEmailVerificationOptions } from './user-management/interfaces/authenticate-with-email-verification-options.interface.cjs';
|
|
48
|
-
import { AuthenticateWithMagicAuthOptions } from './user-management/interfaces/authenticate-with-magic-auth-options.interface.cjs';
|
|
49
|
-
import { AuthenticateWithOrganizationSelectionOptions } from './user-management/interfaces/authenticate-with-organization-selection.interface.cjs';
|
|
50
|
-
import { AuthenticateWithPasswordOptions } from './user-management/interfaces/authenticate-with-password-options.interface.cjs';
|
|
51
|
-
import { AuthenticateWithRefreshTokenOptions } from './user-management/interfaces/authenticate-with-refresh-token-options.interface.cjs';
|
|
52
|
-
import { AuthenticateWithSessionCookieSuccessResponse, AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieOptions, SessionCookieData } from './user-management/interfaces/authenticate-with-session-cookie.interface.cjs';
|
|
53
|
-
import { AuthenticateWithTotpOptions } from './user-management/interfaces/authenticate-with-totp-options.interface.cjs';
|
|
54
|
-
import { AuthenticationResponse } from './user-management/interfaces/authentication-response.interface.cjs';
|
|
55
|
-
import { UserManagementAuthorizationURLOptions } from './user-management/interfaces/authorization-url-options.interface.cjs';
|
|
56
|
-
import { CreateMagicAuthOptions } from './user-management/interfaces/create-magic-auth-options.interface.cjs';
|
|
57
|
-
import { CreateOrganizationMembershipOptions } from './user-management/interfaces/create-organization-membership-options.interface.cjs';
|
|
58
|
-
import { CreatePasswordResetOptions } from './user-management/interfaces/create-password-reset-options.interface.cjs';
|
|
59
|
-
import { CreateUserOptions } from './user-management/interfaces/create-user-options.interface.cjs';
|
|
60
|
-
import { EmailVerification } from './user-management/interfaces/email-verification.interface.cjs';
|
|
61
|
-
import { EnrollAuthFactorOptions } from './user-management/interfaces/enroll-auth-factor.interface.cjs';
|
|
62
|
-
import { FactorWithSecrets as FactorWithSecrets$1, Factor as Factor$1 } from './user-management/interfaces/factor.interface.cjs';
|
|
63
|
-
import { Identity } from './user-management/interfaces/identity.interface.cjs';
|
|
64
|
-
import { Invitation } from './user-management/interfaces/invitation.interface.cjs';
|
|
65
|
-
import { ListAuthFactorsOptions } from './user-management/interfaces/list-auth-factors-options.interface.cjs';
|
|
66
|
-
import { ListInvitationsOptions, SerializedListInvitationsOptions } from './user-management/interfaces/list-invitations-options.interface.cjs';
|
|
67
|
-
import { ListOrganizationMembershipsOptions, SerializedListOrganizationMembershipsOptions } from './user-management/interfaces/list-organization-memberships-options.interface.cjs';
|
|
68
|
-
import { ListSessionsOptions, SerializedListSessionsOptions } from './user-management/interfaces/list-sessions-options.interface.cjs';
|
|
69
|
-
import { ListUserFeatureFlagsOptions } from './user-management/interfaces/list-user-feature-flags-options.interface.cjs';
|
|
70
|
-
import { ListUsersOptions, SerializedListUsersOptions } from './user-management/interfaces/list-users-options.interface.cjs';
|
|
71
|
-
import { MagicAuth } from './user-management/interfaces/magic-auth.interface.cjs';
|
|
72
|
-
import { OrganizationMembership } from './user-management/interfaces/organization-membership.interface.cjs';
|
|
73
|
-
import { PasswordReset } from './user-management/interfaces/password-reset.interface.cjs';
|
|
74
|
-
import { ResetPasswordOptions } from './user-management/interfaces/reset-password-options.interface.cjs';
|
|
75
|
-
import { RevokeSessionOptions } from './user-management/interfaces/revoke-session-options.interface.cjs';
|
|
76
|
-
import { SendInvitationOptions } from './user-management/interfaces/send-invitation-options.interface.cjs';
|
|
77
|
-
import { SendVerificationEmailOptions } from './user-management/interfaces/send-verification-email-options.interface.cjs';
|
|
78
|
-
import { Session } from './user-management/interfaces/session.interface.cjs';
|
|
79
|
-
import { UpdateOrganizationMembershipOptions } from './user-management/interfaces/update-organization-membership-options.interface.cjs';
|
|
80
|
-
import { UpdateUserOptions } from './user-management/interfaces/update-user-options.interface.cjs';
|
|
81
|
-
import { User } from './user-management/interfaces/user.interface.cjs';
|
|
82
|
-
import { VerifyEmailOptions } from './user-management/interfaces/verify-email-options.interface.cjs';
|
|
83
|
-
import { SessionHandlerOptions } from './user-management/interfaces/session-handler-options.interface.cjs';
|
|
84
|
-
import { RefreshSessionResponse } from './user-management/interfaces/refresh-and-seal-session-data.interface.cjs';
|
|
85
|
-
import { CheckOptions, CheckRequestOptions, CheckResult, CheckBatchOptions } from './fga/interfaces/check.interface.cjs';
|
|
86
|
-
import { QueryOptions, QueryRequestOptions, QueryResult, SerializedQueryOptions } from './fga/interfaces/query.interface.cjs';
|
|
87
|
-
import { CreateResourceOptions, Resource, ResourceInterface, ResourceOptions, ListResourcesOptions, SerializedListResourcesOptions, UpdateResourceOptions, DeleteResourceOptions, BatchWriteResourcesOptions } from './fga/interfaces/resource.interface.cjs';
|
|
88
|
-
import { WarrantToken } from './fga/interfaces/warrant-token.interface.cjs';
|
|
89
|
-
import { WriteWarrantOptions, ListWarrantsOptions, ListWarrantsRequestOptions, Warrant, SerializedListWarrantsOptions } from './fga/interfaces/warrant.interface.cjs';
|
|
90
|
-
import { FgaPaginatable } from './fga/utils/fga-paginatable.cjs';
|
|
91
|
-
import { HttpClient } from './common/net/http-client.cjs';
|
|
92
|
-
import { GetTokenOptions } from './widgets/interfaces/get-token.cjs';
|
|
93
|
-
import { Actions } from './actions/actions.cjs';
|
|
94
|
-
import { CreateDataKeyOptions } from './vault/interfaces/key/create-data-key.interface.cjs';
|
|
95
|
-
import { DecryptDataKeyOptions } from './vault/interfaces/key/decrypt-data-key.interface.cjs';
|
|
96
|
-
import { DataKeyPair, DataKey, KeyContext } from './vault/interfaces/key.interface.cjs';
|
|
97
|
-
import { CreateObjectOptions } from './vault/interfaces/object/create-object.interface.cjs';
|
|
98
|
-
import { DeleteObjectOptions } from './vault/interfaces/object/delete-object.interface.cjs';
|
|
99
|
-
import { ReadObjectOptions } from './vault/interfaces/object/read-object.interface.cjs';
|
|
100
|
-
import { UpdateObjectOptions } from './vault/interfaces/object/update-object.interface.cjs';
|
|
101
|
-
import { ObjectMetadata, ObjectDigest, ObjectVersion, VaultObject } from './vault/interfaces/object.interface.cjs';
|
|
102
|
-
import { CryptoProvider } from './common/crypto/crypto-provider.cjs';
|
|
103
|
-
import { Directory } from './directory-sync/interfaces/directory.interface.cjs';
|
|
104
|
-
import { DirectoryGroup } from './directory-sync/interfaces/directory-group.interface.cjs';
|
|
105
|
-
import { ListDirectoriesOptions, SerializedListDirectoriesOptions } from './directory-sync/interfaces/list-directories-options.interface.cjs';
|
|
106
|
-
import { ListDirectoryGroupsOptions } from './directory-sync/interfaces/list-groups-options.interface.cjs';
|
|
107
|
-
import { ListDirectoryUsersOptions } from './directory-sync/interfaces/list-directory-users-options.interface.cjs';
|
|
108
|
-
import { DefaultCustomAttributes, DirectoryUserWithGroups } from './directory-sync/interfaces/directory-user.interface.cjs';
|
|
109
|
-
|
|
110
|
-
declare class DirectorySync {
|
|
111
|
-
private readonly workos;
|
|
112
|
-
constructor(workos: WorkOS);
|
|
113
|
-
listDirectories(options?: ListDirectoriesOptions): Promise<AutoPaginatable<Directory, SerializedListDirectoriesOptions>>;
|
|
114
|
-
getDirectory(id: string): Promise<Directory>;
|
|
115
|
-
deleteDirectory(id: string): Promise<void>;
|
|
116
|
-
listGroups(options: ListDirectoryGroupsOptions): Promise<AutoPaginatable<DirectoryGroup, ListDirectoryGroupsOptions>>;
|
|
117
|
-
listUsers<TCustomAttributes extends object = DefaultCustomAttributes>(options: ListDirectoryUsersOptions): Promise<AutoPaginatable<DirectoryUserWithGroups<TCustomAttributes>, ListDirectoryUsersOptions>>;
|
|
118
|
-
getUser<TCustomAttributes extends object = DefaultCustomAttributes>(user: string): Promise<DirectoryUserWithGroups<TCustomAttributes>>;
|
|
119
|
-
getGroup(group: string): Promise<DirectoryGroup>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
declare class Events {
|
|
123
|
-
private readonly workos;
|
|
124
|
-
constructor(workos: WorkOS);
|
|
125
|
-
listEvents(options: ListEventOptions): Promise<List<Event>>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
declare class Organizations {
|
|
129
|
-
private readonly workos;
|
|
130
|
-
constructor(workos: WorkOS);
|
|
131
|
-
listOrganizations(options?: ListOrganizationsOptions): Promise<AutoPaginatable<Organization, ListOrganizationsOptions>>;
|
|
132
|
-
createOrganization(payload: CreateOrganizationOptions, requestOptions?: CreateOrganizationRequestOptions): Promise<Organization>;
|
|
133
|
-
deleteOrganization(id: string): Promise<void>;
|
|
134
|
-
getOrganization(id: string): Promise<Organization>;
|
|
135
|
-
getOrganizationByExternalId(externalId: string): Promise<Organization>;
|
|
136
|
-
updateOrganization(options: UpdateOrganizationOptions): Promise<Organization>;
|
|
137
|
-
listOrganizationRoles(options: ListOrganizationRolesOptions): Promise<RoleList>;
|
|
138
|
-
listOrganizationFeatureFlags(options: ListOrganizationFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag, ListOrganizationFeatureFlagsOptions>>;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
declare class OrganizationDomains {
|
|
142
|
-
private readonly workos;
|
|
143
|
-
constructor(workos: WorkOS);
|
|
144
|
-
get(id: string): Promise<OrganizationDomain>;
|
|
145
|
-
verify(id: string): Promise<OrganizationDomain>;
|
|
146
|
-
create(payload: CreateOrganizationDomainOptions): Promise<OrganizationDomain>;
|
|
147
|
-
delete(id: string): Promise<void>;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
declare class Passwordless {
|
|
151
|
-
private readonly workos;
|
|
152
|
-
constructor(workos: WorkOS);
|
|
153
|
-
createSession({ redirectURI, expiresIn, ...options }: CreatePasswordlessSessionOptions): Promise<PasswordlessSession>;
|
|
154
|
-
sendSession(sessionId: string): Promise<SendSessionResponse>;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
declare class Portal {
|
|
158
|
-
private readonly workos;
|
|
159
|
-
constructor(workos: WorkOS);
|
|
160
|
-
generateLink({ intent, organization, returnUrl, successUrl, }: {
|
|
161
|
-
intent: GeneratePortalLinkIntent;
|
|
162
|
-
organization: string;
|
|
163
|
-
returnUrl?: string;
|
|
164
|
-
successUrl?: string;
|
|
165
|
-
}): Promise<{
|
|
166
|
-
link: string;
|
|
167
|
-
}>;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
declare class SSO {
|
|
171
|
-
private readonly workos;
|
|
172
|
-
constructor(workos: WorkOS);
|
|
173
|
-
listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection, SerializedListConnectionsOptions>>;
|
|
174
|
-
deleteConnection(id: string): Promise<void>;
|
|
175
|
-
getAuthorizationUrl(options: SSOAuthorizationURLOptions): string;
|
|
176
|
-
getConnection(id: string): Promise<Connection>;
|
|
177
|
-
getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
|
|
178
|
-
getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare class Mfa {
|
|
182
|
-
private readonly workos;
|
|
183
|
-
constructor(workos: WorkOS);
|
|
184
|
-
deleteFactor(id: string): Promise<void>;
|
|
185
|
-
getFactor(id: string): Promise<Factor>;
|
|
186
|
-
enrollFactor(options: EnrollFactorOptions): Promise<FactorWithSecrets>;
|
|
187
|
-
challengeFactor(options: ChallengeFactorOptions): Promise<Challenge>;
|
|
188
|
-
verifyChallenge(options: VerifyChallengeOptions): Promise<VerifyResponse>;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
declare class AuditLogs {
|
|
192
|
-
private readonly workos;
|
|
193
|
-
constructor(workos: WorkOS);
|
|
194
|
-
createEvent(organization: string, event: CreateAuditLogEventOptions, options?: CreateAuditLogEventRequestOptions): Promise<void>;
|
|
195
|
-
createExport(options: AuditLogExportOptions): Promise<AuditLogExport>;
|
|
196
|
-
getExport(auditLogExportId: string): Promise<AuditLogExport>;
|
|
197
|
-
createSchema(schema: CreateAuditLogSchemaOptions, options?: CreateAuditLogSchemaRequestOptions): Promise<AuditLogSchema>;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
type RefreshOptions = {
|
|
201
|
-
cookiePassword?: string;
|
|
202
|
-
organizationId?: string;
|
|
203
|
-
};
|
|
204
|
-
declare class CookieSession {
|
|
205
|
-
private jwks;
|
|
206
|
-
private userManagement;
|
|
207
|
-
private cookiePassword;
|
|
208
|
-
private sessionData;
|
|
209
|
-
constructor(userManagement: UserManagement, sessionData: string, cookiePassword: string);
|
|
210
|
-
/**
|
|
211
|
-
* Authenticates a user with a session cookie.
|
|
212
|
-
*
|
|
213
|
-
* @returns An object indicating whether the authentication was successful or not. If successful, it will include the user's session data.
|
|
214
|
-
*/
|
|
215
|
-
authenticate(): Promise<AuthenticateWithSessionCookieSuccessResponse | AuthenticateWithSessionCookieFailedResponse>;
|
|
216
|
-
/**
|
|
217
|
-
* Refreshes the user's session.
|
|
218
|
-
*
|
|
219
|
-
* @param options - Optional options for refreshing the session.
|
|
220
|
-
* @param options.cookiePassword - The password to use for the new session cookie.
|
|
221
|
-
* @param options.organizationId - The organization ID to use for the new session cookie.
|
|
222
|
-
* @returns An object indicating whether the refresh was successful or not. If successful, it will include the new sealed session data.
|
|
223
|
-
*/
|
|
224
|
-
refresh(options?: RefreshOptions): Promise<RefreshSessionResponse>;
|
|
225
|
-
/**
|
|
226
|
-
* Gets the URL to redirect the user to for logging out.
|
|
227
|
-
*
|
|
228
|
-
* @returns The URL to redirect the user to for logging out.
|
|
229
|
-
*/
|
|
230
|
-
getLogoutUrl({ returnTo, }?: {
|
|
231
|
-
returnTo?: string;
|
|
232
|
-
}): Promise<string>;
|
|
233
|
-
private isValidJwt;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
declare class UserManagement {
|
|
237
|
-
private readonly workos;
|
|
238
|
-
private _jwks;
|
|
239
|
-
clientId: string | undefined;
|
|
240
|
-
constructor(workos: WorkOS);
|
|
241
|
-
get jwks(): ReturnType<typeof createRemoteJWKSet> | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Loads a sealed session using the provided session data and cookie password.
|
|
244
|
-
*
|
|
245
|
-
* @param options - The options for loading the sealed session.
|
|
246
|
-
* @param options.sessionData - The sealed session data.
|
|
247
|
-
* @param options.cookiePassword - The password used to encrypt the session data.
|
|
248
|
-
* @returns The session class.
|
|
249
|
-
*/
|
|
250
|
-
loadSealedSession(options: {
|
|
251
|
-
sessionData: string;
|
|
252
|
-
cookiePassword: string;
|
|
253
|
-
}): CookieSession;
|
|
254
|
-
getUser(userId: string): Promise<User>;
|
|
255
|
-
getUserByExternalId(externalId: string): Promise<User>;
|
|
256
|
-
listUsers(options?: ListUsersOptions): Promise<AutoPaginatable<User, SerializedListUsersOptions>>;
|
|
257
|
-
createUser(payload: CreateUserOptions): Promise<User>;
|
|
258
|
-
authenticateWithMagicAuth(payload: AuthenticateWithMagicAuthOptions): Promise<AuthenticationResponse>;
|
|
259
|
-
authenticateWithPassword(payload: AuthenticateWithPasswordOptions): Promise<AuthenticationResponse>;
|
|
260
|
-
authenticateWithCode(payload: AuthenticateWithCodeOptions): Promise<AuthenticationResponse>;
|
|
261
|
-
authenticateWithCodeAndVerifier(payload: AuthenticateWithCodeAndVerifierOptions): Promise<AuthenticationResponse>;
|
|
262
|
-
authenticateWithRefreshToken(payload: AuthenticateWithRefreshTokenOptions): Promise<AuthenticationResponse>;
|
|
263
|
-
authenticateWithTotp(payload: AuthenticateWithTotpOptions): Promise<AuthenticationResponse>;
|
|
264
|
-
authenticateWithEmailVerification(payload: AuthenticateWithEmailVerificationOptions): Promise<AuthenticationResponse>;
|
|
265
|
-
authenticateWithOrganizationSelection(payload: AuthenticateWithOrganizationSelectionOptions): Promise<AuthenticationResponse>;
|
|
266
|
-
authenticateWithSessionCookie({ sessionData, cookiePassword, }: AuthenticateWithSessionCookieOptions): Promise<AuthenticateWithSessionCookieSuccessResponse | AuthenticateWithSessionCookieFailedResponse>;
|
|
267
|
-
private isValidJwt;
|
|
268
|
-
private prepareAuthenticationResponse;
|
|
269
|
-
private sealSessionDataFromAuthenticationResponse;
|
|
270
|
-
getSessionFromCookie({ sessionData, cookiePassword, }: SessionHandlerOptions): Promise<SessionCookieData | undefined>;
|
|
271
|
-
getEmailVerification(emailVerificationId: string): Promise<EmailVerification>;
|
|
272
|
-
sendVerificationEmail({ userId, }: SendVerificationEmailOptions): Promise<{
|
|
273
|
-
user: User;
|
|
274
|
-
}>;
|
|
275
|
-
getMagicAuth(magicAuthId: string): Promise<MagicAuth>;
|
|
276
|
-
createMagicAuth(options: CreateMagicAuthOptions): Promise<MagicAuth>;
|
|
277
|
-
verifyEmail({ code, userId, }: VerifyEmailOptions): Promise<{
|
|
278
|
-
user: User;
|
|
279
|
-
}>;
|
|
280
|
-
getPasswordReset(passwordResetId: string): Promise<PasswordReset>;
|
|
281
|
-
createPasswordReset(options: CreatePasswordResetOptions): Promise<PasswordReset>;
|
|
282
|
-
resetPassword(payload: ResetPasswordOptions): Promise<{
|
|
283
|
-
user: User;
|
|
284
|
-
}>;
|
|
285
|
-
updateUser(payload: UpdateUserOptions): Promise<User>;
|
|
286
|
-
enrollAuthFactor(payload: EnrollAuthFactorOptions): Promise<{
|
|
287
|
-
authenticationFactor: FactorWithSecrets$1;
|
|
288
|
-
authenticationChallenge: Challenge;
|
|
289
|
-
}>;
|
|
290
|
-
listAuthFactors(options: ListAuthFactorsOptions): Promise<AutoPaginatable<Factor$1, PaginationOptions>>;
|
|
291
|
-
listUserFeatureFlags(options: ListUserFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
292
|
-
listSessions(userId: string, options?: ListSessionsOptions): Promise<AutoPaginatable<Session, SerializedListSessionsOptions>>;
|
|
293
|
-
deleteUser(userId: string): Promise<void>;
|
|
294
|
-
getUserIdentities(userId: string): Promise<Identity[]>;
|
|
295
|
-
getOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
|
|
296
|
-
listOrganizationMemberships(options: ListOrganizationMembershipsOptions): Promise<AutoPaginatable<OrganizationMembership, SerializedListOrganizationMembershipsOptions>>;
|
|
297
|
-
createOrganizationMembership(options: CreateOrganizationMembershipOptions): Promise<OrganizationMembership>;
|
|
298
|
-
updateOrganizationMembership(organizationMembershipId: string, options: UpdateOrganizationMembershipOptions): Promise<OrganizationMembership>;
|
|
299
|
-
deleteOrganizationMembership(organizationMembershipId: string): Promise<void>;
|
|
300
|
-
deactivateOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
|
|
301
|
-
reactivateOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
|
|
302
|
-
getInvitation(invitationId: string): Promise<Invitation>;
|
|
303
|
-
findInvitationByToken(invitationToken: string): Promise<Invitation>;
|
|
304
|
-
listInvitations(options: ListInvitationsOptions): Promise<AutoPaginatable<Invitation, SerializedListInvitationsOptions>>;
|
|
305
|
-
sendInvitation(payload: SendInvitationOptions): Promise<Invitation>;
|
|
306
|
-
acceptInvitation(invitationId: string): Promise<Invitation>;
|
|
307
|
-
revokeInvitation(invitationId: string): Promise<Invitation>;
|
|
308
|
-
revokeSession(payload: RevokeSessionOptions): Promise<void>;
|
|
309
|
-
getAuthorizationUrl(options: UserManagementAuthorizationURLOptions): string;
|
|
310
|
-
getLogoutUrl(options: LogoutURLOptions): string;
|
|
311
|
-
getJwksUrl(clientId: string): string;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
declare class FGA {
|
|
315
|
-
private readonly workos;
|
|
316
|
-
constructor(workos: WorkOS);
|
|
317
|
-
check(checkOptions: CheckOptions, options?: CheckRequestOptions): Promise<CheckResult>;
|
|
318
|
-
checkBatch(checkOptions: CheckBatchOptions, options?: CheckRequestOptions): Promise<CheckResult[]>;
|
|
319
|
-
createResource(resource: CreateResourceOptions): Promise<Resource>;
|
|
320
|
-
getResource(resource: ResourceInterface | ResourceOptions): Promise<Resource>;
|
|
321
|
-
listResources(options?: ListResourcesOptions): Promise<AutoPaginatable<Resource, SerializedListResourcesOptions>>;
|
|
322
|
-
updateResource(options: UpdateResourceOptions): Promise<Resource>;
|
|
323
|
-
deleteResource(resource: DeleteResourceOptions): Promise<void>;
|
|
324
|
-
batchWriteResources(options: BatchWriteResourcesOptions): Promise<Resource[]>;
|
|
325
|
-
writeWarrant(options: WriteWarrantOptions): Promise<WarrantToken>;
|
|
326
|
-
batchWriteWarrants(options: WriteWarrantOptions[]): Promise<WarrantToken>;
|
|
327
|
-
listWarrants(options?: ListWarrantsOptions, requestOptions?: ListWarrantsRequestOptions): Promise<AutoPaginatable<Warrant, SerializedListWarrantsOptions>>;
|
|
328
|
-
query(options: QueryOptions, requestOptions?: QueryRequestOptions): Promise<FgaPaginatable<QueryResult, SerializedQueryOptions>>;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
declare class Widgets {
|
|
332
|
-
private readonly workos;
|
|
333
|
-
constructor(workos: WorkOS);
|
|
334
|
-
getToken(payload: GetTokenOptions): Promise<string>;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
declare class Vault {
|
|
338
|
-
private readonly workos;
|
|
339
|
-
private cryptoProvider;
|
|
340
|
-
constructor(workos: WorkOS);
|
|
341
|
-
private decode;
|
|
342
|
-
createObject(options: CreateObjectOptions): Promise<ObjectMetadata>;
|
|
343
|
-
listObjects(options?: PaginationOptions | undefined): Promise<List<ObjectDigest>>;
|
|
344
|
-
listObjectVersions(options: ReadObjectOptions): Promise<ObjectVersion[]>;
|
|
345
|
-
readObject(options: ReadObjectOptions): Promise<VaultObject>;
|
|
346
|
-
describeObject(options: ReadObjectOptions): Promise<VaultObject>;
|
|
347
|
-
updateObject(options: UpdateObjectOptions): Promise<VaultObject>;
|
|
348
|
-
deleteObject(options: DeleteObjectOptions): Promise<void>;
|
|
349
|
-
createDataKey(options: CreateDataKeyOptions): Promise<DataKeyPair>;
|
|
350
|
-
decryptDataKey(options: DecryptDataKeyOptions): Promise<DataKey>;
|
|
351
|
-
encrypt(data: string, context: KeyContext, associatedData?: string): Promise<string>;
|
|
352
|
-
decrypt(encryptedData: string, associatedData?: string): Promise<string>;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
declare class WorkOS {
|
|
356
|
-
readonly key?: string | undefined;
|
|
357
|
-
readonly options: WorkOSOptions;
|
|
358
|
-
readonly baseURL: string;
|
|
359
|
-
readonly client: HttpClient;
|
|
360
|
-
readonly clientId?: string;
|
|
361
|
-
readonly actions: Actions;
|
|
362
|
-
readonly auditLogs: AuditLogs;
|
|
363
|
-
readonly directorySync: DirectorySync;
|
|
364
|
-
readonly organizations: Organizations;
|
|
365
|
-
readonly organizationDomains: OrganizationDomains;
|
|
366
|
-
readonly passwordless: Passwordless;
|
|
367
|
-
readonly portal: Portal;
|
|
368
|
-
readonly sso: SSO;
|
|
369
|
-
readonly webhooks: Webhooks;
|
|
370
|
-
readonly mfa: Mfa;
|
|
371
|
-
readonly events: Events;
|
|
372
|
-
readonly userManagement: UserManagement;
|
|
373
|
-
readonly fga: FGA;
|
|
374
|
-
readonly widgets: Widgets;
|
|
375
|
-
readonly vault: Vault;
|
|
376
|
-
constructor(key?: string | undefined, options?: WorkOSOptions);
|
|
377
|
-
private createUserAgent;
|
|
378
|
-
createWebhookClient(): Webhooks;
|
|
379
|
-
createActionsClient(): Actions;
|
|
380
|
-
getCryptoProvider(): CryptoProvider;
|
|
381
|
-
createHttpClient(options: WorkOSOptions, userAgent: string): HttpClient;
|
|
382
|
-
get version(): string;
|
|
383
|
-
post<Result = any, Entity = any>(path: string, entity: Entity, options?: PostOptions): Promise<{
|
|
384
|
-
data: Result;
|
|
385
|
-
}>;
|
|
386
|
-
get<Result = any>(path: string, options?: GetOptions): Promise<{
|
|
387
|
-
data: Result;
|
|
388
|
-
}>;
|
|
389
|
-
put<Result = any, Entity = any>(path: string, entity: Entity, options?: PutOptions): Promise<{
|
|
390
|
-
data: Result;
|
|
391
|
-
}>;
|
|
392
|
-
delete(path: string, query?: any): Promise<void>;
|
|
393
|
-
emitWarning(warning: string): void;
|
|
394
|
-
private handleParseError;
|
|
395
|
-
private handleHttpError;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export { AuditLogs as A, CookieSession as C, DirectorySync as D, Events as E, FGA as F, Mfa as M, Organizations as O, Passwordless as P, SSO as S, UserManagement as U, Vault as V, WorkOS as W, OrganizationDomains as a, Portal as b, Widgets as c };
|