@workos-inc/node 10.1.0 → 10.2.1
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-B6eXwJEX.mjs → factory-Bp8G8dsp.mjs} +112 -57
- package/lib/factory-Bp8G8dsp.mjs.map +1 -0
- package/lib/{factory-SnCyjvy0.cjs → factory-BzpScK-h.cjs} +111 -68
- package/lib/factory-BzpScK-h.cjs.map +1 -0
- package/lib/{factory-BNdbGia2.d.mts → factory-C2wHWEA5.d.cts} +95 -21
- package/lib/{factory-D4Gq3s2Q.d.cts → factory-C2wHWEA5.d.mts} +95 -21
- 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.cjs.map +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/lib/index.worker.mjs.map +1 -1
- package/lib/{webapi-lTzmUixq.cjs → webapi-CVu-Hjaz.cjs} +1 -1
- package/lib/{webapi-CKFbiPvQ.mjs.map → webapi-CVu-Hjaz.cjs.map} +1 -1
- package/lib/{webapi-CKFbiPvQ.mjs → webapi-S8D5YgJz.mjs} +1 -1
- package/lib/{webapi-lTzmUixq.cjs.map → webapi-S8D5YgJz.mjs.map} +1 -1
- package/package.json +1 -1
- package/lib/factory-B6eXwJEX.mjs.map +0 -1
- package/lib/factory-SnCyjvy0.cjs.map +0 -1
|
@@ -349,8 +349,20 @@ var FetchHttpClientResponse = class FetchHttpClientResponse extends HttpClientRe
|
|
|
349
349
|
getRawResponse() {
|
|
350
350
|
return this._res;
|
|
351
351
|
}
|
|
352
|
-
toJSON() {
|
|
353
|
-
|
|
352
|
+
async toJSON() {
|
|
353
|
+
if (!this._res.headers.get("content-type")?.includes("application/json")) return null;
|
|
354
|
+
const rawBody = await this._res.text();
|
|
355
|
+
try {
|
|
356
|
+
return JSON.parse(rawBody);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (error instanceof SyntaxError) throw new ParseError({
|
|
359
|
+
message: error.message,
|
|
360
|
+
rawBody,
|
|
361
|
+
rawStatus: this._res.status,
|
|
362
|
+
requestID: this._res.headers.get("X-Request-ID") ?? ""
|
|
363
|
+
});
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
354
366
|
}
|
|
355
367
|
static _transformHeadersToObject(headers) {
|
|
356
368
|
const headersObj = {};
|
|
@@ -411,6 +423,8 @@ const AUTHENTICATION_ERROR_CODES = new Set([
|
|
|
411
423
|
"mfa_enrollment",
|
|
412
424
|
"mfa_challenge",
|
|
413
425
|
"mfa_verification",
|
|
426
|
+
"radar_email_challenge",
|
|
427
|
+
"radar_sms_challenge",
|
|
414
428
|
"sso_required"
|
|
415
429
|
]);
|
|
416
430
|
function parseAuthenticationErrorCode(value) {
|
|
@@ -429,12 +443,14 @@ var AuthenticationException = class extends GenericServerException {
|
|
|
429
443
|
name = "AuthenticationException";
|
|
430
444
|
code;
|
|
431
445
|
pendingAuthenticationToken;
|
|
446
|
+
radarChallengeId;
|
|
432
447
|
constructor(status, rawData, requestID) {
|
|
433
448
|
const code = getAuthenticationErrorCode(rawData);
|
|
434
449
|
super(status, rawData.message ?? rawData.error_description, rawData, requestID);
|
|
435
450
|
this.rawData = rawData;
|
|
436
451
|
this.code = code;
|
|
437
452
|
this.pendingAuthenticationToken = rawData.pending_authentication_token;
|
|
453
|
+
this.radarChallengeId = rawData.radar_challenge_id;
|
|
438
454
|
}
|
|
439
455
|
};
|
|
440
456
|
//#endregion
|
|
@@ -671,6 +687,31 @@ const serializeAuthenticateWithMagicAuthOptions = (options) => ({
|
|
|
671
687
|
radar_auth_attempt_id: options.radarAuthAttemptId
|
|
672
688
|
});
|
|
673
689
|
//#endregion
|
|
690
|
+
//#region src/user-management/serializers/authenticate-with-radar-email-challenge-options.serializer.ts
|
|
691
|
+
const serializeAuthenticateWithRadarEmailChallengeOptions = (options) => ({
|
|
692
|
+
grant_type: "urn:workos:oauth:grant-type:radar-email-challenge:code",
|
|
693
|
+
client_id: options.clientId,
|
|
694
|
+
client_secret: options.clientSecret,
|
|
695
|
+
code: options.code,
|
|
696
|
+
radar_challenge_id: options.radarChallengeId,
|
|
697
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
698
|
+
ip_address: options.ipAddress,
|
|
699
|
+
user_agent: options.userAgent
|
|
700
|
+
});
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/user-management/serializers/authenticate-with-radar-sms-challenge-options.serializer.ts
|
|
703
|
+
const serializeAuthenticateWithRadarSmsChallengeOptions = (options) => ({
|
|
704
|
+
grant_type: "urn:workos:oauth:grant-type:radar-sms-challenge:code",
|
|
705
|
+
client_id: options.clientId,
|
|
706
|
+
client_secret: options.clientSecret,
|
|
707
|
+
code: options.code,
|
|
708
|
+
verification_id: options.verificationId,
|
|
709
|
+
phone_number: options.phoneNumber,
|
|
710
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
711
|
+
ip_address: options.ipAddress,
|
|
712
|
+
user_agent: options.userAgent
|
|
713
|
+
});
|
|
714
|
+
//#endregion
|
|
674
715
|
//#region src/user-management/serializers/authenticate-with-password-options.serializer.ts
|
|
675
716
|
const serializeAuthenticateWithPasswordOptions = (options) => ({
|
|
676
717
|
grant_type: "password",
|
|
@@ -970,6 +1011,15 @@ const serializeCreateUserOptions = (options) => ({
|
|
|
970
1011
|
user_agent: options.userAgent
|
|
971
1012
|
});
|
|
972
1013
|
//#endregion
|
|
1014
|
+
//#region src/user-management/serializers/send-radar-sms-challenge-options.serializer.ts
|
|
1015
|
+
const serializeSendRadarSmsChallengeOptions = (options) => ({
|
|
1016
|
+
user_id: options.userId,
|
|
1017
|
+
pending_authentication_token: options.pendingAuthenticationToken,
|
|
1018
|
+
phone_number: options.phoneNumber,
|
|
1019
|
+
ip_address: options.ipAddress,
|
|
1020
|
+
user_agent: options.userAgent
|
|
1021
|
+
});
|
|
1022
|
+
//#endregion
|
|
973
1023
|
//#region src/user-management/serializers/update-user-options.serializer.ts
|
|
974
1024
|
const serializeUpdateUserOptions = (options) => ({
|
|
975
1025
|
email: options.email,
|
|
@@ -3550,7 +3600,7 @@ function isJson(val) {
|
|
|
3550
3600
|
}
|
|
3551
3601
|
return !0;
|
|
3552
3602
|
}
|
|
3553
|
-
const enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = typeof Uint8Array.fromBase64 == "function" && typeof Uint8Array.prototype.toBase64 == "function" && typeof Uint8Array.prototype.toHex == "function";
|
|
3603
|
+
const enc = /* @__PURE__ */ new TextEncoder(), dec = /* @__PURE__ */ new TextDecoder(), jsBase64Enabled = /* @__PURE__ */ (() => typeof Uint8Array.fromBase64 == "function" && typeof Uint8Array.prototype.toBase64 == "function" && typeof Uint8Array.prototype.toHex == "function")();
|
|
3554
3604
|
function b64ToU8(str) {
|
|
3555
3605
|
return jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: "base64url" }) : base64ToUint8Array$1(str);
|
|
3556
3606
|
}
|
|
@@ -3595,7 +3645,7 @@ const defaults = /* @__PURE__ */ Object.freeze({
|
|
|
3595
3645
|
ivBits: void 0,
|
|
3596
3646
|
name: "SHA-256"
|
|
3597
3647
|
})
|
|
3598
|
-
})
|
|
3648
|
+
});
|
|
3599
3649
|
function randomBits(bits) {
|
|
3600
3650
|
return crypto.getRandomValues(new Uint8Array(bits / 8));
|
|
3601
3651
|
}
|
|
@@ -3689,7 +3739,7 @@ function normalizePassword(password) {
|
|
|
3689
3739
|
async function seal(object, password, options) {
|
|
3690
3740
|
let now = Date.now() + (options.localtimeOffsetMsec || 0), { id = "", encryption, integrity } = normalizePassword(password);
|
|
3691
3741
|
if (id && !/^\w+$/.test(id)) throw Error("Invalid password id");
|
|
3692
|
-
let { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : "", macBaseString =
|
|
3742
|
+
let { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : "", macBaseString = "Fe26.2*" + id + "*" + key.salt + "*" + u8ToB64(key.iv) + "*" + u8ToB64(encrypted) + "*" + expiration, mac = await hmacWithPassword(integrity, options.integrity, macBaseString);
|
|
3693
3743
|
return macBaseString + "*" + mac.salt + "*" + mac.digest;
|
|
3694
3744
|
}
|
|
3695
3745
|
async function unseal(sealed, password, options) {
|
|
@@ -3937,7 +3987,7 @@ let _josePromise;
|
|
|
3937
3987
|
* @returns Promise that resolves to the jose module
|
|
3938
3988
|
*/
|
|
3939
3989
|
function getJose() {
|
|
3940
|
-
return _josePromise ??= Promise.resolve().then(() => require("./webapi-
|
|
3990
|
+
return _josePromise ??= Promise.resolve().then(() => require("./webapi-CVu-Hjaz.cjs"));
|
|
3941
3991
|
}
|
|
3942
3992
|
//#endregion
|
|
3943
3993
|
//#region src/user-management/session.ts
|
|
@@ -4307,6 +4357,42 @@ var UserManagement = class {
|
|
|
4307
4357
|
session
|
|
4308
4358
|
});
|
|
4309
4359
|
}
|
|
4360
|
+
/** Send a Radar SMS challenge. */
|
|
4361
|
+
async sendRadarSmsChallenge(payload) {
|
|
4362
|
+
const { data } = await this.workos.post("/user_management/radar_challenges", serializeSendRadarSmsChallengeOptions(payload));
|
|
4363
|
+
return {
|
|
4364
|
+
verificationId: data.verification_id,
|
|
4365
|
+
phoneNumber: data.phone_number
|
|
4366
|
+
};
|
|
4367
|
+
}
|
|
4368
|
+
/** Authenticate with Radar SMS challenge. */
|
|
4369
|
+
async authenticateWithRadarSmsChallenge(payload) {
|
|
4370
|
+
const { session, clientId, ...remainingPayload } = payload;
|
|
4371
|
+
const resolvedClientId = this.resolveClientId(clientId);
|
|
4372
|
+
const { data } = await this.workos.post("/user_management/authenticate", serializeAuthenticateWithRadarSmsChallengeOptions({
|
|
4373
|
+
...remainingPayload,
|
|
4374
|
+
clientId: resolvedClientId,
|
|
4375
|
+
clientSecret: this.workos.key
|
|
4376
|
+
}));
|
|
4377
|
+
return this.prepareAuthenticationResponse({
|
|
4378
|
+
authenticationResponse: deserializeAuthenticationResponse(data),
|
|
4379
|
+
session
|
|
4380
|
+
});
|
|
4381
|
+
}
|
|
4382
|
+
/** Authenticate with Radar email challenge. */
|
|
4383
|
+
async authenticateWithRadarEmailChallenge(payload) {
|
|
4384
|
+
const { session, clientId, ...remainingPayload } = payload;
|
|
4385
|
+
const resolvedClientId = this.resolveClientId(clientId);
|
|
4386
|
+
const { data } = await this.workos.post("/user_management/authenticate", serializeAuthenticateWithRadarEmailChallengeOptions({
|
|
4387
|
+
...remainingPayload,
|
|
4388
|
+
clientId: resolvedClientId,
|
|
4389
|
+
clientSecret: this.workos.key
|
|
4390
|
+
}));
|
|
4391
|
+
return this.prepareAuthenticationResponse({
|
|
4392
|
+
authenticationResponse: deserializeAuthenticationResponse(data),
|
|
4393
|
+
session
|
|
4394
|
+
});
|
|
4395
|
+
}
|
|
4310
4396
|
async authenticateWithSessionCookie({ sessionData, cookiePassword = getEnv("WORKOS_COOKIE_PASSWORD") }) {
|
|
4311
4397
|
if (!cookiePassword) throw new Error("Cookie password is required");
|
|
4312
4398
|
if (!await this.getJWKS()) throw new Error("Must provide clientId to initialize JWKS");
|
|
@@ -5364,13 +5450,15 @@ var Groups = class {
|
|
|
5364
5450
|
}
|
|
5365
5451
|
};
|
|
5366
5452
|
//#endregion
|
|
5367
|
-
//#region src/widgets/
|
|
5368
|
-
const
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5453
|
+
//#region src/widgets/serializers/widget-session-token-response.serializer.ts
|
|
5454
|
+
const deserializeWidgetSessionTokenResponse = (response) => ({ token: response.token });
|
|
5455
|
+
//#endregion
|
|
5456
|
+
//#region src/widgets/serializers/widget-session-token.serializer.ts
|
|
5457
|
+
const serializeGetTokenOptions = (model) => ({
|
|
5458
|
+
organization_id: model.organizationId,
|
|
5459
|
+
user_id: model.userId,
|
|
5460
|
+
scopes: model.scopes
|
|
5372
5461
|
});
|
|
5373
|
-
const deserializeGetTokenResponse = (data) => ({ token: data.token });
|
|
5374
5462
|
//#endregion
|
|
5375
5463
|
//#region src/widgets/widgets.ts
|
|
5376
5464
|
var Widgets = class {
|
|
@@ -5382,15 +5470,16 @@ var Widgets = class {
|
|
|
5382
5470
|
* Generate a widget token
|
|
5383
5471
|
*
|
|
5384
5472
|
* Generate a widget token scoped to an organization and user with the specified scopes.
|
|
5385
|
-
* @param
|
|
5386
|
-
* @returns {Promise<
|
|
5473
|
+
* @param options - The request options.
|
|
5474
|
+
* @returns {Promise<WidgetSessionTokenResponse>}
|
|
5387
5475
|
* @throws {BadRequestException} 400
|
|
5388
5476
|
* @throws {NotFoundException} 404
|
|
5389
5477
|
* @throws {UnprocessableEntityException} 422
|
|
5390
5478
|
*/
|
|
5391
|
-
async createToken(
|
|
5479
|
+
async createToken(options) {
|
|
5480
|
+
const payload = options;
|
|
5392
5481
|
const { data } = await this.workos.post("/widgets/token", serializeGetTokenOptions(payload));
|
|
5393
|
-
return
|
|
5482
|
+
return deserializeWidgetSessionTokenResponse(data);
|
|
5394
5483
|
}
|
|
5395
5484
|
};
|
|
5396
5485
|
//#endregion
|
|
@@ -6828,7 +6917,7 @@ var Vault = class {
|
|
|
6828
6917
|
};
|
|
6829
6918
|
//#endregion
|
|
6830
6919
|
//#region package.json
|
|
6831
|
-
var version = "10.1
|
|
6920
|
+
var version = "10.2.1";
|
|
6832
6921
|
//#endregion
|
|
6833
6922
|
//#region src/workos.ts
|
|
6834
6923
|
const DEFAULT_HOSTNAME = "api.workos.com";
|
|
@@ -6961,12 +7050,7 @@ var WorkOS = class {
|
|
|
6961
7050
|
});
|
|
6962
7051
|
throw error;
|
|
6963
7052
|
}
|
|
6964
|
-
|
|
6965
|
-
return { data: await res.toJSON() };
|
|
6966
|
-
} catch (error) {
|
|
6967
|
-
await this.handleParseError(error, res);
|
|
6968
|
-
throw error;
|
|
6969
|
-
}
|
|
7053
|
+
return { data: await res.toJSON() };
|
|
6970
7054
|
}
|
|
6971
7055
|
async get(path, options = {}) {
|
|
6972
7056
|
if (!options.skipApiKeyCheck) this.requireApiKey(path);
|
|
@@ -6986,12 +7070,7 @@ var WorkOS = class {
|
|
|
6986
7070
|
});
|
|
6987
7071
|
throw error;
|
|
6988
7072
|
}
|
|
6989
|
-
|
|
6990
|
-
return { data: await res.toJSON() };
|
|
6991
|
-
} catch (error) {
|
|
6992
|
-
await this.handleParseError(error, res);
|
|
6993
|
-
throw error;
|
|
6994
|
-
}
|
|
7073
|
+
return { data: await res.toJSON() };
|
|
6995
7074
|
}
|
|
6996
7075
|
async put(path, entity, options = {}) {
|
|
6997
7076
|
if (!options.skipApiKeyCheck) this.requireApiKey(path);
|
|
@@ -7010,12 +7089,7 @@ var WorkOS = class {
|
|
|
7010
7089
|
});
|
|
7011
7090
|
throw error;
|
|
7012
7091
|
}
|
|
7013
|
-
|
|
7014
|
-
return { data: await res.toJSON() };
|
|
7015
|
-
} catch (error) {
|
|
7016
|
-
await this.handleParseError(error, res);
|
|
7017
|
-
throw error;
|
|
7018
|
-
}
|
|
7092
|
+
return { data: await res.toJSON() };
|
|
7019
7093
|
}
|
|
7020
7094
|
async patch(path, entity, options = {}) {
|
|
7021
7095
|
if (!options.skipApiKeyCheck) this.requireApiKey(path);
|
|
@@ -7034,12 +7108,7 @@ var WorkOS = class {
|
|
|
7034
7108
|
});
|
|
7035
7109
|
throw error;
|
|
7036
7110
|
}
|
|
7037
|
-
|
|
7038
|
-
return { data: await res.toJSON() };
|
|
7039
|
-
} catch (error) {
|
|
7040
|
-
await this.handleParseError(error, res);
|
|
7041
|
-
throw error;
|
|
7042
|
-
}
|
|
7111
|
+
return { data: await res.toJSON() };
|
|
7043
7112
|
}
|
|
7044
7113
|
async delete(path, query) {
|
|
7045
7114
|
this.requireApiKey(path);
|
|
@@ -7068,20 +7137,6 @@ var WorkOS = class {
|
|
|
7068
7137
|
emitWarning(warning) {
|
|
7069
7138
|
console.warn(`WorkOS: ${warning}`);
|
|
7070
7139
|
}
|
|
7071
|
-
async handleParseError(error, res) {
|
|
7072
|
-
if (error instanceof SyntaxError) {
|
|
7073
|
-
const rawResponse = res.getRawResponse();
|
|
7074
|
-
const requestID = rawResponse.headers.get("X-Request-ID") ?? "";
|
|
7075
|
-
const rawStatus = rawResponse.status;
|
|
7076
|
-
const rawBody = await rawResponse.text();
|
|
7077
|
-
throw new ParseError({
|
|
7078
|
-
message: error.message,
|
|
7079
|
-
rawBody,
|
|
7080
|
-
rawStatus,
|
|
7081
|
-
requestID
|
|
7082
|
-
});
|
|
7083
|
-
}
|
|
7084
|
-
}
|
|
7085
7140
|
handleHttpError({ path, error }) {
|
|
7086
7141
|
if (!(error instanceof HttpClientError)) throw new Error(`Unexpected error: ${error}`, { cause: error });
|
|
7087
7142
|
const { response } = error;
|
|
@@ -7380,24 +7435,12 @@ Object.defineProperty(exports, "createWorkOS", {
|
|
|
7380
7435
|
return createWorkOS;
|
|
7381
7436
|
}
|
|
7382
7437
|
});
|
|
7383
|
-
Object.defineProperty(exports, "deserializeGetTokenResponse", {
|
|
7384
|
-
enumerable: true,
|
|
7385
|
-
get: function() {
|
|
7386
|
-
return deserializeGetTokenResponse;
|
|
7387
|
-
}
|
|
7388
|
-
});
|
|
7389
7438
|
Object.defineProperty(exports, "isAuthenticationErrorData", {
|
|
7390
7439
|
enumerable: true,
|
|
7391
7440
|
get: function() {
|
|
7392
7441
|
return isAuthenticationErrorData;
|
|
7393
7442
|
}
|
|
7394
7443
|
});
|
|
7395
|
-
Object.defineProperty(exports, "serializeGetTokenOptions", {
|
|
7396
|
-
enumerable: true,
|
|
7397
|
-
get: function() {
|
|
7398
|
-
return serializeGetTokenOptions;
|
|
7399
|
-
}
|
|
7400
|
-
});
|
|
7401
7444
|
Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
7402
7445
|
enumerable: true,
|
|
7403
7446
|
get: function() {
|
|
@@ -7405,4 +7448,4 @@ Object.defineProperty(exports, "serializeRevokeSessionOptions", {
|
|
|
7405
7448
|
}
|
|
7406
7449
|
});
|
|
7407
7450
|
|
|
7408
|
-
//# sourceMappingURL=factory-
|
|
7451
|
+
//# sourceMappingURL=factory-BzpScK-h.cjs.map
|