@workos-inc/node 10.2.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.
@@ -349,8 +349,20 @@ var FetchHttpClientResponse = class FetchHttpClientResponse extends HttpClientRe
349
349
  getRawResponse() {
350
350
  return this._res;
351
351
  }
352
- toJSON() {
353
- return this._res.headers.get("content-type")?.includes("application/json") ? this._res.json() : null;
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 = {};
@@ -3588,7 +3600,7 @@ function isJson(val) {
3588
3600
  }
3589
3601
  return !0;
3590
3602
  }
3591
- 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")();
3592
3604
  function b64ToU8(str) {
3593
3605
  return jsBase64Enabled ? Uint8Array.fromBase64(str, { alphabet: "base64url" }) : base64ToUint8Array$1(str);
3594
3606
  }
@@ -3633,7 +3645,7 @@ const defaults = /* @__PURE__ */ Object.freeze({
3633
3645
  ivBits: void 0,
3634
3646
  name: "SHA-256"
3635
3647
  })
3636
- }), macPrefix = "Fe26.2";
3648
+ });
3637
3649
  function randomBits(bits) {
3638
3650
  return crypto.getRandomValues(new Uint8Array(bits / 8));
3639
3651
  }
@@ -3727,7 +3739,7 @@ function normalizePassword(password) {
3727
3739
  async function seal(object, password, options) {
3728
3740
  let now = Date.now() + (options.localtimeOffsetMsec || 0), { id = "", encryption, integrity } = normalizePassword(password);
3729
3741
  if (id && !/^\w+$/.test(id)) throw Error("Invalid password id");
3730
- let { encrypted, key } = await encrypt(encryption, options.encryption, (options.encode || losslessJsonStringify)(object)), expiration = options.ttl ? now + options.ttl : "", macBaseString = macPrefix + "*" + id + "*" + key.salt + "*" + u8ToB64(key.iv) + "*" + u8ToB64(encrypted) + "*" + expiration, mac = await hmacWithPassword(integrity, options.integrity, 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);
3731
3743
  return macBaseString + "*" + mac.salt + "*" + mac.digest;
3732
3744
  }
3733
3745
  async function unseal(sealed, password, options) {
@@ -3975,7 +3987,7 @@ let _josePromise;
3975
3987
  * @returns Promise that resolves to the jose module
3976
3988
  */
3977
3989
  function getJose() {
3978
- return _josePromise ??= import("./webapi-CKFbiPvQ.mjs");
3990
+ return _josePromise ??= import("./webapi-S8D5YgJz.mjs");
3979
3991
  }
3980
3992
  //#endregion
3981
3993
  //#region src/user-management/session.ts
@@ -6905,7 +6917,7 @@ var Vault = class {
6905
6917
  };
6906
6918
  //#endregion
6907
6919
  //#region package.json
6908
- var version = "10.2.0";
6920
+ var version = "10.2.1";
6909
6921
  //#endregion
6910
6922
  //#region src/workos.ts
6911
6923
  const DEFAULT_HOSTNAME = "api.workos.com";
@@ -7038,12 +7050,7 @@ var WorkOS = class {
7038
7050
  });
7039
7051
  throw error;
7040
7052
  }
7041
- try {
7042
- return { data: await res.toJSON() };
7043
- } catch (error) {
7044
- await this.handleParseError(error, res);
7045
- throw error;
7046
- }
7053
+ return { data: await res.toJSON() };
7047
7054
  }
7048
7055
  async get(path, options = {}) {
7049
7056
  if (!options.skipApiKeyCheck) this.requireApiKey(path);
@@ -7063,12 +7070,7 @@ var WorkOS = class {
7063
7070
  });
7064
7071
  throw error;
7065
7072
  }
7066
- try {
7067
- return { data: await res.toJSON() };
7068
- } catch (error) {
7069
- await this.handleParseError(error, res);
7070
- throw error;
7071
- }
7073
+ return { data: await res.toJSON() };
7072
7074
  }
7073
7075
  async put(path, entity, options = {}) {
7074
7076
  if (!options.skipApiKeyCheck) this.requireApiKey(path);
@@ -7087,12 +7089,7 @@ var WorkOS = class {
7087
7089
  });
7088
7090
  throw error;
7089
7091
  }
7090
- try {
7091
- return { data: await res.toJSON() };
7092
- } catch (error) {
7093
- await this.handleParseError(error, res);
7094
- throw error;
7095
- }
7092
+ return { data: await res.toJSON() };
7096
7093
  }
7097
7094
  async patch(path, entity, options = {}) {
7098
7095
  if (!options.skipApiKeyCheck) this.requireApiKey(path);
@@ -7111,12 +7108,7 @@ var WorkOS = class {
7111
7108
  });
7112
7109
  throw error;
7113
7110
  }
7114
- try {
7115
- return { data: await res.toJSON() };
7116
- } catch (error) {
7117
- await this.handleParseError(error, res);
7118
- throw error;
7119
- }
7111
+ return { data: await res.toJSON() };
7120
7112
  }
7121
7113
  async delete(path, query) {
7122
7114
  this.requireApiKey(path);
@@ -7145,20 +7137,6 @@ var WorkOS = class {
7145
7137
  emitWarning(warning) {
7146
7138
  console.warn(`WorkOS: ${warning}`);
7147
7139
  }
7148
- async handleParseError(error, res) {
7149
- if (error instanceof SyntaxError) {
7150
- const rawResponse = res.getRawResponse();
7151
- const requestID = rawResponse.headers.get("X-Request-ID") ?? "";
7152
- const rawStatus = rawResponse.status;
7153
- const rawBody = await rawResponse.text();
7154
- throw new ParseError({
7155
- message: error.message,
7156
- rawBody,
7157
- rawStatus,
7158
- requestID
7159
- });
7160
- }
7161
- }
7162
7140
  handleHttpError({ path, error }) {
7163
7141
  if (!(error instanceof HttpClientError)) throw new Error(`Unexpected error: ${error}`, { cause: error });
7164
7142
  const { response } = error;
@@ -7285,4 +7263,4 @@ function createWorkOS(options) {
7285
7263
  //#endregion
7286
7264
  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 };
7287
7265
 
7288
- //# sourceMappingURL=factory-CenLS49y.mjs.map
7266
+ //# sourceMappingURL=factory-Bp8G8dsp.mjs.map