@workos-inc/node 12.0.0 → 12.2.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.
@@ -1340,18 +1340,17 @@ var AutoPaginatable = class {
1340
1340
  get listMetadata() {
1341
1341
  return this.list.listMetadata;
1342
1342
  }
1343
- async *generatePages(params) {
1343
+ async *generatePages(after) {
1344
1344
  const { before, ...options } = this.options;
1345
1345
  const result = await this.apiCall({
1346
1346
  ...options,
1347
1347
  limit: 100,
1348
- ...params.before ? { before } : {},
1349
- after: params.after
1348
+ after
1350
1349
  });
1351
1350
  yield result.data;
1352
1351
  if (result.listMetadata.after) {
1353
1352
  await new Promise((resolve) => setTimeout(resolve, 350));
1354
- yield* this.generatePages({ after: result.listMetadata.after });
1353
+ yield* this.generatePages(result.listMetadata.after);
1355
1354
  }
1356
1355
  }
1357
1356
  /**
@@ -1359,12 +1358,9 @@ var AutoPaginatable = class {
1359
1358
  * Returns the first result if `options.limit` is passed to the first request.
1360
1359
  */
1361
1360
  async autoPagination() {
1362
- if (this.options.limit) return this.data;
1363
- const results = [];
1364
- for await (const page of this.generatePages({
1365
- before: this.options.before,
1366
- after: this.options.after
1367
- })) results.push(...page);
1361
+ if (this.options.limit || !this.listMetadata.after) return this.data;
1362
+ const results = [...this.data];
1363
+ for await (const page of this.generatePages(this.listMetadata.after)) results.push(...page);
1368
1364
  return results;
1369
1365
  }
1370
1366
  };
@@ -2021,12 +2017,19 @@ const deserializeResourceExportEvent = (data) => ({
2021
2017
  const deserializePipesConnectedAccount = (connectedAccount) => ({
2022
2018
  object: connectedAccount.object,
2023
2019
  id: connectedAccount.id,
2020
+ ...connectedAccount.connection_role !== void 0 && { connectionRole: connectedAccount.connection_role },
2021
+ ...connectedAccount.account_identifier !== void 0 && { accountIdentifier: connectedAccount.account_identifier },
2022
+ ...connectedAccount.account_display_name !== void 0 && { accountDisplayName: connectedAccount.account_display_name },
2024
2023
  dataIntegrationId: connectedAccount.data_integration_id,
2025
2024
  providerSlug: connectedAccount.provider_slug,
2026
2025
  userId: connectedAccount.user_id,
2027
2026
  organizationId: connectedAccount.organization_id,
2028
2027
  scopes: connectedAccount.scopes,
2028
+ ...connectedAccount.auth_method !== void 0 && { authMethod: connectedAccount.auth_method },
2029
+ ...connectedAccount.api_key_last_4 !== void 0 && { apiKeyLast4: connectedAccount.api_key_last_4 },
2029
2030
  state: connectedAccount.state,
2031
+ ...connectedAccount.established_by_user_id !== void 0 && { establishedByUserId: connectedAccount.established_by_user_id },
2032
+ ...connectedAccount.state_reason !== void 0 && { stateReason: connectedAccount.state_reason },
2030
2033
  createdAt: new Date(connectedAccount.created_at),
2031
2034
  updatedAt: new Date(connectedAccount.updated_at)
2032
2035
  });
@@ -3253,6 +3256,15 @@ var ApiKeys = class {
3253
3256
  //#region src/connect/serializers/external-auth-complete-response.serializer.ts
3254
3257
  const deserializeExternalAuthCompleteResponse = (response) => ({ redirectUri: response.redirect_uri });
3255
3258
  //#endregion
3259
+ //#region src/connect/serializers/token-exchange-response.serializer.ts
3260
+ const deserializeTokenExchangeResponse = (response) => ({
3261
+ accessToken: response.access_token,
3262
+ issuedTokenType: response.issued_token_type,
3263
+ tokenType: response.token_type,
3264
+ expiresIn: response.expires_in,
3265
+ ...response.scope !== void 0 && { scope: response.scope }
3266
+ });
3267
+ //#endregion
3256
3268
  //#region src/connect/serializers/connect-application-redirect-uri.serializer.ts
3257
3269
  const deserializeConnectApplicationRedirectUri = (response) => ({
3258
3270
  uri: response.uri,
@@ -3428,6 +3440,73 @@ var Connect = class {
3428
3440
  return deserializeExternalAuthCompleteResponse(data);
3429
3441
  }
3430
3442
  /**
3443
+ * Exchange an access token for one issued to another Resource Indicator
3444
+ *
3445
+ * Performs an [RFC 8693](https://datatracker.ietf.org/doc/html/rfc8693) token exchange against the environment's
3446
+ * `/oauth2/token` endpoint, authenticating as a first-party Connect Application with its client ID and client
3447
+ * secret. The issued access token keeps the subject token's user and consent and is audienced to `resource`.
3448
+ *
3449
+ * Unlike other SDK methods this does not call the WorkOS API with your API key: the request goes to the
3450
+ * environment's issuer (AuthKit domain) using the Connect Application's credentials. The client's `fetchFn`,
3451
+ * `timeout`, `maxRetries` and `config` options still apply.
3452
+ * @param options - Object containing issuer, clientId, clientSecret, subjectToken, resource, scope.
3453
+ * @returns {Promise<TokenExchangeResponse>}
3454
+ * @throws {OauthException} `invalid_client`, `unauthorized_client`, `invalid_grant`, `invalid_target`,
3455
+ * `invalid_scope`, `unsupported_grant_type`
3456
+ */
3457
+ async exchangeToken(options) {
3458
+ const { issuer, clientId, clientSecret, subjectToken, resource, scope } = options;
3459
+ const path = "/oauth2/token";
3460
+ const client = this.createIssuerHttpClient(issuer);
3461
+ const body = new URLSearchParams({
3462
+ client_id: clientId,
3463
+ client_secret: clientSecret,
3464
+ grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
3465
+ subject_token: subjectToken,
3466
+ subject_token_type: "urn:ietf:params:oauth:token-type:access_token",
3467
+ requested_token_type: "urn:ietf:params:oauth:token-type:access_token",
3468
+ resource,
3469
+ ...scope !== void 0 && { scope }
3470
+ });
3471
+ let res;
3472
+ try {
3473
+ res = await client.post(path, body, {});
3474
+ } catch (error) {
3475
+ this.throwOauthErrorFromTokenEndpoint(error);
3476
+ this.workos.handleHttpError({
3477
+ path,
3478
+ error
3479
+ });
3480
+ throw error;
3481
+ }
3482
+ const data = await this.workos.readResponseJSON(path, res);
3483
+ return deserializeTokenExchangeResponse(data);
3484
+ }
3485
+ /**
3486
+ * Builds an HTTP client for the environment's issuer that carries the SDK's
3487
+ * transport settings (`fetchFn`, `timeout`, `maxRetries`, `config`) but not
3488
+ * the WorkOS API key.
3489
+ */
3490
+ createIssuerHttpClient(issuer) {
3491
+ const { config, timeout, maxRetries, fetchFn } = this.workos.options;
3492
+ return new FetchHttpClient(issuer, {
3493
+ ...config,
3494
+ timeout,
3495
+ maxRetries,
3496
+ headers: { "User-Agent": `workos-node/${this.workos.version}` }
3497
+ }, fetchFn);
3498
+ }
3499
+ /**
3500
+ * The token endpoint reports client authentication failures as a 401 with
3501
+ * an RFC 6749 error body; surface that as an `OauthException` instead of the
3502
+ * generic `UnauthorizedException` used for API-key failures.
3503
+ */
3504
+ throwOauthErrorFromTokenEndpoint(error) {
3505
+ if (!(error instanceof HttpClientError) || !error.response) return;
3506
+ const { status, data, headers } = error.response;
3507
+ if (status === 401 && (data.error || data.error_description)) throw new OauthException(status, headers.get("X-Request-ID") ?? "", data.error, data.error_description, data);
3508
+ }
3509
+ /**
3431
3510
  * List Connect Applications
3432
3511
  *
3433
3512
  * List all Connect Applications in the current environment with optional filtering.
@@ -3730,8 +3809,7 @@ const serializeListEventOptions = (options) => ({
3730
3809
  range_start: options.rangeStart,
3731
3810
  range_end: options.rangeEnd,
3732
3811
  limit: options.limit,
3733
- after: options.after,
3734
- order: options.order
3812
+ after: options.after
3735
3813
  });
3736
3814
  //#endregion
3737
3815
  //#region src/events/events.ts
@@ -4127,6 +4205,12 @@ const deserializeDataIntegration = (response) => ({
4127
4205
  updatedAt: new Date(response.updated_at)
4128
4206
  });
4129
4207
  //#endregion
4208
+ //#region src/pipes/serializers/connected-account-warning.serializer.ts
4209
+ const deserializeConnectedAccountWarning = (response) => ({
4210
+ code: response.code,
4211
+ message: response.message
4212
+ });
4213
+ //#endregion
4130
4214
  //#region src/pipes/serializers/connected-account.serializer.ts
4131
4215
  const deserializeConnectedAccount = (response) => ({
4132
4216
  object: response.object,
@@ -4143,12 +4227,22 @@ const deserializeConnectedAccount = (response) => ({
4143
4227
  clientSecretLast4: response.client_secret_last_4 ?? null,
4144
4228
  config: response.config,
4145
4229
  state: response.state,
4230
+ establishedByUserId: response.established_by_user_id ?? null,
4231
+ stateReason: response.state_reason ?? null,
4146
4232
  createdAt: new Date(response.created_at),
4147
- updatedAt: new Date(response.updated_at)
4233
+ updatedAt: new Date(response.updated_at),
4234
+ warnings: response.warnings != null ? response.warnings.map(deserializeConnectedAccountWarning) : void 0
4148
4235
  });
4149
4236
  //#endregion
4237
+ //#region src/pipes/serializers/data-integration-finish-connection-response.serializer.ts
4238
+ const deserializeDataIntegrationFinishConnectionResponse = (response) => ({ connectedAccount: deserializeConnectedAccount(response.connected_account) });
4239
+ //#endregion
4150
4240
  //#region src/pipes/serializers/data-integration-authorize-url-response.serializer.ts
4151
- const deserializeDataIntegrationAuthorizeUrlResponse = (response) => ({ url: response.url });
4241
+ const deserializeDataIntegrationAuthorizeUrlResponse = (response) => ({
4242
+ url: response.url,
4243
+ state: response.state ?? "",
4244
+ completion: response.completion
4245
+ });
4152
4246
  //#endregion
4153
4247
  //#region src/pipes/serializers/data-integration-vended-credential.serializer.ts
4154
4248
  const deserializeDataIntegrationVendedCredential = (response) => {
@@ -4160,6 +4254,7 @@ const deserializeDataIntegrationVendedCredential = (response) => {
4160
4254
  expiresAt: response.expires_at != null ? new Date(response.expires_at) : null,
4161
4255
  scopes: response.scopes,
4162
4256
  missingScopes: response.missing_scopes,
4257
+ metadata: response.metadata,
4163
4258
  config: response.config
4164
4259
  };
4165
4260
  case "api_key": return {
@@ -4217,7 +4312,7 @@ const deserializeDataIntegrationAccessTokenResponse = (response) => {
4217
4312
  active: false,
4218
4313
  error: response.error
4219
4314
  };
4220
- default: throw new Error(`Unknown active: ${String(response.active)}`);
4315
+ default: throw new Error("Unknown active: " + String(response.active));
4221
4316
  }
4222
4317
  };
4223
4318
  //#endregion
@@ -4237,8 +4332,11 @@ const deserializeDataIntegrationsListResponseDataConnectedAccount = (response) =
4237
4332
  clientSecretLast4: response.client_secret_last_4 ?? null,
4238
4333
  config: response.config,
4239
4334
  state: response.state,
4335
+ establishedByUserId: response.established_by_user_id ?? null,
4336
+ stateReason: response.state_reason ?? null,
4240
4337
  createdAt: new Date(response.created_at),
4241
4338
  updatedAt: new Date(response.updated_at),
4339
+ warnings: response.warnings != null ? response.warnings.map(deserializeConnectedAccountWarning) : void 0,
4242
4340
  userlandUserId: response.userland_user_id ?? null
4243
4341
  });
4244
4342
  //#endregion
@@ -4300,55 +4398,21 @@ const serializeCustomProviderDefinition = (model) => ({
4300
4398
  const serializeCreateDataIntegration = (model) => ({
4301
4399
  provider: model.provider,
4302
4400
  ownership: model.ownership,
4303
- auth_methods: model.authMethods,
4304
- config: model.config,
4305
- api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4306
4401
  description: model.description,
4307
4402
  enabled: model.enabled,
4308
4403
  scopes: model.scopes,
4404
+ auth_methods: model.authMethods,
4405
+ config: model.config,
4309
4406
  credentials: model.credentials != null ? serializeDataIntegrationCredentialsInput(model.credentials) : void 0,
4407
+ api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4310
4408
  custom_provider: model.customProvider != null ? serializeCustomProviderDefinition(model.customProvider) : void 0
4311
4409
  });
4312
4410
  //#endregion
4313
- //#region src/pipes/serializers/data-integrations-create-api-key-connection-request.serializer.ts
4314
- const serializeDataIntegrationsCreateApiKeyConnectionRequest = (model) => ({
4315
- user_id: model.userId,
4316
- organization_id: model.organizationId,
4317
- connection_owner: model.connectionOwner,
4318
- secret: model.secret,
4319
- connection_intent: model.connectionIntent
4320
- });
4321
- //#endregion
4322
- //#region src/pipes/serializers/data-integrations-create-client-credentials-connection-request.serializer.ts
4323
- const serializeDataIntegrationsCreateClientCredentialsConnectionRequest = (model) => ({
4324
- user_id: model.userId,
4325
- organization_id: model.organizationId,
4326
- connection_owner: model.connectionOwner,
4327
- client_id: model.clientId,
4328
- client_secret: model.clientSecret,
4329
- config: model.config,
4330
- connection_intent: model.connectionIntent
4331
- });
4332
- //#endregion
4333
- //#region src/pipes/serializers/create-connected-account.serializer.ts
4334
- const serializeCreateConnectedAccount = (model) => ({
4335
- access_token: model.accessToken,
4336
- refresh_token: model.refreshToken,
4337
- expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4338
- scopes: model.scopes,
4339
- state: model.state,
4340
- connection_intent: model.connectionIntent
4341
- });
4342
- //#endregion
4343
- //#region src/pipes/serializers/create-organization-connected-account.serializer.ts
4344
- const serializeCreateOrganizationConnectedAccount = (model) => ({
4345
- access_token: model.accessToken,
4346
- refresh_token: model.refreshToken,
4347
- expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4348
- scopes: model.scopes,
4349
- state: model.state,
4350
- user_id: model.userId,
4351
- connection_intent: model.connectionIntent
4411
+ //#region src/pipes/serializers/data-integrations-finish-connection-request.serializer.ts
4412
+ const serializeDataIntegrationsFinishConnectionRequest = (model) => ({
4413
+ connect_code: model.connectCode,
4414
+ code_verifier: model.codeVerifier,
4415
+ state: model.state
4352
4416
  });
4353
4417
  //#endregion
4354
4418
  //#region src/pipes/serializers/update-custom-provider-definition.serializer.ts
@@ -4371,40 +4435,47 @@ const serializeUpdateDataIntegration = (model) => ({
4371
4435
  description: model.description,
4372
4436
  enabled: model.enabled,
4373
4437
  scopes: model.scopes,
4374
- api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4375
4438
  credentials: model.credentials != null ? serializeDataIntegrationCredentialsInput(model.credentials) : void 0,
4439
+ api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4376
4440
  custom_provider: model.customProvider != null ? serializeUpdateCustomProviderDefinition(model.customProvider) : void 0
4377
4441
  });
4378
4442
  //#endregion
4379
- //#region src/pipes/serializers/data-integrations-upsert-api-key-request.serializer.ts
4380
- const serializeDataIntegrationsUpsertApiKeyRequest = (model) => ({
4443
+ //#region src/pipes/serializers/data-integrations-create-api-key-connection-request.serializer.ts
4444
+ const serializeDataIntegrationsCreateApiKeyConnectionRequest = (model) => ({
4445
+ account_display_name: model.accountDisplayName,
4446
+ account_identifier: model.accountIdentifier,
4381
4447
  user_id: model.userId,
4382
4448
  organization_id: model.organizationId,
4383
- connected_account_id: model.connectedAccountId,
4384
- connection_intent: model.connectionIntent,
4385
4449
  connection_owner: model.connectionOwner,
4386
- secret: model.secret
4450
+ secret: model.secret,
4451
+ connection_intent: model.connectionIntent
4387
4452
  });
4388
4453
  //#endregion
4389
4454
  //#region src/pipes/serializers/data-integrations-get-data-integration-authorize-url-request.serializer.ts
4390
4455
  const serializeDataIntegrationsGetDataIntegrationAuthorizeUrlRequest = (model) => ({
4456
+ account_display_name: model.accountDisplayName,
4391
4457
  user_id: model.userId,
4392
4458
  organization_id: model.organizationId,
4393
4459
  connection_owner: model.connectionOwner,
4394
4460
  return_to: model.returnTo,
4395
- config: model.config
4461
+ code_challenge: model.codeChallenge,
4462
+ code_challenge_method: model.codeChallengeMethod,
4463
+ config: model.config,
4464
+ connection_intent: model.connectionIntent,
4465
+ connected_account_id: model.connectedAccountId
4396
4466
  });
4397
4467
  //#endregion
4398
- //#region src/pipes/serializers/data-integrations-upsert-client-credentials-request.serializer.ts
4399
- const serializeDataIntegrationsUpsertClientCredentialsRequest = (model) => ({
4468
+ //#region src/pipes/serializers/data-integrations-create-client-credentials-connection-request.serializer.ts
4469
+ const serializeDataIntegrationsCreateClientCredentialsConnectionRequest = (model) => ({
4470
+ account_display_name: model.accountDisplayName,
4471
+ account_identifier: model.accountIdentifier,
4400
4472
  user_id: model.userId,
4401
4473
  organization_id: model.organizationId,
4402
- connected_account_id: model.connectedAccountId,
4403
- connection_intent: model.connectionIntent,
4404
4474
  connection_owner: model.connectionOwner,
4405
4475
  client_id: model.clientId,
4406
4476
  client_secret: model.clientSecret,
4407
- config: model.config
4477
+ config: model.config,
4478
+ connection_intent: model.connectionIntent
4408
4479
  });
4409
4480
  //#endregion
4410
4481
  //#region src/pipes/serializers/data-integrations-vend-credentials-request.serializer.ts
@@ -4425,8 +4496,23 @@ const serializeDataIntegrationsGetUserTokenRequest = (model) => ({
4425
4496
  supports_multiple_connections: model.supportsMultipleConnections
4426
4497
  });
4427
4498
  //#endregion
4499
+ //#region src/pipes/serializers/create-organization-connected-account.serializer.ts
4500
+ const serializeCreateOrganizationConnectedAccount = (model) => ({
4501
+ account_display_name: model.accountDisplayName,
4502
+ account_identifier: model.accountIdentifier,
4503
+ access_token: model.accessToken,
4504
+ refresh_token: model.refreshToken,
4505
+ expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4506
+ scopes: model.scopes,
4507
+ state: model.state,
4508
+ user_id: model.userId,
4509
+ connection_intent: model.connectionIntent
4510
+ });
4511
+ //#endregion
4428
4512
  //#region src/pipes/serializers/organization-connected-account.serializer.ts
4429
4513
  const serializeOrganizationConnectedAccount = (model) => ({
4514
+ account_display_name: model.accountDisplayName,
4515
+ account_identifier: model.accountIdentifier,
4430
4516
  access_token: model.accessToken,
4431
4517
  refresh_token: model.refreshToken,
4432
4518
  expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
@@ -4435,8 +4521,22 @@ const serializeOrganizationConnectedAccount = (model) => ({
4435
4521
  user_id: model.userId
4436
4522
  });
4437
4523
  //#endregion
4524
+ //#region src/pipes/serializers/create-connected-account.serializer.ts
4525
+ const serializeCreateConnectedAccount = (model) => ({
4526
+ account_display_name: model.accountDisplayName,
4527
+ account_identifier: model.accountIdentifier,
4528
+ access_token: model.accessToken,
4529
+ refresh_token: model.refreshToken,
4530
+ expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4531
+ scopes: model.scopes,
4532
+ state: model.state,
4533
+ connection_intent: model.connectionIntent
4534
+ });
4535
+ //#endregion
4438
4536
  //#region src/pipes/serializers/connected-account-input.serializer.ts
4439
4537
  const serializeConnectedAccountInput = (model) => ({
4538
+ account_display_name: model.accountDisplayName,
4539
+ account_identifier: model.accountIdentifier,
4440
4540
  access_token: model.accessToken,
4441
4541
  refresh_token: model.refreshToken,
4442
4542
  expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
@@ -4444,6 +4544,32 @@ const serializeConnectedAccountInput = (model) => ({
4444
4544
  state: model.state
4445
4545
  });
4446
4546
  //#endregion
4547
+ //#region src/pipes/serializers/data-integrations-upsert-api-key-request.serializer.ts
4548
+ const serializeDataIntegrationsUpsertApiKeyRequest = (model) => ({
4549
+ account_display_name: model.accountDisplayName,
4550
+ account_identifier: model.accountIdentifier,
4551
+ user_id: model.userId,
4552
+ organization_id: model.organizationId,
4553
+ connected_account_id: model.connectedAccountId,
4554
+ connection_intent: model.connectionIntent,
4555
+ connection_owner: model.connectionOwner,
4556
+ secret: model.secret
4557
+ });
4558
+ //#endregion
4559
+ //#region src/pipes/serializers/data-integrations-upsert-client-credentials-request.serializer.ts
4560
+ const serializeDataIntegrationsUpsertClientCredentialsRequest = (model) => ({
4561
+ account_display_name: model.accountDisplayName,
4562
+ account_identifier: model.accountIdentifier,
4563
+ user_id: model.userId,
4564
+ organization_id: model.organizationId,
4565
+ connected_account_id: model.connectedAccountId,
4566
+ connection_intent: model.connectionIntent,
4567
+ connection_owner: model.connectionOwner,
4568
+ client_id: model.clientId,
4569
+ client_secret: model.clientSecret,
4570
+ config: model.config
4571
+ });
4572
+ //#endregion
4447
4573
  //#region src/pipes/pipes.ts
4448
4574
  var Pipes = class {
4449
4575
  workos;
@@ -4451,6 +4577,111 @@ var Pipes = class {
4451
4577
  this.workos = workos;
4452
4578
  }
4453
4579
  /**
4580
+ * Upsert an API key for a connected account
4581
+ *
4582
+ * Creates or updates an API-key-based installation for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. If an installation already exists, the stored API key is rotated to the new value.
4583
+ * @param options - Object containing userId, secret.
4584
+ * @param options.slug - The identifier of the integration.
4585
+ * @example "github"
4586
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4587
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4588
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
4589
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4590
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
4591
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4592
+ * @param options.connectionOwner - Whose connection to create or rotate. `user` (the default) addresses the connection owned by `user_id`. `organization` addresses the connection shared by every member of `organization_id`; `user_id` then identifies the member performing the request and must be an active member of the organization.
4593
+ * @example "user"
4594
+ * @param options.secret - The API key secret to store for this integration.
4595
+ * @example "sk-1234567890abcdef"
4596
+ * @returns {Promise<ConnectedAccount>}
4597
+ * @throws {BadRequestException} 400
4598
+ * @throws {UnauthorizedException} 401
4599
+ * @throws {AuthorizationException} 403
4600
+ * @throws {NotFoundException} 404
4601
+ * @throws {ConflictException} 409
4602
+ * @throws {UnprocessableEntityException} 422
4603
+ */
4604
+ async updateDataIntegrationApiKey(options) {
4605
+ const { slug, ...payload } = options;
4606
+ const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsUpsertApiKeyRequest(payload));
4607
+ return deserializeConnectedAccount(data);
4608
+ }
4609
+ /**
4610
+ * Upsert client credentials for a connected account
4611
+ *
4612
+ * Creates or updates a client-credentials-based installation for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. If an installation already exists, the stored client credentials are rotated to the new values.
4613
+ * @param options - The request options.
4614
+ * @param options.slug - The identifier of the integration.
4615
+ * @example "salesforce"
4616
+ * @returns {Promise<ConnectedAccount>}
4617
+ * @throws {BadRequestException} 400
4618
+ * @throws {UnauthorizedException} 401
4619
+ * @throws {AuthorizationException} 403
4620
+ * @throws {NotFoundException} 404
4621
+ * @throws {ConflictException} 409
4622
+ * @throws {UnprocessableEntityException} 422
4623
+ */
4624
+ async updateDataIntegrationClientCredentials(options) {
4625
+ const { slug, ...payload } = options;
4626
+ const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsUpsertClientCredentialsRequest(payload));
4627
+ return deserializeConnectedAccount(data);
4628
+ }
4629
+ /**
4630
+ * Delete an organization connected account
4631
+ *
4632
+ * Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side.
4633
+ * @param options - Additional query options.
4634
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4635
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4636
+ * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4637
+ * @example "github"
4638
+ * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4639
+ * @example true
4640
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4641
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4642
+ * @returns {Promise<void>}
4643
+ * @throws {BadRequestException} 400
4644
+ * @throws {UnauthorizedException} 401
4645
+ * @throws {NotFoundException} 404
4646
+ * @throws {ConflictException} 409
4647
+ */
4648
+ async deleteOrganizationConnectedAccount(options) {
4649
+ const { organizationId, slug } = options;
4650
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4651
+ supports_multiple_connections: options.supportsMultipleConnections,
4652
+ connected_account_id: options.connectedAccountId
4653
+ });
4654
+ }
4655
+ /**
4656
+ * Delete a connected account
4657
+ *
4658
+ * Disconnects WorkOS's account for the user, including removing any stored access and refresh tokens. The user will need to reauthorize if they want to reconnect. Access is not revoked on the provider side, except for the WorkOS OAuth provider, whose underlying AuthKit grant is revoked.
4659
+ * @param options - Additional query options.
4660
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4661
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4662
+ * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4663
+ * @example "github"
4664
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4665
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4666
+ * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4667
+ * @example true
4668
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4669
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4670
+ * @returns {Promise<void>}
4671
+ * @throws {BadRequestException} 400
4672
+ * @throws {UnauthorizedException} 401
4673
+ * @throws {NotFoundException} 404
4674
+ * @throws {ConflictException} 409
4675
+ */
4676
+ async deleteUserConnectedAccount(options) {
4677
+ const { userId, slug } = options;
4678
+ await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4679
+ organization_id: options.organizationId,
4680
+ supports_multiple_connections: options.supportsMultipleConnections,
4681
+ connected_account_id: options.connectedAccountId
4682
+ });
4683
+ }
4684
+ /**
4454
4685
  * List data integrations
4455
4686
  *
4456
4687
  * Lists the environment's data integrations configured with `custom` or `organization` credentials, including custom providers and API key integrations. Both user-owned and organization-owned roots are returned, each as its own row with an `ownership`; filter with `ownership` to return only one kind.
@@ -4500,6 +4731,20 @@ var Pipes = class {
4500
4731
  return deserializeDataIntegration(data);
4501
4732
  }
4502
4733
  /**
4734
+ * Finish connection
4735
+ *
4736
+ * Saves a connection that was started with `code_challenge`. After the user authorizes, WorkOS redirects them to `return_to` with a `connect_code` and `state`. Call this endpoint from your server with that `connect_code` and the `code_verifier` behind the challenge to save the connected account.
4737
+ * @returns {Promise<DataIntegrationFinishConnectionResponse>}
4738
+ * @throws {BadRequestException} 400
4739
+ * @throws {UnauthorizedException} 401
4740
+ * @throws {AuthorizationException} 403
4741
+ */
4742
+ async finishConnection(options) {
4743
+ const payload = options;
4744
+ const { data } = await this.workos.post("/data-integrations/finish", serializeDataIntegrationsFinishConnectionRequest(payload));
4745
+ return deserializeDataIntegrationFinishConnectionResponse(data);
4746
+ }
4747
+ /**
4503
4748
  * Get a data integration
4504
4749
  *
4505
4750
  * Retrieves the user-owned data integration by its slug.
@@ -4562,45 +4807,34 @@ var Pipes = class {
4562
4807
  /**
4563
4808
  * Create another API key connected account
4564
4809
  *
4565
- * Requires `connectionIntent: 'add'` and does not accept an account selector.
4566
- * Until additional connections are available, this creates the first connection
4567
- * or returns 404 `multiple_connections_unavailable` if one already exists.
4568
- * Use `updateDataIntegrationApiKey` to rotate the compatibility connection or
4569
- * update an exact connection.
4570
- */
4571
- async createDataIntegrationApiKey(options) {
4572
- const { slug, ...payload } = options;
4573
- const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsCreateApiKeyConnectionRequest(payload));
4574
- return deserializeConnectedAccount(data);
4575
- }
4576
- /**
4577
- * Upsert an API key for a connected account
4578
- *
4579
- * Creates or updates an API-key-based installation for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. If an installation already exists, the stored API key is rotated to the new value.
4580
- * @param options - Object containing userId, secret.
4810
+ * Creates another API key-based connected account for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. Requires `connection_intent: add` and does not accept `connected_account_id`; use PUT to create or rotate the compatibility connection or to update an exact connection.
4811
+ * @param options - Object containing userId, secret, connectionIntent.
4581
4812
  * @param options.slug - The identifier of the integration.
4582
4813
  * @example "github"
4814
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4815
+ * @example "Acme production"
4816
+ * @param options.accountIdentifier - A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.
4817
+ * @example "workspace_123"
4583
4818
  * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4584
4819
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4585
4820
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
4586
4821
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4587
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
4588
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4589
4822
  * @param options.connectionOwner - Whose connection to create or rotate. `user` (the default) addresses the connection owned by `user_id`. `organization` addresses the connection shared by every member of `organization_id`; `user_id` then identifies the member performing the request and must be an active member of the organization.
4590
4823
  * @example "user"
4591
4824
  * @param options.secret - The API key secret to store for this integration.
4592
4825
  * @example "sk-1234567890abcdef"
4826
+ * @param options.connectionIntent - Must be `add`: this endpoint only creates another connection. The first connection for an owner shape fills the compatibility slot; later connections are standard.
4827
+ * @example "add"
4593
4828
  * @returns {Promise<ConnectedAccount>}
4594
4829
  * @throws {BadRequestException} 400
4595
4830
  * @throws {UnauthorizedException} 401
4596
4831
  * @throws {AuthorizationException} 403
4597
4832
  * @throws {NotFoundException} 404
4598
4833
  * @throws {ConflictException} 409
4599
- * @throws {UnprocessableEntityException} 422
4600
4834
  */
