@auth/qwik 0.9.1 → 0.9.3
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 +12 -13
- package/index.qwik.js +201 -184
- package/package.json +6 -6
package/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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
|
-
|
|
6
5
|
export declare const customFetch: typeof _customFetch | undefined;
|
|
7
6
|
export { AuthError, CredentialsSignin } from '@auth/core/errors';
|
|
8
7
|
export type { Account, DefaultSession, Profile, Session, User, } from '@auth/core/types';
|
|
@@ -33,19 +32,19 @@ export declare const QwikAuth$: (qrl: (ev: RequestEventCommon) => QwikAuthConfig
|
|
|
33
32
|
failed?: undefined;
|
|
34
33
|
} | {
|
|
35
34
|
formErrors: string[];
|
|
36
|
-
fieldErrors: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
authorizationParams
|
|
41
|
-
}
|
|
35
|
+
fieldErrors: Partial<{
|
|
36
|
+
options: string;
|
|
37
|
+
providerId: string;
|
|
38
|
+
redirectTo: string;
|
|
39
|
+
authorizationParams: string;
|
|
40
|
+
}>;
|
|
42
41
|
failed: true;
|
|
43
42
|
}, {
|
|
44
|
-
|
|
45
|
-
redirectTo?: string | undefined;
|
|
46
|
-
options?: z.objectOutputType<{
|
|
43
|
+
options?: z.objectInputType<{
|
|
47
44
|
redirectTo: z.ZodOptional<z.ZodString>;
|
|
48
45
|
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
46
|
+
providerId?: string | undefined;
|
|
47
|
+
redirectTo?: string | undefined;
|
|
49
48
|
authorizationParams?: string | URLSearchParams | Record<string, string> | undefined;
|
|
50
49
|
}, false>;
|
|
51
50
|
useSignOut: import('@builder.io/qwik-city').Action<{
|
|
@@ -54,9 +53,9 @@ export declare const QwikAuth$: (qrl: (ev: RequestEventCommon) => QwikAuthConfig
|
|
|
54
53
|
failed?: undefined;
|
|
55
54
|
} | {
|
|
56
55
|
formErrors: string[];
|
|
57
|
-
fieldErrors: {
|
|
58
|
-
redirectTo
|
|
59
|
-
}
|
|
56
|
+
fieldErrors: Partial<{
|
|
57
|
+
redirectTo: string;
|
|
58
|
+
}>;
|
|
60
59
|
failed: true;
|
|
61
60
|
}, {
|
|
62
61
|
redirectTo?: string | undefined;
|
package/index.qwik.js
CHANGED
|
@@ -1,171 +1,178 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { customFetch as customFetch$1, skipCSRFCheck, Auth, isAuthAction } from "@auth/core";
|
|
2
|
+
import { implicit$FirstArg } from "@builder.io/qwik";
|
|
3
|
+
import { globalAction$, zod$, z, routeLoader$ } from "@builder.io/qwik-city";
|
|
4
4
|
import { isServer } from "@builder.io/qwik/build";
|
|
5
5
|
var setCookie = { exports: {} };
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function parseString(setCookieValue, options) {
|
|
15
|
-
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
16
|
-
var nameValuePairStr = parts.shift();
|
|
17
|
-
var parsed = parseNameValuePair(nameValuePairStr);
|
|
18
|
-
var name = parsed.name;
|
|
19
|
-
var value = parsed.value;
|
|
20
|
-
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
21
|
-
try {
|
|
22
|
-
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.error(
|
|
25
|
-
"set-cookie-parser encountered an error while decoding a cookie with value '" + value + "'. Set options.decodeValues to false to disable this feature.",
|
|
26
|
-
e
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
var cookie = {
|
|
30
|
-
name,
|
|
31
|
-
value
|
|
6
|
+
var hasRequiredSetCookie;
|
|
7
|
+
function requireSetCookie() {
|
|
8
|
+
if (hasRequiredSetCookie) return setCookie.exports;
|
|
9
|
+
hasRequiredSetCookie = 1;
|
|
10
|
+
var defaultParseOptions = {
|
|
11
|
+
decodeValues: true,
|
|
12
|
+
map: false,
|
|
13
|
+
silent: false
|
|
32
14
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
cookie[key] = value2;
|
|
15
|
+
function isNonEmptyString(str) {
|
|
16
|
+
return typeof str === "string" && !!str.trim();
|
|
17
|
+
}
|
|
18
|
+
function parseString(setCookieValue, options) {
|
|
19
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
20
|
+
var nameValuePairStr = parts.shift();
|
|
21
|
+
var parsed = parseNameValuePair(nameValuePairStr);
|
|
22
|
+
var name = parsed.name;
|
|
23
|
+
var value = parsed.value;
|
|
24
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
25
|
+
try {
|
|
26
|
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error(
|
|
29
|
+
"set-cookie-parser encountered an error while decoding a cookie with value '" + value + "'. Set options.decodeValues to false to disable this feature.",
|
|
30
|
+
e
|
|
31
|
+
);
|
|
51
32
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
33
|
+
var cookie = {
|
|
34
|
+
name,
|
|
35
|
+
value
|
|
36
|
+
};
|
|
37
|
+
parts.forEach(function(part) {
|
|
38
|
+
var sides = part.split("=");
|
|
39
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
40
|
+
var value2 = sides.join("=");
|
|
41
|
+
if (key === "expires") {
|
|
42
|
+
cookie.expires = new Date(value2);
|
|
43
|
+
} else if (key === "max-age") {
|
|
44
|
+
cookie.maxAge = parseInt(value2, 10);
|
|
45
|
+
} else if (key === "secure") {
|
|
46
|
+
cookie.secure = true;
|
|
47
|
+
} else if (key === "httponly") {
|
|
48
|
+
cookie.httpOnly = true;
|
|
49
|
+
} else if (key === "samesite") {
|
|
50
|
+
cookie.sameSite = value2;
|
|
51
|
+
} else if (key === "partitioned") {
|
|
52
|
+
cookie.partitioned = true;
|
|
53
|
+
} else {
|
|
54
|
+
cookie[key] = value2;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return cookie;
|
|
64
58
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
function parseNameValuePair(nameValuePairStr) {
|
|
60
|
+
var name = "";
|
|
61
|
+
var value = "";
|
|
62
|
+
var nameValueArr = nameValuePairStr.split("=");
|
|
63
|
+
if (nameValueArr.length > 1) {
|
|
64
|
+
name = nameValueArr.shift();
|
|
65
|
+
value = nameValueArr.join("=");
|
|
72
66
|
} else {
|
|
73
|
-
|
|
67
|
+
value = nameValuePairStr;
|
|
74
68
|
}
|
|
69
|
+
return { name, value };
|
|
75
70
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return key.toLowerCase() === "set-cookie";
|
|
84
|
-
})];
|
|
85
|
-
if (!sch && input.headers.cookie && !options.silent) {
|
|
86
|
-
console.warn(
|
|
87
|
-
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
88
|
-
);
|
|
71
|
+
function parse(input, options) {
|
|
72
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
73
|
+
if (!input) {
|
|
74
|
+
if (!options.map) {
|
|
75
|
+
return [];
|
|
76
|
+
} else {
|
|
77
|
+
return {};
|
|
89
78
|
}
|
|
90
|
-
input = sch;
|
|
91
79
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
function skipWhitespace() {
|
|
125
|
-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
126
|
-
pos += 1;
|
|
80
|
+
if (input.headers) {
|
|
81
|
+
if (typeof input.headers.getSetCookie === "function") {
|
|
82
|
+
input = input.headers.getSetCookie();
|
|
83
|
+
} else if (input.headers["set-cookie"]) {
|
|
84
|
+
input = input.headers["set-cookie"];
|
|
85
|
+
} else {
|
|
86
|
+
var sch = input.headers[Object.keys(input.headers).find(function(key) {
|
|
87
|
+
return key.toLowerCase() === "set-cookie";
|
|
88
|
+
})];
|
|
89
|
+
if (!sch && input.headers.cookie && !options.silent) {
|
|
90
|
+
console.warn(
|
|
91
|
+
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
input = sch;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!Array.isArray(input)) {
|
|
98
|
+
input = [input];
|
|
99
|
+
}
|
|
100
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
101
|
+
if (!options.map) {
|
|
102
|
+
return input.filter(isNonEmptyString).map(function(str) {
|
|
103
|
+
return parseString(str, options);
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
var cookies = {};
|
|
107
|
+
return input.filter(isNonEmptyString).reduce(function(cookies2, str) {
|
|
108
|
+
var cookie = parseString(str, options);
|
|
109
|
+
cookies2[cookie.name] = cookie;
|
|
110
|
+
return cookies2;
|
|
111
|
+
}, cookies);
|
|
127
112
|
}
|
|
128
|
-
return pos < cookiesString.length;
|
|
129
|
-
}
|
|
130
|
-
function notSpecialChar() {
|
|
131
|
-
ch = cookiesString.charAt(pos);
|
|
132
|
-
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
133
113
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
114
|
+
function splitCookiesString(cookiesString) {
|
|
115
|
+
if (Array.isArray(cookiesString)) {
|
|
116
|
+
return cookiesString;
|
|
117
|
+
}
|
|
118
|
+
if (typeof cookiesString !== "string") {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
var cookiesStrings = [];
|
|
122
|
+
var pos = 0;
|
|
123
|
+
var start;
|
|
124
|
+
var ch;
|
|
125
|
+
var lastComma;
|
|
126
|
+
var nextStart;
|
|
127
|
+
var cookiesSeparatorFound;
|
|
128
|
+
function skipWhitespace() {
|
|
129
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
141
130
|
pos += 1;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
131
|
+
}
|
|
132
|
+
return pos < cookiesString.length;
|
|
133
|
+
}
|
|
134
|
+
function notSpecialChar() {
|
|
135
|
+
ch = cookiesString.charAt(pos);
|
|
136
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
137
|
+
}
|
|
138
|
+
while (pos < cookiesString.length) {
|
|
139
|
+
start = pos;
|
|
140
|
+
cookiesSeparatorFound = false;
|
|
141
|
+
while (skipWhitespace()) {
|
|
142
|
+
ch = cookiesString.charAt(pos);
|
|
143
|
+
if (ch === ",") {
|
|
144
|
+
lastComma = pos;
|
|
145
145
|
pos += 1;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
skipWhitespace();
|
|
147
|
+
nextStart = pos;
|
|
148
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
149
|
+
pos += 1;
|
|
150
|
+
}
|
|
151
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
152
|
+
cookiesSeparatorFound = true;
|
|
153
|
+
pos = nextStart;
|
|
154
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
155
|
+
start = pos;
|
|
156
|
+
} else {
|
|
157
|
+
pos = lastComma + 1;
|
|
158
|
+
}
|
|
152
159
|
} else {
|
|
153
|
-
pos
|
|
160
|
+
pos += 1;
|
|
154
161
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
162
|
+
}
|
|
163
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
164
|
+
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
|
-
|
|
160
|
-
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
161
|
-
}
|
|
167
|
+
return cookiesStrings;
|
|
162
168
|
}
|
|
163
|
-
|
|
169
|
+
setCookie.exports = parse;
|
|
170
|
+
setCookie.exports.parse = parse;
|
|
171
|
+
setCookie.exports.parseString = parseString;
|
|
172
|
+
setCookie.exports.splitCookiesString = splitCookiesString;
|
|
173
|
+
return setCookie.exports;
|
|
164
174
|
}
|
|
165
|
-
|
|
166
|
-
setCookie.exports.parse = parse;
|
|
167
|
-
var parseString_1 = setCookie.exports.parseString = parseString;
|
|
168
|
-
var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
|
|
175
|
+
var setCookieExports = /* @__PURE__ */ requireSetCookie();
|
|
169
176
|
class AuthError extends Error {
|
|
170
177
|
/** @internal */
|
|
171
178
|
constructor(message, errorOptions) {
|
|
@@ -294,12 +301,11 @@ class ExperimentalFeatureNotEnabled extends AuthError {
|
|
|
294
301
|
ExperimentalFeatureNotEnabled.type = "ExperimentalFeatureNotEnabled";
|
|
295
302
|
const customFetch = isServer ? customFetch$1 : void 0;
|
|
296
303
|
function QwikAuthQrl(authOptions) {
|
|
297
|
-
const useSignIn =
|
|
298
|
-
const [authOptions2] = useLexicalScope();
|
|
304
|
+
const useSignIn = globalAction$(async ({ providerId, redirectTo: _redirectTo, options, authorizationParams }, req) => {
|
|
299
305
|
if (!isServer) return;
|
|
300
306
|
const { redirectTo = _redirectTo ?? defaultRedirectTo(req), ...rest } = options ?? {};
|
|
301
307
|
const isCredentials = providerId === "credentials";
|
|
302
|
-
const authOpts = await
|
|
308
|
+
const authOpts = await authOptions(req);
|
|
303
309
|
setEnvDefaults(req.env, authOpts);
|
|
304
310
|
const body = new URLSearchParams({
|
|
305
311
|
callbackUrl: redirectTo
|
|
@@ -310,10 +316,10 @@ function QwikAuthQrl(authOptions) {
|
|
|
310
316
|
const baseSignInUrl = `/auth/${isCredentials ? "callback" : "signin"}${providerId ? `/${providerId}` : ""}`;
|
|
311
317
|
const signInUrl = `${baseSignInUrl}?${new URLSearchParams(authorizationParams)}`;
|
|
312
318
|
const data = await authAction(body, req, signInUrl, authOpts);
|
|
313
|
-
if (data.url)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
319
|
+
if (data.url) {
|
|
320
|
+
throw req.redirect(301, data.url);
|
|
321
|
+
}
|
|
322
|
+
}, zod$({
|
|
317
323
|
providerId: z.string().optional(),
|
|
318
324
|
redirectTo: z.string().optional(),
|
|
319
325
|
options: z.object({
|
|
@@ -324,25 +330,22 @@ function QwikAuthQrl(authOptions) {
|
|
|
324
330
|
z.custom(),
|
|
325
331
|
z.record(z.string())
|
|
326
332
|
]).optional()
|
|
327
|
-
}
|
|
328
|
-
const useSignOut =
|
|
329
|
-
const [authOptions2] = useLexicalScope();
|
|
333
|
+
}));
|
|
334
|
+
const useSignOut = globalAction$(async ({ redirectTo }, req) => {
|
|
330
335
|
if (!isServer) return;
|
|
331
336
|
redirectTo ?? (redirectTo = defaultRedirectTo(req));
|
|
332
|
-
const authOpts = await
|
|
337
|
+
const authOpts = await authOptions(req);
|
|
333
338
|
setEnvDefaults(req.env, authOpts);
|
|
334
339
|
const body = new URLSearchParams({
|
|
335
340
|
callbackUrl: redirectTo
|
|
336
341
|
});
|
|
337
342
|
await authAction(body, req, `/auth/signout`, authOpts);
|
|
338
|
-
},
|
|
339
|
-
authOptions
|
|
340
|
-
]), zodQrl(/* @__PURE__ */ inlinedQrl({
|
|
343
|
+
}, zod$({
|
|
341
344
|
redirectTo: z.string().optional()
|
|
342
|
-
}
|
|
343
|
-
const useSession =
|
|
345
|
+
}));
|
|
346
|
+
const useSession = routeLoader$((req) => {
|
|
344
347
|
return req.sharedMap.get("session");
|
|
345
|
-
}
|
|
348
|
+
});
|
|
346
349
|
const onRequest = async (req) => {
|
|
347
350
|
if (isServer) {
|
|
348
351
|
const prefix = "/auth";
|
|
@@ -387,11 +390,15 @@ async function authAction(body, req, path, authOptions) {
|
|
|
387
390
|
const res = await Auth(request, authOptions);
|
|
388
391
|
const cookies = [];
|
|
389
392
|
res.headers.forEach((value, key) => {
|
|
390
|
-
if (key === "set-cookie")
|
|
393
|
+
if (key === "set-cookie") {
|
|
391
394
|
cookies.push(value);
|
|
392
|
-
else if (!req.headers.has(key))
|
|
395
|
+
} else if (!req.headers.has(key)) {
|
|
396
|
+
req.headers.set(key, value);
|
|
397
|
+
}
|
|
393
398
|
});
|
|
394
|
-
if (cookies.length > 0)
|
|
399
|
+
if (cookies.length > 0) {
|
|
400
|
+
req.headers.set("set-cookie", cookies.join(", "));
|
|
401
|
+
}
|
|
395
402
|
fixCookies(req);
|
|
396
403
|
try {
|
|
397
404
|
return await res.json();
|
|
@@ -404,8 +411,8 @@ const fixCookies = (req) => {
|
|
|
404
411
|
const cookie = req.headers.get("set-cookie");
|
|
405
412
|
if (cookie) {
|
|
406
413
|
req.headers.delete("set-cookie");
|
|
407
|
-
|
|
408
|
-
const { name, value, ...rest } =
|
|
414
|
+
setCookieExports.splitCookiesString(cookie).forEach((cookie2) => {
|
|
415
|
+
const { name, value, ...rest } = setCookieExports.parseString(cookie2);
|
|
409
416
|
req.cookie.set(name, value, rest);
|
|
410
417
|
});
|
|
411
418
|
}
|
|
@@ -424,14 +431,18 @@ async function getSessionData(req, options) {
|
|
|
424
431
|
const { status = 200 } = response;
|
|
425
432
|
const data = await response.json();
|
|
426
433
|
const cookie = response.headers.get("set-cookie");
|
|
427
|
-
if (!data || !Object.keys(data).length)
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
434
|
+
if (!data || !Object.keys(data).length) {
|
|
435
|
+
return {
|
|
436
|
+
data: null,
|
|
437
|
+
cookie
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
if (status === 200) {
|
|
441
|
+
return {
|
|
442
|
+
data,
|
|
443
|
+
cookie
|
|
444
|
+
};
|
|
445
|
+
}
|
|
435
446
|
throw new Error(data.message);
|
|
436
447
|
}
|
|
437
448
|
const setEnvDefaults = (env, config) => {
|
|
@@ -440,14 +451,18 @@ const setEnvDefaults = (env, config) => {
|
|
|
440
451
|
if (!config.secret?.length) {
|
|
441
452
|
config.secret = [];
|
|
442
453
|
const secret = env.get("AUTH_SECRET");
|
|
443
|
-
if (secret)
|
|
454
|
+
if (secret) {
|
|
455
|
+
config.secret.push(secret);
|
|
456
|
+
}
|
|
444
457
|
for (const i of [
|
|
445
458
|
1,
|
|
446
459
|
2,
|
|
447
460
|
3
|
|
448
461
|
]) {
|
|
449
462
|
const secret2 = env.get(`AUTH_SECRET_${i}`);
|
|
450
|
-
if (secret2)
|
|
463
|
+
if (secret2) {
|
|
464
|
+
config.secret.unshift(secret2);
|
|
465
|
+
}
|
|
451
466
|
}
|
|
452
467
|
}
|
|
453
468
|
config.redirectProxyUrl ?? (config.redirectProxyUrl = env.get("AUTH_REDIRECT_PROXY_URL"));
|
|
@@ -459,8 +474,12 @@ const setEnvDefaults = (env, config) => {
|
|
|
459
474
|
if (finalProvider.type === "oauth" || finalProvider.type === "oidc") {
|
|
460
475
|
finalProvider.clientId ?? (finalProvider.clientId = env.get(`AUTH_${ID}_ID`));
|
|
461
476
|
finalProvider.clientSecret ?? (finalProvider.clientSecret = env.get(`AUTH_${ID}_SECRET`));
|
|
462
|
-
if (finalProvider.type === "oidc")
|
|
463
|
-
|
|
477
|
+
if (finalProvider.type === "oidc") {
|
|
478
|
+
finalProvider.issuer ?? (finalProvider.issuer = env.get(`AUTH_${ID}_ISSUER`));
|
|
479
|
+
}
|
|
480
|
+
} else if (finalProvider.type === "email") {
|
|
481
|
+
finalProvider.apiKey ?? (finalProvider.apiKey = env.get(`AUTH_${ID}_KEY`));
|
|
482
|
+
}
|
|
464
483
|
return finalProvider;
|
|
465
484
|
});
|
|
466
485
|
};
|
|
@@ -469,8 +488,6 @@ export {
|
|
|
469
488
|
CredentialsSignin,
|
|
470
489
|
QwikAuth$,
|
|
471
490
|
QwikAuthQrl,
|
|
472
|
-
authAction as _auto_authAction,
|
|
473
|
-
defaultRedirectTo as _auto_defaultRedirectTo,
|
|
474
491
|
customFetch,
|
|
475
492
|
setEnvDefaults
|
|
476
493
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth/qwik",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Authentication for Qwik.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "gioboa <giorgiob.boa@gmail.com>",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"set-cookie-parser": "^2.6.0",
|
|
52
|
-
"@auth/core": "0.41.
|
|
52
|
+
"@auth/core": "0.41.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@builder.io/qwik": "1.
|
|
56
|
-
"@builder.io/qwik-city": "1.
|
|
55
|
+
"@builder.io/qwik": "1.19.1",
|
|
56
|
+
"@builder.io/qwik-city": "1.19.2",
|
|
57
57
|
"@types/set-cookie-parser": "^2.4.7",
|
|
58
58
|
"typescript": "^5.4.5",
|
|
59
|
-
"vite-plugin-dts": "^
|
|
60
|
-
"vite-plugin-static-copy": "^
|
|
59
|
+
"vite-plugin-dts": "^4.5.4",
|
|
60
|
+
"vite-plugin-static-copy": "^2.3.2"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "pnpm clean && pnpm providers && vite build --mode lib",
|