Skip to content

Commit eba0933

Browse files
committed
Merge branch 'main' into release/openid4vc
2 parents af1e523 + 6d88c1f commit eba0933

21 files changed

Lines changed: 541 additions & 45 deletions

File tree

package-lock.json

Lines changed: 20 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"madge": "^8.0.0",
4444
"npm-check-updates": "^19.1.2",
4545
"patch-package": "^8.0.1",
46-
"prettier": "^3.6.2",
47-
"ts-jest": "^29.4.5",
46+
"prettier": "^3.7.3",
47+
"ts-jest": "^29.4.6",
4848
"ts-node": "^10.9.2",
4949
"tsconfig-paths": "^4.2.0",
5050
"typescript": "^5.9.3"

packages/app-runtime/test/modules/MessageEventing.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ describe("MessageEventingTest", function () {
3131
"@type": "Mail",
3232
to: [recipient],
3333
subject: "aSubject",
34-
body: "aBody"
34+
body: "aBody",
35+
bodyFormat: "PlainText"
3536
};
3637
const message = await TestUtil.sendMessage(sessionA, sessionB, mail);
3738
const eventListener = new EventListener(runtime, [MailReceivedEvent, MessageReceivedEvent]);

packages/consumption/src/modules/requests/itemProcessors/AbstractRequestItemProcessor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export abstract class AbstractRequestItemProcessor<
1212
TRequestItem extends RequestItem = RequestItem,
1313
TAcceptParams extends AcceptRequestItemParametersJSON = AcceptRequestItemParametersJSON,
1414
TRejectParams extends RejectRequestItemParametersJSON = RejectRequestItemParametersJSON
15-
> implements IRequestItemProcessor<TRequestItem, TAcceptParams, TRejectParams>
16-
{
15+
> implements IRequestItemProcessor<TRequestItem, TAcceptParams, TRejectParams> {
1716
protected accountController: AccountController;
1817
protected currentIdentityAddress: CoreAddress;
1918

packages/content/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@js-soft/ts-serval": "2.0.14",
5555
"@nmshd/core-types": "*",
5656
"@nmshd/iql": "^1.0.4",
57+
"ibantools": "^4.5.1",
5758
"luxon": "^3.7.2",
5859
"ts-simple-nameof": "^1.3.3"
5960
},

packages/content/src/attributes/AttributeValueTypes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {
22
Affiliation,
33
AffiliationJSON,
4+
BankAccount,
5+
BankAccountJSON,
46
BirthDate,
57
BirthDateJSON,
68
BirthName,
@@ -28,6 +30,7 @@ import {
2830
HonorificSuffix,
2931
HonorificSuffixJSON,
3032
IAffiliation,
33+
IBankAccount,
3134
IBirthDate,
3235
IBirthName,
3336
IBirthPlace,
@@ -128,6 +131,7 @@ export namespace AttributeValues {
128131
export namespace Editable {
129132
export type Json =
130133
| AffiliationJSON
134+
| BankAccountJSON
131135
| BirthDateJSON
132136
| BirthNameJSON
133137
| BirthPlaceJSON
@@ -155,6 +159,7 @@ export namespace AttributeValues {
155159

156160
export type Interface =
157161
| IAffiliation
162+
| IBankAccount
158163
| IBirthDate
159164
| IBirthName
160165
| IBirthPlace
@@ -182,6 +187,7 @@ export namespace AttributeValues {
182187

183188
export type Class =
184189
| Affiliation
190+
| BankAccount
185191
| BirthDate
186192
| BirthName
187193
| BirthPlace
@@ -209,6 +215,7 @@ export namespace AttributeValues {
209215

210216
export const CLASSES = [
211217
Affiliation,
218+
BankAccount,
212219
BirthDate,
213220
BirthName,
214221
BirthPlace,
@@ -237,6 +244,7 @@ export namespace AttributeValues {
237244

238245
export const TYPE_NAMES = [
239246
"Affiliation",
247+
"BankAccount",
240248
"BirthDate",
241249
"BirthName",
242250
"BirthPlace",
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { serialize, type, validate } from "@js-soft/ts-serval";
2+
import { isValidBIC, isValidIBAN } from "ibantools";
3+
import { nameof } from "ts-simple-nameof";
4+
import { AbstractComplexValue, AbstractComplexValueJSON, IAbstractComplexValue } from "../../AbstractComplexValue";
5+
import { RenderHints, RenderHintsEditType, RenderHintsTechnicalType, ValueHints } from "../../hints";
6+
7+
const MAX_ACCOUNT_HOLDER_LENGTH = 100;
8+
const MIN_IBAN_LENGTH = 14;
9+
const MAX_IBAN_LENGTH = 34;
10+
const MIN_BIC_LENGTH = 8;
11+
const MAX_BIC_LENGTH = 11;
12+
13+
export interface BankAccountJSON extends AbstractComplexValueJSON {
14+
"@type": "BankAccount";
15+
accountHolder: string;
16+
iban: string;
17+
bic?: string;
18+
}
19+
20+
export interface IBankAccount extends IAbstractComplexValue {
21+
accountHolder: string;
22+
iban: string;
23+
bic?: string;
24+
}
25+
26+
@type("BankAccount")
27+
export class BankAccount extends AbstractComplexValue implements IBankAccount {
28+
@serialize()
29+
@validate({ max: MAX_ACCOUNT_HOLDER_LENGTH })
30+
public accountHolder: string;
31+
32+
@serialize()
33+
@validate({
34+
min: MIN_IBAN_LENGTH,
35+
max: MAX_IBAN_LENGTH,
36+
customValidator: (iban) => (!isValidIBAN(iban) ? "invalid IBAN" : undefined)
37+
})
38+
public iban: string;
39+
40+
@serialize()
41+
@validate({
42+
nullable: true,
43+
min: MIN_BIC_LENGTH,
44+
max: MAX_BIC_LENGTH,
45+
customValidator: (bic) => (!isValidBIC(bic) ? "invalid BIC" : undefined)
46+
})
47+
public bic?: string;
48+
49+
public static from(value: IBankAccount | Omit<BankAccountJSON, "@type">): BankAccount {
50+
return this.fromAny(value);
51+
}
52+
53+
public static get valueHints(): ValueHints {
54+
return ValueHints.from({
55+
propertyHints: {
56+
[nameof<BankAccount>((s) => s.accountHolder)]: ValueHints.from({
57+
max: MAX_ACCOUNT_HOLDER_LENGTH
58+
}),
59+
[nameof<BankAccount>((s) => s.iban)]: ValueHints.from({
60+
min: MIN_IBAN_LENGTH,
61+
max: MAX_IBAN_LENGTH
62+
}),
63+
[nameof<BankAccount>((s) => s.bic)]: ValueHints.from({
64+
min: MIN_BIC_LENGTH,
65+
max: MAX_BIC_LENGTH
66+
})
67+
}
68+
});
69+
}
70+
71+
public static override get renderHints(): RenderHints {
72+
return super.renderHints.copyWith({
73+
propertyHints: {
74+
[nameof<BankAccount>((s) => s.accountHolder)]: RenderHints.from({
75+
editType: RenderHintsEditType.InputLike,
76+
technicalType: RenderHintsTechnicalType.String
77+
}),
78+
[nameof<BankAccount>((s) => s.iban)]: RenderHints.from({
79+
editType: RenderHintsEditType.InputLike,
80+
technicalType: RenderHintsTechnicalType.String
81+
}),
82+
[nameof<BankAccount>((s) => s.bic)]: RenderHints.from({
83+
editType: RenderHintsEditType.InputLike,
84+
technicalType: RenderHintsTechnicalType.String
85+
})
86+
}
87+
});
88+
}
89+
90+
public override toString(): string {
91+
const value: string[] = [];
92+
value.push(`${this.accountHolder}`);
93+
value.push(`${this.iban}`);
94+
if (this.bic) {
95+
value.push(this.bic.toString());
96+
}
97+
98+
return value.join("\n");
99+
}
100+
101+
public override toJSON(verbose?: boolean | undefined, serializeAsString?: boolean | undefined): BankAccountJSON {
102+
return super.toJSON(verbose, serializeAsString) as BankAccountJSON;
103+
}
104+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./BankAccount";

packages/content/src/attributes/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from "./affiliation";
77
export * from "./birth";
88
export * from "./communication";
99
export * from "./dates";
10+
export * from "./finance";
1011
export * from "./identity";
1112
export * from "./measurements";
1213
export * from "./name";

packages/content/src/messages/Mail.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft
22
import { CoreAddress, ICoreAddress } from "@nmshd/core-types";
33
import { ContentJSON } from "../ContentJSON";
44

5+
export enum MailBodyFormat {
6+
PlainText = "PlainText",
7+
Markdown = "Markdown"
8+
}
9+
510
export interface MailJSON extends ContentJSON {
611
"@type": "Mail";
712
to: string[];
813
cc?: string[];
914
subject: string;
1015
body: string;
16+
bodyFormat: `${MailBodyFormat}`;
1117
}
1218

1319
export interface IMail extends ISerializable {
1420
to: ICoreAddress[];
1521
cc?: ICoreAddress[];
1622
subject: string;
1723
body: string;
24+
bodyFormat: MailBodyFormat;
1825
}
1926

2027
@type("Mail")
@@ -35,13 +42,15 @@ export class Mail extends Serializable implements IMail {
3542
@validate({ max: 50000 })
3643
public body: string;
3744

45+
@serialize()
46+
@validate({ customValidator: (v) => (!Object.values(MailBodyFormat).includes(v) ? `must be one of: ${Object.values(MailBodyFormat)}` : undefined) })
47+
public bodyFormat: MailBodyFormat;
48+
3849
protected static override preFrom(value: any): any {
3950
value.cc ??= [];
4051

41-
if (!value.body && value.content) {
42-
value.body = value.content;
43-
delete value.content;
44-
}
52+
// @deprecated bodyFormat default
53+
value.bodyFormat ??= MailBodyFormat.PlainText;
4554

4655
return value;
4756
}

0 commit comments

Comments
 (0)