@oila/0account 3.4.6 → 3.4.8

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 (83) hide show
  1. package/dist/types/components/zero-account/zero-account.d.ts +0 -3
  2. package/dist/types/components.d.ts +0 -6
  3. package/dist/zero-account/app-globals-0f993ce5.js +5 -0
  4. package/dist/zero-account/app-globals-0f993ce5.js.map +1 -0
  5. package/dist/{collection/components/zero-account/enums.js → zero-account/enums-816340c2.js} +7 -4
  6. package/dist/zero-account/enums-816340c2.js.map +1 -0
  7. package/dist/zero-account/enums-e7827156.js +21 -0
  8. package/dist/zero-account/enums-e7827156.js.map +1 -0
  9. package/dist/zero-account/index-57856b47.js +3380 -0
  10. package/dist/zero-account/index-57856b47.js.map +1 -0
  11. package/dist/zero-account/index.esm.js +1 -0
  12. package/dist/zero-account/index.esm.js.map +1 -1
  13. package/dist/{collection/utils/qrcode/qrcode.js → zero-account/qr-code.entry.js} +35 -3
  14. package/dist/zero-account/qr-code.entry.js.map +1 -0
  15. package/dist/zero-account/shadow-css-8a6ccf47.js +389 -0
  16. package/dist/zero-account/shadow-css-8a6ccf47.js.map +1 -0
  17. package/dist/{components/zero-account.js → zero-account/zero-account.entry.js} +597 -64
  18. package/dist/zero-account/zero-account.entry.js.map +1 -0
  19. package/dist/zero-account/zero-account.esm.js +64 -1
  20. package/dist/zero-account/zero-account.esm.js.map +1 -1
  21. package/package.json +1 -1
  22. package/dist/cjs/index-1e526aba.js +0 -1645
  23. package/dist/cjs/index-1e526aba.js.map +0 -1
  24. package/dist/cjs/index.cjs.js +0 -4
  25. package/dist/cjs/index.cjs.js.map +0 -1
  26. package/dist/cjs/loader.cjs.js +0 -15
  27. package/dist/cjs/loader.cjs.js.map +0 -1
  28. package/dist/cjs/qr-code_2.cjs.entry.js +0 -2473
  29. package/dist/cjs/qr-code_2.cjs.entry.js.map +0 -1
  30. package/dist/cjs/zero-account.cjs.js +0 -25
  31. package/dist/cjs/zero-account.cjs.js.map +0 -1
  32. package/dist/collection/collection-manifest.json +0 -13
  33. package/dist/collection/components/zero-account/enums.js.map +0 -1
  34. package/dist/collection/components/zero-account/logo.js +0 -6
  35. package/dist/collection/components/zero-account/logo.js.map +0 -1
  36. package/dist/collection/components/zero-account/qrcode.js +0 -111
  37. package/dist/collection/components/zero-account/qrcode.js.map +0 -1
  38. package/dist/collection/components/zero-account/websocket.js +0 -175
  39. package/dist/collection/components/zero-account/websocket.js.map +0 -1
  40. package/dist/collection/components/zero-account/zero-account.css +0 -287
  41. package/dist/collection/components/zero-account/zero-account.e2e.js +0 -26
  42. package/dist/collection/components/zero-account/zero-account.e2e.js.map +0 -1
  43. package/dist/collection/components/zero-account/zero-account.js +0 -457
  44. package/dist/collection/components/zero-account/zero-account.js.map +0 -1
  45. package/dist/collection/components/zero-account/zero-account.spec.js +0 -35
  46. package/dist/collection/components/zero-account/zero-account.spec.js.map +0 -1
  47. package/dist/collection/index.js +0 -2
  48. package/dist/collection/index.js.map +0 -1
  49. package/dist/collection/utils/request.js +0 -38
  50. package/dist/collection/utils/request.js.map +0 -1
  51. package/dist/collection/utils/url.js +0 -43
  52. package/dist/collection/utils/utils.js +0 -16
  53. package/dist/collection/utils/utils.js.map +0 -1
  54. package/dist/collection/utils/utils.spec.js +0 -10
  55. package/dist/collection/utils/utils.spec.js.map +0 -1
  56. package/dist/components/index.js +0 -3
  57. package/dist/components/index.js.map +0 -1
  58. package/dist/components/qr-code.js +0 -8
  59. package/dist/components/qr-code.js.map +0 -1
  60. package/dist/components/qrcode.js +0 -1073
  61. package/dist/components/qrcode.js.map +0 -1
  62. package/dist/components/zero-account.js.map +0 -1
  63. package/dist/esm/index-09024c20.js +0 -1616
  64. package/dist/esm/index-09024c20.js.map +0 -1
  65. package/dist/esm/index.js +0 -3
  66. package/dist/esm/index.js.map +0 -1
  67. package/dist/esm/loader.js +0 -11
  68. package/dist/esm/loader.js.map +0 -1
  69. package/dist/esm/polyfills/core-js.js +0 -11
  70. package/dist/esm/polyfills/dom.js +0 -79
  71. package/dist/esm/polyfills/es5-html-element.js +0 -1
  72. package/dist/esm/polyfills/index.js +0 -34
  73. package/dist/esm/polyfills/system.js +0 -6
  74. package/dist/esm/qr-code_2.entry.js +0 -2468
  75. package/dist/esm/qr-code_2.entry.js.map +0 -1
  76. package/dist/esm/zero-account.js +0 -20
  77. package/dist/esm/zero-account.js.map +0 -1
  78. package/dist/index.cjs.js +0 -1
  79. package/dist/index.js +0 -1
  80. package/dist/zero-account/p-1a2ddcc2.entry.js +0 -2
  81. package/dist/zero-account/p-1a2ddcc2.entry.js.map +0 -1
  82. package/dist/zero-account/p-21f4994d.js +0 -3
  83. package/dist/zero-account/p-21f4994d.js.map +0 -1
