@gataca/qr 2.0.3 → 2.0.5

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 (30) hide show
  1. package/dist/cjs/gataca-autoqr.cjs.entry.js +105 -0
  2. package/dist/cjs/gataca-qr_2.cjs.entry.js +230 -0
  3. package/dist/cjs/gataca-qrws.cjs.entry.js +176 -0
  4. package/dist/cjs/gataca-ssibutton_2.cjs.entry.js +129 -0
  5. package/dist/cjs/gatacaqr.cjs.js +1 -1
  6. package/dist/cjs/loader.cjs.js +1 -1
  7. package/dist/cjs/logo_gataca-f3dc6840.js +14 -0
  8. package/dist/{esm/gataca-autoqr_6.entry.js → cjs/qr-code-styling-412bbc7a.js} +2 -603
  9. package/dist/collection/components/gataca-qr/gataca-qr.css +11 -2
  10. package/dist/collection/components/gataca-qr/gataca-qr.js +110 -10
  11. package/dist/components/gataca-qr2.js +26 -10
  12. package/dist/esm/gataca-autoqr.entry.js +101 -0
  13. package/dist/esm/gataca-qr_2.entry.js +225 -0
  14. package/dist/esm/gataca-qrws.entry.js +172 -0
  15. package/dist/esm/gataca-ssibutton_2.entry.js +124 -0
  16. package/dist/esm/gatacaqr.js +1 -1
  17. package/dist/esm/loader.js +1 -1
  18. package/dist/esm/logo_gataca-57ad0363.js +9 -0
  19. package/dist/{cjs/gataca-autoqr_6.cjs.entry.js → esm/qr-code-styling-0eeb38d5.js} +1 -613
  20. package/dist/gatacaqr/gatacaqr.esm.js +1 -1
  21. package/dist/gatacaqr/p-0be4566d.js +1 -0
  22. package/dist/gatacaqr/p-35b616ba.entry.js +1 -0
  23. package/dist/gatacaqr/p-5eb106c0.entry.js +1 -0
  24. package/dist/gatacaqr/p-66ad21ac.entry.js +1 -0
  25. package/dist/gatacaqr/p-6adc6933.js +1 -0
  26. package/dist/gatacaqr/p-b834ef88.entry.js +1 -0
  27. package/dist/types/components/gataca-qr/gataca-qr.d.ts +27 -2
  28. package/dist/types/components.d.ts +42 -2
  29. package/package.json +40 -38
  30. package/dist/gatacaqr/p-b37057bb.entry.js +0 -1
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-4be0cdca.js');
6
+
7
+ const gatacaAutoqrCss = "@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}";
8
+
9
+ const DEFAULT_REPOSITORY = "https://studio.gataca.io/api/v1/qrconfigs";
10
+ const fixFunctions = (data) => {
11
+ var _a, _b, _c, _d, _e, _f;
12
+ data.errorCallback = deserializeFunction((_a = data.errorCallback) === null || _a === void 0 ? void 0 : _a.toString());
13
+ data.successCallback = deserializeFunction((_b = data.successCallback) === null || _b === void 0 ? void 0 : _b.toString());
14
+ data.wsOnMessage = deserializeFunction((_c = data.wsOnMessage) === null || _c === void 0 ? void 0 : _c.toString());
15
+ data.wsOnOpen = deserializeFunction((_d = data.wsOnOpen) === null || _d === void 0 ? void 0 : _d.toString());
16
+ data.checkStatus = deserializeFunction((_e = data.checkStatus) === null || _e === void 0 ? void 0 : _e.toString());
17
+ data.createSession = deserializeFunction((_f = data.createSession) === null || _f === void 0 ? void 0 : _f.toString());
18
+ return data;
19
+ };
20
+ const deserializeFunction = (data) => {
21
+ if (data) {
22
+ return new Function("return " + data)();
23
+ }
24
+ return undefined;
25
+ };
26
+ const GatacaAutoQR = class {
27
+ constructor(hostRef) {
28
+ index.registerInstance(this, hostRef);
29
+ this.gatacaLoginCompleted = index.createEvent(this, "gatacaLoginCompleted", 7);
30
+ this.gatacaLoginFailed = index.createEvent(this, "gatacaLoginFailed", 7);
31
+ this.configId = undefined;
32
+ this.configRepository = DEFAULT_REPOSITORY;
33
+ this.successCallback = undefined;
34
+ this.errorCallback = undefined;
35
+ this.checkStatus = undefined;
36
+ this.createSession = undefined;
37
+ this.wsOnOpen = undefined;
38
+ this.wsOnMessage = undefined;
39
+ this.config = undefined;
40
+ this.loading = undefined;
41
+ this.loading = true;
42
+ fetch(this.configRepository + "/" + this.configId, {
43
+ method: "GET",
44
+ headers: {
45
+ "Content-Type": "application/json",
46
+ },
47
+ })
48
+ .then((response) => {
49
+ response
50
+ .json()
51
+ .then((data) => {
52
+ data = fixFunctions(data);
53
+ this.config = data;
54
+ this.loading = false;
55
+ })
56
+ .catch((err) => {
57
+ console.log("Cannot retrieve selected config", err);
58
+ this.loading = false;
59
+ });
60
+ })
61
+ .catch((err) => {
62
+ console.log("Cannot retrieve selected config", err);
63
+ this.loading = false;
64
+ });
65
+ }
66
+ /**
67
+ * Retrieve manually the session data on a successful login
68
+ */
69
+ async getSessionData() {
70
+ return this.qr.getSessionData();
71
+ }
72
+ selectQR() {
73
+ if (this.config.useButton) {
74
+ if (this.config.useWs) {
75
+ this.qr = (index.h("gataca-ssibuttonws", { buttonText: this.config.buttonText, wsOnMessage: this.wsOnMessage || this.config.wsOnMessage, wsOnOpen: this.wsOnOpen || this.config.wsOnOpen, successCallback: this.successCallback || this.config.successCallback, errorCallback: this.errorCallback || this.config.errorCallback, qrRole: this.config.qrRole, callbackServer: this.config.callbackServer, sessionTimeout: this.config.sessionTimeout, socketEndpoint: this.config.socketEndpoint, autostart: true, autorefresh: this.config.autorefresh, v2: this.config.v2, qrModalTitle: this.config.qrModalTitle, qrModalDescription: this.config.qrModalDescription, hideBrandTitle: this.config.hideBrandTitle, dynamicLink: this.config.dynamicLink }));
76
+ }
77
+ else {
78
+ this.qr = (index.h("gataca-ssibutton", { buttonText: this.config.buttonText, checkStatus: this.checkStatus || this.config.checkStatus, createSession: this.createSession || this.config.createSession, successCallback: this.successCallback || this.config.successCallback, errorCallback: this.errorCallback || this.config.errorCallback, qrRole: this.config.qrRole, callbackServer: this.config.callbackServer, sessionTimeout: this.config.sessionTimeout, pollingFrequency: this.config.pollingFrequency, autorefresh: this.config.autorefresh, v2: this.config.v2, qrModalTitle: this.config.qrModalTitle, qrModalDescription: this.config.qrModalDescription, hideBrandTitle: this.config.hideBrandTitle, dynamicLink: this.config.dynamicLink }));
79
+ }
80
+ }
81
+ else {
82
+ if (this.config.useWs) {
83
+ this.qr = (index.h("gataca-qrws", { wsOnMessage: this.wsOnMessage || this.config.wsOnMessage, wsOnOpen: this.wsOnOpen || this.config.wsOnOpen, successCallback: this.successCallback || this.config.successCallback, errorCallback: this.errorCallback || this.config.errorCallback, qrRole: this.config.qrRole, callbackServer: this.config.callbackServer, sessionTimeout: this.config.sessionTimeout, socketEndpoint: this.config.socketEndpoint, autostart: this.config.autostart, autorefresh: this.config.autorefresh, v2: this.config.v2, qrModalTitle: this.config.qrModalTitle, qrModalDescription: this.config.qrModalDescription, hideBrandTitle: this.config.hideBrandTitle, dynamicLink: this.config.dynamicLink }));
84
+ }
85
+ else {
86
+ this.qr = (index.h("gataca-qr", { checkStatus: this.checkStatus || this.config.checkStatus, createSession: this.createSession || this.config.createSession, successCallback: this.successCallback || this.config.successCallback, errorCallback: this.errorCallback || this.config.errorCallback, qrRole: this.config.qrRole, callbackServer: this.config.callbackServer, sessionTimeout: this.config.sessionTimeout, pollingFrequency: this.config.pollingFrequency, autostart: this.config.autostart, autorefresh: this.config.autorefresh, v2: this.config.v2, qrModalTitle: this.config.qrModalTitle, qrModalDescription: this.config.qrModalDescription, hideBrandTitle: this.config.hideBrandTitle, dynamicLink: this.config.dynamicLink }));
87
+ }
88
+ }
89
+ }
90
+ render() {
91
+ if (this.loading) {
92
+ //TODO: Improve loading message
93
+ return index.h("div", null, "Loading...");
94
+ }
95
+ if (this.config) {
96
+ this.selectQR();
97
+ return this.qr;
98
+ }
99
+ //TODO: Improve error message
100
+ return index.h("div", null, "Error loading your config...");
101
+ }
102
+ };
103
+ GatacaAutoQR.style = gatacaAutoqrCss;
104
+
105
+ exports.gataca_autoqr = GatacaAutoQR;
@@ -0,0 +1,230 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-4be0cdca.js');
6
+ const logo_gataca = require('./logo_gataca-f3dc6840.js');
7
+ const qrCodeStyling = require('./qr-code-styling-412bbc7a.js');
8
+ const utils = require('./utils-383ee834.js');
9
+
10
+ const GatacaQRDisplay = class {
11
+ constructor(hostRef) {
12
+ index.registerInstance(this, hostRef);
13
+ this.qrData = undefined;
14
+ this.size = 256;
15
+ this.logoSize = 0;
16
+ this.logoSrc = undefined;
17
+ this.qrColor = "#1E1E20";
18
+ this.rounded = true;
19
+ }
20
+ componentDidLoad() {
21
+ const qrCode = new qrCodeStyling.QRCodeStyling({
22
+ data: this.qrData,
23
+ width: this.size,
24
+ height: this.size,
25
+ image: this.logoSize > 0 ? this.logoSrc || logo_gataca.logoGatacaSvg : undefined,
26
+ margin: 10,
27
+ type: "svg",
28
+ dotsOptions: {
29
+ color: this.qrColor,
30
+ type: this.rounded ? "dots" : "square",
31
+ },
32
+ cornersSquareOptions: {
33
+ type: this.rounded ? "extra-rounded" : "square",
34
+ },
35
+ cornersDotOptions: {
36
+ type: this.rounded ? "dot" : "square",
37
+ },
38
+ imageOptions: {
39
+ margin: 2,
40
+ imageSize: this.logoSize,
41
+ },
42
+ });
43
+ qrCode.append(this.qr);
44
+ }
45
+ render() {
46
+ return (index.h("div", { ref: (el) => {
47
+ this.qr = el;
48
+ } }));
49
+ }
50
+ };
51
+
52
+ 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=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 p{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;color:#1e1e20}.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-weight:400;font-size:14px;line-height:16.5px;padding-top:12px;padding-bottom:5px;color:#A1A1A1}.popUpContainer .modal-window .bold{font-weight:600}.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 .reload{height:252px;width:252px;border:1px dashed #A1A1A1;border-radius:12px;position:relative;margin:24px;display:flex;justify-content:center;align-items:center}.popUpContainer #qrwait{display:flex;justify-content:center}.popUpContainer #qrwait,.popUpContainer #notify{width:100%;height:100%;top:0;left:0;border-radius:20px}.popUpContainer #notify{z-index:10;background-color:gray;position:absolute;justify-self:center;justify-items:center;justify-content:center;align-items:center;align-content:center;align-self:center;display:flex;flex-direction:column;padding:24px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:20px;background:rgba(255, 255, 255, 0.9);}.popUpContainer .notify-text{font-family:\"Work Sans\";font-style:normal;font-weight:400;font-size:14px;line-height:16px;text-align:center;font-feature-settings:\"salt\" on;color:#8B8B8B;flex:none;order:1;align-self:stretch;flex-grow:0}.popUpContainer .alert{display:flex;flex-direction:row;align-items:center;justify-content:start;width:252px;position:absolute;bottom:0;background:#FFE5E5;border-radius:12px}.popUpContainer .alert img{margin:12px}.popUpContainer .alert p{font-weight:400;font-size:14px;line-height:16px;color:black}.popUpContainer .success{display:flex;height:300px;flex-direction:column;justify-content:center;align-items:center;padding:0px}.popUpContainer .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;}.popUpContainer .is-visible{opacity:1;visibility:visible}.is-transparent{opacity:0}";
53
+
54
+ const DEEP_LINK_PREFIX = "https://gataca.page.link/?apn=com.gatacaapp&ibi=com.gataca.wallet&link=";
55
+ //Default values
56
+ const DEFAULT_SESSION_TIMEOUT = 300; //5mins as in connect
57
+ const DEFAULT_POLLING_FREQ = 3;
58
+ const QR_ROLE_CONNECT = "connect";
59
+ const FUNCTION_ROLES = {
60
+ connect: "scan",
61
+ certify: "credential",
62
+ };
63
+ const GatacaQR = class {
64
+ 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.callbackServer = undefined; this.autostart = true; this.autorefresh = false; this.v2 = false; 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 = logo_gataca.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.hideQrModalDescription = false; this.sessionTimeout = DEFAULT_SESSION_TIMEOUT; this.pollingFrequency = DEFAULT_POLLING_FREQ; this.dynamicLink = true; this.sessionId = undefined; this.authenticationRequest = undefined; this.sessionData = undefined; this.result = utils.RESULT_STATUS.NOT_STARTED; }
65
+ disconnectedCallback() {
66
+ this.stop();
67
+ }
68
+ async componentDidLoad() {
69
+ if (this.autostart) {
70
+ await this.display();
71
+ }
72
+ }
73
+ /**
74
+ * Force manually the display of a QR
75
+ */
76
+ async display() {
77
+ await this.getSessionId();
78
+ this.result = utils.RESULT_STATUS.ONGOING;
79
+ this.poll()
80
+ .then((data) => {
81
+ this.result = utils.RESULT_STATUS.SUCCESS;
82
+ this.sessionData = data;
83
+ this.gatacaLoginCompleted.emit(data);
84
+ this.successCallback(data);
85
+ })
86
+ .catch((err) => {
87
+ this.clean();
88
+ let expired = err === utils.RESULT_STATUS.EXPIRED;
89
+ if (expired && this.autorefresh) {
90
+ this.display();
91
+ }
92
+ else {
93
+ if (err !== utils.RESULT_STATUS.NOT_STARTED) {
94
+ let error = expired
95
+ ? new Error(this.userNotScanInTimeErrorLabel)
96
+ : new Error(this.credsNotValidatedErrorLabel);
97
+ this.result = err;
98
+ this.gatacaLoginFailed.emit(error);
99
+ this.errorCallback(error);
100
+ }
101
+ }
102
+ });
103
+ if (utils.checkMobile() && this.dynamicLink) {
104
+ window.location.href = this.getLink();
105
+ }
106
+ }
107
+ /**
108
+ * Stop manually an ongoing session
109
+ */
110
+ async stop() {
111
+ this.clean();
112
+ if (this.result === utils.RESULT_STATUS.ONGOING) {
113
+ this.result = utils.RESULT_STATUS.NOT_STARTED;
114
+ }
115
+ }
116
+ clean() {
117
+ this.sessionData = undefined;
118
+ this.sessionId = undefined;
119
+ }
120
+ /**
121
+ * Retrieve manually the session data on a successful login
122
+ */
123
+ async getSessionData() {
124
+ return this.sessionData
125
+ ? Promise.resolve(this.sessionData)
126
+ : Promise.reject(new Error(this.failedLoginErrorLabel));
127
+ }
128
+ async getSessionId() {
129
+ if (this.sessionId) {
130
+ return this.sessionId;
131
+ }
132
+ let { sessionId, authenticationRequest } = await this.createSession();
133
+ this.sessionId = sessionId;
134
+ this.authenticationRequest = authenticationRequest;
135
+ return this.sessionId;
136
+ }
137
+ getLink() {
138
+ if (this.v2) {
139
+ return this.authenticationRequest;
140
+ }
141
+ let op = FUNCTION_ROLES[this.qrRole];
142
+ let link = "https://gataca.page.link/" + op + "?";
143
+ link +=
144
+ this.qrRole === QR_ROLE_CONNECT
145
+ ? "session=" + this.sessionId
146
+ : "process=" + this.sessionId;
147
+ link +=
148
+ "&callback=" + utils.base64UrlEncode(encodeURIComponent(this.callbackServer));
149
+ link = encodeURIComponent(link);
150
+ return this.dynamicLink ? DEEP_LINK_PREFIX + link : link;
151
+ }
152
+ async poll() {
153
+ let endTime = new Date().getTime() +
154
+ (this.sessionTimeout || DEFAULT_SESSION_TIMEOUT) * 1000;
155
+ let interval = (this.pollingFrequency || DEFAULT_POLLING_FREQ) * 1000;
156
+ let checkFunc = async (component) => {
157
+ if (component.result === utils.RESULT_STATUS.NOT_STARTED) {
158
+ return { result: utils.RESULT_STATUS.NOT_STARTED };
159
+ }
160
+ let id = await component.getSessionId();
161
+ return component.checkStatus(id);
162
+ };
163
+ let component = this;
164
+ let checkCondition = async function (resolve, reject) {
165
+ // If the condition is met, we're done!
166
+ let { result, data } = await checkFunc(component);
167
+ switch (result) {
168
+ case utils.RESULT_STATUS.SUCCESS:
169
+ resolve(data);
170
+ break;
171
+ case utils.RESULT_STATUS.ONGOING:
172
+ if (component.sessionTimeout > 0 && new Date().getTime() < endTime) {
173
+ setTimeout(checkCondition, interval, resolve, reject);
174
+ }
175
+ else {
176
+ reject(utils.RESULT_STATUS.EXPIRED);
177
+ }
178
+ break;
179
+ default:
180
+ reject(result);
181
+ break;
182
+ }
183
+ };
184
+ return new Promise(checkCondition);
185
+ }
186
+ renderQRSection() {
187
+ switch (this.result) {
188
+ case utils.RESULT_STATUS.NOT_STARTED:
189
+ return this.renderRetryButton();
190
+ case utils.RESULT_STATUS.ONGOING:
191
+ return this.renderQR(this.getLink(), true);
192
+ case utils.RESULT_STATUS.EXPIRED:
193
+ return this.renderRetryButton(this.qrCodeExpiredLabel);
194
+ case utils.RESULT_STATUS.FAILED:
195
+ return this.renderRetryButton(this.credentialsNotValidatedLabel);
196
+ case utils.RESULT_STATUS.SUCCESS:
197
+ return this.renderSuccess();
198
+ }
199
+ }
200
+ renderSuccess() {
201
+ var _a;
202
+ return (index.h("div", { class: "success", style: {
203
+ height: this.modalHeight
204
+ ? ((_a = this.modalHeight) === null || _a === void 0 ? void 0 : _a.toString()) + "px"
205
+ : "300px",
206
+ } }, index.h("img", { src: logo_gataca.gatIconCheckSvg, height: 52, width: 52 }), index.h("p", { class: "successMsg" }, this.successLoginLabel)));
207
+ }
208
+ renderRetryButton(errorMessage) {
209
+ return (index.h("div", { class: "reload" }, index.h("div", { id: "notify", onClick: () => this.display() }, index.h("img", { src: logo_gataca.gatIconRefreshSvg, height: 24, width: 24 }), index.h("p", { class: "qrDescription" }, this.clickInsideBoxLabel, " "), errorMessage ? (index.h("p", { class: "qrDescription bold" }, this.refreshQrLabel)) : (index.h("p", { class: "qrDescription bold" }, this.scanQrLabel, "e")), errorMessage && (index.h("div", { class: "alert" }, index.h("img", { src: logo_gataca.gatIconAlertSvg, height: 24, width: 24 }), index.h("p", null, errorMessage)))), index.h("div", { id: "qrwait" }, this.renderQR(this.waitingStartSessionLabel))));
210
+ }
211
+ renderQR(value, useLogo) {
212
+ return (index.h("gataca-qrdisplay", { qrData: value, rounded: true, size: this.qrSize, "logo-size": useLogo ? 0.33 : 0, "logo-src": this.logoSrc }));
213
+ }
214
+ render() {
215
+ var _a;
216
+ return (index.h("div", { class: "popUpContainer" }, index.h("div", { class: `is-visible modal-window ${this.hideModalTexts ? "" : "large-modal"} ${this.hideModalBoxShadow ? "noBoxShadow" : ""}`, style: {
217
+ width: (this.modalWidth - 2).toString() + "px",
218
+ height: this.modalHeight
219
+ ? ((_a = (this.modalHeight - 2)) === null || _a === void 0 ? void 0 : _a.toString()) + "px"
220
+ : "",
221
+ }, onClick: (event) => {
222
+ event.stopPropagation();
223
+ } }, index.h("div", { class: "modal-window__content" }, index.h("div", { class: `qrTitleContainer ${this.hideModalTexts ? "hidenText" : ""}` }, index.h("p", { class: "qrTitle", style: { color: this.modalTitleColor || "#1e1e20" } }, this.qrModalTitle), !this.hideBrandTitle && (index.h("p", { class: "qrBrand" }, this.byBrandLabel, " ", index.h("span", null, index.h("img", { src: logo_gataca.logoGatacaSvg })))), this.result !== utils.RESULT_STATUS.SUCCESS &&
224
+ !this.hideQrModalDescription && (index.h("p", { class: "qrDescription" }, this.qrModalDescription))), index.h("div", { class: "qrSection" }, this.renderQRSection())))));
225
+ }
226
+ };
227
+ GatacaQR.style = gatacaQrCss;
228
+
229
+ exports.gataca_qr = GatacaQR;
230
+ exports.gataca_qrdisplay = GatacaQRDisplay;
@@ -0,0 +1,176 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-4be0cdca.js');
6
+ const logo_gataca = require('./logo_gataca-f3dc6840.js');
7
+ require('./qr-code-styling-412bbc7a.js');
8
+ const utils = require('./utils-383ee834.js');
9
+
10
+ const gatacaQrwsCss = "@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 .modal-window{position:relative;border-radius:6px;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;width:300px;min-height:408px;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 p{font-family:\"Work Sans\", \"Helvetica Neue\", sans-serif;font-weight:normal;font-size:12px;letter-spacing:1px;color:#1e1e20}.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-weight:400;font-size:14px;line-height:16.5px;padding-top:12px;padding-bottom:5px;color:#A1A1A1}.popUpContainer .modal-window .bold{font-weight:600}.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 .reload{height:252px;width:252px;border:1px dashed #A1A1A1;border-radius:12px;position:relative;margin:24px;display:flex;justify-content:center;align-items:center}.popUpContainer #qrwait{display:flex;justify-content:center}.popUpContainer #qrwait,.popUpContainer #notify{width:100%;height:100%;top:0;left:0;border-radius:20px}.popUpContainer #notify{z-index:10;background-color:gray;position:absolute;justify-self:center;justify-items:center;justify-content:center;align-items:center;align-content:center;align-self:center;display:flex;flex-direction:column;padding:24px;box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:20px;background:rgba(255, 255, 255, 0.9);}.popUpContainer .notify-text{font-family:\"Work Sans\";font-style:normal;font-weight:400;font-size:14px;line-height:16px;text-align:center;font-feature-settings:\"salt\" on;color:#8B8B8B;flex:none;order:1;align-self:stretch;flex-grow:0}.popUpContainer .alert{display:flex;flex-direction:row;align-items:center;justify-content:start;width:252px;position:absolute;bottom:0;background:#FFE5E5;border-radius:12px}.popUpContainer .alert img{margin:12px}.popUpContainer .alert p{font-weight:400;font-size:14px;line-height:16px;color:black}.popUpContainer .success{display:flex;height:300px;flex-direction:column;justify-content:center;align-items:center;padding:0px}.popUpContainer .success .successMsg{margin-top:20px;font-size:20px;font-weight:600;line-height:23.5px}.popUpContainer .is-visible{opacity:1;visibility:visible}.is-transparent{opacity:0}";
11
+
12
+ const DEEP_LINK_PREFIX = "https://gataca.page.link/?apn=com.gatacaapp&ibi=com.gataca.wallet&link=";
13
+ const DEFAULT_SESSION_TIMEOUT = 300;
14
+ const QR_ROLE_CONNECT = "connect";
15
+ const FUNCTION_ROLES = {
16
+ connect: "scan",
17
+ certify: "credential",
18
+ };
19
+ const GatacaQRWS = class {
20
+ constructor(hostRef) { index.registerInstance(this, hostRef); this.gatacaLoginCompleted = index.createEvent(this, "gatacaLoginCompleted", 7); this.gatacaLoginFailed = index.createEvent(this, "gatacaLoginFailed", 7); this.successCallback = undefined; this.errorCallback = undefined; this.qrRole = undefined; this.callbackServer = undefined; this.socketEndpoint = undefined; this.sessionTimeout = DEFAULT_SESSION_TIMEOUT; this.wsOnOpen = undefined; this.wsOnMessage = undefined; this.autostart = true; this.autorefresh = false; this.v2 = false; this.qrModalTitle = "Quick Access"; this.qrModalDescription = "Sign up or sign in by scanning the QR Code with the Gataca Wallet"; this.hideBrandTitle = false; this.dynamicLink = true; this.sessionId = undefined; this.authenticationRequest = undefined; this.sessionData = undefined; this.result = utils.RESULT_STATUS.NOT_STARTED; }
21
+ disconnectedCallback() {
22
+ this.stop();
23
+ }
24
+ async componentDidLoad() {
25
+ if (this.autostart) {
26
+ await this.display();
27
+ }
28
+ }
29
+ /**
30
+ * Force manually the display of a QR
31
+ */
32
+ async display() {
33
+ let socket = new WebSocket(this.socketEndpoint);
34
+ setTimeout(() => {
35
+ this.socket.close(1000, "");
36
+ }, 1000 * this.sessionTimeout);
37
+ this.socket = socket;
38
+ socket.onopen = () => {
39
+ if (this.wsOnOpen)
40
+ this.wsOnOpen(this.socket);
41
+ };
42
+ socket.onmessage = (msg) => {
43
+ if (this.wsOnMessage) {
44
+ this.wsOnMessage(this.socket, msg);
45
+ }
46
+ else {
47
+ let wsresp = JSON.parse(msg.data);
48
+ if (!!wsresp.sessionId) {
49
+ this.handleWSResponse(wsresp);
50
+ }
51
+ }
52
+ };
53
+ socket.onerror = () => {
54
+ let error = new Error("Error connecting with server");
55
+ this.result = utils.RESULT_STATUS.FAILED;
56
+ this.gatacaLoginFailed.emit(error);
57
+ this.errorCallback(error);
58
+ socket.close(1000, "");
59
+ };
60
+ socket.onclose = () => {
61
+ if (this.result === utils.RESULT_STATUS.ONGOING) {
62
+ this.result = utils.RESULT_STATUS.EXPIRED;
63
+ }
64
+ if (this.result === utils.RESULT_STATUS.EXPIRED) {
65
+ if (this.autorefresh) {
66
+ this.display();
67
+ }
68
+ else {
69
+ let error = new Error("User did not scan the QR in the alloted time");
70
+ this.gatacaLoginFailed.emit(error);
71
+ this.errorCallback(error);
72
+ }
73
+ }
74
+ };
75
+ if (utils.checkMobile() && this.dynamicLink) {
76
+ window.location.href = this.getLink();
77
+ }
78
+ }
79
+ sessionMsgReceived(event) {
80
+ let wsresp = event.detail;
81
+ this.handleWSResponse(wsresp);
82
+ }
83
+ handleWSResponse(wsresp) {
84
+ this.result = wsresp.result;
85
+ switch (wsresp.result) {
86
+ case utils.RESULT_STATUS.ONGOING:
87
+ this.sessionId = wsresp.sessionId;
88
+ this.authenticationRequest = wsresp.authenticationRequest;
89
+ break;
90
+ case utils.RESULT_STATUS.SUCCESS:
91
+ this.sessionData = wsresp.authenticatedUserData;
92
+ this.gatacaLoginCompleted.emit(wsresp.authenticatedUserData);
93
+ this.successCallback(wsresp.authenticatedUserData);
94
+ this.socket.close(1000, "");
95
+ break;
96
+ case utils.RESULT_STATUS.FAILED:
97
+ this.socket.close();
98
+ let error = new Error("Provided user credentials couldn't be validated");
99
+ this.gatacaLoginFailed.emit(error);
100
+ this.errorCallback(error);
101
+ break;
102
+ case utils.RESULT_STATUS.EXPIRED:
103
+ this.socket.close();
104
+ if (this.autorefresh) {
105
+ this.display();
106
+ }
107
+ else {
108
+ let error = new Error("User did not scan the QR in the alloted time");
109
+ this.gatacaLoginFailed.emit(error);
110
+ this.errorCallback(error);
111
+ }
112
+ }
113
+ }
114
+ /**
115
+ * Stop manually an ongoing session
116
+ */
117
+ async stop() {
118
+ this.sessionData = undefined;
119
+ this.sessionId = undefined;
120
+ this.socket.close(1000, "Client stopped the connection");
121
+ }
122
+ /**
123
+ * Retrieve manually the session data on a successful login
124
+ */
125
+ async getSessionData() {
126
+ return this.sessionData
127
+ ? Promise.resolve(this.sessionData)
128
+ : Promise.reject(new Error("No successful login"));
129
+ }
130
+ getLink() {
131
+ if (this.v2 && this.qrRole == QR_ROLE_CONNECT) {
132
+ return this.authenticationRequest;
133
+ }
134
+ let op = FUNCTION_ROLES[this.qrRole];
135
+ let link = "https://gataca.page.link/" + op + "?";
136
+ link +=
137
+ this.qrRole === QR_ROLE_CONNECT
138
+ ? "session=" + this.sessionId
139
+ : "process=" + this.sessionId;
140
+ link +=
141
+ "&callback=" + utils.base64UrlEncode(encodeURIComponent(this.callbackServer));
142
+ link = encodeURIComponent(link);
143
+ return this.dynamicLink ? DEEP_LINK_PREFIX + link : link;
144
+ }
145
+ renderQRSection() {
146
+ switch (this.result) {
147
+ case utils.RESULT_STATUS.NOT_STARTED:
148
+ return this.renderRetryButton();
149
+ case utils.RESULT_STATUS.ONGOING:
150
+ return this.renderQR(this.getLink(), 300, true);
151
+ case utils.RESULT_STATUS.EXPIRED:
152
+ return this.renderRetryButton("QR Code expired");
153
+ case utils.RESULT_STATUS.FAILED:
154
+ return this.renderRetryButton("User credentials not validated");
155
+ case utils.RESULT_STATUS.SUCCESS:
156
+ return this.renderSuccess();
157
+ }
158
+ }
159
+ renderSuccess() {
160
+ return (index.h("div", { class: "success" }, index.h("img", { src: logo_gataca.gatIconCheckSvg, height: 52, width: 52 }), index.h("p", { class: "successMsg" }, "Successful Connection!")));
161
+ }
162
+ renderRetryButton(errorMessage) {
163
+ return (index.h("div", { class: "reload" }, index.h("div", { id: "notify", onClick: () => this.display() }, index.h("img", { src: logo_gataca.gatIconRefreshSvg, height: 24, width: 24 }), index.h("p", { class: "qrDescription" }, "Click inside the box to "), errorMessage ? (index.h("p", { class: "qrDescription bold" }, "Refresh QR Code")) : (index.h("p", { class: "qrDescription bold" }, "Scan QR Code")), errorMessage && (index.h("div", { class: "alert" }, index.h("img", { src: logo_gataca.gatIconAlertSvg, height: 24, width: 24 }), index.h("p", null, errorMessage)))), index.h("div", { id: "qrwait" }, this.renderQR("waiting to start a session", 250))));
164
+ }
165
+ renderQR(value, size, useLogo) {
166
+ return (index.h("gataca-qrdisplay", { qrData: value, rounded: true, size: size, "logo-size": useLogo ? 0.33 : 0 }));
167
+ }
168
+ render() {
169
+ return (index.h("div", { class: "popUpContainer" }, index.h("div", { class: "modal-window is-visible", onClick: (event) => {
170
+ event.stopPropagation();
171
+ } }, index.h("div", { class: "modal-window__content" }, index.h("div", { class: "qrTitleContainer" }, index.h("p", { class: "qrTitle" }, this.qrModalTitle), !this.hideBrandTitle && (index.h("p", { class: "qrBrand" }, "by Gataca", " ", index.h("span", null, index.h("img", { src: logo_gataca.logoGatacaSvg })))), this.result !== utils.RESULT_STATUS.SUCCESS && (index.h("p", { class: "qrDescription" }, this.qrModalDescription))), index.h("div", { class: "qrSection" }, this.renderQRSection())))));
172
+ }
173
+ };
174
+ GatacaQRWS.style = gatacaQrwsCss;
175
+
176
+ exports.gataca_qrws = GatacaQRWS;