@axium/client 0.9.2 → 0.9.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/dist/cli/config.js +11 -2
- package/dist/cli/index.js +3 -0
- package/dist/user.js +3 -1
- package/package.json +1 -1
package/dist/cli/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as io from '@axium/core/node/io';
|
|
2
2
|
import { loadPlugin } from '@axium/core/node/plugins';
|
|
3
|
-
import { mkdirSync } from 'node:fs';
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { join } from 'node:path/posix';
|
|
6
6
|
import * as z from 'zod';
|
|
@@ -10,6 +10,8 @@ import { getCurrentSession } from '../user.js';
|
|
|
10
10
|
export const configDir = join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'axium');
|
|
11
11
|
mkdirSync(configDir, { recursive: true });
|
|
12
12
|
const axcConfig = join(configDir, 'config.json');
|
|
13
|
+
if (!existsSync(axcConfig))
|
|
14
|
+
writeFileSync(axcConfig, '{}');
|
|
13
15
|
export const cacheDir = join(process.env.XDG_CACHE_HOME || join(homedir(), '.cache'), 'axium');
|
|
14
16
|
mkdirSync(cacheDir, { recursive: true });
|
|
15
17
|
export function session() {
|
|
@@ -30,7 +32,14 @@ export async function loadConfig(safe) {
|
|
|
30
32
|
await loadPlugin('client', plugin, axcConfig, safe);
|
|
31
33
|
}
|
|
32
34
|
catch (e) {
|
|
33
|
-
io.warn('Failed to load config: ' +
|
|
35
|
+
io.warn('Failed to load config: ' +
|
|
36
|
+
(e instanceof z.core.$ZodError
|
|
37
|
+
? z.prettifyError(e)
|
|
38
|
+
: e instanceof Error
|
|
39
|
+
? io._debugOutput
|
|
40
|
+
? e.stack
|
|
41
|
+
: e.message
|
|
42
|
+
: String(e)));
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
export function saveConfig() {
|
package/dist/cli/index.js
CHANGED
|
@@ -64,6 +64,9 @@ import { prefix, setPrefix, setToken } from '../requests.js';
|
|
|
64
64
|
import { getCurrentSession, logout } from '../user.js';
|
|
65
65
|
import { loadConfig, saveConfig, updateCache } from './config.js';
|
|
66
66
|
const safe = z.stringbool().default(false).parse(process.env.SAFE?.toLowerCase()) || process.argv.includes('--safe');
|
|
67
|
+
const debug = z.stringbool().default(false).parse(process.env.DEBUG?.toLowerCase()) || process.argv.includes('--debug');
|
|
68
|
+
if (debug)
|
|
69
|
+
io._setDebugOutput(true);
|
|
67
70
|
await loadConfig(safe);
|
|
68
71
|
process.on('SIGHUP', () => {
|
|
69
72
|
io.info('Reloading configuration due to SIGHUP.');
|
package/dist/user.js
CHANGED
|
@@ -141,7 +141,9 @@ export async function createPasskey(userId) {
|
|
|
141
141
|
_checkId(userId);
|
|
142
142
|
const options = await fetchAPI('OPTIONS', 'users/:id/passkeys', {}, userId);
|
|
143
143
|
const response = await startRegistration({ optionsJSON: options });
|
|
144
|
-
|
|
144
|
+
const passkey = await fetchAPI('PUT', 'users/:id/passkeys', response, userId);
|
|
145
|
+
passkey.createdAt = new Date(passkey.createdAt);
|
|
146
|
+
return passkey;
|
|
145
147
|
}
|
|
146
148
|
export async function updatePasskey(passkeyId, data) {
|
|
147
149
|
return await fetchAPI('PATCH', 'passkeys/:id', data, passkeyId);
|