authup 1.0.0-beta.34 → 1.0.0-beta.36

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.
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs CHANGED
@@ -1,446 +1,336 @@
1
1
  #!/usr/bin/env node
2
- import { defineCommand, runMain } from 'citty';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import process from 'node:process';
6
- import { makeURLPublicAccessible, extendObject, isObject, hasOwnProperty } from '@authup/kit';
7
- import { dycraft, defineGetter } from 'dycraft';
8
- import zod from 'zod';
9
- import { merge } from 'smob';
10
- import { oneOf, readInt, read } from 'envix';
11
- import { Container } from 'confinity';
12
- import consola from 'consola';
13
- import { exec } from 'node:child_process';
14
- import findUpPackagePath from 'resolve-package-path';
15
-
16
-
17
- // -- Shims --
18
- import cjsUrl from 'node:url';
19
- import cjsPath from 'node:path';
20
- import cjsModule from 'node:module';
21
- const __filename = cjsUrl.fileURLToPath(import.meta.url);
22
- const __dirname = cjsPath.dirname(__filename);
23
- const require = cjsModule.createRequire(import.meta.url);
2
+ import { defineCommand, runMain } from "citty";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import process from "node:process";
6
+ import { extendObject, hasOwnProperty, isObject, makeURLPublicAccessible } from "@authup/kit";
7
+ import { defineGetter, dycraft } from "dycraft";
8
+ import zod from "zod";
9
+ import { merge } from "smob";
10
+ import { oneOf, read, readInt } from "envix";
11
+ import { Container } from "confinity";
12
+ import consola from "consola";
13
+ import { exec } from "node:child_process";
14
+ import findUpPackagePath from "resolve-package-path";
15
+ //#region src/packages/client-web/config/parse.ts
24
16
  function parseClientWebConfig(input = {}) {
25
- const schema = zod.object({
26
- port: zod.number().nonnegative().optional(),
27
- host: zod.string().optional(),
28
- apiUrl: zod.string().url().optional(),
29
- publicUrl: zod.string().url().optional()
30
- });
31
- return schema.parse(input);
17
+ return zod.object({
18
+ port: zod.number().nonnegative().optional(),
19
+ host: zod.string().optional(),
20
+ apiUrl: zod.string().url().optional(),
21
+ publicUrl: zod.string().url().optional()
22
+ }).parse(input);
32
23
  }
33
-
24
+ //#endregion
25
+ //#region src/packages/client-web/config/build.ts
34
26
  function buildClientWebConfig(raw) {
35
- const config = dycraft({
36
- defaults: {
37
- port: 3000,
38
- host: '0.0.0.0',
39
- apiUrl: 'http://127.0.0.1:3001/'
40
- },
41
- getters: {
42
- publicUrl: defineGetter((context)=>`http://${makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`)
43
- }
44
- });
45
- return extendObject(config, parseClientWebConfig(raw));
27
+ return extendObject(dycraft({
28
+ defaults: {
29
+ port: 3e3,
30
+ host: "0.0.0.0",
31
+ apiUrl: "http://127.0.0.1:3001/"
32
+ },
33
+ getters: { publicUrl: defineGetter((context) => `http://${makeURLPublicAccessible(context.get("host"))}:${context.get("port")}/`) }
34
+ }), parseClientWebConfig(raw));
46
35
  }
47
-
36
+ //#endregion
37
+ //#region src/packages/client-web/config/read/env.ts
48
38
  function readClientWebConfigFromEnv() {
49
- const config = {};
50
- const port = oneOf([
51
- readInt('UI_PORT'),
52
- readInt('NITRO_UI_PORT'),
53
- readInt('NUXT_UI_PORT'),
54
- readInt('NUXT_PUBLIC_UI_PORT'),
55
- readInt('PORT'),
56
- readInt('NITRO_PORT'),
57
- readInt('NUXT_PORT'),
58
- readInt('NUXT_PUBLIC_PORT')
59
- ]);
60
- if (typeof port !== 'undefined') {
61
- config.port = port;
62
- }
63
- const host = oneOf([
64
- read('HOST'),
65
- read('NITRO_HOST'),
66
- read('NUXT_HOST')
67
- ]);
68
- if (host) {
69
- config.host = host;
70
- }
71
- const apiUrl = oneOf([
72
- read('API_URL'),
73
- read('NUXT_API_URL'),
74
- read('NUXT_PUBLIC_API_URL')
75
- ]);
76
- if (apiUrl) {
77
- config.apiUrl = apiUrl;
78
- }
79
- const publicURL = oneOf([
80
- read('PUBLIC_URL'),
81
- read('NUXT_PUBLIC_URL'),
82
- read('NUXT_PUBLIC_PUBLIC_URL')
83
- ]);
84
- if (publicURL) {
85
- config.publicUrl = publicURL;
86
- }
87
- return config;
39
+ const config = {};
40
+ const port = oneOf([
41
+ readInt("UI_PORT"),
42
+ readInt("NITRO_UI_PORT"),
43
+ readInt("NUXT_UI_PORT"),
44
+ readInt("NUXT_PUBLIC_UI_PORT"),
45
+ readInt("PORT"),
46
+ readInt("NITRO_PORT"),
47
+ readInt("NUXT_PORT"),
48
+ readInt("NUXT_PUBLIC_PORT")
49
+ ]);
50
+ if (typeof port !== "undefined") config.port = port;
51
+ const host = oneOf([
52
+ read("HOST"),
53
+ read("NITRO_HOST"),
54
+ read("NUXT_HOST")
55
+ ]);
56
+ if (host) config.host = host;
57
+ const apiUrl = oneOf([
58
+ read("API_URL"),
59
+ read("NUXT_API_URL"),
60
+ read("NUXT_PUBLIC_API_URL")
61
+ ]);
62
+ if (apiUrl) config.apiUrl = apiUrl;
63
+ const publicURL = oneOf([
64
+ read("PUBLIC_URL"),
65
+ read("NUXT_PUBLIC_URL"),
66
+ read("NUXT_PUBLIC_PUBLIC_URL")
67
+ ]);
68
+ if (publicURL) config.publicUrl = publicURL;
69
+ return config;
88
70
  }
89
-
71
+ //#endregion
72
+ //#region src/packages/client-web/config/read/fs.ts
90
73
  async function readClientWebConfigFromFS(options = {}) {
91
- const container = new Container({
92
- prefix: 'authup',
93
- cwd: options.cwd
94
- });
95
- if (options.file) {
96
- await container.loadFile(options.file);
97
- } else {
98
- await container.load();
99
- }
100
- const clientRaw = container.get('client.web') || {};
101
- const serverRaw = container.get('server.core') || {};
102
- if (serverRaw) {
103
- if (!clientRaw.apiUrl && typeof serverRaw.publicUrl === 'string') {
104
- clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);
105
- }
106
- if (!clientRaw.publicUrl && typeof serverRaw.authorizeRedirectUrl === 'string') {
107
- clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);
108
- }
109
- }
110
- return clientRaw;
74
+ const container = new Container({
75
+ prefix: "authup",
76
+ cwd: options.cwd
77
+ });
78
+ if (options.file) await container.loadFile(options.file);
79
+ else await container.load();
80
+ const clientRaw = container.get("client.web") || {};
81
+ const serverRaw = container.get("server.core") || {};
82
+ if (serverRaw) {
83
+ if (!clientRaw.apiUrl && typeof serverRaw.publicUrl === "string") clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);
84
+ if (!clientRaw.publicUrl && typeof serverRaw.authorizeRedirectUrl === "string") clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);
85
+ }
86
+ return clientRaw;
111
87
  }
