@gataca/qr 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/gatacaqr/app-globals-0f993ce5.js +3 -0
  2. package/dist/gatacaqr/css-shim-8eec97b3.js +4 -0
  3. package/dist/gatacaqr/dom-1b0cf05d.js +73 -0
  4. package/dist/gatacaqr/gat-icon-check-9132c0ad.js +5 -0
  5. package/dist/{esm → gatacaqr}/gataca-autoqr.entry.js +1 -1
  6. package/dist/{components/gataca-qr2.js → gatacaqr/gataca-qr.entry.js} +10 -77
  7. package/dist/gatacaqr/gataca-qrdisplay-9a22c242.js +123 -0
  8. package/dist/gatacaqr/gataca-qrdisplay.entry.js +2 -0
  9. package/dist/{esm → gatacaqr}/gataca-qrws.entry.js +3 -2
  10. package/dist/{components/gataca-ssibutton2.js → gatacaqr/gataca-ssibutton.entry.js} +39 -89
  11. package/dist/{esm → gatacaqr}/gataca-ssibuttonws.entry.js +1 -1
  12. package/dist/gatacaqr/gatacaqr.esm.js +129 -1
  13. package/dist/gatacaqr/index-aea56eb8.js +3262 -0
  14. package/dist/gatacaqr/index.esm.js +1 -1
  15. package/dist/gatacaqr/shadow-css-146f2f6f.js +387 -0
  16. package/dist/types/components/gataca-autoqr/gataca-autoqr.e2e.d.ts +1 -0
  17. package/dist/types/components/gataca-qr/gataca-qr.e2e.d.ts +1 -0
  18. package/dist/types/components/gataca-qrdisplay/gataca-qrdisplay.e2e.d.ts +1 -0
  19. package/dist/types/components/gataca-qrws/gataca-qrws.e2e.d.ts +1 -0
  20. package/dist/types/components/gataca-ssibutton/gataca-ssibutton.d.ts +2 -1
  21. package/dist/types/components/gataca-ssibutton/gataca-ssibutton.e2e.d.ts +1 -0
  22. package/dist/types/components/gataca-ssibuttonws/gataca-ssibuttonws.e2e.d.ts +1 -0
  23. package/package.json +1 -1
  24. package/dist/cjs/gat-icon-check-6b6780eb.js +0 -37
  25. package/dist/cjs/gataca-autoqr.cjs.entry.js +0 -106
  26. package/dist/cjs/gataca-qr_3.cjs.entry.js +0 -743
  27. package/dist/cjs/gataca-qrws.cjs.entry.js +0 -366
  28. package/dist/cjs/gataca-ssibuttonws.cjs.entry.js +0 -61
  29. package/dist/cjs/gatacaqr.cjs.js +0 -19
  30. package/dist/cjs/index-d8d3dfde.js +0 -1532
  31. package/dist/cjs/index.cjs.js +0 -17
  32. package/dist/cjs/loader.cjs.js +0 -21
  33. package/dist/cjs/utils-17b0a5ba.js +0 -72
  34. package/dist/collection/assets/icons/gat-icon-alert.svg +0 -5
  35. package/dist/collection/assets/icons/gat-icon-check.svg +0 -5
  36. package/dist/collection/assets/icons/gat-icon-refresh.svg +0 -4
  37. package/dist/collection/assets/images/logo_gataca.svg +0 -7
  38. package/dist/collection/collection-manifest.json +0 -17
  39. package/dist/collection/components/gataca-autoqr/gataca-autoqr.css +0 -116
  40. package/dist/collection/components/gataca-autoqr/gataca-autoqr.js +0 -347
  41. package/dist/collection/components/gataca-qr/components/qr/QR.js +0 -13
  42. package/dist/collection/components/gataca-qr/components/readQR/ReadQR.js +0 -16
  43. package/dist/collection/components/gataca-qr/components/readQR/components/AnimatedLoader.js +0 -6
  44. package/dist/collection/components/gataca-qr/components/retryButton/RetryButton.js +0 -19
  45. package/dist/collection/components/gataca-qr/components/success/Success.js +0 -9
  46. package/dist/collection/components/gataca-qr/gataca-qr.css +0 -415
  47. package/dist/collection/components/gataca-qr/gataca-qr.js +0 -1069
  48. package/dist/collection/components/gataca-qrdisplay/gataca-qrdisplay.js +0 -224
  49. package/dist/collection/components/gataca-qrws/components/qr/QR.js +0 -13
  50. package/dist/collection/components/gataca-qrws/components/readQR/ReadQR.js +0 -11
  51. package/dist/collection/components/gataca-qrws/components/readQR/components/AnimatedLoader.js +0 -4
  52. package/dist/collection/components/gataca-qrws/components/retryButton/RetryButton.js +0 -16
  53. package/dist/collection/components/gataca-qrws/components/success/Success.js +0 -8
  54. package/dist/collection/components/gataca-qrws/gataca-qrws.css +0 -407
  55. package/dist/collection/components/gataca-qrws/gataca-qrws.js +0 -1098
  56. package/dist/collection/components/gataca-ssibutton/gataca-ssibutton.css +0 -116
  57. package/dist/collection/components/gataca-ssibutton/gataca-ssibutton.js +0 -1151
  58. package/dist/collection/components/gataca-ssibuttonws/gataca-ssibuttonws.css +0 -116
  59. package/dist/collection/components/gataca-ssibuttonws/gataca-ssibuttonws.js +0 -434
  60. package/dist/collection/components/icons/RefreshIcon.js +0 -6
  61. package/dist/collection/index.js +0 -2
  62. package/dist/collection/utils/index.js +0 -1
  63. package/dist/collection/utils/utils.js +0 -66
  64. package/dist/components/gat-icon-check.js +0 -72
  65. package/dist/components/gataca-autoqr.js +0 -163
  66. package/dist/components/gataca-qr.js +0 -6
  67. package/dist/components/gataca-qrdisplay.js +0 -6
  68. package/dist/components/gataca-qrdisplay2.js +0 -121
  69. package/dist/components/gataca-qrws.js +0 -6
  70. package/dist/components/gataca-qrws2.js +0 -430
  71. package/dist/components/gataca-ssibutton.js +0 -6
  72. package/dist/components/gataca-ssibuttonws.js +0 -6
  73. package/dist/components/gataca-ssibuttonws2.js +0 -104
  74. package/dist/components/index.js +0 -8
  75. package/dist/esm/gat-icon-check-7320c81b.js +0 -32
  76. package/dist/esm/gataca-qr_3.entry.js +0 -737
  77. package/dist/esm/gatacaqr.js +0 -17
  78. package/dist/esm/index-dca2ab22.js +0 -1506
  79. package/dist/esm/index.js +0 -1
  80. package/dist/esm/loader.js +0 -17
  81. package/dist/esm/polyfills/core-js.js +0 -11
  82. package/dist/esm/polyfills/css-shim.js +0 -1
  83. package/dist/esm/polyfills/dom.js +0 -79
  84. package/dist/esm/polyfills/es5-html-element.js +0 -1
  85. package/dist/esm/polyfills/index.js +0 -34
  86. package/dist/esm/polyfills/system.js +0 -6
  87. package/dist/gatacaqr/p-143c0080.js +0 -1
  88. package/dist/gatacaqr/p-29119208.js +0 -1
  89. package/dist/gatacaqr/p-2dc7190a.entry.js +0 -1
  90. package/dist/gatacaqr/p-2e8accf9.entry.js +0 -1
  91. package/dist/gatacaqr/p-85af64b1.js +0 -2
  92. package/dist/gatacaqr/p-d27dabe4.entry.js +0 -1
  93. package/dist/gatacaqr/p-e172581d.entry.js +0 -1
  94. package/dist/index.cjs.js +0 -1
  95. package/dist/index.js +0 -1
  96. /package/dist/{esm → gatacaqr}/utils-e4a08623.js +0 -0
