@workos-inc/node 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -0
- package/lib/{factory-BbGPjwhL.mjs → factory-D2Ig6M1S.mjs} +904 -407
- package/lib/factory-D2Ig6M1S.mjs.map +1 -0
- package/lib/{factory-DJd6WXWm.cjs → factory-J5qx-wp3.cjs} +908 -405
- package/lib/factory-J5qx-wp3.cjs.map +1 -0
- package/lib/{factory-C86kGSc7.d.cts → factory-r4pCiC4E.d.cts} +2815 -2293
- package/lib/{factory-G1JU2hJz.d.mts → factory-r4pCiC4E.d.mts} +2816 -2293
- package/lib/index.cjs +50 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +50 -2
- package/lib/index.mjs.map +1 -1
- package/lib/index.worker.cjs +2 -1
- package/lib/index.worker.d.cts +2 -2
- package/lib/index.worker.d.mts +2 -2
- package/lib/index.worker.mjs +2 -2
- package/lib/{webapi-C2FQ2NNL.mjs → webapi-CfgZkeeN.mjs} +13 -2
- package/lib/{webapi-C2FQ2NNL.mjs.map → webapi-CfgZkeeN.mjs.map} +1 -1
- package/lib/webapi-MD5xmNba.cjs.map +1 -1
- package/package.json +2 -2
- package/lib/factory-BbGPjwhL.mjs.map +0 -1
- package/lib/factory-DJd6WXWm.cjs.map +0 -1
- package/lib/rolldown-runtime-D7D4PA-g.mjs +0 -13
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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({
|
|
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/
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
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
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
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/
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
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
|
-
|
|
1750
|
+
organizationId: profile.organization_id ?? null,
|
|
1525
1751
|
connectionId: profile.connection_id,
|
|
1526
1752
|
connectionType: profile.connection_type,
|
|
1527
1753
|
email: profile.email,
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
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
|
-
|
|
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,6 +1972,51 @@ 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,
|
|
@@ -1741,8 +2027,8 @@ const deserializePipesConnectedAccount = (connectedAccount) => ({
|
|
|
1741
2027
|
organizationId: connectedAccount.organization_id,
|
|
1742
2028
|
scopes: connectedAccount.scopes,
|
|
1743
2029
|
state: connectedAccount.state,
|
|
1744
|
-
createdAt: connectedAccount.created_at,
|
|
1745
|
-
updatedAt: connectedAccount.updated_at
|
|
2030
|
+
createdAt: new Date(connectedAccount.created_at),
|
|
2031
|
+
updatedAt: new Date(connectedAccount.updated_at)
|
|
1746
2032
|
});
|
|
1747
2033
|
const deserializePipesConnectionFailed = (connectionFailed) => ({
|
|
1748
2034
|
object: connectionFailed.object,
|
|
@@ -1750,22 +2036,95 @@ const deserializePipesConnectionFailed = (connectionFailed) => ({
|
|
|
1750
2036
|
providerSlug: connectionFailed.provider_slug,
|
|
1751
2037
|
userId: connectionFailed.user_id,
|
|
1752
2038
|
organizationId: connectionFailed.organization_id,
|
|
2039
|
+
...connectionFailed.account_identifier !== void 0 && { accountIdentifier: connectionFailed.account_identifier },
|
|
1753
2040
|
errorCode: connectionFailed.error_code,
|
|
1754
2041
|
errorReason: connectionFailed.error_reason,
|
|
1755
2042
|
providerError: connectionFailed.provider_error,
|
|
1756
2043
|
providerErrorDescription: connectionFailed.provider_error_description,
|
|
1757
|
-
createdAt: connectionFailed.created_at
|
|
2044
|
+
createdAt: new Date(connectionFailed.created_at)
|
|
1758
2045
|
});
|
|
1759
2046
|
const deserializeEvent = (event) => {
|
|
1760
2047
|
const eventBase = {
|
|
1761
2048
|
id: event.id,
|
|
1762
|
-
createdAt: event.created_at,
|
|
2049
|
+
createdAt: new Date(event.created_at),
|
|
1763
2050
|
context: event.context
|
|
1764
2051
|
};
|
|
2052
|
+
const knownEvent = deserializeKnownEvent(event, eventBase);
|
|
2053
|
+
if (knownEvent) return knownEvent;
|
|
2054
|
+
const unknownEvent = event;
|
|
2055
|
+
return {
|
|
2056
|
+
...eventBase,
|
|
2057
|
+
event: unknownEvent.event,
|
|
2058
|
+
data: unknownEvent.data
|
|
2059
|
+
};
|
|
2060
|
+
};
|
|
2061
|
+
function deserializeKnownEvent(event, eventBase) {
|
|
1765
2062
|
switch (event.event) {
|
|
2063
|
+
case "agent.blueprint.created":
|
|
2064
|
+
case "agent.blueprint.updated": return {
|
|
2065
|
+
...eventBase,
|
|
2066
|
+
event: event.event,
|
|
2067
|
+
data: deserializeAgentBlueprintEvent(event.data)
|
|
2068
|
+
};
|
|
2069
|
+
case "agent.blueprint.deleted": return {
|
|
2070
|
+
...eventBase,
|
|
2071
|
+
event: event.event,
|
|
2072
|
+
data: deserializeAgentBlueprintDeletedEvent(event.data)
|
|
2073
|
+
};
|
|
2074
|
+
case "agent.instance.created":
|
|
2075
|
+
case "agent.instance.deleted": return {
|
|
2076
|
+
...eventBase,
|
|
2077
|
+
event: event.event,
|
|
2078
|
+
data: deserializeAgentInstance(event.data)
|
|
2079
|
+
};
|
|
2080
|
+
case "agent.instance.session.created": return {
|
|
2081
|
+
...eventBase,
|
|
2082
|
+
event: event.event,
|
|
2083
|
+
data: deserializeAgentInstanceSessionCreatedEvent(event.data)
|
|
2084
|
+
};
|
|
2085
|
+
case "agent.instance.session.revoked": return {
|
|
2086
|
+
...eventBase,
|
|
2087
|
+
event: event.event,
|
|
2088
|
+
data: deserializeAgentInstanceSessionEvent(event.data)
|
|
2089
|
+
};
|
|
2090
|
+
case "agent.registration.created": return {
|
|
2091
|
+
...eventBase,
|
|
2092
|
+
event: event.event,
|
|
2093
|
+
data: deserializeAgentRegistrationCreatedEvent(event.data)
|
|
2094
|
+
};
|
|
2095
|
+
case "agent.registration.claim.attempt.created": return {
|
|
2096
|
+
...eventBase,
|
|
2097
|
+
event: event.event,
|
|
2098
|
+
data: deserializeAgentRegistrationClaimAttemptCreatedEvent(event.data)
|
|
2099
|
+
};
|
|
2100
|
+
case "agent.registration.claim.completed": return {
|
|
2101
|
+
...eventBase,
|
|
2102
|
+
event: event.event,
|
|
2103
|
+
data: deserializeAgentRegistrationClaimCompletedEvent(event.data)
|
|
2104
|
+
};
|
|
2105
|
+
case "agent.registration.credential.issued": return {
|
|
2106
|
+
...eventBase,
|
|
2107
|
+
event: event.event,
|
|
2108
|
+
data: deserializeAgentRegistrationCredentialIssuedEvent(event.data)
|
|
2109
|
+
};
|
|
2110
|
+
case "agent.registration.organization.switched": return {
|
|
2111
|
+
...eventBase,
|
|
2112
|
+
event: event.event,
|
|
2113
|
+
data: deserializeAgentRegistrationOrganizationSwitchedEvent(event.data)
|
|
2114
|
+
};
|
|
2115
|
+
case "agent.registration.refreshed":
|
|
2116
|
+
case "agent.registration.expired":
|
|
2117
|
+
case "agent.registration.revoked":
|
|
2118
|
+
case "agent.registration.deleted": return {
|
|
2119
|
+
...eventBase,
|
|
2120
|
+
event: event.event,
|
|
2121
|
+
data: deserializeAgentRegistrationLifecycleEvent(event.data)
|
|
2122
|
+
};
|
|
2123
|
+
case "authentication.email_verification_failed":
|
|
1766
2124
|
case "authentication.email_verification_succeeded":
|
|
1767
2125
|
case "authentication.magic_auth_failed":
|
|
1768
2126
|
case "authentication.magic_auth_succeeded":
|
|
2127
|
+
case "authentication.mfa_failed":
|
|
1769
2128
|
case "authentication.mfa_succeeded":
|
|
1770
2129
|
case "authentication.oauth_failed":
|
|
1771
2130
|
case "authentication.oauth_succeeded":
|
|
@@ -1773,8 +2132,11 @@ const deserializeEvent = (event) => {
|
|
|
1773
2132
|
case "authentication.passkey_succeeded":
|
|
1774
2133
|
case "authentication.password_failed":
|
|
1775
2134
|
case "authentication.password_succeeded":
|
|
2135
|
+
case "authentication.reauthentication_succeeded":
|
|
1776
2136
|
case "authentication.sso_failed":
|
|
1777
|
-
case "authentication.
|
|
2137
|
+
case "authentication.sso_started":
|
|
2138
|
+
case "authentication.sso_succeeded":
|
|
2139
|
+
case "authentication.sso_timed_out": return {
|
|
1778
2140
|
...eventBase,
|
|
1779
2141
|
event: event.event,
|
|
1780
2142
|
data: deserializeAuthenticationEvent(event.data)
|
|
@@ -2010,13 +2372,88 @@ const deserializeEvent = (event) => {
|
|
|
2010
2372
|
event: event.event,
|
|
2011
2373
|
data: deserializeVaultByokKeyVerificationCompletedEvent(event.data)
|
|
2012
2374
|
};
|
|
2013
|
-
|
|
2375
|
+
case "action.authentication.denied": return {
|
|
2376
|
+
...eventBase,
|
|
2377
|
+
event: event.event,
|
|
2378
|
+
data: deserializeActionAuthenticationDeniedEvent(event.data)
|
|
2379
|
+
};
|
|
2380
|
+
case "action.user_registration.denied": return {
|
|
2381
|
+
...eventBase,
|
|
2382
|
+
event: event.event,
|
|
2383
|
+
data: deserializeActionUserRegistrationDeniedEvent(event.data)
|
|
2384
|
+
};
|
|
2385
|
+
case "api_key.updated": return {
|
|
2386
|
+
...eventBase,
|
|
2387
|
+
event: event.event,
|
|
2388
|
+
data: deserializeApiKeyUpdatedEvent(event.data)
|
|
2389
|
+
};
|
|
2390
|
+
case "connection.saml_certificate_renewal_required": return {
|
|
2391
|
+
...eventBase,
|
|
2392
|
+
event: event.event,
|
|
2393
|
+
data: deserializeConnectionSamlCertificateRenewalRequiredEvent(event.data)
|
|
2394
|
+
};
|
|
2395
|
+
case "connection.saml_certificate_renewed": return {
|
|
2396
|
+
...eventBase,
|
|
2397
|
+
event: event.event,
|
|
2398
|
+
data: deserializeConnectionSamlCertificateRenewedEvent(event.data)
|
|
2399
|
+
};
|
|
2400
|
+
case "dsync.token.created":
|
|
2401
|
+
case "dsync.token.revoked": return {
|
|
2402
|
+
...eventBase,
|
|
2403
|
+
event: event.event,
|
|
2404
|
+
data: deserializeDirectoryToken(event.data)
|
|
2405
|
+
};
|
|
2406
|
+
case "pipes.account_connection.connected":
|
|
2407
|
+
case "pipes.account_connection.disconnected":
|
|
2408
|
+
case "pipes.account_connection.reauthorization_needed": return {
|
|
2409
|
+
...eventBase,
|
|
2410
|
+
event: event.event,
|
|
2411
|
+
data: deserializePipesConnectedAccount(event.data)
|
|
2412
|
+
};
|
|
2413
|
+
case "pipes.account_connection.add_failed":
|
|
2414
|
+
case "pipes.account_connection.connection_failed": return {
|
|
2415
|
+
...eventBase,
|
|
2416
|
+
event: event.event,
|
|
2417
|
+
data: deserializePipesConnectionFailed(event.data)
|
|
2418
|
+
};
|
|
2419
|
+
case "radar.challenge_created": return {
|
|
2014
2420
|
...eventBase,
|
|
2015
2421
|
event: event.event,
|
|
2016
|
-
data: event.data
|
|
2422
|
+
data: deserializeRadarChallengeCreatedEvent(event.data)
|
|
2017
2423
|
};
|
|
2424
|
+
case "resource_export.completed":
|
|
2425
|
+
case "resource_export.created":
|
|
2426
|
+
case "resource_export.downloaded":
|
|
2427
|
+
case "resource_export.failed": return {
|
|
2428
|
+
...eventBase,
|
|
2429
|
+
event: event.event,
|
|
2430
|
+
data: deserializeResourceExportEvent(event.data)
|
|
2431
|
+
};
|
|
2432
|
+
case "vault.byok_key.deleted": return {
|
|
2433
|
+
...eventBase,
|
|
2434
|
+
event: event.event,
|
|
2435
|
+
data: deserializeVaultByokKeyDeletedEvent(event.data)
|
|
2436
|
+
};
|
|
2437
|
+
case "vault.dek.rekeyed": return {
|
|
2438
|
+
...eventBase,
|
|
2439
|
+
event: event.event,
|
|
2440
|
+
data: deserializeVaultDekRekeyedEvent(event.data)
|
|
2441
|
+
};
|
|
2442
|
+
case "vault.kek.deleted": return {
|
|
2443
|
+
...eventBase,
|
|
2444
|
+
event: event.event,
|
|
2445
|
+
data: deserializeVaultKekDeletedEvent(event.data)
|
|
2446
|
+
};
|
|
2447
|
+
case "waitlist_user.approved":
|
|
2448
|
+
case "waitlist_user.created":
|
|
2449
|
+
case "waitlist_user.denied": return {
|
|
2450
|
+
...eventBase,
|
|
2451
|
+
event: event.event,
|
|
2452
|
+
data: deserializeWaitlistUserEvent(event.data)
|
|
2453
|
+
};
|
|
2454
|
+
default: return;
|
|
2018
2455
|
}
|
|
2019
|
-
}
|
|
2456
|
+
}
|
|
2020
2457
|
//#endregion
|
|
2021
2458
|
//#region src/common/serializers/list.serializer.ts
|
|
2022
2459
|
const deserializeList = (list, deserializer) => ({
|
|
@@ -2241,61 +2678,7 @@ let _josePromise;
|
|
|
2241
2678
|
* @returns Promise that resolves to the jose module
|
|
2242
2679
|
*/
|
|
2243
2680
|
function getJose() {
|
|
2244
|
-
return _josePromise ??= import("./webapi-
|
|
2245
|
-
}
|
|
2246
|
-
//#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
|
-
};
|
|
2681
|
+
return _josePromise ??= import("./webapi-CfgZkeeN.mjs");
|
|
2299
2682
|
}
|
|
2300
2683
|
//#endregion
|
|
2301
2684
|
//#region src/agents/serializers/agent-instance-session.serializer.ts
|
|
@@ -2305,10 +2688,10 @@ function deserializeAgentInstanceSession(session) {
|
|
|
2305
2688
|
id: session.id,
|
|
2306
2689
|
agentInstanceId: session.agent_instance_id,
|
|
2307
2690
|
status: session.status,
|
|
2308
|
-
expiresAt: session.expires_at,
|
|
2309
|
-
revokedAt: session.revoked_at,
|
|
2310
|
-
createdAt: session.created_at,
|
|
2311
|
-
updatedAt: session.updated_at
|
|
2691
|
+
expiresAt: new Date(session.expires_at),
|
|
2692
|
+
revokedAt: session.revoked_at != null ? new Date(session.revoked_at) : null,
|
|
2693
|
+
createdAt: new Date(session.created_at),
|
|
2694
|
+
updatedAt: new Date(session.updated_at)
|
|
2312
2695
|
};
|
|
2313
2696
|
}
|
|
2314
2697
|
function serializeListAgentInstanceSessionsOptions(options) {
|
|
@@ -2322,30 +2705,6 @@ function serializeListAgentInstanceSessionsOptions(options) {
|
|
|
2322
2705
|
};
|
|
2323
2706
|
}
|
|
2324
2707
|
//#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
2708
|
//#region src/agents/serializers/agent-registration.serializer.ts
|
|
2350
2709
|
function deserializeAgentRegistration(registration) {
|
|
2351
2710
|
return {
|
|
@@ -2353,27 +2712,28 @@ function deserializeAgentRegistration(registration) {
|
|
|
2353
2712
|
agentIdentity: {
|
|
2354
2713
|
id: registration.agent_identity.id,
|
|
2355
2714
|
userlandUserId: registration.agent_identity.userland_user_id,
|
|
2356
|
-
createdAt: registration.agent_identity.created_at,
|
|
2357
|
-
updatedAt: registration.agent_identity.updated_at
|
|
2715
|
+
createdAt: new Date(registration.agent_identity.created_at),
|
|
2716
|
+
updatedAt: new Date(registration.agent_identity.updated_at)
|
|
2358
2717
|
},
|
|
2359
2718
|
organizationId: registration.organization_id,
|
|
2360
2719
|
status: registration.status,
|
|
2361
2720
|
kind: registration.kind,
|
|
2721
|
+
revokedAt: registration.revoked_at != null ? new Date(registration.revoked_at) : null,
|
|
2362
2722
|
claim: registration.claim ? {
|
|
2363
2723
|
id: registration.claim.id,
|
|
2364
2724
|
claimCompletion: registration.claim.claim_completion ? {
|
|
2365
2725
|
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
|
|
2726
|
+
createdAt: new Date(registration.claim.claim_completion.created_at),
|
|
2727
|
+
updatedAt: new Date(registration.claim.claim_completion.updated_at),
|
|
2728
|
+
expiresAt: new Date(registration.claim.claim_completion.expires_at),
|
|
2729
|
+
claimedAt: new Date(registration.claim.claim_completion.claimed_at)
|
|
2370
2730
|
} : null,
|
|
2371
|
-
createdAt: registration.claim.created_at,
|
|
2372
|
-
updatedAt: registration.claim.updated_at,
|
|
2373
|
-
expiresAt: registration.claim.expires_at
|
|
2731
|
+
createdAt: new Date(registration.claim.created_at),
|
|
2732
|
+
updatedAt: new Date(registration.claim.updated_at),
|
|
2733
|
+
expiresAt: new Date(registration.claim.expires_at)
|
|
2374
2734
|
} : null,
|
|
2375
|
-
createdAt: registration.created_at,
|
|
2376
|
-
updatedAt: registration.updated_at
|
|
2735
|
+
createdAt: new Date(registration.created_at),
|
|
2736
|
+
updatedAt: new Date(registration.updated_at)
|
|
2377
2737
|
};
|
|
2378
2738
|
}
|
|
2379
2739
|
//#endregion
|
|
@@ -2455,7 +2815,7 @@ function deserializeAgentCredentialValidation(validation) {
|
|
|
2455
2815
|
return {
|
|
2456
2816
|
valid: true,
|
|
2457
2817
|
registrationId: validation.registration_id,
|
|
2458
|
-
expiresAt: validation.expires_at,
|
|
2818
|
+
expiresAt: validation.expires_at != null ? new Date(validation.expires_at) : null,
|
|
2459
2819
|
claims: null
|
|
2460
2820
|
};
|
|
2461
2821
|
}
|
|
@@ -2733,7 +3093,7 @@ var Agents = class {
|
|
|
2733
3093
|
if (!options.checkForRevoked) return {
|
|
2734
3094
|
valid: true,
|
|
2735
3095
|
registrationId: claims.registrationId,
|
|
2736
|
-
expiresAt:
|
|
3096
|
+
expiresAt: /* @__PURE__ */ new Date(claims.expiresAt * 1e3),
|
|
2737
3097
|
claims
|
|
2738
3098
|
};
|
|
2739
3099
|
const remote = await this.validateCredentialRemotely(options);
|
|
@@ -2802,10 +3162,11 @@ function deserializeCreatedApiKey(apiKey) {
|
|
|
2802
3162
|
name: apiKey.name,
|
|
2803
3163
|
obfuscatedValue: apiKey.obfuscated_value,
|
|
2804
3164
|
value: apiKey.value,
|
|
2805
|
-
lastUsedAt: apiKey.last_used_at,
|
|
3165
|
+
lastUsedAt: apiKey.last_used_at != null ? new Date(apiKey.last_used_at) : null,
|
|
3166
|
+
expiresAt: apiKey.expires_at != null ? new Date(apiKey.expires_at) : null,
|
|
2806
3167
|
permissions: apiKey.permissions,
|
|
2807
|
-
createdAt: apiKey.created_at,
|
|
2808
|
-
updatedAt: apiKey.updated_at
|
|
3168
|
+
createdAt: new Date(apiKey.created_at),
|
|
3169
|
+
updatedAt: new Date(apiKey.updated_at)
|
|
2809
3170
|
};
|
|
2810
3171
|
}
|
|
2811
3172
|
//#endregion
|
|
@@ -3241,44 +3602,18 @@ var Connect = class {
|
|
|
3241
3602
|
}
|
|
3242
3603
|
};
|
|
3243
3604
|
//#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
3605
|
//#region src/directory-sync/directory-sync.ts
|
|
3606
|
+
const serializeListDirectoriesOptions = (options) => {
|
|
3607
|
+
const wire = {
|
|
3608
|
+
limit: options.limit,
|
|
3609
|
+
before: options.before,
|
|
3610
|
+
after: options.after,
|
|
3611
|
+
order: options.order
|
|
3612
|
+
};
|
|
3613
|
+
if (options.organizationId !== void 0) wire.organization_id = options.organizationId;
|
|
3614
|
+
if (options.search !== void 0) wire.search = options.search;
|
|
3615
|
+
return wire;
|
|
3616
|
+
};
|
|
3282
3617
|
var DirectorySync = class {
|
|
3283
3618
|
workos;
|
|
3284
3619
|
constructor(workos) {
|
|
@@ -3289,8 +3624,8 @@ var DirectorySync = class {
|
|
|
3289
3624
|
*
|
|
3290
3625
|
* Get a list of all of your existing directories matching the criteria specified.
|
|
3291
3626
|
* @param options - Pagination and filter options.
|
|
3292
|
-
* @returns {Promise<AutoPaginatable<Directory,
|
|
3293
|
-
* @throws 403
|
|
3627
|
+
* @returns {Promise<AutoPaginatable<Directory, PaginationOptions>>}
|
|
3628
|
+
* @throws {AuthorizationException} 403
|
|
3294
3629
|
* @throws {UnprocessableEntityException} 422
|
|
3295
3630
|
*/
|
|
3296
3631
|
async listDirectories(options) {
|
|
@@ -3300,33 +3635,31 @@ var DirectorySync = class {
|
|
|
3300
3635
|
* Get a Directory
|
|
3301
3636
|
*
|
|
3302
3637
|
* Get the details of an existing directory.
|
|
3303
|
-
* @param
|
|
3304
|
-
*
|
|
3305
|
-
* @example
|
|
3306
|
-
* "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
3307
|
-
*
|
|
3638
|
+
* @param options - The request options.
|
|
3639
|
+
* @param options.id - Unique identifier for the Directory.
|
|
3640
|
+
* @example "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
3308
3641
|
* @returns {Promise<Directory>}
|
|
3309
|
-
* @throws 403
|
|
3642
|
+
* @throws {AuthorizationException} 403
|
|
3310
3643
|
* @throws {NotFoundException} 404
|
|
3311
3644
|
*/
|
|
3312
|
-
async getDirectory(
|
|
3313
|
-
const {
|
|
3645
|
+
async getDirectory(options) {
|
|
3646
|
+
const { id } = options;
|
|
3647
|
+
const { data } = await this.workos.get(`/directories/${encodeURIComponent(id)}`);
|
|
3314
3648
|
return deserializeDirectory(data);
|
|
3315
3649
|
}
|
|
3316
3650
|
/**
|
|
3317
3651
|
* Delete a Directory
|
|
3318
3652
|
*
|
|
3319
3653
|
* Permanently deletes an existing directory. It cannot be undone.
|
|
3320
|
-
* @param
|
|
3321
|
-
*
|
|
3322
|
-
* @example
|
|
3323
|
-
* "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
3324
|
-
*
|
|
3654
|
+
* @param options - The request options.
|
|
3655
|
+
* @param options.id - Unique identifier for the Directory.
|
|
3656
|
+
* @example "directory_01ECAZ4NV9QMV47GW873HDCX74"
|
|
3325
3657
|
* @returns {Promise<void>}
|
|
3326
|
-
* @throws 403
|
|
3658
|
+
* @throws {AuthorizationException} 403
|
|
3327
3659
|
*/
|
|
3328
|
-
async deleteDirectory(
|
|
3329
|
-
|
|
3660
|
+
async deleteDirectory(options) {
|
|
3661
|
+
const { id } = options;
|
|
3662
|
+
await this.workos.delete(`/directories/${encodeURIComponent(id)}`);
|
|
3330
3663
|
}
|
|
3331
3664
|
/**
|
|
3332
3665
|
* List Directory Groups
|
|
@@ -3334,12 +3667,29 @@ var DirectorySync = class {
|
|
|
3334
3667
|
* Get a list of all of existing directory groups matching the criteria specified.
|
|
3335
3668
|
* @param options - Pagination and filter options.
|
|
3336
3669
|
* @returns {Promise<AutoPaginatable<DirectoryGroup, ListDirectoryGroupsOptions>>}
|
|
3337
|
-
* @throws 403
|
|
3670
|
+
* @throws {AuthorizationException} 403
|
|
3338
3671
|
* @throws {NotFoundException} 404
|
|
3339
3672
|
* @throws {UnprocessableEntityException} 422
|
|
3340
3673
|
*/
|
|
3341
3674
|
async listGroups(options) {
|
|
3342
|
-
|
|
3675
|
+
const paginationOptions = options;
|
|
3676
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, paginationOptions), (params) => fetchAndDeserialize(this.workos, "/directory_groups", deserializeDirectoryGroup, params), paginationOptions);
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* Get a Directory Group
|
|
3680
|
+
*
|
|
3681
|
+
* Get the details of an existing Directory Group.
|
|
3682
|
+
* @param options - The request options.
|
|
3683
|
+
* @param options.id - Unique identifier for the Directory Group.
|
|
3684
|
+
* @example "directory_group_01E1JJS84MFPPQ3G655FHTKX6Z"
|
|
3685
|
+
* @returns {Promise<DirectoryGroup>}
|
|
3686
|
+
* @throws {AuthorizationException} 403
|
|
3687
|
+
* @throws {NotFoundException} 404
|
|
3688
|
+
*/
|
|
3689
|
+
async getGroup(options) {
|
|
3690
|
+
const { id } = options;
|
|
3691
|
+
const { data } = await this.workos.get(`/directory_groups/${encodeURIComponent(id)}`);
|
|
3692
|
+
return deserializeDirectoryGroup(data);
|
|
3343
3693
|
}
|
|
3344
3694
|
/**
|
|
3345
3695
|
* List Directory Users
|
|
@@ -3347,7 +3697,7 @@ var DirectorySync = class {
|
|
|
3347
3697
|
* Get a list of all of existing Directory Users matching the criteria specified.
|
|
3348
3698
|
* @param options - Pagination and filter options.
|
|
3349
3699
|
* @returns {Promise<AutoPaginatable<DirectoryUserWithGroups<TCustomAttributes>, ListDirectoryUsersOptions>>}
|
|
3350
|
-
* @throws 403
|
|
3700
|
+
* @throws {AuthorizationException} 403
|
|
3351
3701
|
* @throws {NotFoundException} 404
|
|
3352
3702
|
* @throws {UnprocessableEntityException} 422
|
|
3353
3703
|
* @throws {RateLimitExceededException} 429
|
|
@@ -3359,34 +3709,18 @@ var DirectorySync = class {
|
|
|
3359
3709
|
* Get a Directory User
|
|
3360
3710
|
*
|
|
3361
3711
|
* Get the details of an existing Directory User.
|
|
3362
|
-
* @param
|
|
3363
|
-
*
|
|
3364
|
-
* @example
|
|
3365
|
-
* "directory_user_01E1JG7J09H96KYP8HM9B0G5SJ"
|
|
3712
|
+
* @param options - The request options.
|
|
3713
|
+
* @param options.id - Unique identifier for the Directory User.
|
|
3714
|
+
* @example "directory_user_01E1JG7J09H96KYP8HM9B0G5SJ"
|
|
3366
3715
|
* @returns {Promise<DirectoryUserWithGroups<TCustomAttributes>>}
|
|
3367
|
-
* @throws 403
|
|
3716
|
+
* @throws {AuthorizationException} 403
|
|
3368
3717
|
* @throws {NotFoundException} 404
|
|
3369
3718
|
*/
|
|
3370
|
-
async getUser(
|
|
3371
|
-
const {
|
|
3719
|
+
async getUser(options) {
|
|
3720
|
+
const { id } = options;
|
|
3721
|
+
const { data } = await this.workos.get(`/directory_users/${encodeURIComponent(id)}`);
|
|
3372
3722
|
return deserializeDirectoryUserWithGroups(data);
|
|
3373
3723
|
}
|
|
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
3724
|
};
|
|
3391
3725
|
//#endregion
|
|
3392
3726
|
//#region src/events/serializers/list-event-options.serializer.ts
|
|
@@ -3421,6 +3755,43 @@ var Events = class {
|
|
|
3421
3755
|
}
|
|
3422
3756
|
};
|
|
3423
3757
|
//#endregion
|
|
3758
|
+
//#region src/common/utils/encode-path-parameter.ts
|
|
3759
|
+
/**
|
|
3760
|
+
* Encode a caller-supplied identifier for safe interpolation into a single URL
|
|
3761
|
+
* path segment.
|
|
3762
|
+
*
|
|
3763
|
+
* SDK path templates interpolate caller-supplied identifiers (user IDs,
|
|
3764
|
+
* invitation tokens, MFA factor IDs, organization IDs, external IDs, role and
|
|
3765
|
+
* permission slugs, ...) into the request path. Without encoding, a value such
|
|
3766
|
+
* as `../../user_management/users/user_01ABC` would be resolved by the WHATWG
|
|
3767
|
+
* `URL` parser (see `HttpClient.getResourceURL`) into a different API path,
|
|
3768
|
+
* letting an attacker who influences one identifier retarget the request to an
|
|
3769
|
+
* arbitrary same-verb endpoint. `encodeURIComponent` neutralizes this by
|
|
3770
|
+
* percent-encoding the path/query/fragment metacharacters (`/`, `?`, `#`, ...)
|
|
3771
|
+
* that enable the injection, keeping one parameter mapped to exactly one path
|
|
3772
|
+
* segment.
|
|
3773
|
+
*
|
|
3774
|
+
* `encodeURIComponent` alone is not sufficient for the two dot-only segments
|
|
3775
|
+
* `.` and `..`: it leaves them unchanged, and the WHATWG `URL` parser then
|
|
3776
|
+
* removes them as relative path segments (even when a value like `..` is a
|
|
3777
|
+
* single segment, a template such as `/feature-flags/${slug}/enable` supplies
|
|
3778
|
+
* the trailing segment, so `..` still climbs and retargets the request).
|
|
3779
|
+
* Percent-encoding the dots does not help because the parser also treats the
|
|
3780
|
+
* `%2e` forms as dot segments. A `.` or `..` is never a valid WorkOS
|
|
3781
|
+
* identifier, so we fail closed and throw rather than emit an ambiguous path.
|
|
3782
|
+
*
|
|
3783
|
+
* The one deviation from `encodeURIComponent` is that a literal `:` is kept
|
|
3784
|
+
* unescaped. Colons are valid path-segment characters (RFC 3986 `pchar`) and
|
|
3785
|
+
* are used by WorkOS RBAC slugs (e.g. `users:read`); an interpolated value is
|
|
3786
|
+
* always preceded by a `/`-delimited segment, so a `:` can never be read as a
|
|
3787
|
+
* URL scheme. Preserving it keeps the wire format identical for existing slugs.
|
|
3788
|
+
*/
|
|
3789
|
+
function encodePathParameter(value) {
|
|
3790
|
+
const encoded = encodeURIComponent(value).replace(/%3A/gi, ":");
|
|
3791
|
+
if (encoded === "." || encoded === "..") throw new TypeError("Invalid path parameter: a path parameter must not be \".\" or \"..\".");
|
|
3792
|
+
return encoded;
|
|
3793
|
+
}
|
|
3794
|
+
//#endregion
|
|
3424
3795
|
//#region src/organizations/organizations.ts
|
|
3425
3796
|
var Organizations = class {
|
|
3426
3797
|
workos;
|
|
@@ -3677,7 +4048,7 @@ var OrganizationDomains = class {
|
|
|
3677
4048
|
const deserializePasswordlessSession = (passwordlessSession) => ({
|
|
3678
4049
|
id: passwordlessSession.id,
|
|
3679
4050
|
email: passwordlessSession.email,
|
|
3680
|
-
expiresAt: passwordlessSession.expires_at,
|
|
4051
|
+
expiresAt: new Date(passwordlessSession.expires_at),
|
|
3681
4052
|
link: passwordlessSession.link,
|
|
3682
4053
|
object: passwordlessSession.object
|
|
3683
4054
|
});
|
|
@@ -3772,8 +4143,8 @@ const deserializeConnectedAccount = (response) => ({
|
|
|
3772
4143
|
clientSecretLast4: response.client_secret_last_4 ?? null,
|
|
3773
4144
|
config: response.config,
|
|
3774
4145
|
state: response.state,
|
|
3775
|
-
createdAt: response.created_at,
|
|
3776
|
-
updatedAt: response.updated_at
|
|
4146
|
+
createdAt: new Date(response.created_at),
|
|
4147
|
+
updatedAt: new Date(response.updated_at)
|
|
3777
4148
|
});
|
|
3778
4149
|
//#endregion
|
|
3779
4150
|
//#region src/pipes/serializers/data-integration-authorize-url-response.serializer.ts
|
|
@@ -3786,7 +4157,7 @@ const deserializeDataIntegrationVendedCredential = (response) => {
|
|
|
3786
4157
|
authMethod: "oauth",
|
|
3787
4158
|
object: response.object,
|
|
3788
4159
|
value: response.value,
|
|
3789
|
-
expiresAt: response.expires_at,
|
|
4160
|
+
expiresAt: response.expires_at != null ? new Date(response.expires_at) : null,
|
|
3790
4161
|
scopes: response.scopes,
|
|
3791
4162
|
missingScopes: response.missing_scopes,
|
|
3792
4163
|
config: response.config
|
|
@@ -3801,7 +4172,7 @@ const deserializeDataIntegrationVendedCredential = (response) => {
|
|
|
3801
4172
|
authMethod: "client_credentials",
|
|
3802
4173
|
object: response.object,
|
|
3803
4174
|
value: response.value,
|
|
3804
|
-
expiresAt: response.expires_at,
|
|
4175
|
+
expiresAt: response.expires_at != null ? new Date(response.expires_at) : null,
|
|
3805
4176
|
scopes: response.scopes,
|
|
3806
4177
|
missingScopes: response.missing_scopes,
|
|
3807
4178
|
metadata: response.metadata,
|
|
@@ -3866,8 +4237,8 @@ const deserializeDataIntegrationsListResponseDataConnectedAccount = (response) =
|
|
|
3866
4237
|
clientSecretLast4: response.client_secret_last_4 ?? null,
|
|
3867
4238
|
config: response.config,
|
|
3868
4239
|
state: response.state,
|
|
3869
|
-
createdAt: response.created_at,
|
|
3870
|
-
updatedAt: response.updated_at,
|
|
4240
|
+
createdAt: new Date(response.created_at),
|
|
4241
|
+
updatedAt: new Date(response.updated_at),
|
|
3871
4242
|
userlandUserId: response.userland_user_id ?? null
|
|
3872
4243
|
});
|
|
3873
4244
|
//#endregion
|
|
@@ -3884,8 +4255,8 @@ const deserializeDataIntegrationsListResponseData = (response) => ({
|
|
|
3884
4255
|
authMethods: response.auth_methods,
|
|
3885
4256
|
connectionOwner: response.connection_owner,
|
|
3886
4257
|
ownership: response.ownership,
|
|
3887
|
-
createdAt: response.created_at,
|
|
3888
|
-
updatedAt: response.updated_at,
|
|
4258
|
+
createdAt: new Date(response.created_at),
|
|
4259
|
+
updatedAt: new Date(response.updated_at),
|
|
3889
4260
|
connectedAccount: response.connected_account != null ? deserializeDataIntegrationsListResponseDataConnectedAccount(response.connected_account) : null,
|
|
3890
4261
|
connectedAccounts: response.connected_accounts != null ? response.connected_accounts.map(deserializeDataIntegrationsListResponseDataConnectedAccount) : void 0
|
|
3891
4262
|
});
|
|
@@ -4777,12 +5148,13 @@ var Radar = class {
|
|
|
4777
5148
|
* @example "block"
|
|
4778
5149
|
* @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
5150
|
* @example "198.51.100.42"
|
|
4780
|
-
* @returns {Promise<RadarListEntryAlreadyPresentResponse>}
|
|
5151
|
+
* @returns {Promise<RadarListEntryAlreadyPresentResponse | null>}
|
|
4781
5152
|
* @throws {BadRequestException} 400
|
|
4782
5153
|
*/
|
|
4783
5154
|
async addListEntry(options) {
|
|
4784
5155
|
const { type, action, ...payload } = options;
|
|
4785
5156
|
const { data } = await this.workos.post(`/radar/lists/${encodeURIComponent(type)}/${encodeURIComponent(action)}`, serializeRadarStandaloneUpdateRadarListRequest(payload));
|
|
5157
|
+
if (!data) return null;
|
|
4786
5158
|
return deserializeRadarListEntryAlreadyPresentResponse(data);
|
|
4787
5159
|
}
|
|
4788
5160
|
/**
|
|
@@ -4823,7 +5195,7 @@ var AdminPortal = class {
|
|
|
4823
5195
|
* @throws {NotFoundException} 404
|
|
4824
5196
|
* @throws {UnprocessableEntityException} 422
|
|
4825
5197
|
*/
|
|
4826
|
-
async generateLink({ intent, organization, returnUrl, successUrl, intentOptions,
|
|
5198
|
+
async generateLink({ intent, organization, returnUrl, successUrl, intentOptions, itContactEmails }) {
|
|
4827
5199
|
const { data } = await this.workos.post("/portal/generate_link", {
|
|
4828
5200
|
intent,
|
|
4829
5201
|
organization,
|
|
@@ -4833,7 +5205,7 @@ var AdminPortal = class {
|
|
|
4833
5205
|
bookmark_slug: intentOptions.sso.bookmarkSlug,
|
|
4834
5206
|
provider_type: intentOptions.sso.providerType
|
|
4835
5207
|
} } : void 0,
|
|
4836
|
-
|
|
5208
|
+
it_contact_emails: itContactEmails
|
|
4837
5209
|
});
|
|
4838
5210
|
return data;
|
|
4839
5211
|
}
|
|
@@ -5037,9 +5409,9 @@ var SSO = class {
|
|
|
5037
5409
|
const deserializeChallenge = (challenge) => ({
|
|
5038
5410
|
object: challenge.object,
|
|
5039
5411
|
id: challenge.id,
|
|
5040
|
-
createdAt: challenge.created_at,
|
|
5041
|
-
updatedAt: challenge.updated_at,
|
|
5042
|
-
expiresAt: challenge.expires_at,
|
|
5412
|
+
createdAt: new Date(challenge.created_at),
|
|
5413
|
+
updatedAt: new Date(challenge.updated_at),
|
|
5414
|
+
expiresAt: challenge.expires_at != null ? new Date(challenge.expires_at) : void 0,
|
|
5043
5415
|
code: challenge.code,
|
|
5044
5416
|
authenticationFactorId: challenge.authentication_factor_id
|
|
5045
5417
|
});
|
|
@@ -5048,8 +5420,8 @@ const deserializeChallenge = (challenge) => ({
|
|
|
5048
5420
|
const deserializeFactor = (factor) => ({
|
|
5049
5421
|
object: factor.object,
|
|
5050
5422
|
id: factor.id,
|
|
5051
|
-
createdAt: factor.created_at,
|
|
5052
|
-
updatedAt: factor.updated_at,
|
|
5423
|
+
createdAt: new Date(factor.created_at),
|
|
5424
|
+
updatedAt: new Date(factor.updated_at),
|
|
5053
5425
|
type: factor.type,
|
|
5054
5426
|
...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
|
|
5055
5427
|
...factor.totp ? { totp: deserializeTotp(factor.totp) } : {}
|
|
@@ -5057,8 +5429,8 @@ const deserializeFactor = (factor) => ({
|
|
|
5057
5429
|
const deserializeFactorWithSecrets = (factor) => ({
|
|
5058
5430
|
object: factor.object,
|
|
5059
5431
|
id: factor.id,
|
|
5060
|
-
createdAt: factor.created_at,
|
|
5061
|
-
updatedAt: factor.updated_at,
|
|
5432
|
+
createdAt: new Date(factor.created_at),
|
|
5433
|
+
updatedAt: new Date(factor.updated_at),
|
|
5062
5434
|
type: factor.type,
|
|
5063
5435
|
...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
|
|
5064
5436
|
...factor.totp ? { totp: deserializeTotpWithSecrets(factor.totp) } : {}
|
|
@@ -5193,8 +5565,8 @@ const deserializeAuditLogExport = (auditLogExport) => ({
|
|
|
5193
5565
|
id: auditLogExport.id,
|
|
5194
5566
|
state: auditLogExport.state,
|
|
5195
5567
|
url: auditLogExport.url,
|
|
5196
|
-
createdAt: auditLogExport.created_at,
|
|
5197
|
-
updatedAt: auditLogExport.updated_at
|
|
5568
|
+
createdAt: new Date(auditLogExport.created_at),
|
|
5569
|
+
updatedAt: new Date(auditLogExport.updated_at)
|
|
5198
5570
|
});
|
|
5199
5571
|
//#endregion
|
|
5200
5572
|
//#region src/audit-logs/serializers/audit-log-export-options.serializer.ts
|
|
@@ -5269,7 +5641,7 @@ const deserializeAuditLogSchema = (auditLogSchema) => ({
|
|
|
5269
5641
|
})),
|
|
5270
5642
|
actor: auditLogSchema.actor ? { metadata: deserializeMetadata(auditLogSchema.actor.metadata) } : void 0,
|
|
5271
5643
|
metadata: auditLogSchema.metadata ? deserializeMetadata(auditLogSchema.metadata) : void 0,
|
|
5272
|
-
createdAt: auditLogSchema.created_at
|
|
5644
|
+
createdAt: new Date(auditLogSchema.created_at)
|
|
5273
5645
|
});
|
|
5274
5646
|
//#endregion
|
|
5275
5647
|
//#region src/audit-logs/serializers/audit-logs-retention.serializer.ts
|
|
@@ -5690,6 +6062,21 @@ async function unsealData(encryptedData, { password }) {
|
|
|
5690
6062
|
return data;
|
|
5691
6063
|
}
|
|
5692
6064
|
//#endregion
|
|
6065
|
+
//#region src/user-management/serializers/session-cookie-data.serializer.ts
|
|
6066
|
+
const toDate = (value) => value instanceof Date ? value : new Date(value);
|
|
6067
|
+
const deserializeSessionCookieData = (data) => {
|
|
6068
|
+
if (!data.user) return data;
|
|
6069
|
+
return {
|
|
6070
|
+
...data,
|
|
6071
|
+
user: {
|
|
6072
|
+
...data.user,
|
|
6073
|
+
createdAt: toDate(data.user.createdAt),
|
|
6074
|
+
updatedAt: toDate(data.user.updatedAt),
|
|
6075
|
+
lastSignInAt: data.user.lastSignInAt != null ? toDate(data.user.lastSignInAt) : null
|
|
6076
|
+
}
|
|
6077
|
+
};
|
|
6078
|
+
};
|
|
6079
|
+
//#endregion
|
|
5693
6080
|
//#region src/common/utils/env.ts
|
|
5694
6081
|
let detectedRuntime = null;
|
|
5695
6082
|
/**
|
|
@@ -5895,7 +6282,7 @@ var CookieSession = class {
|
|
|
5895
6282
|
authenticated: false,
|
|
5896
6283
|
reason: "no_session_cookie_provided"
|
|
5897
6284
|
};
|
|
5898
|
-
const session = await unsealData(this.sessionData, { password: this.cookiePassword });
|
|
6285
|
+
const session = deserializeSessionCookieData(await unsealData(this.sessionData, { password: this.cookiePassword }));
|
|
5899
6286
|
if (!session.accessToken) return {
|
|
5900
6287
|
authenticated: false,
|
|
5901
6288
|
reason: "invalid_session_cookie"
|
|
@@ -5931,7 +6318,7 @@ var CookieSession = class {
|
|
|
5931
6318
|
*/
|
|
5932
6319
|
async refresh(options = {}) {
|
|
5933
6320
|
const { decodeJwt } = await getJose();
|
|
5934
|
-
const session = await unsealData(this.sessionData, { password: this.cookiePassword });
|
|
6321
|
+
const session = deserializeSessionCookieData(await unsealData(this.sessionData, { password: this.cookiePassword }));
|
|
5935
6322
|
if (!session.refreshToken || !session.user) return {
|
|
5936
6323
|
authenticated: false,
|
|
5937
6324
|
reason: "invalid_session_cookie",
|
|
@@ -6067,7 +6454,7 @@ function isNetworkError(error) {
|
|
|
6067
6454
|
}
|
|
6068
6455
|
//#endregion
|
|
6069
6456
|
//#region src/user-management/user-management.ts
|
|
6070
|
-
var UserManagement = class {
|
|
6457
|
+
var UserManagement = class UserManagement {
|
|
6071
6458
|
workos;
|
|
6072
6459
|
_jwks;
|
|
6073
6460
|
clientId;
|
|
@@ -6348,7 +6735,7 @@ var UserManagement = class {
|
|
|
6348
6735
|
authenticated: false,
|
|
6349
6736
|
reason: "no_session_cookie_provided"
|
|
6350
6737
|
};
|
|
6351
|
-
const session = await unsealData(sessionData, { password: cookiePassword });
|
|
6738
|
+
const session = deserializeSessionCookieData(await unsealData(sessionData, { password: cookiePassword }));
|
|
6352
6739
|
if (!session.accessToken) return {
|
|
6353
6740
|
authenticated: false,
|
|
6354
6741
|
reason: "invalid_session_cookie"
|
|
@@ -6372,18 +6759,74 @@ var UserManagement = class {
|
|
|
6372
6759
|
authenticationMethod: session.authenticationMethod
|
|
6373
6760
|
};
|
|
6374
6761
|
}
|
|
6375
|
-
|
|
6762
|
+
/**
|
|
6763
|
+
* Verify an access token and return its claims.
|
|
6764
|
+
*
|
|
6765
|
+
* Checks the token's signature against the environment's JWKS and its
|
|
6766
|
+
* expiry, plus the issuer when one was configured on the client, and that
|
|
6767
|
+
* the payload carries the claims of a WorkOS user access token. Tokens the
|
|
6768
|
+
* environment signed for another purpose, such as agent or widget session
|
|
6769
|
+
* tokens, are rejected. Resolves to `null` when the token fails any of
|
|
6770
|
+
* those checks, is not a JWT, or was signed by a key the JWKS does not
|
|
6771
|
+
* have. Errors that are not JWT validation failures, such as a network
|
|
6772
|
+
* error while fetching the JWKS, propagate.
|
|
6773
|
+
*
|
|
6774
|
+
* @param accessToken - The access token to verify, for example from an `Authorization: Bearer` header.
|
|
6775
|
+
* @returns {Promise<AccessTokenClaims | null>} The token's claims, or `null` when the token is invalid.
|
|
6776
|
+
* @throws {Error} When no client ID was provided when initializing WorkOS.
|
|
6777
|
+
*/
|
|
6778
|
+
async verifyAccessToken(accessToken) {
|
|
6779
|
+
const payload = await this.verifyJwt(accessToken);
|
|
6780
|
+
if (payload === null || !UserManagement.hasRequiredAccessTokenClaims(payload)) return null;
|
|
6781
|
+
return payload;
|
|
6782
|
+
}
|
|
6783
|
+
/**
|
|
6784
|
+
* Several token families are signed with an environment's key pair, so a
|
|
6785
|
+
* valid signature alone does not prove a token is a user access token. This
|
|
6786
|
+
* mirrors how the API identifies one: `sid` and `auth_time` are always
|
|
6787
|
+
* minted together on user access tokens, agent tokens classify themselves
|
|
6788
|
+
* with a `sub_profile` other than `user`, and widget session tokens carry
|
|
6789
|
+
* `sub_type`. The registered claims `AccessTokenClaims` guarantees are
|
|
6790
|
+
* checked too, so a token is rejected rather than returned with missing
|
|
6791
|
+
* values.
|
|
6792
|
+
*
|
|
6793
|
+
* Consent tokens for interactive Connect grants also mint `sid` and
|
|
6794
|
+
* `auth_time`. The API excludes those by resolving `sid` to a live
|
|
6795
|
+
* session, which cannot be done offline here.
|
|
6796
|
+
*/
|
|
6797
|
+
static hasRequiredAccessTokenClaims(payload) {
|
|
6798
|
+
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;
|
|
6799
|
+
}
|
|
6800
|
+
/**
|
|
6801
|
+
* Verify a JWT's signature, expiry and, when configured, issuer against the
|
|
6802
|
+
* environment's JWKS. Resolves to the payload, or `null` when jose rejects
|
|
6803
|
+
* the token; errors that are not JWT validation failures propagate.
|
|
6804
|
+
*/
|
|
6805
|
+
async verifyJwt(accessToken) {
|
|
6376
6806
|
const jwks = await this.getJWKS();
|
|
6377
6807
|
const { jwtVerify } = await getJose();
|
|
6378
6808
|
if (!jwks) throw new Error("Must provide clientId to initialize JWKS");
|
|
6379
6809
|
try {
|
|
6380
|
-
await jwtVerify(accessToken, jwks, this.issuer ? { issuer: this.issuer } : void 0);
|
|
6381
|
-
return
|
|
6810
|
+
const { payload } = await jwtVerify(accessToken, jwks, this.issuer ? { issuer: this.issuer } : void 0);
|
|
6811
|
+
return payload;
|
|
6382
6812
|
} catch (e) {
|
|
6383
|
-
if (
|
|
6813
|
+
if (UserManagement.isJwtValidationError(e)) return null;
|
|
6384
6814
|
throw e;
|
|
6385
6815
|
}
|
|
6386
6816
|
}
|
|
6817
|
+
/**
|
|
6818
|
+
* Whether a jose error means the presented token is invalid, as opposed to
|
|
6819
|
+
* a failure to verify it at all. Network errors, JWKS timeouts and crypto
|
|
6820
|
+
* failures propagate so they surface as errors rather than as rejected
|
|
6821
|
+
* tokens.
|
|
6822
|
+
*/
|
|
6823
|
+
static isJwtValidationError(e) {
|
|
6824
|
+
if (!(e instanceof Error) || !("code" in e) || typeof e.code !== "string") return false;
|
|
6825
|
+
return e.code.startsWith("ERR_JWT_") || e.code.startsWith("ERR_JWS_") || e.code === "ERR_JWKS_NO_MATCHING_KEY" || e.code === "ERR_JWKS_MULTIPLE_MATCHING_KEYS" || e.code === "ERR_JOSE_NOT_SUPPORTED" || e.code === "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
6826
|
+
}
|
|
6827
|
+
async isValidJwt(accessToken) {
|
|
6828
|
+
return await this.verifyJwt(accessToken) !== null;
|
|
6829
|
+
}
|
|
6387
6830
|
async prepareAuthenticationResponse({ authenticationResponse, session }) {
|
|
6388
6831
|
if (session?.sealSession) {
|
|
6389
6832
|
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 +6855,7 @@ var UserManagement = class {
|
|
|
6412
6855
|
}
|
|
6413
6856
|
async getSessionFromCookie({ sessionData, cookiePassword = getEnv("WORKOS_COOKIE_PASSWORD") }) {
|
|
6414
6857
|
if (!cookiePassword) throw new Error("Cookie password is required");
|
|
6415
|
-
if (sessionData) return unsealData(sessionData, { password: cookiePassword });
|
|
6858
|
+
if (sessionData) return deserializeSessionCookieData(await unsealData(sessionData, { password: cookiePassword }));
|
|
6416
6859
|
}
|
|
6417
6860
|
/**
|
|
6418
6861
|
* Get an email verification code
|
|
@@ -7080,7 +7523,7 @@ var InMemoryStore = class {
|
|
|
7080
7523
|
this.flags = { ...newFlags };
|
|
7081
7524
|
}
|
|
7082
7525
|
get(slug) {
|
|
7083
|
-
return this.flags[slug];
|
|
7526
|
+
return Object.hasOwn(this.flags, slug) ? this.flags[slug] : void 0;
|
|
7084
7527
|
}
|
|
7085
7528
|
getAll() {
|
|
7086
7529
|
return { ...this.flags };
|
|
@@ -7108,15 +7551,23 @@ var Evaluator = class {
|
|
|
7108
7551
|
getAllFlags(context = {}) {
|
|
7109
7552
|
const normalizedContext = this.normalizeContext(context);
|
|
7110
7553
|
const flags = this.store.getAll();
|
|
7111
|
-
|
|
7112
|
-
for (const slug of Object.keys(flags)) result[slug] = this.evaluate(flags[slug], normalizedContext, false);
|
|
7113
|
-
return result;
|
|
7554
|
+
return Object.fromEntries(Object.entries(flags).map(([slug, flag]) => [slug, this.evaluate(flag, normalizedContext, false)]));
|
|
7114
7555
|
}
|
|
7115
7556
|
evaluate(entry, normalizedContext, defaultValue) {
|
|
7116
7557
|
if (!entry) return defaultValue;
|
|
7117
|
-
if (!entry.enabled) return
|
|
7118
|
-
for (const
|
|
7119
|
-
|
|
7558
|
+
if (!entry.enabled) return this.servedValue(entry.off_value, defaultValue);
|
|
7559
|
+
for (const rule of entry.rules) {
|
|
7560
|
+
if (rule.kind !== "conditions" || !rule.conditions?.length) continue;
|
|
7561
|
+
if (rule.conditions.every((condition) => {
|
|
7562
|
+
if (condition.operator !== "one_of" || !condition.target_type || !Array.isArray(condition.values)) return false;
|
|
7563
|
+
const id = normalizedContext.get(condition.target_type);
|
|
7564
|
+
return id !== void 0 && condition.values.includes(id);
|
|
7565
|
+
})) return this.servedValue(rule.value, defaultValue);
|
|
7566
|
+
}
|
|
7567
|
+
return this.servedValue(entry.default_value, defaultValue);
|
|
7568
|
+
}
|
|
7569
|
+
servedValue(value, defaultValue) {
|
|
7570
|
+
return typeof value === "boolean" ? value : defaultValue;
|
|
7120
7571
|
}
|
|
7121
7572
|
/**
|
|
7122
7573
|
* Reduces either context form to target type → ID pairs. Evaluation must
|
|
@@ -7126,6 +7577,10 @@ var Evaluator = class {
|
|
|
7126
7577
|
*/
|
|
7127
7578
|
normalizeContext(context) {
|
|
7128
7579
|
const normalized = /* @__PURE__ */ new Map();
|
|
7580
|
+
if (typeof context !== "object" || context === null || Array.isArray(context)) {
|
|
7581
|
+
this.logger?.warn("Ignoring invalid evaluation context");
|
|
7582
|
+
return normalized;
|
|
7583
|
+
}
|
|
7129
7584
|
const record = context;
|
|
7130
7585
|
const legacyEntries = [];
|
|
7131
7586
|
const typedKeys = [];
|
|
@@ -7166,18 +7621,37 @@ var Evaluator = class {
|
|
|
7166
7621
|
}
|
|
7167
7622
|
return normalized;
|
|
7168
7623
|
}
|
|
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
7624
|
};
|
|
7180
7625
|
//#endregion
|
|
7626
|
+
//#region src/feature-flags/payload.ts
|
|
7627
|
+
function isRecord(value) {
|
|
7628
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7629
|
+
}
|
|
7630
|
+
function isCondition(value) {
|
|
7631
|
+
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));
|
|
7632
|
+
}
|
|
7633
|
+
function isRule(value) {
|
|
7634
|
+
return isRecord(value) && typeof value.id === "string" && typeof value.kind === "string" && (value.conditions === void 0 || Array.isArray(value.conditions) && value.conditions.every(isCondition));
|
|
7635
|
+
}
|
|
7636
|
+
function isEntry(value) {
|
|
7637
|
+
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);
|
|
7638
|
+
}
|
|
7639
|
+
/** Validate a payload before swapping the store. One invalid entry rejects the
|
|
7640
|
+
* whole payload, so the store never holds a partial snapshot and the last good
|
|
7641
|
+
* one stays intact; bootstrap callers can still be ready. */
|
|
7642
|
+
function parseFlagPollResponse(response) {
|
|
7643
|
+
if (!isRecord(response) || response.version !== 2 || !isRecord(response.flags)) return;
|
|
7644
|
+
const entries = [];
|
|
7645
|
+
for (const [slug, entry] of Object.entries(response.flags)) {
|
|
7646
|
+
if (!isEntry(entry)) return void 0;
|
|
7647
|
+
entries.push([slug, entry]);
|
|
7648
|
+
}
|
|
7649
|
+
return {
|
|
7650
|
+
version: 2,
|
|
7651
|
+
flags: Object.fromEntries(entries)
|
|
7652
|
+
};
|
|
7653
|
+
}
|
|
7654
|
+
//#endregion
|
|
7181
7655
|
//#region src/feature-flags/runtime-client.ts
|
|
7182
7656
|
const DEFAULT_POLLING_INTERVAL_MS = 3e4;
|
|
7183
7657
|
const MIN_POLLING_INTERVAL_MS = 5e3;
|
|
@@ -7197,6 +7671,7 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7197
7671
|
closed = false;
|
|
7198
7672
|
initialized = false;
|
|
7199
7673
|
consecutiveErrors = 0;
|
|
7674
|
+
warnedUnobservedError = false;
|
|
7200
7675
|
pollTimer = null;
|
|
7201
7676
|
pollAbortController = null;
|
|
7202
7677
|
readyResolve = null;
|
|
@@ -7223,8 +7698,10 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7223
7698
|
this.readyReject = reject;
|
|
7224
7699
|
});
|
|
7225
7700
|
this.readyPromise.catch(() => {});
|
|
7226
|
-
if (options.bootstrapFlags) {
|
|
7227
|
-
|
|
7701
|
+
if (options.bootstrapFlags !== void 0) {
|
|
7702
|
+
const bootstrap = parseFlagPollResponse(options.bootstrapFlags);
|
|
7703
|
+
if (bootstrap) this.store.swap(bootstrap.flags);
|
|
7704
|
+
else this.logger?.warn("Ignoring bootstrapFlags: expected a v2 flag payload ({ version: 2, flags }). Flags will load on the first successful poll.");
|
|
7228
7705
|
this.stats.flagCount = this.store.size;
|
|
7229
7706
|
this.resolveReady();
|
|
7230
7707
|
}
|
|
@@ -7277,12 +7754,13 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7277
7754
|
try {
|
|
7278
7755
|
this.stats.pollCount++;
|
|
7279
7756
|
this.stats.lastPollAt = /* @__PURE__ */ new Date();
|
|
7280
|
-
const data = await this.fetchWithTimeout();
|
|
7281
|
-
|
|
7757
|
+
const data = parseFlagPollResponse(await this.fetchWithTimeout());
|
|
7758
|
+
if (!data) throw new Error("Feature flag poll returned a payload this SDK can't read; keeping the last good flags");
|
|
7759
|
+
this.store.swap(data.flags);
|
|
7282
7760
|
this.stats.lastSuccessfulPollAt = /* @__PURE__ */ new Date();
|
|
7283
7761
|
this.stats.flagCount = this.store.size;
|
|
7284
7762
|
this.consecutiveErrors = 0;
|
|
7285
|
-
if (this.initialized) this.emitChanges(previousFlags, data);
|
|
7763
|
+
if (this.initialized) this.emitChanges(previousFlags, data.flags);
|
|
7286
7764
|
this.initialized = true;
|
|
7287
7765
|
this.resolveReady();
|
|
7288
7766
|
this.logger?.debug("Poll successful", { flagCount: this.store.size });
|
|
@@ -7291,7 +7769,14 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7291
7769
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
7292
7770
|
this.consecutiveErrors++;
|
|
7293
7771
|
this.stats.pollErrorCount++;
|
|
7294
|
-
this.emit("error", err);
|
|
7772
|
+
if (this.listenerCount("error") > 0) this.emit("error", err);
|
|
7773
|
+
else if (!this.logger) {
|
|
7774
|
+
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}`);
|
|
7775
|
+
else if (!this.warnedUnobservedError) {
|
|
7776
|
+
this.warnedUnobservedError = true;
|
|
7777
|
+
this.workos.emitWarning(`Feature flag sync failed and no 'error' listener or logger is attached; keeping the last good flags and retrying. ${err.message}`);
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
7295
7780
|
this.logger?.error("Poll failed", err);
|
|
7296
7781
|
if (err instanceof UnauthorizedException) {
|
|
7297
7782
|
this.emit("failed", err);
|
|
@@ -7308,7 +7793,7 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7308
7793
|
this.pollAbortController = new AbortController();
|
|
7309
7794
|
const { signal } = this.pollAbortController;
|
|
7310
7795
|
let timeoutId;
|
|
7311
|
-
const fetchPromise = this.workos.get("/sdk/feature-flags").then(({ data }) => data);
|
|
7796
|
+
const fetchPromise = this.workos.get("/sdk/feature-flags?payload_version=2").then(({ data }) => data);
|
|
7312
7797
|
const timeoutPromise = new Promise((_, reject) => {
|
|
7313
7798
|
timeoutId = setTimeout(() => {
|
|
7314
7799
|
this.pollAbortController?.abort();
|
|
@@ -7345,8 +7830,8 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7345
7830
|
if (!previous || !current) return;
|
|
7346
7831
|
const allKeys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(current)]);
|
|
7347
7832
|
for (const key of allKeys) {
|
|
7348
|
-
const prev = previous[key];
|
|
7349
|
-
const curr = current[key];
|
|
7833
|
+
const prev = Object.hasOwn(previous, key) ? previous[key] : void 0;
|
|
7834
|
+
const curr = Object.hasOwn(current, key) ? current[key] : void 0;
|
|
7350
7835
|
if (this.hasEntryChanged(prev, curr)) this.emit("change", {
|
|
7351
7836
|
key,
|
|
7352
7837
|
previous: prev ?? null,
|
|
@@ -7356,18 +7841,22 @@ var FeatureFlagsRuntimeClient = class extends EventEmitter {
|
|
|
7356
7841
|
}
|
|
7357
7842
|
hasEntryChanged(a, b) {
|
|
7358
7843
|
if (!a || !b) return a !== b;
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7844
|
+
const signature = (entry) => JSON.stringify([
|
|
7845
|
+
entry.enabled,
|
|
7846
|
+
entry.default_value,
|
|
7847
|
+
entry.off_value,
|
|
7848
|
+
entry.rules.map((rule) => [
|
|
7849
|
+
rule.id,
|
|
7850
|
+
rule.kind,
|
|
7851
|
+
rule.value,
|
|
7852
|
+
rule.conditions?.map((condition) => JSON.stringify([
|
|
7853
|
+
condition.operator,
|
|
7854
|
+
condition.target_type,
|
|
7855
|
+
Array.isArray(condition.values) ? [...new Set(condition.values)].sort() : condition.values
|
|
7856
|
+
])).sort()
|
|
7857
|
+
])
|
|
7858
|
+
]);
|
|
7859
|
+
return signature(a) !== signature(b);
|
|
7371
7860
|
}
|
|
7372
7861
|
};
|
|
7373
7862
|
//#endregion
|
|
@@ -7700,8 +8189,8 @@ const deserializeEnvironmentRole = (role) => ({
|
|
|
7700
8189
|
permissions: role.permissions,
|
|
7701
8190
|
resourceTypeSlug: role.resource_type_slug,
|
|
7702
8191
|
type: role.type,
|
|
7703
|
-
createdAt: role.created_at,
|
|
7704
|
-
updatedAt: role.updated_at
|
|
8192
|
+
createdAt: new Date(role.created_at),
|
|
8193
|
+
updatedAt: new Date(role.updated_at)
|
|
7705
8194
|
});
|
|
7706
8195
|
//#endregion
|
|
7707
8196
|
//#region src/authorization/serializers/create-environment-role-options.serializer.ts
|
|
@@ -7756,8 +8245,8 @@ const deserializeAuthorizationResource = (resource) => ({
|
|
|
7756
8245
|
resourceTypeSlug: resource.resource_type_slug,
|
|
7757
8246
|
organizationId: resource.organization_id,
|
|
7758
8247
|
parentResourceId: resource.parent_resource_id,
|
|
7759
|
-
createdAt: resource.created_at,
|
|
7760
|
-
updatedAt: resource.updated_at
|
|
8248
|
+
createdAt: new Date(resource.created_at),
|
|
8249
|
+
updatedAt: new Date(resource.updated_at)
|
|
7761
8250
|
});
|
|
7762
8251
|
//#endregion
|
|
7763
8252
|
//#region src/authorization/serializers/create-authorization-resource-options.serializer.ts
|
|
@@ -7839,8 +8328,8 @@ const deserializeRoleAssignment = (response) => ({
|
|
|
7839
8328
|
type: response.source.type,
|
|
7840
8329
|
groupRoleAssignmentId: response.source.group_role_assignment_id
|
|
7841
8330
|
},
|
|
7842
|
-
createdAt: response.created_at,
|
|
7843
|
-
updatedAt: response.updated_at
|
|
8331
|
+
createdAt: new Date(response.created_at),
|
|
8332
|
+
updatedAt: new Date(response.updated_at)
|
|
7844
8333
|
});
|
|
7845
8334
|
//#endregion
|
|
7846
8335
|
//#region src/authorization/serializers/list-role-assignments-options.serializer.ts
|
|
@@ -7888,8 +8377,8 @@ const deserializeGroupRoleAssignment = (response) => ({
|
|
|
7888
8377
|
externalId: response.resource.external_id,
|
|
7889
8378
|
resourceTypeSlug: response.resource.resource_type_slug
|
|
7890
8379
|
},
|
|
7891
|
-
createdAt: response.created_at,
|
|
7892
|
-
updatedAt: response.updated_at
|
|
8380
|
+
createdAt: new Date(response.created_at),
|
|
8381
|
+
updatedAt: new Date(response.updated_at)
|
|
7893
8382
|
});
|
|
7894
8383
|
//#endregion
|
|
7895
8384
|
//#region src/authorization/serializers/create-group-role-assignment-options.serializer.ts
|
|
@@ -9283,7 +9772,7 @@ var Vault = class {
|
|
|
9283
9772
|
};
|
|
9284
9773
|
//#endregion
|
|
9285
9774
|
//#region package.json
|
|
9286
|
-
var version = "
|
|
9775
|
+
var version = "12.0.0";
|
|
9287
9776
|
//#endregion
|
|
9288
9777
|
//#region src/workos.ts
|
|
9289
9778
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -9609,6 +10098,13 @@ const GenerateLinkIntent = {
|
|
|
9609
10098
|
BringYourOwnKey: "bring_your_own_key"
|
|
9610
10099
|
};
|
|
9611
10100
|
//#endregion
|
|
10101
|
+
//#region src/directory-sync/interfaces/directory-user-with-groups-state.interface.ts
|
|
10102
|
+
const DirectoryUserWithGroupsState = {
|
|
10103
|
+
Active: "active",
|
|
10104
|
+
Suspended: "suspended",
|
|
10105
|
+
Inactive: "inactive"
|
|
10106
|
+
};
|
|
10107
|
+
//#endregion
|
|
9612
10108
|
//#region src/organizations/interfaces/domain-data.interface.ts
|
|
9613
10109
|
let DomainDataState = /* @__PURE__ */ function(DomainDataState) {
|
|
9614
10110
|
DomainDataState["Verified"] = "verified";
|
|
@@ -9629,6 +10125,7 @@ const ItContactIntent = {
|
|
|
9629
10125
|
let OrganizationDomainState = /* @__PURE__ */ function(OrganizationDomainState) {
|
|
9630
10126
|
OrganizationDomainState["Verified"] = "verified";
|
|
9631
10127
|
OrganizationDomainState["Pending"] = "pending";
|
|
10128
|
+
OrganizationDomainState["Unverified"] = "unverified";
|
|
9632
10129
|
OrganizationDomainState["Failed"] = "failed";
|
|
9633
10130
|
return OrganizationDomainState;
|
|
9634
10131
|
}({});
|
|
@@ -9686,6 +10183,6 @@ function createWorkOS(options) {
|
|
|
9686
10183
|
return new WorkOS(options);
|
|
9687
10184
|
}
|
|
9688
10185
|
//#endregion
|
|
9689
|
-
export {
|
|
10186
|
+
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
10187
|
|
|
9691
|
-
//# sourceMappingURL=factory-
|
|
10188
|
+
//# sourceMappingURL=factory-D2Ig6M1S.mjs.map
|