pakdatakit 2.1.0 → 2.1.2

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/README.md CHANGED
@@ -369,7 +369,7 @@ getBankFromIBAN('invalid');
369
369
  // null
370
370
  ```
371
371
 
372
- Supported bank codes include HABB, MEZN, SCBL, UNIL, BAHL, NBPA, MUCB, JSBL, and 43 total entries in the dataset. Merged or renamed banks are labelled with their current name, e.g. `SAUD` → "Silkbank Limited (merged into United Bank Limited)".
372
+ Supported bank codes include HABB, MEZN, SCBL, UNIL, BAHL, NBPA, MUCB, JSBL, SADA (SadaPay), and 44 total entries in the dataset. Merged or renamed banks are labelled with their current name, e.g. `SAUD` → "Silkbank Limited (merged into United Bank Limited)".
373
373
 
374
374
  ---
375
375
 
@@ -690,14 +690,19 @@ FBR does not publish its check-digit algorithms, so these check the format only.
690
690
  Builds and reads payment QR codes following the State Bank of Pakistan's QR standard (Circular Letter No. 1 of 2022). Turn the returned string into an image with any QR library.
691
691
 
692
692
  ```ts
693
- // Person-to-person: anyone can pay this IBAN through Raast
693
+ // Person-to-person: anyone can pay this IBAN through Raast; the payer enters the amount
694
+ createRaastP2PQr({ iban: 'PK36SCBL0000001123456702' });
695
+
696
+ // With a fixed amount: banking apps require an expiry
694
697
  const payload = createRaastP2PQr({
695
698
  iban: 'PK36SCBL0000001123456702',
696
699
  amount: 1500,
700
+ expiresAt: new Date(2026, 10, 13, 23, 59),
697
701
  });
698
702
 
699
703
  parseRaastQr(payload);
700
- // { kind: 'p2p', dynamic: true, crcValid: true, iban: 'PK36SCBL0000001123456702', amount: 1500, ... }
704
+ // { kind: 'p2p', dynamic: true, crcValid: true, iban: 'PK36SCBL0000001123456702',
705
+ // amount: 1500, expiresAt: '2026-11-13T23:59', ... }
701
706
 
702
707
  // Merchant QR (EMVCo), with Pakistan-specific bill due dates