4601
- async updateDataIntegrationApiKey(options) {
4835
+ async createDataIntegrationApiKey(options) {
4602
4836
  const { slug, ...payload } = options;
4603
- const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsUpsertApiKeyRequest(payload));
4837
+ const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsCreateApiKeyConnectionRequest(payload));
4604
4838
  return deserializeConnectedAccount(data);
4605
4839
  }
4606
4840
  /**
@@ -4610,21 +4844,33 @@ var Pipes = class {
4610
4844
  * @param options - Object containing userId.
4611
4845
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4612
4846
  * @example "github"
4847
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4848
+ * @example "Acme production"
4613
4849
  * @param options.userId - The ID of the user to authorize. When `connection_owner` is `organization`, this is the user authorizing on behalf of the organization; they must be an active member of the organization and do not become the owner of the resulting connected account.
4614
4850
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4615
4851
  * @param options.organizationId - An organization ID to scope the authorization to a specific organization. Required when `connection_owner` is `organization`.
4616
4852
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4617
4853
  * @param options.connectionOwner - Who will own the connected account. `user` (the default) connects the user's own account. `organization` connects the organization's shared account and requires `organization_id`.
4618
4854
  * @example "user"
4619
- * @param options.returnTo - The URL to redirect the user to after authorization.
4855
+ * @param options.returnTo - The URL to redirect the user to after authorization. Required with `code_challenge`, and must then exactly match a redirect URI registered on one of the environment's applications. Loopback URLs match on any port; wildcard redirect URIs are not honored, and a `return_to` with a query string or fragment never matches.
4620
4856
  * @example "https://example.com/callback"
4857
+ * @param options.codeChallenge - A PKCE-style code challenge: the base64url-encoded SHA-256 of a `code_verifier` your app keeps. When set, the connection isn't saved when the user finishes authorizing. Instead, the user is redirected to `return_to` with a `connect_code` and `state`, and your app must call [Finish connection](https://workos.com/docs/reference/pipes/connected-account/finish-connection) with the `connect_code` and `code_verifier` within 90 seconds to save it.
4858
+ * @example "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"
4859
+ * @param options.codeChallengeMethod - The method used to derive `code_challenge`. Only `S256` is supported, and it is the default. Requires `code_challenge`.
4860
+ * @example "S256"
4621
4861
  * @param options.config - Connect-time config values for the provider-declared `installation`-scope fields (e.g. a Zendesk `subdomain`), keyed by the config field. Only fields the provider declares may be supplied, and required fields must be provided unless already pinned on the integration.
4622
4862
  * @example {"subdomain":"acme"}
4863
+ * @param options.connectionIntent - Which connection the request targets. Omit it to use the compatibility connection. Send `add` to create another connection: the first connection for an owner shape fills the compatibility slot, and later connections are standard. Send `reauthorize` with `connected_account_id` to reauthorize one exact connection.
4864
+ * @example "add"
4865
+ * @param options.connectedAccountId - The exact connected account to reauthorize. Required with `connection_intent: reauthorize` and not accepted otherwise.
4866
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4623
4867
  * @returns {Promise<DataIntegrationAuthorizeUrlResponse>}
4624
4868
  * @throws {BadRequestException} 400
4625
4869
  * @throws {UnauthorizedException} 401
4626
4870
  * @throws {AuthorizationException} 403
4627
4871
  * @throws {NotFoundException} 404
4872
+ * @throws {ConflictException} 409
4873
+ * @throws {UnprocessableEntityException} 422
4628
4874
  */