112
-
88
+ //#endregion
89
+ //#region src/packages/client-web/config/read/module.ts
113
90
  async function readClientWebConfigRaw(options = {}) {
114
- if (options.fs && options.env) {
115
- const fsOptions = boolableToObject(options.fs);
116
- const fs = await readClientWebConfigFromFS(fsOptions);
117
- const env = readClientWebConfigFromEnv();
118
- return merge(env, fs);
119
- }
120
- if (options.fs) {
121
- const fsOptions = boolableToObject(options.fs);
122
- return readClientWebConfigFromFS(fsOptions);
123
- }
124
- if (options.env) {
125
- return readClientWebConfigFromEnv();
126
- }
127
- return {};
91
+ if (options.fs && options.env) {
92
+ const fs = await readClientWebConfigFromFS(boolableToObject(options.fs));
93
+ return merge(readClientWebConfigFromEnv(), fs);
94
+ }
95
+ if (options.fs) return readClientWebConfigFromFS(boolableToObject(options.fs));
96
+ if (options.env) return readClientWebConfigFromEnv();
97
+ return {};
128
98
  }
129
99
  function boolableToObject(input) {
130
- if (typeof input === 'boolean') {
131
- return {};
132
- }
133
- return input;
100
+ if (typeof input === "boolean") return {};
101
+ return input;
134
102
  }
135
-
136
- /*
137
- * Copyright (c) 2022-2024.
138
- * Author Peter Placzek (tada5hi)
139
- * For the full copyright and license information,
140
- * view the LICENSE file that was distributed with this source code.
141
- */ function removeLineBreaks(input) {
142
- return input.replace(/(\r\n|\n|\r)/gm, '');
103
+ //#endregion
104
+ //#region src/utils/line-breaks.ts
105
+ function removeLineBreaks(input) {
106
+ return input.replace(/(\r\n|\n|\r)/gm, "");
143
107
  }
144
-
108
+ //#endregion
109
+ //#region src/utils/process-output.ts
145
110
  function parseProcessOutputData(input) {
146
- if (typeof input !== 'string') {
147
- return [];
148
- }
149
- const lines = input.split(/\r?\n/).filter((element)=>element);
150
- const items = [];
151
- for (const line_ of lines){
152
- const line = removeLineBreaks(line_).trim();
153
- if (line.length === 0) {
154
- continue;
155
- }
156
- try {
157
- const parsed = JSON.parse(line);
158
- if (isObject(parsed) && hasOwnProperty(parsed, 'message') && typeof parsed.message === 'string') {
159
- items.push(parsed.message);
160
- continue;
161
- }
162
- } catch {
163
- // no json :/
164
- }
165
- items.push(line);
166
- }
167
- return items;
111
+ if (typeof input !== "string") return [];
112
+ const lines = input.split(/\r?\n/).filter((element) => element);
113
+ const items = [];
114
+ for (const line_ of lines) {
115
+ const line = removeLineBreaks(line_).trim();
116
+ if (line.length === 0) continue;
117
+ try {
118
+ const parsed = JSON.parse(line);
119
+ if (isObject(parsed) && hasOwnProperty(parsed, "message") && typeof parsed.message === "string") {
120
+ items.push(parsed.message);
121
+ continue;
122
+ }
123
+ } catch {}
124
+ items.push(line);
125
+ }
126
+ return items;
168
127
  }
169
-
170
- /*
171
- * Copyright (c) 2022-2024.
172
- * Author Peter Placzek (tada5hi)
173
- * For the full copyright and license information,
174
- * view the LICENSE file that was distributed with this source code.
175
- */ function stringifyObjectArgs(ob) {
176
- const parts = [];
177
- const keys = Object.keys(ob);
178
- for (const key of keys){
179
- parts.push(`--${key} ${ob[key]}`);
180
- }
181
- return parts.join(' ');
128
+ //#endregion
129
+ //#region src/utils/stringify-object-args.ts
130
+ function stringifyObjectArgs(ob) {
131
+ const parts = [];
132
+ const keys = Object.keys(ob);
133
+ for (const key of keys) parts.push(`--${key} ${ob[key]}`);
134
+ return parts.join(" ");
182
135
  }
183
-
136
+ //#endregion
137
+ //#region src/utils/shell.ts
184
138
  async function execShellCommand(command, ctx = {}) {
185
- return new Promise((resolve, reject)=>{
186
- const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {
187
- env: {
188
- PATH: process.env.PATH,
189
- ...ctx.envFromProcess ? process.env : {},
190
- ...ctx.env ? ctx.env : {}
191
- }
192
- });
193
- childProcess.on('error', (data)=>{
194
- reject(data);
195
- });
196
- childProcess.on('spawn', ()=>{
197
- resolve(childProcess);
198
- });
199
- if (childProcess.stderr) {
200
- childProcess.stderr.setEncoding('utf-8');
201
- childProcess.stderr.on('data', (data)=>{
202
- if (typeof data !== 'string' || data.length === 0) {
203
- return;
204
- }
205
- if (ctx.logErrorStream) {
206
- ctx.logErrorStream(data);
207
- }
208
- });
209
- }
210
- if (childProcess.stdout) {
211
- childProcess.stdout.on('data', (data)=>{
212
- if (typeof data !== 'string' || data.length === 0) {
213
- return;
214
- }
215
- if (!ctx.logDataStream) {
216
- return;
217
- }
218
- const lines = parseProcessOutputData(data);
219
- for (const line of lines){
220
- ctx.logDataStream(line);
221
- }
222
- });
223
- }
224
- });
139
+ return new Promise((resolve, reject) => {
140
+ const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, { env: {
141
+ PATH: process.env.PATH,
142
+ ...ctx.envFromProcess ? process.env : {},
143
+ ...ctx.env ? ctx.env : {}
144
+ } });
145
+ childProcess.on("error", (data) => {
146
+ reject(data);
147
+ });
148
+ childProcess.on("spawn", () => {
149
+ resolve(childProcess);
150
+ });
151
+ if (childProcess.stderr) {
152
+ childProcess.stderr.setEncoding("utf-8");
153
+ childProcess.stderr.on("data", (data) => {
154
+ if (typeof data !== "string" || data.length === 0) return;
155
+ if (ctx.logErrorStream) ctx.logErrorStream(data);
156
+ });
157
+ }
158
+ if (childProcess.stdout) childProcess.stdout.on("data", (data) => {
159
+ if (typeof data !== "string" || data.length === 0) return;
160
+ if (!ctx.logDataStream) return;
161
+ const lines = parseProcessOutputData(data);
162
+ for (const line of lines) ctx.logDataStream(line);
163
+ });
164
+ });
225
165
  }
226
-
227
- const PACKAGE_DIRECTORY = path.join(__dirname, '..');
228
-
166
+ //#endregion
167
+ //#region src/constants.ts
168
+ const PACKAGE_DIRECTORY = path.join(__dirname, "..");
169
+ //#endregion
170
+ //#region src/utils/modules-path.ts
229
171
  function findModulePath(module) {
230
- let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);
231
- if (PACKAGE_DIRECTORY !== process.cwd()) {
232
- modulePath = findUpPackagePath(module, process.cwd());
233
- }
234
- if (!modulePath) {
235
- return undefined;
236
- }
237
- return modulePath;
172
+ let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);
173
+ if (PACKAGE_DIRECTORY !== process.cwd()) modulePath = findUpPackagePath(module, process.cwd());
174
+ if (!modulePath) return;
175
+ return modulePath;
238
176
  }