@@ -1,457 +0,0 @@
1
- import { h, Host } from "@stencil/core";
2
- import { UAParser } from "ua-parser-js";
3
- import { v4 as uuidv4 } from "uuid";
4
- import { Environment, ErrorCorrectionLevel, ThemePreset } from "./enums";
5
- import { Logger } from "../../utils/utils";
6
- import * as utilsURL from "../../utils/url";
7
- import Logo from "./logo";
8
- import { WS } from "./websocket";
9
- const maxInterval = 59 * 60 * 1000;
10
- const minInterval = 10 * 1000;
11
- const DEFAULT_CALLBACK_URL = window.location.origin + '/zero/auth';
12
- const ANIMATION_DURATION = 3000;
13
- export class ZeroAccount {
14
- constructor() {
15
- this.refreshQR = (ignoreAnimate = false) => {
16
- const update = () => {
17
- this.restartTimer();
18
- this.updateURL();
19
- };
20
- if (ignoreAnimate)
21
- return update();
22
- this.isAnimating = true;
23
- this.animationTimer = window.setTimeout(() => {
24
- update();
25
- this.isAnimating = false;
26
- }, ANIMATION_DURATION);
27
- };
28
- this.hideOnEsc = (e) => {
29
- if ((e.key === 'Escape' || e.key === 'Esc')) {
30
- this.modalOpen = false;
31
- }
32
- };
33
- this.log = (...args) => this.logger.log(...args);
34
- this.appId = undefined;
35
- this.updateInterval = 3 * 60 * 1000;
36
- this.callbackURL = DEFAULT_CALLBACK_URL;
37
- this.modal = true;
38
- this.selector = null;
39
- this.level = ErrorCorrectionLevel.M;
40
- this.primaryColor = '#3C444F';
41
- this.secondaryColor = undefined;
42
- this.instructionsText = undefined;
43
- this.hideInstructions = false;
44
- this.environment = Environment.production;
45
- this.enableWithCredentials = false;
46
- this.themePreset = ThemePreset.light;
47
- this.autoStartApp = true;
48
- this.modalOpen = false;
49
- this.isAnimating = false;
50
- this.url = '';
51
- }
52
- getUpdateInterval() {
53
- // make sure the provided value is within bounds
54
- return Math.min(Math.max(this.updateInterval, minInterval), maxInterval);
55
- }
56
- toggleModal() {
57
- this.modalOpen = !this.modalOpen;
58
- if (this.modalOpen)
59
- this.refreshQR(true);
60
- if ((this.modalOpen && this.autoStartApp) || this.isMobile())
61
- this.openApp();
62
- }
63
- _closeModal() {
64
- this.modalOpen = false;
65
- this.stopTimer();
66
- }
67
- closeModal(e) {
68
- if (e.target !== this.modalEl && e.target !== this.closeButtonEl) {
69
- return e.stopPropagation();
70
- }
71
- this._closeModal();
72
- }
73
- openApp() {
74
- if (this.modalOpen) {
75
- window.location.href = this.url;
76
- }
77
- }
78
- render() {
79
- const logoColor = this.themePreset === ThemePreset.light ? '#7263FA' : '#FFFFF9';
80
- const qrColor = this.themePreset === ThemePreset.light ? '#000' : '#FFFFF9';
81
- return (h(Host, null, h("slot", null), this.host.childNodes.length === 0 &&
82
- h("button", { class: `button ${this.themePreset}`, onClick: () => this.toggleModal() }, h(Logo, { className: 'button__logo', color: logoColor }), "use 0account"), h("div", { ref: el => this.modalEl = el, onClick: (e) => this.closeModal(e), class: `modal ${this.themePreset} ${this.isAnimating ? 'modal-animated' : ''} ${this.modalOpen ? '' : 'modal--hidden'}` }, h("div", { class: 'modal__content' }, h("div", { ref: el => this.closeButtonEl = el, class: 'modal__close-button' }), h("div", { class: 'modal__qrcode__container' }, h("qr-code", { url: this.url, class: `modal__qrcode`, level: this.level, color: qrColor }), h("div", { class: 'circle__overlay' }, h("div", { class: 'circle' }), h("div", { class: 'circle circle--medium' }), h("div", { class: 'circle circle--large' })), h(Logo, { className: 'modal__logo', color: logoColor })), h("div", { class: 'modal__buttons' }, h("button", { onClick: () => this.openApp(), class: 'modal__button' }, "Open the desktop app"), h("a", { href: '#', class: 'modal__link' }, "Download the app"))))));
83
- }
84
- // called only once
85
- componentWillLoad() {
86
- this.logger = new Logger(this.environment);
87
- this.uaParser = new UAParser();
88
- this.ws = new WS(this.appId, {
89
- updateInterval: this.getUpdateInterval(),
90
- callbackURL: this.callbackURL,
91
- uaParser: this.uaParser,
92
- env: this.environment,
93
- log: this.log,
94
- });
95
- // make sure we initQR
96
- this.refreshQR(true);
97
- document.addEventListener('keydown', this.hideOnEsc);
98
- }
99
- updateURL() {
100
- const expires = new Date().getTime() + this.getUpdateInterval();
101
- const uuid = uuidv4();
102
- this.ws.updateUUID(uuid);
103
- const params = utilsURL.appendToParams('', {
104
- appId: this.appId,
105
- uuid: uuid,
106
- expires: expires,
107
- });
108
- if (this.isMobile()) {
109
- this.url = 'https://launch.0account.com/auth?' + params;
110
- }
111
- else {
112
- this.url = 'zero-account://auth?' + params;
113
- }
114
- }
115
- isMobile() {
116
- const device = this.uaParser.getDevice();
117
- return device.type === 'tablet' || device.type === 'mobile';
118
- }
119
- connectedCallback() {
120
- this.startTimer();
121
- }
122
- disconnectedCallback() {
123
- this.stopTimer();
124
- document.removeEventListener('keydown', this.hideOnEsc);
125
- }
126
- restartTimer() {
127
- this.stopTimer();
128
- this.startTimer();
129
- }
130
- startTimer() {
131
- this.timer = window.setInterval(this.refreshQR, this.getUpdateInterval());
132
- }
133
- stopTimer() {
134
- window.clearInterval(this.timer);
135
- window.clearTimeout(this.animationTimer);
136
- this.isAnimating = false;
137
- }
138
- static get is() { return "zero-account"; }
139
- static get encapsulation() { return "shadow"; }
140
- static get originalStyleUrls() {
141
- return {
142
- "$": ["zero-account.css"]
143
- };
144
- }
145
- static get styleUrls() {
146
- return {
147
- "$": ["zero-account.css"]
148
- };
149
- }
150
- static get properties() {
151
- return {
152
- "appId": {
153
- "type": "string",
154
- "mutable": false,
155
- "complexType": {
156
- "original": "string",
157
- "resolved": "string",
158
- "references": {}
159
- },
160
- "required": true,
161
- "optional": false,
162
- "docs": {
163
- "tags": [],
164
- "text": ""
165
- },
166
- "attribute": "app-id",
167
- "reflect": false
168
- },
169
- "updateInterval": {
170
- "type": "number",
171
- "mutable": false,
172
- "complexType": {
173
- "original": "number",
174
- "resolved": "number",
175
- "references": {}
176
- },
177
- "required": false,
178
- "optional": true,
179
- "docs": {
180
- "tags": [],
181
- "text": ""
182
- },
183
- "attribute": "update-interval",
184
- "reflect": false,
185
- "defaultValue": "3 * 60 * 1000"
186
- },
187
- "callbackURL": {
188
- "type": "string",
189
- "mutable": false,
190
- "complexType": {
191
- "original": "string",
192
- "resolved": "string",
193
- "references": {}
194
- },
195
- "required": false,
196
- "optional": false,
197
- "docs": {
198
- "tags": [],
199
- "text": ""
200
- },
201
- "attribute": "callback-u-r-l",
202
- "reflect": false,
203
- "defaultValue": "DEFAULT_CALLBACK_URL"
204
- },
205
- "modal": {
206
- "type": "boolean",
207
- "mutable": false,
208
- "complexType": {
209
- "original": "boolean",
210
- "resolved": "boolean",
211
- "references": {}
212
- },
213
- "required": false,
214
- "optional": true,
215
- "docs": {
216
- "tags": [],
217
- "text": ""
218
- },
219
- "attribute": "modal",
220
- "reflect": false,
221
- "defaultValue": "true"
222
- },
223
- "selector": {
224
- "type": "string",
225
- "mutable": false,
226
- "complexType": {
227
- "original": "string",
228
- "resolved": "string",
229
- "references": {}
230
- },
231
- "required": false,
232
- "optional": true,
233
- "docs": {
234
- "tags": [],
235
- "text": ""
236
- },
237
- "attribute": "selector",
238
- "reflect": false,
239
- "defaultValue": "null"
240
- },
241
- "level": {
242
- "type": "string",
243
- "mutable": false,
244
- "complexType": {
245
- "original": "ErrorCorrectionLevel",
246
- "resolved": "ErrorCorrectionLevel.H | ErrorCorrectionLevel.L | ErrorCorrectionLevel.M | ErrorCorrectionLevel.Q",
247
- "references": {
248
- "ErrorCorrectionLevel": {
249
- "location": "import",
250
- "path": "./enums",
251
- "id": "src/components/zero-account/enums.ts::ErrorCorrectionLevel"
252
- }
253
- }
254
- },
255
- "required": false,
256
- "optional": true,
257
- "docs": {
258
- "tags": [],
259
- "text": ""
260
- },
261
- "attribute": "level",
262
- "reflect": false,
263
- "defaultValue": "ErrorCorrectionLevel.M"
264
- },
265
- "primaryColor": {
266
- "type": "string",
267
- "mutable": false,
268
- "complexType": {
269
- "original": "string",
270
- "resolved": "string",
271
- "references": {}
272
- },
273
- "required": false,
274
- "optional": false,
275
- "docs": {
276
- "tags": [],
277
- "text": ""
278
- },
279
- "attribute": "primary-color",
280
- "reflect": false,
281
- "defaultValue": "'#3C444F'"
282
- },
283
- "secondaryColor": {
284
- "type": "string",
285
- "mutable": false,
286
- "complexType": {
287
- "original": "string",
288
- "resolved": "string",
289
- "references": {}
290
- },
291
- "required": false,
292
- "optional": false,
293
- "docs": {
294
- "tags": [],
295
- "text": ""
296
- },
297
- "attribute": "secondary-color",
298
- "reflect": false
299
- },
300
- "instructionsText": {
301
- "type": "string",
302
- "mutable": false,
303
- "complexType": {
304
- "original": "string",
305
- "resolved": "string",
306
- "references": {}
307
- },
308
- "required": false,
309
- "optional": false,
310
- "docs": {
311
- "tags": [],
312
- "text": ""
313
- },
314
- "attribute": "instructions-text",
315
- "reflect": false
316
- },
317
- "hideInstructions": {
318
- "type": "boolean",
319
- "mutable": false,
320
- "complexType": {
321
- "original": "boolean",
322
- "resolved": "boolean",
323
- "references": {}
324
- },
325
- "required": false,
326
- "optional": false,
327
- "docs": {
328
- "tags": [],
329
- "text": ""
330
- },
331
- "attribute": "hide-instructions",
332
- "reflect": false,
333
- "defaultValue": "false"
334
- },
335
- "environment": {
336
- "type": "string",
337
- "mutable": false,
338
- "complexType": {
339
- "original": "Environment",
340
- "resolved": "Environment.production | Environment.staging",
341
- "references": {
342
- "Environment": {
343
- "location": "import",
344
- "path": "./enums",
345
- "id": "src/components/zero-account/enums.ts::Environment"
346
- }
347
- }
348
- },
349
- "required": false,
350
- "optional": true,
351
- "docs": {
352
- "tags": [],
353
- "text": ""
354
- },
355
- "attribute": "environment",
356
- "reflect": false,
357
- "defaultValue": "Environment.production"
358
- },
359
- "enableWithCredentials": {
360
- "type": "boolean",
361
- "mutable": false,
362
- "complexType": {
363
- "original": "boolean",
364
- "resolved": "boolean",
365
- "references": {}
366
- },
367
- "required": false,
368
- "optional": true,
369
- "docs": {
370
- "tags": [],
371
- "text": ""
372
- },
373
- "attribute": "enable-with-credentials",
374
- "reflect": false,
375
- "defaultValue": "false"
376
- },
377
- "themePreset": {
378
- "type": "string",
379
- "mutable": false,
380
- "complexType": {
381
- "original": "ThemePreset",
382
- "resolved": "ThemePreset.dark | ThemePreset.light",
383
- "references": {
384
- "ThemePreset": {
385
- "location": "import",
386
- "path": "./enums",
387
- "id": "src/components/zero-account/enums.ts::ThemePreset"
388
- }
389
- }
390
- },
391
- "required": false,
392
- "optional": true,
393
- "docs": {
394
- "tags": [],
395
- "text": ""
396
- },
397
- "attribute": "theme-preset",
398
- "reflect": false,
399
- "defaultValue": "ThemePreset.light"
400
- },
401
- "autoStartApp": {
402
- "type": "boolean",
403
- "mutable": false,
404
- "complexType": {
405
- "original": "boolean",
406
- "resolved": "boolean",
407
- "references": {}
408
- },
409
- "required": false,
410
- "optional": true,
411
- "docs": {
412
- "tags": [],
413
- "text": ""
414
- },
415
- "attribute": "auto-start-app",
416
- "reflect": false,
417
- "defaultValue": "true"
418
- }
419
- };
420
- }
421
- static get states() {
422
- return {
423
- "modalOpen": {},
424
- "isAnimating": {},
425
- "url": {}
426
- };
427
- }
428
- static get elementRef() { return "host"; }
429
- static get listeners() {
430
- return [{
431
- "name": "0account-toggle-modal",
432
- "method": "toggleModal",
433
- "target": "document",
434
- "capture": false,
435
- "passive": false
436
- }, {
437
- "name": "0account-close-modal",
438
- "method": "_closeModal",
439
- "target": "document",
440
- "capture": false,
441
- "passive": false
442
- }, {
443
- "name": "0account-authenticated",
444
- "method": "_closeModal",
445
- "target": "document",
446
- "capture": false,
447
- "passive": false
448
- }, {
449
- "name": "0account-open-app",
450
- "method": "openApp",
451
- "target": "document",
452
- "capture": false,
453
- "passive": false
454
- }];
455
- }
456
- }
457
- //# sourceMappingURL=zero-account.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zero-account.js","sourceRoot":"","sources":["../../../src/components/zero-account/zero-account.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9B,MAAM,oBAAoB,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,YAAY,CAAC;AACnE,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAO/B,MAAM,OAAO,WAAW;;IAmCd,cAAS,GAAG,CAAC,aAAa,GAAG,KAAK,EAAC,EAAE;MAC3C,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,EAAE,CAAA;MAClB,CAAC,CAAA;MACD,IAAI,aAAa;QAAE,OAAO,M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I,CAAC,SAAS,CAAC,CAAC;EAC1D,CAAC;EAEO,YAAY;IAClB,IAAI,CAAC,SAAS,EAAE,CAAA;IAChB,IAAI,CAAC,UAAU,EAAE,CAAA;EACnB,CAAC;EAEO,UAAU;IAChB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;EAC5E,CAAC;EAEO,SAAS;IACf,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;EAC1B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGF","sourcesContent":["import { Element, Component, h, Host, Prop, Listen, State } from '@stencil/core';\nimport { UAParser } from 'ua-parser-js';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { Environment, ErrorCorrectionLevel, ThemePreset } from './enums';\nimport { Logger } from '../../utils/utils';\nimport * as utilsURL from '../../utils/url';\nimport Logo from './logo';\nimport { WS } from './websocket';\n\nconst maxInterval = 59 * 60 * 1000;\nconst minInterval = 10 * 1000;\n\nconst DEFAULT_CALLBACK_URL = window.location.origin + '/zero/auth';\nconst ANIMATION_DURATION = 3000\n\n@Component({\n tag: 'zero-account',\n styleUrl: 'zero-account.css',\n shadow: true,\n})\nexport class ZeroAccount {\n @Prop() appId!: string;\n @Prop() updateInterval?: number = 3 * 60 * 1000;\n @Prop() callbackURL: string = DEFAULT_CALLBACK_URL;\n @Prop() modal?: boolean = true;\n @Prop() selector?: string = null;\n @Prop() level?: ErrorCorrectionLevel = ErrorCorrectionLevel.M;\n @Prop() primaryColor: string = '#3C444F';\n @Prop() secondaryColor: string;\n @Prop() instructionsText: string;\n @Prop() hideInstructions: boolean = false;\n @Prop() environment?: Environment = Environment.production;\n @Prop() enableWithCredentials?: boolean = false;\n @Prop() themePreset?: ThemePreset = ThemePreset.light;\n @Prop() autoStartApp? = true;\n\n private logger: Logger;\n private uaParser: UAParser;\n private ws: WS;\n\n private timer: number;\n private animationTimer: number;\n\n @Element() host: HTMLElement;\n private modalEl: HTMLDivElement;\n private closeButtonEl: HTMLDivElement;\n\n @State() modalOpen = false;\n @State() isAnimating = false;\n @State() url = '';\n\n private getUpdateInterval() {\n // make sure the provided value is within bounds\n return Math.min(Math.max(this.updateInterval, minInterval), maxInterval);\n }\n private refreshQR = (ignoreAnimate = false)=> {\n const update = () => {\n this.restartTimer();\n this.updateURL()\n }\n if (ignoreAnimate) return update();\n\n this.isAnimating = true\n this.animationTimer = window.setTimeout(()=>{\n update()\n this.isAnimating = false\n }, ANIMATION_DURATION)\n }\n\n @Listen('0account-toggle-modal', { target: 'document' })\n toggleModal() {\n this.modalOpen = !this.modalOpen;\n if (this.modalOpen) this.refreshQR(true)\n if ((this.modalOpen && this.autoStartApp) || this.isMobile()) this.openApp()\n }\n\n @Listen('0account-close-modal', { target: 'document' })\n @Listen('0account-authenticated', { target: 'document' })\n private _closeModal() {\n this.modalOpen = false;\n this.stopTimer()\n }\n\n private closeModal(e: MouseEvent) {\n if (e.target !== this.modalEl && e.target !== this.closeButtonEl) {\n return e.stopPropagation();\n }\n this._closeModal()\n }\n\n @Listen('0account-open-app', { target: 'document' })\n openApp() {\n if (this.modalOpen) {\n window.location.href = this.url\n }\n }\n\n render() {\n const logoColor = this.themePreset === ThemePreset.light ? '#7263FA': '#FFFFF9'\n const qrColor = this.themePreset === ThemePreset.light ? '#000': '#FFFFF9'\n return (\n <Host>\n <slot />\n {this.host.childNodes.length === 0 &&\n <button class={`button ${this.themePreset}`} onClick={()=>this.toggleModal()}>\n <Logo className='button__logo' color={logoColor} />\n use 0account\n </button>\n }\n <div\n ref={el => this.modalEl = el}\n onClick={(e) => this.closeModal(e)}\n class={`modal ${this.themePreset} ${this.isAnimating ? 'modal-animated': ''} ${this.modalOpen ? '' : 'modal--hidden'}`}>\n <div class='modal__content'>\n <div ref={el => this.closeButtonEl = el} class='modal__close-button'></div>\n <div class='modal__qrcode__container'>\n <qr-code url={this.url} class={`modal__qrcode`} level={this.level} color={qrColor}/>\n <div class='circle__overlay'>\n <div class='circle'></div>\n <div class='circle circle--medium'></div>\n <div class='circle circle--large'></div>\n </div>\n <Logo className='modal__logo' color={logoColor} />\n </div>\n <div class='modal__buttons'>\n <button onClick={()=>this.openApp()} class='modal__button'>Open the desktop app</button>\n <a href='#' class='modal__link'>Download the app</a>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n private hideOnEsc = (e) => {\n if ((e.key === 'Escape' || e.key === 'Esc')) {\n this.modalOpen = false;\n }\n };\n\n // called only once\n componentWillLoad() {\n this.logger = new Logger(this.environment);\n this.uaParser = new UAParser();\n this.ws = new WS(this.appId, {\n updateInterval: this.getUpdateInterval(),\n callbackURL: this.callbackURL,\n uaParser: this.uaParser,\n env: this.environment,\n log: this.log,\n })\n\n // make sure we initQR\n this.refreshQR(true)\n document.addEventListener('keydown', this.hideOnEsc);\n }\n\n private updateURL() {\n const expires = new Date().getTime() + this.getUpdateInterval();\n const uuid = uuidv4();\n this.ws.updateUUID(uuid);\n const params = utilsURL.appendToParams('', {\n appId: this.appId,\n uuid: uuid,\n expires: expires,\n })\n\n if (this.isMobile()) {\n this.url = 'https://launch.0account.com/auth?' + params;\n } else {\n this.url = 'zero-account://auth?' + params;\n }\n }\n\n isMobile() {\n const device = this.uaParser.getDevice()\n return device.type === 'tablet' || device.type === 'mobile'\n }\n\n connectedCallback() {\n this.startTimer()\n }\n\n disconnectedCallback() {\n this.stopTimer()\n document.removeEventListener('keydown', this.hideOnEsc);\n }\n\n private restartTimer() {\n this.stopTimer()\n this.startTimer()\n }\n\n private startTimer() {\n this.timer = window.setInterval(this.refreshQR, this.getUpdateInterval());\n }\n\n private stopTimer() {\n window.clearInterval(this.timer);\n window.clearTimeout(this.animationTimer);\n this.isAnimating = false\n }\n\n private log = (...args) => this.logger.log(...args);\n}\n"]}
@@ -1,35 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { ZeroAccount } from "./zero-account";
3
- describe('zero-account', () => {
4
- it('renders', async () => {
5
- const { root } = await newSpecPage({
6
- components: [ZeroAccount],
7
- html: '<zero-account></zero-account>',
8
- });
9
- expect(root).toEqualHtml(`
10
- <zero-account>
11
- <mock:shadow-root>
12
- <div>
13
- Hello, World! I'm
14
- </div>
15
- </mock:shadow-root>
16
- </zero-account>
17
- `);
18
- });
19
- it('renders with values', async () => {
20
- const { root } = await newSpecPage({
21
- components: [ZeroAccount],
22
- html: `<zero-account first="Stencil" last="'Don't call me a framework' JS"></zero-account>`,
23
- });
24
- expect(root).toEqualHtml(`
25
- <zero-account first="Stencil" last="'Don't call me a framework' JS">
26
- <mock:shadow-root>
27
- <div>
28
- Hello, World! I'm Stencil 'Don't call me a framework' JS
29
- </div>
30
- </mock:shadow-root>
31
- </zero-account>
32
- `);
33
- });
34
- });
35
- //# sourceMappingURL=zero-account.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zero-account.spec.js","sourceRoot":"","sources":["../../../src/components/zero-account/zero-account.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;EAC5B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;MACjC,UAAU,EAAE,CAAC,WAAW,CAAC;MACzB,IAAI,EAAE,+BAA+B;KACtC,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQxB,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;MACjC,UAAU,EAAE,CAAC,WAAW,CAAC;MACzB,IAAI,EAAE,qFAAqF;KAC5F,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQxB,CAAC,CAAC;EACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { ZeroAccount } from './zero-account';\n\ndescribe('zero-account', () => {\n it('renders', async () => {\n const { root } = await newSpecPage({\n components: [ZeroAccount],\n html: '<zero-account></zero-account>',\n });\n expect(root).toEqualHtml(`\n <zero-account>\n <mock:shadow-root>\n <div>\n Hello, World! I'm\n </div>\n </mock:shadow-root>\n </zero-account>\n `);\n });\n\n it('renders with values', async () => {\n const { root } = await newSpecPage({\n components: [ZeroAccount],\n html: `<zero-account first=\"Stencil\" last=\"'Don't call me a framework' JS\"></zero-account>`,\n });\n expect(root).toEqualHtml(`\n <zero-account first=\"Stencil\" last=\"'Don't call me a framework' JS\">\n <mock:shadow-root>\n <div>\n Hello, World! I'm Stencil 'Don't call me a framework' JS\n </div>\n </mock:shadow-root>\n </zero-account>\n `);\n });\n});\n"]}
@@ -1,2 +0,0 @@
1
- export * from './components';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './components';\n"]}
@@ -1,38 +0,0 @@
1
- const send = (url, opts, request, errorCount) => {
2
- let limit = errorCount
3
- ? Math.pow(2, errorCount - 1) * opts.startLimit
4
- : 0;
5
- limit = limit < opts.maxLimit ? limit : opts.maxLimit;
6
- const pause = Math.random() * limit;
7
- setTimeout(function () {
8
- request.open('POST', url, true);
9
- for (const k in opts.headers) {
10
- if (Object.prototype.hasOwnProperty.call(opts.headers, k)) {
11
- request.setRequestHeader(k, opts.headers[k]);
12
- }
13
- }
14
- request.send();
15
- }, pause);
16
- };
17
- const xhr = (url, opts = { startLimit: 100, maxLimit: 3 * 1000, enableWithCredentials: false }, callback) => {
18
- let errorCount = 0;
19
- const request = new XMLHttpRequest();
20
- if (opts.enableWithCredentials)
21
- request.withCredentials = true;
22
- const retry = () => send(url, opts, request, ++errorCount);
23
- request.addEventListener('error', retry);
24
- request.addEventListener('timeout', retry);
25
- request.addEventListener('load', () => {
26
- if (request.status >= 200 && request.status < 300) {
27
- return callback(request.responseText);
28
- }
29
- retry();
30
- });
31
- send(url, opts, request, errorCount);
32
- return request;
33
- };
34
- const http = {
35
- send: xhr,
36
- };
37
- export default http;
38
- //# sourceMappingURL=request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AACA,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,IAAI,EAAE,OAAuB,EAAE,UAAkB,EAAQ,EAAE;EACpF,IAAI,KAAK,GAAG,UAAU;IACpB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU;IAC/C,CAAC,CAAC,CAAC,CAAC;EACN,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,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AO,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;KACtC;IACD,KAAK,EAAE,CAAA;EACT,CAAC,CAAC,CAAA;EAEF,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;EACpC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA;AAED,MAAM,IAAI,GAAG;EACX,IAAI,EAAE,GAAG;CACV,CAAA;AACD,eAAe,IAAI,CAAC","sourcesContent":["\nconst send = (url: string, opts, request: XMLHttpRequest, errorCount: number): void => {\n let limit = errorCount\n ? Math.pow(2, errorCount - 1) * opts.startLimit\n : 0;\n limit = limit < opts.maxLimit ? limit : opts.maxLimit\n const pause = Math.random() * limit;\n setTimeout(function () {\n request.open('POST', url, true)\n for (const k in opts.headers) {\n if (Object.prototype.hasOwnProperty.call(opts.headers, k)) {\n request.setRequestHeader(k, opts.headers[k])\n }\n }\n request.send()\n }, pause)\n}\n\ntype Options = {\n startLimit?: number;\n maxLimit?: number;\n enableWithCredentials?: boolean;\n headers?: any\n}\n\nconst xhr = (url: string, opts: Options = {startLimit: 100, maxLimit: 3 * 1000, enableWithCredentials: false}, callback: (v: string) => void): XMLHttpRequest => {\n let errorCount = 0;\n const request = new XMLHttpRequest();\n if (opts.enableWithCredentials) request.withCredentials = true;\n const retry = (): void => send(url, opts, request, ++errorCount);\n request.addEventListener('error', retry);\n request.addEventListener('timeout', retry);\n request.addEventListener('load', () => {\n if (request.status >= 200 && request.status < 300) {\n return callback(request.responseText)\n }\n retry()\n })\n\n send(url, opts, request, errorCount)\n return request;\n}\n\nconst http = {\n send: xhr,\n}\nexport default http;\n"]}
@@ -1,43 +0,0 @@
1
- export function appendToParams(url, getParamsToUpdate) {
2
- if (typeof getParamsToUpdate !== "object") return false;
3
-
4
- // remove consecutive duplicate '&' chars from the url
5
- url = url.replace(/(&)\1+/g, '&')
6
- //Note: substr(1) removes first character (getting rid of possible "?")
7
- // (does nothing with empty string)
8
- let getParams = url.substr(1).split('&');
9
-
10
- //avoid extra "&" at the beginning if current document.location.search was empty or 1 char
11
- if ((getParams.length < 1) || ((getParams.length === 1) && (getParams[0] === "")))
12
- getParams = [];
13
-
14
- let searchBuffer;
15
- let found;
16
-
17
- for (let k in getParamsToUpdate) {
18
- if (!getParamsToUpdate.hasOwnProperty(k)) continue;
19
-
20
- let key = encodeURIComponent(k);
21
- let value = encodeURIComponent(getParamsToUpdate[k]);
22
-
23
- searchBuffer = [];
24
- found = false;
25
-
26
- let paramsLength = getParams.length - 1
27
- //from the end to start...
28
- for (let i = paramsLength; i >= 0; --i) {
29
- searchBuffer = getParams[i].split('=');
30
-
31
- if (searchBuffer[0] === key) {
32
- //found key!
33
- getParams[i] = key + '=' + value;
34
- found = true;
35
- break;
36
- }
37
- }
38
-
39
- if (!found) getParams.push(key + '=' + value);
40
- }
41
-
42
- return getParams.join('&');
43
- }
@@ -1,16 +0,0 @@
1
- import { Build } from "@stencil/core";
2
- export const format = (appId) => {
3
- return appId || '';
4
- };
5
- export class Logger {
6
- constructor(environment) {
7
- this.log = (...args) => {
8
- if (this.environment !== 'production' && Build.isDev) {
9
- console.clear();
10
- console.log(...args);
11
- }
12
- };
13
- this.environment = environment;
14
- }
15
- }
16
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE;EAC9C,OAAO,KAAK,IAAI,EAAE,CAAC;AACrB,CAAC,CAAA;AAED,MAAM,OAAO,MAAM;EAEjB,YAAY,WAAwB;IAGpC,QAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;MAChB,IAAI,IAAI,CAAC,WAAW,KAAK,YAAY,IAAI,KAAK,CAAC,KAAK,EAAE;QACpD,OAAO,CAAC,KAAK,EAAE,CAAA;QACf,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;OACtB;IACH,CAAC,CAAA;IAPC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;EACjC,CAAC;CAOF","sourcesContent":["import { Environment } from '../components/zero-account/enums';\nimport { Build } from '@stencil/core';\n\nexport const format = (appId: string): string => {\n return appId || '';\n}\n\nexport class Logger {\n private readonly environment: Environment;\n constructor(environment: Environment) {\n this.environment = environment;\n }\n log = (...args) => {\n if (this.environment !== 'production' && Build.isDev) {\n console.clear()\n console.log(...args);\n }\n }\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { format } from "./utils";
2
- describe('format', () => {
3
- it('returns empty string for no appId defined', () => {
4
- expect(format(undefined)).toEqual('');
5
- });
6
- it('formats appId', () => {
7
- expect(format('some-id')).toEqual('some-id');
8
- });
9
- });
10
- //# sourceMappingURL=utils.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../src/utils/utils.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;EACtB,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACnD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;EACxC,CAAC,CAAC,CAAC;EAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;IACvB,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;EAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { format } from './utils';\n\ndescribe('format', () => {\n it('returns empty string for no appId defined', () => {\n expect(format(undefined)).toEqual('');\n });\n\n it('formats appId', () => {\n expect(format('some-id')).toEqual('some-id');\n });\n});\n"]}
@@ -1,3 +0,0 @@
1
- export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"file":"index.js","mappings":"","names":[],"sources":[],"sourcesContent":[],"version":3}