pakdatakit 2.1.2 → 2.2.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.
Files changed (84) hide show
  1. package/DATA.md +105 -0
  2. package/README.md +94 -9
  3. package/dist/address.cjs +4 -4
  4. package/dist/address.d.cts +2 -1
  5. package/dist/address.d.ts +2 -1
  6. package/dist/address.js +2 -2
  7. package/dist/{chunk-PHHKIMO2.cjs → chunk-33FXHM2E.cjs} +5 -5
  8. package/dist/{chunk-3COX5FSL.cjs → chunk-34CJGJ67.cjs} +53 -6
  9. package/dist/chunk-3IARSCO6.cjs +317 -0
  10. package/dist/{chunk-BSS4Z7NI.cjs → chunk-3ZA265SK.cjs} +2 -2
  11. package/dist/{chunk-AUATLZA5.cjs → chunk-47P7HILD.cjs} +4 -4
  12. package/dist/{chunk-Q7XHVR3U.cjs → chunk-4VSGCQ6K.cjs} +86 -15
  13. package/dist/{chunk-Y6BUGLXU.js → chunk-6IPPANNX.js} +4 -1
  14. package/dist/{chunk-L45UXUWX.js → chunk-AZV45DMG.js} +1 -1
  15. package/dist/{chunk-QQQKISXT.js → chunk-BR4QLZPX.js} +11 -2
  16. package/dist/{chunk-K6CZFCX6.js → chunk-E6DT2DWQ.js} +53 -6
  17. package/dist/{chunk-P4CGOJEM.js → chunk-EMH4IP2U.js} +1 -1
  18. package/dist/{chunk-JNP27XW2.cjs → chunk-GJENL6VK.cjs} +6 -6
  19. package/dist/{chunk-APXP7OK7.cjs → chunk-HIZQBWNW.cjs} +11 -2
  20. package/dist/{chunk-YS7MOLK2.cjs → chunk-HTERSQGF.cjs} +3 -3
  21. package/dist/{chunk-E7GAK72W.js → chunk-HUQY2WR5.js} +3 -3
  22. package/dist/{chunk-KQKW2ZEK.cjs → chunk-NAJGGUAM.cjs} +2 -2
  23. package/dist/{chunk-YLWZGSFY.cjs → chunk-NTD4JLDW.cjs} +4 -0
  24. package/dist/{chunk-R7UTY3SY.js → chunk-NZQ47NWD.js} +84 -14
  25. package/dist/{chunk-432ZYMYV.js → chunk-PLDVGOKZ.js} +2 -2
  26. package/dist/{chunk-L2BDDM2W.js → chunk-QKH7W2CC.js} +1 -1
  27. package/dist/{chunk-T3E4B5MJ.js → chunk-RXNYY5K5.js} +1 -1
  28. package/dist/chunk-TTARJWGT.js +82 -0
  29. package/dist/chunk-U7MWHXMF.cjs +89 -0
  30. package/dist/chunk-YPPKY5XZ.js +312 -0
  31. package/dist/cli.js +1 -1
  32. package/dist/cnic.d.cts +2 -1
  33. package/dist/cnic.d.ts +2 -1
  34. package/dist/geo.cjs +6 -6
  35. package/dist/geo.js +1 -1
  36. package/dist/hijri.d.cts +2 -1
  37. package/dist/hijri.d.ts +2 -1
  38. package/dist/holidays.d.cts +4 -2
  39. package/dist/holidays.d.ts +4 -2
  40. package/dist/iban.cjs +11 -3
  41. package/dist/iban.d.cts +46 -1
  42. package/dist/iban.d.ts +46 -1
  43. package/dist/iban.js +1 -1
  44. package/dist/index.cjs +76 -37
  45. package/dist/index.d.cts +11 -2
  46. package/dist/index.d.ts +11 -2
  47. package/dist/index.js +16 -10
  48. package/dist/input.cjs +34 -0
  49. package/dist/input.d.cts +68 -0
  50. package/dist/input.d.ts +68 -0
  51. package/dist/input.js +5 -0
  52. package/dist/networks.cjs +3 -3
  53. package/dist/networks.d.cts +2 -1
  54. package/dist/networks.d.ts +2 -1
  55. package/dist/networks.js +2 -2
  56. package/dist/numbers.cjs +6 -6
  57. package/dist/numbers.d.cts +2 -1
  58. package/dist/numbers.d.ts +2 -1
  59. package/dist/numbers.js +2 -2
  60. package/dist/phone.cjs +8 -8
  61. package/dist/phone.d.cts +2 -1
  62. package/dist/phone.d.ts +2 -1
  63. package/dist/phone.js +3 -3
  64. package/dist/raast.cjs +9 -5
  65. package/dist/raast.d.cts +54 -8
  66. package/dist/raast.d.ts +54 -8
  67. package/dist/raast.js +2 -2
  68. package/dist/tax.d.cts +2 -1
  69. package/dist/tax.d.ts +2 -1
  70. package/dist/valibot.cjs +7 -7
  71. package/dist/valibot.js +6 -6
  72. package/dist/whatsapp.cjs +3 -3
  73. package/dist/whatsapp.js +2 -2
  74. package/dist/words.cjs +3 -3
  75. package/dist/words.d.cts +2 -1
  76. package/dist/words.d.ts +2 -1
  77. package/dist/words.js +1 -1
  78. package/dist/yup.cjs +7 -7
  79. package/dist/yup.js +6 -6
  80. package/dist/zod.cjs +7 -7
  81. package/dist/zod.js +6 -6
  82. package/package.json +24 -11
  83. package/dist/chunk-4EUKCSLW.js +0 -221
  84. package/dist/chunk-E47SNBWQ.cjs +0 -224
