@vn-contrib/napas-qr 1.0.0 → 1.0.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/dist/main.d.ts CHANGED
@@ -9,6 +9,7 @@ interface NapasQRProps {
9
9
  amount?: number;
10
10
  currency?: number;
11
11
  countryCode?: string;
12
- description?: string;
12
+ purpose?: string;
13
+ bill?: string;
13
14
  }
14
- export declare function generateCode({ method, system, serviceCode, bin, account, amount, currency, countryCode, description }: NapasQRProps): string;
15
+ export declare function generateCode({ method, system, serviceCode, bin, account, amount, currency, countryCode, purpose, bill }: NapasQRProps): string;
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- var u = /* @__PURE__ */ ((t) => (t[t.Static = 11] = "Static", t[t.Dynamic = 12] = "Dynamic", t))(u || {}), l = /* @__PURE__ */ ((t) => (t[t.NAPAS = 38] = "NAPAS", t))(l || {}), f = /* @__PURE__ */ ((t) => (t.Push = "QRPUSH", t.Cash = "QRCASH", t.CardTransfer = "QRIBFTTC", t.AccountTransfer = "QRIBFTTA", t))(f || {}), i = /* @__PURE__ */ ((t) => (t[t.VND = 704] = "VND", t))(i || {}), A = /* @__PURE__ */ ((t) => (t.VN = "VN", t))(A || {});
2
- function T(t) {
1
+ var u = /* @__PURE__ */ ((t) => (t[t.Static = 11] = "Static", t[t.Dynamic = 12] = "Dynamic", t))(u || {}), i = /* @__PURE__ */ ((t) => (t[t.NAPAS = 38] = "NAPAS", t))(i || {}), A = /* @__PURE__ */ ((t) => (t.Push = "QRPUSH", t.Cash = "QRCASH", t.CardTransfer = "QRIBFTTC", t.AccountTransfer = "QRIBFTTA", t))(A || {}), l = /* @__PURE__ */ ((t) => (t[t.VND = 704] = "VND", t))(l || {}), N = /* @__PURE__ */ ((t) => (t.VN = "VN", t))(N || {});
2
+ function V(t) {
3
3
  let r = 65535;
4
4
  for (let n = 0; n < t.length; n++) {
5
5
  r ^= t.charCodeAt(n) << 8;
@@ -9,26 +9,27 @@ function T(t) {
9
9
  }
10
10
  return r;
11
11
  }
12
- function N(t) {
12
+ function S(t) {
13
13
  let e = "";
14
14
  for (const [r, n] of Object.entries(t).sort((a, o) => a[0] > o[0] ? 1 : -1)) {
15
- const a = typeof n == "string" ? n : typeof n == "number" ? n.toString() : N(n);
15
+ const a = typeof n == "string" ? n : typeof n == "number" ? n.toString() : S(n);
16
16
  e += r + a.length.toString().padStart(2, "0") + a;
17
17
  }
18
18
  return e;
19
19
  }
20
- function D({
20
+ function p({
21
21
  method: t = u.Static,
22
- system: e = l.NAPAS,
23
- serviceCode: r = f.AccountTransfer,
22
+ system: e = i.NAPAS,
23
+ serviceCode: r = A.AccountTransfer,
24
24
  bin: n,
25
25
  account: a,
26
26
  amount: o,
27
- currency: S = i.VND,
28
- countryCode: p = A.VN,
29
- description: c
27
+ currency: g = l.VND,
28
+ countryCode: T = N.VN,
29
+ purpose: c,
30
+ bill: s
30
31
  }) {
31
- const g = {
32
+ const D = {
32
33
  // payload format indicator
33
34
  "00": "01",
34
35
  // point of initiation method
@@ -48,22 +49,29 @@ function D({
48
49
  "02": r
49
50
  },
50
51
  // currency
51
- 53: S,
52
+ 53: g,
52
53
  ...o && {
53
54
  54: o
54
55
  },
55
- 58: p,
56
- ...c && {
57
- 62: c
56
+ 58: T,
57
+ ...(s || c) && {
58
+ 62: {
59
+ ...s && {
60
+ "01": s
61
+ },
62
+ ...c && {
63
+ "08": c
64
+ }
65
+ }
58
66
  }
59
- }, s = N(g) + "6304";
60
- return s + T(s).toString(16).toUpperCase().padStart(4, "0");
67
+ }, f = S(D) + "6304";
68
+ return f + V(f).toString(16).toUpperCase().padStart(4, "0");
61
69
  }
62
70
  export {
63
- A as CountryCode,
64
- i as Currency,
71
+ N as CountryCode,
72
+ l as Currency,
65
73
  u as Method,
66
- f as ServiceCode,
67
- l as System,
68
- D as generateCode
74
+ A as ServiceCode,
75
+ i as System,
76
+ p as generateCode
69
77
  };
package/dist/main.umd.cjs CHANGED
@@ -1 +1 @@
1
- (function(e,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(e=typeof globalThis<"u"?globalThis:e||self,o(e.NapasQR={}))})(this,(function(e){"use strict";var o=(t=>(t[t.Static=11]="Static",t[t.Dynamic=12]="Dynamic",t))(o||{}),f=(t=>(t[t.NAPAS=38]="NAPAS",t))(f||{}),c=(t=>(t.Push="QRPUSH",t.Cash="QRCASH",t.CardTransfer="QRIBFTTC",t.AccountTransfer="QRIBFTTA",t))(c||{}),s=(t=>(t[t.VND=704]="VND",t))(s||{}),l=(t=>(t.VN="VN",t))(l||{});function y(t){let n=65535;for(let r=0;r<t.length;r++){n^=t.charCodeAt(r)<<8;for(let a=0;a<8;a++)n&32768?n=n<<1^4129:n<<=1;n&=65535}return n}function d(t){let i="";for(const[n,r]of Object.entries(t).sort((a,u)=>a[0]>u[0]?1:-1)){const a=typeof r=="string"?r:typeof r=="number"?r.toString():d(r);i+=n+a.length.toString().padStart(2,"0")+a}return i}function g({method:t=o.Static,system:i=f.NAPAS,serviceCode:n=c.AccountTransfer,bin:r,account:a,amount:u,currency:p=s.VND,countryCode:C=l.VN,description:S}){const N={"00":"01","01":t,[i]:{"00":"A000000727","01":{"00":r,"01":a},"02":n},53:p,...u&&{54:u},58:C,...S&&{62:S}},A=d(N)+"6304";return A+y(A).toString(16).toUpperCase().padStart(4,"0")}e.CountryCode=l,e.Currency=s,e.Method=o,e.ServiceCode=c,e.System=f,e.generateCode=g,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.NapasQR={}))})(this,(function(n){"use strict";var o=(t=>(t[t.Static=11]="Static",t[t.Dynamic=12]="Dynamic",t))(o||{}),c=(t=>(t[t.NAPAS=38]="NAPAS",t))(c||{}),u=(t=>(t.Push="QRPUSH",t.Cash="QRCASH",t.CardTransfer="QRIBFTTC",t.AccountTransfer="QRIBFTTA",t))(u||{}),s=(t=>(t[t.VND=704]="VND",t))(s||{}),l=(t=>(t.VN="VN",t))(l||{});function g(t){let e=65535;for(let r=0;r<t.length;r++){e^=t.charCodeAt(r)<<8;for(let a=0;a<8;a++)e&32768?e=e<<1^4129:e<<=1;e&=65535}return e}function A(t){let i="";for(const[e,r]of Object.entries(t).sort((a,f)=>a[0]>f[0]?1:-1)){const a=typeof r=="string"?r:typeof r=="number"?r.toString():A(r);i+=e+a.length.toString().padStart(2,"0")+a}return i}function C({method:t=o.Static,system:i=c.NAPAS,serviceCode:e=u.AccountTransfer,bin:r,account:a,amount:f,currency:N=s.VND,countryCode:T=l.VN,purpose:d,bill:S}){const m={"00":"01","01":t,[i]:{"00":"A000000727","01":{"00":r,"01":a},"02":e},53:N,...f&&{54:f},58:T,...(S||d)&&{62:{...S&&{"01":S},...d&&{"08":d}}}},y=A(m)+"6304";return y+g(y).toString(16).toUpperCase().padStart(4,"0")}n.CountryCode=l,n.Currency=s,n.Method=o,n.ServiceCode=u,n.System=c,n.generateCode=C,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vn-contrib/napas-qr",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -26,6 +26,17 @@
26
26
  "vite-plugin-dts": "^4.5.4",
27
27
  "vitest": "^4.0.16"
28
28
  },
29
+ "homepage": "https://vn-contrib.github.io/napas-qr/",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/vn-contrib/napas-qr.git"
33
+ },
34
+ "license": "MIT",
35
+ "keywords": [
36
+ "napas",
37
+ "qrcode",
38
+ "vietqr"
39
+ ],
29
40
  "scripts": {
30
41
  "dev": "vite",
31
42
  "build": "pnpm run /^build:.*/",
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>