239
-
240
- /*
241
- * Copyright (c) 2023-2024.
242
- * Author Peter Placzek (tada5hi)
243
- * For the full copyright and license information,
244
- * view the LICENSE file that was distributed with this source code.
245
- */ var PackageName = /*#__PURE__*/ function(PackageName) {
246
- PackageName["CLIENT_WEB"] = "@authup/client-web";
247
- PackageName["SERVER_CORE"] = "@authup/server-core";
248
- return PackageName;
249
- }({});
250
- var PackageID = /*#__PURE__*/ function(PackageID) {
251
- PackageID["CLIENT_WEB"] = "client.web";
252
- PackageID["SERVER_CORE"] = "server.core";
253
- return PackageID;
177
+ //#endregion
178
+ //#region src/packages/constants.ts
179
+ let PackageID = /* @__PURE__ */ function(PackageID) {
180
+ PackageID["CLIENT_WEB"] = "client.web";
181
+ PackageID["SERVER_CORE"] = "server.core";
182
+ return PackageID;
254
183
  }({});
255
-
256
- class ClientWebPackage {
257
- async execute(command, options = {}) {
258
- const shellCommand = await this.buildShellCommand();
259
- const env = await this.buildEnv({
260
- configDirectory: options.configDirectory,
261
- configFile: options.configFile
262
- });
263
- return execShellCommand(shellCommand, {
264
- env,
265
- logDataStream (line) {
266
- consola.info(`${PackageID.CLIENT_WEB}: ${line}`);
267
- },
268
- logErrorStream (line) {
269
- consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);
270
- }
271
- });
272
- }
273
- async buildShellCommand() {
274
- let shellCommand;
275
- const modulePath = findModulePath(PackageName.CLIENT_WEB);
276
- if (typeof modulePath === 'string') {
277
- const directory = path.dirname(modulePath);
278
- const outputPath = path.join(directory, '.output', 'server', 'index.mjs');
279
- shellCommand = `node ${outputPath}`;
280
- } else {
281
- shellCommand = `npx ${PackageName.CLIENT_WEB}`;
282
- }
283
- return shellCommand;
284
- }
285
- async buildEnv(ctx) {
286
- const env = {};
287
- const configRaw = await readClientWebConfigRaw({
288
- fs: {
289
- file: ctx.configFile,
290
- cwd: ctx.configDirectory
291
- }
292
- });
293
- const config = buildClientWebConfig(configRaw);
294
- if (config.host) {
295
- env.HOST = config.host;
296
- }
297
- if (config.port) {
298
- env.PORT = `${config.port}`;
299
- }
300
- if (config.apiUrl) {
301
- env.API_URL = config.apiUrl;
302
- }
303
- if (config.publicUrl) {
304
- env.PUBLIC_URL = config.publicUrl;
305
- }
306
- return this.extendEnvKeys(env);
307
- }
308
- extendEnvKeys(input) {
309
- const env = {};
310
- const keys = Object.keys(input);
311
- for (const key of keys){
312
- env[key] = input[key];
313
- if (!key.match(/^(?:NUXT|NITRO)_.*$/)) {
314
- env[`NUXT_PUBLIC_${key}`] = input[key];
315
- }
316
- }
317
- return env;
318
- }
319
- }
320
-
321
- class ServerCorePackage {
322
- async execute(command, options = {}) {
323
- const shellCommand = await this.buildShellCommand(command, {
324
- configDirectory: options.configDirectory,
325
- configFile: options.configFile
326
- });
327
- return execShellCommand(shellCommand, {
328
- logDataStream (line) {
329
- consola.info(`${PackageID.SERVER_CORE}: ${line}`);
330
- },
331
- logErrorStream (line) {
332
- consola.warn(`${PackageID.SERVER_CORE}: ${line}`);
333
- }
334
- });
335
- }
336
- async buildShellCommand(command, options) {
337
- const parts = [];
338
- const modulePath = findModulePath(PackageName.SERVER_CORE);
339
- if (typeof modulePath === 'string') {
340
- const directory = path.dirname(modulePath);
341
- const outputPath = path.join(directory, 'dist', 'cli', 'index.js');
342
- parts.push(`node ${outputPath}`);
343
- } else {
344
- parts.push(`npx ${PackageName.SERVER_CORE}`);
345
- }
346
- parts.push(command);
347
- if (options.configFile) {
348
- parts.push(`--configFile=${options.configFile}`);
349
- }
350
- if (options.configDirectory) {
351
- parts.push(`--configDirectory=${options.configDirectory}`);
352
- }
353
- return parts.join(' ');
354
- }
355
- }
356
-
184
+ //#endregion
185
+ //#region src/packages/client-web/module.ts
186
+ var ClientWebPackage = class {
187
+ async execute(command, options = {}) {
188
+ return execShellCommand(await this.buildShellCommand(), {
189
+ env: await this.buildEnv({
190
+ configDirectory: options.configDirectory,
191
+ configFile: options.configFile
192
+ }),
193
+ logDataStream(line) {
194
+ consola.info(`client.web: ${line}`);
195
+ },
196
+ logErrorStream(line) {
197
+ consola.warn(`client.web: ${line}`);
198
+ }
199
+ });
200
+ }
201
+ async buildShellCommand() {
202
+ let shellCommand;
203
+ const modulePath = findModulePath("@authup/client-web");
204
+ if (typeof modulePath === "string") {
205
+ const directory = path.dirname(modulePath);
206
+ shellCommand = `node ${path.join(directory, ".output", "server", "index.mjs")}`;
207
+ } else shellCommand = `npx @authup/client-web`;
208
+ return shellCommand;
209
+ }
210
+ async buildEnv(ctx) {
211
+ const env = {};
212
+ const config = buildClientWebConfig(await readClientWebConfigRaw({ fs: {
213
+ file: ctx.configFile,
214
+ cwd: ctx.configDirectory
215
+ } }));
216
+ if (config.host) env.HOST = config.host;
217
+ if (config.port) env.PORT = `${config.port}`;
218
+ if (config.apiUrl) env.API_URL = config.apiUrl;
219
+ if (config.publicUrl) env.PUBLIC_URL = config.publicUrl;
220
+ return this.extendEnvKeys(env);
221
+ }
222
+ extendEnvKeys(input) {
223
+ const env = {};
224
+ const keys = Object.keys(input);
225
+ for (const key of keys) {
226
+ env[key] = input[key];
227
+ if (!key.match(/^(?:NUXT|NITRO)_.*$/)) env[`NUXT_PUBLIC_${key}`] = input[key];
228
+ }
229
+ return env;
230
+ }
231
+ };
232
+ //#endregion
233
+ //#region src/packages/server-core/module.ts
234
+ var ServerCorePackage = class {
235
+ async execute(command, options = {}) {
236
+ return execShellCommand(await this.buildShellCommand(command, {
237
+ configDirectory: options.configDirectory,
238
+ configFile: options.configFile
239
+ }), {
240
+ logDataStream(line) {
241
+ consola.info(`server.core: ${line}`);
242
+ },
243
+ logErrorStream(line) {
244
+ consola.warn(`server.core: ${line}`);
245
+ }
246
+ });
247
+ }
248
+ async buildShellCommand(command, options) {
249
+ const parts = [];
250
+ const modulePath = findModulePath("@authup/server-core");
251
+ if (typeof modulePath === "string") {
252
+ const directory = path.dirname(modulePath);
253
+ const outputPath = path.join(directory, "dist", "cli.mjs");
254
+ parts.push(`node ${outputPath}`);
255
+ } else parts.push(`npx @authup/server-core`);
256
+ parts.push(command);
257
+ if (options.configFile) parts.push(`--configFile=${options.configFile}`);
258
+ if (options.configDirectory) parts.push(`--configDirectory=${options.configDirectory}`);
259
+ return parts.join(" ");
260
+ }
261
+ };
262
+ //#endregion
263
+ //#region src/packages/execute.ts
357
264
  async function executePackageCommand(pkg, command, options = {}) {
358
- switch(pkg){
359
- case PackageID.CLIENT_WEB:
360
- {
361
- const serverCore = new ClientWebPackage();
362
- return serverCore.execute(command, options);
363
- }
364
- case PackageID.SERVER_CORE:
365
- {
366
- const serverCore = new ServerCorePackage();
367
- return serverCore.execute(command, options);
368
- }
369
- }
370
- throw new Error(`The package ${pkg} is not supported.`);
265
+ switch (pkg) {
266
+ case "client.web": return new ClientWebPackage().execute(command, options);
267
+ case "server.core": return new ServerCorePackage().execute(command, options);
268
+ }
269
+ throw new Error(`The package ${pkg} is not supported.`);
371
270
  }
