@payoutjp/bank 0.1.0-alpha.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/LICENSE +201 -0
- package/README.md +11 -0
- package/dist/destination.d.ts +36 -0
- package/dist/destination.d.ts.map +1 -0
- package/dist/destination.js +27 -0
- package/dist/destination.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/profile.d.ts +23 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +46 -0
- package/dist/profile.js.map +1 -0
- package/dist/registry.d.ts +110 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +59 -0
- package/dist/registry.js.map +1 -0
- package/dist/rules.d.ts +24 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +445 -0
- package/dist/rules.js.map +1 -0
- package/dist/validate.d.ts +14 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +97 -0
- package/dist/validate.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PayoutJP contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @payoutjp/bank
|
|
2
|
+
|
|
3
|
+
Conservative structural validation for Japanese bank-transfer destinations. The package does not
|
|
4
|
+
bundle a production Bank Registry and does not verify account existence or ownership.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install @payoutjp/bank@alpha
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
See the [PayoutJP repository](https://github.com/inthecradle/payoutjp) for profiles, local Registry
|
|
11
|
+
injection, safety boundaries, and examples. Licensed under Apache-2.0.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Canonical account types accepted by the Bank destination contract. */
|
|
3
|
+
export declare const bankAccountTypeValues: readonly ["ordinary", "checking", "savings", "other"];
|
|
4
|
+
/** Runtime schema for a canonical Bank account type. */
|
|
5
|
+
export declare const BankAccountTypeSchema: z.ZodEnum<{
|
|
6
|
+
checking: "checking";
|
|
7
|
+
ordinary: "ordinary";
|
|
8
|
+
other: "other";
|
|
9
|
+
savings: "savings";
|
|
10
|
+
}>;
|
|
11
|
+
/** A canonical Bank account type. Profile rules may allow only a subset. */
|
|
12
|
+
export type BankAccountType = z.infer<typeof BankAccountTypeSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime shape contract for a bank-transfer destination.
|
|
15
|
+
*
|
|
16
|
+
* Compatibility constraints deliberately live in rules so raw strings and
|
|
17
|
+
* leading zeroes survive parsing unchanged.
|
|
18
|
+
*/
|
|
19
|
+
export declare const BankTransferDestinationV1Schema: z.ZodObject<{
|
|
20
|
+
schemaVersion: z.ZodLiteral<"1">;
|
|
21
|
+
rail: z.ZodLiteral<"bank_transfer">;
|
|
22
|
+
id: z.ZodOptional<z.ZodString>;
|
|
23
|
+
bankCode: z.ZodString;
|
|
24
|
+
branchCode: z.ZodString;
|
|
25
|
+
accountType: z.ZodEnum<{
|
|
26
|
+
checking: "checking";
|
|
27
|
+
ordinary: "ordinary";
|
|
28
|
+
other: "other";
|
|
29
|
+
savings: "savings";
|
|
30
|
+
}>;
|
|
31
|
+
accountNumber: z.ZodString;
|
|
32
|
+
accountHolder: z.ZodString;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
/** Version 1 bank-transfer destination inferred from its runtime schema. */
|
|
35
|
+
export type BankTransferDestinationV1 = z.infer<typeof BankTransferDestinationV1Schema>;
|
|
36
|
+
//# sourceMappingURL=destination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.d.ts","sourceRoot":"","sources":["../src/destination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yEAAyE;AACzE,eAAO,MAAM,qBAAqB,uDAKvB,CAAC;AAEZ,wDAAwD;AACxD,eAAO,MAAM,qBAAqB;;;;;EAAgC,CAAC;AAEnE,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;kBAS1C,CAAC;AAEH,4EAA4E;AAC5E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Canonical account types accepted by the Bank destination contract. */
|
|
3
|
+
export const bankAccountTypeValues = Object.freeze([
|
|
4
|
+
"ordinary",
|
|
5
|
+
"checking",
|
|
6
|
+
"savings",
|
|
7
|
+
"other",
|
|
8
|
+
]);
|
|
9
|
+
/** Runtime schema for a canonical Bank account type. */
|
|
10
|
+
export const BankAccountTypeSchema = z.enum(bankAccountTypeValues);
|
|
11
|
+
/**
|
|
12
|
+
* Runtime shape contract for a bank-transfer destination.
|
|
13
|
+
*
|
|
14
|
+
* Compatibility constraints deliberately live in rules so raw strings and
|
|
15
|
+
* leading zeroes survive parsing unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export const BankTransferDestinationV1Schema = z.strictObject({
|
|
18
|
+
schemaVersion: z.literal("1"),
|
|
19
|
+
rail: z.literal("bank_transfer"),
|
|
20
|
+
id: z.string().min(1).optional(),
|
|
21
|
+
bankCode: z.string(),
|
|
22
|
+
branchCode: z.string(),
|
|
23
|
+
accountType: BankAccountTypeSchema,
|
|
24
|
+
accountNumber: z.string(),
|
|
25
|
+
accountHolder: z.string(),
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=destination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.js","sourceRoot":"","sources":["../src/destination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU;IACV,UAAU;IACV,SAAS;IACT,OAAO;CACC,CAAC,CAAC;AAEZ,wDAAwD;AACxD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAKnE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5D,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAChC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,WAAW,EAAE,qBAAqB;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;CAC1B,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { type BankAccountType, BankAccountTypeSchema, bankAccountTypeValues, type BankTransferDestinationV1, BankTransferDestinationV1Schema, } from "./destination.js";
|
|
2
|
+
export { bankGenericJpProfileV1 } from "./profile.js";
|
|
3
|
+
export { type BankBranchEntryV1, BankBranchEntryV1Schema, type BankDirectoryRegistryV1, BankDirectoryRegistryEnvelopeV1Schema, BankDirectoryRegistryV1Schema, bankDirectoryEntryStatusValues, type BankEntryV1, BankEntryV1Schema, loadBankDirectoryRegistryV1, } from "./registry.js";
|
|
4
|
+
export { accountHolderCharsetRule, accountHolderControlCharacterRule, accountHolderEncodedByteLengthRule, accountHolderRequiredRule, accountHolderUnicodeNormalizationRule, accountHolderWhitespaceRule, accountNumberDigitsRule, accountNumberLengthRule, accountTypeAllowedRule, allBankAccountTypes, bankCodeExistsRule, bankCodeSyntaxRule, type BankRuleContextV1, type BankRuleParamsV1, bankRules, branchCodeExistsRule, branchCodeSyntaxRule, branchOwnershipRule, } from "./rules.js";
|
|
5
|
+
export { type ValidateBankTransferDestinationV1Options, validateBankTransferDestinationV1, } from "./validate.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EACL,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,KAAK,uBAAuB,EAC5B,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,KAAK,WAAW,EAChB,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,kCAAkC,EAClC,yBAAyB,EACzB,qCAAqC,EACrC,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,wCAAwC,EAC7C,iCAAiC,GAClC,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BankAccountTypeSchema, bankAccountTypeValues, BankTransferDestinationV1Schema, } from "./destination.js";
|
|
2
|
+
export { bankGenericJpProfileV1 } from "./profile.js";
|
|
3
|
+
export { BankBranchEntryV1Schema, BankDirectoryRegistryEnvelopeV1Schema, BankDirectoryRegistryV1Schema, bankDirectoryEntryStatusValues, BankEntryV1Schema, loadBankDirectoryRegistryV1, } from "./registry.js";
|
|
4
|
+
export { accountHolderCharsetRule, accountHolderControlCharacterRule, accountHolderEncodedByteLengthRule, accountHolderRequiredRule, accountHolderUnicodeNormalizationRule, accountHolderWhitespaceRule, accountNumberDigitsRule, accountNumberLengthRule, accountTypeAllowedRule, allBankAccountTypes, bankCodeExistsRule, bankCodeSyntaxRule, bankRules, branchCodeExistsRule, branchCodeSyntaxRule, branchOwnershipRule, } from "./rules.js";
|
|
5
|
+
export { validateBankTransferDestinationV1, } from "./validate.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,qBAAqB,EAErB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAEL,uBAAuB,EAEvB,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAE9B,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,kCAAkC,EAClC,yBAAyB,EACzB,qCAAqC,EACrC,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAGlB,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,iCAAiC,GAClC,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Conservative structural Profile; it intentionally carries no production Bank Registry. */
|
|
2
|
+
export declare const bankGenericJpProfileV1: {
|
|
3
|
+
schemaVersion: "1";
|
|
4
|
+
id: import("@payoutjp/core").ProfileId;
|
|
5
|
+
version: string;
|
|
6
|
+
status: "deprecated" | "experimental" | "retired" | "verified";
|
|
7
|
+
rail: "bank_transfer" | "jpyc";
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
rules: {
|
|
11
|
+
id: import("@payoutjp/core").RuleId;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
severity?: "error" | "info" | "warning" | undefined;
|
|
14
|
+
params?: Record<string, unknown> | undefined;
|
|
15
|
+
}[];
|
|
16
|
+
registries: {
|
|
17
|
+
id: import("@payoutjp/core").RegistryId;
|
|
18
|
+
version: string;
|
|
19
|
+
sha256: string;
|
|
20
|
+
}[];
|
|
21
|
+
sourceNotes?: string[] | undefined;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAGA,6FAA6F;AAC7F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;CA6ClC,CAAC"}
|
package/dist/profile.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { loadCompatibilityProfileV1 } from "@payoutjp/core";
|
|
2
|
+
import { bankRules } from "./rules.js";
|
|
3
|
+
/** Conservative structural Profile; it intentionally carries no production Bank Registry. */
|
|
4
|
+
export const bankGenericJpProfileV1 = loadCompatibilityProfileV1({
|
|
5
|
+
schemaVersion: "1",
|
|
6
|
+
id: "bank-generic-jp",
|
|
7
|
+
version: "0.1.0",
|
|
8
|
+
status: "verified",
|
|
9
|
+
rail: "bank_transfer",
|
|
10
|
+
title: "Generic Japanese bank transfer",
|
|
11
|
+
description: "Conservative structural validation without claims about acceptance by a specific bank.",
|
|
12
|
+
rules: [
|
|
13
|
+
{ id: "BANK-CODE-001", enabled: true, params: { asciiDigits: 4 } },
|
|
14
|
+
{ id: "BANK-BRANCH-001", enabled: true, params: { asciiDigits: 3 } },
|
|
15
|
+
{
|
|
16
|
+
id: "BANK-TYPE-001",
|
|
17
|
+
enabled: true,
|
|
18
|
+
params: { allowedValues: ["ordinary", "checking", "savings", "other"] },
|
|
19
|
+
},
|
|
20
|
+
{ id: "BANK-NUMBER-001", enabled: true, params: { asciiDigitsOnly: true } },
|
|
21
|
+
{
|
|
22
|
+
id: "BANK-NUMBER-002",
|
|
23
|
+
enabled: true,
|
|
24
|
+
params: { minDigits: 1, maxDigits: 7 },
|
|
25
|
+
},
|
|
26
|
+
{ id: "BANK-HOLDER-001", enabled: true, params: { required: true } },
|
|
27
|
+
{ id: "BANK-HOLDER-002", enabled: true, params: {} },
|
|
28
|
+
{
|
|
29
|
+
id: "BANK-HOLDER-003",
|
|
30
|
+
enabled: true,
|
|
31
|
+
params: { rejectControlCharacters: true },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "BANK-HOLDER-004",
|
|
35
|
+
enabled: true,
|
|
36
|
+
params: { unicodeNormalization: "NFC" },
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
registries: [],
|
|
40
|
+
sourceNotes: [
|
|
41
|
+
"Structural checks only; this Profile does not assert that a destination is accepted by every bank.",
|
|
42
|
+
"Bank and branch existence rules require an explicitly supplied, version-pinned Registry.",
|
|
43
|
+
"No provider-specific character set or encoded byte limit is asserted.",
|
|
44
|
+
],
|
|
45
|
+
}, { rules: bankRules });
|
|
46
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,sBAAsB,GAAG,0BAA0B,CAC9D;IACE,aAAa,EAAE,GAAG;IAClB,EAAE,EAAE,iBAAiB;IACrB,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,gCAAgC;IACvC,WAAW,EACT,wFAAwF;IAC1F,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE;QAClE,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE;QACpE;YACE,EAAE,EAAE,eAAe;YACnB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE;SACxE;QACD,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE;QAC3E;YACE,EAAE,EAAE,iBAAiB;YACrB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE;SACvC;QACD,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QACpE,EAAE,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;QACpD;YACE,EAAE,EAAE,iBAAiB;YACrB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE,uBAAuB,EAAE,IAAI,EAAE;SAC1C;QACD;YACE,EAAE,EAAE,iBAAiB;YACrB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE;SACxC;KACF;IACD,UAAU,EAAE,EAAE;IACd,WAAW,EAAE;QACX,oGAAoG;QACpG,0FAA0F;QAC1F,uEAAuE;KACxE;CACF,EACD,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type RegistryEnvelopeV1 } from "@payoutjp/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const bankDirectoryEntryStatusValues: readonly ["active", "closed", "unknown"];
|
|
4
|
+
/** Runtime schema for one branch in a Bank Directory Registry. */
|
|
5
|
+
export declare const BankBranchEntryV1Schema: z.ZodObject<{
|
|
6
|
+
code: z.ZodString;
|
|
7
|
+
name: z.ZodOptional<z.ZodString>;
|
|
8
|
+
kana: z.ZodOptional<z.ZodString>;
|
|
9
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
active: "active";
|
|
11
|
+
closed: "closed";
|
|
12
|
+
unknown: "unknown";
|
|
13
|
+
}>>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type BankBranchEntryV1 = z.infer<typeof BankBranchEntryV1Schema>;
|
|
16
|
+
/** Runtime schema for one bank and its declared branches. */
|
|
17
|
+
export declare const BankEntryV1Schema: z.ZodObject<{
|
|
18
|
+
code: z.ZodString;
|
|
19
|
+
name: z.ZodOptional<z.ZodString>;
|
|
20
|
+
kana: z.ZodOptional<z.ZodString>;
|
|
21
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
active: "active";
|
|
23
|
+
closed: "closed";
|
|
24
|
+
unknown: "unknown";
|
|
25
|
+
}>>;
|
|
26
|
+
branches: z.ZodArray<z.ZodObject<{
|
|
27
|
+
code: z.ZodString;
|
|
28
|
+
name: z.ZodOptional<z.ZodString>;
|
|
29
|
+
kana: z.ZodOptional<z.ZodString>;
|
|
30
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
active: "active";
|
|
32
|
+
closed: "closed";
|
|
33
|
+
unknown: "unknown";
|
|
34
|
+
}>>;
|
|
35
|
+
}, z.core.$strict>>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export type BankEntryV1 = z.infer<typeof BankEntryV1Schema>;
|
|
38
|
+
/** Runtime payload schema for a synthetic or externally supplied Bank Directory. */
|
|
39
|
+
export declare const BankDirectoryRegistryV1Schema: z.ZodObject<{
|
|
40
|
+
kind: z.ZodLiteral<"bank-directory">;
|
|
41
|
+
banks: z.ZodArray<z.ZodObject<{
|
|
42
|
+
code: z.ZodString;
|
|
43
|
+
name: z.ZodOptional<z.ZodString>;
|
|
44
|
+
kana: z.ZodOptional<z.ZodString>;
|
|
45
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
active: "active";
|
|
47
|
+
closed: "closed";
|
|
48
|
+
unknown: "unknown";
|
|
49
|
+
}>>;
|
|
50
|
+
branches: z.ZodArray<z.ZodObject<{
|
|
51
|
+
code: z.ZodString;
|
|
52
|
+
name: z.ZodOptional<z.ZodString>;
|
|
53
|
+
kana: z.ZodOptional<z.ZodString>;
|
|
54
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
55
|
+
active: "active";
|
|
56
|
+
closed: "closed";
|
|
57
|
+
unknown: "unknown";
|
|
58
|
+
}>>;
|
|
59
|
+
}, z.core.$strict>>;
|
|
60
|
+
}, z.core.$strict>>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
export type BankDirectoryRegistryV1 = z.infer<typeof BankDirectoryRegistryV1Schema>;
|
|
63
|
+
/** Runtime envelope schema for a Bank Directory Registry. */
|
|
64
|
+
export declare const BankDirectoryRegistryEnvelopeV1Schema: z.ZodObject<{
|
|
65
|
+
schemaVersion: z.ZodLiteral<"1">;
|
|
66
|
+
id: z.ZodPipe<z.ZodString, z.ZodTransform<import("@payoutjp/core").RegistryId, string>>;
|
|
67
|
+
version: z.ZodString;
|
|
68
|
+
kind: z.ZodString;
|
|
69
|
+
sha256: z.ZodString;
|
|
70
|
+
source: z.ZodObject<{
|
|
71
|
+
publisher: z.ZodString;
|
|
72
|
+
uri: z.ZodString;
|
|
73
|
+
retrievedAt: z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>;
|
|
74
|
+
effectiveAsOf: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
75
|
+
license: z.ZodOptional<z.ZodString>;
|
|
76
|
+
notes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
payload: z.ZodType<{
|
|
79
|
+
kind: "bank-directory";
|
|
80
|
+
banks: {
|
|
81
|
+
code: string;
|
|
82
|
+
name?: string | undefined;
|
|
83
|
+
kana?: string | undefined;
|
|
84
|
+
status?: "active" | "closed" | "unknown" | undefined;
|
|
85
|
+
branches: {
|
|
86
|
+
code: string;
|
|
87
|
+
name?: string | undefined;
|
|
88
|
+
kana?: string | undefined;
|
|
89
|
+
status?: "active" | "closed" | "unknown" | undefined;
|
|
90
|
+
}[];
|
|
91
|
+
}[];
|
|
92
|
+
}, unknown, z.core.$ZodTypeInternals<{
|
|
93
|
+
kind: "bank-directory";
|
|
94
|
+
banks: {
|
|
95
|
+
code: string;
|
|
96
|
+
name?: string | undefined;
|
|
97
|
+
kana?: string | undefined;
|
|
98
|
+
status?: "active" | "closed" | "unknown" | undefined;
|
|
99
|
+
branches: {
|
|
100
|
+
code: string;
|
|
101
|
+
name?: string | undefined;
|
|
102
|
+
kana?: string | undefined;
|
|
103
|
+
status?: "active" | "closed" | "unknown" | undefined;
|
|
104
|
+
}[];
|
|
105
|
+
}[];
|
|
106
|
+
}, unknown>>;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
/** Loads and digest-verifies a local Bank Directory Registry without I/O. */
|
|
109
|
+
export declare function loadBankDirectoryRegistryV1(input: unknown): RegistryEnvelopeV1<BankDirectoryRegistryV1>;
|
|
110
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,8BAA8B,0CAIhC,CAAC;AAIZ,kEAAkE;AAClE,eAAO,MAAM,uBAAuB;;;;;;;;;kBAKlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAoBxE,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;kBAQ+D,CAAC;AAE9F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,oFAAoF;AACpF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;kBAKqD,CAAC;AAEhG,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,6DAA6D;AAC7D,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKhD,CAAC;AAEH,6EAA6E;AAC7E,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,kBAAkB,CAAC,uBAAuB,CAAC,CAM7C"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createRegistryEnvelopeV1Schema, loadRegistryEnvelopeV1, PayoutJpIntegrityError, } from "@payoutjp/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const bankDirectoryEntryStatusValues = Object.freeze([
|
|
4
|
+
"active",
|
|
5
|
+
"closed",
|
|
6
|
+
"unknown",
|
|
7
|
+
]);
|
|
8
|
+
const OptionalLabelSchema = z.string().min(1).optional();
|
|
9
|
+
/** Runtime schema for one branch in a Bank Directory Registry. */
|
|
10
|
+
export const BankBranchEntryV1Schema = z.strictObject({
|
|
11
|
+
code: z.string().min(1),
|
|
12
|
+
name: OptionalLabelSchema,
|
|
13
|
+
kana: OptionalLabelSchema,
|
|
14
|
+
status: z.enum(bankDirectoryEntryStatusValues).optional(),
|
|
15
|
+
});
|
|
16
|
+
function rejectDuplicateCodes(entries, context, pathPrefix) {
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
entries.forEach((entry, index) => {
|
|
19
|
+
if (seen.has(entry.code)) {
|
|
20
|
+
context.addIssue({
|
|
21
|
+
code: "custom",
|
|
22
|
+
message: "Duplicate Bank Directory code",
|
|
23
|
+
path: [...pathPrefix, index, "code"],
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
seen.add(entry.code);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Runtime schema for one bank and its declared branches. */
|
|
30
|
+
export const BankEntryV1Schema = z
|
|
31
|
+
.strictObject({
|
|
32
|
+
code: z.string().min(1),
|
|
33
|
+
name: OptionalLabelSchema,
|
|
34
|
+
kana: OptionalLabelSchema,
|
|
35
|
+
status: z.enum(bankDirectoryEntryStatusValues).optional(),
|
|
36
|
+
branches: z.array(BankBranchEntryV1Schema),
|
|
37
|
+
})
|
|
38
|
+
.superRefine((bank, context) => rejectDuplicateCodes(bank.branches, context, ["branches"]));
|
|
39
|
+
/** Runtime payload schema for a synthetic or externally supplied Bank Directory. */
|
|
40
|
+
export const BankDirectoryRegistryV1Schema = z
|
|
41
|
+
.strictObject({
|
|
42
|
+
kind: z.literal("bank-directory"),
|
|
43
|
+
banks: z.array(BankEntryV1Schema),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((registry, context) => rejectDuplicateCodes(registry.banks, context, ["banks"]));
|
|
46
|
+
/** Runtime envelope schema for a Bank Directory Registry. */
|
|
47
|
+
export const BankDirectoryRegistryEnvelopeV1Schema = createRegistryEnvelopeV1Schema(BankDirectoryRegistryV1Schema).refine((envelope) => envelope.kind === "bank-directory", {
|
|
48
|
+
message: "Registry envelope kind must match its Bank Directory payload",
|
|
49
|
+
path: ["kind"],
|
|
50
|
+
});
|
|
51
|
+
/** Loads and digest-verifies a local Bank Directory Registry without I/O. */
|
|
52
|
+
export function loadBankDirectoryRegistryV1(input) {
|
|
53
|
+
if (!BankDirectoryRegistryEnvelopeV1Schema.safeParse(input).success) {
|
|
54
|
+
throw new PayoutJpIntegrityError("PJP_REGISTRY_INVALID");
|
|
55
|
+
}
|
|
56
|
+
const envelope = loadRegistryEnvelopeV1(input, BankDirectoryRegistryV1Schema);
|
|
57
|
+
return envelope;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1D,QAAQ;IACR,QAAQ;IACR,SAAS;CACD,CAAC,CAAC;AAEZ,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAEzD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B,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAI9F,oFAAoF;AACpF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC;KAC3C,YAAY,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;CAClC,CAAC;KACD,WAAW,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAIhG,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qCAAqC,GAAG,8BAA8B,CACjF,6BAA6B,CAC9B,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE;IACzD,OAAO,EAAE,8DAA8D;IACvE,IAAI,EAAE,CAAC,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,IAAI,CAAC,qCAAqC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QACpE,MAAM,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC;IAC9E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/rules.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Rule, type RuleContextV1 } from "@payoutjp/core";
|
|
2
|
+
import { type BankAccountType, type BankTransferDestinationV1 } from "./destination.js";
|
|
3
|
+
import type { BankDirectoryRegistryV1 } from "./registry.js";
|
|
4
|
+
export type BankRuleParamsV1 = Readonly<Record<string, unknown>>;
|
|
5
|
+
export type BankRuleContextV1 = RuleContextV1<BankTransferDestinationV1, BankRuleParamsV1, BankDirectoryRegistryV1>;
|
|
6
|
+
export declare const bankCodeSyntaxRule: Rule<BankRuleContextV1>;
|
|
7
|
+
export declare const branchCodeSyntaxRule: Rule<BankRuleContextV1>;
|
|
8
|
+
export declare const bankCodeExistsRule: Rule<BankRuleContextV1>;
|
|
9
|
+
export declare const branchCodeExistsRule: Rule<BankRuleContextV1>;
|
|
10
|
+
export declare const branchOwnershipRule: Rule<BankRuleContextV1>;
|
|
11
|
+
export declare const accountTypeAllowedRule: Rule<BankRuleContextV1>;
|
|
12
|
+
export declare const accountNumberDigitsRule: Rule<BankRuleContextV1>;
|
|
13
|
+
export declare const accountNumberLengthRule: Rule<BankRuleContextV1>;
|
|
14
|
+
export declare const accountHolderRequiredRule: Rule<BankRuleContextV1>;
|
|
15
|
+
export declare const accountHolderWhitespaceRule: Rule<BankRuleContextV1>;
|
|
16
|
+
export declare const accountHolderControlCharacterRule: Rule<BankRuleContextV1>;
|
|
17
|
+
export declare const accountHolderUnicodeNormalizationRule: Rule<BankRuleContextV1>;
|
|
18
|
+
export declare const accountHolderCharsetRule: Rule<BankRuleContextV1>;
|
|
19
|
+
export declare const accountHolderEncodedByteLengthRule: Rule<BankRuleContextV1>;
|
|
20
|
+
/** All non-experimental M2 Bank rules, in stable RuleId order. */
|
|
21
|
+
export declare const bankRules: readonly Rule<BankRuleContextV1>[];
|
|
22
|
+
/** Canonical account-type values useful when constructing a Profile parameter allowlist. */
|
|
23
|
+
export declare const allBankAccountTypes: readonly BankAccountType[];
|
|
24
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACT,KAAK,aAAa,EAEnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC/B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACjE,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAC3C,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,CACxB,CAAC;AAgFF,eAAO,MAAM,kBAAkB,yBAsB7B,CAAC;AAEH,eAAO,MAAM,oBAAoB,yBAsB/B,CAAC;AAiBH,eAAO,MAAM,kBAAkB,yBAsB7B,CAAC;AAUH,eAAO,MAAM,oBAAoB,yBA6B/B,CAAC;AAEH,eAAO,MAAM,mBAAmB,yBA2B9B,CAAC;AAcH,eAAO,MAAM,sBAAsB,yBAkBjC,CAAC;AAIH,eAAO,MAAM,uBAAuB,yBAsBlC,CAAC;AAYH,eAAO,MAAM,uBAAuB,yBAuBlC,CAAC;AAIH,eAAO,MAAM,yBAAyB,yBAsBpC,CAAC;AAEH,eAAO,MAAM,2BAA2B,yBAqBtC,CAAC;AAQH,eAAO,MAAM,iCAAiC,yBAqB5C,CAAC;AAMH,eAAO,MAAM,qCAAqC,yBAyBhD,CAAC;AAMH,eAAO,MAAM,wBAAwB,yBAuBnC,CAAC;AAOH,eAAO,MAAM,kCAAkC,yBAuB7C,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,SAAS,oCAiBrB,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,EAAE,SAAS,eAAe,EAKxD,CAAC"}
|
package/dist/rules.js
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { createMetadataObservedValue, createPublicObservedValue, createRuleId, maskBankAccountNumber, redactAccountHolder, } from "@payoutjp/core";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { BankAccountTypeSchema, } from "./destination.js";
|
|
4
|
+
const EmptyParamsSchema = z.strictObject({});
|
|
5
|
+
const PositiveBoundedIntegerSchema = z.number().int().positive().max(1_000_000);
|
|
6
|
+
function finding(rule, context, definition) {
|
|
7
|
+
return {
|
|
8
|
+
schemaVersion: "1",
|
|
9
|
+
ruleId: rule.id,
|
|
10
|
+
severity: rule.defaultSeverity,
|
|
11
|
+
messageKey: definition.messageKey,
|
|
12
|
+
message: definition.message,
|
|
13
|
+
path: definition.path,
|
|
14
|
+
location: { itemIndex: context.itemIndex },
|
|
15
|
+
...(definition.actual === undefined ? {} : { actual: definition.actual }),
|
|
16
|
+
...(definition.expected === undefined ? {} : { expected: definition.expected }),
|
|
17
|
+
...(definition.remediation === undefined ? {} : { remediation: definition.remediation }),
|
|
18
|
+
profileId: context.profile.id,
|
|
19
|
+
profileVersion: context.profile.version,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function defineBankRule(definition) {
|
|
23
|
+
const rule = {
|
|
24
|
+
id: createRuleId(definition.id),
|
|
25
|
+
defaultSeverity: definition.defaultSeverity,
|
|
26
|
+
parseParams(input) {
|
|
27
|
+
return definition.paramsSchema.parse(input ?? {});
|
|
28
|
+
},
|
|
29
|
+
applies(context) {
|
|
30
|
+
const params = definition.paramsSchema.parse(context.params);
|
|
31
|
+
return definition.applies?.(context, params) ?? true;
|
|
32
|
+
},
|
|
33
|
+
evaluate(context) {
|
|
34
|
+
const params = definition.paramsSchema.parse(context.params);
|
|
35
|
+
return definition.evaluate(context, params, rule);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
return rule;
|
|
39
|
+
}
|
|
40
|
+
function isExactAsciiDigits(value, length) {
|
|
41
|
+
return value.length === length && /^[0-9]+$/u.test(value);
|
|
42
|
+
}
|
|
43
|
+
function compareStrings(left, right) {
|
|
44
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
45
|
+
}
|
|
46
|
+
const AsciiDigitsParamsSchema = z.strictObject({
|
|
47
|
+
asciiDigits: PositiveBoundedIntegerSchema.max(32),
|
|
48
|
+
});
|
|
49
|
+
export const bankCodeSyntaxRule = defineBankRule({
|
|
50
|
+
id: "BANK-CODE-001",
|
|
51
|
+
defaultSeverity: "error",
|
|
52
|
+
paramsSchema: AsciiDigitsParamsSchema,
|
|
53
|
+
evaluate(context, params, rule) {
|
|
54
|
+
if (isExactAsciiDigits(context.destination.bankCode, params.asciiDigits)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
return [
|
|
58
|
+
finding(rule, context, {
|
|
59
|
+
messageKey: "bank.code.invalid_format",
|
|
60
|
+
message: "Bank code must contain the configured number of ASCII digits.",
|
|
61
|
+
path: "destination.bankCode",
|
|
62
|
+
actual: createPublicObservedValue(context.destination.bankCode),
|
|
63
|
+
expected: `${params.asciiDigits} ASCII digits`,
|
|
64
|
+
remediation: {
|
|
65
|
+
code: "confirm_bank_selection",
|
|
66
|
+
message: "Confirm the bank code without converting or padding the input automatically.",
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
export const branchCodeSyntaxRule = defineBankRule({
|
|
73
|
+
id: "BANK-BRANCH-001",
|
|
74
|
+
defaultSeverity: "error",
|
|
75
|
+
paramsSchema: AsciiDigitsParamsSchema,
|
|
76
|
+
evaluate(context, params, rule) {
|
|
77
|
+
if (isExactAsciiDigits(context.destination.branchCode, params.asciiDigits)) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return [
|
|
81
|
+
finding(rule, context, {
|
|
82
|
+
messageKey: "bank.branch.invalid_format",
|
|
83
|
+
message: "Branch code must contain the configured number of ASCII digits.",
|
|
84
|
+
path: "destination.branchCode",
|
|
85
|
+
actual: createPublicObservedValue(context.destination.branchCode),
|
|
86
|
+
expected: `${params.asciiDigits} ASCII digits`,
|
|
87
|
+
remediation: {
|
|
88
|
+
code: "confirm_branch_selection",
|
|
89
|
+
message: "Confirm the branch code without converting or padding the input automatically.",
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
];
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
function bankDirectories(context) {
|
|
96
|
+
return [...context.registries.values()]
|
|
97
|
+
.filter((registry) => registry.kind === "bank-directory" && registry.payload.kind === "bank-directory")
|
|
98
|
+
.sort((left, right) => compareStrings(left.id, right.id));
|
|
99
|
+
}
|
|
100
|
+
function declaredBanks(context) {
|
|
101
|
+
return bankDirectories(context).flatMap((registry) => registry.payload.banks.filter((bank) => bank.code === context.destination.bankCode));
|
|
102
|
+
}
|
|
103
|
+
export const bankCodeExistsRule = defineBankRule({
|
|
104
|
+
id: "BANK-CODE-002",
|
|
105
|
+
defaultSeverity: "error",
|
|
106
|
+
paramsSchema: EmptyParamsSchema,
|
|
107
|
+
applies: (context) => bankDirectories(context).length > 0,
|
|
108
|
+
evaluate(context, _params, rule) {
|
|
109
|
+
if (declaredBanks(context).length > 0) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
return [
|
|
113
|
+
finding(rule, context, {
|
|
114
|
+
messageKey: "bank.code.not_found",
|
|
115
|
+
message: "Bank code is absent from the selected Bank Directory Registry.",
|
|
116
|
+
path: "destination.bankCode",
|
|
117
|
+
actual: createPublicObservedValue(context.destination.bankCode),
|
|
118
|
+
remediation: {
|
|
119
|
+
code: "confirm_bank_selection",
|
|
120
|
+
message: "Confirm the bank selection against the configured Registry snapshot.",
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
function branchOwners(context) {
|
|
127
|
+
return bankDirectories(context).flatMap((registry) => registry.payload.banks.filter((bank) => bank.branches.some((branch) => branch.code === context.destination.branchCode)));
|
|
128
|
+
}
|
|
129
|
+
export const branchCodeExistsRule = defineBankRule({
|
|
130
|
+
id: "BANK-BRANCH-002",
|
|
131
|
+
defaultSeverity: "error",
|
|
132
|
+
paramsSchema: EmptyParamsSchema,
|
|
133
|
+
applies: (context) => bankDirectories(context).length > 0,
|
|
134
|
+
evaluate(context, _params, rule) {
|
|
135
|
+
const banks = declaredBanks(context);
|
|
136
|
+
if (banks.length === 0 ||
|
|
137
|
+
banks.some((bank) => bank.branches.some((branch) => branch.code === context.destination.branchCode)) ||
|
|
138
|
+
branchOwners(context).length > 0) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
return [
|
|
142
|
+
finding(rule, context, {
|
|
143
|
+
messageKey: "bank.branch.not_found",
|
|
144
|
+
message: "Branch code is absent from the selected bank entry.",
|
|
145
|
+
path: "destination.branchCode",
|
|
146
|
+
actual: createPublicObservedValue(context.destination.branchCode),
|
|
147
|
+
remediation: {
|
|
148
|
+
code: "confirm_branch_selection",
|
|
149
|
+
message: "Confirm the branch selection against the configured Registry snapshot.",
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
];
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
export const branchOwnershipRule = defineBankRule({
|
|
156
|
+
id: "BANK-BRANCH-003",
|
|
157
|
+
defaultSeverity: "error",
|
|
158
|
+
paramsSchema: EmptyParamsSchema,
|
|
159
|
+
applies: (context) => bankDirectories(context).length > 0,
|
|
160
|
+
evaluate(context, _params, rule) {
|
|
161
|
+
const banks = declaredBanks(context);
|
|
162
|
+
const belongsToDeclaredBank = banks.some((bank) => bank.branches.some((branch) => branch.code === context.destination.branchCode));
|
|
163
|
+
if (banks.length === 0 || belongsToDeclaredBank || branchOwners(context).length === 0) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
return [
|
|
167
|
+
finding(rule, context, {
|
|
168
|
+
messageKey: "bank.branch.wrong_bank",
|
|
169
|
+
message: "Branch exists in the Registry but does not belong to the declared bank.",
|
|
170
|
+
path: "destination.branchCode",
|
|
171
|
+
actual: createPublicObservedValue(context.destination.branchCode),
|
|
172
|
+
remediation: {
|
|
173
|
+
code: "confirm_branch_selection",
|
|
174
|
+
message: "Confirm the bank and branch combination against the configured Registry snapshot.",
|
|
175
|
+
},
|
|
176
|
+
}),
|
|
177
|
+
];
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
const AllowedAccountTypesParamsSchema = z
|
|
181
|
+
.strictObject({ allowedValues: z.array(BankAccountTypeSchema).min(1) })
|
|
182
|
+
.superRefine((params, context) => {
|
|
183
|
+
if (new Set(params.allowedValues).size !== params.allowedValues.length) {
|
|
184
|
+
context.addIssue({
|
|
185
|
+
code: "custom",
|
|
186
|
+
message: "Account type allowlist contains a duplicate",
|
|
187
|
+
path: ["allowedValues"],
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
export const accountTypeAllowedRule = defineBankRule({
|
|
192
|
+
id: "BANK-TYPE-001",
|
|
193
|
+
defaultSeverity: "error",
|
|
194
|
+
paramsSchema: AllowedAccountTypesParamsSchema,
|
|
195
|
+
evaluate(context, params, rule) {
|
|
196
|
+
if (params.allowedValues.includes(context.destination.accountType)) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
return [
|
|
200
|
+
finding(rule, context, {
|
|
201
|
+
messageKey: "bank.account_type.not_allowed",
|
|
202
|
+
message: "Account type is not allowed by the selected Profile.",
|
|
203
|
+
path: "destination.accountType",
|
|
204
|
+
actual: createPublicObservedValue(context.destination.accountType),
|
|
205
|
+
expected: params.allowedValues.join(", "),
|
|
206
|
+
}),
|
|
207
|
+
];
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
const AccountNumberDigitsParamsSchema = z.strictObject({ asciiDigitsOnly: z.literal(true) });
|
|
211
|
+
export const accountNumberDigitsRule = defineBankRule({
|
|
212
|
+
id: "BANK-NUMBER-001",
|
|
213
|
+
defaultSeverity: "error",
|
|
214
|
+
paramsSchema: AccountNumberDigitsParamsSchema,
|
|
215
|
+
evaluate(context, _params, rule) {
|
|
216
|
+
if (/^[0-9]+$/u.test(context.destination.accountNumber)) {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
return [
|
|
220
|
+
finding(rule, context, {
|
|
221
|
+
messageKey: "bank.account_number.invalid_characters",
|
|
222
|
+
message: "Account number must contain only ASCII digits.",
|
|
223
|
+
path: "destination.accountNumber",
|
|
224
|
+
actual: maskBankAccountNumber(context.destination.accountNumber),
|
|
225
|
+
expected: "one or more ASCII digits",
|
|
226
|
+
remediation: {
|
|
227
|
+
code: "confirm_bank_selection",
|
|
228
|
+
message: "Confirm the account number without converting or padding it automatically.",
|
|
229
|
+
},
|
|
230
|
+
}),
|
|
231
|
+
];
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
const AccountNumberLengthParamsSchema = z
|
|
235
|
+
.strictObject({
|
|
236
|
+
minDigits: z.number().int().nonnegative().max(128),
|
|
237
|
+
maxDigits: z.number().int().nonnegative().max(128),
|
|
238
|
+
})
|
|
239
|
+
.refine((params) => params.minDigits <= params.maxDigits, {
|
|
240
|
+
message: "Minimum digits must not exceed maximum digits",
|
|
241
|
+
path: ["minDigits"],
|
|
242
|
+
});
|
|
243
|
+
export const accountNumberLengthRule = defineBankRule({
|
|
244
|
+
id: "BANK-NUMBER-002",
|
|
245
|
+
defaultSeverity: "error",
|
|
246
|
+
paramsSchema: AccountNumberLengthParamsSchema,
|
|
247
|
+
evaluate(context, params, rule) {
|
|
248
|
+
const length = context.destination.accountNumber.length;
|
|
249
|
+
if (length >= params.minDigits && length <= params.maxDigits) {
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
return [
|
|
253
|
+
finding(rule, context, {
|
|
254
|
+
messageKey: "bank.account_number.invalid_length",
|
|
255
|
+
message: "Account number length is outside the selected Profile limits.",
|
|
256
|
+
path: "destination.accountNumber",
|
|
257
|
+
actual: maskBankAccountNumber(context.destination.accountNumber),
|
|
258
|
+
expected: `${params.minDigits} to ${params.maxDigits} characters`,
|
|
259
|
+
remediation: {
|
|
260
|
+
code: "confirm_bank_selection",
|
|
261
|
+
message: "Confirm the account number without adding or removing leading zeroes.",
|
|
262
|
+
},
|
|
263
|
+
}),
|
|
264
|
+
];
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
const AccountHolderRequiredParamsSchema = z.strictObject({ required: z.literal(true) });
|
|
268
|
+
export const accountHolderRequiredRule = defineBankRule({
|
|
269
|
+
id: "BANK-HOLDER-001",
|
|
270
|
+
defaultSeverity: "error",
|
|
271
|
+
paramsSchema: AccountHolderRequiredParamsSchema,
|
|
272
|
+
evaluate(context, _params, rule) {
|
|
273
|
+
if (context.destination.accountHolder.trim().length > 0) {
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
return [
|
|
277
|
+
finding(rule, context, {
|
|
278
|
+
messageKey: "bank.account_holder.required",
|
|
279
|
+
message: "Account holder is empty after a non-mutating presence check.",
|
|
280
|
+
path: "destination.accountHolder",
|
|
281
|
+
actual: redactAccountHolder(context.destination.accountHolder),
|
|
282
|
+
expected: "a non-whitespace account holder value",
|
|
283
|
+
remediation: {
|
|
284
|
+
code: "compare_registered_account_name",
|
|
285
|
+
message: "Compare the value with the registered account name.",
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
];
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
export const accountHolderWhitespaceRule = defineBankRule({
|
|
292
|
+
id: "BANK-HOLDER-002",
|
|
293
|
+
defaultSeverity: "warning",
|
|
294
|
+
paramsSchema: EmptyParamsSchema,
|
|
295
|
+
evaluate(context, _params, rule) {
|
|
296
|
+
if (context.destination.accountHolder === context.destination.accountHolder.trim()) {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
return [
|
|
300
|
+
finding(rule, context, {
|
|
301
|
+
messageKey: "bank.account_holder.surrounding_whitespace",
|
|
302
|
+
message: "Account holder contains leading or trailing whitespace.",
|
|
303
|
+
path: "destination.accountHolder",
|
|
304
|
+
actual: redactAccountHolder(context.destination.accountHolder),
|
|
305
|
+
remediation: {
|
|
306
|
+
code: "compare_registered_account_name",
|
|
307
|
+
message: "Review surrounding whitespace without changing the value automatically.",
|
|
308
|
+
},
|
|
309
|
+
}),
|
|
310
|
+
];
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
const AccountHolderControlParamsSchema = z.strictObject({
|
|
314
|
+
rejectControlCharacters: z.literal(true),
|
|
315
|
+
});
|
|
316
|
+
const forbiddenInvisiblePattern = /[\p{Cc}\p{Cf}]/u;
|
|
317
|
+
export const accountHolderControlCharacterRule = defineBankRule({
|
|
318
|
+
id: "BANK-HOLDER-003",
|
|
319
|
+
defaultSeverity: "error",
|
|
320
|
+
paramsSchema: AccountHolderControlParamsSchema,
|
|
321
|
+
evaluate(context, _params, rule) {
|
|
322
|
+
if (!forbiddenInvisiblePattern.test(context.destination.accountHolder)) {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
return [
|
|
326
|
+
finding(rule, context, {
|
|
327
|
+
messageKey: "bank.account_holder.forbidden_invisible_character",
|
|
328
|
+
message: "Account holder contains a forbidden control or invisible format character.",
|
|
329
|
+
path: "destination.accountHolder",
|
|
330
|
+
actual: redactAccountHolder(context.destination.accountHolder),
|
|
331
|
+
remediation: {
|
|
332
|
+
code: "remove_invisible_character",
|
|
333
|
+
message: "Remove the invisible character only after reviewing the source value.",
|
|
334
|
+
},
|
|
335
|
+
}),
|
|
336
|
+
];
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
const UnicodeNormalizationParamsSchema = z.strictObject({
|
|
340
|
+
unicodeNormalization: z.enum(["NFC", "NFD", "NFKC", "NFKD"]),
|
|
341
|
+
});
|
|
342
|
+
export const accountHolderUnicodeNormalizationRule = defineBankRule({
|
|
343
|
+
id: "BANK-HOLDER-004",
|
|
344
|
+
defaultSeverity: "warning",
|
|
345
|
+
paramsSchema: UnicodeNormalizationParamsSchema,
|
|
346
|
+
evaluate(context, params, rule) {
|
|
347
|
+
if (context.destination.accountHolder ===
|
|
348
|
+
context.destination.accountHolder.normalize(params.unicodeNormalization)) {
|
|
349
|
+
return [];
|
|
350
|
+
}
|
|
351
|
+
return [
|
|
352
|
+
finding(rule, context, {
|
|
353
|
+
messageKey: "bank.account_holder.unicode_normalization_differs",
|
|
354
|
+
message: "Account holder differs under the configured Unicode normalization form.",
|
|
355
|
+
path: "destination.accountHolder",
|
|
356
|
+
actual: redactAccountHolder(context.destination.accountHolder),
|
|
357
|
+
expected: params.unicodeNormalization,
|
|
358
|
+
remediation: {
|
|
359
|
+
code: "review_unicode_normalization",
|
|
360
|
+
message: "Review normalization requirements; no replacement was applied.",
|
|
361
|
+
},
|
|
362
|
+
}),
|
|
363
|
+
];
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
const AccountHolderCharsetParamsSchema = z.strictObject({
|
|
367
|
+
allowedCharacters: z.string().min(1).max(10_000),
|
|
368
|
+
});
|
|
369
|
+
export const accountHolderCharsetRule = defineBankRule({
|
|
370
|
+
id: "BANK-HOLDER-005",
|
|
371
|
+
defaultSeverity: "error",
|
|
372
|
+
paramsSchema: AccountHolderCharsetParamsSchema,
|
|
373
|
+
evaluate(context, params, rule) {
|
|
374
|
+
const allowed = new Set(params.allowedCharacters);
|
|
375
|
+
if ([...context.destination.accountHolder].every((character) => allowed.has(character))) {
|
|
376
|
+
return [];
|
|
377
|
+
}
|
|
378
|
+
return [
|
|
379
|
+
finding(rule, context, {
|
|
380
|
+
messageKey: "bank.account_holder.character_not_allowed",
|
|
381
|
+
message: "Account holder contains a character outside the Profile-declared set.",
|
|
382
|
+
path: "destination.accountHolder",
|
|
383
|
+
actual: redactAccountHolder(context.destination.accountHolder),
|
|
384
|
+
expected: "only characters declared by the selected Profile",
|
|
385
|
+
remediation: {
|
|
386
|
+
code: "compare_registered_account_name",
|
|
387
|
+
message: "Compare the value with the character requirements of the selected Profile.",
|
|
388
|
+
},
|
|
389
|
+
}),
|
|
390
|
+
];
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
const AccountHolderByteLengthParamsSchema = z.strictObject({
|
|
394
|
+
encoding: z.literal("utf8"),
|
|
395
|
+
maxBytes: PositiveBoundedIntegerSchema,
|
|
396
|
+
});
|
|
397
|
+
export const accountHolderEncodedByteLengthRule = defineBankRule({
|
|
398
|
+
id: "BANK-HOLDER-006",
|
|
399
|
+
defaultSeverity: "error",
|
|
400
|
+
paramsSchema: AccountHolderByteLengthParamsSchema,
|
|
401
|
+
evaluate(context, params, rule) {
|
|
402
|
+
const byteLength = Buffer.byteLength(context.destination.accountHolder, params.encoding);
|
|
403
|
+
if (byteLength <= params.maxBytes) {
|
|
404
|
+
return [];
|
|
405
|
+
}
|
|
406
|
+
return [
|
|
407
|
+
finding(rule, context, {
|
|
408
|
+
messageKey: "bank.account_holder.encoded_length_exceeded",
|
|
409
|
+
message: "Account holder encoded byte length exceeds the selected Profile limit.",
|
|
410
|
+
path: "destination.accountHolder",
|
|
411
|
+
actual: createMetadataObservedValue(`encoded bytes: ${byteLength}`),
|
|
412
|
+
expected: `at most ${params.maxBytes} bytes in ${params.encoding}`,
|
|
413
|
+
remediation: {
|
|
414
|
+
code: "compare_registered_account_name",
|
|
415
|
+
message: "Review the account holder against the selected Profile byte limit.",
|
|
416
|
+
},
|
|
417
|
+
}),
|
|
418
|
+
];
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
/** All non-experimental M2 Bank rules, in stable RuleId order. */
|
|
422
|
+
export const bankRules = Object.freeze([
|
|
423
|
+
branchCodeSyntaxRule,
|
|
424
|
+
branchCodeExistsRule,
|
|
425
|
+
branchOwnershipRule,
|
|
426
|
+
bankCodeSyntaxRule,
|
|
427
|
+
bankCodeExistsRule,
|
|
428
|
+
accountHolderRequiredRule,
|
|
429
|
+
accountHolderWhitespaceRule,
|
|
430
|
+
accountHolderControlCharacterRule,
|
|
431
|
+
accountHolderUnicodeNormalizationRule,
|
|
432
|
+
accountHolderCharsetRule,
|
|
433
|
+
accountHolderEncodedByteLengthRule,
|
|
434
|
+
accountNumberDigitsRule,
|
|
435
|
+
accountNumberLengthRule,
|
|
436
|
+
accountTypeAllowedRule,
|
|
437
|
+
].sort((left, right) => compareStrings(left.id, right.id)));
|
|
438
|
+
/** Canonical account-type values useful when constructing a Profile parameter allowlist. */
|
|
439
|
+
export const allBankAccountTypes = Object.freeze([
|
|
440
|
+
"ordinary",
|
|
441
|
+
"checking",
|
|
442
|
+
"savings",
|
|
443
|
+
"other",
|
|
444
|
+
]);
|
|
445
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,GAKpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,GAGtB,MAAM,kBAAkB,CAAC;AAU1B,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AAC7C,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAWhF,SAAS,OAAO,CACd,IAA6B,EAC7B,OAAoC,EACpC,UAA6B;IAE7B,OAAO;QACL,aAAa,EAAE,GAAG;QAClB,MAAM,EAAE,IAAI,CAAC,EAAE;QACf,QAAQ,EAAE,IAAI,CAAC,eAAe;QAC9B,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE;QAC1C,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;Q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F,IAAI,EAAE,2BAA2B;gBACjC,MAAM,EAAE,2BAA2B,CAAC,kBAAkB,UAAU,EAAE,CAAC;gBACnE,QAAQ,EAAE,WAAW,MAAM,CAAC,QAAQ,aAAa,MAAM,CAAC,QAAQ,EAAE;gBAClE,WAAW,EAAE;oBACX,IAAI,EAAE,iCAAiC;oBACvC,OAAO,EAAE,oEAAoE;iBAC9E;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CACpC;IACE,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,yBAAyB;IACzB,2BAA2B;IAC3B,iCAAiC;IACjC,qCAAqC;IACrC,wBAAwB;IACxB,kCAAkC;IAClC,uBAAuB;IACvB,uBAAuB;IACvB,sBAAsB;CACvB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAC3D,CAAC;AAEF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAA+B,MAAM,CAAC,MAAM,CAAC;IAC3E,UAAU;IACV,UAAU;IACV,SAAS;IACT,OAAO;CACR,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CompatibilityProfileV1, type FindingV1, type RegistryEnvelopeV1 } from "@payoutjp/core";
|
|
2
|
+
import { type BankDirectoryRegistryV1 } from "./registry.js";
|
|
3
|
+
export interface ValidateBankTransferDestinationV1Options {
|
|
4
|
+
readonly profile?: CompatibilityProfileV1;
|
|
5
|
+
readonly registries?: ReadonlyMap<string, RegistryEnvelopeV1<BankDirectoryRegistryV1>>;
|
|
6
|
+
readonly itemIndex?: number;
|
|
7
|
+
readonly allowExperimental?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validates one destination synchronously against an exact local Profile and Registry set.
|
|
11
|
+
* No normalization, network access, or input mutation is performed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateBankTransferDestinationV1(input: unknown, options?: ValidateBankTransferDestinationV1Options): readonly FindingV1[];
|
|
14
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAG3B,KAAK,SAAS,EAKd,KAAK,kBAAkB,EAExB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,uBAAuB,EAA+B,MAAM,eAAe,CAAC;AAK1F,MAAM,WAAW,wCAAwC;IACvD,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACvF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAyDD;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,wCAA6C,GACrD,SAAS,SAAS,EAAE,CAgDtB"}
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createItemId, executeRules, loadCompatibilityProfileV1, PayoutJpConfigurationError, PayoutJpInputError, PayoutJpIntegrityError, } from "@payoutjp/core";
|
|
2
|
+
import { BankTransferDestinationV1Schema } from "./destination.js";
|
|
3
|
+
import { bankGenericJpProfileV1 } from "./profile.js";
|
|
4
|
+
import { loadBankDirectoryRegistryV1 } from "./registry.js";
|
|
5
|
+
import { bankRules } from "./rules.js";
|
|
6
|
+
const registryRuleIds = new Set(["BANK-CODE-002", "BANK-BRANCH-002", "BANK-BRANCH-003"]);
|
|
7
|
+
function validateItemIndex(value) {
|
|
8
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
9
|
+
throw new PayoutJpConfigurationError("PJP_CONFIG_INVALID");
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
function selectReferencedRegistries(profile, registries) {
|
|
14
|
+
const selected = new Map();
|
|
15
|
+
for (const reference of profile.registries) {
|
|
16
|
+
const registry = registries.get(reference.id);
|
|
17
|
+
if (registry === undefined || registry.version !== reference.version) {
|
|
18
|
+
throw new PayoutJpIntegrityError("PJP_REGISTRY_NOT_FOUND");
|
|
19
|
+
}
|
|
20
|
+
if (registry.sha256 !== reference.sha256) {
|
|
21
|
+
throw new PayoutJpIntegrityError("PJP_REGISTRY_DIGEST_MISMATCH");
|
|
22
|
+
}
|
|
23
|
+
selected.set(registry.id, registry);
|
|
24
|
+
}
|
|
25
|
+
return selected;
|
|
26
|
+
}
|
|
27
|
+
function verifyRegistries(registries) {
|
|
28
|
+
const verified = new Map();
|
|
29
|
+
for (const [key, input] of registries) {
|
|
30
|
+
const registry = loadBankDirectoryRegistryV1(input);
|
|
31
|
+
if (key !== registry.id) {
|
|
32
|
+
throw new PayoutJpIntegrityError("PJP_REGISTRY_INVALID");
|
|
33
|
+
}
|
|
34
|
+
verified.set(key, registry);
|
|
35
|
+
}
|
|
36
|
+
return verified;
|
|
37
|
+
}
|
|
38
|
+
function effectiveRule(rule, severity) {
|
|
39
|
+
if (severity === undefined) {
|
|
40
|
+
return rule;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
...rule,
|
|
44
|
+
defaultSeverity: severity,
|
|
45
|
+
evaluate(context) {
|
|
46
|
+
return rule.evaluate(context).map((entry) => ({ ...entry, severity }));
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validates one destination synchronously against an exact local Profile and Registry set.
|
|
52
|
+
* No normalization, network access, or input mutation is performed.
|
|
53
|
+
*/
|
|
54
|
+
export function validateBankTransferDestinationV1(input, options = {}) {
|
|
55
|
+
const parsed = BankTransferDestinationV1Schema.safeParse(input);
|
|
56
|
+
if (!parsed.success) {
|
|
57
|
+
throw new PayoutJpInputError();
|
|
58
|
+
}
|
|
59
|
+
const destination = parsed.data;
|
|
60
|
+
const profile = loadCompatibilityProfileV1(options.profile ?? bankGenericJpProfileV1, {
|
|
61
|
+
rules: bankRules,
|
|
62
|
+
...(options.allowExperimental === undefined
|
|
63
|
+
? {}
|
|
64
|
+
: { allowExperimental: options.allowExperimental }),
|
|
65
|
+
});
|
|
66
|
+
if (profile.rail !== "bank_transfer") {
|
|
67
|
+
throw new PayoutJpConfigurationError("PJP_CONFIG_INVALID");
|
|
68
|
+
}
|
|
69
|
+
const itemIndex = validateItemIndex(options.itemIndex ?? 0);
|
|
70
|
+
const itemId = createItemId(destination.id ?? `item-${String(itemIndex + 1).padStart(6, "0")}`);
|
|
71
|
+
const verifiedRegistries = verifyRegistries(options.registries ?? new Map());
|
|
72
|
+
const registries = selectReferencedRegistries(profile, verifiedRegistries);
|
|
73
|
+
const enabledConfigurations = profile.rules.filter((configuration) => configuration.enabled);
|
|
74
|
+
if (enabledConfigurations.some((configuration) => registryRuleIds.has(configuration.id)) &&
|
|
75
|
+
profile.registries.length === 0) {
|
|
76
|
+
throw new PayoutJpIntegrityError("PJP_REGISTRY_NOT_FOUND");
|
|
77
|
+
}
|
|
78
|
+
const ruleById = new Map(bankRules.map((rule) => [rule.id, rule]));
|
|
79
|
+
const paramsById = new Map();
|
|
80
|
+
const selectedRules = enabledConfigurations.map((configuration) => {
|
|
81
|
+
const rule = ruleById.get(configuration.id);
|
|
82
|
+
if (rule === undefined) {
|
|
83
|
+
throw new PayoutJpConfigurationError("PJP_RULE_UNKNOWN");
|
|
84
|
+
}
|
|
85
|
+
paramsById.set(rule.id, rule.parseParams(configuration.params));
|
|
86
|
+
return effectiveRule(rule, configuration.severity);
|
|
87
|
+
});
|
|
88
|
+
return executeRules(selectedRules, (rule) => ({
|
|
89
|
+
destination,
|
|
90
|
+
profile,
|
|
91
|
+
params: paramsById.get(rule.id) ?? {},
|
|
92
|
+
registries,
|
|
93
|
+
itemIndex,
|
|
94
|
+
itemId,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,YAAY,EAEZ,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EAClB,sBAAsB,GAGvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAkC,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAgC,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAA0B,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC,CAAC;AASzF,SAAS,iBAAiB,CAAC,KAAa;IACtC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,0BAA0B,CACjC,OAA+B,EAC/B,UAA4E;IAE5E,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuD,CAAC;IAChF,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,C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|
2
|
+
"name": "@payoutjp/bank",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Conservative Japanese bank destination validation for PayoutJP",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/inthecradle/payoutjp.git",
|
|
9
|
+
"directory": "packages/bank"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/inthecradle/payoutjp#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/inthecradle/payoutjp/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=24 <25"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@payoutjp/core": "0.1.0-alpha.1",
|
|
35
|
+
"zod": "^4.5.4"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -b tsconfig.build.json",
|
|
39
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"test:coverage": "vitest run --coverage",
|
|
42
|
+
"clean": "tsc -b tsconfig.build.json --clean"
|
|
43
|
+
}
|
|
44
|
+
}
|