@niledatabase/server 5.0.0-alpha.21 → 5.0.0-alpha.22

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.mjs CHANGED
@@ -217,7 +217,7 @@ async function request(url, _init, config) {
217
217
  const updatedRes = await config.extensionCtx?.runExtensions(
218
218
  "onResponse" /* onResponse */,
219
219
  config,
220
- params
220
+ { ...params, response: res }
221
221
  );
222
222
  if (updatedRes) {
223
223
  return updatedRes;
@@ -2631,7 +2631,7 @@ var Users = class {
2631
2631
  }
2632
2632
  }
2633
2633
  async verifySelf(options, rawResponse = false) {
2634
- const bypassEmail = typeof options === "object" ? options.bypassEmail ?? process.env.NODE_ENV !== "production" : process.env.NODE_ENV !== "production";
2634
+ const bypassEmail = typeof options === "object" && options?.bypassEmail === true;
2635
2635
  const callbackUrl = typeof options === "object" ? options.callbackUrl : defaultCallbackUrl2(this.#config).callbackUrl;
2636
2636
  let res;
2637
2637
  try {
@@ -2641,17 +2641,22 @@ var Users = class {
2641
2641
  }
2642
2642
  res = await verifyEmailAddress(this.#config, me, String(callbackUrl));
2643
2643
  return res;
2644
- } catch {
2645
- const message = "Unable to verify email.";
2646
- this.#logger?.warn(message);
2647
- res = new Response(message, { status: 400 });
2644
+ } catch (e) {
2645
+ if (!bypassEmail) {
2646
+ let message = "Unable to verify email.";
2647
+ if (e instanceof Error) {
2648
+ message = e.message;
2649
+ }
2650
+ this.#logger?.error(
2651
+ `${message} you can bypass this message by setting bypassEmail: true when calling 'verifySelf'`
2652
+ );
2653
+ res = new Response(message, { status: 400 });
2654
+ }
2648
2655
  }
2649
2656
  if (bypassEmail) {
2657
+ this.#logger?.info("bypassing email requirements for email verification");
2650
2658
  res = this.updateSelf({ emailVerified: true }, rawResponse);
2651
2659
  }
2652
- this.#logger.error(
2653
- "Unable to verify email address. Configure your SMTP server in the console."
2654
- );
2655
2660
  return res;
2656
2661
  }
2657
2662
  };
@@ -3041,10 +3046,10 @@ function bindRunExtensions(instance) {
3041
3046
  const result = await ext.onHandleRequest(
3042
3047
  ...Array.isArray(params) ? params : [params]
3043
3048
  );
3049
+ debug(`${ext.id ?? create2.name} ran onHandleRequest`);
3044
3050
  if (result != null) {
3045
3051
  return result;
3046
3052
  }
3047
- continue;
3048
3053
  }
3049
3054
  const [param] = Array.isArray(params) ? params : [params];
3050
3055
  if (ext.onRequest && toRun === "onRequest" /* onRequest */) {
@@ -3076,14 +3081,13 @@ function bindRunExtensions(instance) {
3076
3081
  }
3077
3082
  }
3078
3083
  debug(`${ext.id ?? create2.name} ran onRequest`);
3079
- continue;
3080
3084
  }
3081
3085
  if (ext.onResponse && toRun === "onResponse" /* onResponse */) {
3082
3086
  const result = await ext.onResponse(param);
3087
+ debug(`${ext.id ?? create2.name} ran onResponse`);
3083
3088
  if (result != null) {
3084
3089
  return result;
3085
3090
  }
3086
- continue;
3087
3091
  }
3088
3092
  }
3089
3093
  }