@workos-inc/node 11.0.0 → 12.1.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.
@@ -671,7 +671,9 @@ var SignatureProvider = class {
671
671
  async verifyHeader({ payload, sigHeader, secret, tolerance = 18e4 }) {
672
672
  const [timestamp, signatureHash] = this.getTimestampAndSignatureHash(sigHeader);
673
673
  if (!signatureHash || Object.keys(signatureHash).length === 0) throw new SignatureVerificationException("No signature hash found with expected scheme v1");
674
- if (parseInt(timestamp, 10) < Date.now() - tolerance) throw new SignatureVerificationException("Timestamp outside the tolerance zone");
674
+ const timestampMs = Number(timestamp);
675
+ if (!/^\d+$/.test(timestamp) || !Number.isSafeInteger(timestampMs)) throw new SignatureVerificationException("Invalid timestamp");
676
+ if (Math.abs(Date.now() - timestampMs) > tolerance) throw new SignatureVerificationException("Timestamp outside the tolerance zone");
675
677
  const expectedSig = await this.computeSignature(timestamp, payload, secret);
676
678
  if (await this.cryptoProvider.secureCompare(expectedSig, signatureHash) === false) throw new SignatureVerificationException("Signature hash does not match the expected signature hash for payload");
677
679
  return true;
@@ -713,8 +715,8 @@ const deserializeOrganizationDomain = (organizationDomain) => ({
713
715
  ...organizationDomain.verification_token !== void 0 && { verificationToken: organizationDomain.verification_token },
714
716
  verificationStrategy: organizationDomain.verification_strategy,
715
717
  ...organizationDomain.verification_prefix !== void 0 && { verificationPrefix: organizationDomain.verification_prefix },
716
- createdAt: organizationDomain.created_at,
717
- updatedAt: organizationDomain.updated_at
718
+ createdAt: new Date(organizationDomain.created_at),
719
+ updatedAt: new Date(organizationDomain.updated_at)
718
720
  });
719
721
  //#endregion
720
722
  //#region src/organizations/serializers/organization.serializer.ts
@@ -725,8 +727,8 @@ const deserializeOrganization = (organization) => ({
725
727
  allowProfilesOutsideOrganization: organization.allow_profiles_outside_organization,
726
728
  domains: organization.domains.map(deserializeOrganizationDomain),
727
729
  ...typeof organization.stripe_customer_id === "undefined" ? void 0 : { stripeCustomerId: organization.stripe_customer_id },
728
- createdAt: organization.created_at,
729
- updatedAt: organization.updated_at,
730
+ createdAt: new Date(organization.created_at),
731
+ updatedAt: new Date(organization.updated_at),
730
732
  externalId: organization.external_id ?? null,
731
733
  metadata: organization.metadata ?? {}
732
734
  });
@@ -845,9 +847,9 @@ const serializeAuthenticateWithTotpOptions = (options) => ({
845
847
  //#endregion
846
848
  //#region src/user-management/serializers/authentication-event.serializer.ts
847
849
  const deserializeAuthenticationEventSso = (sso) => ({
848
- connectionId: sso.connection_id,
849
- organizationId: sso.organization_id,
850
- ...sso.session_id !== void 0 && { sessionId: sso.session_id }
850
+ connectionId: sso.connection_id ?? null,
851
+ organizationId: sso.organization_id ?? null,
852
+ sessionId: sso.session_id ?? null
851
853
  });
852
854
  const deserializeAuthenticationEvent = (authenticationEvent) => ({
853
855
  email: authenticationEvent.email,
@@ -884,8 +886,8 @@ const deserializeTotpWithSecrets = (totp) => {
884
886
  const deserializeFactor$1 = (factor) => ({
885
887
  object: factor.object,
886
888
  id: factor.id,
887
- createdAt: factor.created_at,
888
- updatedAt: factor.updated_at,
889
+ createdAt: new Date(factor.created_at),
890
+ updatedAt: new Date(factor.updated_at),
889
891
  type: factor.type,
890
892
  ...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
891
893
  ...factor.totp ? { totp: deserializeTotp(factor.totp) } : {},
@@ -894,8 +896,8 @@ const deserializeFactor$1 = (factor) => ({
894
896
  const deserializeFactorWithSecrets$1 = (factor) => ({
895
897
  object: factor.object,
896
898
  id: factor.id,
897
- createdAt: factor.created_at,
898
- updatedAt: factor.updated_at,
899
+ createdAt: new Date(factor.created_at),
900
+ updatedAt: new Date(factor.updated_at),
899
901
  type: factor.type,
900
902
  totp: deserializeTotpWithSecrets(factor.totp),
901
903
  userId: factor.user_id
@@ -919,10 +921,10 @@ const deserializeUser = (user) => ({
919
921
  firstName: user.first_name,
920
922
  profilePictureUrl: user.profile_picture_url,
921
923
  lastName: user.last_name,
922
- lastSignInAt: user.last_sign_in_at,
924
+ lastSignInAt: user.last_sign_in_at != null ? new Date(user.last_sign_in_at) : null,
923
925
  locale: user.locale,
924
- createdAt: user.created_at,
925
- updatedAt: user.updated_at,
926
+ createdAt: new Date(user.created_at),
927
+ updatedAt: new Date(user.updated_at),
926
928
  externalId: user.external_id ?? null,
927
929
  metadata: user.metadata ?? {}
928
930
  });
@@ -971,19 +973,19 @@ const deserializeEmailVerification = (emailVerification) => ({
971
973
  id: emailVerification.id,
972
974
  userId: emailVerification.user_id,
973
975
  email: emailVerification.email,
974
- expiresAt: emailVerification.expires_at,
976
+ expiresAt: new Date(emailVerification.expires_at),
975
977
  code: emailVerification.code,
976
- createdAt: emailVerification.created_at,
977
- updatedAt: emailVerification.updated_at
978
+ createdAt: new Date(emailVerification.created_at),
979
+ updatedAt: new Date(emailVerification.updated_at)
978
980
  });
979
981
  const deserializeEmailVerificationEvent = (emailVerification) => ({
980
982
  object: emailVerification.object,
981
983
  id: emailVerification.id,
982
984
  userId: emailVerification.user_id,
983
985
  email: emailVerification.email,
984
- expiresAt: emailVerification.expires_at,
985
- createdAt: emailVerification.created_at,
986
- updatedAt: emailVerification.updated_at
986
+ expiresAt: new Date(emailVerification.expires_at),
987
+ createdAt: new Date(emailVerification.created_at),
988
+ updatedAt: new Date(emailVerification.updated_at)
987
989
  });
988
990
  //#endregion
989
991
  //#region src/user-management/serializers/enroll-auth-factor-options.serializer.ts
@@ -1000,32 +1002,32 @@ const deserializeInvitation = (invitation) => ({
1000
1002
  id: invitation.id,
1001
1003
  email: invitation.email,
1002
1004
  state: invitation.state,
1003
- acceptedAt: invitation.accepted_at,
1004
- revokedAt: invitation.revoked_at,
1005
- expiresAt: invitation.expires_at,
1005
+ acceptedAt: invitation.accepted_at != null ? new Date(invitation.accepted_at) : null,
1006
+ revokedAt: invitation.revoked_at != null ? new Date(invitation.revoked_at) : null,
1007
+ expiresAt: new Date(invitation.expires_at),
1006
1008
  organizationId: invitation.organization_id,
1007
1009
  inviterUserId: invitation.inviter_user_id,
1008
1010
  acceptedUserId: invitation.accepted_user_id,
1009
1011
  roleSlug: invitation.role_slug,
1010
1012
  token: invitation.token,
1011
1013
  acceptInvitationUrl: invitation.accept_invitation_url,
1012
- createdAt: invitation.created_at,
1013
- updatedAt: invitation.updated_at
1014
+ createdAt: new Date(invitation.created_at),
1015
+ updatedAt: new Date(invitation.updated_at)
1014
1016
  });
1015
1017
  const deserializeInvitationEvent = (invitation) => ({
1016
1018
  object: invitation.object,
1017
1019
  id: invitation.id,
1018
1020
  email: invitation.email,
1019
1021
  state: invitation.state,
1020
- acceptedAt: invitation.accepted_at,
1021
- revokedAt: invitation.revoked_at,
1022
- expiresAt: invitation.expires_at,
1022
+ acceptedAt: invitation.accepted_at != null ? new Date(invitation.accepted_at) : null,
1023
+ revokedAt: invitation.revoked_at != null ? new Date(invitation.revoked_at) : null,
1024
+ expiresAt: new Date(invitation.expires_at),
1023
1025
  organizationId: invitation.organization_id,
1024
1026
  inviterUserId: invitation.inviter_user_id,
1025
1027
  acceptedUserId: invitation.accepted_user_id,
1026
1028
  roleSlug: invitation.role_slug,
1027
- createdAt: invitation.created_at,
1028
- updatedAt: invitation.updated_at
1029
+ createdAt: new Date(invitation.created_at),
1030
+ updatedAt: new Date(invitation.updated_at)
1029
1031
  });
1030
1032
  //#endregion
1031
1033
  //#region src/user-management/serializers/list-sessions-options.serializer.ts
@@ -1048,19 +1050,19 @@ const deserializeMagicAuth = (magicAuth) => ({
1048
1050
  id: magicAuth.id,
1049
1051
  userId: magicAuth.user_id,
1050
1052
  email: magicAuth.email,
1051
- expiresAt: magicAuth.expires_at,
1053
+ expiresAt: new Date(magicAuth.expires_at),
1052
1054
  code: magicAuth.code,
1053
- createdAt: magicAuth.created_at,
1054
- updatedAt: magicAuth.updated_at
1055
+ createdAt: new Date(magicAuth.created_at),
1056
+ updatedAt: new Date(magicAuth.updated_at)
1055
1057
  });
1056
1058
  const deserializeMagicAuthEvent = (magicAuth) => ({
1057
1059
  object: magicAuth.object,
1058
1060
  id: magicAuth.id,
1059
1061
  userId: magicAuth.user_id,
1060
1062
  email: magicAuth.email,
1061
- expiresAt: magicAuth.expires_at,
1062
- createdAt: magicAuth.created_at,
1063
- updatedAt: magicAuth.updated_at
1063
+ expiresAt: new Date(magicAuth.expires_at),
1064
+ createdAt: new Date(magicAuth.created_at),
1065
+ updatedAt: new Date(magicAuth.updated_at)
1064
1066
  });
1065
1067
  //#endregion
1066
1068
  //#region src/user-management/serializers/password-reset.serializer.ts
@@ -1071,16 +1073,16 @@ const deserializePasswordReset = (passwordReset) => ({
1071
1073
  email: passwordReset.email,
1072
1074
  passwordResetToken: passwordReset.password_reset_token,
1073
1075
  passwordResetUrl: passwordReset.password_reset_url,
1074
- expiresAt: passwordReset.expires_at,
1075
- createdAt: passwordReset.created_at
1076
+ expiresAt: new Date(passwordReset.expires_at),
1077
+ createdAt: new Date(passwordReset.created_at)
1076
1078
  });
1077
1079
  const deserializePasswordResetEvent = (passwordReset) => ({
1078
1080
  object: passwordReset.object,
1079
1081
  id: passwordReset.id,
1080
1082
  userId: passwordReset.user_id,
1081
1083
  email: passwordReset.email,
1082
- expiresAt: passwordReset.expires_at,
1083
- createdAt: passwordReset.created_at
1084
+ expiresAt: new Date(passwordReset.expires_at),
1085
+ createdAt: new Date(passwordReset.created_at)
1084
1086
  });
1085
1087
  //#endregion
1086
1088
  //#region src/user-management/serializers/reset-password-options.serializer.ts
@@ -1100,10 +1102,10 @@ const deserializeSession = (session) => ({
1100
1102
  ...session.impersonator !== void 0 && { impersonator: session.impersonator },
1101
1103
  authMethod: session.auth_method,
1102
1104
  status: session.status,
1103
- expiresAt: session.expires_at,
1104
- endedAt: session.ended_at,
1105
- createdAt: session.created_at,
1106
- updatedAt: session.updated_at
1105
+ expiresAt: new Date(session.expires_at),
1106
+ endedAt: session.ended_at != null ? new Date(session.ended_at) : null,
1107
+ createdAt: new Date(session.created_at),
1108
+ updatedAt: new Date(session.updated_at)
1107
1109
  });
1108
1110
  //#endregion
1109
1111
  //#region src/user-management/serializers/create-user-options.serializer.ts
@@ -1159,11 +1161,11 @@ function deserializeUserApiKey(apiKey) {
1159
1161
  },
1160
1162
  name: apiKey.name,
1161
1163
  obfuscatedValue: apiKey.obfuscated_value,
1162
- lastUsedAt: apiKey.last_used_at,
1163
- expiresAt: apiKey.expires_at,
1164
+ lastUsedAt: apiKey.last_used_at != null ? new Date(apiKey.last_used_at) : null,
1165
+ expiresAt: apiKey.expires_at != null ? new Date(apiKey.expires_at) : null,
1164
1166
  permissions: apiKey.permissions,
1165
- createdAt: apiKey.created_at,
1166
- updatedAt: apiKey.updated_at
1167
+ createdAt: new Date(apiKey.created_at),
1168
+ updatedAt: new Date(apiKey.updated_at)
1167
1169
  };
1168
1170
  }
1169
1171
  //#endregion
@@ -1179,8 +1181,8 @@ function deserializeUserApiKeyWithValue(apiKey) {
1179
1181
  const deserializeWaitlist = (waitlist) => ({
1180
1182
  object: waitlist.object,
1181
1183
  id: waitlist.id,
1182
- createdAt: waitlist.created_at,
1183
- updatedAt: waitlist.updated_at
1184
+ createdAt: new Date(waitlist.created_at),
1185
+ updatedAt: new Date(waitlist.updated_at)
1184
1186
  });
1185
1187
  //#endregion
1186
1188
  //#region src/user-management/serializers/waitlist-entry.serializer.ts
@@ -1189,11 +1191,24 @@ const deserializeWaitlistEntry = (waitlistEntry) => ({
1189
1191
  id: waitlistEntry.id,
1190
1192
  email: waitlistEntry.email,
1191
1193
  state: waitlistEntry.state,
1192
- approvedAt: waitlistEntry.approved_at,
1194
+ approvedAt: waitlistEntry.approved_at != null ? new Date(waitlistEntry.approved_at) : null,
1193
1195
  additionalFields: waitlistEntry.additional_fields,
1194
1196
  waitlistId: waitlistEntry.waitlist_id ?? null,
1195
- createdAt: waitlistEntry.created_at,
1196
- updatedAt: waitlistEntry.updated_at
1197
+ createdAt: new Date(waitlistEntry.created_at),
1198
+ updatedAt: new Date(waitlistEntry.updated_at)
1199
+ });
1200
+ //#endregion
1201
+ //#region src/user-management/serializers/waitlist-user-event.serializer.ts
1202
+ const deserializeWaitlistUserEvent = (data) => ({
1203
+ object: data.object,
1204
+ id: data.id,
1205
+ email: data.email,
1206
+ state: data.state,
1207
+ approvedAt: data.approved_at != null ? new Date(data.approved_at) : null,
1208
+ additionalFields: data.additional_fields,
1209
+ waitlistId: data.waitlist_id ?? null,
1210
+ createdAt: new Date(data.created_at),
1211
+ updatedAt: new Date(data.updated_at)
1197
1212
  });
1198
1213
  //#endregion
1199
1214
  //#region src/user-management/serializers/organization-membership.serializer.ts
@@ -1205,11 +1220,12 @@ const deserializeOrganizationMembership = (organizationMembership) => ({
1205
1220
  organizationName: organizationMembership.organization_name,
1206
1221
  status: organizationMembership.status,
1207
1222
  directoryManaged: organizationMembership.directory_managed ?? false,
1208
- createdAt: organizationMembership.created_at,
1209
- updatedAt: organizationMembership.updated_at,
1223
+ createdAt: new Date(organizationMembership.created_at),
1224
+ updatedAt: new Date(organizationMembership.updated_at),
1210
1225
  role: organizationMembership.role,
1211
1226
  ...organizationMembership.roles && { roles: organizationMembership.roles },
1212
- customAttributes: organizationMembership.custom_attributes ?? {}
1227
+ customAttributes: organizationMembership.custom_attributes ?? {},
1228
+ ...organizationMembership.user && { user: deserializeUser(organizationMembership.user) }
1213
1229
  });
1214
1230
  const deserializeAuthorizationOrganizationMembership = (organizationMembership) => ({
1215
1231
  object: organizationMembership.object,
@@ -1218,8 +1234,8 @@ const deserializeAuthorizationOrganizationMembership = (organizationMembership)
1218
1234
  organizationId: organizationMembership.organization_id,
1219
1235
  status: organizationMembership.status,
1220
1236
  directoryManaged: organizationMembership.directory_managed ?? false,
1221
- createdAt: organizationMembership.created_at,
1222
- updatedAt: organizationMembership.updated_at,
1237
+ createdAt: new Date(organizationMembership.created_at),
1238
+ updatedAt: new Date(organizationMembership.updated_at),
1223
1239
  customAttributes: organizationMembership.custom_attributes ?? {}
1224
1240
  });
1225
1241
  //#endregion
@@ -1325,9 +1341,11 @@ var AutoPaginatable = class {
1325
1341
  return this.list.listMetadata;
1326
1342
  }
1327
1343
  async *generatePages(params) {
1344
+ const { before, ...options } = this.options;
1328
1345
  const result = await this.apiCall({
1329
- ...this.options,
1346
+ ...options,
1330
1347
  limit: 100,
1348
+ ...params.before ? { before } : {},
1331
1349
  after: params.after
1332
1350
  });
1333
1351
  yield result.data;
@@ -1343,32 +1361,227 @@ var AutoPaginatable = class {
1343
1361
  async autoPagination() {
1344
1362
  if (this.options.limit) return this.data;
1345
1363
  const results = [];
1346
- for await (const page of this.generatePages({ after: this.options.after })) results.push(...page);
1364
+ for await (const page of this.generatePages({
1365
+ before: this.options.before,
1366
+ after: this.options.after
1367
+ })) results.push(...page);
1347
1368
  return results;
1348
1369
  }
1349
1370
  };
1350
1371
  //#endregion
1351
- //#region src/directory-sync/serializers/directory-group.serializer.ts
1352
- const deserializeDirectoryGroup = (directoryGroup) => ({
1353
- id: directoryGroup.id,
1354
- idpId: directoryGroup.idp_id,
1355
- directoryId: directoryGroup.directory_id,
1356
- organizationId: directoryGroup.organization_id,
1357
- name: directoryGroup.name,
1358
- createdAt: directoryGroup.created_at,
1359
- updatedAt: directoryGroup.updated_at,
1360
- rawAttributes: directoryGroup.raw_attributes
1372
+ //#region src/agents/serializers/agent-blueprint.serializer.ts
1373
+ function deserializeAgentBlueprint(blueprint) {
1374
+ return {
1375
+ object: blueprint.object,
1376
+ id: blueprint.id,
1377
+ name: blueprint.name,
1378
+ description: blueprint.description,
1379
+ permissions: blueprint.permissions,
1380
+ invocableBy: {
1381
+ roleSlugs: blueprint.invocable_by.role_slugs,
1382
+ organizationIds: blueprint.invocable_by.organization_ids
1383
+ },
1384
+ sessionSettings: {
1385
+ maxAgeSeconds: blueprint.session_settings.max_age_seconds,
1386
+ accessTokenTtlSeconds: blueprint.session_settings.access_token_ttl_seconds,
1387
+ refreshTokenTtlSeconds: blueprint.session_settings.refresh_token_ttl_seconds
1388
+ },
1389
+ createdAt: new Date(blueprint.created_at),
1390
+ updatedAt: new Date(blueprint.updated_at)
1391
+ };
1392
+ }
1393
+ function serializeCreateAgentBlueprintOptions(options) {
1394
+ return {
1395
+ name: options.name,
1396
+ ...options.description !== void 0 && { description: options.description },
1397
+ ...options.permissions !== void 0 && { permissions: options.permissions },
1398
+ ...options.invocableBy !== void 0 && { invocable_by: {
1399
+ ...options.invocableBy.roleSlugs !== void 0 && { role_slugs: options.invocableBy.roleSlugs },
1400
+ ...options.invocableBy.organizationIds !== void 0 && { organization_ids: options.invocableBy.organizationIds }
1401
+ } },
1402
+ session_settings: {
1403
+ max_age_seconds: options.sessionSettings.maxAgeSeconds,
1404
+ access_token_ttl_seconds: options.sessionSettings.accessTokenTtlSeconds,
1405
+ refresh_token_ttl_seconds: options.sessionSettings.refreshTokenTtlSeconds
1406
+ }
1407
+ };
1408
+ }
1409
+ function serializeUpdateAgentBlueprintOptions(options) {
1410
+ return {
1411
+ ...options.name !== void 0 && { name: options.name },
1412
+ ...options.description !== void 0 && { description: options.description },
1413
+ ...options.permissions !== void 0 && { permissions: options.permissions },
1414
+ ...options.invocableBy !== void 0 && { invocable_by: {
1415
+ ...options.invocableBy.roleSlugs !== void 0 && { role_slugs: options.invocableBy.roleSlugs },
1416
+ ...options.invocableBy.organizationIds !== void 0 && { organization_ids: options.invocableBy.organizationIds }
1417
+ } },
1418
+ ...options.sessionSettings !== void 0 && { session_settings: {
1419
+ ...options.sessionSettings.maxAgeSeconds !== void 0 && { max_age_seconds: options.sessionSettings.maxAgeSeconds },
1420
+ ...options.sessionSettings.accessTokenTtlSeconds !== void 0 && { access_token_ttl_seconds: options.sessionSettings.accessTokenTtlSeconds },
1421
+ ...options.sessionSettings.refreshTokenTtlSeconds !== void 0 && { refresh_token_ttl_seconds: options.sessionSettings.refreshTokenTtlSeconds }
1422
+ } }
1423
+ };
1424
+ }
1425
+ //#endregion
1426
+ //#region src/agents/serializers/agent-event.serializer.ts
1427
+ const deserializeAgentBlueprintEvent = (data) => ({
1428
+ ...deserializeAgentBlueprint(data),
1429
+ invocableAs: { instanceTypes: data.invocable_as.instance_types }
1430
+ });
1431
+ const deserializeAgentBlueprintDeletedEvent = (data) => ({
1432
+ object: data.object,
1433
+ id: data.id,
1434
+ name: data.name,
1435
+ createdAt: new Date(data.created_at),
1436
+ updatedAt: new Date(data.updated_at)
1437
+ });
1438
+ const deserializeAgentInstanceSessionEvent = (data) => ({
1439
+ object: data.object,
1440
+ id: data.id,
1441
+ agentInstanceId: data.agent_instance_id,
1442
+ organizationId: data.organization_id,
1443
+ expiresAt: new Date(data.expires_at),
1444
+ revokedAt: data.revoked_at != null ? new Date(data.revoked_at) : null,
1445
+ createdAt: new Date(data.created_at),
1446
+ updatedAt: new Date(data.updated_at)
1447
+ });
1448
+ const deserializeAgentInstanceSessionCreatedEvent = (data) => ({
1449
+ ...deserializeAgentInstanceSessionEvent(data),
1450
+ permissionSlugs: data.permission_slugs
1451
+ });
1452
+ const deserializeAgentRegistrationCreatedEvent = (data) => ({
1453
+ object: data.object,
1454
+ id: data.id,
1455
+ agentIdentity: {
1456
+ object: data.agent_identity.object,
1457
+ id: data.agent_identity.id,
1458
+ userlandUserId: data.agent_identity.userland_user_id
1459
+ },
1460
+ organizationId: data.organization_id,
1461
+ status: data.status,
1462
+ kind: data.kind,
1463
+ method: data.method,
1464
+ createdAt: new Date(data.created_at),
1465
+ updatedAt: new Date(data.updated_at)
1466
+ });
1467
+ const deserializeAgentRegistrationClaimAttemptCreatedEvent = (data) => ({
1468
+ object: data.object,
1469
+ id: data.id,
1470
+ agentRegistrationId: data.agent_registration_id,
1471
+ agentRegistrationClaimId: data.agent_registration_claim_id,
1472
+ loginHint: data.login_hint,
1473
+ expiresAt: new Date(data.expires_at),
1474
+ createdAt: new Date(data.created_at),
1475
+ updatedAt: new Date(data.updated_at)
1476
+ });
1477
+ const deserializeAgentRegistrationClaimCompletedEvent = (data) => ({
1478
+ object: data.object,
1479
+ id: data.id,
1480
+ agentRegistrationId: data.agent_registration_id,
1481
+ completedByAttemptId: data.completed_by_attempt_id,
1482
+ claimedBy: {
1483
+ userId: data.claimed_by.user_id,
1484
+ organizationId: data.claimed_by.organization_id
1485
+ },
1486
+ completedAt: new Date(data.completed_at),
1487
+ createdAt: new Date(data.created_at),
1488
+ updatedAt: new Date(data.updated_at)
1361
1489
  });
1362
- const deserializeUpdatedEventDirectoryGroup = (directoryGroup) => ({
1363
- id: directoryGroup.id,
1364
- idpId: directoryGroup.idp_id,
1365
- directoryId: directoryGroup.directory_id,
1366
- organizationId: directoryGroup.organization_id,
1367
- name: directoryGroup.name,
1368
- createdAt: directoryGroup.created_at,
1369
- updatedAt: directoryGroup.updated_at,
1370
- rawAttributes: directoryGroup.raw_attributes,
1371
- previousAttributes: directoryGroup.previous_attributes
1490
+ const deserializeAgentRegistrationCredentialDetail = (detail) => {
1491
+ switch (detail.kind) {
1492
+ case "api_key": return {
1493
+ kind: detail.kind,
1494
+ apiKeyId: detail.api_key_id
1495
+ };
1496
+ case "access_token": return {
1497
+ kind: detail.kind,
1498
+ jti: detail.jti,
1499
+ expiresAt: detail.expires_at != null ? new Date(detail.expires_at) : null
1500
+ };
1501
+ }
1502
+ };
1503
+ const deserializeAgentRegistrationCredentialIssuedEvent = (data) => ({
1504
+ object: data.object,
1505
+ id: data.id,
1506
+ agentRegistrationId: data.agent_registration_id,
1507
+ detail: deserializeAgentRegistrationCredentialDetail(data.detail),
1508
+ createdAt: new Date(data.created_at),
1509
+ updatedAt: new Date(data.updated_at)
1510
+ });
1511
+ const deserializeAgentRegistrationOrganizationSwitchedEvent = (data) => ({
1512
+ agentRegistrationId: data.agent_registration_id,
1513
+ fromOrganizationId: data.from_organization_id,
1514
+ toOrganizationId: data.to_organization_id
1515
+ });
1516
+ const deserializeAgentRegistrationLifecycleEvent = (data) => ({ agentRegistrationId: data.agent_registration_id });
1517
+ //#endregion
1518
+ //#region src/agents/serializers/agent-instance.serializer.ts
1519
+ function deserializeAgentInstance(instance) {
1520
+ return {
1521
+ object: instance.object,
1522
+ id: instance.id,
1523
+ agentBlueprintId: instance.agent_blueprint_id,
1524
+ organizationId: instance.organization_id,
1525
+ organizationMembershipId: instance.organization_membership_id,
1526
+ type: instance.type,
1527
+ createdAt: new Date(instance.created_at),
1528
+ updatedAt: new Date(instance.updated_at)
1529
+ };
1530
+ }
1531
+ function serializeListAgentInstancesOptions(options) {
1532
+ return {
1533
+ organization_id: options.organizationId,
1534
+ agent_blueprint_id: options.agentBlueprintId,
1535
+ limit: options.limit,
1536
+ before: options.before,
1537
+ after: options.after,
1538
+ order: options.order
1539
+ };
1540
+ }
1541
+ //#endregion
1542
+ //#region src/directory-sync/serializers/directory-metadata-user.serializer.ts
1543
+ const deserializeDirectoryMetadataUser = (response) => ({
1544
+ active: response.active,
1545
+ inactive: response.inactive
1546
+ });
1547
+ //#endregion
1548
+ //#region src/directory-sync/serializers/directory-metadata.serializer.ts
1549
+ const deserializeDirectoryMetadata = (response) => ({
1550
+ users: deserializeDirectoryMetadataUser(response.users),
1551
+ groups: response.groups
1552
+ });
1553
+ //#endregion
1554
+ //#region src/directory-sync/serializers/directory.serializer.ts
1555
+ const deserializeDirectoryState = (value) => {
1556
+ if (value === "linked") return "active";
1557
+ if (value === "unlinked") return "inactive";
1558
+ return value;
1559
+ };
1560
+ const deserializeDirectory = (response) => ({
1561
+ object: response.object,
1562
+ id: response.id,
1563
+ organizationId: response.organization_id,
1564
+ externalKey: response.external_key,
1565
+ type: response.type,
1566
+ state: deserializeDirectoryState(response.state),
1567
+ name: response.name,
1568
+ domain: response.domain,
1569
+ metadata: response.metadata != null ? deserializeDirectoryMetadata(response.metadata) : void 0,
1570
+ createdAt: new Date(response.created_at),
1571
+ updatedAt: new Date(response.updated_at)
1572
+ });
1573
+ //#endregion
1574
+ //#region src/directory-sync/serializers/directory-group.serializer.ts
1575
+ const deserializeDirectoryGroup = (response) => ({
1576
+ object: response.object,
1577
+ id: response.id,
1578
+ idpId: response.idp_id,
1579
+ directoryId: response.directory_id,
1580
+ organizationId: response.organization_id,
1581
+ name: response.name,
1582
+ rawAttributes: response.raw_attributes,
1583
+ createdAt: new Date(response.created_at),
1584
+ updatedAt: new Date(response.updated_at)
1372
1585
  });
1373
1586
  //#endregion
1374
1587
  //#region src/directory-sync/serializers/directory-user.serializer.ts
@@ -1383,11 +1596,12 @@ const deserializeDirectoryUser = (directoryUser) => ({
1383
1596
  firstName: directoryUser.first_name,
1384
1597
  email: directoryUser.email,
1385
1598
  lastName: directoryUser.last_name,
1599
+ name: directoryUser.name ?? null,
1386
1600
  state: directoryUser.state,
1387
1601
  ...directoryUser.role !== void 0 && { role: directoryUser.role },
1388
1602
  ...directoryUser.roles !== void 0 && { roles: directoryUser.roles },
1389
- createdAt: directoryUser.created_at,
1390
- updatedAt: directoryUser.updated_at
1603
+ createdAt: new Date(directoryUser.created_at),
1604
+ updatedAt: new Date(directoryUser.updated_at)
1391
1605
  });
1392
1606
  const deserializeDirectoryUserWithGroups = (directoryUserWithGroups) => ({
1393
1607
  ...deserializeDirectoryUser(directoryUserWithGroups),
@@ -1404,32 +1618,16 @@ const deserializeUpdatedEventDirectoryUser = (directoryUser) => ({
1404
1618
  firstName: directoryUser.first_name,
1405
1619
  email: directoryUser.email,
1406
1620
  lastName: directoryUser.last_name,
1621
+ name: directoryUser.name ?? null,
1407
1622
  state: directoryUser.state,
1408
1623
  ...directoryUser.role !== void 0 && { role: directoryUser.role },
1409
1624
  ...directoryUser.roles !== void 0 && { roles: directoryUser.roles },
1410
- createdAt: directoryUser.created_at,
1411
- updatedAt: directoryUser.updated_at,
1625
+ createdAt: new Date(directoryUser.created_at),
1626
+ updatedAt: new Date(directoryUser.updated_at),
1412
1627
  previousAttributes: directoryUser.previous_attributes
1413
1628
  });
1414
1629
  //#endregion
1415
- //#region src/directory-sync/serializers/directory.serializer.ts
1416
- const deserializeDirectory = (directory) => ({
1417
- object: directory.object,
1418
- id: directory.id,
1419
- domain: directory.domain,
1420
- externalKey: directory.external_key,
1421
- name: directory.name,
1422
- organizationId: directory.organization_id,
1423
- state: deserializeDirectoryState(directory.state),
1424
- type: directory.type,
1425
- createdAt: directory.created_at,
1426
- updatedAt: directory.updated_at
1427
- });
1428
- const deserializeDirectoryState = (state) => {
1429
- if (state === "linked") return "active";
1430
- if (state === "unlinked") return "inactive";
1431
- return state;
1432
- };
1630
+ //#region src/directory-sync/serializers/event-directory.serializer.ts
1433
1631
  const deserializeEventDirectory = (directory) => ({
1434
1632
  object: directory.object,
1435
1633
  id: directory.id,
@@ -1439,8 +1637,8 @@ const deserializeEventDirectory = (directory) => ({
1439
1637
  name: directory.name,
1440
1638
  organizationId: directory.organization_id,
1441
1639
  domains: directory.domains,
1442
- createdAt: directory.created_at,
1443
- updatedAt: directory.updated_at
1640
+ createdAt: new Date(directory.created_at),
1641
+ updatedAt: new Date(directory.updated_at)
1444
1642
  });
1445
1643
  const deserializeDeletedEventDirectory = (directory) => ({
1446
1644
  object: directory.object,
@@ -1449,18 +1647,22 @@ const deserializeDeletedEventDirectory = (directory) => ({
1449
1647
  state: directory.state,
1450
1648
  name: directory.name,
1451
1649
  organizationId: directory.organization_id,
1452
- createdAt: directory.created_at,
1453
- updatedAt: directory.updated_at
1650
+ createdAt: new Date(directory.created_at),
1651
+ updatedAt: new Date(directory.updated_at)
1652
+ });
1653
+ const deserializeUpdatedEventDirectoryGroup = (directoryGroup) => ({
1654
+ ...deserializeDirectoryGroup(directoryGroup),
1655
+ previousAttributes: directoryGroup.previous_attributes
1454
1656
  });
1455
1657
  //#endregion
1456
- //#region src/directory-sync/serializers/list-directories-options.serializer.ts
1457
- const serializeListDirectoriesOptions = (options) => ({
1458
- organization_id: options.organizationId,
1459
- search: options.search,
1460
- limit: options.limit,
1461
- before: options.before,
1462
- after: options.after,
1463
- order: options.order
1658
+ //#region src/directory-sync/serializers/directory-token.serializer.ts
1659
+ const deserializeDirectoryToken = (token) => ({
1660
+ object: token.object,
1661
+ id: token.id,
1662
+ directoryId: token.directory_id,
1663
+ ...token.organization_id !== void 0 && { organizationId: token.organization_id },
1664
+ tokenSuffix: token.token_suffix,
1665
+ createdAt: new Date(token.created_at)
1464
1666
  });
1465
1667
  //#endregion
1466
1668
  //#region src/organizations/serializers/create-organization-options.serializer.ts
@@ -1480,8 +1682,8 @@ const deserializeItContact = (itContact) => ({
1480
1682
  object: itContact.object,
1481
1683
  id: itContact.id,
1482
1684
  email: itContact.email,
1483
- createdAt: itContact.created_at,
1484
- updatedAt: itContact.updated_at
1685
+ createdAt: new Date(itContact.created_at),
1686
+ updatedAt: new Date(itContact.updated_at)
1485
1687
  });
1486
1688
  //#endregion
1487
1689
  //#region src/organizations/serializers/update-organization-options.serializer.ts
@@ -1502,8 +1704,31 @@ const deserializeConnection = (connection) => ({
1502
1704
  type: connection.connection_type,
1503
1705
  state: connection.state,
1504
1706
  domains: connection.domains,
1505
- createdAt: connection.created_at,
1506
- updatedAt: connection.updated_at
1707
+ createdAt: new Date(connection.created_at),
1708
+ updatedAt: new Date(connection.updated_at)
1709
+ });
1710
+ //#endregion
1711
+ //#region src/sso/serializers/connection-event.serializer.ts
1712
+ const deserializeConnectionEventConnection = (connection) => ({
1713
+ id: connection.id,
1714
+ ...connection.organization_id !== void 0 && { organizationId: connection.organization_id }
1715
+ });
1716
+ const deserializeConnectionSamlCertificateRenewalRequiredEvent = (data) => ({
1717
+ connection: deserializeConnectionEventConnection(data.connection),
1718
+ certificate: {
1719
+ certificateType: data.certificate.certificate_type,
1720
+ expiryDate: new Date(data.certificate.expiry_date),
1721
+ isExpired: data.certificate.is_expired
1722
+ },
1723
+ daysUntilExpiry: data.days_until_expiry
1724
+ });
1725
+ const deserializeConnectionSamlCertificateRenewedEvent = (data) => ({
1726
+ connection: deserializeConnectionEventConnection(data.connection),
1727
+ certificate: {
1728
+ certificateType: data.certificate.certificate_type,
1729
+ expiryDate: new Date(data.certificate.expiry_date)
1730
+ },
1731
+ renewedAt: new Date(data.renewed_at)
1507
1732
  });
1508
1733
  //#endregion
1509
1734
  //#region src/sso/serializers/list-connections-options.serializer.ts
@@ -1519,20 +1744,21 @@ const serializeListConnectionsOptions = (options) => ({
1519
1744
  //#endregion
1520
1745
  //#region src/sso/serializers/profile.serializer.ts
1521
1746
  const deserializeProfile = (profile) => ({
1747
+ object: profile.object,
1522
1748
  id: profile.id,
1523
1749
  idpId: profile.idp_id,
1524
- ...profile.organization_id !== void 0 && { organizationId: profile.organization_id },
1750
+ organizationId: profile.organization_id ?? null,
1525
1751
  connectionId: profile.connection_id,
1526
1752
  connectionType: profile.connection_type,
1527
1753
  email: profile.email,
1528
- ...profile.name !== void 0 && { name: profile.name },
1529
- ...profile.first_name !== void 0 && { firstName: profile.first_name },
1530
- ...profile.last_name !== void 0 && { lastName: profile.last_name },
1754
+ name: profile.name ?? null,
1755
+ firstName: profile.first_name ?? null,
1756
+ lastName: profile.last_name ?? null,
1531
1757
  ...profile.role !== void 0 && { role: profile.role },
1532
1758
  ...profile.roles !== void 0 && { roles: profile.roles },
1533
1759
  ...profile.groups !== void 0 && { groups: profile.groups },
1534
1760
  ...profile.custom_attributes !== void 0 && { customAttributes: profile.custom_attributes },
1535
- ...profile.raw_attributes !== void 0 && { rawAttributes: profile.raw_attributes }
1761
+ rawAttributes: profile.raw_attributes
1536
1762
  });
1537
1763
  //#endregion
1538
1764
  //#region src/sso/serializers/profile-and-token.serializer.ts
@@ -1548,8 +1774,8 @@ const deserializeRoleEvent = (role) => ({
1548
1774
  slug: role.slug,
1549
1775
  resourceTypeSlug: role.resource_type_slug,
1550
1776
  permissions: role.permissions,
1551
- createdAt: role.created_at,
1552
- updatedAt: role.updated_at
1777
+ createdAt: new Date(role.created_at),
1778
+ updatedAt: new Date(role.updated_at)
1553
1779
  });
1554
1780
  //#endregion
1555
1781
  //#region src/user-management/serializers/authentication-radar-risk-event-serializer.ts
@@ -1576,10 +1802,11 @@ function deserializeApiKey(apiKey) {
1576
1802
  } : apiKey.owner,
1577
1803
  name: apiKey.name,
1578
1804
  obfuscatedValue: apiKey.obfuscated_value,
1579
- lastUsedAt: apiKey.last_used_at,
1805
+ lastUsedAt: apiKey.last_used_at != null ? new Date(apiKey.last_used_at) : null,
1806
+ expiresAt: apiKey.expires_at != null ? new Date(apiKey.expires_at) : null,
1580
1807
  permissions: apiKey.permissions,
1581
- createdAt: apiKey.created_at,
1582
- updatedAt: apiKey.updated_at
1808
+ createdAt: new Date(apiKey.created_at),
1809
+ updatedAt: new Date(apiKey.updated_at)
1583
1810
  };
1584
1811
  }
1585
1812
  //#endregion
@@ -1593,8 +1820,8 @@ const deserializeRole = (role) => ({
1593
1820
  permissions: role.permissions,
1594
1821
  resourceTypeSlug: role.resource_type_slug,
1595
1822
  type: role.type,
1596
- createdAt: role.created_at,
1597
- updatedAt: role.updated_at
1823
+ createdAt: new Date(role.created_at),
1824
+ updatedAt: new Date(role.updated_at)
1598
1825
  });
1599
1826
  const deserializeOrganizationRole = (role) => ({
1600
1827
  object: role.object,
@@ -1605,8 +1832,8 @@ const deserializeOrganizationRole = (role) => ({
1605
1832
  permissions: role.permissions,
1606
1833
  resourceTypeSlug: role.resource_type_slug,
1607
1834
  type: "OrganizationRole",
1608
- createdAt: role.created_at,
1609
- updatedAt: role.updated_at
1835
+ createdAt: new Date(role.created_at),
1836
+ updatedAt: new Date(role.updated_at)
1610
1837
  });
1611
1838
  const deserializeOrganizationRoleEvent = (event) => ({
1612
1839
  object: event.object,
@@ -1616,8 +1843,8 @@ const deserializeOrganizationRoleEvent = (event) => ({
1616
1843
  description: event.description,
1617
1844
  resourceTypeSlug: event.resource_type_slug,
1618
1845
  permissions: event.permissions,
1619
- createdAt: event.created_at,
1620
- updatedAt: event.updated_at
1846
+ createdAt: new Date(event.created_at),
1847
+ updatedAt: new Date(event.updated_at)
1621
1848
  });
1622
1849
  //#endregion
1623
1850
  //#region src/authorization/serializers/permission.serializer.ts
@@ -1629,8 +1856,8 @@ const deserializePermission = (permission) => ({
1629
1856
  description: permission.description,
1630
1857
  resourceTypeSlug: permission.resource_type_slug,
1631
1858
  system: permission.system,
1632
- createdAt: permission.created_at,
1633
- updatedAt: permission.updated_at
1859
+ createdAt: new Date(permission.created_at),
1860
+ updatedAt: new Date(permission.updated_at)
1634
1861
  });
1635
1862
  //#endregion
1636
1863
  //#region src/feature-flags/serializers/feature-flag.serializer.ts
@@ -1643,8 +1870,8 @@ const deserializeFeatureFlag = (featureFlag) => ({
1643
1870
  tags: featureFlag.tags,
1644
1871
  enabled: featureFlag.enabled,
1645
1872
  defaultValue: featureFlag.default_value,
1646
- createdAt: featureFlag.created_at,
1647
- updatedAt: featureFlag.updated_at
1873
+ createdAt: new Date(featureFlag.created_at),
1874
+ updatedAt: new Date(featureFlag.updated_at)
1648
1875
  });
1649
1876
  //#endregion
1650
1877
  //#region src/groups/serializers/create-group.serializer.ts
@@ -1724,6 +1951,20 @@ const deserializeVaultByokKeyVerificationCompletedEvent = (data) => ({
1724
1951
  keyProvider: data.key_provider,
1725
1952
  verified: data.verified
1726
1953
  });
1954
+ const deserializeVaultKekDeletedEvent = (data) => ({
1955
+ ...deserializeVaultActor(data),
1956
+ keyName: data.key_name,
1957
+ keyId: data.key_id
1958
+ });
1959
+ const deserializeVaultDekRekeyedEvent = (data) => ({
1960
+ ...deserializeVaultActor(data),
1961
+ keyIds: data.key_ids,
1962
+ keyContext: data.key_context
1963
+ });
1964
+ const deserializeVaultByokKeyDeletedEvent = (data) => ({
1965
+ organizationId: data.organization_id,
1966
+ keyProvider: data.key_provider
1967
+ });
1727
1968
  //#endregion
1728
1969
  //#region src/organization-domains/serializers/organization-domain-verification-failed.serializer.ts
1729
1970
  const deserializeOrganizationDomainVerificationFailed = (organizationDomainVerificationFailed) => ({
@@ -1731,18 +1972,70 @@ const deserializeOrganizationDomainVerificationFailed = (organizationDomainVerif
1731
1972
  organizationDomain: deserializeOrganizationDomain(organizationDomainVerificationFailed.organization_domain)
1732
1973
  });
1733
1974
  //#endregion
1975
+ //#region src/actions/serializers/action-event.serializer.ts
1976
+ const deserializeActionAuthenticationDeniedEvent = (data) => ({
1977
+ actionEndpointId: data.action_endpoint_id,
1978
+ actionExecutionId: data.action_execution_id,
1979
+ type: data.type,
1980
+ verdict: data.verdict,
1981
+ userId: data.user_id,
1982
+ organizationId: data.organization_id,
1983
+ email: data.email,
1984
+ ipAddress: data.ip_address,
1985
+ userAgent: data.user_agent
1986
+ });
1987
+ const deserializeActionUserRegistrationDeniedEvent = (data) => ({
1988
+ actionEndpointId: data.action_endpoint_id,
1989
+ actionExecutionId: data.action_execution_id,
1990
+ type: data.type,
1991
+ verdict: data.verdict,
1992
+ organizationId: data.organization_id,
1993
+ email: data.email,
1994
+ ipAddress: data.ip_address,
1995
+ userAgent: data.user_agent
1996
+ });
1997
+ //#endregion
1998
+ //#region src/api-keys/serializers/api-key-event.serializer.ts
1999
+ function deserializeApiKeyUpdatedEvent(data) {
2000
+ return {
2001
+ ...deserializeApiKey(data),
2002
+ previousAttributes: { expiresAt: data.previous_attributes.expires_at != null ? new Date(data.previous_attributes.expires_at) : null }
2003
+ };
2004
+ }
2005
+ //#endregion
2006
+ //#region src/radar/serializers/radar-event.serializer.ts
2007
+ const deserializeRadarChallengeCreatedEvent = (data) => ({
2008
+ type: data.type,
2009
+ radarChallengeId: data.radar_challenge_id,
2010
+ userId: data.user_id,
2011
+ email: data.email
2012
+ });
2013
+ //#endregion
2014
+ //#region src/common/serializers/resource-export-event.serializer.ts
2015
+ const deserializeResourceExportEvent = (data) => ({
2016
+ id: data.id,
2017
+ resourceType: data.resource_type
2018
+ });
2019
+ //#endregion
1734
2020
  //#region src/common/serializers/event.serializer.ts
1735
2021
  const deserializePipesConnectedAccount = (connectedAccount) => ({
1736
2022
  object: connectedAccount.object,
1737
2023
  id: connectedAccount.id,
2024
+ ...connectedAccount.connection_role !== void 0 && { connectionRole: connectedAccount.connection_role },
2025
+ ...connectedAccount.account_identifier !== void 0 && { accountIdentifier: connectedAccount.account_identifier },
2026
+ ...connectedAccount.account_display_name !== void 0 && { accountDisplayName: connectedAccount.account_display_name },
1738
2027
  dataIntegrationId: connectedAccount.data_integration_id,
1739
2028
  providerSlug: connectedAccount.provider_slug,
1740
2029
  userId: connectedAccount.user_id,
1741
2030
  organizationId: connectedAccount.organization_id,
1742
2031
  scopes: connectedAccount.scopes,
2032
+ ...connectedAccount.auth_method !== void 0 && { authMethod: connectedAccount.auth_method },
2033
+ ...connectedAccount.api_key_last_4 !== void 0 && { apiKeyLast4: connectedAccount.api_key_last_4 },
1743
2034
  state: connectedAccount.state,
1744
- createdAt: connectedAccount.created_at,
1745
- updatedAt: connectedAccount.updated_at
2035
+ ...connectedAccount.established_by_user_id !== void 0 && { establishedByUserId: connectedAccount.established_by_user_id },
2036
+ ...connectedAccount.state_reason !== void 0 && { stateReason: connectedAccount.state_reason },
2037
+ createdAt: new Date(connectedAccount.created_at),
2038
+ updatedAt: new Date(connectedAccount.updated_at)
1746
2039
  });
1747
2040
  const deserializePipesConnectionFailed = (connectionFailed) => ({
1748
2041
  object: connectionFailed.object,
@@ -1750,22 +2043,95 @@ const deserializePipesConnectionFailed = (connectionFailed) => ({
1750
2043
  providerSlug: connectionFailed.provider_slug,
1751
2044
  userId: connectionFailed.user_id,
1752
2045
  organizationId: connectionFailed.organization_id,
2046
+ ...connectionFailed.account_identifier !== void 0 && { accountIdentifier: connectionFailed.account_identifier },
1753
2047
  errorCode: connectionFailed.error_code,
1754
2048
  errorReason: connectionFailed.error_reason,
1755
2049
  providerError: connectionFailed.provider_error,
1756
2050
  providerErrorDescription: connectionFailed.provider_error_description,
1757
- createdAt: connectionFailed.created_at
2051
+ createdAt: new Date(connectionFailed.created_at)
1758
2052
  });
1759
2053
  const deserializeEvent = (event) => {
1760
2054
  const eventBase = {
1761
2055
  id: event.id,
1762
- createdAt: event.created_at,
2056
+ createdAt: new Date(event.created_at),
1763
2057
  context: event.context
1764
2058
  };
2059
+ const knownEvent = deserializeKnownEvent(event, eventBase);
2060
+ if (knownEvent) return knownEvent;
2061
+ const unknownEvent = event;
2062
+ return {
2063
+ ...eventBase,
2064
+ event: unknownEvent.event,
2065
+ data: unknownEvent.data
2066
+ };
2067
+ };
2068
+ function deserializeKnownEvent(event, eventBase) {
1765
2069
  switch (event.event) {
2070
+ case "agent.blueprint.created":
2071
+ case "agent.blueprint.updated": return {
2072
+ ...eventBase,
2073
+ event: event.event,
2074
+ data: deserializeAgentBlueprintEvent(event.data)
2075
+ };
2076
+ case "agent.blueprint.deleted": return {
2077
+ ...eventBase,
2078
+ event: event.event,
2079
+ data: deserializeAgentBlueprintDeletedEvent(event.data)
2080
+ };
2081
+ case "agent.instance.created":
2082
+ case "agent.instance.deleted": return {
2083
+ ...eventBase,
2084
+ event: event.event,
2085
+ data: deserializeAgentInstance(event.data)
2086
+ };
2087
+ case "agent.instance.session.created": return {
2088
+ ...eventBase,
2089
+ event: event.event,
2090
+ data: deserializeAgentInstanceSessionCreatedEvent(event.data)
2091
+ };
2092
+ case "agent.instance.session.revoked": return {
2093
+ ...eventBase,
2094
+ event: event.event,
2095
+ data: deserializeAgentInstanceSessionEvent(event.data)
2096
+ };
2097
+ case "agent.registration.created": return {
2098
+ ...eventBase,
2099
+ event: event.event,
2100
+ data: deserializeAgentRegistrationCreatedEvent(event.data)
2101
+ };
2102
+ case "agent.registration.claim.attempt.created": return {
2103
+ ...eventBase,
2104
+ event: event.event,
2105
+ data: deserializeAgentRegistrationClaimAttemptCreatedEvent(event.data)
2106
+ };
2107
+ case "agent.registration.claim.completed": return {
2108
+ ...eventBase,
2109
+ event: event.event,
2110
+ data: deserializeAgentRegistrationClaimCompletedEvent(event.data)
2111
+ };
2112
+ case "agent.registration.credential.issued": return {
2113
+ ...eventBase,
2114
+ event: event.event,
2115
+ data: deserializeAgentRegistrationCredentialIssuedEvent(event.data)
2116
+ };
2117
+ case "agent.registration.organization.switched": return {
2118
+ ...eventBase,
2119
+ event: event.event,
2120
+ data: deserializeAgentRegistrationOrganizationSwitchedEvent(event.data)
2121
+ };
2122
+ case "agent.registration.refreshed":
2123
+ case "agent.registration.expired":
2124
+ case "agent.registration.revoked":
2125
+ case "agent.registration.deleted": return {
2126
+ ...eventBase,
2127
+ event: event.event,
2128
+ data: deserializeAgentRegistrationLifecycleEvent(event.data)
2129
+ };
2130
+ case "authentication.email_verification_failed":
1766
2131
  case "authentication.email_verification_succeeded":
1767
2132
  case "authentication.magic_auth_failed":
1768
2133
  case "authentication.magic_auth_succeeded":
2134
+ case "authentication.mfa_failed":
1769
2135
  case "authentication.mfa_succeeded":
1770
2136
  case "authentication.oauth_failed":
1771
2137
  case "authentication.oauth_succeeded":
@@ -1773,8 +2139,11 @@ const deserializeEvent = (event) => {
1773
2139
  case "authentication.passkey_succeeded":
1774
2140
  case "authentication.password_failed":
1775
2141
  case "authentication.password_succeeded":
2142
+ case "authentication.reauthentication_succeeded":
1776
2143
  case "authentication.sso_failed":
1777
- case "authentication.sso_succeeded": return {
2144
+ case "authentication.sso_started":
2145
+ case "authentication.sso_succeeded":
2146
+ case "authentication.sso_timed_out": return {
1778
2147
  ...eventBase,
1779
2148
  event: event.event,
1780
2149
  data: deserializeAuthenticationEvent(event.data)
@@ -2010,13 +2379,88 @@ const deserializeEvent = (event) => {
2010
2379
  event: event.event,
2011
2380
  data: deserializeVaultByokKeyVerificationCompletedEvent(event.data)
2012
2381
  };
2013
- default: return {
2382
+ case "action.authentication.denied": return {
2383
+ ...eventBase,
2384
+ event: event.event,
2385
+ data: deserializeActionAuthenticationDeniedEvent(event.data)
2386
+ };
2387
+ case "action.user_registration.denied": return {
2388
+ ...eventBase,
2389
+ event: event.event,
2390
+ data: deserializeActionUserRegistrationDeniedEvent(event.data)
2391
+ };
2392
+ case "api_key.updated": return {
2393
+ ...eventBase,
2394
+ event: event.event,
2395
+ data: deserializeApiKeyUpdatedEvent(event.data)
2396
+ };
2397
+ case "connection.saml_certificate_renewal_required": return {
2398
+ ...eventBase,
2399
+ event: event.event,
2400
+ data: deserializeConnectionSamlCertificateRenewalRequiredEvent(event.data)
2401
+ };
2402
+ case "connection.saml_certificate_renewed": return {
2403
+ ...eventBase,
2404
+ event: event.event,
2405
+ data: deserializeConnectionSamlCertificateRenewedEvent(event.data)
2406
+ };
2407
+ case "dsync.token.created":
2408
+ case "dsync.token.revoked": return {
2409
+ ...eventBase,
2410
+ event: event.event,
2411
+ data: deserializeDirectoryToken(event.data)
2412
+ };
2413
+ case "pipes.account_connection.connected":
2414
+ case "pipes.account_connection.disconnected":
2415
+ case "pipes.account_connection.reauthorization_needed": return {
2416
+ ...eventBase,
2417
+ event: event.event,
2418
+ data: deserializePipesConnectedAccount(event.data)
2419
+ };
2420
+ case "pipes.account_connection.add_failed":
2421
+ case "pipes.account_connection.connection_failed": return {
2422
+ ...eventBase,
2423
+ event: event.event,
2424
+ data: deserializePipesConnectionFailed(event.data)
2425
+ };
2426
+ case "radar.challenge_created": return {
2427
+ ...eventBase,
2428
+ event: event.event,
2429
+ data: deserializeRadarChallengeCreatedEvent(event.data)
2430
+ };
2431
+ case "resource_export.completed":
2432
+ case "resource_export.created":
2433
+ case "resource_export.downloaded":
2434
+ case "resource_export.failed": return {
2435
+ ...eventBase,
2436
+ event: event.event,
2437
+ data: deserializeResourceExportEvent(event.data)
2438
+ };
2439
+ case "vault.byok_key.deleted": return {
2440
+ ...eventBase,
2441
+ event: event.event,
2442
+ data: deserializeVaultByokKeyDeletedEvent(event.data)
2443
+ };
2444
+ case "vault.dek.rekeyed": return {
2014
2445
  ...eventBase,
2015
2446
  event: event.event,
2016
- data: event.data
2447
+ data: deserializeVaultDekRekeyedEvent(event.data)
2017
2448
  };
2449
+ case "vault.kek.deleted": return {
2450
+ ...eventBase,
2451
+ event: event.event,
2452
+ data: deserializeVaultKekDeletedEvent(event.data)
2453
+ };
2454
+ case "waitlist_user.approved":
2455
+ case "waitlist_user.created":
2456
+ case "waitlist_user.denied": return {
2457
+ ...eventBase,
2458
+ event: event.event,
2459
+ data: deserializeWaitlistUserEvent(event.data)
2460
+ };
2461
+ default: return;
2018
2462
  }
2019
- };
2463
+ }
2020
2464
  //#endregion
2021
2465
  //#region src/common/serializers/list.serializer.ts
2022
2466
  const deserializeList = (list, deserializer) => ({
@@ -2241,74 +2685,20 @@ let _josePromise;
2241
2685
  * @returns Promise that resolves to the jose module
2242
2686
  */
2243
2687
  function getJose() {
2244
- return _josePromise ??= import("./webapi-C2FQ2NNL.mjs");
2688
+ return _josePromise ??= import("./webapi-CfgZkeeN.mjs");
2245
2689
  }
2246
2690
  //#endregion
2247
- //#region src/agents/serializers/agent-blueprint.serializer.ts
2248
- function deserializeAgentBlueprint(blueprint) {
2249
- return {
2250
- object: blueprint.object,
2251
- id: blueprint.id,
2252
- name: blueprint.name,
2253
- description: blueprint.description,
2254
- permissions: blueprint.permissions,
2255
- invocableBy: {
2256
- roleSlugs: blueprint.invocable_by.role_slugs,
2257
- organizationIds: blueprint.invocable_by.organization_ids
2258
- },
2259
- sessionSettings: {
2260
- maxAgeSeconds: blueprint.session_settings.max_age_seconds,
2261
- accessTokenTtlSeconds: blueprint.session_settings.access_token_ttl_seconds,
2262
- refreshTokenTtlSeconds: blueprint.session_settings.refresh_token_ttl_seconds
2263
- },
2264
- createdAt: blueprint.created_at,
2265
- updatedAt: blueprint.updated_at
2266
- };
2267
- }
2268
- function serializeCreateAgentBlueprintOptions(options) {
2269
- return {
2270
- name: options.name,
2271
- ...options.description !== void 0 && { description: options.description },
2272
- ...options.permissions !== void 0 && { permissions: options.permissions },
2273
- ...options.invocableBy !== void 0 && { invocable_by: {
2274
- ...options.invocableBy.roleSlugs !== void 0 && { role_slugs: options.invocableBy.roleSlugs },
2275
- ...options.invocableBy.organizationIds !== void 0 && { organization_ids: options.invocableBy.organizationIds }
2276
- } },
2277
- session_settings: {
2278
- max_age_seconds: options.sessionSettings.maxAgeSeconds,
2279
- access_token_ttl_seconds: options.sessionSettings.accessTokenTtlSeconds,
2280
- refresh_token_ttl_seconds: options.sessionSettings.refreshTokenTtlSeconds
2281
- }
2282
- };
2283
- }
2284
- function serializeUpdateAgentBlueprintOptions(options) {
2285
- return {
2286
- ...options.name !== void 0 && { name: options.name },
2287
- ...options.description !== void 0 && { description: options.description },
2288
- ...options.permissions !== void 0 && { permissions: options.permissions },
2289
- ...options.invocableBy !== void 0 && { invocable_by: {
2290
- ...options.invocableBy.roleSlugs !== void 0 && { role_slugs: options.invocableBy.roleSlugs },
2291
- ...options.invocableBy.organizationIds !== void 0 && { organization_ids: options.invocableBy.organizationIds }
2292
- } },
2293
- ...options.sessionSettings !== void 0 && { session_settings: {
2294
- ...options.sessionSettings.maxAgeSeconds !== void 0 && { max_age_seconds: options.sessionSettings.maxAgeSeconds },
2295
- ...options.sessionSettings.accessTokenTtlSeconds !== void 0 && { access_token_ttl_seconds: options.sessionSettings.accessTokenTtlSeconds },
2296
- ...options.sessionSettings.refreshTokenTtlSeconds !== void 0 && { refresh_token_ttl_seconds: options.sessionSettings.refreshTokenTtlSeconds }
2297
- } }
2298
- };
2299
- }
2300
- //#endregion
2301
- //#region src/agents/serializers/agent-instance-session.serializer.ts
2302
- function deserializeAgentInstanceSession(session) {
2691
+ //#region src/agents/serializers/agent-instance-session.serializer.ts
2692
+ function deserializeAgentInstanceSession(session) {
2303
2693
  return {
2304
2694
  object: session.object,
2305
2695
  id: session.id,
2306
2696
  agentInstanceId: session.agent_instance_id,
2307
2697
  status: session.status,
2308
- expiresAt: session.expires_at,
2309
- revokedAt: session.revoked_at,
2310
- createdAt: session.created_at,
2311
- updatedAt: session.updated_at
2698
+ expiresAt: new Date(session.expires_at),
2699
+ revokedAt: session.revoked_at != null ? new Date(session.revoked_at) : null,
2700
+ createdAt: new Date(session.created_at),
2701
+ updatedAt: new Date(session.updated_at)
2312
2702
  };
2313
2703
  }
2314
2704
  function serializeListAgentInstanceSessionsOptions(options) {
@@ -2322,30 +2712,6 @@ function serializeListAgentInstanceSessionsOptions(options) {
2322
2712
  };
2323
2713
  }
2324
2714
  //#endregion
2325
- //#region src/agents/serializers/agent-instance.serializer.ts
2326
- function deserializeAgentInstance(instance) {
2327
- return {
2328
- object: instance.object,
2329
- id: instance.id,
2330
- agentBlueprintId: instance.agent_blueprint_id,
2331
- organizationId: instance.organization_id,
2332
- organizationMembershipId: instance.organization_membership_id,
2333
- type: instance.type,
2334
- createdAt: instance.created_at,
2335
- updatedAt: instance.updated_at
2336
- };
2337
- }
2338
- function serializeListAgentInstancesOptions(options) {
2339
- return {
2340
- organization_id: options.organizationId,
2341
- agent_blueprint_id: options.agentBlueprintId,
2342
- limit: options.limit,
2343
- before: options.before,
2344
- after: options.after,
2345
- order: options.order
2346
- };
2347
- }
2348
- //#endregion
2349
2715
  //#region src/agents/serializers/agent-registration.serializer.ts
2350
2716
  function deserializeAgentRegistration(registration) {
2351
2717
  return {
@@ -2353,27 +2719,28 @@ function deserializeAgentRegistration(registration) {
2353
2719
  agentIdentity: {
2354
2720
  id: registration.agent_identity.id,
2355
2721
  userlandUserId: registration.agent_identity.userland_user_id,
2356
- createdAt: registration.agent_identity.created_at,
2357
- updatedAt: registration.agent_identity.updated_at
2722
+ createdAt: new Date(registration.agent_identity.created_at),
2723
+ updatedAt: new Date(registration.agent_identity.updated_at)
2358
2724
  },
2359
2725
  organizationId: registration.organization_id,
2360
2726
  status: registration.status,
2361
2727
  kind: registration.kind,
2728
+ revokedAt: registration.revoked_at != null ? new Date(registration.revoked_at) : null,
2362
2729
  claim: registration.claim ? {
2363
2730
  id: registration.claim.id,
2364
2731
  claimCompletion: registration.claim.claim_completion ? {
2365
2732
  id: registration.claim.claim_completion.id,
2366
- createdAt: registration.claim.claim_completion.created_at,
2367
- updatedAt: registration.claim.claim_completion.updated_at,
2368
- expiresAt: registration.claim.claim_completion.expires_at,
2369
- claimedAt: registration.claim.claim_completion.claimed_at
2733
+ createdAt: new Date(registration.claim.claim_completion.created_at),
2734
+ updatedAt: new Date(registration.claim.claim_completion.updated_at),
2735
+ expiresAt: new Date(registration.claim.claim_completion.expires_at),
2736
+ claimedAt: new Date(registration.claim.claim_completion.claimed_at)
2370
2737
  } : null,
2371
- createdAt: registration.claim.created_at,
2372
- updatedAt: registration.claim.updated_at,
2373
- expiresAt: registration.claim.expires_at
2738
+ createdAt: new Date(registration.claim.created_at),
2739
+ updatedAt: new Date(registration.claim.updated_at),
2740
+ expiresAt: new Date(registration.claim.expires_at)
2374
2741
  } : null,
2375
- createdAt: registration.created_at,
2376
- updatedAt: registration.updated_at
2742
+ createdAt: new Date(registration.created_at),
2743
+ updatedAt: new Date(registration.updated_at)
2377
2744
  };
2378
2745
  }
2379
2746
  //#endregion
@@ -2455,7 +2822,7 @@ function deserializeAgentCredentialValidation(validation) {
2455
2822
  return {
2456
2823
  valid: true,
2457
2824
  registrationId: validation.registration_id,
2458
- expiresAt: validation.expires_at,
2825
+ expiresAt: validation.expires_at != null ? new Date(validation.expires_at) : null,
2459
2826
  claims: null
2460
2827
  };
2461
2828
  }
@@ -2733,7 +3100,7 @@ var Agents = class {
2733
3100
  if (!options.checkForRevoked) return {
2734
3101
  valid: true,
2735
3102
  registrationId: claims.registrationId,
2736
- expiresAt: (/* @__PURE__ */ new Date(claims.expiresAt * 1e3)).toISOString(),
3103
+ expiresAt: /* @__PURE__ */ new Date(claims.expiresAt * 1e3),
2737
3104
  claims
2738
3105
  };
2739
3106
  const remote = await this.validateCredentialRemotely(options);
@@ -2802,10 +3169,11 @@ function deserializeCreatedApiKey(apiKey) {
2802
3169
  name: apiKey.name,
2803
3170
  obfuscatedValue: apiKey.obfuscated_value,
2804
3171
  value: apiKey.value,
2805
- lastUsedAt: apiKey.last_used_at,
3172
+ lastUsedAt: apiKey.last_used_at != null ? new Date(apiKey.last_used_at) : null,
3173
+ expiresAt: apiKey.expires_at != null ? new Date(apiKey.expires_at) : null,
2806
3174
  permissions: apiKey.permissions,
2807
- createdAt: apiKey.created_at,
2808
- updatedAt: apiKey.updated_at
3175
+ createdAt: new Date(apiKey.created_at),
3176
+ updatedAt: new Date(apiKey.updated_at)
2809
3177
  };
2810
3178
  }
2811
3179
  //#endregion
@@ -3241,44 +3609,18 @@ var Connect = class {
3241
3609
  }
3242
3610
  };
3243
3611
  //#endregion
3244
- //#region src/common/utils/encode-path-parameter.ts
3245
- /**
3246
- * Encode a caller-supplied identifier for safe interpolation into a single URL
3247
- * path segment.
3248
- *
3249
- * SDK path templates interpolate caller-supplied identifiers (user IDs,
3250
- * invitation tokens, MFA factor IDs, organization IDs, external IDs, role and
3251
- * permission slugs, ...) into the request path. Without encoding, a value such
3252
- * as `../../user_management/users/user_01ABC` would be resolved by the WHATWG
3253
- * `URL` parser (see `HttpClient.getResourceURL`) into a different API path,
3254
- * letting an attacker who influences one identifier retarget the request to an
3255
- * arbitrary same-verb endpoint. `encodeURIComponent` neutralizes this by
3256
- * percent-encoding the path/query/fragment metacharacters (`/`, `?`, `#`, ...)
3257
- * that enable the injection, keeping one parameter mapped to exactly one path
3258
- * segment.
3259
- *
3260
- * `encodeURIComponent` alone is not sufficient for the two dot-only segments
3261
- * `.` and `..`: it leaves them unchanged, and the WHATWG `URL` parser then
3262
- * removes them as relative path segments (even when a value like `..` is a
3263
- * single segment, a template such as `/feature-flags/${slug}/enable` supplies
3264
- * the trailing segment, so `..` still climbs and retargets the request).
3265
- * Percent-encoding the dots does not help because the parser also treats the
3266
- * `%2e` forms as dot segments. A `.` or `..` is never a valid WorkOS
3267
- * identifier, so we fail closed and throw rather than emit an ambiguous path.
3268
- *
3269
- * The one deviation from `encodeURIComponent` is that a literal `:` is kept
3270
- * unescaped. Colons are valid path-segment characters (RFC 3986 `pchar`) and
3271
- * are used by WorkOS RBAC slugs (e.g. `users:read`); an interpolated value is
3272
- * always preceded by a `/`-delimited segment, so a `:` can never be read as a
3273
- * URL scheme. Preserving it keeps the wire format identical for existing slugs.
3274
- */
3275
- function encodePathParameter(value) {
3276
- const encoded = encodeURIComponent(value).replace(/%3A/gi, ":");
3277
- if (encoded === "." || encoded === "..") throw new TypeError("Invalid path parameter: a path parameter must not be \".\" or \"..\".");
3278
- return encoded;
3279
- }
3280
- //#endregion
3281
3612
  //#region src/directory-sync/directory-sync.ts
3613
+ const serializeListDirectoriesOptions = (options) => {
3614
+ const wire = {
3615
+ limit: options.limit,
3616
+ before: options.before,
3617
+ after: options.after,
3618
+ order: options.order
3619
+ };
3620
+ if (options.organizationId !== void 0) wire.organization_id = options.organizationId;
3621
+ if (options.search !== void 0) wire.search = options.search;
3622
+ return wire;
3623
+ };
3282
3624
  var DirectorySync = class {
3283
3625
  workos;
3284
3626
  constructor(workos) {
@@ -3289,8 +3631,8 @@ var DirectorySync = class {
3289
3631
  *
3290
3632
  * Get a list of all of your existing directories matching the criteria specified.
3291
3633
  * @param options - Pagination and filter options.
3292
- * @returns {Promise<AutoPaginatable<Directory, SerializedListDirectoriesOptions>>}
3293
- * @throws 403 response from the API.
3634
+ * @returns {Promise<AutoPaginatable<Directory, PaginationOptions>>}
3635
+ * @throws {AuthorizationException} 403
3294
3636
  * @throws {UnprocessableEntityException} 422
3295
3637
  */
3296
3638
  async listDirectories(options) {
@@ -3300,33 +3642,31 @@ var DirectorySync = class {
3300
3642
  * Get a Directory
3301
3643
  *
3302
3644
  * Get the details of an existing directory.
3303
- * @param id - Unique identifier for the Directory.
3304
- *
3305
- * @example
3306
- * "directory_01ECAZ4NV9QMV47GW873HDCX74"
3307
- *
3645
+ * @param options - The request options.
3646
+ * @param options.id - Unique identifier for the Directory.
3647
+ * @example "directory_01ECAZ4NV9QMV47GW873HDCX74"
3308
3648
  * @returns {Promise<Directory>}
3309
- * @throws 403 response from the API.
3649
+ * @throws {AuthorizationException} 403
3310
3650
  * @throws {NotFoundException} 404
3311
3651
  */
3312
- async getDirectory(id) {
3313
- const { data } = await this.workos.get(`/directories/${encodePathParameter(id)}`);
3652
+ async getDirectory(options) {
3653
+ const { id } = options;
3654
+ const { data } = await this.workos.get(`/directories/${encodeURIComponent(id)}`);
3314
3655
  return deserializeDirectory(data);
3315
3656
  }
3316
3657
  /**
3317
3658
  * Delete a Directory
3318
3659
  *
3319
3660
  * Permanently deletes an existing directory. It cannot be undone.
3320
- * @param id - Unique identifier for the Directory.
3321
- *
3322
- * @example
3323
- * "directory_01ECAZ4NV9QMV47GW873HDCX74"
3324
- *
3661
+ * @param options - The request options.
3662
+ * @param options.id - Unique identifier for the Directory.
3663
+ * @example "directory_01ECAZ4NV9QMV47GW873HDCX74"
3325
3664
  * @returns {Promise<void>}
3326
- * @throws 403 response from the API.
3665
+ * @throws {AuthorizationException} 403
3327
3666
  */
3328
- async deleteDirectory(id) {
3329
- await this.workos.delete(`/directories/${encodePathParameter(id)}`);
3667
+ async deleteDirectory(options) {
3668
+ const { id } = options;
3669
+ await this.workos.delete(`/directories/${encodeURIComponent(id)}`);
3330
3670
  }
3331
3671
  /**
3332
3672
  * List Directory Groups
@@ -3334,12 +3674,29 @@ var DirectorySync = class {
3334
3674
  * Get a list of all of existing directory groups matching the criteria specified.
3335
3675
  * @param options - Pagination and filter options.
3336
3676
  * @returns {Promise<AutoPaginatable<DirectoryGroup, ListDirectoryGroupsOptions>>}
3337
- * @throws 403 response from the API.
3677
+ * @throws {AuthorizationException} 403
3338
3678
  * @throws {NotFoundException} 404
3339
3679
  * @throws {UnprocessableEntityException} 422
3340
3680
  */
3341
3681
  async listGroups(options) {
3342
- return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, options), (params) => fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, params), options);
3682
+ const paginationOptions = options;
3683
+ return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, params), paginationOptions);
3684
+ }
3685
+ /**
3686
+ * Get a Directory Group
3687
+ *
3688
+ * Get the details of an existing Directory Group.
3689
+ * @param options - The request options.
3690
+ * @param options.id - Unique identifier for the Directory Group.
3691
+ * @example "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"
3692
+ * @returns {Promise<DirectoryGroup>}
3693
+ * @throws {AuthorizationException} 403
3694
+ * @throws {NotFoundException} 404
3695
+ */
3696
+ async getGroup(options) {
3697
+ const { id } = options;
3698
+ const { data } = await this.workos.get(`/directory_groups/${encodeURIComponent(id)}`);
3699
+ return deserializeDirectoryGroup(data);
3343
3700
  }
3344
3701
  /**
3345
3702
  * List Directory Users
@@ -3347,7 +3704,7 @@ var DirectorySync = class {
3347
3704
  * Get a list of all of existing Directory Users matching the criteria specified.
3348
3705
  * @param options - Pagination and filter options.
3349
3706
  * @returns {Promise<AutoPaginatable<DirectoryUserWithGroups<TCustomAttributes>, ListDirectoryUsersOptions>>}
3350
- * @throws 403 response from the API.
3707
+ * @throws {AuthorizationException} 403
3351
3708
  * @throws {NotFoundException} 404
3352
3709
  * @throws {UnprocessableEntityException} 422
3353
3710
  * @throws {RateLimitExceededException} 429
@@ -3359,34 +3716,18 @@ var DirectorySync = class {
3359
3716
  * Get a Directory User
3360
3717
  *
3361
3718
  * Get the details of an existing Directory User.
3362
- * @param user - Unique identifier for the Directory User.
3363
- *
3364
- * @example
3365
- * "directory_user_01E1JG7J09H96KYP8HM9B0G5SJ"
3719
+ * @param options - The request options.
3720
+ * @param options.id - Unique identifier for the Directory User.
3721
+ * @example "directory_user_01E1JG7J09H96KYP8HM9B0G5SJ"
3366
3722
  * @returns {Promise<DirectoryUserWithGroups<TCustomAttributes>>}
3367
- * @throws 403 response from the API.
3723
+ * @throws {AuthorizationException} 403
3368
3724
  * @throws {NotFoundException} 404
3369
3725
  */
3370
- async getUser(user) {
3371
- const { data } = await this.workos.get(`/directory_users/${encodePathParameter(user)}`);
3726
+ async getUser(options) {
3727
+ const { id } = options;
3728
+ const { data } = await this.workos.get(`/directory_users/${encodeURIComponent(id)}`);
3372
3729
  return deserializeDirectoryUserWithGroups(data);
3373
3730
  }
3374
- /**
3375
- * Get a Directory Group
3376
- *
3377
- * Get the details of an existing Directory Group.
3378
- * @param group - Unique identifier for the Directory Group.
3379
- *
3380
- * @example
3381
- * "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"
3382
- * @returns {Promise<DirectoryGroup>}
3383
- * @throws 403 response from the API.
3384
- * @throws {NotFoundException} 404
3385
- */
3386
- async getGroup(group) {
3387
- const { data } = await this.workos.get(`/directory_groups/${encodePathParameter(group)}`);
3388
- return deserializeDirectoryGroup(data);
3389
- }
3390
3731
  };
3391
3732
  //#endregion
3392
3733
  //#region src/events/serializers/list-event-options.serializer.ts
@@ -3421,6 +3762,43 @@ var Events = class {
3421
3762
  }
3422
3763
  };
3423
3764
  //#endregion
3765
+ //#region src/common/utils/encode-path-parameter.ts
3766
+ /**
3767
+ * Encode a caller-supplied identifier for safe interpolation into a single URL
3768
+ * path segment.
3769
+ *
3770
+ * SDK path templates interpolate caller-supplied identifiers (user IDs,
3771
+ * invitation tokens, MFA factor IDs, organization IDs, external IDs, role and
3772
+ * permission slugs, ...) into the request path. Without encoding, a value such
3773
+ * as `../../user_management/users/user_01ABC` would be resolved by the WHATWG
3774
+ * `URL` parser (see `HttpClient.getResourceURL`) into a different API path,
3775
+ * letting an attacker who influences one identifier retarget the request to an
3776
+ * arbitrary same-verb endpoint. `encodeURIComponent` neutralizes this by
3777
+ * percent-encoding the path/query/fragment metacharacters (`/`, `?`, `#`, ...)
3778
+ * that enable the injection, keeping one parameter mapped to exactly one path
3779
+ * segment.
3780
+ *
3781
+ * `encodeURIComponent` alone is not sufficient for the two dot-only segments
3782
+ * `.` and `..`: it leaves them unchanged, and the WHATWG `URL` parser then
3783
+ * removes them as relative path segments (even when a value like `..` is a
3784
+ * single segment, a template such as `/feature-flags/${slug}/enable` supplies
3785
+ * the trailing segment, so `..` still climbs and retargets the request).
3786
+ * Percent-encoding the dots does not help because the parser also treats the
3787
+ * `%2e` forms as dot segments. A `.` or `..` is never a valid WorkOS
3788
+ * identifier, so we fail closed and throw rather than emit an ambiguous path.
3789
+ *
3790
+ * The one deviation from `encodeURIComponent` is that a literal `:` is kept
3791
+ * unescaped. Colons are valid path-segment characters (RFC 3986 `pchar`) and
3792
+ * are used by WorkOS RBAC slugs (e.g. `users:read`); an interpolated value is
3793
+ * always preceded by a `/`-delimited segment, so a `:` can never be read as a
3794
+ * URL scheme. Preserving it keeps the wire format identical for existing slugs.
3795
+ */
3796
+ function encodePathParameter(value) {
3797
+ const encoded = encodeURIComponent(value).replace(/%3A/gi, ":");
3798
+ if (encoded === "." || encoded === "..") throw new TypeError("Invalid path parameter: a path parameter must not be \".\" or \"..\".");
3799
+ return encoded;
3800
+ }
3801
+ //#endregion
3424
3802
  //#region src/organizations/organizations.ts
3425
3803
  var Organizations = class {
3426
3804
  workos;
@@ -3677,7 +4055,7 @@ var OrganizationDomains = class {
3677
4055
  const deserializePasswordlessSession = (passwordlessSession) => ({
3678
4056
  id: passwordlessSession.id,
3679
4057
  email: passwordlessSession.email,
3680
- expiresAt: passwordlessSession.expires_at,
4058
+ expiresAt: new Date(passwordlessSession.expires_at),
3681
4059
  link: passwordlessSession.link,
3682
4060
  object: passwordlessSession.object
3683
4061
  });
@@ -3756,6 +4134,12 @@ const deserializeDataIntegration = (response) => ({
3756
4134
  updatedAt: new Date(response.updated_at)
3757
4135
  });
3758
4136
  //#endregion
4137
+ //#region src/pipes/serializers/connected-account-warning.serializer.ts
4138
+ const deserializeConnectedAccountWarning = (response) => ({
4139
+ code: response.code,
4140
+ message: response.message
4141
+ });
4142
+ //#endregion
3759
4143
  //#region src/pipes/serializers/connected-account.serializer.ts
3760
4144
  const deserializeConnectedAccount = (response) => ({
3761
4145
  object: response.object,
@@ -3772,12 +4156,21 @@ const deserializeConnectedAccount = (response) => ({
3772
4156
  clientSecretLast4: response.client_secret_last_4 ?? null,
3773
4157
  config: response.config,
3774
4158
  state: response.state,
3775
- createdAt: response.created_at,
3776
- updatedAt: response.updated_at
4159
+ establishedByUserId: response.established_by_user_id ?? null,
4160
+ stateReason: response.state_reason ?? null,
4161
+ createdAt: new Date(response.created_at),
4162
+ updatedAt: new Date(response.updated_at),
4163
+ warnings: response.warnings != null ? response.warnings.map(deserializeConnectedAccountWarning) : void 0
3777
4164
  });
3778
4165
  //#endregion
4166
+ //#region src/pipes/serializers/data-integration-finish-connection-response.serializer.ts
4167
+ const deserializeDataIntegrationFinishConnectionResponse = (response) => ({ connectedAccount: deserializeConnectedAccount(response.connected_account) });
4168
+ //#endregion
3779
4169
  //#region src/pipes/serializers/data-integration-authorize-url-response.serializer.ts
3780
- const deserializeDataIntegrationAuthorizeUrlResponse = (response) => ({ url: response.url });
4170
+ const deserializeDataIntegrationAuthorizeUrlResponse = (response) => ({
4171
+ url: response.url,
4172
+ completion: response.completion
4173
+ });
3781
4174
  //#endregion
3782
4175
  //#region src/pipes/serializers/data-integration-vended-credential.serializer.ts
3783
4176
  const deserializeDataIntegrationVendedCredential = (response) => {
@@ -3786,9 +4179,10 @@ const deserializeDataIntegrationVendedCredential = (response) => {
3786
4179
  authMethod: "oauth",
3787
4180
  object: response.object,
3788
4181
  value: response.value,
3789
- expiresAt: response.expires_at,
4182
+ expiresAt: response.expires_at != null ? new Date(response.expires_at) : null,
3790
4183
  scopes: response.scopes,
3791
4184
  missingScopes: response.missing_scopes,
4185
+ metadata: response.metadata,
3792
4186
  config: response.config
3793
4187
  };
3794
4188
  case "api_key": return {
@@ -3801,7 +4195,7 @@ const deserializeDataIntegrationVendedCredential = (response) => {
3801
4195
  authMethod: "client_credentials",
3802
4196
  object: response.object,
3803
4197
  value: response.value,
3804
- expiresAt: response.expires_at,
4198
+ expiresAt: response.expires_at != null ? new Date(response.expires_at) : null,
3805
4199
  scopes: response.scopes,
3806
4200
  missingScopes: response.missing_scopes,
3807
4201
  metadata: response.metadata,
@@ -3846,7 +4240,7 @@ const deserializeDataIntegrationAccessTokenResponse = (response) => {
3846
4240
  active: false,
3847
4241
  error: response.error
3848
4242
  };
3849
- default: throw new Error(`Unknown active: ${String(response.active)}`);
4243
+ default: throw new Error("Unknown active: " + String(response.active));
3850
4244
  }
3851
4245
  };
3852
4246
  //#endregion
@@ -3866,8 +4260,11 @@ const deserializeDataIntegrationsListResponseDataConnectedAccount = (response) =
3866
4260
  clientSecretLast4: response.client_secret_last_4 ?? null,
3867
4261
  config: response.config,
3868
4262
  state: response.state,
3869
- createdAt: response.created_at,
3870
- updatedAt: response.updated_at,
4263
+ establishedByUserId: response.established_by_user_id ?? null,
4264
+ stateReason: response.state_reason ?? null,
4265
+ createdAt: new Date(response.created_at),
4266
+ updatedAt: new Date(response.updated_at),
4267
+ warnings: response.warnings != null ? response.warnings.map(deserializeConnectedAccountWarning) : void 0,
3871
4268
  userlandUserId: response.userland_user_id ?? null
3872
4269
  });
3873
4270
  //#endregion
@@ -3884,8 +4281,8 @@ const deserializeDataIntegrationsListResponseData = (response) => ({
3884
4281
  authMethods: response.auth_methods,
3885
4282
  connectionOwner: response.connection_owner,
3886
4283
  ownership: response.ownership,
3887
- createdAt: response.created_at,
3888
- updatedAt: response.updated_at,
4284
+ createdAt: new Date(response.created_at),
4285
+ updatedAt: new Date(response.updated_at),
3889
4286
  connectedAccount: response.connected_account != null ? deserializeDataIntegrationsListResponseDataConnectedAccount(response.connected_account) : null,
3890
4287
  connectedAccounts: response.connected_accounts != null ? response.connected_accounts.map(deserializeDataIntegrationsListResponseDataConnectedAccount) : void 0
3891
4288
  });
@@ -3929,55 +4326,21 @@ const serializeCustomProviderDefinition = (model) => ({
3929
4326
  const serializeCreateDataIntegration = (model) => ({
3930
4327
  provider: model.provider,
3931
4328
  ownership: model.ownership,
3932
- auth_methods: model.authMethods,
3933
- config: model.config,
3934
- api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
3935
4329
  description: model.description,
3936
4330
  enabled: model.enabled,
3937
4331
  scopes: model.scopes,
4332
+ auth_methods: model.authMethods,
4333
+ config: model.config,
3938
4334
  credentials: model.credentials != null ? serializeDataIntegrationCredentialsInput(model.credentials) : void 0,
4335
+ api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
3939
4336
  custom_provider: model.customProvider != null ? serializeCustomProviderDefinition(model.customProvider) : void 0
3940
4337
  });
3941
4338
  //#endregion
3942
- //#region src/pipes/serializers/data-integrations-create-api-key-connection-request.serializer.ts
3943
- const serializeDataIntegrationsCreateApiKeyConnectionRequest = (model) => ({
3944
- user_id: model.userId,
3945
- organization_id: model.organizationId,
3946
- connection_owner: model.connectionOwner,
3947
- secret: model.secret,
3948
- connection_intent: model.connectionIntent
3949
- });
3950
- //#endregion
3951
- //#region src/pipes/serializers/data-integrations-create-client-credentials-connection-request.serializer.ts
3952
- const serializeDataIntegrationsCreateClientCredentialsConnectionRequest = (model) => ({
3953
- user_id: model.userId,
3954
- organization_id: model.organizationId,
3955
- connection_owner: model.connectionOwner,
3956
- client_id: model.clientId,
3957
- client_secret: model.clientSecret,
3958
- config: model.config,
3959
- connection_intent: model.connectionIntent
3960
- });
3961
- //#endregion
3962
- //#region src/pipes/serializers/create-connected-account.serializer.ts
3963
- const serializeCreateConnectedAccount = (model) => ({
3964
- access_token: model.accessToken,
3965
- refresh_token: model.refreshToken,
3966
- expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
3967
- scopes: model.scopes,
3968
- state: model.state,
3969
- connection_intent: model.connectionIntent
3970
- });
3971
- //#endregion
3972
- //#region src/pipes/serializers/create-organization-connected-account.serializer.ts
3973
- const serializeCreateOrganizationConnectedAccount = (model) => ({
3974
- access_token: model.accessToken,
3975
- refresh_token: model.refreshToken,
3976
- expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
3977
- scopes: model.scopes,
3978
- state: model.state,
3979
- user_id: model.userId,
3980
- connection_intent: model.connectionIntent
4339
+ //#region src/pipes/serializers/data-integrations-finish-connection-request.serializer.ts
4340
+ const serializeDataIntegrationsFinishConnectionRequest = (model) => ({
4341
+ connect_code: model.connectCode,
4342
+ code_verifier: model.codeVerifier,
4343
+ state: model.state
3981
4344
  });
3982
4345
  //#endregion
3983
4346
  //#region src/pipes/serializers/update-custom-provider-definition.serializer.ts
@@ -4000,40 +4363,47 @@ const serializeUpdateDataIntegration = (model) => ({
4000
4363
  description: model.description,
4001
4364
  enabled: model.enabled,
4002
4365
  scopes: model.scopes,
4003
- api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4004
4366
  credentials: model.credentials != null ? serializeDataIntegrationCredentialsInput(model.credentials) : void 0,
4367
+ api_key: model.apiKey != null ? serializeApiKeyInstallation(model.apiKey) : void 0,
4005
4368
  custom_provider: model.customProvider != null ? serializeUpdateCustomProviderDefinition(model.customProvider) : void 0
4006
4369
  });
4007
4370
  //#endregion
4008
- //#region src/pipes/serializers/data-integrations-upsert-api-key-request.serializer.ts
4009
- const serializeDataIntegrationsUpsertApiKeyRequest = (model) => ({
4371
+ //#region src/pipes/serializers/data-integrations-create-api-key-connection-request.serializer.ts
4372
+ const serializeDataIntegrationsCreateApiKeyConnectionRequest = (model) => ({
4373
+ account_display_name: model.accountDisplayName,
4374
+ account_identifier: model.accountIdentifier,
4010
4375
  user_id: model.userId,
4011
4376
  organization_id: model.organizationId,
4012
- connected_account_id: model.connectedAccountId,
4013
- connection_intent: model.connectionIntent,
4014
4377
  connection_owner: model.connectionOwner,
4015
- secret: model.secret
4378
+ secret: model.secret,
4379
+ connection_intent: model.connectionIntent
4016
4380
  });
4017
4381
  //#endregion
4018
4382
  //#region src/pipes/serializers/data-integrations-get-data-integration-authorize-url-request.serializer.ts
4019
4383
  const serializeDataIntegrationsGetDataIntegrationAuthorizeUrlRequest = (model) => ({
4384
+ account_display_name: model.accountDisplayName,
4020
4385
  user_id: model.userId,
4021
4386
  organization_id: model.organizationId,
4022
4387
  connection_owner: model.connectionOwner,
4023
4388
  return_to: model.returnTo,
4024
- config: model.config
4389
+ code_challenge: model.codeChallenge,
4390
+ code_challenge_method: model.codeChallengeMethod,
4391
+ config: model.config,
4392
+ connection_intent: model.connectionIntent,
4393
+ connected_account_id: model.connectedAccountId
4025
4394
  });
4026
4395
  //#endregion
4027
- //#region src/pipes/serializers/data-integrations-upsert-client-credentials-request.serializer.ts
4028
- const serializeDataIntegrationsUpsertClientCredentialsRequest = (model) => ({
4396
+ //#region src/pipes/serializers/data-integrations-create-client-credentials-connection-request.serializer.ts
4397
+ const serializeDataIntegrationsCreateClientCredentialsConnectionRequest = (model) => ({
4398
+ account_display_name: model.accountDisplayName,
4399
+ account_identifier: model.accountIdentifier,
4029
4400
  user_id: model.userId,
4030
4401
  organization_id: model.organizationId,
4031
- connected_account_id: model.connectedAccountId,
4032
- connection_intent: model.connectionIntent,
4033
4402
  connection_owner: model.connectionOwner,
4034
4403
  client_id: model.clientId,
4035
4404
  client_secret: model.clientSecret,
4036
- config: model.config
4405
+ config: model.config,
4406
+ connection_intent: model.connectionIntent
4037
4407
  });
4038
4408
  //#endregion
4039
4409
  //#region src/pipes/serializers/data-integrations-vend-credentials-request.serializer.ts
@@ -4054,8 +4424,23 @@ const serializeDataIntegrationsGetUserTokenRequest = (model) => ({
4054
4424
  supports_multiple_connections: model.supportsMultipleConnections
4055
4425
  });
4056
4426
  //#endregion
4427
+ //#region src/pipes/serializers/create-organization-connected-account.serializer.ts
4428
+ const serializeCreateOrganizationConnectedAccount = (model) => ({
4429
+ account_display_name: model.accountDisplayName,
4430
+ account_identifier: model.accountIdentifier,
4431
+ access_token: model.accessToken,
4432
+ refresh_token: model.refreshToken,
4433
+ expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4434
+ scopes: model.scopes,
4435
+ state: model.state,
4436
+ user_id: model.userId,
4437
+ connection_intent: model.connectionIntent
4438
+ });
4439
+ //#endregion
4057
4440
  //#region src/pipes/serializers/organization-connected-account.serializer.ts
4058
4441
  const serializeOrganizationConnectedAccount = (model) => ({
4442
+ account_display_name: model.accountDisplayName,
4443
+ account_identifier: model.accountIdentifier,
4059
4444
  access_token: model.accessToken,
4060
4445
  refresh_token: model.refreshToken,
4061
4446
  expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
@@ -4064,8 +4449,22 @@ const serializeOrganizationConnectedAccount = (model) => ({
4064
4449
  user_id: model.userId
4065
4450
  });
4066
4451
  //#endregion
4452
+ //#region src/pipes/serializers/create-connected-account.serializer.ts
4453
+ const serializeCreateConnectedAccount = (model) => ({
4454
+ account_display_name: model.accountDisplayName,
4455
+ account_identifier: model.accountIdentifier,
4456
+ access_token: model.accessToken,
4457
+ refresh_token: model.refreshToken,
4458
+ expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
4459
+ scopes: model.scopes,
4460
+ state: model.state,
4461
+ connection_intent: model.connectionIntent
4462
+ });
4463
+ //#endregion
4067
4464
  //#region src/pipes/serializers/connected-account-input.serializer.ts
4068
4465
  const serializeConnectedAccountInput = (model) => ({
4466
+ account_display_name: model.accountDisplayName,
4467
+ account_identifier: model.accountIdentifier,
4069
4468
  access_token: model.accessToken,
4070
4469
  refresh_token: model.refreshToken,
4071
4470
  expires_at: model.expiresAt != null ? model.expiresAt.toISOString() : void 0,
@@ -4073,6 +4472,32 @@ const serializeConnectedAccountInput = (model) => ({
4073
4472
  state: model.state
4074
4473
  });
4075
4474
  //#endregion
4475
+ //#region src/pipes/serializers/data-integrations-upsert-api-key-request.serializer.ts
4476
+ const serializeDataIntegrationsUpsertApiKeyRequest = (model) => ({
4477
+ account_display_name: model.accountDisplayName,
4478
+ account_identifier: model.accountIdentifier,
4479
+ user_id: model.userId,
4480
+ organization_id: model.organizationId,
4481
+ connected_account_id: model.connectedAccountId,
4482
+ connection_intent: model.connectionIntent,
4483
+ connection_owner: model.connectionOwner,
4484
+ secret: model.secret
4485
+ });
4486
+ //#endregion
4487
+ //#region src/pipes/serializers/data-integrations-upsert-client-credentials-request.serializer.ts
4488
+ const serializeDataIntegrationsUpsertClientCredentialsRequest = (model) => ({
4489
+ account_display_name: model.accountDisplayName,
4490
+ account_identifier: model.accountIdentifier,
4491
+ user_id: model.userId,
4492
+ organization_id: model.organizationId,
4493
+ connected_account_id: model.connectedAccountId,
4494
+ connection_intent: model.connectionIntent,
4495
+ connection_owner: model.connectionOwner,
4496
+ client_id: model.clientId,
4497
+ client_secret: model.clientSecret,
4498
+ config: model.config
4499
+ });
4500
+ //#endregion
4076
4501
  //#region src/pipes/pipes.ts
4077
4502
  var Pipes = class {
4078
4503
  workos;
@@ -4080,6 +4505,111 @@ var Pipes = class {
4080
4505
  this.workos = workos;
4081
4506
  }
4082
4507
  /**
4508
+ * Upsert an API key for a connected account
4509
+ *
4510
+ * 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.
4511
+ * @param options - Object containing userId, secret.
4512
+ * @param options.slug - The identifier of the integration.
4513
+ * @example "github"
4514
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4515
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4516
+ * @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`.
4517
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4518
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
4519
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4520
+ * @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.
4521
+ * @example "user"
4522
+ * @param options.secret - The API key secret to store for this integration.
4523
+ * @example "sk-1234567890abcdef"
4524
+ * @returns {Promise<ConnectedAccount>}
4525
+ * @throws {BadRequestException} 400
4526
+ * @throws {UnauthorizedException} 401
4527
+ * @throws {AuthorizationException} 403
4528
+ * @throws {NotFoundException} 404
4529
+ * @throws {ConflictException} 409
4530
+ * @throws {UnprocessableEntityException} 422
4531
+ */
4532
+ async updateDataIntegrationApiKey(options) {
4533
+ const { slug, ...payload } = options;
4534
+ const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsUpsertApiKeyRequest(payload));
4535
+ return deserializeConnectedAccount(data);
4536
+ }
4537
+ /**
4538
+ * Upsert client credentials for a connected account
4539
+ *
4540
+ * 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.
4541
+ * @param options - The request options.
4542
+ * @param options.slug - The identifier of the integration.
4543
+ * @example "salesforce"
4544
+ * @returns {Promise<ConnectedAccount>}
4545
+ * @throws {BadRequestException} 400
4546
+ * @throws {UnauthorizedException} 401
4547
+ * @throws {AuthorizationException} 403
4548
+ * @throws {NotFoundException} 404
4549
+ * @throws {ConflictException} 409
4550
+ * @throws {UnprocessableEntityException} 422
4551
+ */
4552
+ async updateDataIntegrationClientCredentials(options) {
4553
+ const { slug, ...payload } = options;
4554
+ const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsUpsertClientCredentialsRequest(payload));
4555
+ return deserializeConnectedAccount(data);
4556
+ }
4557
+ /**
4558
+ * Delete an organization connected account
4559
+ *
4560
+ * 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.
4561
+ * @param options - Additional query options.
4562
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4563
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4564
+ * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4565
+ * @example "github"
4566
+ * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4567
+ * @example true
4568
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4569
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4570
+ * @returns {Promise<void>}
4571
+ * @throws {BadRequestException} 400
4572
+ * @throws {UnauthorizedException} 401
4573
+ * @throws {NotFoundException} 404
4574
+ * @throws {ConflictException} 409
4575
+ */
4576
+ async deleteOrganizationConnectedAccount(options) {
4577
+ const { organizationId, slug } = options;
4578
+ await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4579
+ supports_multiple_connections: options.supportsMultipleConnections,
4580
+ connected_account_id: options.connectedAccountId
4581
+ });
4582
+ }
4583
+ /**
4584
+ * Delete a connected account
4585
+ *
4586
+ * 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.
4587
+ * @param options - Additional query options.
4588
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4589
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4590
+ * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4591
+ * @example "github"
4592
+ * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4593
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4594
+ * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4595
+ * @example true
4596
+ * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4597
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4598
+ * @returns {Promise<void>}
4599
+ * @throws {BadRequestException} 400
4600
+ * @throws {UnauthorizedException} 401
4601
+ * @throws {NotFoundException} 404
4602
+ * @throws {ConflictException} 409
4603
+ */
4604
+ async deleteUserConnectedAccount(options) {
4605
+ const { userId, slug } = options;
4606
+ await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4607
+ organization_id: options.organizationId,
4608
+ supports_multiple_connections: options.supportsMultipleConnections,
4609
+ connected_account_id: options.connectedAccountId
4610
+ });
4611
+ }
4612
+ /**
4083
4613
  * List data integrations
4084
4614
  *
4085
4615
  * 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.
@@ -4129,6 +4659,20 @@ var Pipes = class {
4129
4659
  return deserializeDataIntegration(data);
4130
4660
  }
4131
4661
  /**
4662
+ * Finish connection
4663
+ *
4664
+ * 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.
4665
+ * @returns {Promise<DataIntegrationFinishConnectionResponse>}
4666
+ * @throws {BadRequestException} 400
4667
+ * @throws {UnauthorizedException} 401
4668
+ * @throws {AuthorizationException} 403
4669
+ */
4670
+ async finishConnection(options) {
4671
+ const payload = options;
4672
+ const { data } = await this.workos.post("/data-integrations/finish", serializeDataIntegrationsFinishConnectionRequest(payload));
4673
+ return deserializeDataIntegrationFinishConnectionResponse(data);
4674
+ }
4675
+ /**
4132
4676
  * Get a data integration
4133
4677
  *
4134
4678
  * Retrieves the user-owned data integration by its slug.
@@ -4191,45 +4735,34 @@ var Pipes = class {
4191
4735
  /**
4192
4736
  * Create another API key connected account
4193
4737
  *
4194
- * Requires `connectionIntent: 'add'` and does not accept an account selector.
4195
- * Until additional connections are available, this creates the first connection
4196
- * or returns 404 `multiple_connections_unavailable` if one already exists.
4197
- * Use `updateDataIntegrationApiKey` to rotate the compatibility connection or
4198
- * update an exact connection.
4199
- */
4200
- async createDataIntegrationApiKey(options) {
4201
- const { slug, ...payload } = options;
4202
- const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsCreateApiKeyConnectionRequest(payload));
4203
- return deserializeConnectedAccount(data);
4204
- }
4205
- /**
4206
- * Upsert an API key for a connected account
4207
- *
4208
- * 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.
4209
- * @param options - Object containing userId, secret.
4738
+ * 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.
4739
+ * @param options - Object containing userId, secret, connectionIntent.
4210
4740
  * @param options.slug - The identifier of the integration.
4211
4741
  * @example "github"
4742
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4743
+ * @example "Acme production"
4744
+ * @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.
4745
+ * @example "workspace_123"
4212
4746
  * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4213
4747
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4214
4748
  * @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`.
4215
4749
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4216
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to rotate a specific existing connection.
4217
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4218
4750
  * @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.
4219
4751
  * @example "user"
4220
4752
  * @param options.secret - The API key secret to store for this integration.
4221
4753
  * @example "sk-1234567890abcdef"
4754
+ * @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.
4755
+ * @example "add"
4222
4756
  * @returns {Promise<ConnectedAccount>}
4223
4757
  * @throws {BadRequestException} 400
4224
4758
  * @throws {UnauthorizedException} 401
4225
4759
  * @throws {AuthorizationException} 403
4226
4760
  * @throws {NotFoundException} 404
4227
4761
  * @throws {ConflictException} 409
4228
- * @throws {UnprocessableEntityException} 422
4229
4762
  */
4230
- async updateDataIntegrationApiKey(options) {
4763
+ async createDataIntegrationApiKey(options) {
4231
4764
  const { slug, ...payload } = options;
4232
- const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsUpsertApiKeyRequest(payload));
4765
+ const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/api-key`, serializeDataIntegrationsCreateApiKeyConnectionRequest(payload));
4233
4766
  return deserializeConnectedAccount(data);
4234
4767
  }
4235
4768
  /**
@@ -4239,21 +4772,33 @@ var Pipes = class {
4239
4772
  * @param options - Object containing userId.
4240
4773
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4241
4774
  * @example "github"
4775
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4776
+ * @example "Acme production"
4242
4777
  * @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.
4243
4778
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4244
4779
  * @param options.organizationId - An organization ID to scope the authorization to a specific organization. Required when `connection_owner` is `organization`.
4245
4780
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4246
4781
  * @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`.
4247
4782
  * @example "user"
4248
- * @param options.returnTo - The URL to redirect the user to after authorization.
4783
+ * @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.
4249
4784
  * @example "https://example.com/callback"
4785
+ * @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.
4786
+ * @example "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"
4787
+ * @param options.codeChallengeMethod - The method used to derive `code_challenge`. Only `S256` is supported, and it is the default. Requires `code_challenge`.
4788
+ * @example "S256"
4250
4789
  * @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.
4251
4790
  * @example {"subdomain":"acme"}
4791
+ * @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.
4792
+ * @example "add"
4793
+ * @param options.connectedAccountId - The exact connected account to reauthorize. Required with `connection_intent: reauthorize` and not accepted otherwise.
4794
+ * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4252
4795
  * @returns {Promise<DataIntegrationAuthorizeUrlResponse>}
4253
4796
  * @throws {BadRequestException} 400
4254
4797
  * @throws {UnauthorizedException} 401
4255
4798
  * @throws {AuthorizationException} 403
4256
4799
  * @throws {NotFoundException} 404
4800
+ * @throws {ConflictException} 409
4801
+ * @throws {UnprocessableEntityException} 422
4257
4802
  */
4258
4803
  async authorizeDataIntegration(options) {
4259
4804
  const { slug, ...payload } = options;
@@ -4263,41 +4808,44 @@ var Pipes = class {
4263
4808
  /**
4264
4809
  * Create another client credentials connected account
4265
4810
  *
4266
- * Requires `connectionIntent: 'add'` and does not accept an account selector.
4267
- * Until additional connections are available, this creates the first connection
4268
- * or returns 404 `multiple_connections_unavailable` if one already exists.
4269
- * Use `updateDataIntegrationClientCredentials` to rotate the compatibility
4270
- * connection or update an exact connection.
4271
- */
4272
- async createDataIntegrationClientCredential(options) {
4273
- const { slug, ...payload } = options;
4274
- const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsCreateClientCredentialsConnectionRequest(payload));
4275
- return deserializeConnectedAccount(data);
4276
- }
4277
- /**
4278
- * Upsert client credentials for a connected account
4279
- *
4280
- * 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.
4281
- * @param options - The request options.
4811
+ * 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.
4812
+ * @param options - Object containing userId, clientId, clientSecret, connectionIntent.
4282
4813
  * @param options.slug - The identifier of the integration.
4283
4814
  * @example "salesforce"
4815
+ * @param options.accountDisplayName - A mutable, non-unique label. Omit to preserve an existing label; null clears it. Labels are never account identifiers.
4816
+ * @example "Acme production"
4817
+ * @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.
4818
+ * @example "workspace_123"
4819
+ * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4820
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4821
+ * @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`.
4822
+ * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4823
+ * @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.
4824
+ * @example "user"
4825
+ * @param options.clientId - The OAuth client ID to store for this integration.
4826
+ * @example "3MVG9..."
4827
+ * @param options.clientSecret - The OAuth client secret to store for this integration.
4828
+ * @example "shhh-secret"
4829
+ * @param options.config - Provider-specific configuration values collected for this installation, keyed by the provider's config field descriptors.
4830
+ * @example {"salesforce_host":"acme.my.salesforce.com"}
4831
+ * @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.
4832
+ * @example "add"
4284
4833
  * @returns {Promise<ConnectedAccount>}
4285
4834
  * @throws {BadRequestException} 400
4286
4835
  * @throws {UnauthorizedException} 401
4287
4836
  * @throws {AuthorizationException} 403
4288
4837
  * @throws {NotFoundException} 404
4289
4838
  * @throws {ConflictException} 409
4290
- * @throws {UnprocessableEntityException} 422
4291
4839
  */
4292
- async updateDataIntegrationClientCredentials(options) {
4840
+ async createDataIntegrationClientCredential(options) {
4293
4841
  const { slug, ...payload } = options;
4294
- const { data } = await this.workos.put(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsUpsertClientCredentialsRequest(payload));
4842
+ const { data } = await this.workos.post(`/data-integrations/${encodeURIComponent(slug)}/client-credentials`, serializeDataIntegrationsCreateClientCredentialsConnectionRequest(payload));
4295
4843
  return deserializeConnectedAccount(data);
4296
4844
  }
4297
4845
  /**
4298
4846
  * Vend credentials for a connected account
4299
4847
  *
4300
- * 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`.
4848
+ * 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.
4301
4849
  * @param options - Object containing userId.
4302
4850
  * @param options.slug - The identifier of the integration.
4303
4851
  * @example "github"
@@ -4344,9 +4892,18 @@ var Pipes = class {
4344
4892
  * Update an organization-owned data integration
4345
4893
  *
4346
4894
  * 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.
4347
- * @param options - The request options.
4895
+ * @param options - The request body.
4348
4896
  * @param options.slug - The slug identifier of the data integration.
4349
4897
  * @example "github"
4898
+ * @param options.description - An optional description of the Data Integration.
4899
+ * @example "Production GitHub app"
4900
+ * @param options.enabled - Whether the Data Integration is enabled.
4901
+ * @example true
4902
+ * @param options.scopes - The OAuth scopes to request for the Data Integration. Pass `null` to reset to the provider's configured scopes.
4903
+ * @example ["repo","read:org"]
4904
+ * @param options.credentials - New OAuth credentials for the Data Integration. When provided, rotates the stored client secret. Mutually exclusive with `api_key`.
4905
+ * @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`).
4906
+ * @param options.customProvider - Updates to a custom provider's OAuth definition. Only valid for custom-provider integrations.
4350
4907
  * @returns {Promise<DataIntegration>}
4351
4908
  * @throws {BadRequestException} 400
4352
4909
  * @throws {UnauthorizedException} 401
@@ -4435,12 +4992,30 @@ var Pipes = class {
4435
4992
  /**
4436
4993
  * Import an organization connected account
4437
4994
  *
4438
- * 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.
4439
- * @param options - The request options.
4995
+ * 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.
4996
+ * @param options - Object containing userId.
4440
4997
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4441
4998
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4442
4999
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4443
5000
  * @example "github"
5001
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5002
+ * @example "Acme production"
5003
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5004
+ * @example "workspace_123"
5005
+ * @param options.accessToken - The OAuth access token for the connected account.
5006
+ * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
5007
+ * @param options.refreshToken - The OAuth refresh token for the connected account.
5008
+ * @example "ghr_xxxxxxxxxxxxxxxxxxxx"
5009
+ * @param options.expiresAt - The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
5010
+ * @example "2025-12-31T23:59:59.000Z"
5011
+ * @param options.scopes - The OAuth scopes granted for this connection.
5012
+ * @example ["repo","user:email"]
5013
+ * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
5014
+ * @example "connected"
5015
+ * @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.
5016
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
5017
+ * @param options.connectionIntent - Set to `add` to create another connected account. Omit this field for permanent compatibility behavior.
5018
+ * @example "add"
4444
5019
  * @returns {Promise<ConnectedAccount>}
4445
5020
  * @throws {UnauthorizedException} 401
4446
5021
  * @throws {AuthorizationException} 403
@@ -4457,15 +5032,33 @@ var Pipes = class {
4457
5032
  * Update an organization connected account
4458
5033
  *
4459
5034
  * Updates an organization's [connected account](https://workos.com/docs/reference/pipes/connected-account) tokens, scopes, or state for a specific provider.
4460
- * @param options - Additional query options.
5035
+ * @param options - Object containing userId.
4461
5036
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4462
5037
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4463
5038
  * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4464
5039
  * @example "github"
4465
- * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting.
5040
+ * @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.
5041
+ * @example true
4466
5042
  * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
4467
5043
  * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4468
- * @param options.connectionIntent - Set to `reauthorize` with `connectedAccountId`, or omit both to update the compatibility connection.
5044
+ * @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.
5045
+ * @example "reauthorize"
5046
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5047
+ * @example "Acme production"
5048
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5049
+ * @example "workspace_123"
5050
+ * @param options.accessToken - The OAuth access token for the connected account.
5051
+ * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
5052
+ * @param options.refreshToken - The OAuth refresh token for the connected account.
5053
+ * @example "ghr_xxxxxxxxxxxxxxxxxxxx"
5054
+ * @param options.expiresAt - The ISO-8601 timestamp when the access token expires. Required when `access_token` is provided for tokens that expire.
5055
+ * @example "2025-12-31T23:59:59.000Z"
5056
+ * @param options.scopes - The OAuth scopes granted for this connection.
5057
+ * @example ["repo","user:email"]
5058
+ * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
5059
+ * @example "connected"
5060
+ * @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.
5061
+ * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4469
5062
  * @returns {Promise<ConnectedAccount>}
4470
5063
  * @throws {BadRequestException} 400
4471
5064
  * @throws {UnauthorizedException} 401
@@ -4477,39 +5070,13 @@ var Pipes = class {
4477
5070
  async updateOrganizationConnectedAccount(options) {
4478
5071
  const { organizationId, slug, supportsMultipleConnections, connectedAccountId, connectionIntent, ...payload } = options;
4479
5072
  const { data } = await this.workos.put(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeOrganizationConnectedAccount(payload), { query: {
4480
- supports_multiple_connections: supportsMultipleConnections,
4481
- connected_account_id: connectedAccountId,
4482
- connection_intent: connectionIntent
5073
+ ...options.supportsMultipleConnections !== void 0 && { supports_multiple_connections: options.supportsMultipleConnections },
5074
+ ...options.connectedAccountId !== void 0 && { connected_account_id: options.connectedAccountId },
5075
+ ...options.connectionIntent !== void 0 && { connection_intent: options.connectionIntent }
4483
5076
  } });
4484
5077
  return deserializeConnectedAccount(data);
4485
5078
  }
4486
5079
  /**
4487
- * Delete an organization connected account
4488
- *
4489
- * 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.
4490
- * @param options - Additional query options.
4491
- * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier.
4492
- * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4493
- * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4494
- * @example "github"
4495
- * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4496
- * @example true
4497
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4498
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4499
- * @returns {Promise<void>}
4500
- * @throws {BadRequestException} 400
4501
- * @throws {UnauthorizedException} 401
4502
- * @throws {NotFoundException} 404
4503
- * @throws {ConflictException} 409
4504
- */
4505
- async deleteOrganizationConnectedAccount(options) {
4506
- const { organizationId, slug } = options;
4507
- await this.workos.delete(`/organizations/${encodeURIComponent(organizationId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4508
- supports_multiple_connections: options.supportsMultipleConnections,
4509
- connected_account_id: options.connectedAccountId
4510
- });
4511
- }
4512
- /**
4513
5080
  * List providers for an organization
4514
5081
  *
4515
5082
  * 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.
@@ -4560,7 +5127,7 @@ var Pipes = class {
4560
5127
  /**
4561
5128
  * Import a connected account
4562
5129
  *
4563
- * 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.
5130
+ * 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.
4564
5131
  * @param options - The request body.
4565
5132
  * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4566
5133
  * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
@@ -4568,6 +5135,10 @@ var Pipes = class {
4568
5135
  * @example "github"
4569
5136
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4570
5137
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
5138
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5139
+ * @example "Acme production"
5140
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5141
+ * @example "workspace_123"
4571
5142
  * @param options.accessToken - The OAuth access token for the connected account.
4572
5143
  * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
4573
5144
  * @param options.refreshToken - The OAuth refresh token for the connected account.
@@ -4578,6 +5149,8 @@ var Pipes = class {
4578
5149
  * @example ["repo","user:email"]
4579
5150
  * @param options.state - Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
4580
5151
  * @example "connected"
5152
+ * @param options.connectionIntent - Set to `add` to create another connected account. Omit this field for permanent compatibility behavior.
5153
+ * @example "add"
4581
5154
  * @returns {Promise<ConnectedAccount>}
4582
5155
  * @throws {UnauthorizedException} 401
4583
5156
  * @throws {NotFoundException} 404
@@ -4586,7 +5159,7 @@ var Pipes = class {
4586
5159
  */
4587
5160
  async createUserConnectedAccount(options) {
4588
5161
  const { userId, slug, organizationId, ...payload } = options;
4589
- const { data } = await this.workos.post(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeCreateConnectedAccount(payload), { query: { organization_id: organizationId } });
5162
+ 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 } } });
4590
5163
  return deserializeConnectedAccount(data);
4591
5164
  }
4592
5165
  /**
@@ -4600,10 +5173,16 @@ var Pipes = class {
4600
5173
  * @example "github"
4601
5174
  * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4602
5175
  * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4603
- * @param options.supportsMultipleConnections - Accepted for compatibility; does not change update targeting.
5176
+ * @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.
5177
+ * @example true
4604
5178
  * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
4605
5179
  * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4606
- * @param options.connectionIntent - Set to `reauthorize` with `connectedAccountId`, or omit both to update the compatibility connection.
5180
+ * @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.
5181
+ * @example "reauthorize"
5182
+ * @param options.accountDisplayName - A mutable, non-unique connection label; null clears it. Not an account identifier.
5183
+ * @example "Acme production"
5184
+ * @param options.accountIdentifier - A developer-attested account identifier; null clears it.
5185
+ * @example "workspace_123"
4607
5186
  * @param options.accessToken - The OAuth access token for the connected account.
4608
5187
  * @example "gho_16C7e42F292c6912E7710c838347Ae178B4a"
4609
5188
  * @param options.refreshToken - The OAuth refresh token for the connected account.
@@ -4624,43 +5203,14 @@ var Pipes = class {
4624
5203
  async updateUserConnectedAccount(options) {
4625
5204
  const { userId, slug, organizationId, supportsMultipleConnections, connectedAccountId, connectionIntent, ...payload } = options;
4626
5205
  const { data } = await this.workos.put(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, serializeConnectedAccountInput(payload), { query: {
4627
- organization_id: organizationId,
4628
- supports_multiple_connections: supportsMultipleConnections,
4629
- connected_account_id: connectedAccountId,
4630
- connection_intent: connectionIntent
5206
+ ...options.organizationId !== void 0 && { organization_id: options.organizationId },
5207
+ ...options.supportsMultipleConnections !== void 0 && { supports_multiple_connections: options.supportsMultipleConnections },
5208
+ ...options.connectedAccountId !== void 0 && { connected_account_id: options.connectedAccountId },
5209
+ ...options.connectionIntent !== void 0 && { connection_intent: options.connectionIntent }
4631
5210
  } });
4632
5211
  return deserializeConnectedAccount(data);
4633
5212
  }
4634
5213
  /**
4635
- * Delete a connected account
4636
- *
4637
- * 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.
4638
- * @param options - Additional query options.
4639
- * @param options.userId - A [User](https://workos.com/docs/reference/authkit/user) identifier.
4640
- * @example "user_01EHZNVPK3SFK441A1RGBFSHRT"
4641
- * @param options.slug - The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
4642
- * @example "github"
4643
- * @param options.organizationId - An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
4644
- * @example "org_01EHZNVPK3SFK441A1RGBFSHRT"
4645
- * @param options.supportsMultipleConnections - Set to `true` to use the plural connection contract. When omitted or `false`, only the compatibility connection is considered.
4646
- * @example true
4647
- * @param options.connectedAccountId - A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
4648
- * @example "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
4649
- * @returns {Promise<void>}
4650
- * @throws {BadRequestException} 400
4651
- * @throws {UnauthorizedException} 401
4652
- * @throws {NotFoundException} 404
4653
- * @throws {ConflictException} 409
4654
- */
4655
- async deleteUserConnectedAccount(options) {
4656
- const { userId, slug } = options;
4657
- await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
4658
- organization_id: options.organizationId,
4659
- supports_multiple_connections: options.supportsMultipleConnections,
4660
- connected_account_id: options.connectedAccountId
4661
- });
4662
- }
4663
- /**
4664
5214
  * List providers for a user
4665
5215
  *
4666
5216
  * 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.
@@ -4777,12 +5327,13 @@ var Radar = class {
4777
5327
  * @example "block"
4778
5328
  * @param options.entry - The value to add to the list. Must match the format of the list type (e.g. a valid IP address for `ip_address`, a valid email for `email`).
4779
5329
  * @example "198.51.100.42"
4780
- * @returns {Promise<RadarListEntryAlreadyPresentResponse>}
5330
+ * @returns {Promise<RadarListEntryAlreadyPresentResponse | null>}
4781
5331
  * @throws {BadRequestException} 400
4782
5332
  */
4783
5333
  async addListEntry(options) {
4784
5334
  const { type, action, ...payload } = options;
4785
5335
  const { data } = await this.workos.post(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneUpdateRadarListRequest(payload));
5336
+ if (!data) return null;
4786
5337
  return deserializeRadarListEntryAlreadyPresentResponse(data);
4787
5338
  }
4788
5339
  /**
@@ -4823,7 +5374,7 @@ var AdminPortal = class {
4823
5374
  * @throws {NotFoundException} 404
4824
5375
  * @throws {UnprocessableEntityException} 422
4825
5376
  */
4826
- async generateLink({ intent, organization, returnUrl, successUrl, intentOptions, adminEmails }) {
5377
+ async generateLink({ intent, organization, returnUrl, successUrl, intentOptions, itContactEmails }) {
4827
5378
  const { data } = await this.workos.post("/portal/generate_link", {
4828
5379
  intent,
4829
5380
  organization,
@@ -4833,7 +5384,7 @@ var AdminPortal = class {
4833
5384
  bookmark_slug: intentOptions.sso.bookmarkSlug,
4834
5385
  provider_type: intentOptions.sso.providerType
4835
5386
  } } : void 0,
4836
- admin_emails: adminEmails
5387
+ it_contact_emails: itContactEmails
4837
5388
  });
4838
5389
  return data;
4839
5390
  }
@@ -5037,9 +5588,9 @@ var SSO = class {
5037
5588
  const deserializeChallenge = (challenge) => ({
5038
5589
  object: challenge.object,
5039
5590
  id: challenge.id,
5040
- createdAt: challenge.created_at,
5041
- updatedAt: challenge.updated_at,
5042
- expiresAt: challenge.expires_at,
5591
+ createdAt: new Date(challenge.created_at),
5592
+ updatedAt: new Date(challenge.updated_at),
5593
+ expiresAt: challenge.expires_at != null ? new Date(challenge.expires_at) : void 0,
5043
5594
  code: challenge.code,
5044
5595
  authenticationFactorId: challenge.authentication_factor_id
5045
5596
  });
@@ -5048,8 +5599,8 @@ const deserializeChallenge = (challenge) => ({
5048
5599
  const deserializeFactor = (factor) => ({
5049
5600
  object: factor.object,
5050
5601
  id: factor.id,
5051
- createdAt: factor.created_at,
5052
- updatedAt: factor.updated_at,
5602
+ createdAt: new Date(factor.created_at),
5603
+ updatedAt: new Date(factor.updated_at),
5053
5604
  type: factor.type,
5054
5605
  ...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
5055
5606
  ...factor.totp ? { totp: deserializeTotp(factor.totp) } : {}
@@ -5057,8 +5608,8 @@ const deserializeFactor = (factor) => ({
5057
5608
  const deserializeFactorWithSecrets = (factor) => ({
5058
5609
  object: factor.object,
5059
5610
  id: factor.id,
5060
- createdAt: factor.created_at,
5061
- updatedAt: factor.updated_at,
5611
+ createdAt: new Date(factor.created_at),
5612
+ updatedAt: new Date(factor.updated_at),
5062
5613
  type: factor.type,
5063
5614
  ...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
5064
5615
  ...factor.totp ? { totp: deserializeTotpWithSecrets(factor.totp) } : {}
@@ -5193,8 +5744,8 @@ const deserializeAuditLogExport = (auditLogExport) => ({
5193
5744
  id: auditLogExport.id,
5194
5745
  state: auditLogExport.state,
5195
5746
  url: auditLogExport.url,
5196
- createdAt: auditLogExport.created_at,
5197
- updatedAt: auditLogExport.updated_at
5747
+ createdAt: new Date(auditLogExport.created_at),
5748
+ updatedAt: new Date(auditLogExport.updated_at)
5198
5749
  });
5199
5750
  //#endregion
5200
5751
  //#region src/audit-logs/serializers/audit-log-export-options.serializer.ts
@@ -5269,7 +5820,7 @@ const deserializeAuditLogSchema = (auditLogSchema) => ({
5269
5820
  })),
5270
5821
  actor: auditLogSchema.actor ? { metadata: deserializeMetadata(auditLogSchema.actor.metadata) } : void 0,
5271
5822
  metadata: auditLogSchema.metadata ? deserializeMetadata(auditLogSchema.metadata) : void 0,
5272
- createdAt: auditLogSchema.created_at
5823
+ createdAt: new Date(auditLogSchema.created_at)
5273
5824
  });
5274
5825
  //#endregion
5275
5826
  //#region src/audit-logs/serializers/audit-logs-retention.serializer.ts
@@ -5690,6 +6241,21 @@ async function unsealData(encryptedData, { password }) {
5690
6241
  return data;
5691
6242
  }
5692
6243
  //#endregion
6244
+ //#region src/user-management/serializers/session-cookie-data.serializer.ts
6245
+ const toDate = (value) => value instanceof Date ? value : new Date(value);
6246
+ const deserializeSessionCookieData = (data) => {
6247
+ if (!data.user) return data;
6248
+ return {
6249
+ ...data,
6250
+ user: {
6251
+ ...data.user,
6252
+ createdAt: toDate(data.user.createdAt),
6253
+ updatedAt: toDate(data.user.updatedAt),
6254
+ lastSignInAt: data.user.lastSignInAt != null ? toDate(data.user.lastSignInAt) : null
6255
+ }
6256
+ };
6257
+ };
6258
+ //#endregion
5693
6259
  //#region src/common/utils/env.ts
5694
6260
  let detectedRuntime = null;
5695
6261
  /**
@@ -5701,10 +6267,10 @@ let detectedRuntime = null;
5701
6267
  function detectRuntime() {
5702
6268
  if (detectedRuntime) return detectedRuntime;
5703
6269
  const global = globalThis;
5704
- if (typeof process !== "undefined" && process.release?.name === "node") detectedRuntime = "node";
5705
- else if (typeof global.Deno !== "undefined") detectedRuntime = "deno";
5706
- else if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Bun")) detectedRuntime = "bun";
6270
+ if (typeof global.Deno !== "undefined") detectedRuntime = "deno";
6271
+ else if (typeof global.Bun !== "undefined" || typeof process !== "undefined" && process.versions?.bun || typeof navigator !== "undefined" && navigator.userAgent?.includes("Bun")) detectedRuntime = "bun";
5707
6272
  else if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare")) detectedRuntime = "cloudflare";
6273
+ else if (typeof process !== "undefined" && process.release?.name === "node") detectedRuntime = "node";
5708
6274
  else if (typeof global !== "undefined" && "fastly" in global) detectedRuntime = "fastly";
5709
6275
  else if (typeof global !== "undefined" && "EdgeRuntime" in global) detectedRuntime = "edge-light";
5710
6276
  else detectedRuntime = "other";
@@ -5719,7 +6285,7 @@ function getEnvironmentVariable(key) {
5719
6285
  case "bun":
5720
6286
  case "edge-light": return process.env[key];
5721
6287
  case "deno": return global.Deno.env.get(key);
5722
- case "cloudflare": return global.env?.[key] ?? global[key];
6288
+ case "cloudflare": return global.env?.[key] ?? global[key] ?? (typeof process !== "undefined" ? process.env?.[key] : void 0);
5723
6289
  case "fastly": return global[key];
5724
6290
  default: return process?.env?.[key] ?? global.env?.[key] ?? global[key];
5725
6291
  }
@@ -5895,7 +6461,7 @@ var CookieSession = class {
5895
6461
  authenticated: false,
5896
6462
  reason: "no_session_cookie_provided"
5897
6463
  };
5898
- const session = await unsealData(this.sessionData, { password: this.cookiePassword });
6464
+ const session = deserializeSessionCookieData(await unsealData(this.sessionData, { password: this.cookiePassword }));
5899
6465
  if (!session.accessToken) return {
5900
6466
  authenticated: false,
5901
6467
  reason: "invalid_session_cookie"
@@ -5931,7 +6497,7 @@ var CookieSession = class {
5931
6497
  */
5932
6498
  async refresh(options = {}) {
5933
6499
  const { decodeJwt } = await getJose();
5934
- const session = await unsealData(this.sessionData, { password: this.cookiePassword });
6500
+ const session = deserializeSessionCookieData(await unsealData(this.sessionData, { password: this.cookiePassword }));
5935
6501
  if (!session.refreshToken || !session.user) return {
5936
6502
  authenticated: false,
5937
6503
  reason: "invalid_session_cookie",
@@ -6067,7 +6633,7 @@ function isNetworkError(error) {
6067
6633
  }
6068
6634
  //#endregion
6069
6635
  //#region src/user-management/user-management.ts
6070
- var UserManagement = class {
6636
+ var UserManagement = class UserManagement {
6071
6637
  workos;
6072
6638
  _jwks;
6073
6639
  clientId;
@@ -6348,7 +6914,7 @@ var UserManagement = class {
6348
6914
  authenticated: false,
6349
6915
  reason: "no_session_cookie_provided"
6350
6916
  };
6351
- const session = await unsealData(sessionData, { password: cookiePassword });
6917
+ const session = deserializeSessionCookieData(await unsealData(sessionData, { password: cookiePassword }));
6352
6918
  if (!session.accessToken) return {
6353
6919
  authenticated: false,
6354
6920
  reason: "invalid_session_cookie"
@@ -6372,18 +6938,74 @@ var UserManagement = class {
6372
6938
  authenticationMethod: session.authenticationMethod
6373
6939
  };
6374
6940
  }
6375
- async isValidJwt(accessToken) {
6941
+ /**
6942
+ * Verify an access token and return its claims.
6943
+ *
6944
+ * Checks the token's signature against the environment's JWKS and its
6945
+ * expiry, plus the issuer when one was configured on the client, and that
6946
+ * the payload carries the claims of a WorkOS user access token. Tokens the
6947
+ * environment signed for another purpose, such as agent or widget session
6948
+ * tokens, are rejected. Resolves to `null` when the token fails any of
6949
+ * those checks, is not a JWT, or was signed by a key the JWKS does not
6950
+ * have. Errors that are not JWT validation failures, such as a network
6951
+ * error while fetching the JWKS, propagate.
6952
+ *
6953
+ * @param accessToken - The access token to verify, for example from an `Authorization: Bearer` header.
6954
+ * @returns {Promise<AccessTokenClaims | null>} The token's claims, or `null` when the token is invalid.
6955
+ * @throws {Error} When no client ID was provided when initializing WorkOS.
6956
+ */
6957
+ async verifyAccessToken(accessToken) {
6958
+ const payload = await this.verifyJwt(accessToken);
6959
+ if (payload === null || !UserManagement.hasRequiredAccessTokenClaims(payload)) return null;
6960
+ return payload;
6961
+ }
6962
+ /**
6963
+ * Several token families are signed with an environment's key pair, so a
6964
+ * valid signature alone does not prove a token is a user access token. This
6965
+ * mirrors how the API identifies one: `sid` and `auth_time` are always
6966
+ * minted together on user access tokens, agent tokens classify themselves
6967
+ * with a `sub_profile` other than `user`, and widget session tokens carry
6968
+ * `sub_type`. The registered claims `AccessTokenClaims` guarantees are
6969
+ * checked too, so a token is rejected rather than returned with missing
6970
+ * values.
6971
+ *
6972
+ * Consent tokens for interactive Connect grants also mint `sid` and
6973
+ * `auth_time`. The API excludes those by resolving `sid` to a live
6974
+ * session, which cannot be done offline here.
6975
+ */
6976
+ static hasRequiredAccessTokenClaims(payload) {
6977
+ return typeof payload.sub === "string" && typeof payload.sid === "string" && typeof payload.iss === "string" && typeof payload.exp === "number" && typeof payload.iat === "number" && typeof payload.auth_time === "number" && (payload.sub_profile === void 0 || payload.sub_profile === "user") && payload.sub_type === void 0;
6978
+ }
6979
+ /**
6980
+ * Verify a JWT's signature, expiry and, when configured, issuer against the
6981
+ * environment's JWKS. Resolves to the payload, or `null` when jose rejects
6982
+ * the token; errors that are not JWT validation failures propagate.
6983
+ */
6984
+ async verifyJwt(accessToken) {
6376
6985
  const jwks = await this.getJWKS();
6377
6986
  const { jwtVerify } = await getJose();
6378
6987
  if (!jwks) throw new Error("Must provide clientId to initialize JWKS");
6379
6988
  try {
6380
- await jwtVerify(accessToken, jwks, this.issuer ? { issuer: this.issuer } : void 0);
6381
- return true;
6989
+ const { payload } = await jwtVerify(accessToken, jwks, this.issuer ? { issuer: this.issuer } : void 0);
6990
+ return payload;
6382
6991
  } catch (e) {
6383
- if (e instanceof Error && "code" in e && typeof e.code === "string" && (e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_"))) return false;
6992
+ if (UserManagement.isJwtValidationError(e)) return null;
6384
6993
  throw e;
6385
6994
  }
6386
6995
  }
6996
+ /**
6997
+ * Whether a jose error means the presented token is invalid, as opposed to
6998
+ * a failure to verify it at all. Network errors, JWKS timeouts and crypto
6999
+ * failures propagate so they surface as errors rather than as rejected
7000
+ * tokens.
7001
+ */
7002
+ static isJwtValidationError(e) {
7003
+ if (!(e instanceof Error) || !("code" in e) || typeof e.code !== "string") return false;
7004
+ 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";
7005
+ }
7006
+ async isValidJwt(accessToken) {
7007
+ return await this.verifyJwt(accessToken) !== null;
7008
+ }
6387
7009
  async prepareAuthenticationResponse({ authenticationResponse, session }) {
6388
7010
  if (session?.sealSession) {
6389
7011
  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).");
@@ -6412,7 +7034,7 @@ var UserManagement = class {
6412
7034
  }
6413
7035
  async getSessionFromCookie({ sessionData, cookiePassword = getEnv("WORKOS_COOKIE_PASSWORD") }) {
6414
7036
  if (!cookiePassword) throw new Error("Cookie password is required");
6415
- if (sessionData) return unsealData(sessionData, { password: cookiePassword });
7037
+ if (sessionData) return deserializeSessionCookieData(await unsealData(sessionData, { password: cookiePassword }));
6416
7038
  }
6417
7039
  /**
6418
7040
  * Get an email verification code
@@ -7080,7 +7702,7 @@ var InMemoryStore = class {
7080
7702
  this.flags = { ...newFlags };
7081
7703
  }
7082
7704
  get(slug) {
7083
- return this.flags[slug];
7705
+ return Object.hasOwn(this.flags, slug) ? this.flags[slug] : void 0;
7084
7706
  }
7085
7707
  getAll() {
7086
7708
  return { ...this.flags };
@@ -7108,15 +7730,23 @@ var Evaluator = class {
7108
7730
  getAllFlags(context = {}) {
7109
7731
  const normalizedContext = this.normalizeContext(context);
7110
7732
  const flags = this.store.getAll();
7111
- const result = {};
7112
- for (const slug of Object.keys(flags)) result[slug] = this.evaluate(flags[slug], normalizedContext, false);
7113
- return result;
7733
+ return Object.fromEntries(Object.entries(flags).map(([slug, flag]) => [slug, this.evaluate(flag, normalizedContext, false)]));
7114
7734
  }
7115
7735
  evaluate(entry, normalizedContext, defaultValue) {
7116
7736
  if (!entry) return defaultValue;
7117
- if (!entry.enabled) return false;
7118
- for (const [targetType, targetId] of normalizedContext) if (this.hasEnabledTarget(entry, targetType, targetId)) return true;
7119
- return entry.default_value;
7737
+ if (!entry.enabled) return this.servedValue(entry.off_value, defaultValue);
7738
+ for (const rule of entry.rules) {
7739
+ if (rule.kind !== "conditions" || !rule.conditions?.length) continue;
7740
+ if (rule.conditions.every((condition) => {
7741
+ if (condition.operator !== "one_of" || !condition.target_type || !Array.isArray(condition.values)) return false;
7742
+ const id = normalizedContext.get(condition.target_type);
7743
+ return id !== void 0 && condition.values.includes(id);
7744
+ })) return this.servedValue(rule.value, defaultValue);
7745
+ }
7746
+ return this.servedValue(entry.default_value, defaultValue);
7747
+ }
7748
+ servedValue(value, defaultValue) {
7749
+ return typeof value === "boolean" ? value : defaultValue;
7120
7750
  }
7121
7751
  /**
7122
7752
  * Reduces either context form to target type → ID pairs. Evaluation must
@@ -7126,6 +7756,10 @@ var Evaluator = class {
7126
7756
  */
7127
7757
  normalizeContext(context) {
7128
7758
  const normalized = /* @__PURE__ */ new Map();
7759
+ if (typeof context !== "object" || context === null || Array.isArray(context)) {
7760
+ this.logger?.warn("Ignoring invalid evaluation context");
7761
+ return normalized;
7762
+ }
7129
7763
  const record = context;
7130
7764
  const legacyEntries = [];
7131
7765
  const typedKeys = [];
@@ -7166,18 +7800,37 @@ var Evaluator = class {
7166
7800
  }
7167
7801
  return normalized;
7168
7802
  }
7169
- /**
7170
- * A target participates in evaluation only while its `enabled` is true. A
7171
- * `false` value is reserved for future disabled overrides and is treated
7172
- * as if the target were absent.
7173
- */
7174
- hasEnabledTarget(entry, targetType, targetId) {
7175
- if (targetType === "user") return entry.targets.users.some((t) => t.id === targetId && t.enabled);
7176
- if (targetType === "organization") return entry.targets.organizations.some((t) => t.id === targetId && t.enabled);
7177
- return (entry.targets.custom_targets ?? []).some((t) => t.type === targetType && t.id === targetId && t.enabled);
7178
- }
7179
7803
  };
7180
7804
  //#endregion
7805
+ //#region src/feature-flags/payload.ts
7806
+ function isRecord(value) {
7807
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7808
+ }
7809
+ function isCondition(value) {
7810
+ return isRecord(value) && typeof value.operator === "string" && (value.target_type === void 0 || typeof value.target_type === "string") && (value.operator !== "one_of" || Array.isArray(value.values));
7811
+ }
7812
+ function isRule(value) {
7813
+ return isRecord(value) && typeof value.id === "string" && typeof value.kind === "string" && (value.conditions === void 0 || Array.isArray(value.conditions) && value.conditions.every(isCondition));
7814
+ }
7815
+ function isEntry(value) {
7816
+ return isRecord(value) && typeof value.slug === "string" && typeof value.enabled === "boolean" && "default_value" in value && "off_value" in value && Array.isArray(value.rules) && value.rules.every(isRule);
7817
+ }
7818
+ /** Validate a payload before swapping the store. One invalid entry rejects the
7819
+ * whole payload, so the store never holds a partial snapshot and the last good
7820
+ * one stays intact; bootstrap callers can still be ready. */
7821
+ function parseFlagPollResponse(response) {
7822
+ if (!isRecord(response) || response.version !== 2 || !isRecord(response.flags)) return;
7823
+ const entries = [];
7824
+ for (const [slug, entry] of Object.entries(response.flags)) {
7825
+ if (!isEntry(entry)) return void 0;
7826
+ entries.push([slug, entry]);
7827
+ }
7828
+ return {
7829
+ version: 2,
7830
+ flags: Object.fromEntries(entries)
7831
+ };
7832
+ }
7833
+ //#endregion
7181
7834
  //#region src/feature-flags/runtime-client.ts
7182
7835
  const DEFAULT_POLLING_INTERVAL_MS = 3e4;
7183
7836
  const MIN_POLLING_INTERVAL_MS = 5e3;
@@ -7197,6 +7850,7 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7197
7850
  closed = false;
7198
7851
  initialized = false;
7199
7852
  consecutiveErrors = 0;
7853
+ warnedUnobservedError = false;
7200
7854
  pollTimer = null;
7201
7855
  pollAbortController = null;
7202
7856
  readyResolve = null;
@@ -7223,8 +7877,10 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7223
7877
  this.readyReject = reject;
7224
7878
  });
7225
7879
  this.readyPromise.catch(() => {});
7226
- if (options.bootstrapFlags) {
7227
- this.store.swap(options.bootstrapFlags);
7880
+ if (options.bootstrapFlags !== void 0) {
7881
+ const bootstrap = parseFlagPollResponse(options.bootstrapFlags);
7882
+ if (bootstrap) this.store.swap(bootstrap.flags);
7883
+ else this.logger?.warn("Ignoring bootstrapFlags: expected a v2 flag payload ({ version: 2, flags }). Flags will load on the first successful poll.");
7228
7884
  this.stats.flagCount = this.store.size;
7229
7885
  this.resolveReady();
7230
7886
  }
@@ -7277,12 +7933,13 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7277
7933
  try {
7278
7934
  this.stats.pollCount++;
7279
7935
  this.stats.lastPollAt = /* @__PURE__ */ new Date();
7280
- const data = await this.fetchWithTimeout();
7281
- this.store.swap(data);
7936
+ const data = parseFlagPollResponse(await this.fetchWithTimeout());
7937
+ if (!data) throw new Error("Feature flag poll returned a payload this SDK can't read; keeping the last good flags");
7938
+ this.store.swap(data.flags);
7282
7939
  this.stats.lastSuccessfulPollAt = /* @__PURE__ */ new Date();
7283
7940
  this.stats.flagCount = this.store.size;
7284
7941
  this.consecutiveErrors = 0;
7285
- if (this.initialized) this.emitChanges(previousFlags, data);
7942
+ if (this.initialized) this.emitChanges(previousFlags, data.flags);
7286
7943
  this.initialized = true;
7287
7944
  this.resolveReady();
7288
7945
  this.logger?.debug("Poll successful", { flagCount: this.store.size });
@@ -7291,7 +7948,14 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7291
7948
  const err = error instanceof Error ? error : new Error(String(error));
7292
7949
  this.consecutiveErrors++;
7293
7950
  this.stats.pollErrorCount++;
7294
- this.emit("error", err);
7951
+ if (this.listenerCount("error") > 0) this.emit("error", err);
7952
+ else if (!this.logger) {
7953
+ if (err instanceof UnauthorizedException) this.workos.emitWarning(`Feature flag sync stopped after a 401 and no 'error' listener or logger is attached; keeping the last good flags. Recreate the client with a valid API key to resume. ${err.message}`);
7954
+ else if (!this.warnedUnobservedError) {
7955
+ this.warnedUnobservedError = true;
7956
+ this.workos.emitWarning(`Feature flag sync failed and no 'error' listener or logger is attached; keeping the last good flags and retrying. ${err.message}`);
7957
+ }
7958
+ }
7295
7959
  this.logger?.error("Poll failed", err);
7296
7960
  if (err instanceof UnauthorizedException) {
7297
7961
  this.emit("failed", err);
@@ -7308,7 +7972,7 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7308
7972
  this.pollAbortController = new AbortController();
7309
7973
  const { signal } = this.pollAbortController;
7310
7974
  let timeoutId;
7311
- const fetchPromise = this.workos.get("/sdk/feature-flags").then(({ data }) => data);
7975
+ const fetchPromise = this.workos.get("/sdk/feature-flags?payload_version=2").then(({ data }) => data);
7312
7976
  const timeoutPromise = new Promise((_, reject) => {
7313
7977
  timeoutId = setTimeout(() => {
7314
7978
  this.pollAbortController?.abort();
@@ -7345,8 +8009,8 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7345
8009
  if (!previous || !current) return;
7346
8010
  const allKeys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(current)]);
7347
8011
  for (const key of allKeys) {
7348
- const prev = previous[key];
7349
- const curr = current[key];
8012
+ const prev = Object.hasOwn(previous, key) ? previous[key] : void 0;
8013
+ const curr = Object.hasOwn(current, key) ? current[key] : void 0;
7350
8014
  if (this.hasEntryChanged(prev, curr)) this.emit("change", {
7351
8015
  key,
7352
8016
  previous: prev ?? null,
@@ -7356,18 +8020,22 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
7356
8020
  }
7357
8021
  hasEntryChanged(a, b) {
7358
8022
  if (!a || !b) return a !== b;
7359
- if (a.enabled !== b.enabled || a.default_value !== b.default_value) return true;
7360
- const targetsChanged = (xs, ys) => {
7361
- if (xs.length !== ys.length) return true;
7362
- const map = new Map(ys.map((t) => [t.id, t.enabled]));
7363
- return xs.some((t) => map.get(t.id) !== t.enabled);
7364
- };
7365
- const customTargetsChanged = (xs, ys) => {
7366
- if (xs.length !== ys.length) return true;
7367
- const map = new Map(ys.map((t) => [`${t.type}:${t.id}`, t.enabled]));
7368
- return xs.some((t) => map.get(`${t.type}:${t.id}`) !== t.enabled);
7369
- };
7370
- return targetsChanged(a.targets.users, b.targets.users) || targetsChanged(a.targets.organizations, b.targets.organizations) || customTargetsChanged(a.targets.custom_targets ?? [], b.targets.custom_targets ?? []);
8023
+ const signature = (entry) => JSON.stringify([
8024
+ entry.enabled,
8025
+ entry.default_value,
8026
+ entry.off_value,
8027
+ entry.rules.map((rule) => [
8028
+ rule.id,
8029
+ rule.kind,
8030
+ rule.value,
8031
+ rule.conditions?.map((condition) => JSON.stringify([
8032
+ condition.operator,
8033
+ condition.target_type,
8034
+ Array.isArray(condition.values) ? [...new Set(condition.values)].sort() : condition.values
8035
+ ])).sort()
8036
+ ])
8037
+ ]);
8038
+ return signature(a) !== signature(b);
7371
8039
  }
7372
8040
  };
7373
8041
  //#endregion
@@ -7700,8 +8368,8 @@ const deserializeEnvironmentRole = (role) => ({
7700
8368
  permissions: role.permissions,
7701
8369
  resourceTypeSlug: role.resource_type_slug,
7702
8370
  type: role.type,
7703
- createdAt: role.created_at,
7704
- updatedAt: role.updated_at
8371
+ createdAt: new Date(role.created_at),
8372
+ updatedAt: new Date(role.updated_at)
7705
8373
  });
7706
8374
  //#endregion
7707
8375
  //#region src/authorization/serializers/create-environment-role-options.serializer.ts
@@ -7756,8 +8424,8 @@ const deserializeAuthorizationResource = (resource) => ({
7756
8424
  resourceTypeSlug: resource.resource_type_slug,
7757
8425
  organizationId: resource.organization_id,
7758
8426
  parentResourceId: resource.parent_resource_id,
7759
- createdAt: resource.created_at,
7760
- updatedAt: resource.updated_at
8427
+ createdAt: new Date(resource.created_at),
8428
+ updatedAt: new Date(resource.updated_at)
7761
8429
  });
7762
8430
  //#endregion
7763
8431
  //#region src/authorization/serializers/create-authorization-resource-options.serializer.ts
@@ -7839,8 +8507,8 @@ const deserializeRoleAssignment = (response) => ({
7839
8507
  type: response.source.type,
7840
8508
  groupRoleAssignmentId: response.source.group_role_assignment_id
7841
8509
  },
7842
- createdAt: response.created_at,
7843
- updatedAt: response.updated_at
8510
+ createdAt: new Date(response.created_at),
8511
+ updatedAt: new Date(response.updated_at)
7844
8512
  });
7845
8513
  //#endregion
7846
8514
  //#region src/authorization/serializers/list-role-assignments-options.serializer.ts
@@ -7888,8 +8556,8 @@ const deserializeGroupRoleAssignment = (response) => ({
7888
8556
  externalId: response.resource.external_id,
7889
8557
  resourceTypeSlug: response.resource.resource_type_slug
7890
8558
  },
7891
- createdAt: response.created_at,
7892
- updatedAt: response.updated_at
8559
+ createdAt: new Date(response.created_at),
8560
+ updatedAt: new Date(response.updated_at)
7893
8561
  });
7894
8562
  //#endregion
7895
8563
  //#region src/authorization/serializers/create-group-role-assignment-options.serializer.ts
@@ -9283,7 +9951,7 @@ var Vault = class {
9283
9951
  };
9284
9952
  //#endregion
9285
9953
  //#region package.json
9286
- var version = "11.0.0";
9954
+ var version = "12.1.0";
9287
9955
  //#endregion
9288
9956
  //#region src/workos.ts
9289
9957
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -9609,6 +10277,13 @@ const GenerateLinkIntent = {
9609
10277
  BringYourOwnKey: "bring_your_own_key"
9610
10278
  };
9611
10279
  //#endregion
10280
+ //#region src/directory-sync/interfaces/directory-user-with-groups-state.interface.ts
10281
+ const DirectoryUserWithGroupsState = {
10282
+ Active: "active",
10283
+ Suspended: "suspended",
10284
+ Inactive: "inactive"
10285
+ };
10286
+ //#endregion
9612
10287
  //#region src/organizations/interfaces/domain-data.interface.ts
9613
10288
  let DomainDataState = /* @__PURE__ */ function(DomainDataState) {
9614
10289
  DomainDataState["Verified"] = "verified";
@@ -9629,6 +10304,7 @@ const ItContactIntent = {
9629
10304
  let OrganizationDomainState = /* @__PURE__ */ function(OrganizationDomainState) {
9630
10305
  OrganizationDomainState["Verified"] = "verified";
9631
10306
  OrganizationDomainState["Pending"] = "pending";
10307
+ OrganizationDomainState["Unverified"] = "unverified";
9632
10308
  OrganizationDomainState["Failed"] = "failed";
9633
10309
  return OrganizationDomainState;
9634
10310
  }({});
@@ -9686,6 +10362,6 @@ function createWorkOS(options) {
9686
10362
  return new WorkOS(options);
9687
10363
  }
9688
10364
  //#endregion
9689
- export { GenericServerException as A, OauthException as C, BadRequestException as D, ConflictException as E, FetchHttpClient as M, SubtleCryptoProvider as N, AuthenticationException as O, RateLimitExceededException as S, NoApiKeyProvidedException as T, AutoPaginatable as _, ItContactIntent as a, UnauthorizedException as b, UpdateAuditLogsRetentionRetentionPeriod as c, CookieSession as d, RefreshSessionFailureReason as f, Webhooks as g, PKCE as h, OrganizationDomainVerificationStrategy as i, ApiKeyRequiredException as j, isAuthenticationErrorData as k, WorkOS as l, AuthenticateWithSessionCookieFailureReason as m, ConnectionType as n, DomainDataState as o, serializeRevokeSessionOptions as p, OrganizationDomainState as r, GenerateLinkIntent as s, createWorkOS as t, FeatureFlagsRuntimeClient as u, Actions as v, NotFoundException as w, SignatureVerificationException as x, UnprocessableEntityException as y };
10365
+ 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 };
9690
10366
 
9691
- //# sourceMappingURL=factory-BbGPjwhL.mjs.map
10367
+ //# sourceMappingURL=factory-99SwwalC.mjs.map