@workos-inc/node 10.8.0 → 10.10.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/lib/{factory-MKPb5Egh.mjs → factory-2nVUxmEk.mjs} +196 -11
- package/lib/factory-2nVUxmEk.mjs.map +1 -0
- package/lib/{factory-CoKXdPX2.cjs → factory-CrK6SPfn.cjs} +196 -11
- package/lib/factory-CrK6SPfn.cjs.map +1 -0
- package/lib/{factory-B8vTFojy.d.cts → factory-vzr4nni7.d.cts} +249 -59
- package/lib/{factory-B8vTFojy.d.mts → factory-vzr4nni7.d.mts} +249 -59
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +1 -1
- package/lib/index.worker.cjs +1 -1
- package/lib/index.worker.d.cts +2 -2
- package/lib/index.worker.d.mts +2 -2
- package/lib/index.worker.mjs +1 -1
- package/package.json +1 -1
- package/lib/factory-CoKXdPX2.cjs.map +0 -1
- package/lib/factory-MKPb5Egh.mjs.map +0 -1
|
@@ -821,6 +821,9 @@ const deserializeAuthenticationEvent = (authenticationEvent) => ({
|
|
|
821
821
|
userId: authenticationEvent.user_id
|
|
822
822
|
});
|
|
823
823
|
//#endregion
|
|
824
|
+
//#region src/multi-factor-auth/serializers/sms.serializer.ts
|
|
825
|
+
const deserializeSms = (sms) => ({ phoneNumber: sms.phone_number });
|
|
826
|
+
//#endregion
|
|
824
827
|
//#region src/multi-factor-auth/serializers/totp.serializer.ts
|
|
825
828
|
const deserializeTotp = (totp) => {
|
|
826
829
|
return {
|
|
@@ -845,7 +848,8 @@ const deserializeFactor$1 = (factor) => ({
|
|
|
845
848
|
createdAt: factor.created_at,
|
|
846
849
|
updatedAt: factor.updated_at,
|
|
847
850
|
type: factor.type,
|
|
848
|
-
|
|
851
|
+
...factor.sms ? { sms: deserializeSms(factor.sms) } : {},
|
|
852
|
+
...factor.totp ? { totp: deserializeTotp(factor.totp) } : {},
|
|
849
853
|
userId: factor.user_id
|
|
850
854
|
});
|
|
851
855
|
const deserializeFactorWithSecrets$1 = (factor) => ({
|
|
@@ -912,6 +916,16 @@ const serializeCreateMagicAuthOptions = (options) => ({
|
|
|
912
916
|
//#region src/user-management/serializers/create-password-reset-options.serializer.ts
|
|
913
917
|
const serializeCreatePasswordResetOptions = (options) => ({ email: options.email });
|
|
914
918
|
//#endregion
|
|
919
|
+
//#region src/user-management/serializers/create-user-api-key-options.serializer.ts
|
|
920
|
+
function serializeCreateUserApiKeyOptions(options) {
|
|
921
|
+
return {
|
|
922
|
+
name: options.name,
|
|
923
|
+
organization_id: options.organizationId,
|
|
924
|
+
permissions: options.permissions,
|
|
925
|
+
expires_at: options.expiresAt?.toISOString()
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
//#endregion
|
|
915
929
|
//#region src/user-management/serializers/email-verification.serializer.ts
|
|
916
930
|
const deserializeEmailVerification = (emailVerification) => ({
|
|
917
931
|
object: emailVerification.object,
|
|
@@ -978,6 +992,17 @@ const deserializeInvitationEvent = (invitation) => ({
|
|
|
978
992
|
//#region src/user-management/serializers/list-sessions-options.serializer.ts
|
|
979
993
|
const serializeListSessionsOptions = (options) => ({ ...options });
|
|
980
994
|
//#endregion
|
|
995
|
+
//#region src/user-management/serializers/list-user-api-keys-options.serializer.ts
|
|
996
|
+
function serializeListUserApiKeysOptions(options) {
|
|
997
|
+
return {
|
|
998
|
+
limit: options.limit,
|
|
999
|
+
before: options.before,
|
|
1000
|
+
after: options.after,
|
|
1001
|
+
order: options.order,
|
|
1002
|
+
organization_id: options.organizationId
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
//#endregion
|
|
981
1006
|
//#region src/user-management/serializers/magic-auth.serializer.ts
|
|
982
1007
|
const deserializeMagicAuth = (magicAuth) => ({
|
|
983
1008
|
object: magicAuth.object,
|
|
@@ -1083,6 +1108,34 @@ const serializeUpdateUserOptions = (options) => ({
|
|
|
1083
1108
|
metadata: options.metadata
|
|
1084
1109
|
});
|
|
1085
1110
|
//#endregion
|
|
1111
|
+
//#region src/user-management/serializers/user-api-key.serializer.ts
|
|
1112
|
+
function deserializeUserApiKey(apiKey) {
|
|
1113
|
+
return {
|
|
1114
|
+
object: apiKey.object,
|
|
1115
|
+
id: apiKey.id,
|
|
1116
|
+
owner: {
|
|
1117
|
+
type: "user",
|
|
1118
|
+
id: apiKey.owner.id,
|
|
1119
|
+
organizationId: apiKey.owner.organization_id
|
|
1120
|
+
},
|
|
1121
|
+
name: apiKey.name,
|
|
1122
|
+
obfuscatedValue: apiKey.obfuscated_value,
|
|
1123
|
+
lastUsedAt: apiKey.last_used_at,
|
|
1124
|
+
expiresAt: apiKey.expires_at,
|
|
1125
|
+
permissions: apiKey.permissions,
|
|
1126
|
+
createdAt: apiKey.created_at,
|
|
1127
|
+
updatedAt: apiKey.updated_at
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
//#region src/user-management/serializers/user-api-key-with-value.serializer.ts
|
|
1132
|
+
function deserializeUserApiKeyWithValue(apiKey) {
|
|
1133
|
+
return {
|
|
1134
|
+
...deserializeUserApiKey(apiKey),
|
|
1135
|
+
value: apiKey.value
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
//#endregion
|
|
1086
1139
|
//#region src/user-management/serializers/organization-membership.serializer.ts
|
|
1087
1140
|
const deserializeOrganizationMembership = (organizationMembership) => ({
|
|
1088
1141
|
object: organizationMembership.object,
|
|
@@ -1127,6 +1180,7 @@ const deserializeAction = (actionPayload) => {
|
|
|
1127
1180
|
object: actionPayload.object,
|
|
1128
1181
|
userData: deserializeUserData(actionPayload.user_data),
|
|
1129
1182
|
invitation: actionPayload.invitation ? deserializeInvitation(actionPayload.invitation) : void 0,
|
|
1183
|
+
authenticationMethod: actionPayload.authentication_method,
|
|
1130
1184
|
ipAddress: actionPayload.ip_address,
|
|
1131
1185
|
userAgent: actionPayload.user_agent,
|
|
1132
1186
|
deviceFingerprint: actionPayload.device_fingerprint
|
|
@@ -1137,6 +1191,7 @@ const deserializeAction = (actionPayload) => {
|
|
|
1137
1191
|
user: deserializeUser(actionPayload.user),
|
|
1138
1192
|
organization: actionPayload.organization ? deserializeOrganization(actionPayload.organization) : void 0,
|
|
1139
1193
|
organizationMembership: actionPayload.organization_membership ? deserializeOrganizationMembership(actionPayload.organization_membership) : void 0,
|
|
1194
|
+
authenticationMethod: actionPayload.authentication_method,
|
|
1140
1195
|
ipAddress: actionPayload.ip_address,
|
|
1141
1196
|
userAgent: actionPayload.user_agent,
|
|
1142
1197
|
deviceFingerprint: actionPayload.device_fingerprint,
|
|
@@ -2109,6 +2164,27 @@ function deserializeAgentRegistration(registration) {
|
|
|
2109
2164
|
};
|
|
2110
2165
|
}
|
|
2111
2166
|
//#endregion
|
|
2167
|
+
//#region src/agents/serializers/claim-attempt.serializer.ts
|
|
2168
|
+
function serializeLinkClaimAttemptToExternalUserOptions(options) {
|
|
2169
|
+
return {
|
|
2170
|
+
type: "link_external_user",
|
|
2171
|
+
claim_attempt_token: options.claimAttemptToken,
|
|
2172
|
+
user: {
|
|
2173
|
+
email: options.user.email,
|
|
2174
|
+
external_id: options.user.externalId
|
|
2175
|
+
},
|
|
2176
|
+
...options.organizationId !== void 0 && { organization_id: options.organizationId }
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
function deserializeClaimAttemptResponse(response) {
|
|
2180
|
+
return {
|
|
2181
|
+
id: response.id,
|
|
2182
|
+
status: response.status,
|
|
2183
|
+
userCode: response.user_code,
|
|
2184
|
+
organizations: response.organizations
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
//#endregion
|
|
2112
2188
|
//#region src/agents/serializers/validate-agent-credential.serializer.ts
|
|
2113
2189
|
function serializeValidateAgentCredentialOptions(options) {
|
|
2114
2190
|
return {
|
|
@@ -2162,6 +2238,25 @@ var Agents = class {
|
|
|
2162
2238
|
this.workos = workos;
|
|
2163
2239
|
}
|
|
2164
2240
|
/**
|
|
2241
|
+
* Link a claim attempt to an external user
|
|
2242
|
+
*
|
|
2243
|
+
* Link an external user to a claim attempt and retrieve the code needed
|
|
2244
|
+
* for the agent to complete the claim. The user is looked up by external
|
|
2245
|
+
* ID; if no user exists, one is created. When the user belongs to multiple
|
|
2246
|
+
* organizations, an explicit organization must be provided.
|
|
2247
|
+
*
|
|
2248
|
+
* @param options - Object containing the claim attempt token, user details, and optional organization ID.
|
|
2249
|
+
* @returns {Promise<ClaimAttemptResponse>}
|
|
2250
|
+
* @throws {BadRequestException} 400 - Invalid request, email mismatch, or wrong account.
|
|
2251
|
+
* @throws {ForbiddenException} 403 - Claim denied or auth method disabled.
|
|
2252
|
+
* @throws {ConflictException} 409 - Organization selection required, external ID conflict, or already claimed.
|
|
2253
|
+
* @throws {GoneException} 410 - Claim or user code expired.
|
|
2254
|
+
*/
|
|
2255
|
+
async linkClaimAttemptToExternalUser(options) {
|
|
2256
|
+
const { data } = await this.workos.patch("/agents/claims/attempts", serializeLinkClaimAttemptToExternalUserOptions(options));
|
|
2257
|
+
return deserializeClaimAttemptResponse(data);
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2165
2260
|
* Get an agent registration
|
|
2166
2261
|
*
|
|
2167
2262
|
* Retrieve a single agent registration scoped to the API key's environment.
|
|
@@ -3574,7 +3669,7 @@ var Pipes = class {
|
|
|
3574
3669
|
*/
|
|
3575
3670
|
async deleteUserConnectedAccount(options) {
|
|
3576
3671
|
const { userId, slug } = options;
|
|
3577
|
-
await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
|
|
3672
|
+
await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, { ...options.organizationId !== void 0 && { organization_id: options.organizationId } });
|
|
3578
3673
|
}
|
|
3579
3674
|
/**
|
|
3580
3675
|
* List providers for a user
|
|
@@ -3955,9 +4050,6 @@ const deserializeChallenge = (challenge) => ({
|
|
|
3955
4050
|
authenticationFactorId: challenge.authentication_factor_id
|
|
3956
4051
|
});
|
|
3957
4052
|
//#endregion
|
|
3958
|
-
//#region src/multi-factor-auth/serializers/sms.serializer.ts
|
|
3959
|
-
const deserializeSms = (sms) => ({ phoneNumber: sms.phone_number });
|
|
3960
|
-
//#endregion
|
|
3961
4053
|
//#region src/multi-factor-auth/serializers/factor.serializer.ts
|
|
3962
4054
|
const deserializeFactor = (factor) => ({
|
|
3963
4055
|
object: factor.object,
|
|
@@ -4709,6 +4801,10 @@ let RefreshSessionFailureReason = /* @__PURE__ */ function(RefreshSessionFailure
|
|
|
4709
4801
|
RefreshSessionFailureReason["INVALID_GRANT"] = "invalid_grant";
|
|
4710
4802
|
RefreshSessionFailureReason["MFA_ENROLLMENT"] = "mfa_enrollment";
|
|
4711
4803
|
RefreshSessionFailureReason["SSO_REQUIRED"] = "sso_required";
|
|
4804
|
+
RefreshSessionFailureReason["RATE_LIMIT_EXCEEDED"] = "rate_limit_exceeded";
|
|
4805
|
+
RefreshSessionFailureReason["TIMEOUT"] = "timeout";
|
|
4806
|
+
RefreshSessionFailureReason["SERVER_ERROR"] = "server_error";
|
|
4807
|
+
RefreshSessionFailureReason["NETWORK_ERROR"] = "network_error";
|
|
4712
4808
|
return RefreshSessionFailureReason;
|
|
4713
4809
|
}({});
|
|
4714
4810
|
//#endregion
|
|
@@ -4788,7 +4884,8 @@ var CookieSession = class {
|
|
|
4788
4884
|
const session = await unsealData(this.sessionData, { password: this.cookiePassword });
|
|
4789
4885
|
if (!session.refreshToken || !session.user) return {
|
|
4790
4886
|
authenticated: false,
|
|
4791
|
-
reason: "invalid_session_cookie"
|
|
4887
|
+
reason: "invalid_session_cookie",
|
|
4888
|
+
retryable: false
|
|
4792
4889
|
};
|
|
4793
4890
|
const { org_id: organizationIdFromUserManagementAccessToken } = decodeJwt(session.accessToken);
|
|
4794
4891
|
try {
|
|
@@ -4821,10 +4918,14 @@ var CookieSession = class {
|
|
|
4821
4918
|
impersonator: session.impersonator
|
|
4822
4919
|
};
|
|
4823
4920
|
} catch (error) {
|
|
4824
|
-
|
|
4921
|
+
const terminalReason = classifyTerminalRefreshError(error);
|
|
4922
|
+
if (terminalReason) return {
|
|
4825
4923
|
authenticated: false,
|
|
4826
|
-
reason:
|
|
4924
|
+
reason: terminalReason,
|
|
4925
|
+
retryable: false
|
|
4827
4926
|
};
|
|
4927
|
+
const retryableFailure = classifyRetryableRefreshError(error);
|
|
4928
|
+
if (retryableFailure) return retryableFailure;
|
|
4828
4929
|
throw error;
|
|
4829
4930
|
}
|
|
4830
4931
|
}
|
|
@@ -4857,6 +4958,62 @@ var CookieSession = class {
|
|
|
4857
4958
|
}
|
|
4858
4959
|
}
|
|
4859
4960
|
};
|
|
4961
|
+
/**
|
|
4962
|
+
* Classifies an error thrown while refreshing as a terminal authentication
|
|
4963
|
+
* failure — the session is over and the user must re-authenticate — returning
|
|
4964
|
+
* the matching failure reason, or `null` when the error is not a recognized
|
|
4965
|
+
* terminal failure (and may still be retryable or should be rethrown).
|
|
4966
|
+
*/
|
|
4967
|
+
function classifyTerminalRefreshError(error) {
|
|
4968
|
+
if (error instanceof OauthException && error.error === "invalid_grant") return "invalid_grant";
|
|
4969
|
+
if (error instanceof AuthenticationException) {
|
|
4970
|
+
const code = error.code;
|
|
4971
|
+
if (code === "mfa_enrollment") return "mfa_enrollment";
|
|
4972
|
+
if (code === "sso_required") return "sso_required";
|
|
4973
|
+
}
|
|
4974
|
+
return null;
|
|
4975
|
+
}
|
|
4976
|
+
function classifyRetryableRefreshError(error) {
|
|
4977
|
+
if (error instanceof RateLimitExceededException) return {
|
|
4978
|
+
authenticated: false,
|
|
4979
|
+
reason: "rate_limit_exceeded",
|
|
4980
|
+
retryable: true,
|
|
4981
|
+
retryAfter: error.retryAfter ?? void 0,
|
|
4982
|
+
error
|
|
4983
|
+
};
|
|
4984
|
+
const status = getErrorStatus(error);
|
|
4985
|
+
if (status === 429) return {
|
|
4986
|
+
authenticated: false,
|
|
4987
|
+
reason: "rate_limit_exceeded",
|
|
4988
|
+
retryable: true,
|
|
4989
|
+
error
|
|
4990
|
+
};
|
|
4991
|
+
if (status === 408) return {
|
|
4992
|
+
authenticated: false,
|
|
4993
|
+
reason: "timeout",
|
|
4994
|
+
retryable: true,
|
|
4995
|
+
error
|
|
4996
|
+
};
|
|
4997
|
+
if (status !== void 0 && status >= 500) return {
|
|
4998
|
+
authenticated: false,
|
|
4999
|
+
reason: "server_error",
|
|
5000
|
+
retryable: true,
|
|
5001
|
+
error
|
|
5002
|
+
};
|
|
5003
|
+
if (isNetworkError(error)) return {
|
|
5004
|
+
authenticated: false,
|
|
5005
|
+
reason: "network_error",
|
|
5006
|
+
retryable: true,
|
|
5007
|
+
error
|
|
5008
|
+
};
|
|
5009
|
+
return null;
|
|
5010
|
+
}
|
|
5011
|
+
function getErrorStatus(error) {
|
|
5012
|
+
if (error instanceof OauthException || error instanceof GenericServerException) return error.status;
|
|
5013
|
+
}
|
|
5014
|
+
function isNetworkError(error) {
|
|
5015
|
+
return error instanceof TypeError || error instanceof Error && error.cause instanceof TypeError;
|
|
5016
|
+
}
|
|
4860
5017
|
//#endregion
|
|
4861
5018
|
//#region src/user-management/user-management.ts
|
|
4862
5019
|
var UserManagement = class {
|
|
@@ -5340,6 +5497,34 @@ var UserManagement = class {
|
|
|
5340
5497
|
await this.workos.delete(`/user_management/users/${userId}`);
|
|
5341
5498
|
}
|
|
5342
5499
|
/**
|
|
5500
|
+
* List API keys for a user
|
|
5501
|
+
*
|
|
5502
|
+
* Get a list of API keys owned by a specific user.
|
|
5503
|
+
* @param userId - Unique identifier of the user.
|
|
5504
|
+
* @param options - Pagination and filter options.
|
|
5505
|
+
* @returns {Promise<AutoPaginatable<UserApiKey, SerializedListUserApiKeysOptions>>}
|
|
5506
|
+
* @throws {NotFoundException} 404
|
|
5507
|
+
*/
|
|
5508
|
+
async listUserApiKeys(userId, options) {
|
|
5509
|
+
const serializedOptions = options ? serializeListUserApiKeysOptions(options) : void 0;
|
|
5510
|
+
return new AutoPaginatable(await fetchAndDeserialize(this.workos, `/user_management/users/${userId}/api_keys`, deserializeUserApiKey, serializedOptions), (params) => fetchAndDeserialize(this.workos, `/user_management/users/${userId}/api_keys`, deserializeUserApiKey, params), serializedOptions);
|
|
5511
|
+
}
|
|
5512
|
+
/**
|
|
5513
|
+
* Create an API key for a user
|
|
5514
|
+
*
|
|
5515
|
+
* Create a new API key owned by a user. The user must have an active membership in the specified organization.
|
|
5516
|
+
* @param userId - Unique identifier of the user.
|
|
5517
|
+
* @param options - Object containing the API key properties.
|
|
5518
|
+
* @returns {Promise<UserApiKeyWithValue>}
|
|
5519
|
+
* @throws {BadRequestException} 400
|
|
5520
|
+
* @throws {NotFoundException} 404
|
|
5521
|
+
* @throws {UnprocessableEntityException} 422
|
|
5522
|
+
*/
|
|
5523
|
+
async createUserApiKey(userId, options, requestOptions = {}) {
|
|
5524
|
+
const { data } = await this.workos.post(`/user_management/users/${userId}/api_keys`, serializeCreateUserApiKeyOptions(options), requestOptions);
|
|
5525
|
+
return deserializeUserApiKeyWithValue(data);
|
|
5526
|
+
}
|
|
5527
|
+
/**
|
|
5343
5528
|
* Get user identities
|
|
5344
5529
|
*
|
|
5345
5530
|
* Get a list of identities associated with the user. A user can have multiple associated identities after going through [identity linking](https://workos.com/docs/authkit/identity-linking). Currently only OAuth identities are supported. More provider types may be added in the future.
|
|
@@ -7804,7 +7989,7 @@ var Vault = class {
|
|
|
7804
7989
|
*/
|
|
7805
7990
|
async deleteObject(options) {
|
|
7806
7991
|
const { id } = options;
|
|
7807
|
-
await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, {
|
|
7992
|
+
await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, { ...options.versionCheck !== void 0 && { version_check: options.versionCheck } });
|
|
7808
7993
|
}
|
|
7809
7994
|
/**
|
|
7810
7995
|
* Describe an object
|
|
@@ -7886,7 +8071,7 @@ var Vault = class {
|
|
|
7886
8071
|
};
|
|
7887
8072
|
//#endregion
|
|
7888
8073
|
//#region package.json
|
|
7889
|
-
var version = "10.
|
|
8074
|
+
var version = "10.10.0";
|
|
7890
8075
|
//#endregion
|
|
7891
8076
|
//#region src/workos.ts
|
|
7892
8077
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -8238,4 +8423,4 @@ function createWorkOS(options) {
|
|
|
8238
8423
|
//#endregion
|
|
8239
8424
|
export { FetchHttpClient as A, NoApiKeyProvidedException as C, isAuthenticationErrorData as D, AuthenticationException as E, GenericServerException as O, NotFoundException as S, BadRequestException as T, UnprocessableEntityException as _, DomainDataState as a, RateLimitExceededException as b, FeatureFlagsRuntimeClient as c, serializeRevokeSessionOptions as d, AuthenticateWithSessionCookieFailureReason as f, Actions as g, AutoPaginatable as h, OrganizationDomainVerificationStrategy as i, SubtleCryptoProvider as j, ApiKeyRequiredException as k, CookieSession as l, Webhooks as m, ConnectionType as n, GenerateLinkIntent as o, PKCE as p, OrganizationDomainState as r, WorkOS as s, createWorkOS as t, RefreshSessionFailureReason as u, UnauthorizedException as v, ConflictException as w, OauthException as x, SignatureVerificationException as y };
|
|
8240
8425
|
|
|
8241
|
-
//# sourceMappingURL=factory-
|
|
8426
|
+
//# sourceMappingURL=factory-2nVUxmEk.mjs.map
|