@vistagenic/vista 0.3.2 → 0.3.4
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/bin/vista.js +79 -109
- package/dist/ai/embeddings.d.ts +11 -11
- package/dist/ai/embeddings.js +71 -71
- package/dist/ai/index.d.ts +10 -10
- package/dist/ai/index.js +26 -26
- package/dist/ai/providers/base.js +85 -85
- package/dist/ai/react/react-server.d.ts +1 -1
- package/dist/ai/react/react-server.js +17 -17
- package/dist/ai/react/use-agent.js +138 -138
- package/dist/auth/core.d.ts +140 -140
- package/dist/auth/core.js +165 -165
- package/dist/auth/index.d.ts +20 -20
- package/dist/auth/index.js +369 -369
- package/dist/auth/react-server.d.ts +1 -1
- package/dist/auth/react-server.js +10 -10
- package/dist/auth/react.d.ts +18 -18
- package/dist/auth/react.js +71 -71
- package/dist/bin/build-rsc-flashpack.js +6 -0
- package/dist/bin/build-rsc.js +555 -492
- package/dist/bin/build.js +365 -353
- package/dist/bin/generate.js +513 -510
- package/dist/bin/webpack.config.d.ts +3 -1
- package/dist/bin/webpack.config.js +7 -4
- package/dist/build/manifest.d.ts +169 -169
- package/dist/build/manifest.js +423 -423
- package/dist/build/rsc/client-manifest.d.ts +62 -62
- package/dist/build/rsc/client-manifest.js +295 -295
- package/dist/build/rsc/compiler.d.ts +3 -1
- package/dist/build/rsc/compiler.js +12 -7
- package/dist/build/rsc/native-scanner.d.ts +135 -135
- package/dist/build/rsc/native-scanner.js +203 -203
- package/dist/build/rsc/react-client-reference-manifest.d.ts +35 -28
- package/dist/build/rsc/react-client-reference-manifest.js +366 -240
- package/dist/build/standalone.js +260 -254
- package/dist/client/dynamic.react-server.d.ts +2 -2
- package/dist/client/dynamic.react-server.js +23 -23
- package/dist/client/link.js +1 -1
- package/dist/client/link.react-server.d.ts +2 -2
- package/dist/client/link.react-server.js +11 -11
- package/dist/client/navigation.js +2 -2
- package/dist/client/navigation.react-server.d.ts +1 -1
- package/dist/client/navigation.react-server.js +17 -17
- package/dist/client/router.react-server.d.ts +1 -1
- package/dist/client/router.react-server.js +17 -17
- package/dist/client/rsc-router.d.ts +1 -3
- package/dist/client/rsc-router.js +98 -45
- package/dist/client/rsc-router.react-server.d.ts +1 -1
- package/dist/client/rsc-router.react-server.js +17 -17
- package/dist/client/script.react-server.d.ts +2 -2
- package/dist/client/script.react-server.js +23 -23
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -7
- package/dist/deploy/adapters/cloudflare.js +42 -41
- package/dist/deploy/adapters/docker.d.ts +1 -0
- package/dist/deploy/adapters/docker.js +5 -4
- package/dist/deploy/adapters/netlify.js +60 -27
- package/dist/deploy/adapters/vercel.js +80 -50
- package/dist/deploy/preflight.js +4 -3
- package/dist/deploy/runtime-pack.d.ts +11 -0
- package/dist/deploy/runtime-pack.js +300 -0
- package/dist/deploy/utils.d.ts +7 -1
- package/dist/deploy/utils.js +95 -3
- package/dist/flashpack/command.js +1 -0
- package/dist/flashpack/runtime.js +2 -1
- package/dist/image/get-img-props.js +21 -11
- package/dist/image/image-config.d.ts +2 -0
- package/dist/image/image-config.js +17 -0
- package/dist/image/index.d.ts +18 -3
- package/dist/image/index.js +1 -1
- package/dist/image/react-server.d.ts +1 -2
- package/dist/image/react-server.js +1 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +61 -61
- package/dist/server/app-dir.d.ts +22 -0
- package/dist/server/app-dir.js +77 -0
- package/dist/server/app-router-runtime.d.ts +1 -0
- package/dist/server/app-router-runtime.js +34 -9
- package/dist/server/cookie-parse.d.ts +4 -4
- package/dist/server/cookie-parse.js +14 -14
- package/dist/server/engine.js +5 -5
- package/dist/server/hydration-chunks.d.ts +7 -0
- package/dist/server/hydration-chunks.js +49 -0
- package/dist/server/image-optimizer.js +2 -1
- package/dist/server/index.d.ts +109 -109
- package/dist/server/index.js +315 -315
- package/dist/server/middleware-runner.d.ts +125 -125
- package/dist/server/middleware-runner.js +607 -615
- package/dist/server/middleware-security.d.ts +36 -36
- package/dist/server/middleware-security.js +183 -183
- package/dist/server/module-compile-hook.js +706 -695
- package/dist/server/root-resolver.js +6 -5
- package/dist/server/rsc-engine-flashpack.d.ts +3 -1
- package/dist/server/rsc-engine-flashpack.js +12 -1
- package/dist/server/rsc-engine.d.ts +6 -1
- package/dist/server/rsc-engine.js +217 -280
- package/dist/server/rsc-upstream.js +900 -892
- package/dist/server/ssr-webpack-shim.d.ts +6 -0
- package/dist/server/ssr-webpack-shim.js +29 -0
- package/dist/server/static-generator.d.ts +2 -0
- package/dist/server/static-generator.js +33 -32
- package/dist/server/structure-validator.js +2 -1
- package/dist/server/structure-watch.js +2 -0
- package/dist/server/typed-api-runtime.js +639 -635
- package/dist/server/vista-import-map.js +134 -134
- package/dist/stack/index.d.ts +34 -34
- package/dist/stack/index.js +49 -49
- package/dist/stack/server/caller.d.ts +13 -13
- package/dist/stack/server/caller.js +42 -42
- package/dist/stack/server/executor.d.ts +40 -40
- package/dist/stack/server/executor.js +222 -222
- package/dist/stack/server/index.d.ts +11 -11
- package/dist/stack/server/index.js +24 -24
- package/dist/stack/server/procedure.d.ts +20 -20
- package/dist/stack/server/procedure.js +66 -66
- package/dist/stack/server/types.d.ts +113 -113
- package/dist/theme/react-server.d.ts +10 -10
- package/dist/theme/react-server.js +16 -16
- package/package.json +1 -1
package/dist/auth/core.js
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MemoryAdapter = void 0;
|
|
7
|
-
exports.hashPassword = hashPassword;
|
|
8
|
-
exports.verifyPassword = verifyPassword;
|
|
9
|
-
exports.randomToken = randomToken;
|
|
10
|
-
exports.encryptJwt = encryptJwt;
|
|
11
|
-
exports.decryptJwt = decryptJwt;
|
|
12
|
-
exports.pkcePair = pkcePair;
|
|
13
|
-
exports.GitHub = GitHub;
|
|
14
|
-
exports.Google = Google;
|
|
15
|
-
exports.Credentials = Credentials;
|
|
16
|
-
exports.resolveAuthConfig = resolveAuthConfig;
|
|
17
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
18
|
-
function hashPassword(password, salt) {
|
|
19
|
-
const usedSalt = salt || node_crypto_1.default.randomBytes(16).toString('hex');
|
|
20
|
-
const derived = node_crypto_1.default.scryptSync(password, usedSalt, 32).toString('hex');
|
|
21
|
-
return `${usedSalt}:${derived}`;
|
|
22
|
-
}
|
|
23
|
-
function verifyPassword(password, stored) {
|
|
24
|
-
const [salt, hash] = stored.split(':');
|
|
25
|
-
if (!salt || !hash)
|
|
26
|
-
return false;
|
|
27
|
-
const derived = node_crypto_1.default.scryptSync(password, salt, 32);
|
|
28
|
-
const actual = Buffer.from(hash, 'hex');
|
|
29
|
-
if (derived.length !== actual.length)
|
|
30
|
-
return false;
|
|
31
|
-
return node_crypto_1.default.timingSafeEqual(derived, actual);
|
|
32
|
-
}
|
|
33
|
-
function randomToken(bytes = 32) {
|
|
34
|
-
return node_crypto_1.default.randomBytes(bytes).toString('base64url');
|
|
35
|
-
}
|
|
36
|
-
function deriveKey(secret) {
|
|
37
|
-
return node_crypto_1.default.createHash('sha256').update(secret).digest();
|
|
38
|
-
}
|
|
39
|
-
function encryptJwt(payload, secret) {
|
|
40
|
-
const iv = node_crypto_1.default.randomBytes(12);
|
|
41
|
-
const cipher = node_crypto_1.default.createCipheriv('aes-256-gcm', deriveKey(secret), iv);
|
|
42
|
-
const encrypted = Buffer.concat([cipher.update(JSON.stringify(payload), 'utf8'), cipher.final()]);
|
|
43
|
-
const tag = cipher.getAuthTag();
|
|
44
|
-
return Buffer.concat([iv, tag, encrypted]).toString('base64url');
|
|
45
|
-
}
|
|
46
|
-
function decryptJwt(token, secret) {
|
|
47
|
-
try {
|
|
48
|
-
const buffer = Buffer.from(token, 'base64url');
|
|
49
|
-
const iv = buffer.subarray(0, 12);
|
|
50
|
-
const tag = buffer.subarray(12, 28);
|
|
51
|
-
const encrypted = buffer.subarray(28);
|
|
52
|
-
const decipher = node_crypto_1.default.createDecipheriv('aes-256-gcm', deriveKey(secret), iv);
|
|
53
|
-
decipher.setAuthTag(tag);
|
|
54
|
-
const json = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8');
|
|
55
|
-
const payload = JSON.parse(json);
|
|
56
|
-
if (payload.exp * 1000 < Date.now()) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return payload;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function pkcePair() {
|
|
66
|
-
const verifier = randomToken(32);
|
|
67
|
-
const challenge = node_crypto_1.default.createHash('sha256').update(verifier).digest('base64url');
|
|
68
|
-
return { verifier, challenge };
|
|
69
|
-
}
|
|
70
|
-
class MemoryAdapter {
|
|
71
|
-
users = new Map();
|
|
72
|
-
accounts = new Map();
|
|
73
|
-
createUser(user) {
|
|
74
|
-
this.users.set(user.id, user);
|
|
75
|
-
return user;
|
|
76
|
-
}
|
|
77
|
-
getUser(id) {
|
|
78
|
-
return this.users.get(id) ?? null;
|
|
79
|
-
}
|
|
80
|
-
getUserByEmail(email) {
|
|
81
|
-
return Array.from(this.users.values()).find((user) => user.email === email) ?? null;
|
|
82
|
-
}
|
|
83
|
-
getUserByAccount(provider, providerAccountId) {
|
|
84
|
-
const userId = this.accounts.get(`${provider}:${providerAccountId}`);
|
|
85
|
-
return userId ? this.getUser(userId) : null;
|
|
86
|
-
}
|
|
87
|
-
linkAccount(userId, account) {
|
|
88
|
-
this.accounts.set(`${account.provider}:${account.providerAccountId}`, userId);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.MemoryAdapter = MemoryAdapter;
|
|
92
|
-
function GitHub(options) {
|
|
93
|
-
return {
|
|
94
|
-
id: 'github',
|
|
95
|
-
name: 'GitHub',
|
|
96
|
-
type: 'oauth',
|
|
97
|
-
clientId: options.clientId || process.env.AUTH_GITHUB_ID || process.env.GITHUB_ID || '',
|
|
98
|
-
clientSecret: options.clientSecret || process.env.AUTH_GITHUB_SECRET || process.env.GITHUB_SECRET || '',
|
|
99
|
-
authorization: {
|
|
100
|
-
url: 'https://github.com/login/oauth/authorize',
|
|
101
|
-
params: { scope: 'read:user user:email' },
|
|
102
|
-
},
|
|
103
|
-
token: 'https://github.com/login/oauth/access_token',
|
|
104
|
-
userinfo: 'https://api.github.com/user',
|
|
105
|
-
profile(profile) {
|
|
106
|
-
return {
|
|
107
|
-
id: String(profile.id),
|
|
108
|
-
name: profile.name || profile.login,
|
|
109
|
-
email: profile.email,
|
|
110
|
-
image: profile.avatar_url,
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function Google(options = {}) {
|
|
116
|
-
return {
|
|
117
|
-
id: 'google',
|
|
118
|
-
name: 'Google',
|
|
119
|
-
type: 'oauth',
|
|
120
|
-
clientId: options.clientId || process.env.AUTH_GOOGLE_ID || process.env.GOOGLE_ID || '',
|
|
121
|
-
clientSecret: options.clientSecret || process.env.AUTH_GOOGLE_SECRET || process.env.GOOGLE_SECRET || '',
|
|
122
|
-
authorization: {
|
|
123
|
-
url: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
124
|
-
params: { scope: 'openid email profile', response_type: 'code' },
|
|
125
|
-
},
|
|
126
|
-
token: 'https://oauth2.googleapis.com/token',
|
|
127
|
-
userinfo: 'https://openidconnect.googleapis.com/v1/userinfo',
|
|
128
|
-
profile(profile) {
|
|
129
|
-
return {
|
|
130
|
-
id: String(profile.sub || profile.id),
|
|
131
|
-
name: profile.name,
|
|
132
|
-
email: profile.email,
|
|
133
|
-
image: profile.picture,
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function Credentials(options) {
|
|
139
|
-
return {
|
|
140
|
-
id: options.id || 'credentials',
|
|
141
|
-
name: options.name || 'Credentials',
|
|
142
|
-
type: 'credentials',
|
|
143
|
-
credentials: options.credentials || {
|
|
144
|
-
email: { label: 'Email', type: 'email' },
|
|
145
|
-
password: { label: 'Password', type: 'password' },
|
|
146
|
-
},
|
|
147
|
-
authorize: options.authorize,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function resolveAuthConfig(config) {
|
|
151
|
-
const secret = config.secret || process.env.AUTH_SECRET || process.env.NEXTAUTH_SECRET;
|
|
152
|
-
if (!secret) {
|
|
153
|
-
throw new Error('AUTH_SECRET is required. Set it in the environment or pass secret to VistaAuth().');
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
...config,
|
|
157
|
-
secret,
|
|
158
|
-
basePath: config.basePath || '/api/auth',
|
|
159
|
-
session: {
|
|
160
|
-
strategy: config.session?.strategy || 'jwt',
|
|
161
|
-
maxAge: config.session?.maxAge ?? 30 * 24 * 60 * 60,
|
|
162
|
-
cookieName: config.session?.cookieName || 'vista.session-token',
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MemoryAdapter = void 0;
|
|
7
|
+
exports.hashPassword = hashPassword;
|
|
8
|
+
exports.verifyPassword = verifyPassword;
|
|
9
|
+
exports.randomToken = randomToken;
|
|
10
|
+
exports.encryptJwt = encryptJwt;
|
|
11
|
+
exports.decryptJwt = decryptJwt;
|
|
12
|
+
exports.pkcePair = pkcePair;
|
|
13
|
+
exports.GitHub = GitHub;
|
|
14
|
+
exports.Google = Google;
|
|
15
|
+
exports.Credentials = Credentials;
|
|
16
|
+
exports.resolveAuthConfig = resolveAuthConfig;
|
|
17
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
18
|
+
function hashPassword(password, salt) {
|
|
19
|
+
const usedSalt = salt || node_crypto_1.default.randomBytes(16).toString('hex');
|
|
20
|
+
const derived = node_crypto_1.default.scryptSync(password, usedSalt, 32).toString('hex');
|
|
21
|
+
return `${usedSalt}:${derived}`;
|
|
22
|
+
}
|
|
23
|
+
function verifyPassword(password, stored) {
|
|
24
|
+
const [salt, hash] = stored.split(':');
|
|
25
|
+
if (!salt || !hash)
|
|
26
|
+
return false;
|
|
27
|
+
const derived = node_crypto_1.default.scryptSync(password, salt, 32);
|
|
28
|
+
const actual = Buffer.from(hash, 'hex');
|
|
29
|
+
if (derived.length !== actual.length)
|
|
30
|
+
return false;
|
|
31
|
+
return node_crypto_1.default.timingSafeEqual(derived, actual);
|
|
32
|
+
}
|
|
33
|
+
function randomToken(bytes = 32) {
|
|
34
|
+
return node_crypto_1.default.randomBytes(bytes).toString('base64url');
|
|
35
|
+
}
|
|
36
|
+
function deriveKey(secret) {
|
|
37
|
+
return node_crypto_1.default.createHash('sha256').update(secret).digest();
|
|
38
|
+
}
|
|
39
|
+
function encryptJwt(payload, secret) {
|
|
40
|
+
const iv = node_crypto_1.default.randomBytes(12);
|
|
41
|
+
const cipher = node_crypto_1.default.createCipheriv('aes-256-gcm', deriveKey(secret), iv);
|
|
42
|
+
const encrypted = Buffer.concat([cipher.update(JSON.stringify(payload), 'utf8'), cipher.final()]);
|
|
43
|
+
const tag = cipher.getAuthTag();
|
|
44
|
+
return Buffer.concat([iv, tag, encrypted]).toString('base64url');
|
|
45
|
+
}
|
|
46
|
+
function decryptJwt(token, secret) {
|
|
47
|
+
try {
|
|
48
|
+
const buffer = Buffer.from(token, 'base64url');
|
|
49
|
+
const iv = buffer.subarray(0, 12);
|
|
50
|
+
const tag = buffer.subarray(12, 28);
|
|
51
|
+
const encrypted = buffer.subarray(28);
|
|
52
|
+
const decipher = node_crypto_1.default.createDecipheriv('aes-256-gcm', deriveKey(secret), iv);
|
|
53
|
+
decipher.setAuthTag(tag);
|
|
54
|
+
const json = Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8');
|
|
55
|
+
const payload = JSON.parse(json);
|
|
56
|
+
if (payload.exp * 1000 < Date.now()) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return payload;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function pkcePair() {
|
|
66
|
+
const verifier = randomToken(32);
|
|
67
|
+
const challenge = node_crypto_1.default.createHash('sha256').update(verifier).digest('base64url');
|
|
68
|
+
return { verifier, challenge };
|
|
69
|
+
}
|
|
70
|
+
class MemoryAdapter {
|
|
71
|
+
users = new Map();
|
|
72
|
+
accounts = new Map();
|
|
73
|
+
createUser(user) {
|
|
74
|
+
this.users.set(user.id, user);
|
|
75
|
+
return user;
|
|
76
|
+
}
|
|
77
|
+
getUser(id) {
|
|
78
|
+
return this.users.get(id) ?? null;
|
|
79
|
+
}
|
|
80
|
+
getUserByEmail(email) {
|
|
81
|
+
return Array.from(this.users.values()).find((user) => user.email === email) ?? null;
|
|
82
|
+
}
|
|
83
|
+
getUserByAccount(provider, providerAccountId) {
|
|
84
|
+
const userId = this.accounts.get(`${provider}:${providerAccountId}`);
|
|
85
|
+
return userId ? this.getUser(userId) : null;
|
|
86
|
+
}
|
|
87
|
+
linkAccount(userId, account) {
|
|
88
|
+
this.accounts.set(`${account.provider}:${account.providerAccountId}`, userId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.MemoryAdapter = MemoryAdapter;
|
|
92
|
+
function GitHub(options) {
|
|
93
|
+
return {
|
|
94
|
+
id: 'github',
|
|
95
|
+
name: 'GitHub',
|
|
96
|
+
type: 'oauth',
|
|
97
|
+
clientId: options.clientId || process.env.AUTH_GITHUB_ID || process.env.GITHUB_ID || '',
|
|
98
|
+
clientSecret: options.clientSecret || process.env.AUTH_GITHUB_SECRET || process.env.GITHUB_SECRET || '',
|
|
99
|
+
authorization: {
|
|
100
|
+
url: 'https://github.com/login/oauth/authorize',
|
|
101
|
+
params: { scope: 'read:user user:email' },
|
|
102
|
+
},
|
|
103
|
+
token: 'https://github.com/login/oauth/access_token',
|
|
104
|
+
userinfo: 'https://api.github.com/user',
|
|
105
|
+
profile(profile) {
|
|
106
|
+
return {
|
|
107
|
+
id: String(profile.id),
|
|
108
|
+
name: profile.name || profile.login,
|
|
109
|
+
email: profile.email,
|
|
110
|
+
image: profile.avatar_url,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function Google(options = {}) {
|
|
116
|
+
return {
|
|
117
|
+
id: 'google',
|
|
118
|
+
name: 'Google',
|
|
119
|
+
type: 'oauth',
|
|
120
|
+
clientId: options.clientId || process.env.AUTH_GOOGLE_ID || process.env.GOOGLE_ID || '',
|
|
121
|
+
clientSecret: options.clientSecret || process.env.AUTH_GOOGLE_SECRET || process.env.GOOGLE_SECRET || '',
|
|
122
|
+
authorization: {
|
|
123
|
+
url: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
124
|
+
params: { scope: 'openid email profile', response_type: 'code' },
|
|
125
|
+
},
|
|
126
|
+
token: 'https://oauth2.googleapis.com/token',
|
|
127
|
+
userinfo: 'https://openidconnect.googleapis.com/v1/userinfo',
|
|
128
|
+
profile(profile) {
|
|
129
|
+
return {
|
|
130
|
+
id: String(profile.sub || profile.id),
|
|
131
|
+
name: profile.name,
|
|
132
|
+
email: profile.email,
|
|
133
|
+
image: profile.picture,
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function Credentials(options) {
|
|
139
|
+
return {
|
|
140
|
+
id: options.id || 'credentials',
|
|
141
|
+
name: options.name || 'Credentials',
|
|
142
|
+
type: 'credentials',
|
|
143
|
+
credentials: options.credentials || {
|
|
144
|
+
email: { label: 'Email', type: 'email' },
|
|
145
|
+
password: { label: 'Password', type: 'password' },
|
|
146
|
+
},
|
|
147
|
+
authorize: options.authorize,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function resolveAuthConfig(config) {
|
|
151
|
+
const secret = config.secret || process.env.AUTH_SECRET || process.env.NEXTAUTH_SECRET;
|
|
152
|
+
if (!secret) {
|
|
153
|
+
throw new Error('AUTH_SECRET is required. Set it in the environment or pass secret to VistaAuth().');
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
...config,
|
|
157
|
+
secret,
|
|
158
|
+
basePath: config.basePath || '/api/auth',
|
|
159
|
+
session: {
|
|
160
|
+
strategy: config.session?.strategy || 'jwt',
|
|
161
|
+
maxAge: config.session?.maxAge ?? 30 * 24 * 60 * 60,
|
|
162
|
+
cookieName: config.session?.cookieName || 'vista.session-token',
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { type AuthConfig, type AuthSession, type ResolvedAuthConfig } from './core';
|
|
2
|
-
export * from './core';
|
|
3
|
-
export declare function VistaAuth(config: AuthConfig): {
|
|
4
|
-
handlers: {
|
|
5
|
-
GET: (request: Request) => Promise<Response>;
|
|
6
|
-
POST: (request: Request) => Promise<Response>;
|
|
7
|
-
};
|
|
8
|
-
auth: (request?: Request) => Promise<AuthSession | null>;
|
|
9
|
-
signIn: (providerId?: string, options?: Record<string, string>) => Promise<Response>;
|
|
10
|
-
signOut: () => Promise<Response>;
|
|
11
|
-
authMiddleware: (authorized?: (params: {
|
|
12
|
-
auth: AuthSession | null;
|
|
13
|
-
request: Request;
|
|
14
|
-
}) => boolean | Response | Promise<boolean | Response>) => ({ request, next }: {
|
|
15
|
-
request: any;
|
|
16
|
-
next: () => Promise<Response>;
|
|
17
|
-
}) => Promise<Response>;
|
|
18
|
-
config: ResolvedAuthConfig;
|
|
19
|
-
};
|
|
20
|
-
export default VistaAuth;
|
|
1
|
+
import { type AuthConfig, type AuthSession, type ResolvedAuthConfig } from './core';
|
|
2
|
+
export * from './core';
|
|
3
|
+
export declare function VistaAuth(config: AuthConfig): {
|
|
4
|
+
handlers: {
|
|
5
|
+
GET: (request: Request) => Promise<Response>;
|
|
6
|
+
POST: (request: Request) => Promise<Response>;
|
|
7
|
+
};
|
|
8
|
+
auth: (request?: Request) => Promise<AuthSession | null>;
|
|
9
|
+
signIn: (providerId?: string, options?: Record<string, string>) => Promise<Response>;
|
|
10
|
+
signOut: () => Promise<Response>;
|
|
11
|
+
authMiddleware: (authorized?: (params: {
|
|
12
|
+
auth: AuthSession | null;
|
|
13
|
+
request: Request;
|
|
14
|
+
}) => boolean | Response | Promise<boolean | Response>) => ({ request, next }: {
|
|
15
|
+
request: any;
|
|
16
|
+
next: () => Promise<Response>;
|
|
17
|
+
}) => Promise<Response>;
|
|
18
|
+
config: ResolvedAuthConfig;
|
|
19
|
+
};
|
|
20
|
+
export default VistaAuth;
|