@stamhoofd/models 2.137.5 → 2.138.1
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,80 @@
|
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel, SQLWhereSign } from '@stamhoofd/sql';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A short-lived, single-use WebAuthn registration challenge for a logged-in user, kept
|
|
7
|
+
* server-side so the registration response can be verified against it.
|
|
8
|
+
*/
|
|
9
|
+
export class WebauthnChallenge extends QueryableModel {
|
|
10
|
+
static table = 'webauthn_challenges';
|
|
11
|
+
static EXPIRY_MS = 10 * 60 * 1000;
|
|
12
|
+
|
|
13
|
+
@column({
|
|
14
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
15
|
+
return value ?? uuidv4();
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
id!: string;
|
|
19
|
+
|
|
20
|
+
@column({ type: 'string' })
|
|
21
|
+
userId: string;
|
|
22
|
+
|
|
23
|
+
@column({ type: 'string' })
|
|
24
|
+
challenge: string;
|
|
25
|
+
|
|
26
|
+
@column({ type: 'datetime' })
|
|
27
|
+
expiresAt: Date;
|
|
28
|
+
|
|
29
|
+
@column({
|
|
30
|
+
type: 'datetime', beforeSave(old?: any) {
|
|
31
|
+
if (old !== undefined) {
|
|
32
|
+
return old;
|
|
33
|
+
}
|
|
34
|
+
const date = new Date();
|
|
35
|
+
date.setMilliseconds(0);
|
|
36
|
+
return date;
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
|
|
41
|
+
static async createFor(userId: string, challenge: string): Promise<WebauthnChallenge> {
|
|
42
|
+
// Only keep one pending registration challenge per user
|
|
43
|
+
await this.delete().where('userId', userId);
|
|
44
|
+
|
|
45
|
+
const model = new WebauthnChallenge();
|
|
46
|
+
model.userId = userId;
|
|
47
|
+
model.challenge = challenge;
|
|
48
|
+
model.expiresAt = new Date(Date.now() + WebauthnChallenge.EXPIRY_MS);
|
|
49
|
+
await model.save();
|
|
50
|
+
return model;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
isExpired(): boolean {
|
|
54
|
+
return this.expiresAt < new Date();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Remove every expired challenge. A registration that was started and then abandoned
|
|
59
|
+
* leaves a row behind that nothing else cleans up.
|
|
60
|
+
*/
|
|
61
|
+
static async deleteExpired(): Promise<number> {
|
|
62
|
+
const { affectedRows } = await this.delete().where('expiresAt', SQLWhereSign.Less, new Date()).delete();
|
|
63
|
+
return affectedRows;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Consume the latest pending challenge for a user. Returns the challenge string, or
|
|
68
|
+
* undefined if none valid. Always deletes the row.
|
|
69
|
+
*/
|
|
70
|
+
static async consumeForUser(userId: string): Promise<string | undefined> {
|
|
71
|
+
const model = await this.select().where('userId', userId).first(false);
|
|
72
|
+
if (!model) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const challenge = model.challenge;
|
|
76
|
+
const expired = model.isExpired();
|
|
77
|
+
await model.delete();
|
|
78
|
+
return expired ? undefined : challenge;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { column } from '@simonbackx/simple-database';
|
|
2
|
+
import { QueryableModel } from '@stamhoofd/sql';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
|
|
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
|
+
|
|
13
|
+
@column({
|
|
14
|
+
primary: true, type: 'string', beforeSave(value) {
|
|
15
|
+
return value ?? uuidv4();
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
id!: string;
|
|
19
|
+
|
|
20
|
+
@column({ type: 'string' })
|
|
21
|
+
userId: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base64url-encoded credential id, as returned by the authenticator.
|
|
25
|
+
*/
|
|
26
|
+
@column({ type: 'string' })
|
|
27
|
+
credentialId: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The Relying Party ID this credential was created for.
|
|
31
|
+
*
|
|
32
|
+
* A passkey is bound to one domain: the authenticator will not release it to any other
|
|
33
|
+
* one, and verification has to check it against the RP ID it was made for. Storing it
|
|
34
|
+
* per credential is what keeps existing passkeys valid if the platform ever serves more
|
|
35
|
+
* than one authentication domain, or moves to a different one.
|
|
36
|
+
*
|
|
37
|
+
* NULL for credentials created before this was stored: those all used the platform RP
|
|
38
|
+
* ID, which the helper falls back to.
|
|
39
|
+
*/
|
|
40
|
+
@column({ type: 'string', nullable: true })
|
|
41
|
+
rpId: string | null = null;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Base64url-encoded COSE public key.
|
|
45
|
+
*/
|
|
46
|
+
@column({ type: 'string' })
|
|
47
|
+
publicKey: string;
|
|
48
|
+
|
|
49
|
+
@column({ type: 'integer' })
|
|
50
|
+
counter = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* JSON-encoded array of AuthenticatorTransport values (or null).
|
|
54
|
+
*/
|
|
55
|
+
@column({ type: 'string', nullable: true })
|
|
56
|
+
transports: string | null = null;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The WebAuthn backup state (BS) flag: whether this credential is currently backed up.
|
|
60
|
+
*/
|
|
61
|
+
@column({ type: 'boolean' })
|
|
62
|
+
backedUp = false;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The WebAuthn backup eligibility (BE) flag: whether this credential may ever be backed
|
|
66
|
+
* up (a synced passkey) or is bound to one device.
|
|
67
|
+
*
|
|
68
|
+
* Stored next to `backedUp` because it cannot be derived from it, and a different
|
|
69
|
+
* library would expect both halves of the pair.
|
|
70
|
+
*/
|
|
71
|
+
@column({ type: 'boolean' })
|
|
72
|
+
backupEligible = false;
|
|
73
|
+
|
|
74
|
+
@column({ type: 'string' })
|
|
75
|
+
name = '';
|
|
76
|
+
|
|
77
|
+
@column({ type: 'string', nullable: true })
|
|
78
|
+
providerId: string | null = null;
|
|
79
|
+
|
|
80
|
+
@column({ type: 'string', nullable: true })
|
|
81
|
+
providerName: string | null = null;
|
|
82
|
+
|
|
83
|
+
@column({ type: 'datetime', nullable: true })
|
|
84
|
+
lastUsedAt: Date | null = null;
|
|
85
|
+
|
|
86
|
+
@column({
|
|
87
|
+
type: 'datetime', beforeSave(old?: any) {
|
|
88
|
+
if (old !== undefined) {
|
|
89
|
+
return old;
|
|
90
|
+
}
|
|
91
|
+
const date = new Date();
|
|
92
|
+
date.setMilliseconds(0);
|
|
93
|
+
return date;
|
|
94
|
+
},
|
|
95
|
+
})
|
|
96
|
+
createdAt: Date;
|
|
97
|
+
|
|
98
|
+
@column({
|
|
99
|
+
type: 'datetime', beforeSave() {
|
|
100
|
+
const date = new Date();
|
|
101
|
+
date.setMilliseconds(0);
|
|
102
|
+
return date;
|
|
103
|
+
},
|
|
104
|
+
skipUpdate: true,
|
|
105
|
+
})
|
|
106
|
+
updatedAt: Date;
|
|
107
|
+
|
|
108
|
+
get transportsArray(): string[] | undefined {
|
|
109
|
+
if (!this.transports) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const parsed = JSON.parse(this.transports);
|
|
114
|
+
return Array.isArray(parsed) ? parsed : undefined;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static async getForUser(userId: string): Promise<WebauthnCredential[]> {
|
|
121
|
+
return await this.select().where('userId', userId).fetch();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static async getByCredentialId(credentialId: string): Promise<WebauthnCredential | undefined> {
|
|
125
|
+
if (!credentialId) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return (await this.select().where('credentialId', credentialId).first(false)) ?? undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/models/index.ts
CHANGED
|
@@ -7,6 +7,12 @@ export { User } from './User.js';
|
|
|
7
7
|
|
|
8
8
|
export * from './EmailVerificationCode.js';
|
|
9
9
|
|
|
10
|
+
export * from './MFAToken.js';
|
|
11
|
+
export * from './MFATOTP.js';
|
|
12
|
+
export * from './MFARecoveryCode.js';
|
|
13
|
+
export * from './WebauthnCredential.js';
|
|
14
|
+
export * from './WebauthnChallenge.js';
|
|
15
|
+
|
|
10
16
|
export { BalanceItem } from './BalanceItem.js';
|
|
11
17
|
export { BalanceItemPayment } from './BalanceItemPayment.js';
|
|
12
18
|
export * from './BuckarooPayment.js';
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { EmailBuilder, EmailInterfaceRecipient } from '@stamhoofd/email';
|
|
2
|
-
import type { EmailContent, EmailRecipient as EmailRecipientStruct, EmailTemplateType, Platform as PlatformStruct, Recipient } from '@stamhoofd/structures';
|
|
3
|
-
import { Replacement } from '@stamhoofd/structures';
|
|
4
|
-
import type { Language } from '@stamhoofd/types/Language';
|
|
5
|
-
import { I18n } from '@stamhoofd/backend-i18n/I18n';
|
|
6
|
-
import { EmailRecipient } from '../models/EmailRecipient.js';
|
|
7
|
-
import { EmailTemplate } from '../models/EmailTemplate.js';
|
|
8
|
-
import type { Group } from '../models/Group.js';
|
|
9
|
-
import type { Organization } from '../models/Organization.js';
|
|
10
|
-
import type { Webshop } from '../models/Webshop.js';
|
|
11
|
-
export type EmailTemplateOptions = {
|
|
12
|
-
type: EmailTemplateType;
|
|
13
|
-
webshop?: Webshop | null;
|
|
14
|
-
group?: Group | null;
|
|
15
|
-
organizationId?: string | null;
|
|
16
|
-
};
|
|
17
|
-
export declare function getEmailTemplate(data: EmailTemplateOptions): Promise<EmailTemplate | undefined>;
|
|
18
|
-
export declare function canSendFromEmail(fromAddress: string, organization: Organization | null): Promise<boolean>;
|
|
19
|
-
export declare function getDefaultEmailFrom(organization: Organization | null, options: Pick<EmailBuilderOptions, 'type'> & {
|
|
20
|
-
template: Omit<EmailTemplateOptions, 'organizationId' | 'type'>;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
from: EmailInterfaceRecipient;
|
|
23
|
-
replyTo: EmailInterfaceRecipient | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
export declare function sendEmailTemplate(organization: Organization | null, options: Omit<EmailBuilderOptions, 'subject' | 'html' | 'from' | 'replyTo'> & {
|
|
26
|
-
template: Omit<EmailTemplateOptions, 'organizationId'>;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
export type EmailBuilderOptions = {
|
|
29
|
-
defaultReplacements?: Replacement[];
|
|
30
|
-
recipients: Recipient[];
|
|
31
|
-
from: EmailInterfaceRecipient;
|
|
32
|
-
replyTo?: EmailInterfaceRecipient | null;
|
|
33
|
-
subject: string;
|
|
34
|
-
html: string;
|
|
35
|
-
/**
|
|
36
|
-
* Full content overrides per language. Recipients with a language that has an override
|
|
37
|
-
* receive that content, all others receive the default subject/html.
|
|
38
|
-
*/
|
|
39
|
-
translations?: Map<Language, EmailContent>;
|
|
40
|
-
attachments?: {
|
|
41
|
-
filename: string;
|
|
42
|
-
path?: string;
|
|
43
|
-
href?: string;
|
|
44
|
-
content?: string | Buffer;
|
|
45
|
-
contentType?: string;
|
|
46
|
-
encoding?: string;
|
|
47
|
-
}[];
|
|
48
|
-
type?: 'transactional' | 'broadcast';
|
|
49
|
-
unsubscribeType?: 'all' | 'marketing';
|
|
50
|
-
fromStamhoofd?: boolean;
|
|
51
|
-
singleBcc?: EmailInterfaceRecipient;
|
|
52
|
-
replaceAll?: {
|
|
53
|
-
from: string;
|
|
54
|
-
to: string;
|
|
55
|
-
}[];
|
|
56
|
-
callback?: (error: Error | null) => void;
|
|
57
|
-
headers?: Record<string, string>;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* @param organization defines replacements and unsubsribe behaviour
|
|
61
|
-
*/
|
|
62
|
-
export declare function getEmailBuilder(organization: Organization | null, email: EmailBuilderOptions): Promise<EmailBuilder>;
|
|
63
|
-
export declare function mergeReplacement(replacementA: Replacement, replacementB: Replacement): Replacement | false;
|
|
64
|
-
/**
|
|
65
|
-
* Remove duplicates
|
|
66
|
-
*/
|
|
67
|
-
export declare function cleanReplacements(replacements: Replacement[]): Replacement[];
|
|
68
|
-
export declare function removeUnusedReplacements(html: string, replacements: Replacement[]): Replacement[];
|
|
69
|
-
export declare function mergeReplacementsIfEqual(replacementsA: Replacement[], replacementsB: Replacement[]): Replacement[] | false;
|
|
70
|
-
/**
|
|
71
|
-
* Filter replacements for display in the backend.
|
|
72
|
-
* @param options.forPreview if true, it will hide sensitive information in the preview that could leak information to admin users
|
|
73
|
-
*/
|
|
74
|
-
export declare function stripSensitiveRecipientReplacements(recipient: Recipient | EmailRecipientStruct | EmailRecipient, options: {
|
|
75
|
-
organization: Organization | null;
|
|
76
|
-
willFill?: boolean;
|
|
77
|
-
}): void;
|
|
78
|
-
/**
|
|
79
|
-
* Fill and hide replacements that don't make sense for web display to the user
|
|
80
|
-
*/
|
|
81
|
-
export declare function stripRecipientReplacementsForWebDisplay(recipient: Recipient | EmailRecipientStruct | EmailRecipient, options: {
|
|
82
|
-
organization: Organization | null;
|
|
83
|
-
}): void;
|
|
84
|
-
/**
|
|
85
|
-
* Build the I18n an email should be rendered in for a specific recipient.
|
|
86
|
-
*
|
|
87
|
-
* Falls back to the current (ambient) locale when the recipient has no language set — so flows
|
|
88
|
-
* that already established a locale (order emails wrapped in I18n.runWithLocale, or the request
|
|
89
|
-
* locale) keep working unchanged.
|
|
90
|
-
*/
|
|
91
|
-
export declare function getRecipientI18n(recipient: {
|
|
92
|
-
language?: Language | null;
|
|
93
|
-
}, organization: Organization | null, options?: {
|
|
94
|
-
allowedLanguages?: Language[] | null;
|
|
95
|
-
}): I18n;
|
|
96
|
-
/**
|
|
97
|
-
* Render everything inside `handler` in the recipient's language: all $t / $getLanguage /
|
|
98
|
-
* $getCountry calls (and therefore every generated replacement) use the recipient's locale.
|
|
99
|
-
*
|
|
100
|
-
* This is the single place that binds "a recipient" to "its language" when generating email
|
|
101
|
-
* content. Generate recipient replacements inside this wrapper so new replacements are localized
|
|
102
|
-
* automatically, and pass the provided i18n to helpers that take an explicit locale (e.g. getAppHost).
|
|
103
|
-
*/
|
|
104
|
-
export declare function runWithRecipientLocale<T>(recipient: {
|
|
105
|
-
language?: Language | null;
|
|
106
|
-
}, organization: Organization | null, handler: (i18n: I18n) => T, options?: {
|
|
107
|
-
allowedLanguages?: Language[] | null;
|
|
108
|
-
}): T;
|
|
109
|
-
/**
|
|
110
|
-
* @param options.forPreview if true, it will hide sensitive information in the preview that could leak information to admin users
|
|
111
|
-
*/
|
|
112
|
-
export declare function fillRecipientReplacements(recipient: Recipient | EmailRecipientStruct | EmailRecipient, options: {
|
|
113
|
-
organization: Organization | null;
|
|
114
|
-
platform?: PlatformStruct;
|
|
115
|
-
from: EmailInterfaceRecipient | null;
|
|
116
|
-
replyTo: EmailInterfaceRecipient | null;
|
|
117
|
-
forPreview?: boolean;
|
|
118
|
-
forceRefresh?: boolean;
|
|
119
|
-
allowedLanguages?: Language[] | null;
|
|
120
|
-
}): Promise<void>;
|
|
121
|
-
//# sourceMappingURL=EmailBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EmailBuilder.d.ts","sourceRoot":"","sources":["../../src/helpers/EmailBuilder.ts"],"names":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