@stamhoofd/models 2.137.5 → 2.138.0
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/helpers/Handlebars.d.ts.map +1 -1
- package/dist/helpers/Handlebars.js +1 -1
- package/dist/helpers/Handlebars.js.map +1 -1
- package/dist/helpers/errorToSimpleErrors.d.ts +3 -0
- package/dist/helpers/errorToSimpleErrors.d.ts.map +1 -0
- package/dist/helpers/errorToSimpleErrors.js +17 -0
- package/dist/helpers/errorToSimpleErrors.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/migrations/1782902314-tokens-authenticated-at.sql +2 -0
- package/dist/migrations/1782902315-create-mfa-totp-table.sql +13 -0
- package/dist/migrations/1782902316-create-webauthn-credentials-table.sql +17 -0
- package/dist/migrations/1782902317-create-mfa-recovery-codes-table.sql +10 -0
- package/dist/migrations/1782902318-create-mfa-tokens-table.sql +13 -0
- package/dist/migrations/1782902319-create-webauthn-challenges-table.sql +10 -0
- package/dist/migrations/1784039947-mfa-totp-last-used-counter.sql +2 -0
- package/dist/migrations/1784122354-webauthn-credential-provider.sql +3 -0
- package/dist/migrations/1784500000-webauthn-credential-rp-id.sql +9 -0
- package/dist/migrations/1785354091-platform-parent-tenant-id.sql +1 -0
- package/dist/migrations/1785354092-platform-fees-tenant-id.sql +1 -0
- package/dist/migrations/1785354093-platform-uri.sql +1 -0
- package/dist/migrations/1785354094-platform-domain.sql +1 -0
- package/dist/migrations/1785354095-platform-uri-unique.sql +1 -0
- package/dist/migrations/1785354096-platform-domain-unique.sql +1 -0
- package/dist/migrations/1785354097-platform-parent-tenant-id-index.sql +1 -0
- package/dist/migrations/1785354098-platform-tenant-backfill.d.ts +4 -0
- package/dist/migrations/1785354098-platform-tenant-backfill.d.ts.map +1 -0
- package/dist/migrations/1785354098-platform-tenant-backfill.js +10 -0
- package/dist/migrations/1785354098-platform-tenant-backfill.js.map +1 -0
- package/dist/migrations/1785417301-users-last-active-at.sql +2 -0
- package/dist/models/Email.d.ts +0 -6
- package/dist/models/Email.d.ts.map +1 -1
- package/dist/models/Email.js +4 -625
- package/dist/models/Email.js.map +1 -1
- package/dist/models/MFARecoveryCode.d.ts +17 -0
- package/dist/models/MFARecoveryCode.d.ts.map +1 -0
- package/dist/models/MFARecoveryCode.js +55 -0
- package/dist/models/MFARecoveryCode.js.map +1 -0
- package/dist/models/MFATOTP.d.ts +44 -0
- package/dist/models/MFATOTP.d.ts.map +1 -0
- package/dist/models/MFATOTP.js +116 -0
- package/dist/models/MFATOTP.js.map +1 -0
- package/dist/models/MFAToken.d.ts +49 -0
- package/dist/models/MFAToken.d.ts.map +1 -0
- package/dist/models/MFAToken.js +137 -0
- package/dist/models/MFAToken.js.map +1 -0
- package/dist/models/Organization.d.ts +1 -38
- package/dist/models/Organization.d.ts.map +1 -1
- package/dist/models/Organization.js +1 -132
- package/dist/models/Organization.js.map +1 -1
- package/dist/models/Platform.d.ts +28 -4
- package/dist/models/Platform.d.ts.map +1 -1
- package/dist/models/Platform.js +109 -53
- package/dist/models/Platform.js.map +1 -1
- package/dist/models/Token.d.ts +40 -1
- package/dist/models/Token.d.ts.map +1 -1
- package/dist/models/Token.js +68 -2
- package/dist/models/Token.js.map +1 -1
- package/dist/models/User.d.ts +25 -0
- package/dist/models/User.d.ts.map +1 -1
- package/dist/models/User.js +36 -0
- package/dist/models/User.js.map +1 -1
- package/dist/models/WebauthnChallenge.d.ts +27 -0
- package/dist/models/WebauthnChallenge.d.ts.map +1 -0
- package/dist/models/WebauthnChallenge.js +81 -0
- package/dist/models/WebauthnChallenge.js.map +1 -0
- package/dist/models/WebauthnCredential.d.ts +58 -0
- package/dist/models/WebauthnCredential.d.ts.map +1 -0
- package/dist/models/WebauthnCredential.js +144 -0
- package/dist/models/WebauthnCredential.js.map +1 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +5 -0
- package/dist/models/index.js.map +1 -1
- package/package.json +3 -3
- package/src/helpers/Handlebars.ts +5 -9
- package/src/helpers/errorToSimpleErrors.ts +17 -0
- package/src/index.ts +0 -1
- package/src/migrations/1782902314-tokens-authenticated-at.sql +2 -0
- package/src/migrations/1782902315-create-mfa-totp-table.sql +13 -0
- package/src/migrations/1782902316-create-webauthn-credentials-table.sql +17 -0
- package/src/migrations/1782902317-create-mfa-recovery-codes-table.sql +10 -0
- package/src/migrations/1782902318-create-mfa-tokens-table.sql +13 -0
- package/src/migrations/1782902319-create-webauthn-challenges-table.sql +10 -0
- package/src/migrations/1784039947-mfa-totp-last-used-counter.sql +2 -0
- package/src/migrations/1784122354-webauthn-credential-provider.sql +3 -0
- package/src/migrations/1784500000-webauthn-credential-rp-id.sql +9 -0
- package/src/migrations/1785354091-platform-parent-tenant-id.sql +1 -0
- package/src/migrations/1785354092-platform-fees-tenant-id.sql +1 -0
- package/src/migrations/1785354093-platform-uri.sql +1 -0
- package/src/migrations/1785354094-platform-domain.sql +1 -0
- package/src/migrations/1785354095-platform-uri-unique.sql +1 -0
- package/src/migrations/1785354096-platform-domain-unique.sql +1 -0
- package/src/migrations/1785354097-platform-parent-tenant-id-index.sql +1 -0
- package/src/migrations/1785354098-platform-tenant-backfill.ts +14 -0
- package/src/migrations/1785417301-users-last-active-at.sql +2 -0
- package/src/models/Email.ts +4 -713
- package/src/models/MFARecoveryCode.ts +52 -0
- package/src/models/MFATOTP.ts +112 -0
- package/src/models/MFAToken.ts +138 -0
- package/src/models/Organization.test.ts +0 -46
- package/src/models/Organization.ts +0 -154
- package/src/models/Platform.test.ts +167 -3
- package/src/models/Platform.ts +121 -53
- package/src/models/Token.ts +73 -2
- package/src/models/User.ts +37 -0
- package/src/models/WebauthnChallenge.ts +80 -0
- package/src/models/WebauthnCredential.ts +130 -0
- package/src/models/index.ts +6 -0
- package/dist/helpers/EmailBuilder.d.ts +0 -121
- package/dist/helpers/EmailBuilder.d.ts.map +0 -1
- package/dist/helpers/EmailBuilder.js +0 -659
- package/dist/helpers/EmailBuilder.js.map +0 -1
- package/src/helpers/EmailBuilder.test.ts +0 -291
- package/src/helpers/EmailBuilder.ts +0 -818
- package/src/models/Email.test.ts +0 -1222
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
2
|
+
/**
|
|
3
|
+
* A single passkey / WebAuthn credential enrolled by a user. A user may have multiple.
|
|
4
|
+
* `credentialId` is unique and indexed so credentials can be looked up directly (needed
|
|
5
|
+
* for future usernameless/passwordless login).
|
|
6
|
+
*/
|
|
7
|
+
export declare class WebauthnCredential extends QueryableModel {
|
|
8
|
+
static table: string;
|
|
9
|
+
id: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
/**
|
|
12
|
+
* Base64url-encoded credential id, as returned by the authenticator.
|
|
13
|
+
*/
|
|
14
|
+
credentialId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The Relying Party ID this credential was created for.
|
|
17
|
+
*
|
|
18
|
+
* A passkey is bound to one domain: the authenticator will not release it to any other
|
|
19
|
+
* one, and verification has to check it against the RP ID it was made for. Storing it
|
|
20
|
+
* per credential is what keeps existing passkeys valid if the platform ever serves more
|
|
21
|
+
* than one authentication domain, or moves to a different one.
|
|
22
|
+
*
|
|
23
|
+
* NULL for credentials created before this was stored: those all used the platform RP
|
|
24
|
+
* ID, which the helper falls back to.
|
|
25
|
+
*/
|
|
26
|
+
rpId: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Base64url-encoded COSE public key.
|
|
29
|
+
*/
|
|
30
|
+
publicKey: string;
|
|
31
|
+
counter: number;
|
|
32
|
+
/**
|
|
33
|
+
* JSON-encoded array of AuthenticatorTransport values (or null).
|
|
34
|
+
*/
|
|
35
|
+
transports: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The WebAuthn backup state (BS) flag: whether this credential is currently backed up.
|
|
38
|
+
*/
|
|
39
|
+
backedUp: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The WebAuthn backup eligibility (BE) flag: whether this credential may ever be backed
|
|
42
|
+
* up (a synced passkey) or is bound to one device.
|
|
43
|
+
*
|
|
44
|
+
* Stored next to `backedUp` because it cannot be derived from it, and a different
|
|
45
|
+
* library would expect both halves of the pair.
|
|
46
|
+
*/
|
|
47
|
+
backupEligible: boolean;
|
|
48
|
+
name: string;
|
|
49
|
+
providerId: string | null;
|
|
50
|
+
providerName: string | null;
|
|
51
|
+
lastUsedAt: Date | null;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
updatedAt: Date;
|
|
54
|
+
get transportsArray(): string[] | undefined;
|
|
55
|
+
static getForUser(userId: string): Promise<WebauthnCredential[]>;
|
|
56
|
+
static getByCredentialId(credentialId: string): Promise<WebauthnCredential | undefined>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=WebauthnCredential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebauthnCredential.d.ts","sourceRoot":"","sources":["../../src/models/WebauthnCredential.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;IAClD,MAAM,CAAC,KAAK,SAA0B;IAOtC,EAAE,EAAG,MAAM,CAAC;IAGZ,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IAEH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;;;;;;OAUG;IAEH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE3B;;OAEG;IAEH,SAAS,EAAE,MAAM,CAAC;IAGlB,OAAO,SAAK;IAEZ;;OAEG;IAEH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;;;;;OAMG;IAEH,cAAc,UAAS;IAGvB,IAAI,SAAM;IAGV,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAGjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IAGnC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAQ;IAY/B,SAAS,EAAE,IAAI,CAAC;IAUhB,SAAS,EAAE,IAAI,CAAC;IAEhB,IAAI,eAAe,IAAI,MAAM,EAAE,GAAG,SAAS,CAU1C;WAEY,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;WAIzD,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CAMhG"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { column } from '@simonbackx/simple-database';
|
|
3
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
/**
|
|
6
|
+
* A single passkey / WebAuthn credential enrolled by a user. A user may have multiple.
|
|
7
|
+
* `credentialId` is unique and indexed so credentials can be looked up directly (needed
|
|
8
|
+
* for future usernameless/passwordless login).
|
|
9
|
+
*/
|
|
10
|
+
export class WebauthnCredential extends QueryableModel {
|
|
11
|
+
static table = 'webauthn_credentials';
|
|
12
|
+
id;
|
|
13
|
+
userId;
|
|
14
|
+
/**
|
|
15
|
+
* Base64url-encoded credential id, as returned by the authenticator.
|
|
16
|
+
*/
|
|
17
|
+
credentialId;
|
|
18
|
+
/**
|
|
19
|
+
* The Relying Party ID this credential was created for.
|
|
20
|
+
*
|
|
21
|
+
* A passkey is bound to one domain: the authenticator will not release it to any other
|
|
22
|
+
* one, and verification has to check it against the RP ID it was made for. Storing it
|
|
23
|
+
* per credential is what keeps existing passkeys valid if the platform ever serves more
|
|
24
|
+
* than one authentication domain, or moves to a different one.
|
|
25
|
+
*
|
|
26
|
+
* NULL for credentials created before this was stored: those all used the platform RP
|
|
27
|
+
* ID, which the helper falls back to.
|
|
28
|
+
*/
|
|
29
|
+
rpId = null;
|
|
30
|
+
/**
|
|
31
|
+
* Base64url-encoded COSE public key.
|
|
32
|
+
*/
|
|
33
|
+
publicKey;
|
|
34
|
+
counter = 0;
|
|
35
|
+
/**
|
|
36
|
+
* JSON-encoded array of AuthenticatorTransport values (or null).
|
|
37
|
+
*/
|
|
38
|
+
transports = null;
|
|
39
|
+
/**
|
|
40
|
+
* The WebAuthn backup state (BS) flag: whether this credential is currently backed up.
|
|
41
|
+
*/
|
|
42
|
+
backedUp = false;
|
|
43
|
+
/**
|
|
44
|
+
* The WebAuthn backup eligibility (BE) flag: whether this credential may ever be backed
|
|
45
|
+
* up (a synced passkey) or is bound to one device.
|
|
46
|
+
*
|
|
47
|
+
* Stored next to `backedUp` because it cannot be derived from it, and a different
|
|
48
|
+
* library would expect both halves of the pair.
|
|
49
|
+
*/
|
|
50
|
+
backupEligible = false;
|
|
51
|
+
name = '';
|
|
52
|
+
providerId = null;
|
|
53
|
+
providerName = null;
|
|
54
|
+
lastUsedAt = null;
|
|
55
|
+
createdAt;
|
|
56
|
+
updatedAt;
|
|
57
|
+
get transportsArray() {
|
|
58
|
+
if (!this.transports) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const parsed = JSON.parse(this.transports);
|
|
63
|
+
return Array.isArray(parsed) ? parsed : undefined;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static async getForUser(userId) {
|
|
70
|
+
return await this.select().where('userId', userId).fetch();
|
|
71
|
+
}
|
|
72
|
+
static async getByCredentialId(credentialId) {
|
|
73
|
+
if (!credentialId) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return (await this.select().where('credentialId', credentialId).first(false)) ?? undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
__decorate([
|
|
80
|
+
column({
|
|
81
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
82
|
+
return value ?? uuidv4();
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
], WebauthnCredential.prototype, "id", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
column({ type: 'string' })
|
|
88
|
+
], WebauthnCredential.prototype, "userId", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
column({ type: 'string' })
|
|
91
|
+
], WebauthnCredential.prototype, "credentialId", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
column({ type: 'string', nullable: true })
|
|
94
|
+
], WebauthnCredential.prototype, "rpId", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
column({ type: 'string' })
|
|
97
|
+
], WebauthnCredential.prototype, "publicKey", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
column({ type: 'integer' })
|
|
100
|
+
], WebauthnCredential.prototype, "counter", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
column({ type: 'string', nullable: true })
|
|
103
|
+
], WebauthnCredential.prototype, "transports", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
column({ type: 'boolean' })
|
|
106
|
+
], WebauthnCredential.prototype, "backedUp", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
column({ type: 'boolean' })
|
|
109
|
+
], WebauthnCredential.prototype, "backupEligible", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
column({ type: 'string' })
|
|
112
|
+
], WebauthnCredential.prototype, "name", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
column({ type: 'string', nullable: true })
|
|
115
|
+
], WebauthnCredential.prototype, "providerId", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
column({ type: 'string', nullable: true })
|
|
118
|
+
], WebauthnCredential.prototype, "providerName", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
column({ type: 'datetime', nullable: true })
|
|
121
|
+
], WebauthnCredential.prototype, "lastUsedAt", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
column({
|
|
124
|
+
type: 'datetime', beforeSave(old) {
|
|
125
|
+
if (old !== undefined) {
|
|
126
|
+
return old;
|
|
127
|
+
}
|
|
128
|
+
const date = new Date();
|
|
129
|
+
date.setMilliseconds(0);
|
|
130
|
+
return date;
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
], WebauthnCredential.prototype, "createdAt", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
column({
|
|
136
|
+
type: 'datetime', beforeSave() {
|
|
137
|
+
const date = new Date();
|
|
138
|
+
date.setMilliseconds(0);
|
|
139
|
+
return date;
|
|
140
|
+
},
|
|
141
|
+
skipUpdate: true,
|
|
142
|
+
})
|
|
143
|
+
], WebauthnCredential.prototype, "updatedAt", void 0);
|
|
144
|
+
//# sourceMappingURL=WebauthnCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebauthnCredential.js","sourceRoot":"","sources":["../../src/models/WebauthnCredential.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAClD,MAAM,CAAC,KAAK,GAAG,sBAAsB,CAAC;IAOtC,EAAE,CAAU;IAGZ,MAAM,CAAS;IAEf;;OAEG;IAEH,YAAY,CAAS;IAErB;;;;;;;;;;OAUG;IAEH,IAAI,GAAkB,IAAI,CAAC;IAE3B;;OAEG;IAEH,SAAS,CAAS;IAGlB,OAAO,GAAG,CAAC,CAAC;IAEZ;;OAEG;IAEH,UAAU,GAAkB,IAAI,CAAC;IAEjC;;OAEG;IAEH,QAAQ,GAAG,KAAK,CAAC;IAEjB;;;;;;OAMG;IAEH,cAAc,GAAG,KAAK,CAAC;IAGvB,IAAI,GAAG,EAAE,CAAC;IAGV,UAAU,GAAkB,IAAI,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xB,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,UAAU,EAAE,IAAI;KACnB,CAAC;qDACc"}
|
package/dist/models/index.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export { Payment } from './Payment.js';
|
|
|
5
5
|
export { Registration } from './Registration.js';
|
|
6
6
|
export { User } from './User.js';
|
|
7
7
|
export * from './EmailVerificationCode.js';
|
|
8
|
+
export * from './MFAToken.js';
|
|
9
|
+
export * from './MFATOTP.js';
|
|
10
|
+
export * from './MFARecoveryCode.js';
|
|
11
|
+
export * from './WebauthnCredential.js';
|
|
12
|
+
export * from './WebauthnChallenge.js';
|
|
8
13
|
export { BalanceItem } from './BalanceItem.js';
|
|
9
14
|
export { BalanceItemPayment } from './BalanceItemPayment.js';
|
|
10
15
|
export * from './BuckarooPayment.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,cAAc,4BAA4B,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;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cAAc,uBAAuB,CAAC;AAEtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AAEtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AAExC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,2BAA2B,CAAC;AAE1C,OAAO,iBAAiB,CAAC"}
|
package/dist/models/index.js
CHANGED
|
@@ -5,6 +5,11 @@ export { Payment } from './Payment.js';
|
|
|
5
5
|
export { Registration } from './Registration.js';
|
|
6
6
|
export { User } from './User.js';
|
|
7
7
|
export * from './EmailVerificationCode.js';
|
|
8
|
+
export * from './MFAToken.js';
|
|
9
|
+
export * from './MFATOTP.js';
|
|
10
|
+
export * from './MFARecoveryCode.js';
|
|
11
|
+
export * from './WebauthnCredential.js';
|
|
12
|
+
export * from './WebauthnChallenge.js';
|
|
8
13
|
export { BalanceItem } from './BalanceItem.js';
|
|
9
14
|
export { BalanceItemPayment } from './BalanceItemPayment.js';
|
|
10
15
|
export * from './BuckarooPayment.js';
|
package/dist/models/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cA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package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stamhoofd/models",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.138.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@simonbackx/simple-database": "1.37.1",
|
|
48
|
-
"@stamhoofd/test-utils": "2.
|
|
48
|
+
"@stamhoofd/test-utils": "2.138.0",
|
|
49
49
|
"@types/luxon": "3.7.2",
|
|
50
50
|
"@types/uuid": "8.3.4",
|
|
51
51
|
"vitest": "4.1.10"
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "781877acb024516e384b4119af7e86f847a9d237"
|
|
68
68
|
}
|
|
@@ -54,7 +54,7 @@ Handlebars.registerHelper('formatPrice', (a, options) => {
|
|
|
54
54
|
if (typeof a !== 'number') return a;
|
|
55
55
|
// round=true rounds to nearest cent (100 units = 1 cent, where 10000 units = €1)
|
|
56
56
|
const value = options?.hash?.round ? Math.round(a / 100) * 100 : a;
|
|
57
|
-
return Formatter.price(value);
|
|
57
|
+
return Formatter.price(value, { maximumFractionDigits: 4 });
|
|
58
58
|
});
|
|
59
59
|
Handlebars.registerHelper('formatDate', (a, options) => {
|
|
60
60
|
if (!(a instanceof Date)) {
|
|
@@ -202,8 +202,7 @@ AsyncResolver.registerAsyncHelper(Handlebars, 'src', async (a, options) => {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
return resolution.file.getPublicPath();
|
|
205
|
-
}
|
|
206
|
-
catch (e) {
|
|
205
|
+
} catch (e) {
|
|
207
206
|
console.error('src helper:', e);
|
|
208
207
|
return '';
|
|
209
208
|
}
|
|
@@ -226,8 +225,7 @@ Handlebars.registerHelper('src-width', (a, options) => {
|
|
|
226
225
|
const image = Image.decode(new ObjectData(a, { version: 0 }));
|
|
227
226
|
const resolution = image.getResolutionForSize(width as number | undefined, height as number | undefined);
|
|
228
227
|
return resolution.width;
|
|
229
|
-
}
|
|
230
|
-
catch (e) {
|
|
228
|
+
} catch (e) {
|
|
231
229
|
console.error('src-width helper:', e);
|
|
232
230
|
return 0;
|
|
233
231
|
}
|
|
@@ -250,8 +248,7 @@ Handlebars.registerHelper('src-height', (a, options) => {
|
|
|
250
248
|
const image = Image.decode(new ObjectData(a, { version: 0 }));
|
|
251
249
|
const resolution = image.getResolutionForSize(width as number | undefined, height as number | undefined);
|
|
252
250
|
return resolution.height;
|
|
253
|
-
}
|
|
254
|
-
catch (e) {
|
|
251
|
+
} catch (e) {
|
|
255
252
|
console.error('src-height helper:', e);
|
|
256
253
|
return 0;
|
|
257
254
|
}
|
|
@@ -280,8 +277,7 @@ export async function render(htmlTemplate: string, context: any): Promise<string
|
|
|
280
277
|
const renderedHtml = template({ ...context, asyncResolver: resolver });
|
|
281
278
|
const html = await resolver.replace(renderedHtml);
|
|
282
279
|
return html;
|
|
283
|
-
}
|
|
284
|
-
catch (e) {
|
|
280
|
+
} catch (e) {
|
|
285
281
|
console.error('Failed to render document html', e);
|
|
286
282
|
return null;
|
|
287
283
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isSimpleError, isSimpleErrors, SimpleError, SimpleErrors } from '@simonbackx/simple-errors';
|
|
2
|
+
|
|
3
|
+
export function errorToSimpleErrors(e: unknown) {
|
|
4
|
+
if (isSimpleErrors(e)) {
|
|
5
|
+
return e;
|
|
6
|
+
} else if (isSimpleError(e)) {
|
|
7
|
+
return new SimpleErrors(e);
|
|
8
|
+
} else {
|
|
9
|
+
return new SimpleErrors(
|
|
10
|
+
new SimpleError({
|
|
11
|
+
code: 'unknown_error',
|
|
12
|
+
message: ((typeof e === 'object' && e !== null && 'message' in e && typeof e.message === 'string') ? e.message : 'Unknown error'),
|
|
13
|
+
human: $t(`%1ED`),
|
|
14
|
+
}),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE `mfa_totp` (
|
|
2
|
+
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
3
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`name` varchar(255) NOT NULL DEFAULT '',
|
|
5
|
+
`secret` text NOT NULL,
|
|
6
|
+
`confirmedAt` datetime NULL DEFAULT NULL,
|
|
7
|
+
`lastUsedAt` datetime NULL DEFAULT NULL,
|
|
8
|
+
`createdAt` datetime NOT NULL,
|
|
9
|
+
`updatedAt` datetime NOT NULL,
|
|
10
|
+
PRIMARY KEY (`id`),
|
|
11
|
+
KEY `idx_userId` (`userId`) USING BTREE,
|
|
12
|
+
CONSTRAINT `mfa_totp_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
13
|
+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE `webauthn_credentials` (
|
|
2
|
+
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
3
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`credentialId` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
5
|
+
`publicKey` text NOT NULL,
|
|
6
|
+
`counter` int unsigned NOT NULL DEFAULT '0',
|
|
7
|
+
`transports` text NULL DEFAULT NULL,
|
|
8
|
+
`backedUp` tinyint(1) NOT NULL DEFAULT '0',
|
|
9
|
+
`name` varchar(255) NOT NULL DEFAULT '',
|
|
10
|
+
`lastUsedAt` datetime NULL DEFAULT NULL,
|
|
11
|
+
`createdAt` datetime NOT NULL,
|
|
12
|
+
`updatedAt` datetime NOT NULL,
|
|
13
|
+
PRIMARY KEY (`id`),
|
|
14
|
+
UNIQUE KEY `uk_credentialId` (`credentialId`),
|
|
15
|
+
KEY `idx_userId` (`userId`) USING BTREE,
|
|
16
|
+
CONSTRAINT `webauthn_credentials_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
17
|
+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
CREATE TABLE `mfa_recovery_codes` (
|
|
2
|
+
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
3
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`codeHash` varchar(255) NOT NULL,
|
|
5
|
+
`usedAt` datetime NULL DEFAULT NULL,
|
|
6
|
+
`createdAt` datetime NOT NULL,
|
|
7
|
+
PRIMARY KEY (`id`),
|
|
8
|
+
KEY `idx_userId` (`userId`) USING BTREE,
|
|
9
|
+
CONSTRAINT `mfa_recovery_codes_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
10
|
+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE `mfa_tokens` (
|
|
2
|
+
`token` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
3
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`purpose` varchar(32) NOT NULL,
|
|
5
|
+
`tries` int NOT NULL DEFAULT '0',
|
|
6
|
+
`webauthnChallenge` text NULL DEFAULT NULL,
|
|
7
|
+
`expiresAt` datetime NOT NULL,
|
|
8
|
+
`createdAt` datetime NOT NULL,
|
|
9
|
+
`updatedAt` datetime NOT NULL,
|
|
10
|
+
PRIMARY KEY (`token`),
|
|
11
|
+
KEY `idx_userId` (`userId`) USING BTREE,
|
|
12
|
+
CONSTRAINT `mfa_tokens_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
13
|
+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
CREATE TABLE `webauthn_challenges` (
|
|
2
|
+
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
3
|
+
`userId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
|
4
|
+
`challenge` varchar(512) NOT NULL,
|
|
5
|
+
`expiresAt` datetime NOT NULL,
|
|
6
|
+
`createdAt` datetime NOT NULL,
|
|
7
|
+
PRIMARY KEY (`id`),
|
|
8
|
+
KEY `idx_userId` (`userId`) USING BTREE,
|
|
9
|
+
CONSTRAINT `webauthn_challenges_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
|
10
|
+
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- The Relying Party ID a passkey was created for. A passkey only works on that domain, so
|
|
2
|
+
-- it has to be verified against the domain it was registered on, not against whatever the
|
|
3
|
+
-- dashboard domain happens to be later on.
|
|
4
|
+
--
|
|
5
|
+
-- Left NULL for rows that were created before this column existed: those were all made
|
|
6
|
+
-- against the platform RP ID, which the code falls back to (see WebauthnHelper).
|
|
7
|
+
ALTER TABLE `webauthn_credentials`
|
|
8
|
+
ADD COLUMN `rpId` varchar(255) NULL AFTER `credentialId`,
|
|
9
|
+
ADD COLUMN `backupEligible` tinyint(1) NOT NULL DEFAULT '0' AFTER `backedUp`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD COLUMN `parentTenantId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL AFTER `id`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD COLUMN `feesTenantId` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL AFTER `parentTenantId`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD COLUMN `uri` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL AFTER `feesTenantId`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD COLUMN `domain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL AFTER `uri`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD UNIQUE KEY `uri` (`uri`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD UNIQUE KEY `domain` (`domain`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `platform` ADD KEY `parentTenantId` (`parentTenantId`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Database, Migration } from '@simonbackx/simple-database';
|
|
2
|
+
|
|
3
|
+
export default new Migration(async () => {
|
|
4
|
+
// A tenant charges its own fees until it is explicitly made a child of another one.
|
|
5
|
+
await Database.update('UPDATE `platform` SET `feesTenantId` = `id` WHERE `feesTenantId` IS NULL');
|
|
6
|
+
|
|
7
|
+
// Deployments run one platform row today, so both values come from the deployment environment.
|
|
8
|
+
// If a second row ever exists here, the unique indexes turn this into a hard error rather than
|
|
9
|
+
// silently giving two tenants the same host.
|
|
10
|
+
await Database.update(
|
|
11
|
+
'UPDATE `platform` SET `uri` = COALESCE(`uri`, ?), `domain` = COALESCE(`domain`, ?)',
|
|
12
|
+
[STAMHOOFD.platformName, STAMHOOFD.domains.dashboard ?? null],
|
|
13
|
+
);
|
|
14
|
+
});
|