@@ -1,737 +0,0 @@
1
- import { r as registerInstance, h, c as createEvent } from './index-dca2ab22.js';
2
- import { l as logoGatacaSvg, Q as QRCodeStyling, g as gatIconAlertSvg, a as gatIconCheckSvg } from './gat-icon-check-7320c81b.js';
3
- import { R as RESULT_STATUS, c as checkMobile, b as base64UrlEncode, s as shortenUrlIfPossible } from './utils-e4a08623.js';
4
-
5
- const GatacaQRDisplay = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.qrData = undefined;
9
- this.qrType = 'svg';
10
- this.size = 256;
11
- this.logoSize = 0;
12
- this.logoSrc = undefined;
13
- this.qrColor = '#1E1E20';
14
- this.bgColor = '#FFFFFF';
15
- this.rounded = true;
16
- }
17
- getQrOptions() {
18
- return {
19
- data: this.qrData,
20
- width: this.size,
21
- height: this.size,
22
- image: this.logoSize > 0 ? this.logoSrc || logoGatacaSvg : undefined,
23
- margin: 10,
24
- type: this.qrType,
25
- dotsOptions: {
26
- color: this.qrColor,
27
- type: this.rounded ? 'dots' : 'square'
28
- },
29
- cornersSquareOptions: {
30
- type: this.rounded ? 'extra-rounded' : 'square'
31
- },
32
- cornersDotOptions: {
33
- type: this.rounded ? 'dot' : 'square'
34
- },
35
- imageOptions: {
36
- margin: 2,
37
- imageSize: this.logoSize
38
- },
39
- backgroundOptions: {
40
- color: this.bgColor
41
- }
42
- };
43
- }
44
- componentDidLoad() {
45
- this.mountOrUpdateQr();
46
- }
47
- onQrDataChange() {
48
- this.mountOrUpdateQr();
49
- }
50
- mountOrUpdateQr() {
51
- var _a;
52
- if (!((_a = this.qrData) === null || _a === void 0 ? void 0 : _a.trim()) || !this.qr) {
53
- return;
54
- }
55
- if (!this.qrCode) {
56
- this.qrCode = new QRCodeStyling(this.getQrOptions());
57
- this.qrCode.append(this.qr);
58
- }
59
- else {
60
- this.qrCode.update({ data: this.qrData });
61
- }
62
- }
63
- render() {
64
- return (h("div", { ref: (el) => {
65
- this.qr = el;
66
- } }));
67
- }
68
- static get watchers() { return {
69
- "qrData": ["onQrDataChange"]
70
- }; }
71
- };
72
-
73
- const QR = (props) => {
74
- const { value, useLogo, logoSrc, size, qrType, style, linkReady = true } = props;
75
- const s = size !== null && size !== void 0 ? size : 256;
76
- if (!linkReady) {
77
- return (h("div", { class: "qr-loading-slot", style: {
78
- width: s + 'px',
79
- height: s + 'px',
80
- margin: '0 auto'
81
- } }));
82
- }
83
- return 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 });
84
- };
85
-
86
- const AnimatedLoader = (props) => {
87
- const { color = '#4745B7' } = props;
88
- const style = { '--loader-color': color };
89
- return (h("div", { class: "containerLoader", style: style },
90
- h("div", { class: "loader" },
91
- h("div", { class: "loader__item loader__item__1" }),
92
- h("div", { class: "loader__item loader__item__2" }),
93
- h("div", { class: "loader__item loader__item__3" }),
94
- h("div", { class: "loader__item loader__item__4" }),
95
- h("div", { class: "loader__item loader__item__5" }),
96
- h("div", { class: "loader__item loader__item__6" }),
97
- h("div", { class: "loader__item loader__item__7" }),
98
- h("div", { class: "loader__item loader__item__8" }))));
99
- };
100
-
101
- const ReadQR = (props) => {
102
- var _a;
103
- const { modalWidth, readQrMessages, renderQR, url, sizeQR, style } = props;
104
- const bgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.bgColor) ? style === null || style === void 0 ? void 0 : style.bgColor : 'white' };
105
- const color = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#707074' };
106
- return (h("div", { class: "blured", style: {
107
- width: (modalWidth - 48).toString() + 'px',
108
- height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
109
- backgroundColor: style === null || style === void 0 ? void 0 : style.bgColor,
110
- color: style === null || style === void 0 ? void 0 : style.color,
111
- border: (style === null || style === void 0 ? void 0 : style.color) ? `1px dashed ${style === null || style === void 0 ? void 0 : style.color}` : `1px dashed #a1a1a1`
112
- } },
113
- h("div", { id: "notify", style: bgStyle },
114
- h(AnimatedLoader, { color: style === null || style === void 0 ? void 0 : style.color }),
115
- h("p", { class: "notify-text", style: color }, readQrMessages === null || readQrMessages === void 0 ? void 0 :
116
- readQrMessages.title,
117
- ' '),
118
- h("p", { class: "notify-text bold", style: color }, readQrMessages === null || readQrMessages === void 0 ? void 0 : readQrMessages.description)),
119
- h("div", { id: "qrwait" }, renderQR(url, false, sizeQR))));
120
- };
121
-
122
- const RefreshIcon = (props) => {
123
- const { height = 24, width = 24, color } = props;
124
- const strokeColor = color ? color : '#8B8B8B';
125
- return (h("svg", { width: width, height: height, viewBox: `0 0 ${width} ${height}`, fill: "none", xmlns: "http://www.w3.org/2000/svg" },
126
- h("path", { d: "M23 4V10H17", stroke: strokeColor, "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }),
127
- 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" })));
128
- };
129
-
130
- const RetryButton = (props) => {
131
- var _a;
132
- const { errorMessage, modalWidth, clickInsideBoxLabel, refreshQrLabel, scanQrLabel, style, display } = props;
133
- const bgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.bgColor) ? style === null || style === void 0 ? void 0 : style.bgColor : 'white' };
134
- const alertBgStyle = { backgroundColor: (style === null || style === void 0 ? void 0 : style.alertBgColor) ? style === null || style === void 0 ? void 0 : style.alertBgColor : '#ffdedf' };
135
- const alertBorderColor = { borderColor: (style === null || style === void 0 ? void 0 : style.alertBorderColor) ? style === null || style === void 0 ? void 0 : style.alertBorderColor : '#ee888c' };
136
- const color = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#707074' };
137
- return (h("div", { class: "reload", style: {
138
- width: (modalWidth - 48).toString() + 'px',
139
- height: modalWidth ? ((_a = (modalWidth - 48)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
140
- border: (style === null || style === void 0 ? void 0 : style.color) ? `1px dashed ${style === null || style === void 0 ? void 0 : style.color}` : `1px dashed #a1a1a1`
141
- } },
142
- h("div", { id: "notify", onClick: () => display(), style: bgStyle },
143
- h(RefreshIcon, { color: style === null || style === void 0 ? void 0 : style.color, height: 24, width: 24 }),
144
- h("p", { class: "notify-text", style: color },
145
- clickInsideBoxLabel,
146
- ' '),
147
- errorMessage ? (h("p", { class: "notify-text bold", style: color }, refreshQrLabel)) : (h("p", { class: "notify-text bold", style: color }, scanQrLabel)),
148
- errorMessage && (h("div", { class: "alert", style: Object.assign(Object.assign({ width: (modalWidth - 48).toString() + 'px' }, alertBgStyle), { border: `1px solid ${alertBorderColor}` }) },
149
- h("img", { src: gatIconAlertSvg, height: 24, width: 24 }),
150
- h("p", { style: { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#1e1e20' } }, errorMessage)))),
151
- h("div", { id: "qrwait", class: "qr-placeholder-slot", style: {
152
- width: (modalWidth - 48).toString() + 'px',
153
- height: modalWidth ? (modalWidth - 48).toString() + 'px' : ''
154
- } })));
155
- };
156
-
157
- const Success = (props) => {
158
- const { modalHeight, successLoginLabel, style } = props;
159
- const colorStyle = { color: (style === null || style === void 0 ? void 0 : style.color) ? style === null || style === void 0 ? void 0 : style.color : '#1e1e20' };
160
- return (h("div", { class: 'success', style: {
161
- height: modalHeight ? (modalHeight === null || modalHeight === void 0 ? void 0 : modalHeight.toString()) + 'px' : '300px'
162
- } },
163
- h("img", { src: gatIconCheckSvg, height: 52, width: 52 }),
164
- h("p", { class: "successMsg", style: colorStyle }, successLoginLabel)));
165
- };
166
-
167
- 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}.qr-placeholder-slot{box-sizing:border-box;border-radius:12px;background:rgba(0, 0, 0, 0.04)}#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)}}";
168
-
169
- const DEEP_LINK_PREFIX = 'https://api.gataca.io/qr/redirect.html';
170
- //Default values
171
- const DEFAULT_SESSION_TIMEOUT$1 = 300; //5mins as in connect
172
- const DEFAULT_POLLING_FREQ$1 = 3;
173
- const GatacaQR = class {
174
- constructor(hostRef) {
175
- registerInstance(this, hostRef);
176
- this.gatacaLoginCompleted = createEvent(this, "gatacaLoginCompleted", 7);
177
- this.gatacaLoginFailed = createEvent(this, "gatacaLoginFailed", 7);
178
- this.lastShortenRaw = null;
179
- this.checkStatus = undefined;
180
- this.createSession = undefined;
181
- this.successCallback = undefined;
182
- this.errorCallback = undefined;
183
- this.qrRole = undefined;
184
- this.qrType = 'svg';
185
- this.callbackServer = undefined;
186
- this.autostart = true;
187
- this.autorefresh = false;
188
- this.v = '3';
189
- this.qrModalTitle = 'Quick Access';
190
- this.modalTitleColor = '#4745B7';
191
- this.qrModalDescription = 'Sign up or sign in by scanning the QR Code with the Gataca Wallet';
192
- this.hideModalTexts = false;
193
- this.hideModalBoxShadow = false;
194
- this.hideBrandTitle = false;
195
- this.logoSize = 0;
196
- this.logoSrc = logoGatacaSvg;
197
- this.qrSize = 300;
198
- this.modalWidth = 300;
199
- this.modalHeight = undefined;
200
- this.qrCodeExpiredLabel = 'QR Code expired';
201
- this.credentialsNotValidatedLabel = 'User credentials not validated';
202
- this.clickInsideBoxLabel = 'Click inside the box to';
203
- this.refreshQrLabel = 'Refresh QR Code';
204
- this.scanQrLabel = 'Scan QR Code';
205
- this.userNotScanInTimeErrorLabel = 'User did not scan the QR in the allowed time';
206
- this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated";
207
- this.failedLoginErrorLabel = 'No successful login';
208
- this.successLoginLabel = 'Successful Connection!';
209
- this.byBrandLabel = 'by Gataca';
210
- this.waitingStartSessionLabel = 'waiting to start a session';
211
- this.readQrTitle = 'Processing...';
212
- this.readQrDescription = 'Please wait a moment';
213
- this.hideQrModalDescription = false;
214
- this.sessionTimeout = DEFAULT_SESSION_TIMEOUT$1;
215
- this.pollingFrequency = DEFAULT_POLLING_FREQ$1;
216
- this.dynamicLink = true;
217
- this.qrStyle = undefined;
218
- this.sessionId = undefined;
219
- this.authenticationRequest = undefined;
220
- this.sessionData = undefined;
221
- this.result = RESULT_STATUS.NOT_STARTED;
222
- this.qrHref = '';
223
- }
224
- disconnectedCallback() {
225
- this.stop();
226
- }
227
- async componentDidLoad() {
228
- if (this.autostart) {
229
- await this.display();
230
- }
231
- }
232
- /**
233
- * Force manually the display of a QR
234
- */
235
- async display() {
236
- await this.getSessionId();
237
- await this.refreshQrHref();
238
- this.result = RESULT_STATUS.ONGOING;
239
- this.poll()
240
- .then((data) => {
241
- this.result = RESULT_STATUS.SUCCESS;
242
- this.sessionData = data;
243
- this.gatacaLoginCompleted.emit(data);
244
- this.successCallback(data);
245
- })
246
- .catch((err) => {
247
- this.clean();
248
- let expired = err === RESULT_STATUS.EXPIRED;
249
- if (expired && this.autorefresh) {
250
- this.display();
251
- }
252
- else {
253
- if (err !== RESULT_STATUS.NOT_STARTED) {
254
- let error = expired ? new Error(this.userNotScanInTimeErrorLabel) : new Error(this.credsNotValidatedErrorLabel);
255
- this.result = err;
256
- this.gatacaLoginFailed.emit(error);
257
- this.errorCallback(error);
258
- }
259
- }
260
- });
261
- if (checkMobile() && this.dynamicLink) {
262
- window.location.href = this.getLink();
263
- }
264
- }
265
- buildRawLink() {
266
- var _a;
267
- if (this.v === '2') {
268
- return (_a = this.authenticationRequest) !== null && _a !== void 0 ? _a : '';
269
- }
270
- const authRequestEncoded = '?dl=' + base64UrlEncode(this.authenticationRequest);
271
- return DEEP_LINK_PREFIX + authRequestEncoded;
272
- }
273
- async refreshQrHref() {
274
- var _a;
275
- const raw = this.buildRawLink();
276
- if (raw === this.lastShortenRaw) {
277
- return;
278
- }
279
- this.lastShortenRaw = raw;
280
- const shortened = await shortenUrlIfPossible(raw !== null && raw !== void 0 ? raw : '');
281
- const now = this.buildRawLink();
282
- if (now === raw) {
283
- this.qrHref = shortened;
284
- }
285
- else if (!((_a = this.qrHref) === null || _a === void 0 ? void 0 : _a.trim())) {
286
- this.qrHref = now;
287
- }
288
- }
289
- /**
290
- * Stop manually an ongoing session
291
- */
292
- async stop() {
293
- this.clean();
294
- if (this.result === RESULT_STATUS.ONGOING || RESULT_STATUS.READ) {
295
- this.result = RESULT_STATUS.NOT_STARTED;
296
- }
297
- }
298
- clean() {
299
- this.sessionData = undefined;
300
- this.sessionId = undefined;
301
- this.qrHref = '';
302
- this.lastShortenRaw = null;
303
- }
304
- /**
305
- * Retrieve manually the session data on a successful login
306
- */
307
- async getSessionData() {
308
- return this.sessionData ? Promise.resolve(this.sessionData) : Promise.reject(new Error(this.failedLoginErrorLabel));
309
- }
310
- async getSessionId() {
311
- if (this.sessionId) {
312
- return this.sessionId;
313
- }
314
- let { sessionId, authenticationRequest } = await this.createSession();
315
- this.sessionId = sessionId;
316
- this.authenticationRequest = authenticationRequest;
317
- return this.sessionId;
318
- }
319
- getLink() {
320
- return this.qrHref || this.buildRawLink();
321
- }
322
- async poll() {
323
- let endTime = new Date().getTime() + (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT$1) * 1000;
324
- let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ$1) * 1000;
325
- let checkFunc = async (component) => {
326
- if (component.result === RESULT_STATUS.NOT_STARTED) {
327
- return { result: RESULT_STATUS.NOT_STARTED };
328
- }
329
- let id = await component.getSessionId();
330
- return component.checkStatus(id);
331
- };
332
- let component = this;
333
- let checkCondition = async function (resolve, reject) {
334
- // If the condition is met, we're done!
335
- let { result, data } = await checkFunc(component);
336
- switch (result) {
337
- case RESULT_STATUS.SUCCESS:
338
- resolve(data);
339
- break;
340
- case RESULT_STATUS.READ:
341
- component.result = RESULT_STATUS.READ;
342
- case RESULT_STATUS.ONGOING:
343
- if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
344
- setTimeout(checkCondition, interval, resolve, reject);
345
- }
346
- else {
347
- reject(RESULT_STATUS.EXPIRED);
348
- }
349
- break;
350
- default:
351
- reject(result);
352
- break;
353
- }
354
- };
355
- return new Promise(checkCondition);
356
- }
357
- renderQRSection() {
358
- var _a;
359
- switch (this.result) {
360
- case RESULT_STATUS.NOT_STARTED:
361
- return this.renderRetryButton();
362
- case RESULT_STATUS.ONGOING:
363
- return this.renderQR(this.getLink(), true, undefined, !!((_a = this.qrHref) === null || _a === void 0 ? void 0 : _a.trim()));
364
- case RESULT_STATUS.EXPIRED:
365
- return this.renderRetryButton(this.qrCodeExpiredLabel);
366
- case RESULT_STATUS.FAILED:
367
- return this.renderRetryButton(this.credentialsNotValidatedLabel);
368
- case RESULT_STATUS.SUCCESS:
369
- return this.renderSuccess();
370
- case RESULT_STATUS.READ:
371
- return this.renderReadQR({
372
- title: this === null || this === void 0 ? void 0 : this.readQrTitle,
373
- description: this === null || this === void 0 ? void 0 : this.readQrDescription
374
- });
375
- }
376
- }
377
- renderSuccess() {
378
- return 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 });
379
- }
380
- renderRetryButton(errorMessage) {
381
- return (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, display: this.display.bind(this), style: this === null || this === void 0 ? void 0 : this.qrStyle }));
382
- }
383
- renderReadQR(readQrMessages) {
384
- var _a;
385
- const linkReady = !!((_a = this.qrHref) === null || _a === void 0 ? void 0 : _a.trim());
386
- return (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: (url, useLogo, size) => this.renderQR(url, useLogo, size, linkReady), style: this.qrStyle }));
387
- }
388
- renderQR(value, useLogo, sizeQR, linkReady = true) {
389
- return (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, linkReady: linkReady }));
390
- }
391
- render() {
392
- var _a, _b, _c, _d, _e, _f;
393
- return (h("div", { class: "popUpContainer" }, h("div", { class: `is-visible modal-window ${this.hideModalTexts ? '' : 'large-modal'} ${this.hideModalBoxShadow ? 'noBoxShadow' : ''}`, style: {
394
- width: (this.modalWidth - 2).toString() + 'px',
395
- height: this.modalHeight ? ((_a = (this.modalHeight - 2)) === null || _a === void 0 ? void 0 : _a.toString()) + 'px' : '',
396
- 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',
397
- 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);'
398
- }, onClick: (event) => {
399
- event.stopPropagation();
400
- } }, h("div", { class: "modal-window__content" }, h("div", { class: `qrTitleContainer ${this.hideModalTexts ? 'hidenText' : ''}` }, h("p", { class: "qrTitle modalText", style: { color: this.modalTitleColor || '#1e1e20' } }, this.qrModalTitle), !this.hideBrandTitle && (h("p", { class: "qrBrand modalText" }, this.byBrandLabel, ' ', h("span", null, h("img", { src: logoGatacaSvg })))), this.result !== RESULT_STATUS.SUCCESS && !this.hideQrModalDescription && h("p", { class: "qrDescription modalText" }, this.qrModalDescription)), h("div", { class: "qrSection", style: {
401
- width: this.modalWidth.toString() + 'px',
402
- height: this.modalWidth ? ((_f = this.modalWidth) === null || _f === void 0 ? void 0 : _f.toString()) + 'px' : ''
403
- } }, this.renderQRSection())))));
404
- }
405
- };
406
- GatacaQR.style = gatacaQrCss;
407
-
408
- 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}";
409
-
410
- 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=';
411
- //Default values
412
- const DEFAULT_SESSION_TIMEOUT = 300; //5mins as in connect
413
- const DEFAULT_POLLING_FREQ = 3;
414
- const GatacaSSIButton = class {
415
- constructor(hostRef) {
416
- registerInstance(this, hostRef);
417
- this.gatacaLoginCompleted = createEvent(this, "gatacaLoginCompleted", 7);
418
- this.gatacaLoginFailed = createEvent(this, "gatacaLoginFailed", 7);
419
- this.gatacaButtonPushed = createEvent(this, "gatacaButtonPushed", 7);
420
- this.getRequestFromUri = async (authRequest) => {
421
- const requrl = new URL(authRequest);
422
- const requri = requrl.searchParams.get('request_uri');
423
- if (requri) {
424
- const response = await fetch(requri, {
425
- method: 'GET',
426
- headers: {
427
- 'Content-Type': 'application/json'
428
- }
429
- });
430
- const jwt = await response.json();
431
- const parts = jwt.split('.');
432
- const base64 = parts[1].replace(/-/g, '+').replace(/_/g, '/');
433
- const decoded = window.atob(base64);
434
- let parsed = JSON.parse(decoded);
435
- parsed.response_mode = 'dc_api';
436
- return parsed;
437
- }
438
- };
439
- this.buttonText = 'Easy login';
440
- this.buttonDCAPIText = 'Login with Device Credentials';
441
- this.qrType = 'svg';
442
- this.autostart = true;
443
- this.checkStatus = undefined;
444
- this.createSession = undefined;
445
- this.fillSession = undefined;
446
- this.successCallback = undefined;
447
- this.errorCallback = undefined;
448
- this.handleCheckAppLoading = undefined;
449
- this.checkAppTimeout = 6;
450
- this.qrRole = undefined;
451
- this.callbackServer = undefined;
452
- this.sessionTimeout = undefined;
453
- this.pollingFrequency = undefined;
454
- this.autorefresh = false;
455
- this.v = '3';
456
- this.qrModalTitle = 'Quick Access';
457
- this.modalTitleColor = '#4745B7';
458
- this.qrModalDescription = 'Sign up or sign in by scanning the QR Code with the Gataca Wallet';
459
- this.hideBrandTitle = false;
460
- this.dynamicLink = true;
461
- this.logoSize = 0;
462
- this.logoSrc = undefined;
463
- this.qrCodeExpiredLabel = 'QR Code expired';
464
- this.credentialsNotValidatedLabel = 'User credentials not validated';
465
- this.clickInsideBoxLabel = 'Click inside the box to';
466
- this.refreshQrLabel = 'Refresh QR Code';
467
- this.scanQrLabel = 'Scan QR Code';
468
- this.userNotScanInTimeErrorLabel = 'User did not scan the QR in the allowed time';
469
- this.credsNotValidatedErrorLabel = "Provided user credentials couldn't be validated";
470
- this.failedLoginErrorLabel = 'No successful login';
471
- this.successLoginLabel = 'Successful Connection!';
472
- this.byBrandLabel = 'by Gataca';
473
- this.waitingStartSessionLabel = 'waiting to start a session';
474
- this.enableDcApi = false;
475
- this.hideQrModalDescription = false;
476
- this.qrStyle = undefined;
477
- this.open = false;
478
- this.sessionId = undefined;
479
- this.authenticationRequest = undefined;
480
- this.sessionData = undefined;
481
- this.result = RESULT_STATUS.NOT_STARTED;
482
- this.qr = (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 }));
483
- }
484
- supportsDCAPI() {
485
- // let mobile = checkMobile();
486
- // if (!mobile) return false;
487
- if (!this.enableDcApi) {
488
- return false;
489
- }
490
- //@ts-ignore
491
- if (typeof window.DigitalCredential === 'undefined')
492
- return false;
493
- const protocols = ['org-iso-mdoc', 'openid4vp', 'openid4vci'];
494
- //@ts-ignore
495
- const supportedProtocols = protocols.filter(window.DigitalCredential.userAgentAllowsProtocol);
496
- console.log(supportedProtocols, protocols);
497
- return true;
498
- }
499
- /**
500
- * Retrieve manually the session data on a successful login
501
- */
502
- async getSessionData() {
503
- return this.qr.getSessionData();
504
- }
505
- async getSessionId() {
506
- if (this.sessionId) {
507
- return this.sessionId;
508
- }
509
- let { sessionId, authenticationRequest } = await this.createSession();
510
- this.sessionId = sessionId;
511
- this.authenticationRequest = authenticationRequest;
512
- return this.sessionId;
513
- }
514
- /**
515
- * Force manually the start polling
516
- */
517
- async startMobilePolling() {
518
- await this.getSessionId();
519
- this.result = RESULT_STATUS.ONGOING;
520
- this.poll()
521
- .then((data) => {
522
- this.result = RESULT_STATUS.SUCCESS;
523
- this.sessionData = data;
524
- this.gatacaLoginCompleted.emit(data);
525
- this.successCallback(data);
526
- })
527
- .catch((err) => {
528
- this.clean();
529
- let expired = err === RESULT_STATUS.EXPIRED;
530
- if (expired && this.autorefresh) {
531
- this.startMobilePolling();
532
- }
533
- else {
534
- if (err !== RESULT_STATUS.NOT_STARTED) {
535
- let error = expired ? new Error(this.userNotScanInTimeErrorLabel) : new Error(this.credsNotValidatedErrorLabel);
536
- this.result = err;
537
- this.gatacaLoginFailed.emit(error);
538
- this.errorCallback(error);
539
- }
540
- }
541
- });
542
- }
543
- /**
544
- * Stop manually an ongoing session
545
- */
546
- async stop() {
547
- this.clean();
548
- if (this.result === RESULT_STATUS.ONGOING || RESULT_STATUS.READ) {
549
- this.result = RESULT_STATUS.NOT_STARTED;
550
- }
551
- }
552
- clean() {
553
- this.sessionData = undefined;
554
- this.sessionId = undefined;
555
- }
556
- renderModal() {
557
- return this.qr;
558
- }
559
- async poll() {
560
- let endTime = new Date().getTime() + (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT) * 1000;
561
- let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ) * 1000;
562
- let checkFunc = async (component) => {
563
- if (component.result === RESULT_STATUS.NOT_STARTED) {
564
- return { result: RESULT_STATUS.NOT_STARTED };
565
- }
566
- let id = await component.getSessionId();
567
- return component.checkStatus(id);
568
- };
569
- let component = this;
570
- let checkCondition = async function (resolve, reject) {
571
- // If the condition is met, we're done!
572
- let { result, data } = await checkFunc(component);
573
- switch (result) {
574
- case RESULT_STATUS.SUCCESS:
575
- resolve(data);
576
- break;
577
- case RESULT_STATUS.READ:
578
- component.result = RESULT_STATUS.READ;
579
- case RESULT_STATUS.ONGOING:
580
- if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
581
- setTimeout(checkCondition, interval, resolve, reject);
582
- }
583
- else {
584
- reject(RESULT_STATUS.EXPIRED);
585
- }
586
- break;
587
- default:
588
- reject(result);
589
- break;
590
- }
591
- };
592
- return new Promise(checkCondition);
593
- }
594
- isAppInstalled(appScheme, callback) {
595
- let timeout;
596
- let detected = false;
597
- if (appScheme === null || appScheme === void 0 ? void 0 : appScheme.length) {
598
- window.location.href = appScheme;
599
- }
600
- const waitTimeToCheckApp = this.checkAppTimeout * 1000;
601
- timeout = setTimeout(() => {
602
- if (!detected) {
603
- callback(false);
604
- }
605
- cleanup();
606
- }, waitTimeToCheckApp);
607
- const handleVisibilityChange = () => {
608
- if (document.hidden) {
609
- detected = true;
610
- callback(true);
611
- if (!this.autostart) {
612
- this.startMobilePolling();
613
- }
614
- cleanup();
615
- }
616
- };
617
- document.addEventListener('visibilitychange', handleVisibilityChange);
618
- function cleanup() {
619
- clearTimeout(timeout);
620
- document.removeEventListener('visibilitychange', handleVisibilityChange);
621
- }
622
- }
623
- renderDesktopButton() {
624
- return (h("div", { class: "gatacaButtonWrapper" }, h("button", { class: "gatacaButton", onClick: () => {
625
- this.open = !this.open;
626
- setTimeout(() => {
627
- var _a, _b;
628
- if (this.open) {
629
- (_a = this.qrElement) === null || _a === void 0 ? void 0 : _a.display();
630
- }
631
- else {
632
- (_b = this.qrElement) === null || _b === void 0 ? void 0 : _b.stop();
633
- }
634
- }, 0);
635
- } }, h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonText }), h("span", null, this.buttonText))));
636
- }
637
- async getAuthRequest() {
638
- let { authenticationRequest } = await this.createSession();
639
- return authenticationRequest;
640
- }
641
- renderMobileButton(isAndroid, isIos) {
642
- if (this.autostart && !this.supportsDCAPI()) {
643
- this.startMobilePolling();
644
- }
645
- let loading = false;
646
- const handleLoading = (isLoading) => {
647
- loading = isLoading;
648
- if (this.handleCheckAppLoading) {
649
- this.handleCheckAppLoading(isLoading);
650
- }
651
- };
652
- const executeRedirection = async () => {
653
- handleLoading(true);
654
- const androidStoreLink = 'https://play.google.com/store/apps/details?id=com.gataca.identity';
655
- const iosStoreLink = 'https://apps.apple.com/us/app/gataca/id1498607616';
656
- try {
657
- const appScheme = await this.getAuthRequest();
658
- this.isAppInstalled(appScheme, (installed) => {
659
- if (!installed) {
660
- this.stop();
661
- if (isAndroid) {
662
- window.location.href = androidStoreLink;
663
- }
664
- else if (isIos) {
665
- window.location.href = iosStoreLink;
666
- }
667
- }
668
- handleLoading(false);
669
- });
670
- }
671
- catch (error) {
672
- this.stop();
673
- handleLoading(false);
674
- }
675
- };
676
- return (h("div", { class: "gatacaButtonWrapper" }, h("button", { class: "gatacaButton", onClick: () => {
677
- this.gatacaButtonPushed.emit();
678
- executeRedirection();
679
- }, disabled: loading }, h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonText }), h("span", null, this.buttonText))));
680
- }
681
- renderDCAPIButton(isAndroid, isIos) {
682
- let loading = false;
683
- console.log('Maybe act different', isAndroid, isIos);
684
- const handleLoading = (isLoading) => {
685
- loading = isLoading;
686
- if (this.handleCheckAppLoading) {
687
- this.handleCheckAppLoading(isLoading);
688
- }
689
- };
690
- const executeDCAPICall = async () => {
691
- handleLoading(true);
692
- try {
693
- const authRequest = await this.getAuthRequest();
694
- let request = await this.getRequestFromUri(authRequest);
695
- let credentialResponse = await navigator.credentials.get({
696
- //@ts-ignore
697
- digital: {
698
- requests: [
699
- {
700
- protocol: 'openid4vp-v1-unsigned',
701
- data: request
702
- }
703
- ]
704
- }
705
- });
706
- if (credentialResponse.constructor.name == 'DigitalCredential') {
707
- console.log('Digital Credential - Response Data: ' + credentialResponse);
708
- }
709
- //@ts-ignore
710
- await this.fillSession(request, credentialResponse === null || credentialResponse === void 0 ? void 0 : credentialResponse.data);
711
- }
712
- catch (error) {
713
- this.stop();
714
- handleLoading(false);
715
- }
716
- };
717
- return (h("div", { class: "gatacaButtonWrapper" }, h("button", { class: "gatacaButton", onClick: () => {
718
- this.gatacaButtonPushed.emit();
719
- executeDCAPICall();
720
- }, disabled: loading }, h("img", { src: PHONE_ICON, class: "buttonImg", alt: this.buttonDCAPIText }), h("span", null, this.buttonDCAPIText))));
721
- }
722
- render() {
723
- const userAgent =
724
- // @ts-ignore
725
- (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);
726
- const isAndroid = /android/i.test(userAgent);
727
- const isIos =
728
- // @ts-ignore
729
- (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
730
- const isMobile = isAndroid || isIos;
731
- const displayDCApi = this.supportsDCAPI();
732
- return (h("div", null, h("div", { class: "buttonContainer" }, isMobile && this.v === '3' ? this.renderMobileButton(isAndroid, isIos) : this.renderDesktopButton(), this.open && (!isMobile || this.v === '3') && this.renderModal()), displayDCApi /** && isMobile */ && h("div", { class: "buttonContainer" }, this.renderDCAPIButton(isAndroid, isIos))));
733
- }
734
- };
735
- GatacaSSIButton.style = gatacaSsibuttonCss;
736
-
737
- export { GatacaQR as gataca_qr, GatacaQRDisplay as gataca_qrdisplay, GatacaSSIButton as gataca_ssibutton };