@workos-inc/node 10.8.0 → 10.9.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-CoKXdPX2.cjs → factory-Bd19upQB.cjs} +194 -11
- package/lib/factory-Bd19upQB.cjs.map +1 -0
- package/lib/{factory-MKPb5Egh.mjs → factory-BdXIrbcU.mjs} +194 -11
- package/lib/factory-BdXIrbcU.mjs.map +1 -0
- package/lib/{factory-B8vTFojy.d.cts → factory-DmBBe791.d.cts} +244 -58
- package/lib/{factory-B8vTFojy.d.mts → factory-DmBBe791.d.mts} +244 -58
- 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,
|
|
@@ -2109,6 +2162,27 @@ function deserializeAgentRegistration(registration) {
|
|
|
2109
2162
|
};
|
|
2110
2163
|
}
|
|
2111
2164
|
//#endregion
|
|
2165
|
+
//#region src/agents/serializers/claim-attempt.serializer.ts
|
|
2166
|
+
function serializeLinkClaimAttemptToExternalUserOptions(options) {
|
|
2167
|
+
return {
|
|
2168
|
+
type: "link_external_user",
|
|
2169
|
+
claim_attempt_token: options.claimAttemptToken,
|
|
2170
|
+
user: {
|
|
2171
|
+
email: options.user.email,
|
|
2172
|
+
external_id: options.user.externalId
|
|
2173
|
+
},
|
|
2174
|
+
...options.organizationId !== void 0 && { organization_id: options.organizationId }
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
function deserializeClaimAttemptResponse(response) {
|
|
2178
|
+
return {
|
|
2179
|
+
id: response.id,
|
|
2180
|
+
status: response.status,
|
|
2181
|
+
userCode: response.user_code,
|
|
2182
|
+
organizations: response.organizations
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
//#endregion
|
|
2112
2186
|
//#region src/agents/serializers/validate-agent-credential.serializer.ts
|
|
2113
2187
|
function serializeValidateAgentCredentialOptions(options) {
|
|
2114
2188
|
return {
|
|
@@ -2162,6 +2236,25 @@ var Agents = class {
|
|
|
2162
2236
|
this.workos = workos;
|
|
2163
2237
|
}
|
|
2164
2238
|
/**
|
|
2239
|
+
* Link a claim attempt to an external user
|
|
2240
|
+
*
|
|
2241
|
+
* Link an external user to a claim attempt and retrieve the code needed
|
|
2242
|
+
* for the agent to complete the claim. The user is looked up by external
|
|
2243
|
+
* ID; if no user exists, one is created. When the user belongs to multiple
|
|
2244
|
+
* organizations, an explicit organization must be provided.
|
|
2245
|
+
*
|
|
2246
|
+
* @param options - Object containing the claim attempt token, user details, and optional organization ID.
|
|
2247
|
+
* @returns {Promise<ClaimAttemptResponse>}
|
|
2248
|
+
* @throws {BadRequestException} 400 - Invalid request, email mismatch, or wrong account.
|
|
2249
|
+
* @throws {ForbiddenException} 403 - Claim denied or auth method disabled.
|
|
2250
|
+
* @throws {ConflictException} 409 - Organization selection required, external ID conflict, or already claimed.
|
|
2251
|
+
* @throws {GoneException} 410 - Claim or user code expired.
|
|
2252
|
+
*/
|
|
2253
|
+
async linkClaimAttemptToExternalUser(options) {
|
|
2254
|
+
const { data } = await this.workos.patch("/agents/claims/attempts", serializeLinkClaimAttemptToExternalUserOptions(options));
|
|
2255
|
+
return deserializeClaimAttemptResponse(data);
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2165
2258
|
* Get an agent registration
|
|
2166
2259
|
*
|
|
2167
2260
|
* Retrieve a single agent registration scoped to the API key's environment.
|
|
@@ -3574,7 +3667,7 @@ var Pipes = class {
|
|
|
3574
3667
|
*/
|
|
3575
3668
|
async deleteUserConnectedAccount(options) {
|
|
3576
3669
|
const { userId, slug } = options;
|
|
3577
|
-
await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, {
|
|
3670
|
+
await this.workos.delete(`/user_management/users/${encodeURIComponent(userId)}/connected_accounts/${encodeURIComponent(slug)}`, { ...options.organizationId !== void 0 && { organization_id: options.organizationId } });
|
|
3578
3671
|
}
|
|
3579
3672
|
/**
|
|
3580
3673
|
* List providers for a user
|
|
@@ -3955,9 +4048,6 @@ const deserializeChallenge = (challenge) => ({
|
|
|
3955
4048
|
authenticationFactorId: challenge.authentication_factor_id
|
|
3956
4049
|
});
|
|
3957
4050
|
//#endregion
|
|
3958
|
-
//#region src/multi-factor-auth/serializers/sms.serializer.ts
|
|
3959
|
-
const deserializeSms = (sms) => ({ phoneNumber: sms.phone_number });
|
|
3960
|
-
//#endregion
|
|
3961
4051
|
//#region src/multi-factor-auth/serializers/factor.serializer.ts
|
|
3962
4052
|
const deserializeFactor = (factor) => ({
|
|
3963
4053
|
object: factor.object,
|
|
@@ -4709,6 +4799,10 @@ let RefreshSessionFailureReason = /* @__PURE__ */ function(RefreshSessionFailure
|
|
|
4709
4799
|
RefreshSessionFailureReason["INVALID_GRANT"] = "invalid_grant";
|
|
4710
4800
|
RefreshSessionFailureReason["MFA_ENROLLMENT"] = "mfa_enrollment";
|
|
4711
4801
|
RefreshSessionFailureReason["SSO_REQUIRED"] = "sso_required";
|
|
4802
|
+
RefreshSessionFailureReason["RATE_LIMIT_EXCEEDED"] = "rate_limit_exceeded";
|
|
4803
|
+
RefreshSessionFailureReason["TIMEOUT"] = "timeout";
|
|
4804
|
+
RefreshSessionFailureReason["SERVER_ERROR"] = "server_error";
|
|
4805
|
+
RefreshSessionFailureReason["NETWORK_ERROR"] = "network_error";
|
|
4712
4806
|
return RefreshSessionFailureReason;
|
|
4713
4807
|
}({});
|
|
4714
4808
|
//#endregion
|
|
@@ -4788,7 +4882,8 @@ var CookieSession = class {
|
|
|
4788
4882
|
const session = await unsealData(this.sessionData, { password: this.cookiePassword });
|
|
4789
4883
|
if (!session.refreshToken || !session.user) return {
|
|
4790
4884
|
authenticated: false,
|
|
4791
|
-
reason: "invalid_session_cookie"
|
|
4885
|
+
reason: "invalid_session_cookie",
|
|
4886
|
+
retryable: false
|
|
4792
4887
|
};
|
|
4793
4888
|
const { org_id: organizationIdFromUserManagementAccessToken } = decodeJwt(session.accessToken);
|
|
4794
4889
|
try {
|
|
@@ -4821,10 +4916,14 @@ var CookieSession = class {
|
|
|
4821
4916
|
impersonator: session.impersonator
|
|
4822
4917
|
};
|
|
4823
4918
|
} catch (error) {
|
|
4824
|
-
|
|
4919
|
+
const terminalReason = classifyTerminalRefreshError(error);
|
|
4920
|
+
if (terminalReason) return {
|
|
4825
4921
|
authenticated: false,
|
|
4826
|
-
reason:
|
|
4922
|
+
reason: terminalReason,
|
|
4923
|
+
retryable: false
|
|
4827
4924
|
};
|
|
4925
|
+
const retryableFailure = classifyRetryableRefreshError(error);
|
|
4926
|
+
if (retryableFailure) return retryableFailure;
|
|
4828
4927
|
throw error;
|
|
4829
4928
|
}
|
|
4830
4929
|
}
|
|
@@ -4857,6 +4956,62 @@ var CookieSession = class {
|
|
|
4857
4956
|
}
|
|
4858
4957
|
}
|
|
4859
4958
|
};
|
|
4959
|
+
/**
|
|
4960
|
+
* Classifies an error thrown while refreshing as a terminal authentication
|
|
4961
|
+
* failure — the session is over and the user must re-authenticate — returning
|
|
4962
|
+
* the matching failure reason, or `null` when the error is not a recognized
|
|
4963
|
+
* terminal failure (and may still be retryable or should be rethrown).
|
|
4964
|
+
*/
|
|
4965
|
+
function classifyTerminalRefreshError(error) {
|
|
4966
|
+
if (error instanceof OauthException && error.error === "invalid_grant") return "invalid_grant";
|
|
4967
|
+
if (error instanceof AuthenticationException) {
|
|
4968
|
+
const code = error.code;
|
|
4969
|
+
if (code === "mfa_enrollment") return "mfa_enrollment";
|
|
4970
|
+
if (code === "sso_required") return "sso_required";
|
|
4971
|
+
}
|
|
4972
|
+
return null;
|
|
4973
|
+
}
|
|
4974
|
+
function classifyRetryableRefreshError(error) {
|
|
4975
|
+
if (error instanceof RateLimitExceededException) return {
|
|
4976
|
+
authenticated: false,
|
|
4977
|
+
reason: "rate_limit_exceeded",
|
|
4978
|
+
retryable: true,
|
|
4979
|
+
retryAfter: error.retryAfter ?? void 0,
|
|
4980
|
+
error
|
|
4981
|
+
};
|
|
4982
|
+
const status = getErrorStatus(error);
|
|
4983
|
+
if (status === 429) return {
|
|
4984
|
+
authenticated: false,
|
|
4985
|
+
reason: "rate_limit_exceeded",
|
|
4986
|
+
retryable: true,
|
|
4987
|
+
error
|
|
4988
|
+
};
|
|
4989
|
+
if (status === 408) return {
|
|
4990
|
+
authenticated: false,
|
|
4991
|
+
reason: "timeout",
|
|
4992
|
+
retryable: true,
|
|
4993
|
+
error
|
|
4994
|
+
};
|
|
4995
|
+
if (status !== void 0 && status >= 500) return {
|
|
4996
|
+
authenticated: false,
|
|
4997
|
+
reason: "server_error",
|
|
4998
|
+
retryable: true,
|
|
4999
|
+
error
|
|
5000
|
+
};
|
|
5001
|
+
if (isNetworkError(error)) return {
|
|
5002
|
+
authenticated: false,
|
|
5003
|
+
reason: "network_error",
|
|
5004
|
+
retryable: true,
|
|
5005
|
+
error
|
|
5006
|
+
};
|
|
5007
|
+
return null;
|
|
5008
|
+
}
|
|
5009
|
+
function getErrorStatus(error) {
|
|
5010
|
+
if (error instanceof OauthException || error instanceof GenericServerException) return error.status;
|
|
5011
|
+
}
|
|
5012
|
+
function isNetworkError(error) {
|
|
5013
|
+
return error instanceof TypeError || error instanceof Error && error.cause instanceof TypeError;
|
|
5014
|
+
}
|
|
4860
5015
|
//#endregion
|
|
4861
5016
|
//#region src/user-management/user-management.ts
|
|
4862
5017
|
var UserManagement = class {
|
|
@@ -5340,6 +5495,34 @@ var UserManagement = class {
|
|
|
5340
5495
|
await this.workos.delete(`/user_management/users/${userId}`);
|
|
5341
5496
|
}
|
|
5342
5497
|
/**
|
|
5498
|
+
* List API keys for a user
|
|
5499
|
+
*
|
|
5500
|
+
* Get a list of API keys owned by a specific user.
|
|
5501
|
+
* @param userId - Unique identifier of the user.
|
|
5502
|
+
* @param options - Pagination and filter options.
|
|
5503
|
+
* @returns {Promise<AutoPaginatable<UserApiKey, SerializedListUserApiKeysOptions>>}
|
|
5504
|
+
* @throws {NotFoundException} 404
|
|
5505
|
+
*/
|
|
5506
|
+
async listUserApiKeys(userId, options) {
|
|
5507
|
+
const serializedOptions = options ? serializeListUserApiKeysOptions(options) : void 0;
|
|
5508
|
+
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);
|
|
5509
|
+
}
|
|
5510
|
+
/**
|
|
5511
|
+
* Create an API key for a user
|
|
5512
|
+
*
|
|
5513
|
+
* Create a new API key owned by a user. The user must have an active membership in the specified organization.
|
|
5514
|
+
* @param userId - Unique identifier of the user.
|
|
5515
|
+
* @param options - Object containing the API key properties.
|
|
5516
|
+
* @returns {Promise<UserApiKeyWithValue>}
|
|
5517
|
+
* @throws {BadRequestException} 400
|
|
5518
|
+
* @throws {NotFoundException} 404
|
|
5519
|
+
* @throws {UnprocessableEntityException} 422
|
|
5520
|
+
*/
|
|
5521
|
+
async createUserApiKey(userId, options, requestOptions = {}) {
|
|
5522
|
+
const { data } = await this.workos.post(`/user_management/users/${userId}/api_keys`, serializeCreateUserApiKeyOptions(options), requestOptions);
|
|
5523
|
+
return deserializeUserApiKeyWithValue(data);
|
|
5524
|
+
}
|
|
5525
|
+
/**
|
|
5343
5526
|
* Get user identities
|
|
5344
5527
|
*
|
|
5345
5528
|
* 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 +7987,7 @@ var Vault = class {
|
|
|
7804
7987
|
*/
|
|
7805
7988
|
async deleteObject(options) {
|
|
7806
7989
|
const { id } = options;
|
|
7807
|
-
await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, {
|
|
7990
|
+
await this.workos.delete(`/vault/v1/kv/${encodeURIComponent(id)}`, { ...options.versionCheck !== void 0 && { version_check: options.versionCheck } });
|
|
7808
7991
|
}
|
|
7809
7992
|
/**
|
|
7810
7993
|
* Describe an object
|
|
@@ -7886,7 +8069,7 @@ var Vault = class {
|
|
|
7886
8069
|
};
|
|
7887
8070
|
//#endregion
|
|
7888
8071
|
//#region package.json
|
|
7889
|
-
var version = "10.
|
|
8072
|
+
var version = "10.9.0";
|
|
7890
8073
|
//#endregion
|
|
7891
8074
|
//#region src/workos.ts
|
|
7892
8075
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -8423,4 +8606,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
8423
8606
|
}
|
|
8424
8607
|
});
|
|
8425
8608
|
|
|
8426
|
-
//# sourceMappingURL=factory-
|
|
8609
|
+
//# sourceMappingURL=factory-Bd19upQB.cjs.map
|