372
-
271
+ //#endregion
272
+ //#region src/packages/normalize.ts
373
273
  function normalizePackageID(input) {
374
- const value = input.trim().toLowerCase();
375
- switch(value){
376
- case 'client.web':
377
- case 'client/web':
378
- case 'client-web':
379
- {
380
- return PackageID.CLIENT_WEB;
381
- }
382
- case 'server.core':
383
- case 'server/core':
384
- case 'server-core':
385
- {
386
- return PackageID.SERVER_CORE;
387
- }
388
- }
389
- return null;
274
+ switch (input.trim().toLowerCase()) {
275
+ case "client.web":
276
+ case "client/web":
277
+ case "client-web": return "client.web";
278
+ case "server.core":
279
+ case "server/core":
280
+ case "server-core": return "server.core";
281
+ }
282
+ return null;
390
283
  }
391
-
284
+ //#endregion
285
+ //#region src/module.ts
392
286
  async function createCLIEntryPointCommand() {
393
- const pkgRaw = await fs.promises.readFile(path.join(process.cwd(), 'package.json'), {
394
- encoding: 'utf8'
395
- });
396
- const pkg = JSON.parse(pkgRaw);
397
- return defineCommand({
398
- meta: {
399
- name: pkg.name,
400
- version: pkg.version,
401
- description: pkg.description
402
- },
403
- args: {
404
- command: {
405
- type: 'positional',
406
- description: 'The command which should be forwarded to the package.',
407
- required: true
408
- },
409
- package: {
410
- type: 'positional',
411
- description: 'The package, which should be targeted.',
412
- required: false
413
- },
414
- configDirectory: {
415
- type: 'string',
416
- description: 'Config directory path',
417
- alias: 'cD'
418
- },
419
- configFile: {
420
- type: 'string',
421
- description: 'Name of one or more configuration files.',
422
- alias: 'cF'
423
- }
424
- },
425
- async run (ctx) {
426
- let packages = ctx.args.package ? ctx.args.package.split(',') : [];
427
- if (packages.length > 0) {
428
- packages = packages.map((pkg)=>normalizePackageID(pkg)).filter((pkg)=>Boolean(pkg)).map((pkg)=>`${pkg}`);
429
- }
430
- if (packages.length === 0) {
431
- packages = Object.values(PackageID);
432
- }
433
- const promises = [];
434
- for (const package_ of packages){
435
- promises.push(executePackageCommand(package_, ctx.args.command, {
436
- configFile: ctx.args.configFile,
437
- configDirectory: ctx.args.configDirectory
438
- }));
439
- }
440
- await Promise.all(promises);
441
- }
442
- });
287
+ const pkgRaw = await fs.promises.readFile(path.join(process.cwd(), "package.json"), { encoding: "utf8" });
288
+ const pkg = JSON.parse(pkgRaw);
289
+ return defineCommand({
290
+ meta: {
291
+ name: pkg.name,
292
+ version: pkg.version,
293
+ description: pkg.description
294
+ },
295
+ args: {
296
+ command: {
297
+ type: "positional",
298
+ description: "The command which should be forwarded to the package.",
299
+ required: true
300
+ },
301
+ package: {
302
+ type: "positional",
303
+ description: "The package, which should be targeted.",
304
+ required: false
305
+ },
306
+ configDirectory: {
307
+ type: "string",
308
+ description: "Config directory path",
309
+ alias: "cD"
310
+ },
311
+ configFile: {
312
+ type: "string",
313
+ description: "Name of one or more configuration files.",
314
+ alias: "cF"
315
+ }
316
+ },
317
+ async run(ctx) {
318
+ let packages = ctx.args.package ? ctx.args.package.split(",") : [];
319
+ if (packages.length > 0) packages = packages.map((pkg) => normalizePackageID(pkg)).filter((pkg) => Boolean(pkg)).map((pkg) => `${pkg}`);
320
+ if (packages.length === 0) packages = Object.values(PackageID);
321
+ const promises = [];
322
+ for (const package_ of packages) promises.push(executePackageCommand(package_, ctx.args.command, {
323
+ configFile: ctx.args.configFile,
324
+ configDirectory: ctx.args.configDirectory
325
+ }));
326
+ await Promise.all(promises);
327
+ }
328
+ });
443
329
  }
330
+ //#endregion
331
+ //#region src/index.ts
332
+ Promise.resolve().then(() => createCLIEntryPointCommand()).then((command) => runMain(command));
333
+ //#endregion
334
+ export {};
444
335
 
