@axium/server 0.19.2 → 0.19.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/build/client/_app/immutable/chunks/{DC6rf2pV.js → BMO2uJEL.js} +1 -1
- package/build/client/_app/immutable/chunks/BMO2uJEL.js.br +0 -0
- package/build/client/_app/immutable/chunks/BMO2uJEL.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.BhR1OQ9M.js → app.BtDtVL8V.js} +2 -2
- package/build/client/_app/immutable/entry/app.BtDtVL8V.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BtDtVL8V.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.D7_oizIq.js +1 -0
- package/build/client/_app/immutable/entry/start.D7_oizIq.js.br +2 -0
- package/build/client/_app/immutable/entry/start.D7_oizIq.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.CmApQ62q.js → 1.BMfCraPE.js} +1 -1
- package/build/client/_app/immutable/nodes/1.BMfCraPE.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.BMfCraPE.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/server/chunks/{1-Dvu-6EP-.js → 1-CIIjhTW-.js} +2 -2
- package/build/server/chunks/{1-Dvu-6EP-.js.map → 1-CIIjhTW-.js.map} +1 -1
- package/build/server/chunks/{hooks.server-w5bqOSE3.js → hooks.server-B8traf9Y.js} +54 -2
- package/build/server/chunks/hooks.server-B8traf9Y.js.map +1 -0
- package/build/server/index.js +2 -2
- package/build/server/index.js.map +1 -1
- package/build/server/manifest.js +2 -2
- package/build/server/manifest.js.map +1 -1
- package/dist/auth.js +1 -1
- package/dist/cli.js +0 -3
- package/dist/database.js +208 -132
- package/package.json +1 -1
- package/build/client/_app/immutable/chunks/DC6rf2pV.js.br +0 -0
- package/build/client/_app/immutable/chunks/DC6rf2pV.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.BhR1OQ9M.js.br +0 -0
- package/build/client/_app/immutable/entry/app.BhR1OQ9M.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.DVsnYbMe.js +0 -1
- package/build/client/_app/immutable/entry/start.DVsnYbMe.js.br +0 -2
- package/build/client/_app/immutable/entry/start.DVsnYbMe.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.CmApQ62q.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.CmApQ62q.js.gz +0 -0
- package/build/server/chunks/hooks.server-w5bqOSE3.js.map +0 -1
package/build/server/manifest.js
CHANGED
|
@@ -10,10 +10,10 @@ return {
|
|
|
10
10
|
assets: new Set(["icons/brands.svg","icons/light.svg","icons/regular.svg","icons/solid.svg","styles.css"]),
|
|
11
11
|
mimeTypes: {".svg":"image/svg+xml",".css":"text/css"},
|
|
12
12
|
_: {
|
|
13
|
-
client: {start:"_app/immutable/entry/start.
|
|
13
|
+
client: {start:"_app/immutable/entry/start.D7_oizIq.js",app:"_app/immutable/entry/app.BtDtVL8V.js",imports:["_app/immutable/entry/start.D7_oizIq.js","_app/immutable/chunks/BMO2uJEL.js","_app/immutable/chunks/IgiyYk6u.js","_app/immutable/chunks/DCUM25og.js","_app/immutable/chunks/BYEtX5Az.js","_app/immutable/chunks/p-F-zYzk.js","_app/immutable/entry/app.BtDtVL8V.js","_app/immutable/chunks/DCUM25og.js","_app/immutable/chunks/BYEtX5Az.js","_app/immutable/chunks/DsnmJJEf.js","_app/immutable/chunks/IgiyYk6u.js","_app/immutable/chunks/p-F-zYzk.js","_app/immutable/chunks/FWeOBoAM.js"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},
|
|
14
14
|
nodes: [
|
|
15
15
|
__memo(() => import('./chunks/0-BwO1RCtn.js')),
|
|
16
|
-
__memo(() => import('./chunks/1-
|
|
16
|
+
__memo(() => import('./chunks/1-CIIjhTW-.js')),
|
|
17
17
|
__memo(() => import('./chunks/2-BwMXZ3uH.js')),
|
|
18
18
|
__memo(() => import('./chunks/3-BI9EEPQX.js')),
|
|
19
19
|
__memo(() => import('./chunks/4-B4PHWuxx.js')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sources":["../../.svelte-kit/adapter-node/manifest.js"],"sourcesContent":["export const manifest = (() => {\nfunction __memo(fn) {\n\tlet value;\n\treturn () => value ??= (value = fn());\n}\n\nreturn {\n\tappDir: \"_app\",\n\tappPath: \"_app\",\n\tassets: new Set([\"icons/brands.svg\",\"icons/light.svg\",\"icons/regular.svg\",\"icons/solid.svg\",\"styles.css\"]),\n\tmimeTypes: {\".svg\":\"image/svg+xml\",\".css\":\"text/css\"},\n\t_: {\n\t\tclient: {start:\"_app/immutable/entry/start.
|
|
1
|
+
{"version":3,"file":"manifest.js","sources":["../../.svelte-kit/adapter-node/manifest.js"],"sourcesContent":["export const manifest = (() => {\nfunction __memo(fn) {\n\tlet value;\n\treturn () => value ??= (value = fn());\n}\n\nreturn {\n\tappDir: \"_app\",\n\tappPath: \"_app\",\n\tassets: new Set([\"icons/brands.svg\",\"icons/light.svg\",\"icons/regular.svg\",\"icons/solid.svg\",\"styles.css\"]),\n\tmimeTypes: {\".svg\":\"image/svg+xml\",\".css\":\"text/css\"},\n\t_: {\n\t\tclient: {start:\"_app/immutable/entry/start.D7_oizIq.js\",app:\"_app/immutable/entry/app.BtDtVL8V.js\",imports:[\"_app/immutable/entry/start.D7_oizIq.js\",\"_app/immutable/chunks/BMO2uJEL.js\",\"_app/immutable/chunks/IgiyYk6u.js\",\"_app/immutable/chunks/DCUM25og.js\",\"_app/immutable/chunks/BYEtX5Az.js\",\"_app/immutable/chunks/p-F-zYzk.js\",\"_app/immutable/entry/app.BtDtVL8V.js\",\"_app/immutable/chunks/DCUM25og.js\",\"_app/immutable/chunks/BYEtX5Az.js\",\"_app/immutable/chunks/DsnmJJEf.js\",\"_app/immutable/chunks/IgiyYk6u.js\",\"_app/immutable/chunks/p-F-zYzk.js\",\"_app/immutable/chunks/FWeOBoAM.js\"],stylesheets:[],fonts:[],uses_env_dynamic_public:false},\n\t\tnodes: [\n\t\t\t__memo(() => import('./nodes/0.js')),\n\t\t\t__memo(() => import('./nodes/1.js')),\n\t\t\t__memo(() => import('./nodes/2.js')),\n\t\t\t__memo(() => import('./nodes/3.js')),\n\t\t\t__memo(() => import('./nodes/4.js')),\n\t\t\t__memo(() => import('./nodes/5.js')),\n\t\t\t__memo(() => import('./nodes/6.js'))\n\t\t],\n\t\troutes: [\n\t\t\t{\n\t\t\t\tid: \"/_axium/default\",\n\t\t\t\tpattern: /^\\/_axium\\/default\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 2 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/account\",\n\t\t\t\tpattern: /^\\/account\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 3 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/login\",\n\t\t\t\tpattern: /^\\/login\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 4 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/logout\",\n\t\t\t\tpattern: /^\\/logout\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 5 },\n\t\t\t\tendpoint: null\n\t\t\t},\n\t\t\t{\n\t\t\t\tid: \"/register\",\n\t\t\t\tpattern: /^\\/register\\/?$/,\n\t\t\t\tparams: [],\n\t\t\t\tpage: { layouts: [0,], errors: [1,], leaf: 6 },\n\t\t\t\tendpoint: null\n\t\t\t}\n\t\t],\n\t\tprerendered_routes: new Set([]),\n\t\tmatchers: async () => {\n\t\t\t\n\t\t\treturn { };\n\t\t},\n\t\tserver_assets: {}\n\t}\n}\n})();\n\nexport const prerendered = new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M,EAAE,EAAE;AACd,IAAI,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;AAClD,IAAI,QAAQ,EAAE;AACd;AACA,GAAG;AACH,EAAE,kBAAkB,EAAE,IAAI,GAAG,CAAC,EAAE,CAAC;AACjC,EAAE,QAAQ,EAAE,YAAY;AACxB;AACA,GAAG,OAAO,IAAI;AACd,EAAE,CAAC;AACH,EAAE,aAAa,EAAE;AACjB;AACA;AACA,CAAC;;AAEW,MAAC,WAAW,GAAG,IAAI,GAAG,CAAC,EAAE;;AAEzB,MAAC,IAAI,GAAG;;;;"}
|
package/dist/auth.js
CHANGED
|
@@ -103,7 +103,7 @@ export async function checkAuthForUser(event, userId, sensitive = false) {
|
|
|
103
103
|
return Object.assign(session, { accessor: session.user });
|
|
104
104
|
}
|
|
105
105
|
export async function checkAuthForItem(event, itemType, itemId, permission) {
|
|
106
|
-
const token = getToken(event,
|
|
106
|
+
const token = getToken(event, false);
|
|
107
107
|
if (!token)
|
|
108
108
|
error(401, 'Missing token');
|
|
109
109
|
const session = await getSessionAndUser(token).catch(() => null);
|
package/dist/cli.js
CHANGED
package/dist/database.js
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
1
53
|
import { Kysely, PostgresDialect, sql } from 'kysely';
|
|
2
54
|
import { jsonObjectFrom } from 'kysely/helpers/postgres';
|
|
3
55
|
import { randomBytes } from 'node:crypto';
|
|
@@ -99,118 +151,130 @@ export async function createIndex(table, column, mod) {
|
|
|
99
151
|
await query.execute().then(io.done).catch(warnExists);
|
|
100
152
|
}
|
|
101
153
|
export async function init(opt) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
154
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
155
|
+
try {
|
|
156
|
+
if (!config.db.password) {
|
|
157
|
+
config.save({ db: { password: randomBytes(32).toString('base64') } }, true);
|
|
158
|
+
io.debug('Generated password and wrote to global config');
|
|
159
|
+
}
|
|
160
|
+
await io.run('Checking for sudo', 'which sudo');
|
|
161
|
+
await io.run('Checking for psql', 'which psql');
|
|
162
|
+
await _sql('CREATE DATABASE axium', 'Creating database').catch(async (error) => {
|
|
163
|
+
if (error != 'database "axium" already exists')
|
|
164
|
+
throw error;
|
|
165
|
+
if (shouldRecreate(opt))
|
|
166
|
+
return;
|
|
167
|
+
await _sql('DROP DATABASE axium', 'Dropping database');
|
|
168
|
+
await _sql('CREATE DATABASE axium', 'Re-creating database');
|
|
169
|
+
});
|
|
170
|
+
const createQuery = `CREATE USER axium WITH ENCRYPTED PASSWORD '${config.db.password}' LOGIN`;
|
|
171
|
+
await _sql(createQuery, 'Creating user').catch(async (error) => {
|
|
172
|
+
if (error != 'role "axium" already exists')
|
|
173
|
+
throw error;
|
|
174
|
+
if (shouldRecreate(opt))
|
|
175
|
+
return;
|
|
176
|
+
await _sql('REVOKE ALL PRIVILEGES ON SCHEMA public FROM axium', 'Revoking schema privileges');
|
|
177
|
+
await _sql('DROP USER axium', 'Dropping user');
|
|
178
|
+
await _sql(createQuery, 'Re-creating user');
|
|
179
|
+
});
|
|
180
|
+
await _sql('GRANT ALL PRIVILEGES ON DATABASE axium TO axium', 'Granting database privileges');
|
|
181
|
+
await _sql('GRANT ALL PRIVILEGES ON SCHEMA public TO axium', 'Granting schema privileges');
|
|
182
|
+
await _sql('ALTER DATABASE axium OWNER TO axium', 'Setting database owner');
|
|
183
|
+
await getHBA(opt)
|
|
184
|
+
.then(([content, writeBack]) => {
|
|
185
|
+
io.start('Checking for Axium HBA configuration');
|
|
186
|
+
if (content.includes(pgHba))
|
|
187
|
+
throw 'already exists.';
|
|
188
|
+
io.done();
|
|
189
|
+
io.start('Adding Axium HBA configuration');
|
|
190
|
+
const newContent = content.replace(/^local\s+all\s+all.*$/m, `$&\n${pgHba}`);
|
|
191
|
+
io.done();
|
|
192
|
+
writeBack(newContent);
|
|
193
|
+
})
|
|
194
|
+
.catch(io.warn);
|
|
195
|
+
await _sql('SELECT pg_reload_conf()', 'Reloading configuration');
|
|
196
|
+
io.start('Connecting to database');
|
|
197
|
+
const _ = __addDisposableResource(env_1, connect(), true);
|
|
137
198
|
io.done();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
199
|
+
function maybeCheck(table) {
|
|
200
|
+
return (e) => {
|
|
201
|
+
warnExists(e);
|
|
202
|
+
if (opt.check)
|
|
203
|
+
return checkTableTypes(table, expectedTypes[table], opt);
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
io.start('Creating table users');
|
|
207
|
+
await database.schema
|
|
208
|
+
.createTable('users')
|
|
209
|
+
.addColumn('id', 'uuid', col => col.primaryKey().defaultTo(sql `gen_random_uuid()`))
|
|
210
|
+
.addColumn('name', 'text')
|
|
211
|
+
.addColumn('email', 'text', col => col.unique().notNull())
|
|
212
|
+
.addColumn('emailVerified', 'timestamptz')
|
|
213
|
+
.addColumn('image', 'text')
|
|
214
|
+
.addColumn('isAdmin', 'boolean', col => col.notNull().defaultTo(false))
|
|
215
|
+
.addColumn('roles', sql `text[]`, col => col.notNull().defaultTo(sql `'{}'::text[]`))
|
|
216
|
+
.addColumn('tags', sql `text[]`, col => col.notNull().defaultTo(sql `'{}'::text[]`))
|
|
217
|
+
.addColumn('preferences', 'jsonb', col => col.notNull().defaultTo('{}'))
|
|
218
|
+
.addColumn('registeredAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
219
|
+
.execute()
|
|
220
|
+
.then(io.done)
|
|
221
|
+
.catch(maybeCheck('users'));
|
|
222
|
+
io.start('Creating table sessions');
|
|
223
|
+
await database.schema
|
|
224
|
+
.createTable('sessions')
|
|
225
|
+
.addColumn('id', 'uuid', col => col.primaryKey().defaultTo(sql `gen_random_uuid()`))
|
|
226
|
+
.addColumn('userId', 'uuid', col => col.references('users.id').onDelete('cascade').notNull())
|
|
227
|
+
.addColumn('token', 'text', col => col.notNull().unique())
|
|
228
|
+
.addColumn('created', 'timestamptz', col => col.notNull())
|
|
229
|
+
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
230
|
+
.addColumn('elevated', 'boolean', col => col.notNull())
|
|
231
|
+
.execute()
|
|
232
|
+
.then(io.done)
|
|
233
|
+
.catch(maybeCheck('sessions'));
|
|
234
|
+
await createIndex('sessions', 'id');
|
|
235
|
+
io.start('Creating table verifications');
|
|
236
|
+
await database.schema
|
|
237
|
+
.createTable('verifications')
|
|
238
|
+
.addColumn('userId', 'uuid', col => col.references('users.id').onDelete('cascade').notNull())
|
|
239
|
+
.addColumn('token', 'text', col => col.notNull().unique())
|
|
240
|
+
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
241
|
+
.addColumn('role', 'text', col => col.notNull())
|
|
242
|
+
.execute()
|
|
243
|
+
.then(io.done)
|
|
244
|
+
.catch(maybeCheck('verifications'));
|
|
245
|
+
io.start('Creating table passkeys');
|
|
246
|
+
await database.schema
|
|
247
|
+
.createTable('passkeys')
|
|
248
|
+
.addColumn('id', 'text', col => col.primaryKey().notNull())
|
|
249
|
+
.addColumn('name', 'text')
|
|
250
|
+
.addColumn('createdAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
251
|
+
.addColumn('userId', 'uuid', col => col.notNull().references('users.id').onDelete('cascade').notNull())
|
|
252
|
+
.addColumn('publicKey', 'bytea', col => col.notNull())
|
|
253
|
+
.addColumn('counter', 'integer', col => col.notNull())
|
|
254
|
+
.addColumn('deviceType', 'text', col => col.notNull())
|
|
255
|
+
.addColumn('backedUp', 'boolean', col => col.notNull())
|
|
256
|
+
.addColumn('transports', sql `text[]`)
|
|
257
|
+
.execute()
|
|
258
|
+
.then(io.done)
|
|
259
|
+
.catch(maybeCheck('passkeys'));
|
|
260
|
+
await createIndex('passkeys', 'userId');
|
|
261
|
+
io.start('Creating schema acl');
|
|
262
|
+
await database.schema.createSchema('acl').execute().then(io.done).catch(warnExists);
|
|
263
|
+
for (const plugin of plugins) {
|
|
264
|
+
if (!plugin.hooks.db_init)
|
|
265
|
+
continue;
|
|
266
|
+
io.plugin(plugin.name);
|
|
267
|
+
await plugin.hooks.db_init(opt);
|
|
268
|
+
}
|
|
151
269
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
.addColumn('isAdmin', 'boolean', col => col.notNull().defaultTo(false))
|
|
161
|
-
.addColumn('roles', sql `text[]`, col => col.notNull().defaultTo(sql `'{}'::text[]`))
|
|
162
|
-
.addColumn('tags', sql `text[]`, col => col.notNull().defaultTo(sql `'{}'::text[]`))
|
|
163
|
-
.addColumn('preferences', 'jsonb', col => col.notNull().defaultTo('{}'))
|
|
164
|
-
.addColumn('registeredAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
165
|
-
.execute()
|
|
166
|
-
.then(io.done)
|
|
167
|
-
.catch(maybeCheck('users'));
|
|
168
|
-
io.start('Creating table sessions');
|
|
169
|
-
await database.schema
|
|
170
|
-
.createTable('sessions')
|
|
171
|
-
.addColumn('id', 'uuid', col => col.primaryKey().defaultTo(sql `gen_random_uuid()`))
|
|
172
|
-
.addColumn('userId', 'uuid', col => col.references('users.id').onDelete('cascade').notNull())
|
|
173
|
-
.addColumn('token', 'text', col => col.notNull().unique())
|
|
174
|
-
.addColumn('created', 'timestamptz', col => col.notNull())
|
|
175
|
-
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
176
|
-
.addColumn('elevated', 'boolean', col => col.notNull())
|
|
177
|
-
.execute()
|
|
178
|
-
.then(io.done)
|
|
179
|
-
.catch(maybeCheck('sessions'));
|
|
180
|
-
await createIndex('sessions', 'id');
|
|
181
|
-
io.start('Creating table verifications');
|
|
182
|
-
await database.schema
|
|
183
|
-
.createTable('verifications')
|
|
184
|
-
.addColumn('userId', 'uuid', col => col.references('users.id').onDelete('cascade').notNull())
|
|
185
|
-
.addColumn('token', 'text', col => col.notNull().unique())
|
|
186
|
-
.addColumn('expires', 'timestamptz', col => col.notNull())
|
|
187
|
-
.addColumn('role', 'text', col => col.notNull())
|
|
188
|
-
.execute()
|
|
189
|
-
.then(io.done)
|
|
190
|
-
.catch(maybeCheck('verifications'));
|
|
191
|
-
io.start('Creating table passkeys');
|
|
192
|
-
await database.schema
|
|
193
|
-
.createTable('passkeys')
|
|
194
|
-
.addColumn('id', 'text', col => col.primaryKey().notNull())
|
|
195
|
-
.addColumn('name', 'text')
|
|
196
|
-
.addColumn('createdAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
197
|
-
.addColumn('userId', 'uuid', col => col.notNull().references('users.id').onDelete('cascade').notNull())
|
|
198
|
-
.addColumn('publicKey', 'bytea', col => col.notNull())
|
|
199
|
-
.addColumn('counter', 'integer', col => col.notNull())
|
|
200
|
-
.addColumn('deviceType', 'text', col => col.notNull())
|
|
201
|
-
.addColumn('backedUp', 'boolean', col => col.notNull())
|
|
202
|
-
.addColumn('transports', sql `text[]`)
|
|
203
|
-
.execute()
|
|
204
|
-
.then(io.done)
|
|
205
|
-
.catch(maybeCheck('passkeys'));
|
|
206
|
-
await createIndex('passkeys', 'userId');
|
|
207
|
-
io.start('Creating schema acl');
|
|
208
|
-
await database.schema.createSchema('acl').execute().then(io.done).catch(warnExists);
|
|
209
|
-
for (const plugin of plugins) {
|
|
210
|
-
if (!plugin.hooks.db_init)
|
|
211
|
-
continue;
|
|
212
|
-
io.plugin(plugin.name);
|
|
213
|
-
await plugin.hooks.db_init(opt);
|
|
270
|
+
catch (e_1) {
|
|
271
|
+
env_1.error = e_1;
|
|
272
|
+
env_1.hasError = true;
|
|
273
|
+
}
|
|
274
|
+
finally {
|
|
275
|
+
const result_1 = __disposeResources(env_1);
|
|
276
|
+
if (result_1)
|
|
277
|
+
await result_1;
|
|
214
278
|
}
|
|
215
279
|
}
|
|
216
280
|
export const expectedTypes = {
|
|
@@ -298,29 +362,41 @@ export async function checkTableTypes(tableName, types, opt) {
|
|
|
298
362
|
io.warn(unchecked);
|
|
299
363
|
}
|
|
300
364
|
export async function check(opt) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
opt._metadata = await database.introspection.getTables();
|
|
310
|
-
const tables = Object.fromEntries(opt._metadata.map(t => [t.name, t]));
|
|
311
|
-
io.done();
|
|
312
|
-
for (const table of Object.keys(expectedTypes)) {
|
|
313
|
-
await checkTableTypes(table, expectedTypes[table], opt);
|
|
314
|
-
delete tables[table];
|
|
315
|
-
}
|
|
316
|
-
io.start('Checking for extra tables');
|
|
317
|
-
const unchecked = Object.keys(tables).join(', ');
|
|
318
|
-
if (!unchecked.length)
|
|
365
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
366
|
+
try {
|
|
367
|
+
await io.run('Checking for sudo', 'which sudo');
|
|
368
|
+
await io.run('Checking for psql', 'which psql');
|
|
369
|
+
await _sql(`SELECT 1 FROM pg_database WHERE datname = 'axium'`, 'Checking for database').then(throwUnlessRows);
|
|
370
|
+
await _sql(`SELECT 1 FROM pg_roles WHERE rolname = 'axium'`, 'Checking for user').then(throwUnlessRows);
|
|
371
|
+
io.start('Connecting to database');
|
|
372
|
+
const _ = __addDisposableResource(env_2, connect(), true);
|
|
319
373
|
io.done();
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
io.
|
|
374
|
+
io.start('Getting table metadata');
|
|
375
|
+
opt._metadata = await database.introspection.getTables();
|
|
376
|
+
const tables = Object.fromEntries(opt._metadata.map(t => [t.name, t]));
|
|
377
|
+
io.done();
|
|
378
|
+
for (const table of Object.keys(expectedTypes)) {
|
|
379
|
+
await checkTableTypes(table, expectedTypes[table], opt);
|
|
380
|
+
delete tables[table];
|
|
381
|
+
}
|
|
382
|
+
io.start('Checking for extra tables');
|
|
383
|
+
const unchecked = Object.keys(tables).join(', ');
|
|
384
|
+
if (!unchecked.length)
|
|
385
|
+
io.done();
|
|
386
|
+
else if (opt.strict)
|
|
387
|
+
throw unchecked;
|
|
388
|
+
else
|
|
389
|
+
io.warn(unchecked);
|
|
390
|
+
}
|
|
391
|
+
catch (e_2) {
|
|
392
|
+
env_2.error = e_2;
|
|
393
|
+
env_2.hasError = true;
|
|
394
|
+
}
|
|
395
|
+
finally {
|
|
396
|
+
const result_2 = __disposeResources(env_2);
|
|
397
|
+
if (result_2)
|
|
398
|
+
await result_2;
|
|
399
|
+
}
|
|
324
400
|
}
|
|
325
401
|
export async function clean(opt) {
|
|
326
402
|
const now = new Date();
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as o,a as r}from"../chunks/DC6rf2pV.js";export{o as load_css,r as start};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|