4629
4875
  async authorizeDataIntegration(options) {
4630
4876
  const { slug, ...payload } = options;
@@ -4634,41 +4880,44 @@ var Pipes = class {
4634
4880
  /**
4635
4881
  * Create another client credentials connected account
4636
4882
  *
4637
- * Requires `connectionIntent: 'add'` and does not accept an account selector.
4638
- * Until additional connections are available, this creates the first connection
4639
- * or returns 404 `multiple_connections_unavailable` if one already exists.
4640
- * Use `updateDataIntegrationClientCredentials` to rotate the compatibility
4641
- * connection or update an exact connection.
4642
- */
4643
- async createDataIntegrationClientCredential(options) {
4644
- const { slug, ...payload } = options;
4645
- const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsCreateClientCredentialsConnectionRequest(payload));
4646
- return deserializeConnectedAccount(data);
4647
- }
4648
- /**
4649
- * Upsert client credentials for a connected account
4650
- *
4651
- * Creates or updates a client-credentials-based installation for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. If an installation already exists, the stored client credentials are rotated to the new values.
4652
- * @param options - The request options.
4883
+ * Creates another client credentials-based connected account for the specified integration, owned by the user or, when `connection_owner` is `organization`, shared by the organization. Requires `connection_intent: add` and does not accept `connected_account_id`; use PUT to create or rotate the compatibility connection or to update an exact connection.
4884
+ * @param options - Object containing userId, clientId, clientSecret, connectionIntent.
4653
4885
  * @param options.slug - The identifier of the integration.
4654
4886
  * @example "salesforce"
4887
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4888
+ * @example "Acme production"
4889
+ * @param options.accountIdentifier - A developer-attested provider account identifier, never inferred from a label or credential. Omit to preserve an existing identifier; null clears it.
4890
+ * @example "workspace_123"
4891
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4892
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4893
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. Required when `connection_owner` is `organization`.
4894
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4895
+ * @param options.connectionOwner - Whose connection to create or rotate. `user` (the default) addresses the connection owned by `user_id`. `organization` addresses the connection shared by every member of `organization_id`; `user_id` then identifies the member performing the request and must be an active member of the organization.
4896
+ * @example "user"
4897
+ * @param options.clientId - The OAuth client ID to store for this integration.
4898
+ * @example "3MVG9..."
4899
+ * @param options.clientSecret - The OAuth client secret to store for this integration.
4900
+ * @example "shhh-secret"
4901
+ * @param options.config - Provider-specific configuration values collected for this installation, keyed by the provider's config field descriptors.
4902
+ * @example {"salesforce_host":"acme.my.salesforce.com"}
4903
+ * @param options.connectionIntent - Must be `add`: this endpoint only creates another connection. The first connection for an owner shape fills the compatibility slot; later connections are standard.
4904
+ * @example "add"
4655
4905
  * @returns {Promise<ConnectedAccount>}
4656
4906
  * @throws {BadRequestException} 400
4657
4907
  * @throws {UnauthorizedException} 401
4658
4908
  * @throws {AuthorizationException} 403
4659
4909
  * @throws {NotFoundException} 404
4660
4910
  * @throws {ConflictException} 409
4661
- * @throws {UnprocessableEntityException} 422
4662
4911
  */
4663
- async updateDataIntegrationClientCredentials(options) {
4912
+ async createDataIntegrationClientCredential(options) {
4664
4913
  const { slug, ...payload } = options;
4665
- const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsUpsertClientCredentialsRequest(payload));
4914
+ const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsCreateClientCredentialsConnectionRequest(payload));
4666
4915
  return deserializeConnectedAccount(data);
4667
4916
  }