@@ -0,0 +1,317 @@
1
+ 'use strict';
2
+
3
+ var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
4
+
5
+ // data/banks.json
6
+ var banks_default = [
7
+ {
8
+ code: "ABPA",
9
+ name: "Allied Bank Limited",
10
+ type: "commercial"
11
+ },
12
+ {
13
+ code: "AIIN",
14
+ name: "Al Baraka Bank (Pakistan) Limited",
15
+ type: "islamic"
16
+ },
17
+ {
18
+ code: "ALFH",
19
+ name: "Bank Alfalah Limited",
20
+ type: "commercial"
21
+ },
22
+ {
23
+ code: "APNA",
24
+ name: "Apna Microfinance Bank",
25
+ type: "microfinance"
26
+ },
27
+ {
28
+ code: "ASCM",
29
+ name: "Askari Bank Limited",
30
+ type: "commercial"
31
+ },
32
+ {
33
+ code: "BAHL",
34
+ name: "Bank Al Habib Limited",
35
+ type: "commercial"
36
+ },
37
+ {
38
+ code: "BKCH",
39
+ name: "Bank of China Limited",
40
+ type: "foreign"
41
+ },
42
+ {
43
+ code: "BKIP",
44
+ name: "BankIslami Pakistan Limited",
45
+ type: "islamic"
46
+ },
47
+ {
48
+ code: "BPUN",
49
+ name: "The Bank of Punjab",
50
+ type: "commercial"
51
+ },
52
+ {
53
+ code: "CITI",
54
+ name: "Citibank N.A. Pakistan",
55
+ type: "foreign"
56
+ },
57
+ {
58
+ code: "DEUT",
59
+ name: "Deutsche Bank AG",
60
+ type: "foreign"
61
+ },
62
+ {
63
+ code: "DUIB",
64
+ name: "Dubai Islamic Bank Pakistan Limited",
65
+ type: "islamic"
66
+ },
67
+ {
68
+ code: "FAYS",
69
+ name: "Faysal Bank Limited",
70
+ type: "islamic"
71
+ },
72
+ {
73
+ code: "FINC",
74
+ name: "ABHI Microfinance Bank (formerly FINCA Microfinance Bank)",
75
+ type: "microfinance"
76
+ },
77
+ {
78
+ code: "FMFB",
79
+ name: "HBL Microfinance Bank (formerly First MicroFinance Bank)",
80
+ type: "microfinance"
81
+ },
82
+ {
83
+ code: "FWOM",
84
+ name: "First Women Bank Limited",
85
+ type: "commercial"
86
+ },
87
+ {
88
+ code: "HABB",
89
+ name: "Habib Bank Limited",
90
+ type: "commercial"
91
+ },
92
+ {
93
+ code: "ICBK",
94
+ name: "Industrial and Commercial Bank of China",
95
+ type: "foreign"
96
+ },
97
+ {
98
+ code: "JCMA",
99
+ name: "Mobilink Bank (JazzCash)",
100
+ type: "microfinance"
101
+ },
102
+ {
103
+ code: "JSBL",
104
+ name: "JS Bank Limited",
105
+ type: "commercial"
106
+ },
107
+ {
108
+ code: "KHBL",
109
+ name: "Khushhali Microfinance Bank",
110
+ type: "microfinance"
111
+ },
112
+ {
113
+ code: "KHYB",
114
+ name: "The Bank of Khyber",
115
+ type: "commercial"
116
+ },
117
+ {
118
+ code: "MCBL",
119
+ name: "MCB Bank Limited",
120
+ type: "commercial",
121
+ aliasOf: "MUCB"
122
+ },
123
+ {
124
+ code: "MCIB",
125
+ name: "MCB Islamic Bank Limited",
126
+ type: "islamic"
127
+ },
128
+ {
129
+ code: "MEZN",
130
+ name: "Meezan Bank Limited",
131
+ type: "islamic"
132
+ },
133
+ {
134
+ code: "MPBL",
135
+ name: "Habib Metropolitan Bank Limited",
136
+ type: "commercial"
137
+ },
138
+ {
139
+ code: "MSHQ",
140
+ name: "Mashreq Bank Pakistan Limited",
141
+ type: "digital"
142
+ },
143
+ {
144
+ code: "MUCB",
145
+ name: "MCB Bank Limited",
146
+ type: "commercial"
147
+ },
148
+ {
149
+ code: "NAYA",
150
+ name: "NayaPay",
151
+ type: "emi"
152
+ },
153
+ {
154
+ code: "NBPA",
155
+ name: "National Bank of Pakistan",
156
+ type: "commercial"
157
+ },
158
+ {
159
+ code: "NBPB",
160
+ name: "National Bank of Pakistan",
161
+ type: "commercial",
162
+ aliasOf: "NBPA"
163
+ },
164
+ {
165
+ code: "NIBP",
166
+ name: "NIB Bank Limited (merged into MCB Bank)",
167
+ type: "commercial",
168
+ mergedInto: "MUCB"
169
+ },
170
+ {
171
+ code: "NRSP",
172
+ name: "NRSP Microfinance Bank",
173
+ type: "microfinance"
174
+ },
175
+ {
176
+ code: "RQMI",
177
+ name: "Raqami Islamic Digital Bank Limited",
178
+ type: "digital"
179
+ },
180
+ {
181
+ code: "SADA",
182
+ name: "SadaPay",
183
+ type: "emi"
184
+ },
185
+ {
186
+ code: "SAMB",
187
+ name: "Samba Bank Limited",
188
+ type: "commercial"
189
+ },
190
+ {
191
+ code: "SAUD",
192
+ name: "Silkbank Limited (merged into United Bank Limited)",
193
+ type: "commercial",
194
+ mergedInto: "UNIL"
195
+ },
196
+ {
197
+ code: "SBPP",
198
+ name: "State Bank of Pakistan",
199
+ type: "central"
200
+ },
201
+ {
202
+ code: "SCBL",
203
+ name: "Standard Chartered Bank (Pakistan) Limited",
204
+ type: "commercial"
205
+ },
206
+ {
207
+ code: "SIND",
208
+ name: "Sindh Bank Limited",
209
+ type: "commercial"
210
+ },
211
+ {
212
+ code: "SMES",
213
+ name: "SME Bank Limited",
214
+ type: "specialized"
215
+ },
216
+ {
217
+ code: "SONE",
218
+ name: "Soneri Bank Limited",
219
+ type: "commercial"
220
+ },
221
+ {
222
+ code: "SUMB",
223
+ name: "Bank Makramah Limited (formerly Summit Bank)",
224
+ type: "commercial"
225
+ },
226
+ {
227
+ code: "TAMW",
228
+ name: "easypaisa Digital Bank (formerly Tameer Microfinance Bank)",
229
+ type: "digital",
230
+ aliasOf: "TMFB"
231
+ },
232
+ {
233
+ code: "TMFB",
234
+ name: "easypaisa Digital Bank (formerly Telenor Microfinance Bank)",
235
+ type: "digital"
236
+ },
237
+ {
238
+ code: "UMBL",
239
+ name: "U Microfinance Bank",
240
+ type: "microfinance"
241
+ },
242
+ {
243
+ code: "UNIL",
244
+ name: "United Bank Limited",
245
+ type: "commercial"
246
+ },
247
+ {
248
+ code: "WMBL",
249
+ name: "Mobilink Bank (JazzCash)",
250
+ type: "microfinance",
251
+ aliasOf: "JCMA"
252
+ }
253
+ ];
254
+
255
+ // src/iban.ts
256
+ var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
257
+ var banks = chunkVPBMIYO2_cjs.lazy(
258
+ () => banks_default.map((entry) => ({
259
+ code: entry.code,
260
+ name: entry.name,
261
+ type: entry.type,
262
+ active: entry.mergedInto === void 0,
263
+ mergedInto: entry.mergedInto ?? null,
264
+ aliasOf: entry.aliasOf ?? null
265
+ }))
266
+ );
267
+ var bankByCode = chunkVPBMIYO2_cjs.lazy(
268
+ () => new Map(banks().map((bank) => [bank.code, bank]))
269
+ );
270
+ function expandIbanChars(value) {
271
+ return value.replace(
272
+ /[A-Z]/g,
273
+ (char) => (char.charCodeAt(0) - 55).toString()
274
+ );
275
+ }
276
+ function mod97(numericIban) {
277
+ let remainder = 0;
278
+ for (const digit of numericIban) {
279
+ remainder = (remainder * 10 + Number(digit)) % 97;
280
+ }
281
+ return remainder;
282
+ }
283
+ function normalizeIBAN(iban) {
284
+ return chunkVPBMIYO2_cjs.stripSeparators(iban).toUpperCase();
285
+ }
286
+ function validateIBAN(iban) {
287
+ const normalized = normalizeIBAN(iban);
288
+ if (!PK_IBAN_PATTERN.test(normalized)) {
289
+ return false;
290
+ }
291
+ const rearranged = normalized.slice(4) + normalized.slice(0, 4);
292
+ return mod97(expandIbanChars(rearranged)) === 1;
293
+ }
294
+ function getBankFromIBAN(iban) {
295
+ if (!validateIBAN(iban)) {
296
+ return null;
297
+ }
298
+ return bankByCode().get(normalizeIBAN(iban).slice(4, 8))?.name ?? null;
299
+ }
300
+ function getBankInfo(ibanOrCode) {
301
+ const value = normalizeIBAN(ibanOrCode);
302
+ if (/^[A-Z]{4}$/.test(value)) {
303
+ return bankByCode().get(value) ?? null;
304
+ }
305
+ if (!validateIBAN(value)) {
306
+ return null;
307
+ }
308
+ return bankByCode().get(value.slice(4, 8)) ?? null;
309
+ }
310
+ function getBanks() {
311
+ return banks().map((bank) => ({ ...bank }));
312
+ }
313
+
314
+ exports.getBankFromIBAN = getBankFromIBAN;
315
+ exports.getBankInfo = getBankInfo;
316
+ exports.getBanks = getBanks;
317
+ exports.validateIBAN = validateIBAN;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkYLWZGSFY_cjs = require('./chunk-YLWZGSFY.cjs');
3
+ var chunkNTD4JLDW_cjs = require('./chunk-NTD4JLDW.cjs');
4
4
  var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
