@baasix/sdk 0.1.22 → 0.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/dist/index.js CHANGED
@@ -189,9 +189,11 @@ var HttpClient = class {
189
189
  errorData = await response.json();
190
190
  } catch {
191
191
  }
192
- const message = errorData.error?.message || errorData.message || response.statusText || "Request failed";
193
- const code = errorData.error?.code ?? errorData.code;
194
- const details = errorData.details;
192
+ const errorObj = typeof errorData.error === "object" && errorData.error !== null ? errorData.error : void 0;
193
+ const message = errorObj?.message || errorData.message || (typeof errorData.error === "string" ? errorData.error : "") || response.statusText || "Request failed";
194
+ const code = errorObj?.code ?? errorData.code;
195
+ const rawDetails = errorObj?.details ?? errorData.details;
196
+ const details = Array.isArray(rawDetails) ? rawDetails : void 0;
195
197
  return new BaasixError(message, response.status, code, details);
196
198
  }
197
199
  /**
@@ -897,12 +899,15 @@ var AuthModule = class {
897
899
  * @example
898
900
  * ```typescript
899
901
  * const { user, token } = await baasix.auth.verifyMagicLink('verification-token');
902
+ *
903
+ * // Enforce the tenant's web/mobile session limits for this sign-in
904
+ * await baasix.auth.verifyMagicLink(code, { authType: 'web', tenant_Id });
900
905
  * ```
901
906
  */
902
- async verifyMagicLink(token) {
907
+ async verifyMagicLink(token, opts) {
903
908
  const response = await this.client.get(
904
909
  `/auth/magiclink/${encodeURIComponent(token)}`,
905
- { skipAuth: true }
910
+ { skipAuth: true, params: opts }
906
911
  );
907
912
  await this.storeTokens(response);
908
913
  this.emitAuthStateChange("SIGNED_IN", response.user);