@baasix/sdk 0.2.0 → 0.3.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
@@ -193,7 +193,7 @@ var HttpClient = class {
193
193
  const message = errorObj?.message || errorData.message || (typeof errorData.error === "string" ? errorData.error : "") || response.statusText || "Request failed";
194
194
  const code = errorObj?.code ?? errorData.code;
195
195
  const rawDetails = errorObj?.details ?? errorData.details;
196
- const details = Array.isArray(rawDetails) ? rawDetails : void 0;
196
+ const details = rawDetails == null ? void 0 : Array.isArray(rawDetails) ? rawDetails : typeof rawDetails === "object" ? [rawDetails] : [{ message: String(rawDetails) }];
197
197
  return new BaasixError(message, response.status, code, details);
198
198
  }
199
199
  /**
@@ -902,12 +902,20 @@ var AuthModule = class {
902
902
  *
903
903
  * // Enforce the tenant's web/mobile session limits for this sign-in
904
904
  * await baasix.auth.verifyMagicLink(code, { authType: 'web', tenant_Id });
905
+ *
906
+ * // Emailed code + email: wrong codes are counted and the code is burned after 5
907
+ * await baasix.auth.verifyMagicLink(code, { email: 'user@example.com', authType: 'web' });
905
908
  * ```
906
909
  */
907
910
  async verifyMagicLink(token, opts) {
908
- const response = await this.client.get(
911
+ const { email, ...params } = opts || {};
912
+ const response = email ? await this.client.post(
913
+ "/auth/magiclink/verify",
914
+ { email, code: token, ...params },
915
+ { skipAuth: true }
916
+ ) : await this.client.get(
909
917
  `/auth/magiclink/${encodeURIComponent(token)}`,
910
- { skipAuth: true, params: opts }
918
+ { skipAuth: true, params }
911
919
  );
912
920
  await this.storeTokens(response);
913
921
  this.emitAuthStateChange("SIGNED_IN", response.user);
@@ -948,9 +956,20 @@ var AuthModule = class {
948
956
  * @example
949
957
  * ```typescript
950
958
  * await baasix.auth.resetPassword('reset-token-or-code', 'newpassword123');
959
+ *
960
+ * // Emailed code + email: wrong codes are counted and the code is burned after 5
961
+ * await baasix.auth.resetPassword('K7M2PQ9X', 'newpassword123', { email: 'user@example.com' });
951
962
  * ```
952
963
  */
953
- async resetPassword(token, newPassword) {
964
+ async resetPassword(token, newPassword, opts) {
965
+ if (opts?.email) {
966
+ await this.client.post(
967
+ "/auth/password/reset/verify",
968
+ { email: opts.email, code: token, password: newPassword },
969
+ { skipAuth: true }
970
+ );
971
+ return;
972
+ }
954
973
  await this.client.post(
955
974
  `/auth/password/reset/${encodeURIComponent(token)}`,
956
975
  { password: newPassword },
@@ -1502,6 +1521,9 @@ var QueryBuilder = class {
1502
1521
  if (this.queryParams.searchFields) {
1503
1522
  params.searchFields = this.queryParams.searchFields;
1504
1523
  }
1524
+ if (this.queryParams.excludeSearchFields) {
1525
+ params.excludeSearchFields = this.queryParams.excludeSearchFields;
1526
+ }
1505
1527
  if (this.queryParams.paranoid !== void 0) {
1506
1528
  params.paranoid = this.queryParams.paranoid;
1507
1529
  }