5
5
 
6
6
  // data/area-codes.json
@@ -339,7 +339,7 @@ function groupDigits(digits, size = 3) {
339
339
  return digits.match(new RegExp(`\\d{1,${size}}`, "g"))?.join("-") ?? digits;
340
340
  }
341
341
  function analyzeNumber(phone) {
342
- const mobile = chunkYLWZGSFY_cjs.normalizePhoneDigits(phone);
342
+ const mobile = chunkNTD4JLDW_cjs.normalizePhoneDigits(phone);
343
343
  if (mobile !== null) {
344
344
  const national2 = mobile.slice(2);
345
345
  return {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk4VVFS6FN_cjs = require('./chunk-4VVFS6FN.cjs');
4
- var chunk3COX5FSL_cjs = require('./chunk-3COX5FSL.cjs');
4
+ var chunk34CJGJ67_cjs = require('./chunk-34CJGJ67.cjs');
5
5
  var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
6
6
 
7
7
  // src/address.ts
@@ -9,10 +9,10 @@ function byLengthDesc(a, b) {
9
9
  return b.length - a.length;
10
10
  }
11
11
  var cityNames = chunkVPBMIYO2_cjs.lazy(
12
- () => chunk3COX5FSL_cjs.cities_default.map((entry) => entry.city).sort(byLengthDesc)
12
+ () => chunk34CJGJ67_cjs.cities_default.map((entry) => entry.city).sort(byLengthDesc)
13
13
  );
14
14
  var districtNames = chunkVPBMIYO2_cjs.lazy(
15
- () => chunk3COX5FSL_cjs.districts_default.map((entry) => entry.district).sort(byLengthDesc)
15
+ () => chunk34CJGJ67_cjs.districts_default.map((entry) => entry.district).sort(byLengthDesc)
16
16
  );
17
17
  var PROVINCES = [
18
18
  "Islamabad Capital Territory",
@@ -82,7 +82,7 @@ function parseAddress(address) {
82
82
  if (postalCode !== null && city === null) {
83
83
  city = chunk4VVFS6FN_cjs.getCityByPostalCode(postalCode);
84
84
  }
85
- const inferredProvince = city !== null ? chunk3COX5FSL_cjs.getProvince(city) ?? chunk3COX5FSL_cjs.getDistrictProvince(city) : district !== null ? chunk3COX5FSL_cjs.getDistrictProvince(district) : null;
85
+ const inferredProvince = city !== null ? chunk34CJGJ67_cjs.getProvince(city) ?? chunk34CJGJ67_cjs.getDistrictProvince(city) : district !== null ? chunk34CJGJ67_cjs.getDistrictProvince(district) : null;
86
86
  if (province === null) {
87
87
  province = inferredProvince;
88
88
  } else if (inferredProvince !== null && inferredProvince !== province) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkE47SNBWQ_cjs = require('./chunk-E47SNBWQ.cjs');
3
+ var chunk3IARSCO6_cjs = require('./chunk-3IARSCO6.cjs');
4
4
  var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
5
5
 
6
6
  // src/internal/emv.ts
@@ -57,12 +57,35 @@ function withCrc(payload) {
57
57
  // src/raast.ts
58
58
  var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
59
59
  var DEFAULT_P2P_SCHEME = "00";
60
+ var DURATION_UNITS = { m: 6e4, h: 36e5, d: 864e5 };
61
+ function resolveExpiry(expiresAt, expiresIn, now) {
62
+ if (expiresAt !== void 0 && expiresIn !== void 0) {
63
+ throw new RangeError("Use either expiresAt or expiresIn, not both");
64
+ }
65
+ if (expiresIn === void 0) return expiresAt;
66
+ let ms;
67
+ if (typeof expiresIn === "number") {
68
+ ms = expiresIn;
69
+ } else {
70
+ const match = /^(\d+(?:\.\d+)?)([mhd])$/.exec(expiresIn);
71
+ if (!match) {
72
+ throw new RangeError(
73
+ `expiresIn must be milliseconds or like '30m', '12h' or '7d', received ${expiresIn}`
74
+ );
75
+ }
76
+ ms = Number(match[1]) * DURATION_UNITS[match[2]];
77
+ }
78
+ if (!Number.isFinite(ms) || ms <= 0) {
79
+ throw new RangeError("expiresIn must be a positive duration");
80
+ }
81
+ return new Date(now.getTime() + ms);
82
+ }
60
83
  function formatAmount(amount, maxLength, label) {
61
84
  if (!Number.isFinite(amount) || amount <= 0) {
62
85
  throw new RangeError(`${label} must be a positive number`);
63
86
  }
64
87
  const text = amount.toFixed(2);
65
- if (text.length > maxLength) {
88
+ if (text.length > maxLength || !/^\d+\.\d{2}$/.test(text)) {
66
89
  throw new RangeError(`${label} is too large for a Raast QR code`);
67
90
  }
68
91
  return text;
@@ -72,7 +95,7 @@ function formatP2PAmount(amount) {
72
95
  throw new RangeError("amount must be a positive number");
73
96
  }
74
97
  const text = Number.isInteger(amount) ? String(amount) : amount.toFixed(2);
75
- if (text.length > 10) {
98
+ if (text.length > 10 || !/^\d+(\.\d+)?$/.test(text)) {
76
99
  throw new RangeError("amount is too large for a Raast QR code");
77
100
  }
78
101
  return text;
@@ -92,12 +115,17 @@ function checkLength(value, max, label) {
92
115
  }
93
116
  function normalizeIban(iban) {
94
117
  const normalized = chunkVPBMIYO2_cjs.stripSeparators(iban).toUpperCase();
95
- if (!chunkE47SNBWQ_cjs.validateIBAN(normalized)) {
118
+ if (!chunk3IARSCO6_cjs.validateIBAN(normalized)) {
96
119
  throw new RangeError(`Invalid Pakistani IBAN: ${iban}`);
97
120
  }
98
121
  return normalized;
99
122
  }
100
123
  function createRaastP2PQr(options) {
124
+ const expiresAt = resolveExpiry(
125
+ options.expiresAt,
126
+ options.expiresIn,
127
+ /* @__PURE__ */ new Date()
128
+ );
101
129
  const iban = normalizeIban(options.iban);
102
130
  let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", options.scheme ?? DEFAULT_P2P_SCHEME);
103
131
  if (options.bankName) {
@@ -114,10 +142,10 @@ function createRaastP2PQr(options) {
114
142
  );
115
143
  }
116
144
  if (options.amount !== void 0) {
117
- if (options.expiresAt === void 0) {
118
- throw new RangeError("A QR with an amount needs expiresAt");
145
+ if (expiresAt === void 0) {
146
+ throw new RangeError("A QR with an amount needs expiresAt or expiresIn");
119
147
  }
120
- payload += encodeField("07", formatExpiry(options.expiresAt));
148
+ payload += encodeField("07", formatExpiry(expiresAt));
121
149
  }
122
150
  const data = `${payload}1004`;
123
151
  return `${data}${crc16(data)}`;
@@ -141,12 +169,12 @@ function createMerchantQr(options) {
141
169
  );
142
170
  }
143
171
  const dynamic = options.dynamic ?? options.amount !== void 0;
144
- const account = accountFields.map(([id, value]) => {
172
+ for (const [id] of accountFields) {
145
173
  if (!/^\d{2}$/.test(id)) {
146
174
  throw new RangeError(`Invalid merchant account sub-field ID: ${id}`);
147
175
  }
148
- return encodeField(id, value);
149
- }).join("");
176
+ }
177
+ const account = accountFields.sort(([a], [b]) => Number(a) - Number(b)).map(([id, value]) => encodeField(id, value)).join("");
150
178
  let payload = encodeField("00", "01") + encodeField("01", dynamic ? "12" : "11") + encodeField(tag, account) + encodeField("52", mcc) + encodeField("53", "586");
151
179
  if (options.amount !== void 0) {
152
180
  payload += encodeField("54", formatAmount(options.amount, 13, "amount"));
@@ -194,10 +222,21 @@ function createMerchantQr(options) {
194
222
  function fieldValue(fields, id) {
195
223
  return fields.find((field) => field.id === id)?.value ?? null;
196
224
  }
225
+ function parseExpiry(value) {
226
+ const match = value ? /^(\d{2})(\d{2})(\d{4})(\d{2})(\d{2})$/.exec(value) : null;
227
+ if (!match) return null;
228
+ const [, dd, mm, yyyy, hh, min] = match;
229
+ const [day, month, year, hour, minute] = [dd, mm, yyyy, hh, min].map(
230
+ Number
231
+ );
232
+ const date = new Date(2e3, month - 1, day, hour, minute);
233
+ date.setFullYear(year);
234
+ const real = date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day && date.getHours() === hour && date.getMinutes() === minute;
235
+ return real ? `${yyyy}-${mm}-${dd}T${hh}:${min}` : null;
236
+ }
197
237
  function toAmount(value) {
198
- if (value === null) return null;
199
- const amount = Number(value);
200
- return Number.isFinite(amount) ? amount : null;
238
+ if (value === null || !/^\d+(\.\d+)?$/.test(value)) return null;
239
+ return Number(value);
201
240
  }
202
241
  function parseRaastQr(payload) {
203
242
  const text = payload.trim();
@@ -240,9 +279,9 @@ function parseRaastQr(payload) {
240
279
  dynamic: fieldValue(fields, "01") === "12",
241
280
  crcValid,
242
281
  iban,
243
- ibanValid: iban !== null && chunkE47SNBWQ_cjs.validateIBAN(iban),
282
+ ibanValid: iban !== null && chunk3IARSCO6_cjs.validateIBAN(iban),
244
283
  amount: toAmount(fieldValue(fields, kind === "p2p" ? "05" : "54")),
245
- expiresAt: expiry && /^\d{12}$/.test(expiry) ? `${expiry.slice(4, 8)}-${expiry.slice(2, 4)}-${expiry.slice(0, 2)}T${expiry.slice(8, 10)}:${expiry.slice(10)}` : null,
284
+ expiresAt: parseExpiry(expiry),
246
285
  bankName: kind === "p2p" ? fieldValue(fields, "03") : null,
247
286
  particulars: kind === "p2p" ? fieldValue(fields, "06") : null,
248
287
  merchantName: kind === "merchant" ? fieldValue(fields, "59") : null,
@@ -254,7 +293,39 @@ function parseRaastQr(payload) {
254
293
  fields
255
294
  };
256
295
  }
296
+ function localDateTime(value) {
297
+ const [date, time] = value.split("T");
298
+ const [year, month, day] = date.split("-").map(Number);
299
+ const [hour, minute] = time.split(":").map(Number);
300
+ return new Date(year, month - 1, day, hour, minute);
301
+ }
302
+ function validateRaastQr(payload, options = {}) {
303
+ const qr = parseRaastQr(payload);
304
+ if (qr === null) {
305
+ return { valid: false, errors: ["not-a-raast-qr"], warnings: [], qr: null };
306
+ }
307
+ const errors = [];
308
+ const warnings = [];
309
+ const now = options.now ?? /* @__PURE__ */ new Date();
310
+ if (!qr.crcValid) errors.push("bad-checksum");
311
+ if (qr.iban === null) errors.push("no-iban");
312
+ else if (!qr.ibanValid) errors.push("invalid-iban");
313
+ if (qr.kind === "p2p") {
314
+ if (qr.dynamic && qr.expiresAt === null) errors.push("missing-expiry");
315
+ if (!qr.dynamic && qr.amount !== null) warnings.push("amount-ignored");
316
+ if (qr.expiresAt !== null) {
317
+ const remaining = localDateTime(qr.expiresAt).getTime() - now.getTime();
318
+ if (remaining <= 0) {
319
+ errors.push("expired");
320
+ } else if (remaining <= (options.expiresSoonMs ?? 36e5)) {
321
+ warnings.push("expires-soon");
322
+ }
323
+ }
324
+ }
325
+ return { valid: errors.length === 0, errors, warnings, qr };
326
+ }
257
327
 
258
328
  exports.createMerchantQr = createMerchantQr;
259
329
  exports.createRaastP2PQr = createRaastP2PQr;
260
330
  exports.parseRaastQr = parseRaastQr;
331
+ exports.validateRaastQr = validateRaastQr;
@@ -63,6 +63,9 @@ var allocatedPrefixes = lazy(
63
63
  networks_default.map((entry) => entry.prefix)
64
64
  )
65
65
  );
66
+ function isAllocatedPrefix(prefix) {
67
+ return allocatedPrefixes().has(prefix);
68
+ }
66
69
  function normalizePhoneDigits(phone) {
67
70
  let digits = stripSeparators(toAsciiDigits(phone));
68
71
  if (digits.startsWith("+")) {
@@ -92,4 +95,4 @@ function getPhonePrefix(phone) {
92
95
  return `0${digits.slice(2, 5)}`;
93
96
  }
94
97
 
95
- export { getPhonePrefix, networks_default, normalizePhoneDigits };
98
+ export { getPhonePrefix, isAllocatedPrefix, networks_default, normalizePhoneDigits };
@@ -1,4 +1,4 @@
1
- import { networks_default, getPhonePrefix } from './chunk-Y6BUGLXU.js';
1
+ import { networks_default, getPhonePrefix } from './chunk-6IPPANNX.js';
2
2
  import { lazy } from './chunk-ENQ7O7VW.js';
3
3
 
4
4
  // src/networks.ts
@@ -143,6 +143,15 @@ var UR_0_TO_99 = [
143
143
  "\u0627\u0679\u06BE\u0627\u0646\u0648\u06D2",
144
144
  "\u0646\u0646\u0627\u0646\u0648\u06D2"
145
145
  ];
146
+ function resolveLanguage(language) {
147
+ const value = language ?? "en";
148
+ if (value !== "en" && value !== "ur") {
149
+ throw new RangeError(
150
+ `language must be 'en' or 'ur', received ${String(value)}`
151
+ );
152
+ }
153
+ return value;
154
+ }
146
155
  function underHundred(n, language) {
147
156
  if (language === "ur") {
148
157
  return UR_0_TO_99[n];
@@ -168,7 +177,7 @@ function convert(n, language) {
168
177
  return [underHundred(n, language)];
169
178
  }
170
179
  function numberToWords(n, options = {}) {
171
- const language = options.language ?? "en";
180
+ const language = resolveLanguage(options.language);
172
181
  if (!Number.isSafeInteger(n)) {
173
182
  throw new RangeError(`Expected a safe integer, received ${String(n)}`);
174
183
  }
@@ -188,7 +197,7 @@ function titleCase(text) {
188
197
  );
189
198
  }
190
199
  function amountInWords(amount, options = {}) {
191
- const language = options.language ?? "en";
200
+ const language = resolveLanguage(options.language);
192
201
  if (!Number.isFinite(amount) || amount < 0) {
193
202
  throw new RangeError(
194
203
  `Amount must be a finite number of zero or more, received ${String(amount)}`