@auth/qwik 0.7.0 → 0.8.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/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { AuthConfig, customFetch } from '@auth/core';
1
+ import { AuthConfig, customFetch as _customFetch } from '@auth/core';
2
2
  import { Session } from '@auth/core/types';
3
3
  import { z, RequestEventCommon } from '@builder.io/qwik-city';
4
4
  import { EnvGetter } from '@builder.io/qwik-city/middleware/request-handler';
5
5
 
6
- export { customFetch };
6
+ export declare const customFetch: typeof _customFetch | undefined;
7
7
  export { AuthError, CredentialsSignin } from '@auth/core/errors';
8
8
  export type { Account, DefaultSession, Profile, Session, User, } from '@auth/core/types';
9
9
  /** Configure the {@link QwikAuth$} method. */
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAqC,WAAW,EAAE,MAAM,YAAY,CAAA;AAC3E,OAAO,EAAc,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAGL,CAAC,EAED,KAAK,kBAAkB,EACxB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAA;AAI5E,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEhE,YAAY,EACV,OAAO,EACP,cAAc,EACd,OAAO,EACP,OAAO,EACP,IAAI,GACL,MAAM,kBAAkB,CAAA;AAEzB,8CAA8C;AAC9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gB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAA;AAwG7E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,aAjHE,kBAAkB,KAAK,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmE7B,kBAAkB;CA8CmB,CAAA;AAoFrE,eAAO,MAAM,cAAc,QAAS,SAAS,UAAU,UAAU,SAyChE,CAAA"}
package/index.qwik.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { globalActionQrl, zodQrl, z, routeLoaderQrl } from "@builder.io/qwik-city";
2
2
  import { inlinedQrl, useLexicalScope, implicit$FirstArg } from "@builder.io/qwik";
3
- import { Auth, skipCSRFCheck, isAuthAction } from "@auth/core";
4
- import { customFetch } from "@auth/core";
3
+ import { customFetch as customFetch$1, Auth, skipCSRFCheck, isAuthAction } from "@auth/core";
5
4
  import { isServer } from "@builder.io/qwik/build";
6
5
  var setCookie = { exports: {} };
7
6
  var defaultParseOptions = {
@@ -293,9 +292,11 @@ AccountNotLinked.type = "AccountNotLinked";
293
292
  class ExperimentalFeatureNotEnabled extends AuthError {
294
293
  }
295
294
  ExperimentalFeatureNotEnabled.type = "ExperimentalFeatureNotEnabled";
295
+ const customFetch = isServer ? customFetch$1 : void 0;
296
296
  function QwikAuthQrl(authOptions) {
297
297
  const useSignIn = globalActionQrl(/* @__PURE__ */ inlinedQrl(async ({ providerId, redirectTo: _redirectTo, options, authorizationParams }, req) => {
298
298
  const [authOptions2] = useLexicalScope();
299
+ if (!isServer) return;
299
300
  const { redirectTo = _redirectTo ?? defaultRedirectTo(req), ...rest } = options ?? {};
300
301
  const isCredentials = providerId === "credentials";
301
302
  const authOpts = await authOptions2(req);
@@ -326,6 +327,7 @@ function QwikAuthQrl(authOptions) {
326
327
  }, "QwikAuthQrl_useSignIn_globalAction_zod_X0EcrMISJRM")));
327
328
  const useSignOut = globalActionQrl(/* @__PURE__ */ inlinedQrl(async ({ redirectTo }, req) => {
328
329
  const [authOptions2] = useLexicalScope();
330
+ if (!isServer) return;
329
331
  redirectTo ?? (redirectTo = defaultRedirectTo(req));
330
332
  const authOpts = await authOptions2(req);
331
333
  setEnvDefaults(req.env, authOpts);
@@ -375,6 +377,7 @@ function QwikAuthQrl(authOptions) {
375
377
  }
376
378
  const QwikAuth$ = /* @__PURE__ */ implicit$FirstArg(QwikAuthQrl);
377
379
  async function authAction(body, req, path, authOptions) {
380
+ if (!isServer) return;
378
381
  const request = new Request(new URL(path, req.request.url), {
379
382
  method: req.request.method,
380
383
  headers: req.request.headers,
@@ -432,6 +435,7 @@ async function getSessionData(req, options) {
432
435
  throw new Error(data.message);
433
436
  }
434
437
  const setEnvDefaults = (env, config) => {
438
+ if (!isServer) return;
435
439
  config.basePath = "/auth";
436
440
  if (!config.secret?.length) {
437
441
  config.secret = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth/qwik",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Authentication for Qwik.",
5
5
  "license": "ISC",
6
6
  "author": "gioboa <giorgiob.boa@gmail.com>",
@@ -49,7 +49,7 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "set-cookie-parser": "^2.6.0",
52
- "@auth/core": "0.39.0"
52
+ "@auth/core": "0.40.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@builder.io/qwik": "1.7.3",
package/src/index.ts CHANGED
@@ -110,7 +110,12 @@
110
110
  */
111
111
 
112
112
  import type { AuthConfig } from "@auth/core"
113
- import { Auth, isAuthAction, skipCSRFCheck, customFetch } from "@auth/core"
113
+ import {
114
+ Auth,
115
+ isAuthAction,
116
+ skipCSRFCheck,
117
+ customFetch as _customFetch,
118
+ } from "@auth/core"
114
119
  import { AuthAction, Session } from "@auth/core/types"
115
120
  import { implicit$FirstArg, type QRL } from "@builder.io/qwik"
116
121
  import {
@@ -124,7 +129,8 @@ import { EnvGetter } from "@builder.io/qwik-city/middleware/request-handler"
124
129
  import { isServer } from "@builder.io/qwik/build"
125
130
  import { parseString, splitCookiesString } from "set-cookie-parser"
126
131
 
127
- export { customFetch }
132
+ export const customFetch = isServer ? _customFetch : undefined
133
+
128
134
  export { AuthError, CredentialsSignin } from "@auth/core/errors"
129
135
 
130
136
  export type {
@@ -149,6 +155,7 @@ export function QwikAuthQrl(
149
155
  { providerId, redirectTo: _redirectTo, options, authorizationParams },
150
156
  req
151
157
  ) => {
158
+ if (!isServer) return
152
159
  const { redirectTo = _redirectTo ?? defaultRedirectTo(req), ...rest } =
153
160
  options ?? {}
154
161
 
@@ -192,6 +199,7 @@ export function QwikAuthQrl(
192
199
 
193
200
  const useSignOut = globalAction$(
194
201
  async ({ redirectTo }, req) => {
202
+ if (!isServer) return
195
203
  redirectTo ??= defaultRedirectTo(req)
196
204
  const authOpts = await authOptions(req)
197
205
  setEnvDefaults(req.env, authOpts)
@@ -261,6 +269,7 @@ async function authAction(
261
269
  path: string,
262
270
  authOptions: QwikAuthConfig
263
271
  ) {
272
+ if (!isServer) return
264
273
  const request = new Request(new URL(path, req.request.url), {
265
274
  method: req.request.method,
266
275
  headers: req.request.headers,
@@ -337,6 +346,7 @@ async function getSessionData(
337
346
  }
338
347
 
339
348
  export const setEnvDefaults = (env: EnvGetter, config: AuthConfig) => {
349
+ if (!isServer) return
340
350
  config.basePath = "/auth"
341
351
  if (!config.secret?.length) {
342
352
  config.secret = []