4668
4917
  /**
4669
4918
  * Vend credentials for a connected account
4670
4919
  *
4671
- * Returns credentials for a user-owned or organization-owned connected account. OAuth and client-credentials installations return an access token; API-key installations return the stored secret. Every active credential includes provider-declared, non-secret `config` from the connection snapshot with current defaults. Client-credentials responses also include provider token `metadata`.
4920
+ * Returns credentials for a user's connected account. Branches on the installation's `auth_method`: OAuth installations return an access token (refreshed if needed); API-key installations return the stored secret. Every active credential includes `config`: provider-declared, non-secret values from the installation snapshot, with current provider defaults for unset fields. Editing integration or organization configuration does not change the snapshot; reconnect or explicitly rebind the connection to adopt those edits. Defaults remain live, so a changed default can appear in `config` before a cached token is refreshed or re-minted. Credentials that never refresh require a reconnect or rebind when a default changes their routing.
4672
4921
  * @param options - Object containing userId.
4673
4922
  * @param options.slug - The identifier of the integration.
4674
4923
  * @example "github"
@@ -4715,9 +4964,18 @@ var Pipes = class {
4715
4964
  * Update an organization-owned data integration
4716
4965
  *
4717
4966
  * Updates the description, enabled state, or custom credentials of the organization-owned data integration for a provider. For custom providers, `custom_provider` updates the OAuth definition, which is shared with the user-owned root. The `/organization` suffix selects the environment-level organization-owned root for the provider; it does not name a particular organization.
4718
- * @param options - The request options.
4967
+ * @param options - The request body.
4719
4968
  * @param options.slug - The slug identifier of the data integration.
4720
4969
  * @example "github"
4970
+ * @param options.description - An optional description of the Data Integration.
4971
+ * @example "Production GitHub app"
4972
+ * @param options.enabled - Whether the Data Integration is enabled.
4973
+ * @example true
4974
+ * @param options.scopes - The OAuth scopes to request for the Data Integration. Pass `null` to reset to the provider's configured scopes.
4975
+ * @example ["repo","read:org"]
4976
+ * @param options.credentials - New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with `api_key`.
4977
+ * @param options.apiKey - An API key to install or rotate for a tenant on an `api_key` integration. Upserts the tenant installation identified by `user_id` (and optional `organization_id`).
4978
+ * @param options.customProvider - Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.
4721
4979
  * @returns {Promise<DataIntegration>}
4722
4980
  * @throws {BadRequestException} 400
4723
4981
  * @throws {UnauthorizedException} 401
@@ -4806,12 +5064,30 @@ var Pipes = class {
4806
5064
  /**
4807
5065
  * Import an organization connected account
4808
5066
  *
4809
- * Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Omit `connectionIntent` for compatibility behavior or set it to `add` to explicitly create a connection. Additional connection creation is subject to API availability.
4810
- * @param options - The request options.
5067
+ * Imports an organization-owned [connected account](https://workos.com/docs/reference/pipes/connected-account) by providing OAuth tokens directly. Omit `connection_intent` to create only the compatibility connection, or set it to `add` to explicitly create another connection. This creation-only endpoint does not accept `connected_account_id` or reauthorization intent.
5068
+ * @param options - Object containing userId.
4811
5069
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4812
5070
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4813
5071
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4814
5072
  * @example "github"
5073
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5074
+ * @example "Acme production"
5075
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5076
+ * @example "workspace_123"
5077
+ * @param options.accessToken - The OAuth access token for the connected account.
5078
+ * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
5079
+ * @param options.refreshToken - The OAuth refresh token for the connected account.
5080
+ * @example "ghr_xxxxxxxxxxxxxxxxxxxx"
5081
+ * @param options.expiresAt - The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
5082
+ * @example "2025-12-31T23:59:59.000Z"
5083
+ * @param options.scopes - The OAuth scopes granted for this connection.
5084
+ * @example ["repo","user:email"]
5085
+ * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
5086
+ * @example "connected"
5087
+ * @param options.userId - The [User](https://workos.com/docs/reference/authkit/user) identifier of the organization member on whose behalf the connected account is being imported or updated. The user must be an active member of the organization.
5088
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
5089
+ * @param options.connectionIntent - Set to `add` to create another connected account. Omit this field for permanent compatibility behavior.
5090
+ * @example "add"
4815
5091
  * @returns {Promise<ConnectedAccount>}
4816
5092
  * @throws {UnauthorizedException} 401
4817
5093
  * @throws {AuthorizationException} 403
@@ -4828,15 +5104,33 @@ var Pipes = class {
4828
5104
  * Update an organization connected account
4829
5105
  *
4830
5106
  * Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider.
4831
- * @param options - Additional query options.
5107
+ * @param options - Object containing userId.
4832
5108
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4833
5109
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4834
5110
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4835
5111
  * @example "github"
4836
- * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting.
5112
+ * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting. Omit intent and selector to update the compatibility connection, or supply `connected_account_id` to update an exact connection.
5113
+ * @example true
4837
5114
  * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
4838
5115
  * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4839
- * @param options.connectionIntent - Set to `reauthorize` with `connectedAccountId`, or omit both to update the compatibility connection.
5116
+ * @param options.connectionIntent - Set to `reauthorize` with `connected_account_id` to update one exact connection. The intent may be omitted when supplying an ID. Omit both for permanent compatibility behavior.
5117
+ * @example "reauthorize"
5118
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5119
+ * @example "Acme production"
5120
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5121
+ * @example "workspace_123"
5122
+ * @param options.accessToken - The OAuth access token for the connected account.
5123
+ * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
5124
+ * @param options.refreshToken - The OAuth refresh token for the connected account.
5125
+ * @example "ghr_xxxxxxxxxxxxxxxxxxxx"
5126
+ * @param options.expiresAt - The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
5127
+ * @example "2025-12-31T23:59:59.000Z"
5128
+ * @param options.scopes - The OAuth scopes granted for this connection.
5129
+ * @example ["repo","user:email"]
5130
+ * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
5131
+ * @example "connected"
5132
+ * @param options.userId - The [User](https://workos.com/docs/reference/authkit/user) identifier of the organization member on whose behalf the connected account is being imported or updated. The user must be an active member of the organization.
5133
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4840
5134
  * @returns {Promise<ConnectedAccount>}
4841
5135
  * @throws {BadRequestException} 400
4842
5136
  * @throws {UnauthorizedException} 401
@@ -4848,39 +5142,13 @@ var Pipes = class {
4848
5142
  async updateOrganizationConnectedAccount(options) {
4849
5143
  const { organizationId, slug, supportsMultipleConnections, connectedAccountId, connectionIntent, ...payload } = options;
4850
5144
  const { data } = await this.workos.put(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeOrganizationConnectedAccount(payload), { query: {
4851
- supports_multiple_connections: supportsMultipleConnections,
4852
- connected_account_id: connectedAccountId,
4853
- connection_intent: connectionIntent
5145
+ ...options.supportsMultipleConnections !== void 0 && { supports_multiple_connections: options.supportsMultipleConnections },
5146
+ ...options.connectedAccountId !== void 0 && { connected_account_id: options.connectedAccountId },
5147
+ ...options.connectionIntent !== void 0 && { connection_intent: options.connectionIntent }
4854
5148
  } });
4855
5149
  return deserializeConnectedAccount(data);
4856
5150
  }
4857
5151
  /**
4858
- * Delete an organization connected account
4859
- *
4860
- * Disconnects the organization's account for the provider, including removing any stored access and refresh tokens. A member will need to reauthorize if the organization wants to reconnect. This does not revoke access on the provider side.
4861
- * @param options - Additional query options.
4862
- * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4863
- * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4864
- * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4865
- * @example "github"
4866
- * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4867
- * @example true
4868
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4869
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4870
- * @returns {Promise<void>}
4871
- * @throws {BadRequestException} 400
4872
- * @throws {UnauthorizedException} 401
4873
- * @throws {NotFoundException} 404
4874
- * @throws {ConflictException} 409
4875
- */
4876
- async deleteOrganizationConnectedAccount(options) {
4877
- const { organizationId, slug } = options;
4878
- await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4879
- supports_multiple_connections: options.supportsMultipleConnections,
4880
- connected_account_id: options.connectedAccountId
4881
- });
4882
- }
4883
- /**
4884
5152
  * List providers for an organization
4885
5153
  *
4886
5154
  * Retrieves the organization-owned providers configured for your environment and the organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) information for each. Providers owned by individual users are not included.
@@ -4931,7 +5199,7 @@ var Pipes = class {
4931
5199
  /**
4932
5200
  * Import a connected account
4933
5201
  *
4934
- * Imports a [connected account](https://workos.com/docs/reference/pipes/connected-account) for a user by providing OAuth tokens directly. Omit `connectionIntent` for compatibility behavior or set it to `add` to explicitly create a connection. Additional connection creation is subject to API availability.
5202
+ * Imports a [connected account](https://workos.com/docs/reference/pipes/connected-account) for a user by providing OAuth tokens directly. Use this to migrate existing connections or set up connections without going through the OAuth flow.
4935
5203
  * @param options - The request body.
4936
5204
  * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4937
5205
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
@@ -4939,6 +5207,10 @@ var Pipes = class {
4939
5207
  * @example "github"
4940
5208
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4941
5209
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
5210
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5211
+ * @example "Acme production"
5212
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5213
+ * @example "workspace_123"
4942
5214
  * @param options.accessToken - The OAuth access token for the connected account.
4943
5215
  * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
4944
5216
  * @param options.refreshToken - The OAuth refresh token for the connected account.
@@ -4949,6 +5221,8 @@ var Pipes = class {
4949
5221
  * @example ["repo","user:email"]
4950
5222
  * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
4951
5223
  * @example "connected"
5224
+ * @param options.connectionIntent - Set to `add` to create another connected account. Omit this field for permanent compatibility behavior.
5225
+ * @example "add"
4952
5226
  * @returns {Promise<ConnectedAccount>}
4953
5227
  * @throws {UnauthorizedException} 401
4954
5228
  * @throws {NotFoundException} 404
@@ -4957,7 +5231,7 @@ var Pipes = class {
4957
5231
  */
