@gataca/qr 0.0.28 → 0.0.29
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/{esm/qr-code-styling-0eeb38d5.js → cjs/gat-icon-check-6b6780eb.js} +12 -1
- package/dist/cjs/gataca-autoqr.cjs.entry.js +10 -10
- package/dist/cjs/gataca-qr_3.cjs.entry.js +639 -0
- package/dist/cjs/gataca-qrws.cjs.entry.js +42 -48
- package/dist/cjs/gataca-ssibuttonws.cjs.entry.js +61 -0
- package/dist/cjs/gatacaqr.cjs.js +2 -2
- package/dist/cjs/{index-93d47a75.js → index-1332a8ce.js} +32 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{utils-ef28b844.js → utils-b4e62bc0.js} +1 -1
- package/dist/collection/assets/icons/RefreshIcon.js +6 -0
- package/dist/collection/components/gataca-autoqr/gataca-autoqr.js +13 -13
- package/dist/collection/components/gataca-qr/components/qr/QR.js +3 -3
- package/dist/collection/components/gataca-qr/components/readQR/ReadQR.js +12 -7
- package/dist/collection/components/gataca-qr/components/readQR/components/AnimatedLoader.js +5 -3
- package/dist/collection/components/gataca-qr/components/retryButton/RetryButton.js +12 -9
- package/dist/collection/components/gataca-qr/components/success/Success.js +7 -6
- package/dist/collection/components/gataca-qr/gataca-qr.css +15 -5
- package/dist/collection/components/gataca-qr/gataca-qr.js +68 -57
- package/dist/collection/components/gataca-qrdisplay/gataca-qrdisplay.js +33 -11
- package/dist/collection/components/gataca-qrws/components/qr/QR.js +2 -2
- package/dist/collection/components/gataca-qrws/components/readQR/ReadQR.js +4 -4
- package/dist/collection/components/gataca-qrws/components/readQR/components/AnimatedLoader.js +1 -1
- package/dist/collection/components/gataca-qrws/components/retryButton/RetryButton.js +8 -8
- package/dist/collection/components/gataca-qrws/components/success/Success.js +4 -4
- package/dist/collection/components/gataca-qrws/gataca-qrws.js +49 -56
- package/dist/collection/components/gataca-ssibutton/gataca-ssibutton.js +224 -54
- package/dist/collection/components/gataca-ssibuttonws/gataca-ssibuttonws.js +12 -12
- package/dist/collection/index.js +2 -2
- package/dist/collection/utils/index.js +1 -1
- package/dist/collection/utils/utils.js +1 -1
- package/dist/components/{gat-icon-alert.js → gat-icon-check.js} +4 -6
- package/dist/components/gataca-autoqr.js +9 -9
- package/dist/components/gataca-qr2.js +85 -73
- package/dist/components/gataca-qrdisplay2.js +11 -6
- package/dist/components/gataca-qrws2.js +37 -42
- package/dist/components/gataca-ssibutton2.js +114 -34
- package/dist/components/gataca-ssibuttonws2.js +6 -6
- package/dist/components/index.js +1 -1
- package/dist/{cjs/qr-code-styling-412bbc7a.js → esm/gat-icon-check-7320c81b.js} +6 -2
- package/dist/esm/gataca-autoqr.entry.js +10 -10
- package/dist/esm/gataca-qr_3.entry.js +633 -0
- package/dist/esm/gataca-qrws.entry.js +39 -45
- package/dist/esm/gataca-ssibuttonws.entry.js +57 -0
- package/dist/esm/gatacaqr.js +2 -2
- package/dist/esm/{index-2be54f32.js → index-055790a7.js} +32 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{utils-63e7a33b.js → utils-21ffcc1e.js} +1 -1
- package/dist/gatacaqr/gatacaqr.esm.js +1 -1
- package/dist/gatacaqr/index.esm.js +1 -1
- package/dist/gatacaqr/p-1d1129b7.entry.js +1 -0
- package/dist/gatacaqr/p-29119208.js +1 -0
- package/dist/gatacaqr/p-49cf321c.entry.js +1 -0
- package/dist/gatacaqr/p-9f83bae1.entry.js +1 -0
- package/dist/gatacaqr/{p-5e81ab9e.entry.js → p-c65f810b.entry.js} +1 -1
- package/dist/gatacaqr/p-fccf9d4d.js +2 -0
- package/dist/types/assets/icons/RefreshIcon.d.ts +8 -0
- package/dist/types/components/gataca-autoqr/gataca-autoqr.d.ts +7 -7
- package/dist/types/components/gataca-qr/components/qr/QR.d.ts +4 -2
- package/dist/types/components/gataca-qr/components/readQR/ReadQR.d.ts +3 -1
- package/dist/types/components/gataca-qr/components/readQR/components/AnimatedLoader.d.ts +6 -2
- package/dist/types/components/gataca-qr/components/retryButton/RetryButton.d.ts +3 -1
- package/dist/types/components/gataca-qr/components/success/Success.d.ts +3 -1
- package/dist/types/components/gataca-qr/gataca-qr.d.ts +16 -4
- package/dist/types/components/gataca-qrdisplay/gataca-qrdisplay.d.ts +6 -1
- package/dist/types/components/gataca-qrws/components/qr/QR.d.ts +2 -2
- package/dist/types/components/gataca-qrws/components/readQR/ReadQR.d.ts +1 -1
- package/dist/types/components/gataca-qrws/components/readQR/components/AnimatedLoader.d.ts +1 -1
- package/dist/types/components/gataca-qrws/components/retryButton/RetryButton.d.ts +1 -1
- package/dist/types/components/gataca-qrws/components/success/Success.d.ts +1 -1
- package/dist/types/components/gataca-qrws/gataca-qrws.d.ts +4 -4
- package/dist/types/components/gataca-ssibutton/gataca-ssibutton.d.ts +38 -5
- package/dist/types/components/gataca-ssibuttonws/gataca-ssibuttonws.d.ts +3 -3
- package/dist/types/components.d.ts +78 -36
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +30 -7
- package/dist/cjs/gat-icon-alert-0ad19b26.js +0 -14
- package/dist/cjs/gataca-qr_2.cjs.entry.js +0 -295
- package/dist/cjs/gataca-ssibutton_2.cjs.entry.js +0 -317
- package/dist/esm/gat-icon-alert-7b06ef3a.js +0 -9
- package/dist/esm/gataca-qr_2.entry.js +0 -290
- package/dist/esm/gataca-ssibutton_2.entry.js +0 -312
- package/dist/gatacaqr/p-0be4566d.js +0 -1
- package/dist/gatacaqr/p-3500ae66.entry.js +0 -1
- package/dist/gatacaqr/p-5ae5f952.js +0 -2
- package/dist/gatacaqr/p-68272823.entry.js +0 -1
- package/dist/gatacaqr/p-92a2e6f0.entry.js +0 -1
- package/dist/gatacaqr/p-ea783014.js +0 -1
- /package/dist/gatacaqr/{p-2cd7b062.js → p-bce7e590.js} +0 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-1332a8ce.js');
|
|
6
|
+
const gatIconCheck = require('./gat-icon-check-6b6780eb.js');
|
|
7
|
+
const utils = require('./utils-b4e62bc0.js');
|
|
8
|
+
|
|
9
|
+
const GatacaQRDisplay = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.qrData = undefined;
|
|
13
|
+
this.qrType = 'svg';
|
|
14
|
+
this.size = 256;
|
|
15
|
+
this.logoSize = 0;
|
|
16
|
+
this.logoSrc = undefined;
|
|
17
|
+
this.qrColor = '#1E1E20';
|
|
18
|
+
this.bgColor = '#FFFFFF';
|
|
19
|
+
this.rounded = true;
|
|
20
|
+
}
|
|
21
|
+
componentDidLoad() {
|
|
22
|
+
const qrCode = new gatIconCheck.QRCodeStyling({
|
|
23
|
+
data: this.qrData,
|
|
24
|
+
width: this.size,
|
|
25
|
+
height: this.size,
|
|
26
|
+
image: this.logoSize > 0 ? this.logoSrc || gatIconCheck.logoGatacaSvg : undefined,
|
|
27
|
+
margin: 10,
|
|
28
|
+
type: this.qrType,
|
|
29
|
+
dotsOptions: {
|
|
30
|
+
color: this.qrColor,
|
|
31
|
+
type: this.rounded ? 'dots' : 'square'
|
|
32
|
+
},
|
|
33
|
+
cornersSquareOptions: {
|
|
34
|
+
type: this.rounded ? 'extra-rounded' : 'square'
|
|
35
|
+
},
|
|
36
|
+
cornersDotOptions: {
|
|
37
|
+
type: this.rounded ? 'dot' : 'square'
|
|
38
|
+
},
|
|
39
|
+
imageOptions: {
|
|
40
|
+
margin: 2,
|
|
41
|
+
imageSize: this.logoSize
|
|
42
|
+
},
|
|
43
|
+
backgroundOptions: {
|
|
44
|
+
color: this.bgColor
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
qrCode.append(this.qr);
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
return (index.h("div", { ref: (el) => {
|
|
51
|
+
this.qr = el;
|
|
52
|
+
} }));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const QR = (props) => {
|
|
57
|
+
const { value, useLogo, logoSrc, size, qrType, style } = props;
|
|
58
|
+
return index.h("gataca-qrdisplay", { qrData: value, rounded: true, qrType: qrType, size: size, "logo-size": useLogo ? 0.33 : 0, "logo-src": logoSrc, qrColor: style === null || style === void 0 ? void 0 : style.color, bgColor: style === null || style === void 0 ? void 0 : style.bgColor });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const AnimatedLoader = (props) => {
|
|
62
|
+
const { color = '#4745B7' } = props;
|
|
63
|
+
const style = { '--loader-color': color };
|
|
64
|
+
return (index.h("div", { class: "containerLoader", style: style },
|
|
65
|
+
index.h("div", { class: "loader" },
|
|
66
|
+
index.h("div", { class: "loader__item loader__item__1" }),
|
|
67
|
+
index.h("div", { class: "loader__item loader__item__2" }),
|
|
68
|
+
index.h("div", { class: "loader__item loader__item__3" }),
|
|
69
|
+
index.h("div", { class: "loader__item loader__item__4" }),
|
|
70
|
+
index.h("div", { class: "loader__item loader__item__5" }),
|
|
71
|
+
index.h("div", { class: "loader__item loader__item__6" }),
|
|
72
|
+
index.h("div", { class: "loader__item loader__item__7" }),
|
|
73
|
+
index.h("div", { class: "loader__item loader__item__8" }))));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const ReadQR = (props) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const { modalWidth, readQrMessages, renderQR, url, sizeQR, style } = props;
|
|
79
|
+
const bgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.bgColor) ? style === null || style === void 0 ? void 0 : style.bgColor : 'white' };
|
|
80
|
+
const color = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#707074' };
|
|
81
|
+
return (index.h("div", { class: "blured", style: {
|
|
82
|
+
width: (modalWidth - 48).toString() + 'px',
|
|
83
|
+
height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
|
|
84
|
+
backgroundColor: style === null || style === void 0 ? void 0 : style.bgColor,
|
|
85
|
+
color: style === null || style === void 0 ? void 0 : style.color,
|
|
86
|
+
border: (style === null || style === void 0 ? void 0 : style.color) ? `1px dashed ${style === null || style === void 0 ? void 0 : style.color}` : `1px dashed #a1a1a1`
|
|
87
|
+
} },
|
|
88
|
+
index.h("div", { id: "notify", style: bgStyle },
|
|
89
|
+
index.h(AnimatedLoader, { color: style === null || style === void 0 ? void 0 : style.color }),
|
|
90
|
+
index.h("p", { class: "notify-text", style: color }, readQrMessages === null || readQrMessages === void 0 ? void 0 :
|
|
91
|
+
readQrMessages.title,
|
|
92
|
+
' '),
|
|
93
|
+
index.h("p", { class: "notify-text bold", style: color }, readQrMessages === null || readQrMessages === void 0 ? void 0 : readQrMessages.description)),
|
|
94
|
+
index.h("div", { id: "qrwait" }, renderQR(url, false, sizeQR))));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const RefreshIcon = (props) => {
|
|
98
|
+
const { height = 24, width = 24, color } = props;
|
|
99
|
+
const strokeColor = color ? color : '#8B8B8B';
|
|
100
|
+
return (index.h("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
101
|
+
index.h("path", { d: "M23 4V10H17", stroke: strokeColor, "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
102
|
+
index.h("path", { d: "M20.4899 15C19.8399 16.8399 18.6094 18.4187 16.984 19.4985C15.3586 20.5783 13.4263 21.1006 11.4783 20.9866C9.53026 20.8726 7.67203 20.1286 6.18363 18.8667C4.69524 17.6047 3.6573 15.8932 3.22625 13.9901C2.79519 12.0869 2.99436 10.0952 3.79374 8.31508C4.59313 6.53496 5.94942 5.06288 7.65823 4.12065C9.36705 3.17843 11.3358 2.81711 13.2678 3.09116C15.1999 3.3652 16.9905 4.25975 18.3699 5.64001L22.9999 10", stroke: strokeColor, "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" })));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const RetryButton = (props) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const { errorMessage, modalWidth, clickInsideBoxLabel, refreshQrLabel, scanQrLabel, waitingStartSessionLabel, style, display, renderRetryQR } = props;
|
|
108
|
+
const bgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.bgColor) ? style === null || style === void 0 ? void 0 : style.bgColor : 'white' };
|
|
109
|
+
const alertBgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.alertBgColor) ? style === null || style === void 0 ? void 0 : style.alertBgColor : '#ffdedf' };
|
|
110
|
+
const alertBorderColor = { borderColor: (style === null || style === void 0 ? void 0 : style.alertBorderColor) ? style === null || style === void 0 ? void 0 : style.alertBorderColor : '#ee888c' };
|
|
111
|
+
const color = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#707074' };
|
|
112
|
+
return (index.h("div", { class: "reload", style: {
|
|
113
|
+
width: (modalWidth - 48).toString() + 'px',
|
|
114
|
+
height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
|
|
115
|
+
border: (style === null || style === void 0 ? void 0 : style.color) ? `1px dashed ${style === null || style === void 0 ? void 0 : style.color}` : `1px dashed #a1a1a1`
|
|
116
|
+
} },
|
|
117
|
+
index.h("div", { id: "notify", onClick: () => display(), style: bgStyle },
|
|
118
|
+
index.h(RefreshIcon, { color: style === null || style === void 0 ? void 0 : style.color, height: 24, width: 24 }),
|
|
119
|
+
index.h("p", { class: "notify-text", style: color },
|
|
120
|
+
clickInsideBoxLabel,
|
|
121
|
+
' '),
|
|
122
|
+
errorMessage ? (index.h("p", { class: "notify-text bold", style: color }, refreshQrLabel)) : (index.h("p", { class: "notify-text bold", style: color }, scanQrLabel)),
|
|
123
|
+
errorMessage && (index.h("div", { class: "alert", style: Object.assign(Object.assign({ width: (modalWidth - 48).toString() + 'px' }, alertBgStyle), { border: `1px solid ${alertBorderColor}` }) },
|
|
124
|
+
index.h("img", { src: gatIconCheck.gatIconAlertSvg, height: 24, width: 24 }),
|
|
125
|
+
index.h("p", { style: { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#1e1e20' } }, errorMessage)))),
|
|
126
|
+
index.h("div", { id: "qrwait" }, renderRetryQR(waitingStartSessionLabel))));
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const Success = (props) => {
|
|
130
|
+
const { modalHeight, successLoginLabel, style } = props;
|
|
131
|
+
const colorStyle = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#1e1e20' };
|
|
132
|
+
return (index.h("div", { class: 'success', style: {
|
|
133
|
+
height: modalHeight ? (modalHeight === null || modalHeight === void 0 ? void 0 : modalHeight.toString()) + 'px' : '300px'
|
|
134
|
+
} },
|
|
135
|
+
index.h("img", { src: gatIconCheck.gatIconCheckSvg, height: 52, width: 52 }),
|
|
136
|
+
index.h("p", { class: "successMsg", style: colorStyle }, successLoginLabel)));
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const gatacaQrCss = "@import url(\"https://fonts.googleapis.com/css2?family=Ubuntu:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Poppins:wght@100;300;400;500;600;700&display=swap\"); @import url(\"https://fonts.googleapis.com/css2?family=Work+Sans:wght@300;400&display=swap\"); html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:\"\";content:none}table{border-collapse:collapse;border-spacing:0}.img-fluid{height:auto;max-width:50%}img{margin-left:auto;margin-right:auto}.brandSection{padding-top:5px;display:flex;align-items:center}.brandSection .gatacaImgSmall{height:13px;width:13px;margin:0;margin-right:10px}.popUpContainer .large-modal{width:300px;min-height:350px}.popUpContainer .modal-window{position:relative;border-radius:6px;overflow:hidden;color:rgba(24, 27, 94, 0.8);box-shadow:0px 3px 10px rgba(48, 48, 48, 0.1);display:flex;flex-direction:column;justify-content:space-between;align-items:center;display:flex;z-index:1001;padding:1px;background-color:white;border-radius:12px;-webkit-transition:opacity 0.5s, visibility 0s 0.5s;transition:opacity 0.5s, visibility 0s 0.5s;visibility:hidden;opacity:0}.popUpContainer .modal-window__content{width:100%;height:100%;text-align:left}.popUpContainer .modal-window__content .hidenText{display:none}.popUpContainer .modal-window .modalText{font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px;margin-top:10px;letter-spacing:1px}.popUpContainer .modal-window .qrTitleContainer{padding:14px 24px;padding-bottom:0px}.popUpContainer .modal-window .qrTitle{font-size:20px;font-weight:600;line-height:23.5px}.popUpContainer .modal-window .qrDescription{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074}.popUpContainer .modal-window .bold{font-weight:700}.popUpContainer .modal-window .qrBrand{margin-top:4px;font-size:14px;font-weight:400;line-height:16.5px;display:flex;align-items:center}.popUpContainer .modal-window .qrBrand img{margin-left:5px;height:12px}.popUpContainer .modal-window .qr-section{width:252px;height:252px}.popUpContainer .noBoxShadow{box-shadow:none}.popUpContainer .is-visible{opacity:1;visibility:visible}.is-transparent{opacity:0}.success{display:flex;height:300px;flex-direction:column;justify-content:center;align-items:center;padding:0px}.success>img{padding-bottom:12px}.success>.successMsg{line-height:23.5px;color:var(--neutral-1000, #1e1e20);text-align:center;font-family:\"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:20px;font-style:normal;font-weight:700;line-height:24px}.reload,.blured{height:252px;width:252px;border:1px dashed #a1a1a1;border-radius:20px;position:relative;top:24px;margin:0 24px 24px;display:flex;overflow:hidden;justify-content:center;align-items:center}#qrwait{display:flex;justify-content:center}#qrwait,#notify{width:100%;height:100%;top:0;left:0;border-radius:20px}#notify{z-index:10;position:absolute;justify-self:center;justify-items:center;justify-content:center;align-items:center;align-content:center;display:flex;flex-direction:column;box-sizing:border-box;padding:20px;background:rgba(255, 255, 255, 0.95)}#notify>svg{padding-bottom:12px}.alert{display:flex;flex-direction:row;justify-content:start;width:252px;position:absolute;bottom:0px;border:1px solid #ee888c;background:#ffdedf;border-radius:11px;box-sizing:border-box;padding:12px;align-items:center;gap:12px}.alert>img{margin:0}.alert>p{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;margin-top:0;line-height:16px;color:#1e1e20}.notify-text{font-family:\"Poppins\", \"Ubuntu\", \"Work Sans\", \"Helvetica Neue\", sans-serif;font-size:14px;font-style:normal;font-weight:400;line-height:16px;color:#707074;text-align:center}.containerLoader{display:flex;justify-content:center;align-items:center;width:30px;height:30px;margin-bottom:12px}.loader{position:relative;margin-left:0 !important}.loader__item{position:absolute;width:9.68px;height:4px;background-color:var(--loader-color, #4745B7);border-radius:2px;--to-opacity:1;opacity:var(--to-opacity)}.loader__item__1{transform:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-webkit-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-moz-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);-o-animation:translate(2.5846212025px, 5.4246212025px) rotate(45deg);--to-opacity:calc(1 - (0 / 8));animation:blink 0.8333333333s linear 0.1041666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.1041666667s infinite;-moz-animation:blink 0.8333333333s linear 0.1041666667s infinite;-o-animation:blink 0.8333333333s linear 0.1041666667s infinite}.loader__item__2{transform:translate(-4.84px, 8.5px) rotate(90deg);-webkit-animation:translate(-4.84px, 8.5px) rotate(90deg);-moz-animation:translate(-4.84px, 8.5px) rotate(90deg);-o-animation:translate(-4.84px, 8.5px) rotate(90deg);--to-opacity:calc(1 - (1 / 8));animation:blink 0.8333333333s linear 0.2083333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.2083333333s infinite;-moz-animation:blink 0.8333333333s linear 0.2083333333s infinite;-o-animation:blink 0.8333333333s linear 0.2083333333s infinite}.loader__item__3{transform:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-webkit-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-moz-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);-o-animation:translate(-12.2646212025px, 5.4246212025px) rotate(135deg);--to-opacity:calc(1 - (2 / 8));animation:blink 0.8333333333s linear 0.3125s infinite;-webkit-animation:blink 0.8333333333s linear 0.3125s infinite;-moz-animation:blink 0.8333333333s linear 0.3125s infinite;-o-animation:blink 0.8333333333s linear 0.3125s infinite}.loader__item__4{transform:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-webkit-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-moz-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);-o-animation:translate(-15.3399999992px, -1.9999999999px) rotate(180deg);--to-opacity:calc(1 - (3 / 8));animation:blink 0.8333333333s linear 0.4166666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.4166666667s infinite;-moz-animation:blink 0.8333333333s linear 0.4166666667s infinite;-o-animation:blink 0.8333333333s linear 0.4166666667s infinite}.loader__item__5{transform:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-webkit-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-moz-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);-o-animation:translate(-12.2646210959px, -9.4246211842px) rotate(225deg);--to-opacity:calc(1 - (4 / 8));animation:blink 0.8333333333s linear 0.5208333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.5208333333s infinite;-moz-animation:blink 0.8333333333s linear 0.5208333333s infinite;-o-animation:blink 0.8333333333s linear 0.5208333333s infinite}.loader__item__6{transform:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-webkit-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-moz-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);-o-animation:translate(-4.8399941857px, -12.499998805px) rotate(270deg);--to-opacity:calc(1 - (5 / 8));animation:blink 0.8333333333s linear 0.625s infinite;-webkit-animation:blink 0.8333333333s linear 0.625s infinite;-moz-animation:blink 0.8333333333s linear 0.625s infinite;-o-animation:blink 0.8333333333s linear 0.625s infinite}.loader__item__7{transform:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-webkit-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-moz-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);-o-animation:translate(2.5847915061px, -9.4245803212px) rotate(315deg);--to-opacity:calc(1 - (6 / 8));animation:blink 0.8333333333s linear 0.7291666667s infinite;-webkit-animation:blink 0.8333333333s linear 0.7291666667s infinite;-moz-animation:blink 0.8333333333s linear 0.7291666667s infinite;-o-animation:blink 0.8333333333s linear 0.7291666667s infinite}.loader__item__8{transform:translate(5.6631628524px, -1.99913122px) rotate(360deg);-webkit-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-moz-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);-o-animation:translate(5.6631628524px, -1.99913122px) rotate(360deg);--to-opacity:calc(1 - (7 / 8));animation:blink 0.8333333333s linear 0.8333333333s infinite;-webkit-animation:blink 0.8333333333s linear 0.8333333333s infinite;-moz-animation:blink 0.8333333333s linear 0.8333333333s infinite;-o-animation:blink 0.8333333333s linear 0.8333333333s infinite}.loader__item__8{max-width:8.5px}@keyframes blink{0%{opacity:1}100%{opacity:var(--to-opacity)}}@keyframes rotate{0%{transform:rotate(0deg)}100%{background:rotate(360deg)}}";
|
|
140
|
+
|
|
141
|
+
const DEEP_LINK_PREFIX = 'https://api.gataca.io/qr/redirect.html';
|
|
142
|
+
//Default values
|
|
143
|
+
const DEFAULT_SESSION_TIMEOUT$1 = 300; //5mins as in connect
|
|
144
|
+
const DEFAULT_POLLING_FREQ$1 = 3;
|
|
145
|
+
const GatacaQR = class {
|
|
146
|
+
constructor(hostRef) { index.registerInstance(this, hostRef); this.gatacaLoginCompleted = index.createEvent(this, "gatacaLoginCompleted", 7); this.gatacaLoginFailed = index.createEvent(this, "gatacaLoginFailed", 7); this.checkStatus = undefined; this.createSession = undefined; this.successCallback = undefined; this.errorCallback = undefined; this.qrRole = undefined; this.qrType = 'svg'; this.callbackServer = undefined; this.autostart = true; this.autorefresh = false; this.v = '3'; this.qrModalTitle = 'Quick Access'; this.modalTitleColor = '#4745B7'; this.qrModalDescription = 'Sign up or sign in by scanning the QR Code with the Gataca Wallet'; this.hideModalTexts = false; this.hideModalBoxShadow = false; this.hideBrandTitle = false; this.logoSize = 0; this.logoSrc = gatIconCheck.logoGatacaSvg; this.qrSize = 300; this.modalWidth = 300; this.modalHeight = undefined; this.qrCodeExpiredLabel = 'QR Code expired'; this.credentialsNotValidatedLabel = 'User credentials not validated'; this.clickInsideBoxLabel = 'Click inside the box to'; this.refreshQrLabel = 'Refresh QR Code'; this.scanQrLabel = 'Scan QR Code'; this.userNotScanInTimeErrorLabel = 'User did not scan the QR in the allowed time'; this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated"; this.failedLoginErrorLabel = 'No successful login'; this.successLoginLabel = 'Successful Connection!'; this.byBrandLabel = 'by Gataca'; this.waitingStartSessionLabel = 'waiting to start a session'; this.readQrTitle = 'Processing...'; this.readQrDescription = 'Please wait a moment'; this.hideQrModalDescription = false; this.sessionTimeout = DEFAULT_SESSION_TIMEOUT$1; this.pollingFrequency = DEFAULT_POLLING_FREQ$1; this.dynamicLink = true; this.qrStyle = undefined; this.sessionId = undefined; this.authenticationRequest = undefined; this.sessionData = undefined; this.result = utils.RESULT_STATUS.NOT_STARTED; }
|
|
147
|
+
disconnectedCallback() {
|
|
148
|
+
this.stop();
|
|
149
|
+
}
|
|
150
|
+
async componentDidLoad() {
|
|
151
|
+
if (this.autostart) {
|
|
152
|
+
await this.display();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Force manually the display of a QR
|
|
157
|
+
*/
|
|
158
|
+
async display() {
|
|
159
|
+
await this.getSessionId();
|
|
160
|
+
this.result = utils.RESULT_STATUS.ONGOING;
|
|
161
|
+
this.poll()
|
|
162
|
+
.then((data) => {
|
|
163
|
+
this.result = utils.RESULT_STATUS.SUCCESS;
|
|
164
|
+
this.sessionData = data;
|
|
165
|
+
this.gatacaLoginCompleted.emit(data);
|
|
166
|
+
this.successCallback(data);
|
|
167
|
+
})
|
|
168
|
+
.catch((err) => {
|
|
169
|
+
this.clean();
|
|
170
|
+
let expired = err === utils.RESULT_STATUS.EXPIRED;
|
|
171
|
+
if (expired && this.autorefresh) {
|
|
172
|
+
this.display();
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
if (err !== utils.RESULT_STATUS.NOT_STARTED) {
|
|
176
|
+
let error = expired ? new Error(this.userNotScanInTimeErrorLabel) : new Error(this.credsNotValidatedErrorLabel);
|
|
177
|
+
this.result = err;
|
|
178
|
+
this.gatacaLoginFailed.emit(error);
|
|
179
|
+
this.errorCallback(error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
if (utils.checkMobile() && this.dynamicLink) {
|
|
184
|
+
window.location.href = this.getLink();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Stop manually an ongoing session
|
|
189
|
+
*/
|
|
190
|
+
async stop() {
|
|
191
|
+
this.clean();
|
|
192
|
+
if (this.result === utils.RESULT_STATUS.ONGOING || utils.RESULT_STATUS.READ) {
|
|
193
|
+
this.result = utils.RESULT_STATUS.NOT_STARTED;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
clean() {
|
|
197
|
+
this.sessionData = undefined;
|
|
198
|
+
this.sessionId = undefined;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Retrieve manually the session data on a successful login
|
|
202
|
+
*/
|
|
203
|
+
async getSessionData() {
|
|
204
|
+
return this.sessionData ? Promise.resolve(this.sessionData) : Promise.reject(new Error(this.failedLoginErrorLabel));
|
|
205
|
+
}
|
|
206
|
+
async getSessionId() {
|
|
207
|
+
if (this.sessionId) {
|
|
208
|
+
return this.sessionId;
|
|
209
|
+
}
|
|
210
|
+
let { sessionId, authenticationRequest } = await this.createSession();
|
|
211
|
+
this.sessionId = sessionId;
|
|
212
|
+
this.authenticationRequest = authenticationRequest;
|
|
213
|
+
return this.sessionId;
|
|
214
|
+
}
|
|
215
|
+
getLink() {
|
|
216
|
+
if (this.v === '2') {
|
|
217
|
+
return this.authenticationRequest;
|
|
218
|
+
}
|
|
219
|
+
const authRequestEncoded = '?dl=' + utils.base64UrlEncode(this.authenticationRequest);
|
|
220
|
+
return DEEP_LINK_PREFIX + authRequestEncoded;
|
|
221
|
+
}
|
|
222
|
+
async poll() {
|
|
223
|
+
let endTime = new Date().getTime() + (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT$1) * 1000;
|
|
224
|
+
let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ$1) * 1000;
|
|
225
|
+
let checkFunc = async (component) => {
|
|
226
|
+
if (component.result === utils.RESULT_STATUS.NOT_STARTED) {
|
|
227
|
+
return { result: utils.RESULT_STATUS.NOT_STARTED };
|
|
228
|
+
}
|
|
229
|
+
let id = await component.getSessionId();
|
|
230
|
+
return component.checkStatus(id);
|
|
231
|
+
};
|
|
232
|
+
let component = this;
|
|
233
|
+
let checkCondition = async function (resolve, reject) {
|
|
234
|
+
// If the condition is met, we're done!
|
|
235
|
+
let { result, data } = await checkFunc(component);
|
|
236
|
+
switch (result) {
|
|
237
|
+
case utils.RESULT_STATUS.SUCCESS:
|
|
238
|
+
resolve(data);
|
|
239
|
+
break;
|
|
240
|
+
case utils.RESULT_STATUS.READ:
|
|
241
|
+
component.result = utils.RESULT_STATUS.READ;
|
|
242
|
+
case utils.RESULT_STATUS.ONGOING:
|
|
243
|
+
if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
|
|
244
|
+
setTimeout(checkCondition, interval, resolve, reject);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
reject(utils.RESULT_STATUS.EXPIRED);
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
reject(result);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
return new Promise(checkCondition);
|
|
256
|
+
}
|
|
257
|
+
renderQRSection() {
|
|
258
|
+
switch (this.result) {
|
|
259
|
+
case utils.RESULT_STATUS.NOT_STARTED:
|
|
260
|
+
return this.renderRetryButton();
|
|
261
|
+
case utils.RESULT_STATUS.ONGOING:
|
|
262
|
+
return this.renderQR(this.getLink(), true);
|
|
263
|
+
case utils.RESULT_STATUS.EXPIRED:
|
|
264
|
+
return this.renderRetryButton(this.qrCodeExpiredLabel);
|
|
265
|
+
case utils.RESULT_STATUS.FAILED:
|
|
266
|
+
return this.renderRetryButton(this.credentialsNotValidatedLabel);
|
|
267
|
+
case utils.RESULT_STATUS.SUCCESS:
|
|
268
|
+
return this.renderSuccess();
|
|
269
|
+
case utils.RESULT_STATUS.READ:
|
|
270
|
+
return this.renderReadQR({
|
|
271
|
+
title: this === null || this === void 0 ? void 0 : this.readQrTitle,
|
|
272
|
+
description: this === null || this === void 0 ? void 0 : this.readQrDescription
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
renderSuccess() {
|
|
277
|
+
return index.h(Success, { modalHeight: this === null || this === void 0 ? void 0 : this.modalHeight, successLoginLabel: this === null || this === void 0 ? void 0 : this.successLoginLabel, style: this === null || this === void 0 ? void 0 : this.qrStyle });
|
|
278
|
+
}
|
|
279
|
+
renderRetryButton(errorMessage) {
|
|
280
|
+
return (index.h(RetryButton, { errorMessage: errorMessage, modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, clickInsideBoxLabel: this === null || this === void 0 ? void 0 : this.clickInsideBoxLabel, refreshQrLabel: this === null || this === void 0 ? void 0 : this.refreshQrLabel, scanQrLabel: this === null || this === void 0 ? void 0 : this.scanQrLabel, waitingStartSessionLabel: this === null || this === void 0 ? void 0 : this.waitingStartSessionLabel, display: this.display.bind(this), renderRetryQR: this.renderRetryQR.bind(this), style: this === null || this === void 0 ? void 0 : this.qrStyle }));
|
|
281
|
+
}
|
|
282
|
+
renderReadQR(readQrMessages) {
|
|
283
|
+
return (index.h(ReadQR, { modalWidth: this === null || this === void 0 ? void 0 : this.modalWidth, readQrMessages: readQrMessages, url: this.getLink(), sizeQR: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, renderQR: this.renderQR.bind(this), style: this.qrStyle }));
|
|
284
|
+
}
|
|
285
|
+
renderQR(value, useLogo, sizeQR) {
|
|
286
|
+
return index.h(QR, { value: value, qrType: this.qrType, useLogo: useLogo && this.logoSize !== 0, size: sizeQR || (this === null || this === void 0 ? void 0 : this.qrSize) || undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc, style: this === null || this === void 0 ? void 0 : this.qrStyle });
|
|
287
|
+
}
|
|
288
|
+
renderRetryQR(value, useLogo) {
|
|
289
|
+
return index.h(QR, { value: value, useLogo: useLogo && this.logoSize !== 0, qrType: this.qrType, size: (this === null || this === void 0 ? void 0 : this.qrSize) ? (this === null || this === void 0 ? void 0 : this.qrSize) - 50 : undefined, logoSrc: this === null || this === void 0 ? void 0 : this.logoSrc, style: this === null || this === void 0 ? void 0 : this.qrStyle });
|
|
290
|
+
}
|
|
291
|
+
render() {
|
|
292
|
+
var _a, _b, _c, _d, _e, _f;
|
|
293
|
+
return (index.h("div", { class: "popUpContainer" }, index.h("div", { class: `is-visible modal-window ${this.hideModalTexts ? '' : 'large-modal'} ${this.hideModalBoxShadow ? 'noBoxShadow' : ''}`, style: {
|
|
294
|
+
width: (this.modalWidth - 2).toString() + 'px',
|
|
295
|
+
height: this.modalHeight ? ((_a = (this.modalHeight - 2)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
|
|
296
|
+
backgroundColor: ((_b = this === null || this === void 0 ? void 0 : this.qrStyle) === null || _b === void 0 ? void 0 : _b.bgColor) ? (_c = this === null || this === void 0 ? void 0 : this.qrStyle) === null || _c === void 0 ? void 0 : _c.bgColor : 'white',
|
|
297
|
+
boxShadow: ((_d = this === null || this === void 0 ? void 0 : this.qrStyle) === null || _d === void 0 ? void 0 : _d.boxShadow) ? (_e = this === null || this === void 0 ? void 0 : this.qrStyle) === null || _e === void 0 ? void 0 : _e.boxShadow : '0px 3px 10px rgba(48, 48, 48, 0.1);'
|
|
298
|
+
}, onClick: (event) => {
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
} }, index.h("div", { class: "modal-window__content" }, index.h("div", { class: `qrTitleContainer ${this.hideModalTexts ? 'hidenText' : ''}` }, index.h("p", { class: "qrTitle modalText", style: { color: this.modalTitleColor || '#1e1e20' } }, this.qrModalTitle), !this.hideBrandTitle && (index.h("p", { class: "qrBrand modalText" }, this.byBrandLabel, ' ', index.h("span", null, index.h("img", { src: gatIconCheck.logoGatacaSvg })))), this.result !== utils.RESULT_STATUS.SUCCESS && !this.hideQrModalDescription && index.h("p", { class: "qrDescription modalText" }, this.qrModalDescription)), index.h("div", { class: "qrSection", style: {
|
|
301
|
+
width: this.modalWidth.toString() + 'px',
|
|
302
|
+
height: this.modalWidth ? ((_f = this.modalWidth) === null || _f === void 0 ? void 0 : _f.toString()) + 'px' : ''
|
|
303
|
+
} }, this.renderQRSection())))));
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
GatacaQR.style = gatacaQrCss;
|
|
307
|
+
|
|
308
|
+
const gatacaSsibuttonCss = "@import url(\"https://fonts.googleapis.com/css2?family=Work+Sans:wght@300;400&display=swap\"); html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:\"\";content:none}table{border-collapse:collapse;border-spacing:0}.img-fluid{height:auto;max-width:50%}img{margin-left:auto;margin-right:auto}.buttonContainer{display:inline-block;text-align:right;padding:10px;position:relative}.gatacaButtonWrapper{margin:8px}.gatacaButtonWrapper .gatacaButton{display:flex;min-width:100px;padding:8px 8px;background-color:white;font-size:12px;font-family:\"Work Sans\", sans-serif;letter-spacing:1px;font-weight:2;justify-content:space-between;align-items:center;border-radius:6px;border:1px solid rgba(24, 27, 94, 0.5);color:rgba(24, 27, 94, 0.8);box-shadow:0px 1px 3px rgba(48, 48, 48, 0.15);cursor:pointer}.gatacaButtonWrapper .gatacaButton>span{margin-right:10px}.gatacaButtonWrapper .gatacaButton:hover{box-shadow:0px 2px 8px rgba(48, 48, 48, 0.1)}.gatacaButtonWrapper .buttonText{text-align:right;font-size:8px;color:rgba(24, 27, 94, 0.5);font-family:\"Helvetica Neue\", sans-serif;letter-spacing:1px;padding-right:8px;font-weight:1}.gatacaButtonWrapper .buttonImg{height:25px;width:25px;margin:0;margin-right:20px}";
|
|
309
|
+
|
|
310
|
+
const PHONE_ICON = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAHvSURBVHgB3ZZPTttAFMbfe3YjL7qYLopcpZXSG7Q3CDfIsqrSJpyg5QQtJ2h7glgUdVs4AeEE5AYEQSDAgtnw357Hm0hAQDaeIRFCfFKyeKPxzzPzvc+DUKCZN80GEv1ABgWOQgSdGbOwv7u0nDueV4zjTzUIKhuAZna4vdQFR828azbI0K/TI/qodaLvjlP+tLDGDCs+IKv9Lbsi7kcv0w9541Q0EREPYcoieEQ9KiyECRXHzbpBUOcnYTfPFOOaaGVx9WsLiDrSIp0iU0wFNgIx/AQyc9I/OmOjy+Y8aBvHQcDUYebewc6/Xtk8J5htcg5efEPGhk0JtqkyBjo7DuZcnuO2sqCyKv8rUDmfTS9IBURqBAL+I6CkzBjOMOs22TLY21n8fl17KzXR3uDvb/CQk0GEdfvN07QvpnAOaGfYaRT25JzU6+rnG2tTpcWAy+Cp0m3U/URLms8HWfg/rn6RFaGSs9KQkZMpvGBWNs2Vandt46ac6YNBuc0fDLMaOU5DFybQ8039p/KJ4bq4rwPewtqoM/1gsCm/NfBXvWjgHhhuDAeLyd3qVSifHQULeZkou9EqemLhmUmav8qrZ4GEMGA7ivzjKvfeqGptFV2YdWPMPHHq0cCh3DdpVdLl/XCY9J1gVvbCiWa6N+JLocPFjCsx9cAAAAAASUVORK5CYII=';
|
|
311
|
+
//Default values
|
|
312
|
+
const DEFAULT_SESSION_TIMEOUT = 300; //5mins as in connect
|
|
313
|
+
const DEFAULT_POLLING_FREQ = 3;
|
|
314
|
+
const GatacaSSIButton = class {
|
|
315
|
+
constructor(hostRef) {
|
|
316
|
+
index.registerInstance(this, hostRef);
|
|
317
|
+
this.gatacaLoginCompleted = index.createEvent(this, "gatacaLoginCompleted", 7);
|
|
318
|
+
this.gatacaLoginFailed = index.createEvent(this, "gatacaLoginFailed", 7);
|
|
319
|
+
this.gatacaButtonPushed = index.createEvent(this, "gatacaButtonPushed", 7);
|
|
320
|
+
this.getRequestFromUri = async (authRequest) => {
|
|
321
|
+
const requrl = new URL(authRequest);
|
|
322
|
+
const requri = requrl.searchParams.get('request_uri');
|
|
323
|
+
if (requri) {
|
|
324
|
+
const response = await fetch(requri, {
|
|
325
|
+
method: 'GET',
|
|
326
|
+
headers: {
|
|
327
|
+
'Content-Type': 'application/json'
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const jwt = await response.json();
|
|
331
|
+
const parts = jwt.split('.');
|
|
332
|
+
const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
333
|
+
const decoded = window.atob(base64);
|
|
334
|
+
let parsed = JSON.parse(decoded);
|
|
335
|
+
parsed.response_mode = 'dc_api';
|
|
336
|
+
return parsed;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
this.buttonText = 'Easy login';
|
|
340
|
+
this.buttonDCAPIText = 'Login with Device Credentials';
|
|
341
|
+
this.qrType = 'svg';
|
|
342
|
+
this.autostart = true;
|
|
343
|
+
this.checkStatus = undefined;
|
|
344
|
+
this.createSession = undefined;
|
|
345
|
+
this.fillSession = undefined;
|
|
346
|
+
this.successCallback = undefined;
|
|
347
|
+
this.errorCallback = undefined;
|
|
348
|
+
this.handleCheckAppLoading = undefined;
|
|
349
|
+
this.checkAppTimeout = 6;
|
|
350
|
+
this.qrRole = undefined;
|
|
351
|
+
this.callbackServer = undefined;
|
|
352
|
+
this.sessionTimeout = undefined;
|
|
353
|
+
this.pollingFrequency = undefined;
|
|
354
|
+
this.autorefresh = false;
|
|
355
|
+
this.v = '3';
|
|
356
|
+
this.qrModalTitle = 'Quick Access';
|
|
357
|
+
this.modalTitleColor = '#4745B7';
|
|
358
|
+
this.qrModalDescription = 'Sign up or sign in by scanning the QR Code with the Gataca Wallet';
|
|
359
|
+
this.hideBrandTitle = false;
|
|
360
|
+
this.dynamicLink = true;
|
|
361
|
+
this.logoSize = 0;
|
|
362
|
+
this.logoSrc = undefined;
|
|
363
|
+
this.qrCodeExpiredLabel = 'QR Code expired';
|
|
364
|
+
this.credentialsNotValidatedLabel = 'User credentials not validated';
|
|
365
|
+
this.clickInsideBoxLabel = 'Click inside the box to';
|
|
366
|
+
this.refreshQrLabel = 'Refresh QR Code';
|
|
367
|
+
this.scanQrLabel = 'Scan QR Code';
|
|
368
|
+
this.userNotScanInTimeErrorLabel = 'User did not scan the QR in the allowed time';
|
|
369
|
+
this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated";
|
|
370
|
+
this.failedLoginErrorLabel = 'No successful login';
|
|
371
|
+
this.successLoginLabel = 'Successful Connection!';
|
|
372
|
+
this.byBrandLabel = 'by Gataca';
|
|
373
|
+
this.waitingStartSessionLabel = 'waiting to start a session';
|
|
374
|
+
this.enableDcApi = false;
|
|
375
|
+
this.hideQrModalDescription = false;
|
|
376
|
+
this.qrStyle = undefined;
|
|
377
|
+
this.open = false;
|
|
378
|
+
this.sessionId = undefined;
|
|
379
|
+
this.authenticationRequest = undefined;
|
|
380
|
+
this.sessionData = undefined;
|
|
381
|
+
this.result = utils.RESULT_STATUS.NOT_STARTED;
|
|
382
|
+
this.qr = (index.h("gataca-qr", { ref: (el) => (this.qrElement = el), checkStatus: this.checkStatus, createSession: this.createSession, successCallback: this.successCallback, errorCallback: this.errorCallback, qrRole: this.qrRole, qrType: this.qrType, callbackServer: this.callbackServer, sessionTimeout: this.sessionTimeout, pollingFrequency: this.pollingFrequency, autostart: this.autostart, autorefresh: this.autorefresh, v: this.v, qrModalTitle: this.qrModalTitle, qrModalDescription: this.qrModalDescription, hideBrandTitle: this.hideBrandTitle, dynamicLink: this.dynamicLink, logoSize: this.logoSize, logoSrc: this.logoSrc, modalTitleColor: this.modalTitleColor, qrCodeExpiredLabel: this.qrCodeExpiredLabel, credentialsNotValidatedLabel: this.credentialsNotValidatedLabel, clickInsideBoxLabel: this.clickInsideBoxLabel, refreshQrLabel: this.refreshQrLabel, scanQrLabel: this.scanQrLabel, userNotScanInTimeErrorLabel: this.userNotScanInTimeErrorLabel, credsNotValidatedErrorLabel: this.credsNotValidatedErrorLabel, failedLoginErrorLabel: this.failedLoginErrorLabel, successLoginLabel: this.successLoginLabel, byBrandLabel: this.byBrandLabel, waitingStartSessionLabel: this.waitingStartSessionLabel, hideQrModalDescription: this.hideQrModalDescription, qrStyle: this.qrStyle }));
|
|
383
|
+
}
|
|
384
|
+
supportsDCAPI() {
|
|
385
|
+
// let mobile = checkMobile();
|
|
386
|
+
// if (!mobile) return false;
|
|
387
|
+
if (!this.enableDcApi) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
//@ts-ignore
|
|
391
|
+
if (typeof window.DigitalCredential === 'undefined')
|
|
392
|
+
return false;
|
|
393
|
+
const protocols = ['org-iso-mdoc', 'openid4vp', 'openid4vci'];
|
|
394
|
+
//@ts-ignore
|
|
395
|
+
const supportedProtocols = protocols.filter(window.DigitalCredential.userAgentAllowsProtocol);
|
|
396
|
+
console.log(supportedProtocols, protocols);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Retrieve manually the session data on a successful login
|
|
401
|
+
*/
|
|
402
|
+
async getSessionData() {
|
|
403
|
+
return this.qr.getSessionData();
|
|
404
|
+
}
|
|
405
|
+
async getSessionId() {
|
|
406
|
+
if (this.sessionId) {
|
|
407
|
+
return this.sessionId;
|
|
408
|
+
}
|
|
409
|
+
let { sessionId, authenticationRequest } = await this.createSession();
|
|
410
|
+
this.sessionId = sessionId;
|
|
411
|
+
this.authenticationRequest = authenticationRequest;
|
|
412
|
+
return this.sessionId;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Force manually the start polling
|
|
416
|
+
*/
|
|
417
|
+
async startMobilePolling() {
|
|
418
|
+
await this.getSessionId();
|
|
419
|
+
this.result = utils.RESULT_STATUS.ONGOING;
|
|
420
|
+
this.poll()
|
|
421
|
+
.then((data) => {
|
|
422
|
+
this.result = utils.RESULT_STATUS.SUCCESS;
|
|
423
|
+
this.sessionData = data;
|
|
424
|
+
this.gatacaLoginCompleted.emit(data);
|
|
425
|
+
this.successCallback(data);
|
|
426
|
+
})
|
|
427
|
+
.catch((err) => {
|
|
428
|
+
this.clean();
|
|
429
|
+
let expired = err === utils.RESULT_STATUS.EXPIRED;
|
|
430
|
+
if (expired && this.autorefresh) {
|
|
431
|
+
this.startMobilePolling();
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
if (err !== utils.RESULT_STATUS.NOT_STARTED) {
|
|
435
|
+
let error = expired ? new Error(this.userNotScanInTimeErrorLabel) : new Error(this.credsNotValidatedErrorLabel);
|
|
436
|
+
this.result = err;
|
|
437
|
+
this.gatacaLoginFailed.emit(error);
|
|
438
|
+
this.errorCallback(error);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Stop manually an ongoing session
|
|
445
|
+
*/
|
|
446
|
+
async stop() {
|
|
447
|
+
this.clean();
|
|
448
|
+
if (this.result === utils.RESULT_STATUS.ONGOING || utils.RESULT_STATUS.READ) {
|
|
449
|
+
this.result = utils.RESULT_STATUS.NOT_STARTED;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
clean() {
|
|
453
|
+
this.sessionData = undefined;
|
|
454
|
+
this.sessionId = undefined;
|
|
455
|
+
}
|
|
456
|
+
renderModal() {
|
|
457
|
+
return this.qr;
|
|
458
|
+
}
|
|
459
|
+
async poll() {
|
|
460
|
+
let endTime = new Date().getTime() + (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT) * 1000;
|
|
461
|
+
let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ) * 1000;
|
|
462
|
+
let checkFunc = async (component) => {
|
|
463
|
+
if (component.result === utils.RESULT_STATUS.NOT_STARTED) {
|
|
464
|
+
return { result: utils.RESULT_STATUS.NOT_STARTED };
|
|
465
|
+
}
|
|
466
|
+
let id = await component.getSessionId();
|
|
467
|
+
return component.checkStatus(id);
|
|
468
|
+
};
|
|
469
|
+
let component = this;
|
|
470
|
+
let checkCondition = async function (resolve, reject) {
|
|
471
|
+
// If the condition is met, we're done!
|
|
472
|
+
let { result, data } = await checkFunc(component);
|
|
473
|
+
switch (result) {
|
|
474
|
+
case utils.RESULT_STATUS.SUCCESS:
|
|
475
|
+
resolve(data);
|
|
476
|
+
break;
|
|
477
|
+
case utils.RESULT_STATUS.READ:
|
|
478
|
+
component.result = utils.RESULT_STATUS.READ;
|
|
479
|
+
case utils.RESULT_STATUS.ONGOING:
|
|
480
|
+
if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
|
|
481
|
+
setTimeout(checkCondition, interval, resolve, reject);
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
reject(utils.RESULT_STATUS.EXPIRED);
|
|
485
|
+
}
|
|
486
|
+
break;
|
|
487
|
+
default:
|
|
488
|
+
reject(result);
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
return new Promise(checkCondition);
|
|
493
|
+
}
|
|
494
|
+
isAppInstalled(appScheme, callback) {
|
|
495
|
+
let timeout;
|
|
496
|
+
let detected = false;
|
|
497
|
+
if (appScheme === null || appScheme === void 0 ? void 0 : appScheme.length) {
|
|
498
|
+
window.location.href = appScheme;
|
|
499
|
+
}
|
|
500
|
+
const waitTimeToCheckApp = this.checkAppTimeout * 1000;
|
|
501
|
+
timeout = setTimeout(() => {
|
|
502
|
+
if (!detected) {
|
|
503
|
+
callback(false);
|
|
504
|
+
}
|
|
505
|
+
cleanup();
|
|
506
|
+
}, waitTimeToCheckApp);
|
|
507
|
+
const handleVisibilityChange = () => {
|
|
508
|
+
if (document.hidden) {
|
|
509
|
+
detected = true;
|
|
510
|
+
callback(true);
|
|
511
|
+
if (!this.autostart) {
|
|
512
|
+
this.startMobilePolling();
|
|
513
|
+
}
|
|
514
|
+
cleanup();
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
518
|
+
function cleanup() {
|
|
519
|
+
clearTimeout(timeout);
|
|
520
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
renderDesktopButton() {
|
|
524
|
+
return (index.h("div", { class: "gatacaButtonWrapper" }, index.h("button", { class: "gatacaButton", onClick: () => {
|
|
525
|
+
this.open = !this.open;
|
|
526
|
+
setTimeout(() => {
|
|
527
|
+
var _a, _b;
|
|
528
|
+
if (this.open) {
|
|
529
|
+
(_a = this.qrElement) === null || _a === void 0 ? void 0 : _a.display();
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
(_b = this.qrElement) === null || _b === void 0 ? void 0 : _b.stop();
|
|
533
|
+
}
|
|
534
|
+
}, 0);
|
|
535
|
+
} }, index.h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonText }), index.h("span", null, this.buttonText))));
|
|
536
|
+
}
|
|
537
|
+
async getAuthRequest() {
|
|
538
|
+
let { authenticationRequest } = await this.createSession();
|
|
539
|
+
return authenticationRequest;
|
|
540
|
+
}
|
|
541
|
+
renderMobileButton(isAndroid, isIos) {
|
|
542
|
+
if (this.autostart && !this.supportsDCAPI()) {
|
|
543
|
+
this.startMobilePolling();
|
|
544
|
+
}
|
|
545
|
+
let loading = false;
|
|
546
|
+
const handleLoading = (isLoading) => {
|
|
547
|
+
loading = isLoading;
|
|
548
|
+
if (this.handleCheckAppLoading) {
|
|
549
|
+
this.handleCheckAppLoading(isLoading);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
const executeRedirection = async () => {
|
|
553
|
+
handleLoading(true);
|
|
554
|
+
const androidStoreLink = 'https://play.google.com/store/apps/details?id=com.gataca.identity';
|
|
555
|
+
const iosStoreLink = 'https://apps.apple.com/us/app/gataca/id1498607616';
|
|
556
|
+
try {
|
|
557
|
+
const appScheme = await this.getAuthRequest();
|
|
558
|
+
this.isAppInstalled(appScheme, (installed) => {
|
|
559
|
+
if (!installed) {
|
|
560
|
+
this.stop();
|
|
561
|
+
if (isAndroid) {
|
|
562
|
+
window.location.href = androidStoreLink;
|
|
563
|
+
}
|
|
564
|
+
else if (isIos) {
|
|
565
|
+
window.location.href = iosStoreLink;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
handleLoading(false);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
this.stop();
|
|
573
|
+
handleLoading(false);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
return (index.h("div", { class: "gatacaButtonWrapper" }, index.h("button", { class: "gatacaButton", onClick: () => {
|
|
577
|
+
this.gatacaButtonPushed.emit();
|
|
578
|
+
executeRedirection();
|
|
579
|
+
}, disabled: loading }, index.h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonText }), index.h("span", null, this.buttonText))));
|
|
580
|
+
}
|
|
581
|
+
renderDCAPIButton(isAndroid, isIos) {
|
|
582
|
+
let loading = false;
|
|
583
|
+
console.log('Maybe act different', isAndroid, isIos);
|
|
584
|
+
const handleLoading = (isLoading) => {
|
|
585
|
+
loading = isLoading;
|
|
586
|
+
if (this.handleCheckAppLoading) {
|
|
587
|
+
this.handleCheckAppLoading(isLoading);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
const executeDCAPICall = async () => {
|
|
591
|
+
handleLoading(true);
|
|
592
|
+
try {
|
|
593
|
+
const authRequest = await this.getAuthRequest();
|
|
594
|
+
let request = await this.getRequestFromUri(authRequest);
|
|
595
|
+
let credentialResponse = await navigator.credentials.get({
|
|
596
|
+
//@ts-ignore
|
|
597
|
+
digital: {
|
|
598
|
+
requests: [
|
|
599
|
+
{
|
|
600
|
+
protocol: 'openid4vp-v1-unsigned',
|
|
601
|
+
data: request
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
if (credentialResponse.constructor.name == 'DigitalCredential') {
|
|
607
|
+
console.log('Digital Credential - Response Data: ' + credentialResponse);
|
|
608
|
+
}
|
|
609
|
+
//@ts-ignore
|
|
610
|
+
await this.fillSession(request, credentialResponse === null || credentialResponse === void 0 ? void 0 : credentialResponse.data);
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
this.stop();
|
|
614
|
+
handleLoading(false);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
return (index.h("div", { class: "gatacaButtonWrapper" }, index.h("button", { class: "gatacaButton", onClick: () => {
|
|
618
|
+
this.gatacaButtonPushed.emit();
|
|
619
|
+
executeDCAPICall();
|
|
620
|
+
}, disabled: loading }, index.h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonDCAPIText }), index.h("span", null, this.buttonDCAPIText))));
|
|
621
|
+
}
|
|
622
|
+
render() {
|
|
623
|
+
const userAgent =
|
|
624
|
+
// @ts-ignore
|
|
625
|
+
(navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) || (navigator === null || navigator === void 0 ? void 0 : navigator.vendor) || (window === null || window === void 0 ? void 0 : window.opera);
|
|
626
|
+
const isAndroid = /android/i.test(userAgent);
|
|
627
|
+
const isIos =
|
|
628
|
+
// @ts-ignore
|
|
629
|
+
(/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
|
|
630
|
+
const isMobile = isAndroid || isIos;
|
|
631
|
+
const displayDCApi = this.supportsDCAPI();
|
|
632
|
+
return (index.h("div", null, index.h("div", { class: "buttonContainer" }, isMobile && this.v === '3' ? this.renderMobileButton(isAndroid, isIos) : this.renderDesktopButton(), this.open && (!isMobile || this.v === '3') && this.renderModal()), displayDCApi /** && isMobile */ && index.h("div", { class: "buttonContainer" }, this.renderDCAPIButton(isAndroid, isIos))));
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
GatacaSSIButton.style = gatacaSsibuttonCss;
|
|
636
|
+
|
|
637
|
+
exports.gataca_qr = GatacaQR;
|
|
638
|
+
exports.gataca_qrdisplay = GatacaQRDisplay;
|
|
639
|
+
exports.gataca_ssibutton = GatacaSSIButton;
|