703
708
  createMerchantQr({
@@ -716,6 +721,8 @@ createMerchantQr({
716
721
  });
717
722
  ```
718
723
 
724
+ Person-to-person QR codes use the same layout as QR codes from banking apps (Faysal Bank and easypaisa without an amount; JazzCash and Mashreq with one), and scan in the Easypaisa and JazzCash apps. This is handy for accounts whose app cannot generate a receiving QR, such as SadaPay. A QR with an amount must have `expiresAt`: apps reject amount QRs without an expiry, and ignore an amount in a QR that has none.
725
+
719
726
  SBP reserves merchant-account tags 28–30 for Raast but has shared the layout of the fields inside them only with banks, so `createMerchantQr` takes those sub-fields from you. `parseRaastQr` checks the CRC and finds the IBAN in either kind of QR.
720
727
 
721
728
  ---
@@ -130,6 +130,10 @@ var banks_default = [
130
130
  code: "PAKB",
131
131
  name: "Pak Oman Microfinance Bank"
132
132
  },
133
+ {
134
+ code: "SADA",
135
+ name: "SadaPay"
136
+ },
133
137
  {
134
138
  code: "SAMB",
135
139
  name: "Samba Bank Limited"
@@ -132,6 +132,10 @@ var banks_default = [
132
132
  code: "PAKB",
133
133
  name: "Pak Oman Microfinance Bank"
134
134
  },
135
+ {
136
+ code: "SADA",
137
+ name: "SadaPay"
138
+ },
135
139
  {
136
140
  code: "SAMB",
137
141
  name: "Samba Bank Limited"
@@ -2,7 +2,7 @@ import { validateLandline } from './chunk-T3E4B5MJ.js';
2
2
  import { validatePhone } from './chunk-432ZYMYV.js';
3
3
  import { validateSTRN, validateNTN } from './chunk-CEPNSHIC.js';
4
4
  import { validateCNIC } from './chunk-EEVNLTB4.js';
5
- import { validateIBAN } from './chunk-CQKK3S7A.js';
5
+ import { validateIBAN } from './chunk-4EUKCSLW.js';
6
6
 
7
7
  // src/adapters/rules.ts
8
8
  var RULES = {
@@ -4,13 +4,13 @@ var chunkBSS4Z7NI_cjs = require('./chunk-BSS4Z7NI.cjs');
4
4
  var chunkPHHKIMO2_cjs = require('./chunk-PHHKIMO2.cjs');
5
5
  var chunkH6M6L26S_cjs = require('./chunk-H6M6L26S.cjs');
6
6
  var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
7
- var chunk422X6FEZ_cjs = require('./chunk-422X6FEZ.cjs');
7
+ var chunkE47SNBWQ_cjs = require('./chunk-E47SNBWQ.cjs');
8
8
 
9
9
  // src/adapters/rules.ts
10
10
  var RULES = {
11
11
  cnic: { test: chunkHTCSHHOR_cjs.validateCNIC, message: "Invalid CNIC number" },
12
12
  phone: { test: chunkPHHKIMO2_cjs.validatePhone, message: "Invalid Pakistani mobile number" },
13
- iban: { test: chunk422X6FEZ_cjs.validateIBAN, message: "Invalid Pakistani IBAN" },
13
+ iban: { test: chunkE47SNBWQ_cjs.validateIBAN, message: "Invalid Pakistani IBAN" },
14
14
  ntn: { test: chunkH6M6L26S_cjs.validateNTN, message: "Invalid NTN" },
15
15
  strn: { test: chunkH6M6L26S_cjs.validateSTRN, message: "Invalid STRN" },
16
16
  landline: {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk422X6FEZ_cjs = require('./chunk-422X6FEZ.cjs');
3
+ var chunkE47SNBWQ_cjs = require('./chunk-E47SNBWQ.cjs');
4
4
  var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
5
5
 
6
6
  // src/internal/emv.ts
@@ -56,7 +56,7 @@ function withCrc(payload) {
56
56
 
57
57
  // src/raast.ts
58
58
  var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
59
- var RAAST_P2P_SCHEME = "30";
59
+ var DEFAULT_P2P_SCHEME = "00";
60
60
  function formatAmount(amount, maxLength, label) {
61
61
  if (!Number.isFinite(amount) || amount <= 0) {
62
62
  throw new RangeError(`${label} must be a positive number`);
@@ -67,6 +67,23 @@ function formatAmount(amount, maxLength, label) {
67
67
  }
68
68
  return text;
69
69
  }
70
+ function formatP2PAmount(amount) {
71
+ if (!Number.isFinite(amount) || amount <= 0) {
72
+ throw new RangeError("amount must be a positive number");
73
+ }
74
+ const text = Number.isInteger(amount) ? String(amount) : amount.toFixed(2);
75
+ if (text.length > 10) {
76
+ throw new RangeError("amount is too large for a Raast QR code");
77
+ }
78
+ return text;
79
+ }
80
+ function formatExpiry(date) {
81
+ if (Number.isNaN(date.getTime())) {
82
+ throw new RangeError("expiresAt is invalid");
83
+ }
84
+ const two = (n) => String(n).padStart(2, "0");
85
+ return two(date.getDate()) + two(date.getMonth() + 1) + String(date.getFullYear()).padStart(4, "0") + two(date.getHours()) + two(date.getMinutes());
86
+ }
70
87
  function checkLength(value, max, label) {
71
88
  if ([...value].length > max) {
72
89
  throw new RangeError(`${label} must be at most ${max} characters`);
@@ -75,20 +92,20 @@ function checkLength(value, max, label) {
75
92
  }
76
93
  function normalizeIban(iban) {
77
94
  const normalized = chunkVPBMIYO2_cjs.stripSeparators(iban).toUpperCase();
78
- if (!chunk422X6FEZ_cjs.validateIBAN(normalized)) {
95
+ if (!chunkE47SNBWQ_cjs.validateIBAN(normalized)) {
79
96
  throw new RangeError(`Invalid Pakistani IBAN: ${iban}`);
80
97
  }
81
98
  return normalized;
82
99
  }
83
100
  function createRaastP2PQr(options) {
84
101
  const iban = normalizeIban(options.iban);
85
- let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", RAAST_P2P_SCHEME);
102
+ let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", options.scheme ?? DEFAULT_P2P_SCHEME);
86
103
  if (options.bankName) {
87
104
  payload += encodeField("03", checkLength(options.bankName, 25, "bankName"));
88
105
  }
89
106
  payload += encodeField("04", iban);
90
107
  if (options.amount !== void 0) {
91
- payload += encodeField("05", formatAmount(options.amount, 10, "amount"));
108
+ payload += encodeField("05", formatP2PAmount(options.amount));
92
109
  }
93
110
  if (options.particulars) {
94
111
  payload += encodeField(
@@ -96,6 +113,12 @@ function createRaastP2PQr(options) {
96
113
  checkLength(options.particulars, 30, "particulars")
97
114
  );
98
115
  }
116
+ if (options.amount !== void 0) {
117
+ if (options.expiresAt === void 0) {
118
+ throw new RangeError("A QR with an amount needs expiresAt");
119
+ }
120
+ payload += encodeField("07", formatExpiry(options.expiresAt));
121
+ }
99
122
  const data = `${payload}1004`;
100
123
  return `${data}${crc16(data)}`;
101
124
  }
@@ -211,13 +234,15 @@ function parseRaastQr(payload) {
211
234
  }
212
235
  const additional = fields.find((field) => field.id === "62")?.children ?? [];
213
236
  const due = fieldValue(additional, "50");
237
+ const expiry = kind === "p2p" ? fieldValue(fields, "07") : null;
214
238
  return {
215
239
  kind,
216
240
  dynamic: fieldValue(fields, "01") === "12",
217
241
  crcValid,
218
242
  iban,
219
- ibanValid: iban !== null && chunk422X6FEZ_cjs.validateIBAN(iban),
243
+ ibanValid: iban !== null && chunkE47SNBWQ_cjs.validateIBAN(iban),
220
244
  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,
221
246
  bankName: kind === "p2p" ? fieldValue(fields, "03") : null,
222
247
  particulars: kind === "p2p" ? fieldValue(fields, "06") : null,
223
248
  merchantName: kind === "merchant" ? fieldValue(fields, "59") : null,
@@ -1,4 +1,4 @@
1
- import { validateIBAN } from './chunk-CQKK3S7A.js';
1
+ import { validateIBAN } from './chunk-4EUKCSLW.js';
2
2
  import { stripSeparators } from './chunk-ENQ7O7VW.js';
3
3
 
4
4
  // src/internal/emv.ts
@@ -54,7 +54,7 @@ function withCrc(payload) {
54
54
 
55
55
  // src/raast.ts
56
56
  var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
57
- var RAAST_P2P_SCHEME = "30";
57
+ var DEFAULT_P2P_SCHEME = "00";
58
58
  function formatAmount(amount, maxLength, label) {
59
59
  if (!Number.isFinite(amount) || amount <= 0) {
60
60
  throw new RangeError(`${label} must be a positive number`);
@@ -65,6 +65,23 @@ function formatAmount(amount, maxLength, label) {
65
65
  }
66
66
  return text;
67
67
  }
68
+ function formatP2PAmount(amount) {
69
+ if (!Number.isFinite(amount) || amount <= 0) {
70
+ throw new RangeError("amount must be a positive number");
71
+ }
72
+ const text = Number.isInteger(amount) ? String(amount) : amount.toFixed(2);
73
+ if (text.length > 10) {
74
+ throw new RangeError("amount is too large for a Raast QR code");
75
+ }
76
+ return text;
77
+ }
78
+ function formatExpiry(date) {
79
+ if (Number.isNaN(date.getTime())) {
80
+ throw new RangeError("expiresAt is invalid");
81
+ }
82
+ const two = (n) => String(n).padStart(2, "0");
83
+ return two(date.getDate()) + two(date.getMonth() + 1) + String(date.getFullYear()).padStart(4, "0") + two(date.getHours()) + two(date.getMinutes());
84
+ }
68
85
  function checkLength(value, max, label) {
69
86
  if ([...value].length > max) {
70
87
  throw new RangeError(`${label} must be at most ${max} characters`);
@@ -80,13 +97,13 @@ function normalizeIban(iban) {
80
97
  }
81
98
  function createRaastP2PQr(options) {
82
99
  const iban = normalizeIban(options.iban);
83
- let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", RAAST_P2P_SCHEME);
100
+ let payload = encodeField("00", "02") + encodeField("01", options.amount === void 0 ? "11" : "12") + encodeField("02", options.scheme ?? DEFAULT_P2P_SCHEME);
84
101
  if (options.bankName) {
85
102
  payload += encodeField("03", checkLength(options.bankName, 25, "bankName"));
86
103
  }
87
104
  payload += encodeField("04", iban);
88
105
  if (options.amount !== void 0) {
89
- payload += encodeField("05", formatAmount(options.amount, 10, "amount"));
106
+ payload += encodeField("05", formatP2PAmount(options.amount));
90
107
  }
91
108
  if (options.particulars) {
92
109
  payload += encodeField(
@@ -94,6 +111,12 @@ function createRaastP2PQr(options) {
94
111
  checkLength(options.particulars, 30, "particulars")
95
112
  );
96
113
  }
114
+ if (options.amount !== void 0) {
115
+ if (options.expiresAt === void 0) {
116
+ throw new RangeError("A QR with an amount needs expiresAt");
117
+ }
118
+ payload += encodeField("07", formatExpiry(options.expiresAt));
119
+ }
97
120
  const data = `${payload}1004`;
98
121
  return `${data}${crc16(data)}`;
99
122
  }
@@ -209,6 +232,7 @@ function parseRaastQr(payload) {
209
232
  }
210
233
  const additional = fields.find((field) => field.id === "62")?.children ?? [];
211
234
  const due = fieldValue(additional, "50");
235
+ const expiry = kind === "p2p" ? fieldValue(fields, "07") : null;
212
236
  return {
213
237
  kind,
214
238
  dynamic: fieldValue(fields, "01") === "12",
@@ -216,6 +240,7 @@ function parseRaastQr(payload) {
216
240
  iban,
217
241
  ibanValid: iban !== null && validateIBAN(iban),
218
242
  amount: toAmount(fieldValue(fields, kind === "p2p" ? "05" : "54")),
243
+ 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,
219
244
  bankName: kind === "p2p" ? fieldValue(fields, "03") : null,
220
245
  particulars: kind === "p2p" ? fieldValue(fields, "06") : null,
221
246
  merchantName: kind === "merchant" ? fieldValue(fields, "59") : null,
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { normalizeRomanUrdu, formatHijri, toHijri, formatPKR, formatLakh, parseAddress, getCityByPostalCode, getPostalCode, getProvince, getBankFromIBAN, validateIBAN, analyzePhone, validatePhone, validateCNIC } from 'pakdatakit';
3
3
 
4
4
  // package.json
5
- var version = "2.1.0";
5
+ var version = "2.1.2";
6
6
  var EXIT_OK = 0;
7
7
  var EXIT_NEGATIVE = 1;
8
8
  var EXIT_USAGE = 2;
package/dist/iban.cjs CHANGED
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk422X6FEZ_cjs = require('./chunk-422X6FEZ.cjs');
3
+ var chunkE47SNBWQ_cjs = require('./chunk-E47SNBWQ.cjs');
4
4
  require('./chunk-VPBMIYO2.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "getBankFromIBAN", {
9
9
  enumerable: true,
10
- get: function () { return chunk422X6FEZ_cjs.getBankFromIBAN; }
10
+ get: function () { return chunkE47SNBWQ_cjs.getBankFromIBAN; }
11
11
  });
12
12
  Object.defineProperty(exports, "validateIBAN", {
13
13
  enumerable: true,
14
- get: function () { return chunk422X6FEZ_cjs.validateIBAN; }
14
+ get: function () { return chunkE47SNBWQ_cjs.validateIBAN; }
15
15
  });
package/dist/iban.js CHANGED
@@ -1,2 +1,2 @@
1
- export { getBankFromIBAN, validateIBAN } from './chunk-CQKK3S7A.js';
1
+ export { getBankFromIBAN, validateIBAN } from './chunk-4EUKCSLW.js';
2
2
  import './chunk-ENQ7O7VW.js';
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@ var chunkAPXP7OK7_cjs = require('./chunk-APXP7OK7.cjs');
4
4
  var chunkBSS4Z7NI_cjs = require('./chunk-BSS4Z7NI.cjs');
5
5
  var chunkPHHKIMO2_cjs = require('./chunk-PHHKIMO2.cjs');
6
6
  var chunkYS7MOLK2_cjs = require('./chunk-YS7MOLK2.cjs');
7
- var chunkWPKV5JT3_cjs = require('./chunk-WPKV5JT3.cjs');
7
+ var chunkQ7XHVR3U_cjs = require('./chunk-Q7XHVR3U.cjs');
8
8
  var chunkH6M6L26S_cjs = require('./chunk-H6M6L26S.cjs');
9
9
  var chunkKEHCTYLO_cjs = require('./chunk-KEHCTYLO.cjs');
10
10
  var chunkKQKW2ZEK_cjs = require('./chunk-KQKW2ZEK.cjs');
@@ -16,7 +16,7 @@ var chunkLVHTH4P7_cjs = require('./chunk-LVHTH4P7.cjs');
16
16
  var chunk3COX5FSL_cjs = require('./chunk-3COX5FSL.cjs');
17
17
  var chunkXCXFGTHW_cjs = require('./chunk-XCXFGTHW.cjs');
18
18
  var chunkCYJJ7KGC_cjs = require('./chunk-CYJJ7KGC.cjs');
19
- var chunk422X6FEZ_cjs = require('./chunk-422X6FEZ.cjs');
19
+ var chunkE47SNBWQ_cjs = require('./chunk-E47SNBWQ.cjs');
20
20
  require('./chunk-VPBMIYO2.cjs');
21
21
 
22
22
 
@@ -63,15 +63,15 @@ Object.defineProperty(exports, "getNetwork", {
63
63
  });
64
64
  Object.defineProperty(exports, "createMerchantQr", {
65
65
  enumerable: true,
66
- get: function () { return chunkWPKV5JT3_cjs.createMerchantQr; }
66
+ get: function () { return chunkQ7XHVR3U_cjs.createMerchantQr; }
67
67
  });
68
68
  Object.defineProperty(exports, "createRaastP2PQr", {
69
69
  enumerable: true,
70
- get: function () { return chunkWPKV5JT3_cjs.createRaastP2PQr; }
70
+ get: function () { return chunkQ7XHVR3U_cjs.createRaastP2PQr; }
71
71
  });
72
72
  Object.defineProperty(exports, "parseRaastQr", {
73
73
  enumerable: true,
74
- get: function () { return chunkWPKV5JT3_cjs.parseRaastQr; }
74
+ get: function () { return chunkQ7XHVR3U_cjs.parseRaastQr; }
75
75
  });
76
76
  Object.defineProperty(exports, "analyzeNTN", {
77
77
  enumerable: true,
@@ -203,9 +203,9 @@ Object.defineProperty(exports, "toHijri", {
203
203
  });
204
204
  Object.defineProperty(exports, "getBankFromIBAN", {
205
205
  enumerable: true,
206
- get: function () { return chunk422X6FEZ_cjs.getBankFromIBAN; }
206
+ get: function () { return chunkE47SNBWQ_cjs.getBankFromIBAN; }
207
207
  });
208
208
  Object.defineProperty(exports, "validateIBAN", {
209
209
  enumerable: true,
210
- get: function () { return chunk422X6FEZ_cjs.validateIBAN; }
210
+ get: function () { return chunkE47SNBWQ_cjs.validateIBAN; }
211
211
  });
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ export { amountInWords, numberToWords } from './chunk-QQQKISXT.js';
2
2
  export { analyzeNumber, getAreaCode, getNumberType, validateLandline } from './chunk-T3E4B5MJ.js';
3
3
  export { analyzePhone, formatPhone, validatePhone } from './chunk-432ZYMYV.js';
4
4
  export { getNetwork } from './chunk-L45UXUWX.js';
5
- export { createMerchantQr, createRaastP2PQr, parseRaastQr } from './chunk-H4DVWUYH.js';
5
+ export { createMerchantQr, createRaastP2PQr, parseRaastQr } from './chunk-R7UTY3SY.js';
6
6
  export { analyzeNTN, validateNTN, validateSTRN } from './chunk-CEPNSHIC.js';
7
7
  export { normalizeRomanUrdu, normalizeText, toEnglishDigits, toUrduDigits } from './chunk-JKE4AMSZ.js';
8
8
  export { createWhatsAppLink } from './chunk-P4CGOJEM.js';
@@ -14,5 +14,5 @@ export { formatLakh, formatPKR } from './chunk-6TSKA2PH.js';
14
14
  export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts } from './chunk-K6CZFCX6.js';
15
15
  export { getHolidaysOn, getPakistanHolidays, isPakistanHoliday } from './chunk-HBOZIITD.js';
16
16
  export { formatHijri, fromHijri, getHijriMonthName, isRamadan, toHijri } from './chunk-Z5JEIQVW.js';
17
- export { getBankFromIBAN, validateIBAN } from './chunk-CQKK3S7A.js';
17
+ export { getBankFromIBAN, validateIBAN } from './chunk-4EUKCSLW.js';
18
18
  import './chunk-ENQ7O7VW.js';
package/dist/raast.cjs CHANGED
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkWPKV5JT3_cjs = require('./chunk-WPKV5JT3.cjs');
4
- require('./chunk-422X6FEZ.cjs');
3
+ var chunkQ7XHVR3U_cjs = require('./chunk-Q7XHVR3U.cjs');
4
+ require('./chunk-E47SNBWQ.cjs');
5
5
  require('./chunk-VPBMIYO2.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "createMerchantQr", {
10
10
  enumerable: true,
11
- get: function () { return chunkWPKV5JT3_cjs.createMerchantQr; }
11
+ get: function () { return chunkQ7XHVR3U_cjs.createMerchantQr; }
12
12
  });
13
13
  Object.defineProperty(exports, "createRaastP2PQr", {
14
14
  enumerable: true,
15
- get: function () { return chunkWPKV5JT3_cjs.createRaastP2PQr; }
15
+ get: function () { return chunkQ7XHVR3U_cjs.createRaastP2PQr; }
16
16
  });
17
17
  Object.defineProperty(exports, "parseRaastQr", {
18
18
  enumerable: true,
19
- get: function () { return chunkWPKV5JT3_cjs.parseRaastQr; }
19
+ get: function () { return chunkQ7XHVR3U_cjs.parseRaastQr; }
20
20
  });
package/dist/raast.d.cts CHANGED
@@ -14,8 +14,19 @@ interface EmvField {
14
14
  interface RaastP2PQrOptions {
15
15
  /** Payee's Pakistani IBAN. */
16
16
  iban: string;
17
- /** Amount in PKR. When set, the QR is dynamic (point of initiation 12). */
17
+ /**
18
+ * Scheme identifier (tag 02). Defaults to `'00'`, as used by banking apps.
19
+ * `'30'` is the value listed for Raast in SBP's QR standard.
20
+ */
21
+ scheme?: '00' | '30';
22
+ /**
23
+ * Amount in PKR. When set, the QR is dynamic (point of initiation 12) and
24
+ * `expiresAt` is required: banking apps reject dynamic QR codes without an
25
+ * expiry, and ignore the amount in static ones.
26
+ */
18
27
  amount?: number;
28
+ /** When a QR with an amount stops working (tag 07). Required with `amount`. */
29
+ expiresAt?: Date;
19
30
  /** Payee's bank name (up to 25 characters). */
20
31
  bankName?: string;
21
32
  /** Payment description (up to 30 characters). */
@@ -66,6 +77,8 @@ interface ParsedRaastQr {
66
77
  /** Whether `iban` passes the IBAN checksum. */
67
78
  ibanValid: boolean;
68
79
  amount: number | null;
80
+ /** P2P: expiry of a dynamic QR as local `YYYY-MM-DDTHH:mm`. */
81
+ expiresAt: string | null;
69
82
  /** P2P: bank name. */
70
83
  bankName: string | null;
71
84
  /** P2P: payment description. */
@@ -81,16 +94,27 @@ interface ParsedRaastQr {
81
94
  fields: EmvField[];
82
95
  }
83
96
  /**
84
- * Creates a Raast person-to-person QR payload, following SBP's P2P QR format
85
- * (payload format `02`, scheme `30`). Encode the string as a QR code with any
86
- * QR library.
97
+ * Creates a Raast person-to-person QR payload in SBP's P2P QR format (payload
98
+ * format `02`), matching the QR codes banking apps generate, so it can be
99
+ * scanned by apps such as Easypaisa and JazzCash. Encode the string as a QR
100
+ * code with any QR library.
101
+ *
102
+ * A QR with an `amount` is dynamic and needs `expiresAt`; this layout
103
+ * (`01` = `12`, amount in tag 05, expiry in tag 07) matches dynamic QR codes
104
+ * from banking apps and scans in Easypaisa and JazzCash.
87
105
  *
88
106
  * @example
89
- * createRaastP2PQr({ iban: 'PK36SCBL0000001123456702', amount: 1500 });
107
+ * createRaastP2PQr({ iban: 'PK36SCBL0000001123456702' });
108
+ * createRaastP2PQr({
109
+ * iban: 'PK36SCBL0000001123456702',
110
+ * amount: 1500,
111
+ * expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
112
+ * });
90
113
  *
91
- * @param options - Payee IBAN and optional amount, bank name and description
114
+ * @param options - Payee IBAN and optional amount with expiry, bank name and description
92
115
  * @returns QR payload string
93
- * @throws {RangeError} If the IBAN is invalid or a field is too long
116
+ * @throws {RangeError} If the IBAN is invalid, a field is too long, or an
117
+ * amount is given without `expiresAt`
94
118
  */
95
119
  declare function createRaastP2PQr(options: RaastP2PQrOptions): string;
96
120
  /**
package/dist/raast.d.ts CHANGED
@@ -14,8 +14,19 @@ interface EmvField {
14
14
  interface RaastP2PQrOptions {
15
15
  /** Payee's Pakistani IBAN. */
16
16
  iban: string;
17
- /** Amount in PKR. When set, the QR is dynamic (point of initiation 12). */
17
+ /**
18
+ * Scheme identifier (tag 02). Defaults to `'00'`, as used by banking apps.
19
+ * `'30'` is the value listed for Raast in SBP's QR standard.
20
+ */
21
+ scheme?: '00' | '30';
22
+ /**
23
+ * Amount in PKR. When set, the QR is dynamic (point of initiation 12) and
24
+ * `expiresAt` is required: banking apps reject dynamic QR codes without an
25
+ * expiry, and ignore the amount in static ones.
26
+ */
18
27
  amount?: number;
28
+ /** When a QR with an amount stops working (tag 07). Required with `amount`. */
29
+ expiresAt?: Date;
19
30
  /** Payee's bank name (up to 25 characters). */
20
31
  bankName?: string;
21
32
  /** Payment description (up to 30 characters). */
@@ -66,6 +77,8 @@ interface ParsedRaastQr {
66
77
  /** Whether `iban` passes the IBAN checksum. */
67
78
  ibanValid: boolean;
68
79
  amount: number | null;
80
+ /** P2P: expiry of a dynamic QR as local `YYYY-MM-DDTHH:mm`. */
81
+ expiresAt: string | null;
69
82
  /** P2P: bank name. */
70
83
  bankName: string | null;
71
84
  /** P2P: payment description. */
@@ -81,16 +94,27 @@ interface ParsedRaastQr {
81
94
  fields: EmvField[];
82
95
  }
83
96
  /**
84
- * Creates a Raast person-to-person QR payload, following SBP's P2P QR format
85
- * (payload format `02`, scheme `30`). Encode the string as a QR code with any
86
- * QR library.
97
+ * Creates a Raast person-to-person QR payload in SBP's P2P QR format (payload
98
+ * format `02`), matching the QR codes banking apps generate, so it can be
99
+ * scanned by apps such as Easypaisa and JazzCash. Encode the string as a QR
100
+ * code with any QR library.
101
+ *
102
+ * A QR with an `amount` is dynamic and needs `expiresAt`; this layout
103
+ * (`01` = `12`, amount in tag 05, expiry in tag 07) matches dynamic QR codes
104
+ * from banking apps and scans in Easypaisa and JazzCash.
87
105
  *
88
106
  * @example
89
- * createRaastP2PQr({ iban: 'PK36SCBL0000001123456702', amount: 1500 });
107
+ * createRaastP2PQr({ iban: 'PK36SCBL0000001123456702' });
108
+ * createRaastP2PQr({
109
+ * iban: 'PK36SCBL0000001123456702',
110
+ * amount: 1500,
111
+ * expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
112
+ * });
90
113
  *
91
- * @param options - Payee IBAN and optional amount, bank name and description
114
+ * @param options - Payee IBAN and optional amount with expiry, bank name and description
92
115
  * @returns QR payload string
93
- * @throws {RangeError} If the IBAN is invalid or a field is too long
116
+ * @throws {RangeError} If the IBAN is invalid, a field is too long, or an
117
+ * amount is given without `expiresAt`
94
118
  */
95
119
  declare function createRaastP2PQr(options: RaastP2PQrOptions): string;
96
120
  /**
package/dist/raast.js CHANGED
@@ -1,3 +1,3 @@
1
- export { createMerchantQr, createRaastP2PQr, parseRaastQr } from './chunk-H4DVWUYH.js';
2
- import './chunk-CQKK3S7A.js';
1
+ export { createMerchantQr, createRaastP2PQr, parseRaastQr } from './chunk-R7UTY3SY.js';
2
+ import './chunk-4EUKCSLW.js';
3
3
  import './chunk-ENQ7O7VW.js';
package/dist/valibot.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkOVUR47QH_cjs = require('./chunk-OVUR47QH.cjs');
3
+ var chunkJNP27XW2_cjs = require('./chunk-JNP27XW2.cjs');
4
4
  require('./chunk-BSS4Z7NI.cjs');
5
5
  require('./chunk-PHHKIMO2.cjs');
6
6
  require('./chunk-YS7MOLK2.cjs');
7
7
  require('./chunk-H6M6L26S.cjs');
8
8
  require('./chunk-YLWZGSFY.cjs');
9
9
  require('./chunk-HTCSHHOR.cjs');
10
- require('./chunk-422X6FEZ.cjs');
10
+ require('./chunk-E47SNBWQ.cjs');
11
11
  require('./chunk-VPBMIYO2.cjs');
12
12
  var v = require('valibot');
13
13
 
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
32
32
  var v__namespace = /*#__PURE__*/_interopNamespace(v);
33
33
 
34
34
  function schema(name) {
35
- const rule = chunkOVUR47QH_cjs.RULES[name];
35
+ const rule = chunkJNP27XW2_cjs.RULES[name];
36
36
  return (options = {}) => v__namespace.pipe(v__namespace.string(), v__namespace.check(rule.test, options.message ?? rule.message));
37
37
  }
38
38
  var pk = {
package/dist/valibot.js CHANGED
@@ -1,11 +1,11 @@
1
- import { RULES } from './chunk-XT4ZNXRC.js';
1
+ import { RULES } from './chunk-E7GAK72W.js';
2
2
  import './chunk-T3E4B5MJ.js';
3
3
  import './chunk-432ZYMYV.js';
4
4
  import './chunk-L45UXUWX.js';
5
5
  import './chunk-CEPNSHIC.js';
6
6
  import './chunk-Y6BUGLXU.js';
7
7
  import './chunk-EEVNLTB4.js';
8
- import './chunk-CQKK3S7A.js';
8
+ import './chunk-4EUKCSLW.js';
9
9
  import './chunk-ENQ7O7VW.js';
10
10
  import * as v from 'valibot';
11
11
 
package/dist/yup.cjs CHANGED
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkOVUR47QH_cjs = require('./chunk-OVUR47QH.cjs');
3
+ var chunkJNP27XW2_cjs = require('./chunk-JNP27XW2.cjs');
4
4
  require('./chunk-BSS4Z7NI.cjs');
5
5
  require('./chunk-PHHKIMO2.cjs');
6
6
  require('./chunk-YS7MOLK2.cjs');
7
7
  require('./chunk-H6M6L26S.cjs');
8
8
  require('./chunk-YLWZGSFY.cjs');
9
9
  require('./chunk-HTCSHHOR.cjs');
10
- require('./chunk-422X6FEZ.cjs');
10
+ require('./chunk-E47SNBWQ.cjs');
11
11
  require('./chunk-VPBMIYO2.cjs');
12
12
  var yup = require('yup');
13
13
 
14
14
  function schema(name) {
15
- const rule = chunkOVUR47QH_cjs.RULES[name];
15
+ const rule = chunkJNP27XW2_cjs.RULES[name];
16
16
  return (options = {}) => yup.string().test(
17
17
  `pk-${name}`,
18
18
  options.message ?? rule.message,
package/dist/yup.js CHANGED
@@ -1,11 +1,11 @@
1
- import { RULES } from './chunk-XT4ZNXRC.js';
1
+ import { RULES } from './chunk-E7GAK72W.js';
2
2
  import './chunk-T3E4B5MJ.js';
3
3
  import './chunk-432ZYMYV.js';
4
4
  import './chunk-L45UXUWX.js';
5
5
  import './chunk-CEPNSHIC.js';
6
6
  import './chunk-Y6BUGLXU.js';
7
7
  import './chunk-EEVNLTB4.js';
8
- import './chunk-CQKK3S7A.js';
8
+ import './chunk-4EUKCSLW.js';
9
9
  import './chunk-ENQ7O7VW.js';
10
10
  import { string } from 'yup';
11
11
 
package/dist/zod.cjs CHANGED
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkOVUR47QH_cjs = require('./chunk-OVUR47QH.cjs');
3
+ var chunkJNP27XW2_cjs = require('./chunk-JNP27XW2.cjs');
4
4
  require('./chunk-BSS4Z7NI.cjs');
5
5
  require('./chunk-PHHKIMO2.cjs');
6
6
  require('./chunk-YS7MOLK2.cjs');
7
7
  require('./chunk-H6M6L26S.cjs');
8
8
  require('./chunk-YLWZGSFY.cjs');
9
9
  require('./chunk-HTCSHHOR.cjs');
10
- require('./chunk-422X6FEZ.cjs');
10
+ require('./chunk-E47SNBWQ.cjs');
11
11
  require('./chunk-VPBMIYO2.cjs');
12
12
  var zod = require('zod');
13
13
 
14
14
  function schema(name) {
15
- const rule = chunkOVUR47QH_cjs.RULES[name];
15
+ const rule = chunkJNP27XW2_cjs.RULES[name];
16
16
  return (options = {}) => zod.z.string().refine(rule.test, { message: options.message ?? rule.message });
17
17
  }
18
18
  var pk = {
package/dist/zod.js CHANGED
@@ -1,11 +1,11 @@
1
- import { RULES } from './chunk-XT4ZNXRC.js';
1
+ import { RULES } from './chunk-E7GAK72W.js';
2
2
  import './chunk-T3E4B5MJ.js';
3
3
  import './chunk-432ZYMYV.js';
4
4
  import './chunk-L45UXUWX.js';
5
5
  import './chunk-CEPNSHIC.js';
6
6
  import './chunk-Y6BUGLXU.js';
7
7
  import './chunk-EEVNLTB4.js';
8
- import './chunk-CQKK3S7A.js';
8
+ import './chunk-4EUKCSLW.js';
9
9
  import './chunk-ENQ7O7VW.js';
10
10
  import { z } from 'zod';
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pakdatakit",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Production-ready utility toolkit for Pakistani developers — CNIC, phone, WhatsApp, IBAN, postal codes, address parsing, Hijri dates, Roman Urdu, networks, geography, and formatting",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",