@danidoble/webserial 4.3.4 → 4.3.6
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/boardroid.cjs +1 -1
- package/dist/boardroid.js +506 -478
- package/dist/hopper.cjs +2 -2
- package/dist/hopper.js +117 -114
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +732 -705
- package/dist/kernel-D8A562gb.cjs +1 -0
- package/dist/kernel-DAtdBEi3.js +815 -0
- package/dist/kernel.cjs +1 -1
- package/dist/kernel.js +2 -2
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +81 -83
- package/dist/pinpad.cjs +21 -21
- package/dist/pinpad.js +3386 -3278
- package/dist/pinpax.cjs +4 -4
- package/dist/pinpax.js +133 -138
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +2 -2
- package/dist/{webserial-core-ByrJ7tlu.js → webserial-core-BjytHor1.js} +179 -182
- package/dist/webserial-core-N14HUamr.cjs +4 -0
- package/dist/webserial.cjs +1 -1
- package/dist/webserial.js +3 -3
- package/package.json +5 -5
- package/dist/kernel-BblykfpT.js +0 -875
- package/dist/kernel-CzkmE_OW.cjs +0 -1
- package/dist/webserial-core-5B5nYtyR.cjs +0 -4
package/dist/pinpax.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
`,
|
|
3
|
-
`);await this.appendToQueue(this.stringArrayToUint8Array(
|
|
4
|
-
`);await this.appendToQueue(e,"login")}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./kernel-D8A562gb.cjs"),a=require("./relay-DGFymXOw.cjs"),c=require("./webserial-core-N14HUamr.cjs");class u extends h.Kernel{__pinpax__={server:"DEV",bussinessId:null,encriptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1}};constructor({filters:s=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:t=1,device_listen_on_channel:i=1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1}){if(super({filters:s,config_port:e,no_device:t,device_listen_on_channel:i}),this.__internal__.device.type="pinpax",c.h.getCustom(this.typeDevice,t))throw new Error(`Device ${this.typeDevice} ${t} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
|
|
2
|
+
`,this.#t(),c.h.add(this),this.getResponseAsString()}#t(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of s)this.serialRegisterAvailableListener(e)}set bussinessId(s){this.__pinpax__.bussinessId=s}get bussinessId(){return this.__pinpax__.bussinessId}set encriptionKey(s){this.__pinpax__.encriptionKey=s}get encriptionKey(){return this.__pinpax__.encriptionKey}set apiKey(s){this.__pinpax__.apiKey=s}get apiKey(){return this.__pinpax__.apiKey}set server(s){this.__pinpax__.server=s}get server(){return this.__pinpax__.server}serialMessage(s){let e=null;try{e=JSON.parse(s),e.request||(e.request=this.lastAction),e.name||(e.name=this.lastAction)}catch(t){console.error("Error parsing response",t,s),this.dispatch("serial:message",s);return}switch(e.response){case"INITAPP":this.dispatch("init-app",{name:"INITAPP",request:this.lastAction,status:"started"}),this.#n().then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{name:"CONNECT",request:this.lastAction,status:"connected"}),this.#r().then(()=>{});break;case"LOGIN":e.name||(e.name="LOGIN"),this.dispatch("login",e);break;case"LASTVOUCHER":e.name||(e.name="LASTVOUCHER"),this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":e.name||(e.name="DEVICEINFO"),this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{name:"KEEPALIVE",request:this.lastAction,status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{name:"RESETAPP",request:this.lastAction,status:"accepted"});break;case"GETCONFIG":e.name||(e.name="GETCONFIG"),this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{name:"HIDEBUTTONS",request:this.lastAction,hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{name:"SHOWBUTTONS",request:this.lastAction,hidden:!1});break;case"PAYMENT_PROCESS":e.name||(e.name="PAYMENT_PROCESS"),this.dispatch("payment",{name:"PAYMENT_PROCESS",request:this.lastAction,status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{name:"INSERT_CARD",request:this.lastAction,status:"insert card"});break;case"CARD_DATA":e.name||(e.name="CARD_DATA"),this.dispatch("payment",{name:"CARD_DATA",request:this.lastAction,status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":e.name||(e.name="MERCHANT"),this.dispatch("payment",{request:this.lastAction,status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":e.name||(e.name="TRANSACTION_RESULT"),this.#o({status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":e.name||(e.name="ERROR"),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:e}),this.dispatch("payment",{name:"ERROR",request:this.lastAction,status:"error",response:e});break;case"REFUND":this.dispatch("refund",{name:"ERROR",request:this.lastAction,status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=1){return a.s.connection(s)}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(s={}){if(typeof s!="object")throw new Error("Invalid object");if(s.constructor!==Object)throw new Error("Invalid object");if(Object.keys(s).length===0)throw new Error("Empty object");if(s.action===void 0||s.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(s),t=this.parseStringToBytes(e,`\r
|
|
3
|
+
`);await this.appendToQueue(this.stringArrayToUint8Array(t),"custom")}async connectMessage(){await this.appendToQueue(a.s.connect(),"connect:message")}async#e(){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.queue.length===0)return!0;const s=this;return new Promise(e=>{let t=setInterval(()=>{s.queue.length===0&&(clearInterval(t),e(!0))},500)})}async#s({type:s="production"}={}){const e=a.s.readQR({type:s});return await this.appendToQueue(e,"read-qr")}async#a(){await this.appendToQueue(a.s.forceHide(),"force-hide")}async#i(){await this.appendToQueue(a.s.forceShow(),"force-show")}async#n(){await this.connectMessage()}async#r(){await this.hideButtons()}#o(s){this.dispatch("payment",s),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=s)}async makeSale({amount:s=0,reference:e=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const t=a.s.makeSale({amount:s,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await this.#e();const i=this;return await this.appendToQueue(t,"make-sale"),new Promise(n=>{const r=setInterval(()=>{if(i.__pinpax__.asyncResponses.sale){const o=i.__pinpax__.asyncResponses.sale;i.__pinpax__.asyncResponses.sale=null,i.__pinpax__.waiting.sale=!1,clearInterval(r),n(o.approved)}},100)})}async getVoucher({folio:s=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!s)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=a.s.getVoucher({folio:s});this.queue.length>0&&await this.#e(),await this.appendToQueue(e,"get-voucher");const t=this;return new Promise((i,n)=>{const r=setTimeout(()=>{t.__pinpax__.waiting.voucher=!1,n("Timeout")},1e4),o=setInterval(()=>{if(t.__pinpax__.asyncResponses.voucher){const p=t.__pinpax__.asyncResponses.voucher;t.__pinpax__.asyncResponses.voucher=null,t.__pinpax__.waiting.voucher=!1,clearInterval(o),clearTimeout(r),i(p.voucher)}},100)})}async info(){await this.appendToQueue(a.s.info(),"info")}async keepAlive(){await this.appendToQueue(a.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(a.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(a.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(a.s.hideButtons(),"hide-buttons"),await this.#a()}async showButtons(){return await this.appendToQueue(a.s.showButtons(),"show-buttons"),await this.#i()}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(a.s.demo(),"demo")}async refund({amount:s=0,folio:e=null,auth:t=null}={}){return await this.appendToQueue(a.s.refund({amount:s,folio:e,auth:t}),"refund")}async readProductionQR(){return await this.#s({type:"production"})}async readQualityAssuranceQR(){return this.#s({type:"QA"})}async exit(){return await this.appendToQueue(a.s.exit(),"exit-app")}async init(){await this.appendToQueue(a.s.init(),"init-app")}async login(){if(!this.apiKey||!this.bussinessId||!this.encriptionKey||!this.server)throw new Error("Invalid data to login check apiKey, bussinessId, encriptionKey, server");const s=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,bussiness_id:this.__pinpax__.bussinessId,encription_key:this.__pinpax__.encriptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(s,`\r
|
|
4
|
+
`);await this.appendToQueue(e,"login")}}exports.PinPax=u;
|
package/dist/pinpax.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { K as h } from "./kernel-DAtdBEi3.js";
|
|
2
|
+
import { s as a } from "./relay-CsdB0FSa.js";
|
|
3
|
+
import { h as c } from "./webserial-core-BjytHor1.js";
|
|
4
|
+
class m extends h {
|
|
5
|
+
__pinpax__ = {
|
|
6
|
+
server: "DEV",
|
|
7
|
+
bussinessId: null,
|
|
8
|
+
encriptionKey: null,
|
|
9
|
+
apiKey: null,
|
|
10
|
+
asyncResponses: {
|
|
11
|
+
voucher: null,
|
|
12
|
+
sale: null
|
|
13
|
+
},
|
|
14
|
+
waiting: {
|
|
15
|
+
voucher: !1,
|
|
16
|
+
sale: !1
|
|
17
|
+
}
|
|
18
|
+
};
|
|
14
19
|
constructor({
|
|
15
20
|
filters: s = null,
|
|
16
21
|
config_port: e = {
|
|
@@ -21,8 +26,8 @@ class S extends C {
|
|
|
21
26
|
bufferSize: 32768,
|
|
22
27
|
flowControl: "none"
|
|
23
28
|
},
|
|
24
|
-
no_device:
|
|
25
|
-
device_listen_on_channel:
|
|
29
|
+
no_device: t = 1,
|
|
30
|
+
device_listen_on_channel: i = 1
|
|
26
31
|
} = {
|
|
27
32
|
filters: null,
|
|
28
33
|
config_port: {
|
|
@@ -36,26 +41,28 @@ class S extends C {
|
|
|
36
41
|
no_device: 1,
|
|
37
42
|
device_listen_on_channel: 1
|
|
38
43
|
}) {
|
|
39
|
-
super({ filters: s, config_port: e, no_device:
|
|
40
|
-
|
|
41
|
-
y(this, "__pinpax__", {
|
|
42
|
-
server: "DEV",
|
|
43
|
-
bussinessId: null,
|
|
44
|
-
encriptionKey: null,
|
|
45
|
-
apiKey: null,
|
|
46
|
-
asyncResponses: {
|
|
47
|
-
voucher: null,
|
|
48
|
-
sale: null
|
|
49
|
-
},
|
|
50
|
-
waiting: {
|
|
51
|
-
voucher: !1,
|
|
52
|
-
sale: !1
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (this.__internal__.device.type = "pinpax", m.getCustom(this.typeDevice, a))
|
|
56
|
-
throw new Error(`Device ${this.typeDevice} ${a} already exists`);
|
|
44
|
+
if (super({ filters: s, config_port: e, no_device: t, device_listen_on_channel: i }), this.__internal__.device.type = "pinpax", c.getCustom(this.typeDevice, t))
|
|
45
|
+
throw new Error(`Device ${this.typeDevice} ${t} already exists`);
|
|
57
46
|
this.__internal__.time.response_connection = 4e3, this.__internal__.time.response_general = 3e3, this.__internal__.serial.delay_first_connection = 1e3, this.__internal__.serial.response.replacer = "", this.__internal__.serial.response.limiter = `\r
|
|
58
|
-
`,
|
|
47
|
+
`, this.#t(), c.add(this), this.getResponseAsString();
|
|
48
|
+
}
|
|
49
|
+
#t() {
|
|
50
|
+
const s = [
|
|
51
|
+
"buttons-status",
|
|
52
|
+
"init-app",
|
|
53
|
+
"connectMessage",
|
|
54
|
+
"voucher",
|
|
55
|
+
"info",
|
|
56
|
+
"keep-alive",
|
|
57
|
+
"reset-app",
|
|
58
|
+
"get-config",
|
|
59
|
+
"payment",
|
|
60
|
+
"error",
|
|
61
|
+
"refund",
|
|
62
|
+
"login"
|
|
63
|
+
];
|
|
64
|
+
for (const e of s)
|
|
65
|
+
this.serialRegisterAvailableListener(e);
|
|
59
66
|
}
|
|
60
67
|
set bussinessId(s) {
|
|
61
68
|
this.__pinpax__.bussinessId = s;
|
|
@@ -84,56 +91,60 @@ class S extends C {
|
|
|
84
91
|
serialMessage(s) {
|
|
85
92
|
let e = null;
|
|
86
93
|
try {
|
|
87
|
-
e = JSON.parse(s);
|
|
88
|
-
} catch (
|
|
89
|
-
console.error("Error parsing response",
|
|
94
|
+
e = JSON.parse(s), e.request || (e.request = this.lastAction), e.name || (e.name = this.lastAction);
|
|
95
|
+
} catch (t) {
|
|
96
|
+
console.error("Error parsing response", t, s), this.dispatch("serial:message", s);
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
99
|
switch (e.response) {
|
|
93
100
|
case "INITAPP":
|
|
94
|
-
this.dispatch("init-app", { status: "started" }),
|
|
101
|
+
this.dispatch("init-app", { name: "INITAPP", request: this.lastAction, status: "started" }), this.#n().then(() => {
|
|
95
102
|
});
|
|
96
103
|
break;
|
|
97
104
|
case "CONNECT":
|
|
98
|
-
this.dispatch("connectMessage", { status: "connected" }),
|
|
105
|
+
this.dispatch("connectMessage", { name: "CONNECT", request: this.lastAction, status: "connected" }), this.#r().then(() => {
|
|
99
106
|
});
|
|
100
107
|
break;
|
|
101
108
|
case "LOGIN":
|
|
102
|
-
this.dispatch("login", e);
|
|
109
|
+
e.name || (e.name = "LOGIN"), this.dispatch("login", e);
|
|
103
110
|
break;
|
|
104
111
|
case "LASTVOUCHER":
|
|
105
|
-
this.dispatch("voucher", e), this.__pinpax__.waiting.voucher && (this.__pinpax__.asyncResponses.voucher = e, this.__pinpax__.waiting.voucher = !1);
|
|
112
|
+
e.name || (e.name = "LASTVOUCHER"), this.dispatch("voucher", e), this.__pinpax__.waiting.voucher && (this.__pinpax__.asyncResponses.voucher = e, this.__pinpax__.waiting.voucher = !1);
|
|
106
113
|
break;
|
|
107
114
|
case "DEVICEINFO":
|
|
108
|
-
this.dispatch("info", e);
|
|
115
|
+
e.name || (e.name = "DEVICEINFO"), this.dispatch("info", e);
|
|
109
116
|
break;
|
|
110
117
|
case "KEEPALIVE":
|
|
111
|
-
this.dispatch("keep-alive", { status: "alive" });
|
|
118
|
+
this.dispatch("keep-alive", { name: "KEEPALIVE", request: this.lastAction, status: "alive" });
|
|
112
119
|
break;
|
|
113
120
|
case "RESETAPP":
|
|
114
|
-
this.dispatch("reset-app", { status: "accepted" });
|
|
121
|
+
this.dispatch("reset-app", { name: "RESETAPP", request: this.lastAction, status: "accepted" });
|
|
115
122
|
break;
|
|
116
123
|
case "GETCONFIG":
|
|
117
|
-
this.dispatch("get-config", e);
|
|
124
|
+
e.name || (e.name = "GETCONFIG"), this.dispatch("get-config", e);
|
|
118
125
|
break;
|
|
119
126
|
case "HIDEBUTTONS":
|
|
120
|
-
this.dispatch("buttons-status", { hidden: !0 });
|
|
127
|
+
this.dispatch("buttons-status", { name: "HIDEBUTTONS", request: this.lastAction, hidden: !0 });
|
|
121
128
|
break;
|
|
122
129
|
case "SHOWBUTTONS":
|
|
123
|
-
this.dispatch("buttons-status", { hidden: !1 });
|
|
130
|
+
this.dispatch("buttons-status", { name: "SHOWBUTTONS", request: this.lastAction, hidden: !1 });
|
|
124
131
|
break;
|
|
125
132
|
case "PAYMENT_PROCESS":
|
|
126
|
-
this.dispatch("payment", {
|
|
133
|
+
e.name || (e.name = "PAYMENT_PROCESS"), this.dispatch("payment", {
|
|
134
|
+
name: "PAYMENT_PROCESS",
|
|
135
|
+
request: this.lastAction,
|
|
127
136
|
status: "starting",
|
|
128
137
|
amount: e.amount,
|
|
129
138
|
reference: e.referecence
|
|
130
139
|
});
|
|
131
140
|
break;
|
|
132
141
|
case "INSERT_CARD":
|
|
133
|
-
this.dispatch("payment", { status: "insert card" });
|
|
142
|
+
this.dispatch("payment", { name: "INSERT_CARD", request: this.lastAction, status: "insert card" });
|
|
134
143
|
break;
|
|
135
144
|
case "CARD_DATA":
|
|
136
|
-
this.dispatch("payment", {
|
|
145
|
+
e.name || (e.name = "CARD_DATA"), this.dispatch("payment", {
|
|
146
|
+
name: "CARD_DATA",
|
|
147
|
+
request: this.lastAction,
|
|
137
148
|
status: "card data",
|
|
138
149
|
amount: e.amount,
|
|
139
150
|
cardHolderName: e.cardHolderName,
|
|
@@ -145,7 +156,8 @@ class S extends C {
|
|
|
145
156
|
});
|
|
146
157
|
break;
|
|
147
158
|
case "MERCHANT":
|
|
148
|
-
this.dispatch("payment", {
|
|
159
|
+
e.name || (e.name = "MERCHANT"), this.dispatch("payment", {
|
|
160
|
+
request: this.lastAction,
|
|
149
161
|
status: "merchant",
|
|
150
162
|
afiliation: e.afiliation,
|
|
151
163
|
alias: e.alias,
|
|
@@ -160,7 +172,7 @@ class S extends C {
|
|
|
160
172
|
});
|
|
161
173
|
break;
|
|
162
174
|
case "TRANSACTION_RESULT":
|
|
163
|
-
|
|
175
|
+
e.name || (e.name = "TRANSACTION_RESULT"), this.#o({
|
|
164
176
|
status: "result",
|
|
165
177
|
approved: e.approved,
|
|
166
178
|
acquirer: e.acquirer,
|
|
@@ -196,26 +208,20 @@ class S extends C {
|
|
|
196
208
|
});
|
|
197
209
|
break;
|
|
198
210
|
case "ERROR":
|
|
199
|
-
this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = {
|
|
211
|
+
e.name || (e.name = "ERROR"), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = {
|
|
200
212
|
status: "error",
|
|
201
213
|
approved: !1,
|
|
202
214
|
response: e
|
|
203
|
-
}), this.dispatch("error", {
|
|
204
|
-
status: "error",
|
|
205
|
-
response: e
|
|
206
|
-
}), this.dispatch("payment", {
|
|
207
|
-
status: "error",
|
|
208
|
-
response: e
|
|
209
|
-
});
|
|
215
|
+
}), this.dispatch("error", { name: "ERROR", request: this.lastAction, status: "error", response: e }), this.dispatch("payment", { name: "ERROR", request: this.lastAction, status: "error", response: e });
|
|
210
216
|
break;
|
|
211
217
|
case "REFUND":
|
|
212
|
-
this.dispatch("refund", { status: "refund", response: e });
|
|
218
|
+
this.dispatch("refund", { name: "ERROR", request: this.lastAction, status: "refund", response: e });
|
|
213
219
|
break;
|
|
214
220
|
}
|
|
215
221
|
this.dispatch("serial:message", e);
|
|
216
222
|
}
|
|
217
223
|
serialSetConnectionConstant(s = 1) {
|
|
218
|
-
return
|
|
224
|
+
return a.connection(s);
|
|
219
225
|
}
|
|
220
226
|
softReload() {
|
|
221
227
|
super.softReload(), this.__pinpax__.waiting.sale = !1, this.__pinpax__.waiting.voucher = !1, this.__pinpax__.asyncResponses.sale = null, this.__pinpax__.asyncResponses.voucher = null;
|
|
@@ -225,24 +231,53 @@ class S extends C {
|
|
|
225
231
|
if (s.constructor !== Object) throw new Error("Invalid object");
|
|
226
232
|
if (Object.keys(s).length === 0) throw new Error("Empty object");
|
|
227
233
|
if (s.action === void 0 || s.action === null) throw new Error("Invalid object add action");
|
|
228
|
-
const e = JSON.stringify(s),
|
|
234
|
+
const e = JSON.stringify(s), t = this.parseStringToBytes(e, `\r
|
|
229
235
|
`);
|
|
230
|
-
await this.appendToQueue(this.stringArrayToUint8Array(
|
|
236
|
+
await this.appendToQueue(this.stringArrayToUint8Array(t), "custom");
|
|
231
237
|
}
|
|
232
238
|
async connectMessage() {
|
|
233
|
-
await this.appendToQueue(
|
|
239
|
+
await this.appendToQueue(a.connect(), "connect:message");
|
|
240
|
+
}
|
|
241
|
+
async #e() {
|
|
242
|
+
if (this.isDisconnected) throw new Error("Device is disconnected");
|
|
243
|
+
if (this.queue.length === 0) return !0;
|
|
244
|
+
const s = this;
|
|
245
|
+
return new Promise((e) => {
|
|
246
|
+
let t = setInterval(() => {
|
|
247
|
+
s.queue.length === 0 && (clearInterval(t), e(!0));
|
|
248
|
+
}, 500);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
async #s({ type: s = "production" } = {}) {
|
|
252
|
+
const e = a.readQR({ type: s });
|
|
253
|
+
return await this.appendToQueue(e, "read-qr");
|
|
254
|
+
}
|
|
255
|
+
async #a() {
|
|
256
|
+
await this.appendToQueue(a.forceHide(), "force-hide");
|
|
257
|
+
}
|
|
258
|
+
async #i() {
|
|
259
|
+
await this.appendToQueue(a.forceShow(), "force-show");
|
|
260
|
+
}
|
|
261
|
+
async #n() {
|
|
262
|
+
await this.connectMessage();
|
|
263
|
+
}
|
|
264
|
+
async #r() {
|
|
265
|
+
await this.hideButtons();
|
|
266
|
+
}
|
|
267
|
+
#o(s) {
|
|
268
|
+
this.dispatch("payment", s), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = s);
|
|
234
269
|
}
|
|
235
270
|
async makeSale({ amount: s = 0, reference: e = null } = {}) {
|
|
236
271
|
if (this.isDisconnected) throw new Error("Device is disconnected");
|
|
237
272
|
if (this.__pinpax__.waiting.sale) throw new Error("Already waiting for sale response");
|
|
238
|
-
const
|
|
239
|
-
this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await
|
|
240
|
-
const
|
|
241
|
-
return await this.appendToQueue(
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
|
|
273
|
+
const t = a.makeSale({ amount: s, reference: e });
|
|
274
|
+
this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await this.#e();
|
|
275
|
+
const i = this;
|
|
276
|
+
return await this.appendToQueue(t, "make-sale"), new Promise((n) => {
|
|
277
|
+
const r = setInterval(() => {
|
|
278
|
+
if (i.__pinpax__.asyncResponses.sale) {
|
|
279
|
+
const o = i.__pinpax__.asyncResponses.sale;
|
|
280
|
+
i.__pinpax__.asyncResponses.sale = null, i.__pinpax__.waiting.sale = !1, clearInterval(r), n(o.approved);
|
|
246
281
|
}
|
|
247
282
|
}, 100);
|
|
248
283
|
});
|
|
@@ -252,62 +287,62 @@ class S extends C {
|
|
|
252
287
|
if (this.__pinpax__.waiting.voucher) throw new Error("Already waiting for voucher");
|
|
253
288
|
if (!s) throw new Error("Folio is required");
|
|
254
289
|
this.__pinpax__.waiting.voucher = !0, this.__pinpax__.asyncResponses.voucher = null;
|
|
255
|
-
const e =
|
|
256
|
-
this.queue.length > 0 && await
|
|
257
|
-
const
|
|
258
|
-
return new Promise((
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
}, 1e4),
|
|
262
|
-
if (
|
|
263
|
-
const
|
|
264
|
-
|
|
290
|
+
const e = a.getVoucher({ folio: s });
|
|
291
|
+
this.queue.length > 0 && await this.#e(), await this.appendToQueue(e, "get-voucher");
|
|
292
|
+
const t = this;
|
|
293
|
+
return new Promise((i, n) => {
|
|
294
|
+
const r = setTimeout(() => {
|
|
295
|
+
t.__pinpax__.waiting.voucher = !1, n("Timeout");
|
|
296
|
+
}, 1e4), o = setInterval(() => {
|
|
297
|
+
if (t.__pinpax__.asyncResponses.voucher) {
|
|
298
|
+
const p = t.__pinpax__.asyncResponses.voucher;
|
|
299
|
+
t.__pinpax__.asyncResponses.voucher = null, t.__pinpax__.waiting.voucher = !1, clearInterval(o), clearTimeout(r), i(p.voucher);
|
|
265
300
|
}
|
|
266
301
|
}, 100);
|
|
267
302
|
});
|
|
268
303
|
}
|
|
269
304
|
async info() {
|
|
270
|
-
await this.appendToQueue(
|
|
305
|
+
await this.appendToQueue(a.info(), "info");
|
|
271
306
|
}
|
|
272
307
|
async keepAlive() {
|
|
273
|
-
await this.appendToQueue(
|
|
308
|
+
await this.appendToQueue(a.keepAlive(), "keep-alive");
|
|
274
309
|
}
|
|
275
310
|
async restartApp() {
|
|
276
|
-
await this.appendToQueue(
|
|
311
|
+
await this.appendToQueue(a.restartApp(), "reset-app");
|
|
277
312
|
}
|
|
278
313
|
async getConfig() {
|
|
279
|
-
return await this.appendToQueue(
|
|
314
|
+
return await this.appendToQueue(a.getConfig(), "get-config");
|
|
280
315
|
}
|
|
281
316
|
async hideButtons() {
|
|
282
|
-
return await this.appendToQueue(
|
|
317
|
+
return await this.appendToQueue(a.hideButtons(), "hide-buttons"), await this.#a();
|
|
283
318
|
}
|
|
284
319
|
async showButtons() {
|
|
285
|
-
return await this.appendToQueue(
|
|
320
|
+
return await this.appendToQueue(a.showButtons(), "show-buttons"), await this.#i();
|
|
286
321
|
}
|
|
287
322
|
async demo() {
|
|
288
|
-
return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(
|
|
323
|
+
return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(a.demo(), "demo");
|
|
289
324
|
}
|
|
290
|
-
async refund({ amount: s = 0, folio: e = null, auth:
|
|
325
|
+
async refund({ amount: s = 0, folio: e = null, auth: t = null } = {}) {
|
|
291
326
|
return await this.appendToQueue(
|
|
292
|
-
|
|
327
|
+
a.refund({
|
|
293
328
|
amount: s,
|
|
294
329
|
folio: e,
|
|
295
|
-
auth:
|
|
330
|
+
auth: t
|
|
296
331
|
}),
|
|
297
332
|
"refund"
|
|
298
333
|
);
|
|
299
334
|
}
|
|
300
335
|
async readProductionQR() {
|
|
301
|
-
return await
|
|
336
|
+
return await this.#s({ type: "production" });
|
|
302
337
|
}
|
|
303
338
|
async readQualityAssuranceQR() {
|
|
304
|
-
return
|
|
339
|
+
return this.#s({ type: "QA" });
|
|
305
340
|
}
|
|
306
341
|
async exit() {
|
|
307
|
-
return await this.appendToQueue(
|
|
342
|
+
return await this.appendToQueue(a.exit(), "exit-app");
|
|
308
343
|
}
|
|
309
344
|
async init() {
|
|
310
|
-
await this.appendToQueue(
|
|
345
|
+
await this.appendToQueue(a.init(), "init-app");
|
|
311
346
|
}
|
|
312
347
|
async login() {
|
|
313
348
|
if (!this.apiKey || !this.bussinessId || !this.encriptionKey || !this.server)
|
|
@@ -323,46 +358,6 @@ class S extends C {
|
|
|
323
358
|
await this.appendToQueue(e, "login");
|
|
324
359
|
}
|
|
325
360
|
}
|
|
326
|
-
t = new WeakSet(), w = function() {
|
|
327
|
-
const s = [
|
|
328
|
-
"buttons-status",
|
|
329
|
-
"init-app",
|
|
330
|
-
"connectMessage",
|
|
331
|
-
"voucher",
|
|
332
|
-
"info",
|
|
333
|
-
"keep-alive",
|
|
334
|
-
"reset-app",
|
|
335
|
-
"get-config",
|
|
336
|
-
"payment",
|
|
337
|
-
"error",
|
|
338
|
-
"refund",
|
|
339
|
-
"login"
|
|
340
|
-
];
|
|
341
|
-
for (const e of s)
|
|
342
|
-
this.serialRegisterAvailableListener(e);
|
|
343
|
-
}, _ = async function() {
|
|
344
|
-
if (this.isDisconnected) throw new Error("Device is disconnected");
|
|
345
|
-
if (this.queue.length === 0) return !0;
|
|
346
|
-
const s = this;
|
|
347
|
-
return new Promise((e) => {
|
|
348
|
-
let a = setInterval(() => {
|
|
349
|
-
s.queue.length === 0 && (clearInterval(a), e(!0));
|
|
350
|
-
}, 500);
|
|
351
|
-
});
|
|
352
|
-
}, l = async function({ type: s = "production" } = {}) {
|
|
353
|
-
const e = n.readQR({ type: s });
|
|
354
|
-
return await this.appendToQueue(e, "read-qr");
|
|
355
|
-
}, g = async function() {
|
|
356
|
-
await this.appendToQueue(n.forceHide(), "force-hide");
|
|
357
|
-
}, v = async function() {
|
|
358
|
-
await this.appendToQueue(n.forceShow(), "force-show");
|
|
359
|
-
}, b = async function() {
|
|
360
|
-
await this.connectMessage();
|
|
361
|
-
}, x = async function() {
|
|
362
|
-
await this.hideButtons();
|
|
363
|
-
}, T = function(s) {
|
|
364
|
-
this.dispatch("payment", s), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = s);
|
|
365
|
-
};
|
|
366
361
|
export {
|
|
367
|
-
|
|
362
|
+
m as PinPax
|
|
368
363
|
};
|
package/dist/relay.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-D8A562gb.cjs"),i=require("./relay-DGFymXOw.cjs"),r=require("./webserial-core-N14HUamr.cjs");class o extends a.Kernel{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){if(super({filters:t,config_port:e,no_device:n}),this.__internal__.device.type="relay",this.__internal__.auto_response=!0,r.h.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);r.h.add(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default:e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=n)}),e}serialSetConnectionConstant(t=1){return i.e.connection(t)}async turnOn(){const t=i.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=i.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await a.wait(e),await this.turnOff();return}await this.turnOff(),await a.wait(e),await this.turnOn()}}exports.Relay=o;
|
package/dist/relay.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { K as o, w as i } from "./kernel-
|
|
1
|
+
import { K as o, w as i } from "./kernel-DAtdBEi3.js";
|
|
2
2
|
import { e as a } from "./relay-CsdB0FSa.js";
|
|
3
|
-
import { h as s } from "./webserial-core-
|
|
3
|
+
import { h as s } from "./webserial-core-BjytHor1.js";
|
|
4
4
|
class p extends o {
|
|
5
5
|
constructor({ filters: t = null, config_port: e = null, no_device: n = 1 } = {}) {
|
|
6
6
|
if (super({ filters: t, config_port: e, no_device: n }), this.__internal__.device.type = "relay", this.__internal__.auto_response = !0, s.getCustom(this.typeDevice, n))
|