4958
5232
  async createUserConnectedAccount(options) {
4959
5233
  const { userId, slug, organizationId, ...payload } = options;
4960
- const { data } = await this.workos.post(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeCreateConnectedAccount(payload), { query: { organization_id: organizationId } });
5234
+ const { data } = await this.workos.post(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeCreateConnectedAccount(payload), { query: { ...options.organizationId !== void 0 && { organization_id: options.organizationId } } });
4961
5235
  return deserializeConnectedAccount(data);
4962
5236
  }
4963
5237
  /**
@@ -4971,10 +5245,16 @@ var Pipes = class {
4971
5245
  * @example "github"
4972
5246
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4973
5247
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4974
- * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting.
5248
+ * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting. Omit intent and selector to update the compatibility connection, or supply `connected_account_id` to update an exact connection.
5249
+ * @example true
4975
5250
  * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
4976
5251
  * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4977
- * @param options.connectionIntent - Set to `reauthorize` with `connectedAccountId`, or omit both to update the compatibility connection.
5252
+ * @param options.connectionIntent - Set to `reauthorize` with `connected_account_id` to update one exact connection. The intent may be omitted when supplying an ID. Omit both for permanent compatibility behavior.
5253
+ * @example "reauthorize"
5254
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5255
+ * @example "Acme production"
5256
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5257
+ * @example "workspace_123"
4978
5258
  * @param options.accessToken - The OAuth access token for the connected account.
4979
5259
  * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
4980
5260
  * @param options.refreshToken - The OAuth refresh token for the connected account.
@@ -4995,43 +5275,14 @@ var Pipes = class {
4995
5275
  async updateUserConnectedAccount(options) {
4996
5276
  const { userId, slug, organizationId, supportsMultipleConnections, connectedAccountId, connectionIntent, ...payload } = options;
4997
5277
  const { data } = await this.workos.put(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeConnectedAccountInput(payload), { query: {
4998
- organization_id: organizationId,
4999
- supports_multiple_connections: supportsMultipleConnections,
5000
- connected_account_id: connectedAccountId,
5001
- connection_intent: connectionIntent
5278
+ ...options.organizationId !== void 0 && { organization_id: options.organizationId },
5279
+ ...options.supportsMultipleConnections !== void 0 && { supports_multiple_connections: options.supportsMultipleConnections },
5280
+ ...options.connectedAccountId !== void 0 && { connected_account_id: options.connectedAccountId },
5281
+ ...options.connectionIntent !== void 0 && { connection_intent: options.connectionIntent }
5002
5282
  } });
5003
5283
  return deserializeConnectedAccount(data);
5004
5284
  }
5005
5285
  /**
5006
- * Delete a connected account
5007
- *
5008
- * Disconnects WorkOS's account for the user, including removing any stored access and refresh tokens. The user will need to reauthorize if they want to reconnect. Access is not revoked on the provider side, except for the WorkOS OAuth provider, whose underlying AuthKit grant is revoked.
5009
- * @param options - Additional query options.
5010
- * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
5011
- * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
5012
- * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
5013
- * @example "github"
5014
- * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
5015
- * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
5016
- * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
5017
- * @example true
5018
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
5019
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
5020
- * @returns {Promise<void>}
5021
- * @throws {BadRequestException} 400
5022
- * @throws {UnauthorizedException} 401
5023
- * @throws {NotFoundException} 404
5024
- * @throws {ConflictException} 409
5025
- */
5026
- async deleteUserConnectedAccount(options) {
5027
- const { userId, slug } = options;
5028
- await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
5029
- organization_id: options.organizationId,
5030
- supports_multiple_connections: options.supportsMultipleConnections,
5031
- connected_account_id: options.connectedAccountId
5032
- });
5033
- }
5034
- /**
5035
5286
  * List providers for a user
5036
5287
  *
5037
5288
  * Retrieves a list of available providers and the user's connection status for each. Returns all providers configured for your environment, along with the user's [connected account](https://workos.com/docs/reference/pipes/connected-account) information where applicable.
@@ -6088,10 +6339,10 @@ let detectedRuntime = null;
6088
6339
  function detectRuntime() {
6089
6340
  if (detectedRuntime) return detectedRuntime;
6090
6341
  const global = globalThis;
6091
- if (typeof process !== "undefined" && process.release?.name === "node") detectedRuntime = "node";
6092
- else if (typeof global.Deno !== "undefined") detectedRuntime = "deno";
6093
- else if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Bun")) detectedRuntime = "bun";
6342
+ if (typeof global.Deno !== "undefined") detectedRuntime = "deno";
6343
+ else if (typeof global.Bun !== "undefined" || typeof process !== "undefined" && process.versions?.bun || typeof navigator !== "undefined" && navigator.userAgent?.includes("Bun")) detectedRuntime = "bun";
6094
6344
  else if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare")) detectedRuntime = "cloudflare";
6345
+ else if (typeof process !== "undefined" && process.release?.name === "node") detectedRuntime = "node";
6095
6346
  else if (typeof global !== "undefined" && "fastly" in global) detectedRuntime = "fastly";
6096
6347
  else if (typeof global !== "undefined" && "EdgeRuntime" in global) detectedRuntime = "edge-light";
6097
6348
  else detectedRuntime = "other";
@@ -6106,7 +6357,7 @@ function getEnvironmentVariable(key) {
6106
6357
  case "bun":
6107
6358
  case "edge-light": return process.env[key];
6108
6359
  case "deno": return global.Deno.env.get(key);
6109
- case "cloudflare": return global.env?.[key] ?? global[key];
6360
+ case "cloudflare": return global.env?.[key] ?? global[key] ?? (typeof process !== "undefined" ? process.env?.[key] : void 0);
6110
6361
  case "fastly": return global[key];
6111
6362
  default: return process?.env?.[key] ?? global.env?.[key] ?? global[key];
6112
6363
  }
@@ -6287,12 +6538,12 @@ var CookieSession = class {
6287
6538
  authenticated: false,
6288
6539
  reason: "invalid_session_cookie"
6289
6540
  };
6290
- if (!await this.isValidJwt(session.accessToken)) return {
6541
+ const claims = await this.userManagement.verifyAccessToken(session.accessToken);
6542
+ if (!claims) return {
6291
6543
  authenticated: false,
6292
6544
  reason: "invalid_jwt"
6293
6545
  };
6294
- const { decodeJwt } = await getJose();
6295
- const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = decodeJwt(session.accessToken);
6546
+ const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = claims;
6296
6547
  return {
6297
6548
  authenticated: true,
6298
6549
  sessionId,
@@ -6382,19 +6633,6 @@ var CookieSession = class {
6382
6633
  returnTo
6383
6634
  });
6384
6635
  }
6385
- async isValidJwt(accessToken) {
6386
- const { jwtVerify } = await getJose();
6387
- const jwks = await this.userManagement.getJWKS();
6388
- if (!jwks) throw new Error("Missing client ID. Did you provide it when initializing WorkOS?");
6389
- const { issuer } = this.userManagement;
6390
- try {
6391
- await jwtVerify(accessToken, jwks, issuer ? { issuer } : void 0);
6392
- return true;
6393
- } catch (e) {
6394
- if (e instanceof Error && "code" in e && typeof e.code === "string" && (e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_"))) return false;
6395
- throw e;
6396
- }
6397
- }
6398
6636
  };
6399
6637
  /**
6400
6638
  * Classifies an error thrown while refreshing as a terminal authentication
@@ -6729,8 +6967,6 @@ var UserManagement = class UserManagement {
6729
6967
  }
6730
6968
  async authenticateWithSessionCookie({ sessionData, cookiePassword = getEnv("WORKOS_COOKIE_PASSWORD") }) {
6731
6969
  if (!cookiePassword) throw new Error("Cookie password is required");
6732
- if (!await this.getJWKS()) throw new Error("Must provide clientId to initialize JWKS");
6733
- const { decodeJwt } = await getJose();
6734
6970
  if (!sessionData) return {
6735
6971
  authenticated: false,
6736
6972
  reason: "no_session_cookie_provided"
@@ -6740,11 +6976,12 @@ var UserManagement = class UserManagement {
6740
6976
  authenticated: false,
6741
6977
  reason: "invalid_session_cookie"
6742
6978
  };
6743
- if (!await this.isValidJwt(session.accessToken)) return {
6979
+ const claims = await this.verifyAccessToken(session.accessToken);
6980
+ if (!claims) return {
6744
6981
  authenticated: false,
6745
6982
  reason: "invalid_jwt"
6746
6983
  };
6747
- const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = decodeJwt(session.accessToken);
6984
+ const { sid: sessionId, org_id: organizationId, role, roles, permissions, entitlements, feature_flags: featureFlags } = claims;
6748
6985
  return {
6749
6986
  authenticated: true,
6750
6987
  sessionId,
@@ -6824,9 +7061,6 @@ var UserManagement = class UserManagement {
6824
7061
  if (!(e instanceof Error) || !("code" in e) || typeof e.code !== "string") return false;
6825
7062
  return e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_") || e.code === "ERR_JWKS_NO_MATCHING_KEY" || e.code === "ERR_JWKS_MULTIPLE_MATCHING_KEYS" || e.code === "ERR_JOSE_NOT_SUPPORTED" || e.code === "ERR_JOSE_ALG_NOT_ALLOWED";
6826
7063
  }
6827
- async isValidJwt(accessToken) {
6828
- return await this.verifyJwt(accessToken) !== null;
6829
- }
6830
7064
  async prepareAuthenticationResponse({ authenticationResponse, session }) {
6831
7065
  if (session?.sealSession) {
6832
7066
  if (!this.workos.key) throw new Error("Session sealing requires server-side usage with an API key. Public clients should store tokens directly (e.g., secure storage on mobile, keychain on desktop).");
@@ -9772,7 +10006,7 @@ var Vault = class {
9772
10006
  };
9773
10007
  //#endregion
9774
10008
  //#region package.json
9775
- var version = "12.0.0";
10009
+ var version = "12.2.0";
9776
10010
  //#endregion
9777
10011
  //#region src/workos.ts
9778
10012
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -10002,6 +10236,7 @@ var WorkOS = class {
10002
10236
  * Everything else (a `ParseError` for malformed JSON, a network failure
10003
10237
  * mid-body) propagates unchanged.
10004
10238
  */
