@workos-inc/node 10.1.0 → 10.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{factory-BNdbGia2.d.mts → factory-CcE8UP1h.d.mts} +94 -19
- package/lib/{factory-B6eXwJEX.mjs → factory-CenLS49y.mjs} +90 -13
- package/lib/factory-CenLS49y.mjs.map +1 -0
- package/lib/{factory-SnCyjvy0.cjs → factory-Cvq9SYzX.cjs} +89 -24
- package/lib/factory-Cvq9SYzX.cjs.map +1 -0
- package/lib/{factory-D4Gq3s2Q.d.cts → factory-eDncFka5.d.cts} +94 -19
- package/lib/index.cjs +12 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +17 -2
- package/lib/index.d.mts +17 -2
- package/lib/index.mjs +12 -2
- package/lib/index.mjs.map +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-B6eXwJEX.mjs.map +0 -1
- package/lib/factory-SnCyjvy0.cjs.map +0 -1
|
@@ -411,6 +411,8 @@ const AUTHENTICATION_ERROR_CODES = new Set([
|
|
|
411
411
|
"mfa_enrollment",
|
|
412
412
|
"mfa_challenge",
|
|
413
413
|
"mfa_verification",
|
|
414
|
+
"radar_email_challenge",
|
|
415
|
+
"radar_sms_challenge",
|
|
414
416
|
"sso_required"
|
|
415
417
|
]);
|
|
416
418
|
function parseAuthenticationErrorCode(value) {
|
|
@@ -429,12 +431,14 @@ var AuthenticationException = class extends GenericServerException {
|
|
|
429
431
|
name = "AuthenticationException";
|
|
430
432
|
code;
|
|
431
433
|
pendingAuthenticationToken;
|
|
434
|
+
radarChallengeId;
|
|
432
435
|
constructor(status, rawData, requestID) {
|
|
433
436
|
const code = getAuthenticationErrorCode(rawData);
|
|
434
437
|
super(status, rawData.message ?? rawData.error_description, rawData, requestID);
|
|
435
438
|
this.rawData = rawData;
|
|
436
439
|
this.code = code;
|
|
437
440
|
this.pendingAuthenticationToken = rawData.pending_authentication_token;
|
|
441
|
+
this.radarChallengeId = rawData.radar_challenge_id;
|
|
438
442
|
}
|
|
439
443
|
};
|
|
440
444
|
//#endregion
|
|
@@ -671,6 +675,31 @@ const serializeAuthenticateWithMagicAuthOptions = (options) => ({
|
|
|
671
675
|
radar_auth_attempt_id: options.radarAuthAttemptId
|
|
672
676
|
});
|
|
673
677
|
//#endregion
|
|
678
|
+
//#region src/user-management/serializers/authenticate-with-radar-email-challenge-options.serializer.ts
|
|
679
|
+
const serializeAuthenticateWithRadarEmailChallengeOptions = (options) => ({
|
|
680
|
+
grant_type: "urn:workos:oauth:grant-type:radar-email-challenge:code",
|
|
681
|
+
client_id: options.clientId,
|
|
682
|
+
client_secret: options.clientSecret,
|
|
683
|
+
code: options.code,
|
|
684
|
+
radar_challenge_id: options.radarChallengeId,
|
|
685
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
686
|
+
ip_address: options.ipAddress,
|
|
687
|
+
user_agent: options.userAgent
|
|
688
|
+
});
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/user-management/serializers/authenticate-with-radar-sms-challenge-options.serializer.ts
|
|
691
|
+
const serializeAuthenticateWithRadarSmsChallengeOptions = (options) => ({
|
|
692
|
+
grant_type: "urn:workos:oauth:grant-type:radar-sms-challenge:code",
|
|
693
|
+
client_id: options.clientId,
|
|
694
|
+
client_secret: options.clientSecret,
|
|
695
|
+
code: options.code,
|
|
696
|
+
verification_id: options.verificationId,
|
|
697
|
+
phone_number: options.phoneNumber,
|
|
698
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
699
|
+
ip_address: options.ipAddress,
|
|
700
|
+
user_agent: options.userAgent
|
|
701
|
+
});
|
|
702
|
+
//#endregion
|
|
674
703
|
//#region src/user-management/serializers/authenticate-with-password-options.serializer.ts
|
|
675
704
|
const serializeAuthenticateWithPasswordOptions = (options) => ({
|
|
676
705
|
grant_type: "password",
|
|
@@ -970,6 +999,15 @@ const serializeCreateUserOptions = (options) => ({
|
|
|
970
999
|
user_agent: options.userAgent
|
|
971
1000
|
});
|
|
972
1001
|
//#endregion
|
|
1002
|
+
//#region src/user-management/serializers/send-radar-sms-challenge-options.serializer.ts
|
|
1003
|
+
const serializeSendRadarSmsChallengeOptions = (options) => ({
|
|
1004
|
+
user_id: options.userId,
|
|
1005
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
1006
|
+
phone_number: options.phoneNumber,
|
|
1007
|
+
ip_address: options.ipAddress,
|
|
1008
|
+
user_agent: options.userAgent
|
|
1009
|
+
});
|
|
1010
|
+
//#endregion
|
|
973
1011
|
//#region src/user-management/serializers/update-user-options.serializer.ts
|
|
974
1012
|
const serializeUpdateUserOptions = (options) => ({
|
|
975
1013
|
email: options.email,
|
|
@@ -4307,6 +4345,42 @@ var UserManagement = class {
|
|
|
4307
4345
|
session
|
|
4308
4346
|
});
|
|
4309
4347
|
}
|
|
4348
|
+
/** Send a Radar SMS challenge. */
|
|
4349
|
+
async sendRadarSmsChallenge(payload) {
|
|
4350
|
+
const { data } = await this.workos.post("/user_management/radar_challenges", serializeSendRadarSmsChallengeOptions(payload));
|
|
4351
|
+
return {
|
|
4352
|
+
verificationId: data.verification_id,
|
|
4353
|
+
phoneNumber: data.phone_number
|
|
4354
|
+
};
|
|
4355
|
+
}
|
|
4356
|
+
/** Authenticate with Radar SMS challenge. */
|
|
4357
|
+
async authenticateWithRadarSmsChallenge(payload) {
|
|
4358
|
+
const { session, clientId, ...remainingPayload } = payload;
|
|
4359
|
+
const resolvedClientId = this.resolveClientId(clientId);
|
|
4360
|
+
const { data } = await this.workos.post("/user_management/authenticate", serializeAuthenticateWithRadarSmsChallengeOptions({
|
|
4361
|
+
...remainingPayload,
|
|
4362
|
+
clientId: resolvedClientId,
|
|
4363
|
+
clientSecret: this.workos.key
|
|
4364
|
+
}));
|
|
4365
|
+
return this.prepareAuthenticationResponse({
|
|
4366
|
+
authenticationResponse: deserializeAuthenticationResponse(data),
|
|
4367
|
+
session
|
|
4368
|
+
});
|
|
4369
|
+
}
|
|
4370
|
+
/** Authenticate with Radar email challenge. */
|
|
4371
|
+
async authenticateWithRadarEmailChallenge(payload) {
|
|
4372
|
+
const { session, clientId, ...remainingPayload } = payload;
|
|
4373
|
+
const resolvedClientId = this.resolveClientId(clientId);
|
|
4374
|
+
const { data } = await this.workos.post("/user_management/authenticate", serializeAuthenticateWithRadarEmailChallengeOptions({
|
|
4375
|
+
...remainingPayload,
|
|
4376
|
+
clientId: resolvedClientId,
|
|
4377
|
+
clientSecret: this.workos.key
|
|
4378
|
+
}));
|
|
4379
|
+
return this.prepareAuthenticationResponse({
|
|
4380
|
+
authenticationResponse: deserializeAuthenticationResponse(data),
|
|
4381
|
+
session
|
|
4382
|
+
});
|
|
4383
|
+
}
|
|
4310
4384
|
async authenticateWithSessionCookie({ sessionData, cookiePassword = getEnv("WORKOS_COOKIE_PASSWORD") }) {
|
|
4311
4385
|
if (!cookiePassword) throw new Error("Cookie password is required");
|
|
4312
4386
|
if (!await this.getJWKS()) throw new Error("Must provide clientId to initialize JWKS");
|
|
@@ -5364,13 +5438,15 @@ var Groups = class {
|
|
|
5364
5438
|
}
|
|
5365
5439
|
};
|
|
5366
5440
|
//#endregion
|
|
5367
|
-
//#region src/widgets/
|
|
5368
|
-
const
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5441
|
+
//#region src/widgets/serializers/widget-session-token-response.serializer.ts
|
|
5442
|
+
const deserializeWidgetSessionTokenResponse = (response) => ({ token: response.token });
|
|
5443
|
+
//#endregion
|
|
5444
|
+
//#region src/widgets/serializers/widget-session-token.serializer.ts
|
|
5445
|
+
const serializeGetTokenOptions = (model) => ({
|
|
5446
|
+
organization_id: model.organizationId,
|
|
5447
|
+
user_id: model.userId,
|
|
5448
|
+
scopes: model.scopes
|
|
5372
5449
|
});
|
|
5373
|
-
const deserializeGetTokenResponse = (data) => ({ token: data.token });
|
|
5374
5450
|
//#endregion
|
|
5375
5451
|
//#region src/widgets/widgets.ts
|
|
5376
5452
|
var Widgets = class {
|
|
@@ -5382,15 +5458,16 @@ var Widgets = class {
|
|
|
5382
5458
|
* Generate a widget token
|
|
5383
5459
|
*
|
|
5384
5460
|
* Generate a widget token scoped to an organization and user with the specified scopes.
|
|
5385
|
-
* @param
|
|
5386
|
-
* @returns {Promise<
|
|
5461
|
+
* @param options - The request options.
|
|
5462
|
+
* @returns {Promise<WidgetSessionTokenResponse>}
|
|
5387
5463
|
* @throws {BadRequestException} 400
|
|
5388
5464
|
* @throws {NotFoundException} 404
|
|
5389
5465
|
* @throws {UnprocessableEntityException} 422
|
|
5390
5466
|
*/
|
|
5391
|
-
async createToken(
|
|
5467
|
+
async createToken(options) {
|
|
5468
|
+
const payload = options;
|
|
5392
5469
|
const { data } = await this.workos.post("/widgets/token", serializeGetTokenOptions(payload));
|
|
5393
|
-
return
|
|
5470
|
+
return deserializeWidgetSessionTokenResponse(data);
|
|
5394
5471
|
}
|
|
5395
5472
|
};
|
|
5396
5473
|
//#endregion
|
|
@@ -6828,7 +6905,7 @@ var Vault = class {
|
|
|
6828
6905
|
};
|
|
6829
6906
|
//#endregion
|
|
6830
6907
|
//#region package.json
|
|
6831
|
-
var version = "10.
|
|
6908
|
+
var version = "10.2.0";
|
|
6832
6909
|
//#endregion
|
|
6833
6910
|
//#region src/workos.ts
|
|
6834
6911
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -7380,24 +7457,12 @@ Object.defineProperty(exports, "createWorkOS", {
|
|
|
7380
7457
|
return createWorkOS;
|
|
7381
7458
|
}
|
|
7382
7459
|
});
|
|
7383
|
-
Object.defineProperty(exports, "deserializeGetTokenResponse", {
|
|
7384
|
-
enumerable: true,
|
|
7385
|
-
get: function() {
|
|
7386
|
-
return deserializeGetTokenResponse;
|
|
7387
|
-
}
|
|
7388
|
-
});
|
|
7389
7460
|
Object.defineProperty(exports, "isAuthenticationErrorData", {
|
|
7390
7461
|
enumerable: true,
|
|
7391
7462
|
get: function() {
|
|
7392
7463
|
return isAuthenticationErrorData;
|
|
7393
7464
|
}
|
|
7394
7465
|
});
|
|
7395
|
-
Object.defineProperty(exports, "serializeGetTokenOptions", {
|
|
7396
|
-
enumerable: true,
|
|
7397
|
-
get: function() {
|
|
7398
|
-
return serializeGetTokenOptions;
|
|
7399
|
-
}
|
|
7400
|
-
});
|
|
7401
7466
|
Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
7402
7467
|
enumerable: true,
|
|
7403
7468
|
get: function() {
|
|
@@ -7405,4 +7470,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
7405
7470
|
}
|
|
7406
7471
|
});
|
|
7407
7472
|
|
|
7408
|
-
//# sourceMappingURL=factory-
|
|
7473
|
+
//# sourceMappingURL=factory-Cvq9SYzX.cjs.map
|