@coderoftime/fints 0.1.0 → 0.3.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/CHANGELOG.md +519 -1
- package/README.md +138 -40
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +242 -0
- package/dist/client.js.map +1 -0
- package/dist/core/account.d.ts +46 -7
- package/dist/core/account.d.ts.map +1 -1
- package/dist/core/account.js +143 -24
- package/dist/core/account.js.map +1 -1
- package/dist/core/amount.d.ts +15 -4
- package/dist/core/amount.d.ts.map +1 -1
- package/dist/core/amount.js +46 -9
- package/dist/core/amount.js.map +1 -1
- package/dist/core/balance.d.ts +4 -0
- package/dist/core/balance.d.ts.map +1 -1
- package/dist/core/balance.js +11 -5
- package/dist/core/balance.js.map +1 -1
- package/dist/core/bank-info.d.ts +21 -4
- package/dist/core/bank-info.d.ts.map +1 -1
- package/dist/core/bank-info.js +26 -5
- package/dist/core/bank-info.js.map +1 -1
- package/dist/core/client.d.ts +81 -19
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/config.d.ts +40 -20
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +85 -30
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors.d.ts +100 -26
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +136 -53
- package/dist/core/errors.js.map +1 -1
- package/dist/core/feedback.d.ts +11 -1
- package/dist/core/feedback.d.ts.map +1 -1
- package/dist/core/feedback.js +14 -2
- package/dist/core/feedback.js.map +1 -1
- package/dist/core/transaction.d.ts +11 -1
- package/dist/core/transaction.d.ts.map +1 -1
- package/dist/core/transaction.js +21 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/core/transport.d.ts +48 -6
- package/dist/core/transport.d.ts.map +1 -1
- package/dist/core/transport.js +126 -29
- package/dist/core/transport.js.map +1 -1
- package/dist/formats/camt.d.ts +28 -5
- package/dist/formats/camt.d.ts.map +1 -1
- package/dist/formats/camt.js +132 -50
- package/dist/formats/camt.js.map +1 -1
- package/dist/formats/mt940.d.ts +29 -5
- package/dist/formats/mt940.d.ts.map +1 -1
- package/dist/formats/mt940.js +209 -113
- package/dist/formats/mt940.js.map +1 -1
- package/dist/formats/readers.d.ts +6 -2
- package/dist/formats/readers.d.ts.map +1 -1
- package/dist/formats/readers.js +28 -29
- package/dist/formats/readers.js.map +1 -1
- package/dist/formats/record-budget.d.ts +7 -0
- package/dist/formats/record-budget.d.ts.map +1 -0
- package/dist/formats/record-budget.js +17 -0
- package/dist/formats/record-budget.js.map +1 -0
- package/dist/formats/sepa-purpose.d.ts +9 -0
- package/dist/formats/sepa-purpose.d.ts.map +1 -1
- package/dist/formats/sepa-purpose.js +32 -2
- package/dist/formats/sepa-purpose.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/session/app-approval.d.ts +11 -5
- package/dist/session/app-approval.d.ts.map +1 -1
- package/dist/session/app-approval.js +23 -12
- package/dist/session/app-approval.js.map +1 -1
- package/dist/session/dialog-runner.d.ts +11 -11
- package/dist/session/dialog-runner.d.ts.map +1 -1
- package/dist/session/dialog-runner.js +34 -19
- package/dist/session/dialog-runner.js.map +1 -1
- package/dist/session/login-guard.d.ts +54 -49
- package/dist/session/login-guard.d.ts.map +1 -1
- package/dist/session/login-guard.js +170 -83
- package/dist/session/login-guard.js.map +1 -1
- package/dist/session/sepa-accounts.d.ts +20 -14
- package/dist/session/sepa-accounts.d.ts.map +1 -1
- package/dist/session/sepa-accounts.js +62 -46
- package/dist/session/sepa-accounts.js.map +1 -1
- package/dist/session/session-setup.d.ts +41 -24
- package/dist/session/session-setup.d.ts.map +1 -1
- package/dist/session/session-setup.js +106 -63
- package/dist/session/session-setup.js.map +1 -1
- package/dist/session/session-state.d.ts +10 -6
- package/dist/session/session-state.d.ts.map +1 -1
- package/dist/session/session-state.js +72 -18
- package/dist/session/session-state.js.map +1 -1
- package/dist/session/signed-dialog.d.ts +83 -0
- package/dist/session/signed-dialog.d.ts.map +1 -0
- package/dist/session/signed-dialog.js +185 -0
- package/dist/session/signed-dialog.js.map +1 -0
- package/dist/session/tan-selection.d.ts +26 -18
- package/dist/session/tan-selection.d.ts.map +1 -1
- package/dist/session/tan-selection.js +44 -33
- package/dist/session/tan-selection.js.map +1 -1
- package/dist/session/user-prompts.d.ts +14 -5
- package/dist/session/user-prompts.d.ts.map +1 -1
- package/dist/session/user-prompts.js +53 -18
- package/dist/session/user-prompts.js.map +1 -1
- package/dist/tan/challenge.d.ts +47 -24
- package/dist/tan/challenge.d.ts.map +1 -1
- package/dist/tan/challenge.js +56 -51
- package/dist/tan/challenge.js.map +1 -1
- package/dist/tan/flicker.d.ts +11 -1
- package/dist/tan/flicker.d.ts.map +1 -1
- package/dist/tan/flicker.js +70 -24
- package/dist/tan/flicker.js.map +1 -1
- package/dist/tan/tan-image.d.ts +6 -2
- package/dist/tan/tan-image.d.ts.map +1 -1
- package/dist/tan/tan-image.js +14 -6
- package/dist/tan/tan-image.js.map +1 -1
- package/dist/tan/tan-models.d.ts +14 -2
- package/dist/tan/tan-models.d.ts.map +1 -1
- package/dist/tan/tan-models.js +24 -7
- package/dist/tan/tan-models.js.map +1 -1
- package/dist/util/arguments.d.ts +13 -0
- package/dist/util/arguments.d.ts.map +1 -0
- package/dist/util/arguments.js +40 -0
- package/dist/util/arguments.js.map +1 -0
- package/dist/util/async.d.ts +4 -3
- package/dist/util/async.d.ts.map +1 -1
- package/dist/util/async.js +6 -7
- package/dist/util/async.js.map +1 -1
- package/dist/util/bytes.d.ts +3 -4
- package/dist/util/bytes.d.ts.map +1 -1
- package/dist/util/bytes.js +13 -21
- package/dist/util/bytes.js.map +1 -1
- package/dist/util/call-context.d.ts.map +1 -1
- package/dist/util/call-context.js +3 -2
- package/dist/util/call-context.js.map +1 -1
- package/dist/util/dates.d.ts +6 -20
- package/dist/util/dates.d.ts.map +1 -1
- package/dist/util/dates.js +58 -28
- package/dist/util/dates.js.map +1 -1
- package/dist/util/errors.d.ts +13 -3
- package/dist/util/errors.d.ts.map +1 -1
- package/dist/util/errors.js +19 -6
- package/dist/util/errors.js.map +1 -1
- package/dist/util/immutable-map.d.ts +5 -2
- package/dist/util/immutable-map.d.ts.map +1 -1
- package/dist/util/immutable-map.js +15 -12
- package/dist/util/immutable-map.js.map +1 -1
- package/dist/util/inspect.d.ts +11 -0
- package/dist/util/inspect.d.ts.map +1 -0
- package/dist/util/inspect.js +14 -0
- package/dist/util/inspect.js.map +1 -0
- package/dist/util/json.d.ts +4 -0
- package/dist/util/json.d.ts.map +1 -1
- package/dist/util/json.js +18 -0
- package/dist/util/json.js.map +1 -1
- package/dist/util/text.d.ts +38 -5
- package/dist/util/text.d.ts.map +1 -1
- package/dist/util/text.js +90 -16
- package/dist/util/text.js.map +1 -1
- package/dist/util/xml.d.ts +9 -6
- package/dist/util/xml.d.ts.map +1 -1
- package/dist/util/xml.js +129 -56
- package/dist/util/xml.js.map +1 -1
- package/dist/v3/account-extension.d.ts.map +1 -1
- package/dist/v3/account-extension.js +7 -10
- package/dist/v3/account-extension.js.map +1 -1
- package/dist/v3/bank-connection.d.ts +54 -0
- package/dist/v3/bank-connection.d.ts.map +1 -0
- package/dist/v3/bank-connection.js +118 -0
- package/dist/v3/bank-connection.js.map +1 -0
- package/dist/v3/dialog.d.ts +84 -46
- package/dist/v3/dialog.d.ts.map +1 -1
- package/dist/v3/dialog.js +174 -60
- package/dist/v3/dialog.js.map +1 -1
- package/dist/v3/message.d.ts +32 -11
- package/dist/v3/message.d.ts.map +1 -1
- package/dist/v3/message.js +144 -83
- package/dist/v3/message.js.map +1 -1
- package/dist/v3/parameter-store.d.ts +111 -0
- package/dist/v3/parameter-store.d.ts.map +1 -0
- package/dist/v3/parameter-store.js +197 -0
- package/dist/v3/parameter-store.js.map +1 -0
- package/dist/v3/parameters.d.ts +44 -17
- package/dist/v3/parameters.d.ts.map +1 -1
- package/dist/v3/parameters.js +136 -60
- package/dist/v3/parameters.js.map +1 -1
- package/dist/v3/protocol.d.ts +50 -50
- package/dist/v3/protocol.d.ts.map +1 -1
- package/dist/v3/protocol.js +91 -210
- package/dist/v3/protocol.js.map +1 -1
- package/dist/v3/queries.d.ts +51 -0
- package/dist/v3/queries.d.ts.map +1 -0
- package/dist/v3/queries.js +128 -0
- package/dist/v3/queries.js.map +1 -0
- package/dist/v3/segments.d.ts +43 -19
- package/dist/v3/segments.d.ts.map +1 -1
- package/dist/v3/segments.js +84 -33
- package/dist/v3/segments.js.map +1 -1
- package/dist/v3/syntax.d.ts +68 -13
- package/dist/v3/syntax.d.ts.map +1 -1
- package/dist/v3/syntax.js +183 -102
- package/dist/v3/syntax.js.map +1 -1
- package/package.json +10 -6
- package/src/client.ts +293 -0
- package/src/core/account.ts +153 -24
- package/src/core/amount.ts +45 -10
- package/src/core/balance.ts +12 -5
- package/src/core/bank-info.ts +29 -5
- package/src/core/client.ts +83 -19
- package/src/core/config.ts +95 -35
- package/src/core/errors.ts +148 -54
- package/src/core/feedback.ts +16 -2
- package/src/core/transaction.ts +22 -4
- package/src/core/transport.ts +153 -32
- package/src/formats/camt.ts +153 -45
- package/src/formats/mt940.ts +244 -122
- package/src/formats/readers.ts +28 -31
- package/src/formats/record-budget.ts +18 -0
- package/src/formats/sepa-purpose.ts +29 -2
- package/src/index.ts +4 -2
- package/src/session/app-approval.ts +51 -38
- package/src/session/dialog-runner.ts +61 -31
- package/src/session/login-guard.ts +189 -87
- package/src/session/sepa-accounts.ts +63 -45
- package/src/session/session-setup.ts +105 -68
- package/src/session/session-state.ts +74 -23
- package/src/session/signed-dialog.ts +222 -0
- package/src/session/tan-selection.ts +50 -39
- package/src/session/user-prompts.ts +62 -18
- package/src/tan/challenge.ts +87 -64
- package/src/tan/flicker.ts +72 -23
- package/src/tan/tan-image.ts +15 -6
- package/src/tan/tan-models.ts +26 -7
- package/src/util/arguments.ts +40 -0
- package/src/util/async.ts +10 -9
- package/src/util/bytes.ts +14 -20
- package/src/util/call-context.ts +3 -2
- package/src/util/dates.ts +64 -33
- package/src/util/errors.ts +22 -6
- package/src/util/immutable-map.ts +15 -12
- package/src/util/inspect.ts +14 -0
- package/src/util/json.ts +16 -0
- package/src/util/text.ts +87 -15
- package/src/util/xml.ts +130 -52
- package/src/v3/account-extension.ts +7 -12
- package/src/v3/bank-connection.ts +126 -0
- package/src/v3/dialog.ts +186 -92
- package/src/v3/message.ts +140 -79
- package/src/v3/parameter-store.ts +226 -0
- package/src/v3/parameters.ts +166 -66
- package/src/v3/protocol.ts +103 -253
- package/src/v3/queries.ts +198 -0
- package/src/v3/segments.ts +86 -31
- package/src/v3/syntax.ts +172 -93
- package/dist/session/bank-connection.d.ts +0 -28
- package/dist/session/bank-connection.d.ts.map +0 -1
- package/dist/session/bank-connection.js +0 -48
- package/dist/session/bank-connection.js.map +0 -1
- package/dist/session/parameter-data.d.ts +0 -83
- package/dist/session/parameter-data.d.ts.map +0 -1
- package/dist/session/parameter-data.js +0 -68
- package/dist/session/parameter-data.js.map +0 -1
- package/dist/session/pin-tan-client.d.ts +0 -54
- package/dist/session/pin-tan-client.d.ts.map +0 -1
- package/dist/session/pin-tan-client.js +0 -153
- package/dist/session/pin-tan-client.js.map +0 -1
- package/dist/session/pin-tan-dialog.d.ts +0 -71
- package/dist/session/pin-tan-dialog.d.ts.map +0 -1
- package/dist/session/pin-tan-dialog.js +0 -124
- package/dist/session/pin-tan-dialog.js.map +0 -1
- package/dist/session/protocol.d.ts +0 -209
- package/dist/session/protocol.d.ts.map +0 -1
- package/dist/session/protocol.js +0 -75
- package/dist/session/protocol.js.map +0 -1
- package/dist/session/response-handler.d.ts +0 -48
- package/dist/session/response-handler.d.ts.map +0 -1
- package/dist/session/response-handler.js +0 -121
- package/dist/session/response-handler.js.map +0 -1
- package/dist/v3/client.d.ts +0 -24
- package/dist/v3/client.d.ts.map +0 -1
- package/dist/v3/client.js +0 -16
- package/dist/v3/client.js.map +0 -1
- package/src/session/bank-connection.ts +0 -51
- package/src/session/parameter-data.ts +0 -137
- package/src/session/pin-tan-client.ts +0 -186
- package/src/session/pin-tan-dialog.ts +0 -160
- package/src/session/protocol.ts +0 -311
- package/src/session/response-handler.ts +0 -130
- package/src/v3/client.ts +0 -29
package/dist/tan/tan-models.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { copyDate } from '../util/dates.js';
|
|
2
|
+
import { inspectCustom } from '../util/inspect.js';
|
|
1
3
|
import { maskedId } from '../util/text.js';
|
|
2
4
|
/** Reads the FinTS code: `0` not allowed, `1` optional, `2` required. */
|
|
3
5
|
export function tanMediumRequirementOf(code) {
|
|
@@ -36,7 +38,10 @@ export class TanMethod {
|
|
|
36
38
|
structuredChallenge;
|
|
37
39
|
/** Whether approval happens in a separate app instead of entering a TAN. */
|
|
38
40
|
decoupled;
|
|
39
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Most status requests the bank allows for a decoupled approval, 0 for any number. The client sends 60 where the bank
|
|
43
|
+
* states none, and polls for 10 minutes at most.
|
|
44
|
+
*/
|
|
40
45
|
decoupledMaxPolls;
|
|
41
46
|
/** How long to wait before the first status request of a decoupled approval, in seconds. */
|
|
42
47
|
decoupledFirstPollDelaySeconds;
|
|
@@ -79,6 +84,10 @@ export class TanMethod {
|
|
|
79
84
|
toString() {
|
|
80
85
|
return `TanMethod(${this.securityFunction}, ${this.name})`;
|
|
81
86
|
}
|
|
87
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
88
|
+
[inspectCustom]() {
|
|
89
|
+
return this.toString();
|
|
90
|
+
}
|
|
82
91
|
}
|
|
83
92
|
/** Reads the FinTS code `1` to `4`. */
|
|
84
93
|
export function tanMediumStatusOf(code) {
|
|
@@ -121,6 +130,7 @@ export class TanMedium {
|
|
|
121
130
|
lastUsed;
|
|
122
131
|
/** When the medium was activated. */
|
|
123
132
|
activatedOn;
|
|
133
|
+
/** Takes copies of the dates of `init`: each medium has its own, which no other one shares. */
|
|
124
134
|
constructor(init) {
|
|
125
135
|
this.mediumClass = init.mediumClass;
|
|
126
136
|
this.status = init.status;
|
|
@@ -130,19 +140,26 @@ export class TanMedium {
|
|
|
130
140
|
this.cardSequenceNumber = init.cardSequenceNumber;
|
|
131
141
|
this.mobileNumber = init.mobileNumber;
|
|
132
142
|
this.mobileNumberMasked = init.mobileNumberMasked;
|
|
133
|
-
this.validFrom = init.validFrom;
|
|
134
|
-
this.validUntil = init.validUntil;
|
|
135
|
-
this.lastUsed = init.lastUsed;
|
|
136
|
-
this.activatedOn = init.activatedOn;
|
|
143
|
+
this.validFrom = copyDate(init.validFrom);
|
|
144
|
+
this.validUntil = copyDate(init.validUntil);
|
|
145
|
+
this.lastUsed = copyDate(init.lastUsed);
|
|
146
|
+
this.activatedOn = copyDate(init.activatedOn);
|
|
137
147
|
}
|
|
138
148
|
/** Whether the medium is the one in use. */
|
|
139
149
|
get isActive() {
|
|
140
150
|
return this.status === 'active' || this.status === 'activeFollowUpCard';
|
|
141
151
|
}
|
|
142
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* The medium class, or the last digits of the card number, and the status: no name, which the user may have given the
|
|
154
|
+
* medium after themselves, such as `Max’s iPhone`, so that logs and crash reports collect neither.
|
|
155
|
+
*/
|
|
143
156
|
toString() {
|
|
144
|
-
const label = this.
|
|
157
|
+
const label = this.cardNumber === undefined ? this.mediumClass : maskedId(this.cardNumber);
|
|
145
158
|
return `TanMedium(${label}, ${this.status})`;
|
|
146
159
|
}
|
|
160
|
+
/** What Node.js's `util.inspect` and `console.log` show: `toString`, not the fields. */
|
|
161
|
+
[inspectCustom]() {
|
|
162
|
+
return this.toString();
|
|
163
|
+
}
|
|
147
164
|
}
|
|
148
165
|
//# sourceMappingURL=tan-models.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tan-models.js","sourceRoot":"","sources":["../../src/tan/tan-models.ts"],"names":[],"mappings":"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,CAAC;QAC1C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;IAED,4CAA4C;IAC5C,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,oBAAoB,CAAC;IAC1E,CAAC;IAED;;;OAGG;IACH,QAAQ;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3F,OAAO,aAAa,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC;IAC/C,CAAC;IAED,wFAAwF;IACxF,CAAC,aAAa,CAAC;QACb,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** `value`; throws `TypeError` unless it is a string. */
|
|
2
|
+
export declare function requireString(value: unknown, name: string): string;
|
|
3
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a string or neither. */
|
|
4
|
+
export declare function optionalString(value: unknown, name: string): string | undefined;
|
|
5
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is an integer or neither. */
|
|
6
|
+
export declare function optionalInteger(value: unknown, name: string): number | undefined;
|
|
7
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a boolean or neither. */
|
|
8
|
+
export declare function optionalBoolean(value: unknown, name: string): boolean | undefined;
|
|
9
|
+
/** `value`; throws `TypeError` unless it is a function. */
|
|
10
|
+
export declare function requireFunction<F>(value: F, name: string): F;
|
|
11
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a function or neither. */
|
|
12
|
+
export declare function optionalFunction<F>(value: F | null | undefined, name: string): F | undefined;
|
|
13
|
+
//# sourceMappingURL=arguments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../../src/util/arguments.ts"],"names":[],"mappings":"AAKA,yDAAyD;AACzD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlE;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/E;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIhF;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAIjF;AAED,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAG5D;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAE5F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { invalidArgument } from './errors.js';
|
|
2
|
+
// Plain JavaScript passes arguments of types the declarations rule out, which the Dart package's types refuse. These
|
|
3
|
+
// checks refuse them as well, with messages that leave out the value.
|
|
4
|
+
/** `value`; throws `TypeError` unless it is a string. */
|
|
5
|
+
export function requireString(value, name) {
|
|
6
|
+
if (typeof value !== 'string')
|
|
7
|
+
throw invalidArgument('Must be a string', name);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a string or neither. */
|
|
11
|
+
export function optionalString(value, name) {
|
|
12
|
+
return value === undefined || value === null ? undefined : requireString(value, name);
|
|
13
|
+
}
|
|
14
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is an integer or neither. */
|
|
15
|
+
export function optionalInteger(value, name) {
|
|
16
|
+
if (value === undefined || value === null)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (!Number.isInteger(value))
|
|
19
|
+
throw invalidArgument('Must be an integer', name);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a boolean or neither. */
|
|
23
|
+
export function optionalBoolean(value, name) {
|
|
24
|
+
if (value === undefined || value === null)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof value !== 'boolean')
|
|
27
|
+
throw invalidArgument('Must be a boolean', name);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
/** `value`; throws `TypeError` unless it is a function. */
|
|
31
|
+
export function requireFunction(value, name) {
|
|
32
|
+
if (typeof value !== 'function')
|
|
33
|
+
throw invalidArgument('Must be a function', name);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
/** `value`, `undefined` for `null`; throws `TypeError` unless it is a function or neither. */
|
|
37
|
+
export function optionalFunction(value, name) {
|
|
38
|
+
return value === undefined || value === null ? undefined : requireFunction(value, name);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arguments.js","sourceRoot":"","sources":["../../src/util/arguments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qHAAqH;AACrH,sEAAsE;AAEtE,yDAAyD;AACzD,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,IAAY;IACxD,IAAI,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C,CAAC,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC1F,CAAC"}
|
package/dist/util/async.d.ts
CHANGED
|
@@ -16,9 +16,10 @@ export declare class Deferred<T> {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class SerialExecutor {
|
|
18
18
|
private last;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Runs `action` once the actions submitted before have finished; the result is that of `action`, which the executor
|
|
21
|
+
* does not keep.
|
|
22
|
+
*/
|
|
20
23
|
run<T>(action: () => Promise<T>): Promise<T>;
|
|
21
24
|
}
|
|
22
|
-
/** Waits for `promise` and ignores its result, so that neither a value nor an error goes unhandled. */
|
|
23
|
-
export declare function ignoreOutcome(promise: Promise<unknown>): void;
|
|
24
25
|
//# sourceMappingURL=async.d.ts.map
|
package/dist/util/async.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/util/async.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,qBAAa,QAAQ,CAAC,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,OAAO,CAAS;;IAWxB,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAMvB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAK7B;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/util/async.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,qBAAa,QAAQ,CAAC,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,OAAO,CAAS;;IAWxB,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAMvB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAK7B;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,IAAI,CAAoC;IAEhD;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQ7C"}
|
package/dist/util/async.js
CHANGED
|
@@ -35,15 +35,14 @@ export class Deferred {
|
|
|
35
35
|
*/
|
|
36
36
|
export class SerialExecutor {
|
|
37
37
|
last = Promise.resolve();
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Runs `action` once the actions submitted before have finished; the result is that of `action`, which the executor
|
|
40
|
+
* does not keep.
|
|
41
|
+
*/
|
|
39
42
|
run(action) {
|
|
40
|
-
const result = this.last.then(action);
|
|
41
|
-
this.last = result.
|
|
43
|
+
const result = this.last.then(() => action());
|
|
44
|
+
this.last = result.then(() => undefined, () => undefined);
|
|
42
45
|
return result;
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
|
-
/** Waits for `promise` and ignores its result, so that neither a value nor an error goes unhandled. */
|
|
46
|
-
export function ignoreOutcome(promise) {
|
|
47
|
-
promise.catch(() => undefined);
|
|
48
|
-
}
|
|
49
48
|
//# sourceMappingURL=async.js.map
|
package/dist/util/async.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/util/async.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,OAAO,QAAQ;IACV,OAAO,CAAa;IACrB,SAAS,CAAsB;IAC/B,QAAQ,CAA4B;IACpC,OAAO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AAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,OAAO,CAAC,KAAQ;QACd,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACjB,IAAI,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEhD;;;OAGG;IACH,GAAG,CAAI,MAAwB;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CACrB,GAAG,EAAE,CAAC,SAAS,EACf,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
package/dist/util/bytes.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export declare function concatBytes(parts: readonly Uint8Array[]): Uint8Array;
|
|
|
3
3
|
/** Collects bytes, like a growing buffer. */
|
|
4
4
|
export declare class BytesBuilder {
|
|
5
5
|
private readonly parts;
|
|
6
|
-
private size;
|
|
7
|
-
get length(): number;
|
|
8
6
|
add(bytes: Uint8Array | readonly number[]): void;
|
|
9
7
|
addByte(byte: number): void;
|
|
10
8
|
takeBytes(): Uint8Array;
|
|
@@ -13,11 +11,12 @@ export declare class BytesBuilder {
|
|
|
13
11
|
export declare function latin1Encode(text: string): Uint8Array;
|
|
14
12
|
/** The text of ISO 8859-1 `bytes`. */
|
|
15
13
|
export declare function latin1Decode(bytes: Uint8Array): string;
|
|
14
|
+
/** The text of the UTF-16 code units `codes`. */
|
|
15
|
+
export declare function fromCharCodes(codes: Uint8Array | Uint16Array): string;
|
|
16
16
|
export declare function utf8Encode(text: string): Uint8Array;
|
|
17
|
-
/** Decodes UTF-8; throws `FormatError` for malformed data unless `allowMalformed`. */
|
|
17
|
+
/** Decodes UTF-8, without a leading BOM; throws `FormatError` for malformed data unless `allowMalformed`. */
|
|
18
18
|
export declare function utf8Decode(bytes: Uint8Array, allowMalformed?: boolean): string;
|
|
19
19
|
export declare function base64Encode(bytes: Uint8Array): string;
|
|
20
20
|
/** Decodes base64, in the standard or the URL-safe alphabet; throws `FormatError` if `text` is not base64. */
|
|
21
21
|
export declare function base64Decode(text: string): Uint8Array;
|
|
22
|
-
export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
23
22
|
//# sourceMappingURL=bytes.d.ts.map
|
package/dist/util/bytes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/util/bytes.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAUpE;AAED,6CAA6C;AAC7C,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/util/bytes.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAUpE;AAED,6CAA6C;AAC7C,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAE1C,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI;IAIhD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B,SAAS,IAAI,UAAU;CAKxB;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAIrD;AAED,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED,iDAAiD;AACjD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,CAQrE;AAMD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEnD;AAED,6GAA6G;AAC7G,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,cAAc,UAAQ,GAAG,MAAM,CAM5E;AAYD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAoBtD;AAED,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAqBrD"}
|
package/dist/util/bytes.js
CHANGED
|
@@ -15,14 +15,8 @@ export function concatBytes(parts) {
|
|
|
15
15
|
/** Collects bytes, like a growing buffer. */
|
|
16
16
|
export class BytesBuilder {
|
|
17
17
|
parts = [];
|
|
18
|
-
size = 0;
|
|
19
|
-
get length() {
|
|
20
|
-
return this.size;
|
|
21
|
-
}
|
|
22
18
|
add(bytes) {
|
|
23
|
-
|
|
24
|
-
this.parts.push(part);
|
|
25
|
-
this.size += part.length;
|
|
19
|
+
this.parts.push(bytes instanceof Uint8Array ? bytes : Uint8Array.from(bytes));
|
|
26
20
|
}
|
|
27
21
|
addByte(byte) {
|
|
28
22
|
this.add(Uint8Array.of(byte));
|
|
@@ -30,7 +24,6 @@ export class BytesBuilder {
|
|
|
30
24
|
takeBytes() {
|
|
31
25
|
const result = concatBytes(this.parts);
|
|
32
26
|
this.parts.length = 0;
|
|
33
|
-
this.size = 0;
|
|
34
27
|
return result;
|
|
35
28
|
}
|
|
36
29
|
}
|
|
@@ -43,21 +36,28 @@ export function latin1Encode(text) {
|
|
|
43
36
|
}
|
|
44
37
|
/** The text of ISO 8859-1 `bytes`. */
|
|
45
38
|
export function latin1Decode(bytes) {
|
|
39
|
+
return fromCharCodes(bytes);
|
|
40
|
+
}
|
|
41
|
+
/** The text of the UTF-16 code units `codes`. */
|
|
42
|
+
export function fromCharCodes(codes) {
|
|
46
43
|
let text = '';
|
|
47
|
-
// In chunks, since a
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
// In chunks, since a large array exceeds the argument limit of some engines. `apply` takes the array as it is, where a
|
|
45
|
+
// spread would iterate over it.
|
|
46
|
+
for (let i = 0; i < codes.length; i += 0x8000) {
|
|
47
|
+
text += Reflect.apply(String.fromCharCode, undefined, codes.subarray(i, i + 0x8000));
|
|
50
48
|
}
|
|
51
49
|
return text;
|
|
52
50
|
}
|
|
53
51
|
const utf8Encoder = new TextEncoder();
|
|
52
|
+
const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
|
|
53
|
+
const lenientUtf8Decoder = new TextDecoder('utf-8');
|
|
54
54
|
export function utf8Encode(text) {
|
|
55
55
|
return utf8Encoder.encode(text);
|
|
56
56
|
}
|
|
57
|
-
/** Decodes UTF-8; throws `FormatError` for malformed data unless `allowMalformed`. */
|
|
57
|
+
/** Decodes UTF-8, without a leading BOM; throws `FormatError` for malformed data unless `allowMalformed`. */
|
|
58
58
|
export function utf8Decode(bytes, allowMalformed = false) {
|
|
59
59
|
try {
|
|
60
|
-
return
|
|
60
|
+
return (allowMalformed ? lenientUtf8Decoder : utf8Decoder).decode(bytes);
|
|
61
61
|
}
|
|
62
62
|
catch {
|
|
63
63
|
throw new FormatError('Invalid UTF-8');
|
|
@@ -125,12 +125,4 @@ export function base64Decode(text) {
|
|
|
125
125
|
}
|
|
126
126
|
return out;
|
|
127
127
|
}
|
|
128
|
-
export function bytesEqual(a, b) {
|
|
129
|
-
if (a.length !== b.length)
|
|
130
|
-
return false;
|
|
131
|
-
for (let i = 0; i < a.length; i++)
|
|
132
|
-
if (a[i] !== b[i])
|
|
133
|
-
return false;
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
128
|
//# sourceMappingURL=bytes.js.map
|
package/dist/util/bytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/util/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,yCAAyC;AACzC,MAAM,UAAU,WAAW,CAAC,KAA4B;IACtD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACzB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,6CAA6C;AAC7C,MAAM,OAAO,YAAY;IACN,KAAK,GAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/util/bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,yCAAyC;AACzC,MAAM,UAAU,WAAW,CAAC,KAA4B;IACtD,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,GAAG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AC,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACjC,MAAM,SAAS,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;YAC1E,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,IAAI,KAAK,GAAG,CAAC;gBAAE,MAAM,IAAI,WAAW,CAAC,0BAA0B,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACrF,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QAC/C,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-context.d.ts","sourceRoot":"","sources":["../../src/util/call-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"call-context.d.ts","sourceRoot":"","sources":["../../src/util/call-context.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2F;IAEnH,oEAAoE;IACpE,IAAI,OAAO,IAAI,CAAC,GAAG,SAAS,CAE3B;IAED,yCAAyC;IACzC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;CAGrC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `AsyncLocalStorage` where the runtime has it (Node.js, Deno
|
|
3
|
-
* bundlers for the browser have nothing to
|
|
2
|
+
* `AsyncLocalStorage` where the runtime has it, found through `process.getBuiltinModule` (Node.js 22.3, Deno 2.1 and
|
|
3
|
+
* Bun 1.2.6 or later) rather than by importing `node:async_hooks`, so that bundlers for the browser have nothing to
|
|
4
|
+
* resolve.
|
|
4
5
|
*/
|
|
5
6
|
const AsyncStorageClass = (() => {
|
|
6
7
|
const runtime = globalThis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-context.js","sourceRoot":"","sources":["../../src/util/call-context.ts"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"call-context.js","sourceRoot":"","sources":["../../src/util/call-context.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,iBAAiB,GAAwC,CAAC,GAAG,EAAE;IACnE,MAAM,OAAO,GAAG,UAEf,CAAC;IACF,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IACpF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,EAAE,CAAC;AAEL;;;GAGG;AACH,MAAM,OAAO,WAAW;IACL,OAAO,GAAgC,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,EAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnH,oEAAoE;IACpE,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED,yCAAyC;IACzC,GAAG,CAAI,KAAQ,EAAE,MAAe;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnE,CAAC;CACF"}
|
package/dist/util/dates.d.ts
CHANGED
|
@@ -12,32 +12,17 @@ export declare function parseFintsDate(date: string | undefined): Date | undefin
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function parseFintsDateTime(date: string | undefined, time: string | undefined): Date | undefined;
|
|
14
14
|
/**
|
|
15
|
-
* Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring
|
|
16
|
-
* if it is missing or invalid.
|
|
15
|
+
* Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring what follows it, such as a time zone; `undefined`
|
|
16
|
+
* if it is missing or invalid. A `T` right after the date makes it a date and time, which must be one `parseIsoMoment`
|
|
17
|
+
* reads, and the date the day in Germany at that moment: for a time in UTC late in the evening, the next day.
|
|
17
18
|
*/
|
|
18
19
|
export declare function parseIsoDate(date: string | undefined): Date | undefined;
|
|
19
|
-
/** Parses an ISO 8601 date `YYYY-MM-DD` and time `HH:MM:SS` as the moment they name. */
|
|
20
|
-
export declare function parseIsoDateTime(date: string | undefined, time: string | undefined): Date | undefined;
|
|
21
20
|
/**
|
|
22
21
|
* Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` given in UTC+01:00 all year round, as the account extension of
|
|
23
22
|
* the user parameter data states its times (Formals E.3.1); `undefined` if either is missing or invalid. A time with
|
|
24
23
|
* fewer than six digits lost its leading zeros as a JSON number.
|
|
25
24
|
*/
|
|
26
25
|
export declare function parseUtcPlusOneDateTime(date: string | undefined, time: string | undefined): Date | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* The moment a German clock shows the given time.
|
|
29
|
-
*
|
|
30
|
-
* German time is CET (UTC+1), and CEST (UTC+2) from 01:00 UTC on the last Sunday of March to 01:00 UTC on the last
|
|
31
|
-
* Sunday of October (the EU rule). The hour the clocks show twice in October counts as CEST; a time in the hour that is
|
|
32
|
-
* skipped in March counts as CET.
|
|
33
|
-
*/
|
|
34
|
-
export declare function germanTime(year: number, month: number, day: number, hour: number, minute: number, second: number): Date;
|
|
35
|
-
/** The calendar day a German clock shows at `moment`, as a local `Date` at midnight like every calendar date. */
|
|
36
|
-
export declare function germanDay(moment: Date): Date;
|
|
37
|
-
/** Local midnight of the day; `month` counts from 1, and years below 100 are not moved to 19xx. */
|
|
38
|
-
export declare function localDate(year: number, month: number, day: number): Date;
|
|
39
|
-
/** The date, or `undefined` if `month` or `day` is out of range; `Date` would roll it over into another date. */
|
|
40
|
-
export declare function validDate(year: number, month: number, day: number): Date | undefined;
|
|
41
26
|
/**
|
|
42
27
|
* The date, with a day beyond the end of the month moved to its last day: banks write 30 February or 31 April for
|
|
43
28
|
* month-end bookings. `undefined` for a month or day that no month has.
|
|
@@ -48,8 +33,9 @@ export declare function clampedDate(year: number, month: number, day: number): D
|
|
|
48
33
|
* as 19xx. `undefined` if the date is invalid.
|
|
49
34
|
*/
|
|
50
35
|
export declare function parseSwiftDate(yymmdd: string): Date | undefined;
|
|
51
|
-
/**
|
|
52
|
-
export declare function
|
|
36
|
+
/** A copy of `d`, so that a model keeps dates of its own: a `Date` can be changed in place. */
|
|
37
|
+
export declare function copyDate(d: Date): Date;
|
|
38
|
+
export declare function copyDate(d: Date | undefined): Date | undefined;
|
|
53
39
|
/** The calendar day `moment` falls on in local time, as a local `Date` at midnight. */
|
|
54
40
|
export declare function calendarDay(moment: Date): Date;
|
|
55
41
|
/**
|
package/dist/util/dates.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../../src/util/dates.ts"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gB,WAAW,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAE9C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS,EAAE,GAAG,GAAE,IAAiB,GAAG,IAAI,GAAG,SAAS,CAI7F"}
|
package/dist/util/dates.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// A value is either a calendar date, a local `Date` at midnight of which only the day counts, or the exact moment of a
|
|
2
|
-
// date with a time of day, which the bank states in German time (see `germanTime`)
|
|
3
|
-
// date without a valid time of day is not a moment.
|
|
2
|
+
// date with a time of day, which the bank states in German time (see `germanTime`) unless it gives the UTC offset. The
|
|
3
|
+
// parsers keep the two apart: a date without a valid time of day is not a moment. A time of day runs from 00:00:00 to
|
|
4
|
+
// 23:59:59, and 24:00:00, which ISO 8601 and XML Schema allow for the end of a day, is midnight of the next.
|
|
4
5
|
const hourMs = 3_600_000;
|
|
5
6
|
function twoDigits(n) {
|
|
6
7
|
return n.toString().padStart(2, '0');
|
|
@@ -23,7 +24,8 @@ export function formatIsoDate(d) {
|
|
|
23
24
|
const fintsDate = /^(\d{4})(\d{2})(\d{2})$/;
|
|
24
25
|
const fintsTime = /^(\d{2})(\d{2})(\d{2})/;
|
|
25
26
|
const isoDate = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
26
|
-
|
|
27
|
+
// The time of an XML Schema `dateTime`, whose UTC offset lies between -14:00 and +14:00.
|
|
28
|
+
const isoTime = /^(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-](?:(?:0\d|1[0-3]):[0-5]\d|14:00))?$/;
|
|
27
29
|
/** Parses a FinTS 3.0 date `YYYYMMDD` as a calendar date; `undefined` if it is missing or invalid. */
|
|
28
30
|
export function parseFintsDate(date) {
|
|
29
31
|
return parseDate(fintsDate, date);
|
|
@@ -33,32 +35,63 @@ export function parseFintsDate(date) {
|
|
|
33
35
|
* invalid.
|
|
34
36
|
*/
|
|
35
37
|
export function parseFintsDateTime(date, time) {
|
|
36
|
-
|
|
38
|
+
const clock = clockOn(parseDate(fintsDate, date), match(fintsTime, time));
|
|
39
|
+
return clock && germanTime(...clock);
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
|
-
* Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring
|
|
40
|
-
* if it is missing or invalid.
|
|
42
|
+
* Parses an ISO 8601 date `YYYY-MM-DD` as a calendar date, ignoring what follows it, such as a time zone; `undefined`
|
|
43
|
+
* if it is missing or invalid. A `T` right after the date makes it a date and time, which must be one `parseIsoMoment`
|
|
44
|
+
* reads, and the date the day in Germany at that moment: for a time in UTC late in the evening, the next day.
|
|
41
45
|
*/
|
|
42
46
|
export function parseIsoDate(date) {
|
|
43
|
-
|
|
47
|
+
if (date?.charAt(10) !== 'T')
|
|
48
|
+
return parseDate(isoDate, date);
|
|
49
|
+
const moment = parseIsoMoment(date);
|
|
50
|
+
return moment && germanDay(moment);
|
|
44
51
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Parses an ISO 8601 date and time as XML Schema writes it, `YYYY-MM-DDThh:mm:ss` with optional fractional seconds and
|
|
54
|
+
* UTC offset (`Z` or `±hh:mm` up to ±14:00), as the moment it names, to the second: in German time where it states no
|
|
55
|
+
* offset. `undefined` if it is invalid.
|
|
56
|
+
*/
|
|
57
|
+
function parseIsoMoment(dateTime) {
|
|
58
|
+
const t = isoTime.exec(dateTime.slice(11));
|
|
59
|
+
const clock = clockOn(parseDate(isoDate, dateTime), t);
|
|
60
|
+
if (clock === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
const zone = t?.[5];
|
|
63
|
+
return zone === undefined ? germanTime(...clock) : new Date(utc(...clock) - offsetMs(zone));
|
|
64
|
+
}
|
|
65
|
+
/** The UTC offset `Z` or `±hh:mm` in milliseconds. */
|
|
66
|
+
function offsetMs(zone) {
|
|
67
|
+
if (zone === 'Z')
|
|
68
|
+
return 0;
|
|
69
|
+
const ms = (Number(zone.slice(1, 3)) * 60 + Number(zone.slice(4))) * 60_000;
|
|
70
|
+
return zone.startsWith('-') ? -ms : ms;
|
|
71
|
+
}
|
|
72
|
+
function match(pattern, text) {
|
|
73
|
+
return text === undefined ? null : pattern.exec(text);
|
|
48
74
|
}
|
|
49
75
|
function parseDate(pattern, date) {
|
|
50
|
-
const d =
|
|
76
|
+
const d = match(pattern, date);
|
|
51
77
|
return d ? validDate(Number(d[1]), Number(d[2]), Number(d[3])) : undefined;
|
|
52
78
|
}
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The time of day `t` on `day`, where `t` matched hour, minute and second, and maybe a fraction of a second after them;
|
|
81
|
+
* `undefined` if either is missing or the time is invalid.
|
|
82
|
+
*/
|
|
83
|
+
function clockOn(day, t) {
|
|
56
84
|
if (day === undefined || !t)
|
|
57
85
|
return undefined;
|
|
58
86
|
const [hour, minute, second] = [Number(t[1]), Number(t[2]), Number(t[3])];
|
|
87
|
+
// The fraction counts only here: 24:00:00.5 lies past the end of the day.
|
|
88
|
+
if (hour === 24 && minute === 0 && second === 0 && !/[1-9]/.test(t[4] ?? '')) {
|
|
89
|
+
const next = localDate(day.getFullYear(), day.getMonth() + 1, day.getDate() + 1);
|
|
90
|
+
return [next.getFullYear(), next.getMonth() + 1, next.getDate(), 0, 0, 0];
|
|
91
|
+
}
|
|
59
92
|
if (hour > 23 || minute > 59 || second > 59)
|
|
60
93
|
return undefined;
|
|
61
|
-
return
|
|
94
|
+
return [day.getFullYear(), day.getMonth() + 1, day.getDate(), hour, minute, second];
|
|
62
95
|
}
|
|
63
96
|
/**
|
|
64
97
|
* Parses a FinTS 3.0 date `YYYYMMDD` and time `HHMMSS` given in UTC+01:00 all year round, as the account extension of
|
|
@@ -66,14 +99,8 @@ function moment(day, timePattern, time) {
|
|
|
66
99
|
* fewer than six digits lost its leading zeros as a JSON number.
|
|
67
100
|
*/
|
|
68
101
|
export function parseUtcPlusOneDateTime(date, time) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
if (day === undefined || !t)
|
|
72
|
-
return undefined;
|
|
73
|
-
const [hour, minute, second] = [Number(t[1]), Number(t[2]), Number(t[3])];
|
|
74
|
-
if (hour > 23 || minute > 59 || second > 59)
|
|
75
|
-
return undefined;
|
|
76
|
-
return new Date(utc(day.getFullYear(), day.getMonth() + 1, day.getDate(), hour, minute, second) - hourMs);
|
|
102
|
+
const clock = clockOn(parseDate(fintsDate, date), match(fintsTime, time?.padStart(6, '0')));
|
|
103
|
+
return clock && new Date(utc(...clock) - hourMs);
|
|
77
104
|
}
|
|
78
105
|
/**
|
|
79
106
|
* The moment a German clock shows the given time.
|
|
@@ -82,13 +109,13 @@ export function parseUtcPlusOneDateTime(date, time) {
|
|
|
82
109
|
* Sunday of October (the EU rule). The hour the clocks show twice in October counts as CEST; a time in the hour that is
|
|
83
110
|
* skipped in March counts as CET.
|
|
84
111
|
*/
|
|
85
|
-
|
|
112
|
+
function germanTime(year, month, day, hour, minute, second) {
|
|
86
113
|
const clock = utc(year, month, day, hour, minute, second);
|
|
87
114
|
const summer = clock - 2 * hourMs;
|
|
88
115
|
return new Date(isSummerTime(summer) ? summer : clock - hourMs);
|
|
89
116
|
}
|
|
90
117
|
/** The calendar day a German clock shows at `moment`, as a local `Date` at midnight like every calendar date. */
|
|
91
|
-
|
|
118
|
+
function germanDay(moment) {
|
|
92
119
|
const utcMs = moment.getTime();
|
|
93
120
|
const clock = new Date(utcMs + (isSummerTime(utcMs) ? 2 : 1) * hourMs);
|
|
94
121
|
return localDate(clock.getUTCFullYear(), clock.getUTCMonth() + 1, clock.getUTCDate());
|
|
@@ -111,14 +138,14 @@ function utc(year, month, day, hour, minute, second) {
|
|
|
111
138
|
return d.getTime();
|
|
112
139
|
}
|
|
113
140
|
/** Local midnight of the day; `month` counts from 1, and years below 100 are not moved to 19xx. */
|
|
114
|
-
|
|
141
|
+
function localDate(year, month, day) {
|
|
115
142
|
const d = new Date(0);
|
|
116
143
|
d.setFullYear(year, month - 1, day);
|
|
117
144
|
d.setHours(0, 0, 0, 0);
|
|
118
145
|
return d;
|
|
119
146
|
}
|
|
120
147
|
/** The date, or `undefined` if `month` or `day` is out of range; `Date` would roll it over into another date. */
|
|
121
|
-
|
|
148
|
+
function validDate(year, month, day) {
|
|
122
149
|
if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month))
|
|
123
150
|
return undefined;
|
|
124
151
|
return localDate(year, month, day);
|
|
@@ -145,11 +172,14 @@ export function parseSwiftDate(yymmdd) {
|
|
|
145
172
|
return clampedDate(yy >= 80 ? 1900 + yy : 2000 + yy, Number(m[2]), Number(m[3]));
|
|
146
173
|
}
|
|
147
174
|
/** Number of days the `month` (1 to 12) of `year` has. */
|
|
148
|
-
|
|
175
|
+
function daysInMonth(year, month) {
|
|
149
176
|
if (month === 2)
|
|
150
177
|
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0 ? 29 : 28;
|
|
151
178
|
return [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
152
179
|
}
|
|
180
|
+
export function copyDate(d) {
|
|
181
|
+
return d && new Date(d.getTime());
|
|
182
|
+
}
|
|
153
183
|
/** The calendar day `moment` falls on in local time, as a local `Date` at midnight. */
|
|
154
184
|
export function calendarDay(moment) {
|
|
155
185
|
return localDate(moment.getFullYear(), moment.getMonth() + 1, moment.getDate());
|