445
- Promise.resolve().then(()=>createCLIEntryPointCommand()).then((command)=>runMain(command));
446
- //# sourceMappingURL=index.mjs.map
336
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/packages/client-web/config/parse.ts","../src/packages/client-web/config/build.ts","../src/packages/client-web/config/read/env.ts","../src/packages/client-web/config/read/fs.ts","../src/packages/client-web/config/read/module.ts","../src/utils/line-breaks.ts","../src/utils/process-output.ts","../src/utils/stringify-object-args.ts","../src/utils/shell.ts","../src/constants.ts","../src/utils/modules-path.ts","../src/packages/constants.ts","../src/packages/client-web/module.ts","../src/packages/server-core/module.ts","../src/packages/execute.ts","../src/packages/normalize.ts","../src/module.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport zod from 'zod';\nimport type { ClientWebConfigInput } from './type';\n\nexport function parseClientWebConfig(input: unknown = {}) : ClientWebConfigInput {\n const schema = zod.object({\n port: zod.number().nonnegative().optional(),\n host: zod.string().optional(),\n apiUrl: zod.string().url().optional(),\n publicUrl: zod.string().url().optional(),\n });\n\n return schema.parse(input);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { extendObject, makeURLPublicAccessible } from '@authup/kit';\nimport { defineGetter, dycraft } from 'dycraft';\nimport { parseClientWebConfig } from './parse';\nimport type { ClientWebConfig, ClientWebConfigInput } from './type';\n\nexport function buildClientWebConfig(raw: ClientWebConfigInput): ClientWebConfig {\n const config = dycraft({\n defaults: {\n port: 3000,\n host: '0.0.0.0',\n apiUrl: 'http://127.0.0.1:3001/',\n },\n getters: {\n publicUrl: defineGetter((\n context,\n ) => `http://${makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`),\n },\n });\n\n return extendObject(config, parseClientWebConfig(raw));\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { oneOf, read, readInt } from 'envix';\nimport type { ClientWebConfigInput } from '../type';\n\nexport function readClientWebConfigFromEnv() : ClientWebConfigInput {\n const config : ClientWebConfigInput = {};\n\n const port = oneOf([\n readInt('UI_PORT'),\n readInt('NITRO_UI_PORT'),\n readInt('NUXT_UI_PORT'),\n readInt('NUXT_PUBLIC_UI_PORT'),\n readInt('PORT'),\n readInt('NITRO_PORT'),\n readInt('NUXT_PORT'),\n readInt('NUXT_PUBLIC_PORT'),\n ]);\n\n if (typeof port !== 'undefined') {\n config.port = port;\n }\n\n const host = oneOf([\n read('HOST'),\n read('NITRO_HOST'),\n read('NUXT_HOST'),\n ]);\n\n if (host) {\n config.host = host;\n }\n\n const apiUrl = oneOf([\n read('API_URL'),\n read('NUXT_API_URL'),\n read('NUXT_PUBLIC_API_URL'),\n ]);\n\n if (apiUrl) {\n config.apiUrl = apiUrl;\n }\n\n const publicURL = oneOf([\n read('PUBLIC_URL'),\n read('NUXT_PUBLIC_URL'),\n read('NUXT_PUBLIC_PUBLIC_URL'),\n ]);\n\n if (publicURL) {\n config.publicUrl = publicURL;\n }\n\n return config;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { makeURLPublicAccessible } from '@authup/kit';\nimport { Container } from 'confinity';\nimport type { ClientWebConfigInput } from '../type';\n\nexport type ClientWebConfigReadFsOptions = {\n cwd?: string,\n file?: string | string[]\n};\n\nexport async function readClientWebConfigFromFS(options: ClientWebConfigReadFsOptions = {}) : Promise<ClientWebConfigInput> {\n const container = new Container({\n prefix: 'authup',\n cwd: options.cwd,\n });\n\n if (options.file) {\n await container.loadFile(options.file);\n } else {\n await container.load();\n }\n\n const clientRaw = container.get('client.web') || {};\n const serverRaw = container.get('server.core') || {};\n if (serverRaw) {\n if (\n !clientRaw.apiUrl &&\n typeof serverRaw.publicUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);\n }\n\n if (\n !clientRaw.publicUrl &&\n typeof serverRaw.authorizeRedirectUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);\n }\n }\n\n return clientRaw;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { merge } from 'smob';\nimport type { ClientWebConfigInput } from '../type';\nimport { readClientWebConfigFromEnv } from './env';\nimport type { ClientWebConfigReadFsOptions } from './fs';\nimport { readClientWebConfigFromFS } from './fs';\n\nexport type ClientWebConfigRawReadOptions = {\n fs?: boolean | ClientWebConfigReadFsOptions,\n env?: boolean,\n};\n\nexport async function readClientWebConfigRaw(options: ClientWebConfigRawReadOptions = {}) : Promise<ClientWebConfigInput> {\n if (options.fs && options.env) {\n const fsOptions = boolableToObject(options.fs);\n const fs = await readClientWebConfigFromFS(fsOptions);\n const env = readClientWebConfigFromEnv();\n\n return merge(env, fs);\n }\n\n if (options.fs) {\n const fsOptions = boolableToObject(options.fs);\n return readClientWebConfigFromFS(fsOptions);\n }\n\n if (options.env) {\n return readClientWebConfigFromEnv();\n }\n\n return {};\n}\n\nfunction boolableToObject<T>(input: T | boolean) : T {\n if (typeof input === 'boolean') {\n return {} as T;\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeLineBreaks(input: string) {\n return input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from '@authup/kit';\nimport { removeLineBreaks } from './line-breaks';\n\nexport function parseProcessOutputData(input: unknown) : string[] {\n if (typeof input !== 'string') {\n return [];\n }\n\n const lines = input\n .split(/\\r?\\n/)\n .filter((element) => element);\n\n const items : string[] = [];\n\n for (const line_ of lines) {\n const line = removeLineBreaks(line_).trim();\n if (line.length === 0) {\n continue;\n }\n\n try {\n const parsed = JSON.parse(line);\n\n if (\n isObject(parsed) &&\n hasOwnProperty(parsed, 'message') &&\n typeof parsed.message === 'string'\n ) {\n items.push(parsed.message);\n continue;\n }\n } catch {\n // no json :/\n }\n\n items.push(line);\n }\n\n return items;\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function stringifyObjectArgs(ob: Record<string, any>) {\n const parts : string[] = [];\n\n const keys = Object.keys(ob);\n for (const key of keys) {\n parts.push(`--${key} ${ob[key]}`);\n }\n\n return parts.join(' ');\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { exec } from 'node:child_process';\nimport process from 'node:process';\nimport { parseProcessOutputData } from './process-output';\nimport { stringifyObjectArgs } from './stringify-object-args';\n\nexport type ShellCommandExecOptions = {\n configFile?: string,\n configDirectory?: string,\n\n env?: Record<string, string | undefined>,\n envFromProcess?: boolean,\n args?: Record<string, any>,\n logErrorStream?: (content: string) => void,\n logDataStream?: (content: string) => void\n};\n\nexport async function execShellCommand(\n command: string,\n ctx: ShellCommandExecOptions = {},\n) {\n return new Promise<ChildProcess>((resolve, reject) => {\n const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {\n env: {\n PATH: process.env.PATH,\n ...(ctx.envFromProcess ? process.env : {}),\n ...(ctx.env ? ctx.env : {}),\n },\n });\n\n childProcess.on('error', (data) => {\n reject(data);\n });\n\n childProcess.on('spawn', () => {\n resolve(childProcess);\n });\n\n if (childProcess.stderr) {\n childProcess.stderr.setEncoding('utf-8');\n childProcess.stderr.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (ctx.logErrorStream) {\n ctx.logErrorStream(data);\n }\n });\n }\n if (childProcess.stdout) {\n childProcess.stdout.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (!ctx.logDataStream) {\n return;\n }\n\n const lines = parseProcessOutputData(data);\n for (const line of lines) {\n ctx.logDataStream(line);\n }\n });\n }\n });\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\n\nexport const PACKAGE_DIRECTORY = path.join(__dirname, '..');\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport process from 'node:process';\nimport findUpPackagePath from 'resolve-package-path';\nimport { PACKAGE_DIRECTORY } from '../constants';\n\nexport function findModulePath(module: string) : string | undefined {\n let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);\n if (PACKAGE_DIRECTORY !== process.cwd()) {\n modulePath = findUpPackagePath(module, process.cwd());\n }\n\n if (!modulePath) {\n return undefined;\n }\n\n return modulePath;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PackageName {\n CLIENT_WEB = '@authup/client-web',\n SERVER_CORE = '@authup/server-core',\n}\n\nexport enum PackageID {\n CLIENT_WEB = 'client.web',\n SERVER_CORE = 'server.core',\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport type { ChildProcess } from 'node:child_process';\nimport path from 'node:path';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\nimport { buildClientWebConfig, readClientWebConfigRaw } from './config';\n\nexport class ClientWebPackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) : Promise<ChildProcess> {\n const shellCommand = await this.buildShellCommand();\n const env = await this.buildEnv({\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n env,\n logDataStream(line) {\n consola.info(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand() {\n let shellCommand : string;\n\n const modulePath = findModulePath(PackageName.CLIENT_WEB);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, '.output', 'server', 'index.mjs');\n shellCommand = `node ${outputPath}`;\n } else {\n shellCommand = `npx ${PackageName.CLIENT_WEB}`;\n }\n\n return shellCommand;\n }\n\n protected async buildEnv(ctx: PackageExecuteOptions) {\n const env : Record<string, any> = {};\n\n const configRaw = await readClientWebConfigRaw({\n fs: {\n file: ctx.configFile,\n cwd: ctx.configDirectory,\n },\n });\n const config = buildClientWebConfig(configRaw);\n\n if (config.host) {\n env.HOST = config.host;\n }\n\n if (config.port) {\n env.PORT = `${config.port}`;\n }\n\n if (config.apiUrl) {\n env.API_URL = config.apiUrl;\n }\n\n if (config.publicUrl) {\n env.PUBLIC_URL = config.publicUrl;\n }\n\n return this.extendEnvKeys(env);\n }\n\n extendEnvKeys(input: Record<string, string | undefined>) {\n const env : Record<string, any> = {};\n\n const keys = Object.keys(input);\n for (const key of keys) {\n env[key] = input[key];\n\n if (!key.match(/^(?:NUXT|NITRO)_.*$/)) {\n env[`NUXT_PUBLIC_${key}`] = input[key];\n }\n }\n\n return env;\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport path from 'node:path';\nimport type { ShellCommandExecOptions } from '../../utils';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\n\nexport class ServerCorePackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) {\n const shellCommand = await this.buildShellCommand(command, {\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n logDataStream(line) {\n consola.info(`${PackageID.SERVER_CORE}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.SERVER_CORE}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand(command: string, options: ShellCommandExecOptions) {\n const parts : string[] = [];\n\n const modulePath = findModulePath(PackageName.SERVER_CORE);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, 'dist', 'cli', 'index.js');\n parts.push(`node ${outputPath}`);\n } else {\n parts.push(`npx ${PackageName.SERVER_CORE}`);\n }\n\n parts.push(command);\n\n if (options.configFile) {\n parts.push(`--configFile=${options.configFile}`);\n }\n\n if (options.configDirectory) {\n parts.push(`--configDirectory=${options.configDirectory}`);\n }\n\n return parts.join(' ');\n }\n}\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { ClientWebPackage } from './client-web';\nimport { PackageID } from './constants';\nimport { ServerCorePackage } from './server-core';\nimport type { PackageExecuteOptions } from './types';\n\nexport async function executePackageCommand(\n pkg: string,\n command: string,\n options: PackageExecuteOptions = {},\n) : Promise<ChildProcess> {\n switch (pkg) {\n case PackageID.CLIENT_WEB: {\n const serverCore = new ClientWebPackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n case PackageID.SERVER_CORE: {\n const serverCore = new ServerCorePackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n }\n\n throw new Error(`The package ${pkg} is not supported.`);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { PackageID } from './constants';\n\nexport function normalizePackageID(input: string) : `${PackageID}` | null {\n const value = input.trim().toLowerCase();\n\n switch (value) {\n case 'client.web':\n case 'client/web':\n case 'client-web': {\n return PackageID.CLIENT_WEB;\n }\n case 'server.core':\n case 'server/core':\n case 'server-core': {\n return PackageID.SERVER_CORE;\n }\n }\n\n return null;\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineCommand } from 'citty';\nimport type { ChildProcess } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { PackageID, executePackageCommand, normalizePackageID } from './packages';\n\nexport async function createCLIEntryPointCommand() {\n const pkgRaw = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n { encoding: 'utf8' },\n );\n const pkg = JSON.parse(pkgRaw);\n\n return defineCommand({\n meta: {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n },\n args: {\n command: {\n type: 'positional',\n description: 'The command which should be forwarded to the package.',\n required: true,\n },\n package: {\n type: 'positional',\n description: 'The package, which should be targeted.',\n required: false,\n },\n configDirectory: {\n type: 'string',\n description: 'Config directory path',\n alias: 'cD',\n },\n configFile: {\n type: 'string',\n description: 'Name of one or more configuration files.',\n alias: 'cF',\n },\n },\n async run(ctx) {\n let packages = ctx.args.package ?\n ctx.args.package.split(',') :\n [];\n\n if (packages.length > 0) {\n packages = packages\n .map((pkg) => normalizePackageID(pkg))\n .filter((pkg) => Boolean(pkg))\n .map((pkg) => `${pkg}`);\n }\n\n if (packages.length === 0) {\n packages = Object.values(PackageID);\n }\n\n const promises : Promise<ChildProcess>[] = [];\n for (const package_ of packages) {\n promises.push(executePackageCommand(\n package_,\n ctx.args.command,\n {\n configFile: ctx.args.configFile,\n configDirectory: ctx.args.configDirectory,\n },\n ));\n }\n\n await Promise.all(promises);\n },\n });\n}\n","#!/usr/bin/env node\n\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nPromise.resolve()\n .then(() => createCLIEntryPointCommand())\n .then((command) => runMain(command));\n"],"names":["port","apiUrl","publicUrl","config","cwd","clientRaw","items","childProcess","ctx","PackageName","PackageID","configDirectory","configFile","env","logDataStream","logErrorStream","shellCommand","file","extendEnvKeys","parts","name","version","description","packages","Promise"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAUO;;AAECA;;AAEAC;AACAC;AACJ;;AAGJ;;ACPO;AACH;;;;;AAKI;;AAEIA;AAGJ;AACJ;;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;AACJ;;AAGJ;AACJ;;AC1CO;;AAMC;AAA2B;AACvB;;AAMJ;AACA;AAA4B;AACxB;;AAMJ;AACJ;AAEA;AACJ;;AC7BO;AACH;;;;;AAKuB;AACf;AACJ;;;;AAGoB;AAChB;AACJ;AACJ;;AAGJ;;ACZO;AACH;;AAEuB;;AAIvB;;AAEQC;AACAC;AACAC;AACJ;;;;;;AAMI;;;;;AAKA;;;;;AAKA;;;;;AAKA;AACJ;AACA;AACI;;AAKIC;AAIJ;;;AAIA;AAEA;;;;;AAQQ;AAER;;AAGJ;AACJ;AACJ;;AC3EAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/packages/client-web/config/parse.ts","../src/packages/client-web/config/build.ts","../src/packages/client-web/config/read/env.ts","../src/packages/client-web/config/read/fs.ts","../src/packages/client-web/config/read/module.ts","../src/utils/line-breaks.ts","../src/utils/process-output.ts","../src/utils/stringify-object-args.ts","../src/utils/shell.ts","../src/constants.ts","../src/utils/modules-path.ts","../src/packages/constants.ts","../src/packages/client-web/module.ts","../src/packages/server-core/module.ts","../src/packages/execute.ts","../src/packages/normalize.ts","../src/module.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport zod from 'zod';\nimport type { ClientWebConfigInput } from './type';\n\nexport function parseClientWebConfig(input: unknown = {}) : ClientWebConfigInput {\n const schema = zod.object({\n port: zod.number().nonnegative().optional(),\n host: zod.string().optional(),\n apiUrl: zod.string().url().optional(),\n publicUrl: zod.string().url().optional(),\n });\n\n return schema.parse(input);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { extendObject, makeURLPublicAccessible } from '@authup/kit';\nimport { defineGetter, dycraft } from 'dycraft';\nimport { parseClientWebConfig } from './parse';\nimport type { ClientWebConfig, ClientWebConfigInput } from './type';\n\nexport function buildClientWebConfig(raw: ClientWebConfigInput): ClientWebConfig {\n const config = dycraft({\n defaults: {\n port: 3000,\n host: '0.0.0.0',\n apiUrl: 'http://127.0.0.1:3001/',\n },\n getters: {\n publicUrl: defineGetter((\n context,\n ) => `http://${makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`),\n },\n });\n\n return extendObject(config, parseClientWebConfig(raw));\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { oneOf, read, readInt } from 'envix';\nimport type { ClientWebConfigInput } from '../type';\n\nexport function readClientWebConfigFromEnv() : ClientWebConfigInput {\n const config : ClientWebConfigInput = {};\n\n const port = oneOf([\n readInt('UI_PORT'),\n readInt('NITRO_UI_PORT'),\n readInt('NUXT_UI_PORT'),\n readInt('NUXT_PUBLIC_UI_PORT'),\n readInt('PORT'),\n readInt('NITRO_PORT'),\n readInt('NUXT_PORT'),\n readInt('NUXT_PUBLIC_PORT'),\n ]);\n\n if (typeof port !== 'undefined') {\n config.port = port;\n }\n\n const host = oneOf([\n read('HOST'),\n read('NITRO_HOST'),\n read('NUXT_HOST'),\n ]);\n\n if (host) {\n config.host = host;\n }\n\n const apiUrl = oneOf([\n read('API_URL'),\n read('NUXT_API_URL'),\n read('NUXT_PUBLIC_API_URL'),\n ]);\n\n if (apiUrl) {\n config.apiUrl = apiUrl;\n }\n\n const publicURL = oneOf([\n read('PUBLIC_URL'),\n read('NUXT_PUBLIC_URL'),\n read('NUXT_PUBLIC_PUBLIC_URL'),\n ]);\n\n if (publicURL) {\n config.publicUrl = publicURL;\n }\n\n return config;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { makeURLPublicAccessible } from '@authup/kit';\nimport { Container } from 'confinity';\nimport type { ClientWebConfigInput } from '../type';\n\nexport type ClientWebConfigReadFsOptions = {\n cwd?: string,\n file?: string | string[]\n};\n\nexport async function readClientWebConfigFromFS(options: ClientWebConfigReadFsOptions = {}) : Promise<ClientWebConfigInput> {\n const container = new Container({\n prefix: 'authup',\n cwd: options.cwd,\n });\n\n if (options.file) {\n await container.loadFile(options.file);\n } else {\n await container.load();\n }\n\n const clientRaw = container.get('client.web') || {};\n const serverRaw = container.get('server.core') || {};\n if (serverRaw) {\n if (\n !clientRaw.apiUrl &&\n typeof serverRaw.publicUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);\n }\n\n if (\n !clientRaw.publicUrl &&\n typeof serverRaw.authorizeRedirectUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);\n }\n }\n\n return clientRaw;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { merge } from 'smob';\nimport type { ClientWebConfigInput } from '../type';\nimport { readClientWebConfigFromEnv } from './env';\nimport type { ClientWebConfigReadFsOptions } from './fs';\nimport { readClientWebConfigFromFS } from './fs';\n\nexport type ClientWebConfigRawReadOptions = {\n fs?: boolean | ClientWebConfigReadFsOptions,\n env?: boolean,\n};\n\nexport async function readClientWebConfigRaw(options: ClientWebConfigRawReadOptions = {}) : Promise<ClientWebConfigInput> {\n if (options.fs && options.env) {\n const fsOptions = boolableToObject(options.fs);\n const fs = await readClientWebConfigFromFS(fsOptions);\n const env = readClientWebConfigFromEnv();\n\n return merge(env, fs);\n }\n\n if (options.fs) {\n const fsOptions = boolableToObject(options.fs);\n return readClientWebConfigFromFS(fsOptions);\n }\n\n if (options.env) {\n return readClientWebConfigFromEnv();\n }\n\n return {};\n}\n\nfunction boolableToObject<T>(input: T | boolean) : T {\n if (typeof input === 'boolean') {\n return {} as T;\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeLineBreaks(input: string) {\n return input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from '@authup/kit';\nimport { removeLineBreaks } from './line-breaks';\n\nexport function parseProcessOutputData(input: unknown) : string[] {\n if (typeof input !== 'string') {\n return [];\n }\n\n const lines = input\n .split(/\\r?\\n/)\n .filter((element) => element);\n\n const items : string[] = [];\n\n for (const line_ of lines) {\n const line = removeLineBreaks(line_).trim();\n if (line.length === 0) {\n continue;\n }\n\n try {\n const parsed = JSON.parse(line);\n\n if (\n isObject(parsed) &&\n hasOwnProperty(parsed, 'message') &&\n typeof parsed.message === 'string'\n ) {\n items.push(parsed.message);\n continue;\n }\n } catch {\n // no json :/\n }\n\n items.push(line);\n }\n\n return items;\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function stringifyObjectArgs(ob: Record<string, any>) {\n const parts : string[] = [];\n\n const keys = Object.keys(ob);\n for (const key of keys) {\n parts.push(`--${key} ${ob[key]}`);\n }\n\n return parts.join(' ');\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { exec } from 'node:child_process';\nimport process from 'node:process';\nimport { parseProcessOutputData } from './process-output';\nimport { stringifyObjectArgs } from './stringify-object-args';\n\nexport type ShellCommandExecOptions = {\n configFile?: string,\n configDirectory?: string,\n\n env?: Record<string, string | undefined>,\n envFromProcess?: boolean,\n args?: Record<string, any>,\n logErrorStream?: (content: string) => void,\n logDataStream?: (content: string) => void\n};\n\nexport async function execShellCommand(\n command: string,\n ctx: ShellCommandExecOptions = {},\n) {\n return new Promise<ChildProcess>((resolve, reject) => {\n const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {\n env: {\n PATH: process.env.PATH,\n ...(ctx.envFromProcess ? process.env : {}),\n ...(ctx.env ? ctx.env : {}),\n },\n });\n\n childProcess.on('error', (data) => {\n reject(data);\n });\n\n childProcess.on('spawn', () => {\n resolve(childProcess);\n });\n\n if (childProcess.stderr) {\n childProcess.stderr.setEncoding('utf-8');\n childProcess.stderr.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (ctx.logErrorStream) {\n ctx.logErrorStream(data);\n }\n });\n }\n if (childProcess.stdout) {\n childProcess.stdout.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (!ctx.logDataStream) {\n return;\n }\n\n const lines = parseProcessOutputData(data);\n for (const line of lines) {\n ctx.logDataStream(line);\n }\n });\n }\n });\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\n\nexport const PACKAGE_DIRECTORY = path.join(__dirname, '..');\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport process from 'node:process';\nimport findUpPackagePath from 'resolve-package-path';\nimport { PACKAGE_DIRECTORY } from '../constants';\n\nexport function findModulePath(module: string) : string | undefined {\n let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);\n if (PACKAGE_DIRECTORY !== process.cwd()) {\n modulePath = findUpPackagePath(module, process.cwd());\n }\n\n if (!modulePath) {\n return undefined;\n }\n\n return modulePath;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PackageName {\n CLIENT_WEB = '@authup/client-web',\n SERVER_CORE = '@authup/server-core',\n}\n\nexport enum PackageID {\n CLIENT_WEB = 'client.web',\n SERVER_CORE = 'server.core',\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport type { ChildProcess } from 'node:child_process';\nimport path from 'node:path';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\nimport { buildClientWebConfig, readClientWebConfigRaw } from './config';\n\nexport class ClientWebPackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) : Promise<ChildProcess> {\n const shellCommand = await this.buildShellCommand();\n const env = await this.buildEnv({\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n env,\n logDataStream(line) {\n consola.info(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand() {\n let shellCommand : string;\n\n const modulePath = findModulePath(PackageName.CLIENT_WEB);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, '.output', 'server', 'index.mjs');\n shellCommand = `node ${outputPath}`;\n } else {\n shellCommand = `npx ${PackageName.CLIENT_WEB}`;\n }\n\n return shellCommand;\n }\n\n protected async buildEnv(ctx: PackageExecuteOptions) {\n const env : Record<string, any> = {};\n\n const configRaw = await readClientWebConfigRaw({\n fs: {\n file: ctx.configFile,\n cwd: ctx.configDirectory,\n },\n });\n const config = buildClientWebConfig(configRaw);\n\n if (config.host) {\n env.HOST = config.host;\n }\n\n if (config.port) {\n env.PORT = `${config.port}`;\n }\n\n if (config.apiUrl) {\n env.API_URL = config.apiUrl;\n }\n\n if (config.publicUrl) {\n env.PUBLIC_URL = config.publicUrl;\n }\n\n return this.extendEnvKeys(env);\n }\n\n extendEnvKeys(input: Record<string, string | undefined>) {\n const env : Record<string, any> = {};\n\n const keys = Object.keys(input);\n for (const key of keys) {\n env[key] = input[key];\n\n if (!key.match(/^(?:NUXT|NITRO)_.*$/)) {\n env[`NUXT_PUBLIC_${key}`] = input[key];\n }\n }\n\n return env;\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport path from 'node:path';\nimport type { ShellCommandExecOptions } from '../../utils';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\n\nexport class ServerCorePackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) {\n const shellCommand = await this.buildShellCommand(command, {\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n logDataStream(line) {\n consola.info(`${PackageID.SERVER_CORE}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.SERVER_CORE}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand(command: string, options: ShellCommandExecOptions) {\n const parts : string[] = [];\n\n const modulePath = findModulePath(PackageName.SERVER_CORE);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, 'dist', 'cli.mjs');\n parts.push(`node ${outputPath}`);\n } else {\n parts.push(`npx ${PackageName.SERVER_CORE}`);\n }\n\n parts.push(command);\n\n if (options.configFile) {\n parts.push(`--configFile=${options.configFile}`);\n }\n\n if (options.configDirectory) {\n parts.push(`--configDirectory=${options.configDirectory}`);\n }\n\n return parts.join(' ');\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { ClientWebPackage } from './client-web';\nimport { PackageID } from './constants';\nimport { ServerCorePackage } from './server-core';\nimport type { PackageExecuteOptions } from './types';\n\nexport async function executePackageCommand(\n pkg: string,\n command: string,\n options: PackageExecuteOptions = {},\n) : Promise<ChildProcess> {\n switch (pkg) {\n case PackageID.CLIENT_WEB: {\n const serverCore = new ClientWebPackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n case PackageID.SERVER_CORE: {\n const serverCore = new ServerCorePackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n }\n\n throw new Error(`The package ${pkg} is not supported.`);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { PackageID } from './constants';\n\nexport function normalizePackageID(input: string) : `${PackageID}` | null {\n const value = input.trim().toLowerCase();\n\n switch (value) {\n case 'client.web':\n case 'client/web':\n case 'client-web': {\n return PackageID.CLIENT_WEB;\n }\n case 'server.core':\n case 'server/core':\n case 'server-core': {\n return PackageID.SERVER_CORE;\n }\n }\n\n return null;\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineCommand } from 'citty';\nimport type { ChildProcess } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { PackageID, executePackageCommand, normalizePackageID } from './packages';\n\nexport async function createCLIEntryPointCommand() {\n const pkgRaw = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n { encoding: 'utf8' },\n );\n const pkg = JSON.parse(pkgRaw);\n\n return defineCommand({\n meta: {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n },\n args: {\n command: {\n type: 'positional',\n description: 'The command which should be forwarded to the package.',\n required: true,\n },\n package: {\n type: 'positional',\n description: 'The package, which should be targeted.',\n required: false,\n },\n configDirectory: {\n type: 'string',\n description: 'Config directory path',\n alias: 'cD',\n },\n configFile: {\n type: 'string',\n description: 'Name of one or more configuration files.',\n alias: 'cF',\n },\n },\n async run(ctx) {\n let packages = ctx.args.package ?\n ctx.args.package.split(',') :\n [];\n\n if (packages.length > 0) {\n packages = packages\n .map((pkg) => normalizePackageID(pkg))\n .filter((pkg) => Boolean(pkg))\n .map((pkg) => `${pkg}`);\n }\n\n if (packages.length === 0) {\n packages = Object.values(PackageID);\n }\n\n const promises : Promise<ChildProcess>[] = [];\n for (const package_ of packages) {\n promises.push(executePackageCommand(\n package_,\n ctx.args.command,\n {\n configFile: ctx.args.configFile,\n configDirectory: ctx.args.configDirectory,\n },\n ));\n }\n\n await Promise.all(promises);\n },\n });\n}\n","#!/usr/bin/env node\n\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nPromise.resolve()\n .then(() => createCLIEntryPointCommand())\n .then((command) => runMain(command));\n"],"mappings":";;;;;;;;;;;;;;;AAUA,SAAgB,qBAAqB,QAAiB,EAAE,EAAyB;AAQ7E,QAPe,IAAI,OAAO;EACtB,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,UAAU;EAC3C,MAAM,IAAI,QAAQ,CAAC,UAAU;EAC7B,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU;EACrC,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU;EAC3C,CAAC,CAEY,MAAM,MAAM;;;;ACN9B,SAAgB,qBAAqB,KAA4C;AAc7E,QAAO,aAbQ,QAAQ;EACnB,UAAU;GACN,MAAM;GACN,MAAM;GACN,QAAQ;GACX;EACD,SAAS,EACL,WAAW,cACP,YACC,UAAU,wBAAwB,QAAQ,IAAI,OAAO,CAAC,CAAC,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,EACzF;EACJ,CAAC,EAE0B,qBAAqB,IAAI,CAAC;;;;AChB1D,SAAgB,6BAAoD;CAChE,MAAM,SAAgC,EAAE;CAExC,MAAM,OAAO,MAAM;EACf,QAAQ,UAAU;EAClB,QAAQ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O;IACV;GACJ;EACD,MAAM,IAAI,KAAK;GACX,IAAI,WAAW,IAAI,KAAK,UACpB,IAAI,KAAK,QAAQ,MAAM,IAAI,GAC3B,EAAE;AAEN,OAAI,SAAS,SAAS,EAClB,YAAW,SACN,KAAK,QAAQ,mBAAmB,IAAI,CAAC,CACrC,QAAQ,QAAQ,QAAQ,IAAI,CAAC,CAC7B,KAAK,QAAQ,GAAG,MAAM;AAG/B,OAAI,SAAS,WAAW,EACpB,YAAW,OAAO,OAAO,UAAU;GAGvC,MAAM,WAAqC,EAAE;AAC7C,QAAK,MAAM,YAAY,SACnB,UAAS,KAAK,sBACV,UACA,IAAI,KAAK,SACT;IACI,YAAY,IAAI,KAAK;IACrB,iBAAiB,IAAI,KAAK;IAC7B,CACJ,CAAC;AAGN,SAAM,QAAQ,IAAI,SAAS;;EAElC,CAAC;;;;AC1EN,QAAQ,SAAS,CACZ,WAAW,4BAA4B,CAAC,CACxC,MAAM,YAAY,QAAQ,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "authup",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.34",
4
+ "version": "1.0.0-beta.36",
5
5
  "description": "This is the CLI for the authup ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -20,8 +20,8 @@
20
20
  "cli": "node dist/index.mjs",
21
21
  "cli-dev": "npm run build && npm run cli",
22
22
  "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
23
- "build:js": "rollup -c",
24
- "build": "rimraf ./dist && cross-env NODE_ENV=production npm run build:js && npm run build:types"
23
+ "build:js": "tsdown",
24
+ "build": "rimraf ./dist && npm run build:js && npm run build:types"
25
25
  },
26
26
  "engines": {
27
27
  "node": "^20.19.0 || ^22.13.0 || ^23.5.0 || >=24.0.0"
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "homepage": "https://github.com/authup/authup#readme",
56
56
  "dependencies": {
57
- "@authup/client-web": "^1.0.0-beta.34",
58
- "@authup/kit": "^1.0.0-beta.34",
59
- "@authup/core-kit": "^1.0.0-beta.34",
60
- "@authup/server-core": "^1.0.0-beta.34",
57
+ "@authup/client-web": "^1.0.0-beta.36",
58
+ "@authup/kit": "^1.0.0-beta.36",
59
+ "@authup/core-kit": "^1.0.0-beta.36",
60
+ "@authup/server-core": "^1.0.0-beta.36",
61
61
  "citty": "^0.2.2",
62
62
  "chalk": "^5.6.2",
63
63
  "confinity": "^1.0.0-beta.1",