10239
+ /** @internal */
10005
10240
  async readResponseJSON(path, response) {
10006
10241
  try {
10007
10242
  return await response.toJSON();
@@ -10016,6 +10251,7 @@ var WorkOS = class {
10016
10251
  emitWarning(warning) {
10017
10252
  console.warn(`WorkOS: ${warning}`);
10018
10253
  }
10254
+ /** @internal */
10019
10255
  handleHttpError({ path, error }) {
10020
10256
  if (!(error instanceof HttpClientError)) throw new Error(`Unexpected error: ${error}`, { cause: error });
10021
10257
  const { response } = error;
@@ -10185,4 +10421,4 @@ function createWorkOS(options) {
10185
10421
  //#endregion
10186
10422
  export { isAuthenticationErrorData as A, RateLimitExceededException as C, ConflictException as D, NoApiKeyProvidedException as E, ApiKeyRequiredException as M, FetchHttpClient as N, BadRequestException as O, SubtleCryptoProvider as P, SignatureVerificationException as S, NotFoundException as T, Webhooks as _, ItContactIntent as a, UnprocessableEntityException as b, GenerateLinkIntent as c, FeatureFlagsRuntimeClient as d, CookieSession as f, PKCE as g, AuthenticateWithSessionCookieFailureReason as h, OrganizationDomainVerificationStrategy as i, GenericServerException as j, AuthenticationException as k, UpdateAuditLogsRetentionRetentionPeriod as l, serializeRevokeSessionOptions as m, ConnectionType as n, DomainDataState as o, RefreshSessionFailureReason as p, OrganizationDomainState as r, DirectoryUserWithGroupsState as s, createWorkOS as t, WorkOS as u, AutoPaginatable as v, OauthException as w, UnauthorizedException as x, Actions as y };
10187
10423
 
10188
- //# sourceMappingURL=factory-D2Ig6M1S.mjs.map
10424
+ //# sourceMappingURL=factory-lX3X15SU.mjs.map