@actual-app/sync-server 25.10.0-nightly.20250925 → 25.10.0-nightly.20250927
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/src/load-config.js
CHANGED
|
@@ -26,7 +26,26 @@ convict.addFormat({
|
|
|
26
26
|
return;
|
|
27
27
|
if (typeof val === 'number' && Number.isFinite(val) && val >= 0)
|
|
28
28
|
return;
|
|
29
|
-
|
|
29
|
+
// Handle string values that can be converted to numbers (from env vars)
|
|
30
|
+
if (typeof val === 'string') {
|
|
31
|
+
const numVal = Number(val);
|
|
32
|
+
if (Number.isFinite(numVal) && numVal >= 0)
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`Invalid token_expiration value: ${val}: value was "${val}"`);
|
|
36
|
+
},
|
|
37
|
+
coerce(val) {
|
|
38
|
+
if (val === 'never' || val === 'openid-provider')
|
|
39
|
+
return val;
|
|
40
|
+
if (typeof val === 'number')
|
|
41
|
+
return val;
|
|
42
|
+
// Convert string values to numbers for environment variables
|
|
43
|
+
if (typeof val === 'string') {
|
|
44
|
+
const numVal = Number(val);
|
|
45
|
+
if (Number.isFinite(numVal) && numVal >= 0)
|
|
46
|
+
return numVal;
|
|
47
|
+
}
|
|
48
|
+
return val; // Let validate() handle invalid values
|
|
30
49
|
},
|
|
31
50
|
});
|
|
32
51
|
// Main config schema
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import convict from 'convict';
|
|
2
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
3
|
+
// Import the custom format
|
|
4
|
+
import './load-config.js';
|
|
5
|
+
describe('tokenExpiration format', () => {
|
|
6
|
+
let originalEnv;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
originalEnv = { ...process.env };
|
|
9
|
+
});
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
process.env = originalEnv;
|
|
12
|
+
});
|
|
13
|
+
it('should accept string numbers from environment variables', () => {
|
|
14
|
+
// Test string number
|
|
15
|
+
process.env.TEST_TOKEN_EXPIRATION = '86400';
|
|
16
|
+
const testSchema = convict({
|
|
17
|
+
token_expiration: {
|
|
18
|
+
format: 'tokenExpiration',
|
|
19
|
+
default: 'never',
|
|
20
|
+
env: 'TEST_TOKEN_EXPIRATION',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
expect(() => testSchema.validate()).not.toThrow();
|
|
24
|
+
expect(testSchema.get('token_expiration')).toBe(86400);
|
|
25
|
+
expect(typeof testSchema.get('token_expiration')).toBe('number');
|
|
26
|
+
});
|
|
27
|
+
it('should accept different string numbers', () => {
|
|
28
|
+
const testSchema = convict({
|
|
29
|
+
token_expiration: {
|
|
30
|
+
format: 'tokenExpiration',
|
|
31
|
+
default: 'never',
|
|
32
|
+
env: 'TEST_TOKEN_EXPIRATION',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
// Test different string numbers
|
|
36
|
+
const testCases = ['3600', '7200', '0'];
|
|
37
|
+
for (const testValue of testCases) {
|
|
38
|
+
process.env.TEST_TOKEN_EXPIRATION = testValue;
|
|
39
|
+
testSchema.load({});
|
|
40
|
+
expect(() => testSchema.validate()).not.toThrow();
|
|
41
|
+
expect(testSchema.get('token_expiration')).toBe(Number(testValue));
|
|
42
|
+
expect(typeof testSchema.get('token_expiration')).toBe('number');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
it('should accept special string values', () => {
|
|
46
|
+
const testSchema = convict({
|
|
47
|
+
token_expiration: {
|
|
48
|
+
format: 'tokenExpiration',
|
|
49
|
+
default: 'never',
|
|
50
|
+
env: 'TEST_TOKEN_EXPIRATION',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
// Test 'never' value
|
|
54
|
+
process.env.TEST_TOKEN_EXPIRATION = 'never';
|
|
55
|
+
testSchema.load({});
|
|
56
|
+
expect(() => testSchema.validate()).not.toThrow();
|
|
57
|
+
expect(testSchema.get('token_expiration')).toBe('never');
|
|
58
|
+
// Test 'openid-provider' value
|
|
59
|
+
process.env.TEST_TOKEN_EXPIRATION = 'openid-provider';
|
|
60
|
+
testSchema.load({});
|
|
61
|
+
expect(() => testSchema.validate()).not.toThrow();
|
|
62
|
+
expect(testSchema.get('token_expiration')).toBe('openid-provider');
|
|
63
|
+
});
|
|
64
|
+
it('should accept numeric values directly', () => {
|
|
65
|
+
const testSchema = convict({
|
|
66
|
+
token_expiration: {
|
|
67
|
+
format: 'tokenExpiration',
|
|
68
|
+
default: 'never',
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
testSchema.set('token_expiration', 86400);
|
|
72
|
+
expect(() => testSchema.validate()).not.toThrow();
|
|
73
|
+
expect(testSchema.get('token_expiration')).toBe(86400);
|
|
74
|
+
});
|
|
75
|
+
it('should reject invalid string values', () => {
|
|
76
|
+
const testSchema = convict({
|
|
77
|
+
token_expiration: {
|
|
78
|
+
format: 'tokenExpiration',
|
|
79
|
+
default: 'never',
|
|
80
|
+
env: 'TEST_TOKEN_EXPIRATION',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
// Test invalid string
|
|
84
|
+
process.env.TEST_TOKEN_EXPIRATION = 'invalid';
|
|
85
|
+
testSchema.load({});
|
|
86
|
+
expect(() => testSchema.validate()).toThrow(/Invalid token_expiration value/);
|
|
87
|
+
// Test negative number as string
|
|
88
|
+
process.env.TEST_TOKEN_EXPIRATION = '-100';
|
|
89
|
+
testSchema.load({});
|
|
90
|
+
expect(() => testSchema.validate()).toThrow(/Invalid token_expiration value/);
|
|
91
|
+
});
|
|
92
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actual-app/sync-server",
|
|
3
|
-
"version": "25.10.0-nightly.
|
|
3
|
+
"version": "25.10.0-nightly.20250927",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "actual syncing server",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@actual-app/crdt": "2.1.0",
|
|
31
|
-
"@actual-app/web": "25.10.0-nightly.
|
|
31
|
+
"@actual-app/web": "25.10.0-nightly.20250927",
|
|
32
32
|
"bcrypt": "^6.0.0",
|
|
33
33
|
"better-sqlite3": "^12.2.0",
|
|
34
34
|
"convict": "^6.2.4",
|