@oila/0account 3.4.8 → 3.4.9

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 (95) hide show
  1. package/dist/cjs/index-ef57218a.js +1948 -0
  2. package/dist/cjs/index-ef57218a.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +4 -0
  4. package/dist/cjs/index.cjs.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +15 -0
  6. package/dist/cjs/loader.cjs.js.map +1 -0
  7. package/dist/cjs/qr-code_2.cjs.entry.js +1550 -0
  8. package/dist/cjs/qr-code_2.cjs.entry.js.map +1 -0
  9. package/dist/cjs/zero-account.cjs.js +25 -0
  10. package/dist/cjs/zero-account.cjs.js.map +1 -0
  11. package/dist/collection/collection-manifest.json +13 -0
  12. package/dist/collection/components/zero-account/enums.js +18 -0
  13. package/dist/collection/components/zero-account/enums.js.map +1 -0
  14. package/dist/collection/components/zero-account/logo.js +6 -0
  15. package/dist/collection/components/zero-account/logo.js.map +1 -0
  16. package/dist/collection/components/zero-account/qrcode.js +111 -0
  17. package/dist/collection/components/zero-account/qrcode.js.map +1 -0
  18. package/dist/collection/components/zero-account/websocket.js +176 -0
  19. package/dist/collection/components/zero-account/websocket.js.map +1 -0
  20. package/dist/collection/components/zero-account/zero-account.css +294 -0
  21. package/dist/collection/components/zero-account/zero-account.e2e.js +26 -0
  22. package/dist/collection/components/zero-account/zero-account.e2e.js.map +1 -0
  23. package/dist/collection/components/zero-account/zero-account.js +402 -0
  24. package/dist/collection/components/zero-account/zero-account.js.map +1 -0
  25. package/dist/collection/components/zero-account/zero-account.spec.js +35 -0
  26. package/dist/collection/components/zero-account/zero-account.spec.js.map +1 -0
  27. package/dist/collection/index.js +2 -0
  28. package/dist/collection/index.js.map +1 -0
  29. package/dist/{zero-account/qr-code.entry.js → collection/utils/qrcode/qrcode.js} +3 -35
  30. package/dist/collection/utils/request.js +45 -0
  31. package/dist/collection/utils/request.js.map +1 -0
  32. package/dist/collection/utils/url.js +43 -0
  33. package/dist/collection/utils/utils.js +16 -0
  34. package/dist/collection/utils/utils.js.map +1 -0
  35. package/dist/collection/utils/utils.spec.js +10 -0
  36. package/dist/collection/utils/utils.spec.js.map +1 -0
  37. package/dist/components/index.d.ts +6 -0
  38. package/dist/components/index.js +3 -0
  39. package/dist/components/index.js.map +1 -0
  40. package/dist/components/qr-code.d.ts +2 -2
  41. package/dist/components/qr-code.js +8 -0
  42. package/dist/components/qr-code.js.map +1 -0
  43. package/dist/components/qrcode.js +1073 -0
  44. package/dist/components/qrcode.js.map +1 -0
  45. package/dist/components/zero-account.d.ts +2 -2
  46. package/dist/components/zero-account.js +535 -0
  47. package/dist/components/zero-account.js.map +1 -0
  48. package/dist/esm/index-798be1d4.js +1919 -0
  49. package/dist/esm/index-798be1d4.js.map +1 -0
  50. package/dist/esm/index.js +3 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/loader.js +11 -0
  53. package/dist/esm/loader.js.map +1 -0
  54. package/dist/esm/polyfills/core-js.js +11 -0
  55. package/dist/esm/polyfills/dom.js +79 -0
  56. package/dist/esm/polyfills/es5-html-element.js +1 -0
  57. package/dist/esm/polyfills/index.js +34 -0
  58. package/dist/esm/polyfills/system.js +6 -0
  59. package/dist/esm/qr-code_2.entry.js +1545 -0
  60. package/dist/esm/qr-code_2.entry.js.map +1 -0
  61. package/dist/esm/zero-account.js +20 -0
  62. package/dist/esm/zero-account.js.map +1 -0
  63. package/dist/index.cjs.js +1 -0
  64. package/dist/index.js +1 -0
  65. package/dist/types/components/zero-account/enums.d.ts +8 -8
  66. package/dist/types/components/zero-account/logo.d.ts +2 -2
  67. package/dist/types/components/zero-account/qrcode.d.ts +5 -5
  68. package/dist/types/components/zero-account/websocket.d.ts +27 -25
  69. package/dist/types/components/zero-account/zero-account.d.ts +39 -39
  70. package/dist/types/stencil-public-runtime.d.ts +46 -5
  71. package/dist/types/utils/request.d.ts +5 -5
  72. package/dist/types/utils/utils.d.ts +3 -3
  73. package/dist/zero-account/index.esm.js +0 -1
  74. package/dist/zero-account/index.esm.js.map +1 -1
  75. package/dist/zero-account/p-3b6bbcf5.js +3 -0
  76. package/dist/zero-account/p-3b6bbcf5.js.map +1 -0
  77. package/dist/zero-account/p-b6f591cf.entry.js +2 -0
  78. package/dist/zero-account/p-b6f591cf.entry.js.map +1 -0
  79. package/dist/zero-account/zero-account.esm.js +1 -64
  80. package/dist/zero-account/zero-account.esm.js.map +1 -1
  81. package/loader/index.d.ts +1 -1
  82. package/package.json +10 -10
  83. package/dist/zero-account/app-globals-0f993ce5.js +0 -5
  84. package/dist/zero-account/app-globals-0f993ce5.js.map +0 -1
  85. package/dist/zero-account/enums-816340c2.js +0 -21
  86. package/dist/zero-account/enums-816340c2.js.map +0 -1
  87. package/dist/zero-account/enums-e7827156.js +0 -21
  88. package/dist/zero-account/enums-e7827156.js.map +0 -1
  89. package/dist/zero-account/index-57856b47.js +0 -3380
  90. package/dist/zero-account/index-57856b47.js.map +0 -1
  91. package/dist/zero-account/qr-code.entry.js.map +0 -1
  92. package/dist/zero-account/shadow-css-8a6ccf47.js +0 -389
  93. package/dist/zero-account/shadow-css-8a6ccf47.js.map +0 -1
  94. package/dist/zero-account/zero-account.entry.js +0 -1994
  95. package/dist/zero-account/zero-account.entry.js.map +0 -1
@@ -0,0 +1,402 @@
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.level = ErrorCorrectionLevel.M;
39
+ this.primaryColor = '#3C444F';
40
+ this.secondaryColor = undefined;
41
+ this.environment = Environment.production;
42
+ this.enableWithCredentials = false;
43
+ this.themePreset = ThemePreset.light;
44
+ this.autoStartApp = true;
45
+ this.modalOpen = false;
46
+ this.isAnimating = false;
47
+ this.url = '';
48
+ }
49
+ getUpdateInterval() {
50
+ // make sure the provided value is within bounds
51
+ return Math.min(Math.max(this.updateInterval, minInterval), maxInterval);
52
+ }
53
+ toggleModal() {
54
+ this.modalOpen = !this.modalOpen;
55
+ if (this.modalOpen)
56
+ this.refreshQR(true);
57
+ if ((this.modalOpen && this.autoStartApp) || this.isMobile())
58
+ this.openApp();
59
+ }
60
+ _closeModal() {
61
+ this.modalOpen = false;
62
+ this.stopTimer();
63
+ }
64
+ closeModal(e) {
65
+ if (e.target !== this.modalEl && e.target !== this.closeButtonEl) {
66
+ return e.stopPropagation();
67
+ }
68
+ this._closeModal();
69
+ }
70
+ openApp() {
71
+ if (this.modalOpen) {
72
+ window.location.href = this.url;
73
+ }
74
+ }
75
+ render() {
76
+ const logoColor = this.themePreset === ThemePreset.light ? '#7263FA' : '#FFFFF9';
77
+ const qrColor = '#000';
78
+ return (h(Host, { key: '1dc3610232166249e09861006f22ad43a58d208d' }, h("slot", { key: '5c510d06b9423a2540e494c57eebda16ac2f3fe6' }), this.host.childNodes.length === 0 &&
79
+ h("button", { class: `button ${this.themePreset}`, onClick: () => this.toggleModal() }, h(Logo, { className: 'button__logo', color: logoColor }), "use 0account"), h("div", { key: '1ccab237f88fe77eb22f0c0b82b9612b536a6eb2', ref: el => this.modalEl = el, onClick: (e) => this.closeModal(e), class: `modal ${this.themePreset} ${this.isAnimating ? 'modal-animated' : ''} ${this.modalOpen ? '' : 'modal--hidden'}` }, h("div", { key: 'cca5693c98f2dbf7aa5584e62862e90783c24bdb', class: 'modal__content' }, h("div", { key: 'fa239e9bb2f618a7d0067c74d6c599f1482aa0ce', ref: el => this.closeButtonEl = el, class: 'modal__close-button' }), h("div", { key: '3d8e206fbbb7a45f0b634fc1ac5cda0a3434d6d9', class: 'modal__qrcode__container' }, h("qr-code", { key: 'a2f7f00f7926c7994c79098b4f386e4e60f16bc4', url: this.url, class: `modal__qrcode`, level: this.level, color: qrColor }), h("div", { key: '5819116a32e44341a408b79d5ed48a31c0be17d9', class: 'circle__overlay' }, h("div", { key: '67220c1757145e3263fdf8b265730a9b50628034', class: 'circle' }), h("div", { key: '2d43067a7a3e0fad60670a92f026925b7b2141f0', class: 'circle circle--medium' }), h("div", { key: 'c6cc6df2fcfd06b895e185f5b818150ea031c15e', class: 'circle circle--large' })), h(Logo, { key: '1e5b5f9687d0629cacd3c2524bb271824c03f102', className: 'modal__logo', color: logoColor })), h("div", { key: '13e998689e3b8942c39f94c8d67b1d6908ea63de', class: 'modal__buttons' }, h("button", { key: '879631b5e37bd0b9f440023edbef542d3628142c', onClick: () => this.openApp(), class: 'modal__button' }, "Open the desktop app"), h("a", { key: '3be4413c520f42982546535badf4aa133a25ee78', href: 'https://0account.com/downloads', class: 'modal__link' }, "Download the app"))))));
80
+ }
81
+ // called only once
82
+ componentWillLoad() {
83
+ this.logger = new Logger(this.environment);
84
+ this.uaParser = new UAParser();
85
+ this.ws = new WS(this.appId, {
86
+ updateInterval: this.getUpdateInterval(),
87
+ enableWithCredentials: this.enableWithCredentials,
88
+ callbackURL: this.callbackURL,
89
+ uaParser: this.uaParser,
90
+ env: this.environment,
91
+ log: this.log,
92
+ });
93
+ // make sure we initQR
94
+ this.refreshQR(true);
95
+ document.addEventListener('keydown', this.hideOnEsc);
96
+ }
97
+ updateURL() {
98
+ const expires = new Date().getTime() + this.getUpdateInterval();
99
+ const uuid = uuidv4();
100
+ this.ws.updateUUID(uuid);
101
+ const params = utilsURL.appendToParams('', {
102
+ appId: this.appId,
103
+ uuid: uuid,
104
+ expires: expires,
105
+ });
106
+ if (this.isMobile()) {
107
+ this.url = 'https://launch.0account.com/auth?' + params;
108
+ }
109
+ else {
110
+ this.url = 'zero-account://auth?' + params;
111
+ }
112
+ }
113
+ isMobile() {
114
+ const device = this.uaParser.getDevice();
115
+ return device.type === 'tablet' || device.type === 'mobile';
116
+ }
117
+ connectedCallback() {
118
+ this.startTimer();
119
+ }
120
+ disconnectedCallback() {
121
+ this.stopTimer();
122
+ document.removeEventListener('keydown', this.hideOnEsc);
123
+ }
124
+ restartTimer() {
125
+ this.stopTimer();
126
+ this.startTimer();
127
+ }
128
+ startTimer() {
129
+ this.timer = window.setInterval(this.refreshQR, this.getUpdateInterval());
130
+ }
131
+ stopTimer() {
132
+ window.clearInterval(this.timer);
133
+ window.clearTimeout(this.animationTimer);
134
+ this.isAnimating = false;
135
+ }
136
+ static get is() { return "zero-account"; }
137
+ static get encapsulation() { return "shadow"; }
138
+ static get originalStyleUrls() {
139
+ return {
140
+ "$": ["zero-account.css"]
141
+ };
142
+ }
143
+ static get styleUrls() {
144
+ return {
145
+ "$": ["zero-account.css"]
146
+ };
147
+ }
148
+ static get properties() {
149
+ return {
150
+ "appId": {
151
+ "type": "string",
152
+ "mutable": false,
153
+ "complexType": {
154
+ "original": "string",
155
+ "resolved": "string",
156
+ "references": {}
157
+ },
158
+ "required": true,
159
+ "optional": false,
160
+ "docs": {
161
+ "tags": [],
162
+ "text": ""
163
+ },
164
+ "attribute": "app-id",
165
+ "reflect": false
166
+ },
167
+ "updateInterval": {
168
+ "type": "number",
169
+ "mutable": false,
170
+ "complexType": {
171
+ "original": "number",
172
+ "resolved": "number",
173
+ "references": {}
174
+ },
175
+ "required": false,
176
+ "optional": true,
177
+ "docs": {
178
+ "tags": [],
179
+ "text": ""
180
+ },
181
+ "attribute": "update-interval",
182
+ "reflect": false,
183
+ "defaultValue": "3 * 60 * 1000"
184
+ },
185
+ "callbackURL": {
186
+ "type": "string",
187
+ "mutable": false,
188
+ "complexType": {
189
+ "original": "string",
190
+ "resolved": "string",
191
+ "references": {}
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": ""
198
+ },
199
+ "attribute": "callback-url",
200
+ "reflect": false,
201
+ "defaultValue": "DEFAULT_CALLBACK_URL"
202
+ },
203
+ "modal": {
204
+ "type": "boolean",
205
+ "mutable": false,
206
+ "complexType": {
207
+ "original": "boolean",
208
+ "resolved": "boolean",
209
+ "references": {}
210
+ },
211
+ "required": false,
212
+ "optional": true,
213
+ "docs": {
214
+ "tags": [],
215
+ "text": ""
216
+ },
217
+ "attribute": "modal",
218
+ "reflect": false,
219
+ "defaultValue": "true"
220
+ },
221
+ "level": {
222
+ "type": "string",
223
+ "mutable": false,
224
+ "complexType": {
225
+ "original": "ErrorCorrectionLevel",
226
+ "resolved": "ErrorCorrectionLevel.H | ErrorCorrectionLevel.L | ErrorCorrectionLevel.M | ErrorCorrectionLevel.Q",
227
+ "references": {
228
+ "ErrorCorrectionLevel": {
229
+ "location": "import",
230
+ "path": "./enums",
231
+ "id": "src/components/zero-account/enums.ts::ErrorCorrectionLevel"
232
+ }
233
+ }
234
+ },
235
+ "required": false,
236
+ "optional": true,
237
+ "docs": {
238
+ "tags": [],
239
+ "text": ""
240
+ },
241
+ "attribute": "level",
242
+ "reflect": false,
243
+ "defaultValue": "ErrorCorrectionLevel.M"
244
+ },
245
+ "primaryColor": {
246
+ "type": "string",
247
+ "mutable": false,
248
+ "complexType": {
249
+ "original": "string",
250
+ "resolved": "string",
251
+ "references": {}
252
+ },
253
+ "required": false,
254
+ "optional": false,
255
+ "docs": {
256
+ "tags": [],
257
+ "text": ""
258
+ },
259
+ "attribute": "primary-color",
260
+ "reflect": false,
261
+ "defaultValue": "'#3C444F'"
262
+ },
263
+ "secondaryColor": {
264
+ "type": "string",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "string",
268
+ "resolved": "string",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": ""
276
+ },
277
+ "attribute": "secondary-color",
278
+ "reflect": false
279
+ },
280
+ "environment": {
281
+ "type": "string",
282
+ "mutable": false,
283
+ "complexType": {
284
+ "original": "Environment",
285
+ "resolved": "Environment.production | Environment.staging",
286
+ "references": {
287
+ "Environment": {
288
+ "location": "import",
289
+ "path": "./enums",
290
+ "id": "src/components/zero-account/enums.ts::Environment"
291
+ }
292
+ }
293
+ },
294
+ "required": false,
295
+ "optional": true,
296
+ "docs": {
297
+ "tags": [],
298
+ "text": ""
299
+ },
300
+ "attribute": "environment",
301
+ "reflect": false,
302
+ "defaultValue": "Environment.production"
303
+ },
304
+ "enableWithCredentials": {
305
+ "type": "boolean",
306
+ "mutable": false,
307
+ "complexType": {
308
+ "original": "boolean",
309
+ "resolved": "boolean",
310
+ "references": {}
311
+ },
312
+ "required": false,
313
+ "optional": true,
314
+ "docs": {
315
+ "tags": [],
316
+ "text": ""
317
+ },
318
+ "attribute": "enable-with-credentials",
319
+ "reflect": false,
320
+ "defaultValue": "false"
321
+ },
322
+ "themePreset": {
323
+ "type": "string",
324
+ "mutable": false,
325
+ "complexType": {
326
+ "original": "ThemePreset",
327
+ "resolved": "ThemePreset.dark | ThemePreset.light",
328
+ "references": {
329
+ "ThemePreset": {
330
+ "location": "import",
331
+ "path": "./enums",
332
+ "id": "src/components/zero-account/enums.ts::ThemePreset"
333
+ }
334
+ }
335
+ },
336
+ "required": false,
337
+ "optional": true,
338
+ "docs": {
339
+ "tags": [],
340
+ "text": ""
341
+ },
342
+ "attribute": "theme-preset",
343
+ "reflect": false,
344
+ "defaultValue": "ThemePreset.light"
345
+ },
346
+ "autoStartApp": {
347
+ "type": "boolean",
348
+ "mutable": false,
349
+ "complexType": {
350
+ "original": "boolean",
351
+ "resolved": "boolean",
352
+ "references": {}
353
+ },
354
+ "required": false,
355
+ "optional": true,
356
+ "docs": {
357
+ "tags": [],
358
+ "text": ""
359
+ },
360
+ "attribute": "auto-start-app",
361
+ "reflect": false,
362
+ "defaultValue": "true"
363
+ }
364
+ };
365
+ }
366
+ static get states() {
367
+ return {
368
+ "modalOpen": {},
369
+ "isAnimating": {},
370
+ "url": {}
371
+ };
372
+ }
373
+ static get elementRef() { return "host"; }
374
+ static get listeners() {
375
+ return [{
376
+ "name": "0account-toggle-modal",
377
+ "method": "toggleModal",
378
+ "target": "document",
379
+ "capture": false,
380
+ "passive": false
381
+ }, {
382
+ "name": "0account-close-modal",
383
+ "method": "_closeModal",
384
+ "target": "document",
385
+ "capture": false,
386
+ "passive": false
387
+ }, {
388
+ "name": "0account-authenticated",
389
+ "method": "_closeModal",
390
+ "target": "document",
391
+ "capture": false,
392
+ "passive": false
393
+ }, {
394
+ "name": "0account-open-app",
395
+ "method": "openApp",
396
+ "target": "document",
397
+ "capture": false,
398
+ "passive": false
399
+ }];
400
+ }
401
+ }
402
+ //# sourceMappingURL=zero-account.js.map
@@ -0,0 +1 @@
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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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({attribute: 'callback-url'}) callbackURL: string = DEFAULT_CALLBACK_URL;\n @Prop() modal?: boolean = true;\n @Prop() level?: ErrorCorrectionLevel = ErrorCorrectionLevel.M;\n @Prop() primaryColor: string = '#3C444F';\n @Prop() secondaryColor: string;\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 = '#000'\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='https://0account.com/downloads' 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 enableWithCredentials: this.enableWithCredentials,\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"]}
@@ -0,0 +1,35 @@
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
@@ -0,0 +1 @@
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;IAC5B,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;YACjC,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,+BAA+B;SACtC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;YACjC,UAAU,EAAE,CAAC,WAAW,CAAC;YACzB,IAAI,EAAE,qFAAqF;SAC5F,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;;;KAQxB,CAAC,CAAC;IACL,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"]}
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC","sourcesContent":["export * from './components';\n"]}
@@ -1,6 +1,3 @@
1
- import { r as registerInstance, h } from './index-57856b47.js';
2
- import { a as ErrorCorrectionLevel } from './enums-e7827156.js';
3
-
4
1
  /*
5
2
  * QR Code generator library (JavaScript)
6
3
  *
@@ -167,7 +164,7 @@ var qrcodegen = new function() {
167
164
 
168
165
  this.circlePath = function(cx, cy, r){
169
166
  return 'M '+cx+' '+cy+' m -'+r+', 0 a '+r+','+r+' 0 1,0 '+(r*2)+',0 a '+r+','+r+' 0 1,0 -'+(r*2)+',0';
170
- };
167
+ }
171
168
 
172
169
  this.svgObject = function(round) {
173
170
  var parts = [];
@@ -175,7 +172,7 @@ var qrcodegen = new function() {
175
172
  for (var x = 0; x < size; x++) {
176
173
  if (this.getModule(x, y)){
177
174
  if (round) {
178
- parts.push(this.circlePath(x+0.5,y+0.5, 0.5));
175
+ parts.push(this.circlePath(x+0.5,y+0.5, 0.5))
179
176
  } else {
180
177
  parts.push("M" + x + "," + y + "h1v1h-1z");
181
178
  }
@@ -1007,33 +1004,4 @@ var qrcodegen = new function() {
1007
1004
 
1008
1005
  };
1009
1006
 
1010
- const QRC = qrcodegen.QrCode;
1011
- const QRCode = class {
1012
- constructor(hostRef) {
1013
- registerInstance(this, hostRef);
1014
- this.url = undefined;
1015
- this.level = ErrorCorrectionLevel.M;
1016
- this.class = '';
1017
- this.color = 'black';
1018
- }
1019
- render() {
1020
- const getEcc = (ecc) => {
1021
- ecc = ecc.toUpperCase();
1022
- if (ecc === 'L')
1023
- return QRC.Ecc.LOW;
1024
- if (ecc === 'M')
1025
- return QRC.Ecc.MEDIUM;
1026
- if (ecc === 'Q')
1027
- return QRC.Ecc.QUARTILE;
1028
- return QRC.Ecc.HIGH;
1029
- };
1030
- const ecc = getEcc(this.level);
1031
- const qr = QRC.encodeText(this.url, ecc);
1032
- const qrcode = qr.svgObject();
1033
- return (h("svg", { class: this.class, viewBox: `0 0 ${qrcode.size} ${qrcode.size}` }, h("path", { d: qrcode.path, fill: this.color })));
1034
- }
1035
- };
1036
-
1037
- export { QRCode as qr_code };
1038
-
1039
- //# sourceMappingURL=qr-code.entry.js.map
1007
+ export default qrcodegen
@@ -0,0 +1,45 @@
1
+ const maxRetries = 30;
2
+ const send = (url, opts, request, errorCount) => {
3
+ if (errorCount >= maxRetries) {
4
+ request.abort();
5
+ request = null;
6
+ return;
7
+ }
8
+ let limit = errorCount
9
+ ? Math.pow(2, errorCount - 1) * opts.startLimit
10
+ : 0;
11
+ limit = limit < opts.maxLimit ? limit : opts.maxLimit;
12
+ const pause = Math.random() * limit;
13
+ setTimeout(function () {
14
+ request.open('POST', url, true);
15
+ for (const k in opts.headers) {
16
+ if (Object.prototype.hasOwnProperty.call(opts.headers, k)) {
17
+ request.setRequestHeader(k, opts.headers[k]);
18
+ }
19
+ }
20
+ request.send();
21
+ }, pause);
22
+ };
23
+ const xhr = (url, opts, callback) => {
24
+ opts = Object.assign({ startLimit: 100, maxLimit: 3 * 1000, enableWithCredentials: false }, opts);
25
+ let errorCount = 0;
26
+ const request = new XMLHttpRequest();
27
+ if (opts.enableWithCredentials)
28
+ request.withCredentials = true;
29
+ const retry = () => send(url, opts, request, ++errorCount);
30
+ request.addEventListener('error', retry);
31
+ request.addEventListener('timeout', retry);
32
+ request.addEventListener('load', () => {
33
+ if (request.status >= 200 && request.status < 300) {
34
+ return callback(request.responseText);
35
+ }
36
+ retry();
37
+ });
38
+ send(url, opts, request, errorCount);
39
+ return request;
40
+ };
41
+ const http = {
42
+ send: xhr,
43
+ };
44
+ export default http;
45
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,GAAG,EAAE,CAAA;AACrB,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,IAAa,EAAE,OAAuB,EAAE,UAAkB,EAAQ,EAAE;IAC7F,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,GAAG,IAAI,CAAA;QACd,OAAM;IACR,CAAC;IACD,IAAI,KAAK,GAAG,UAAU;QACpB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU;QAC/C,CAAC,CAAC,CAAC,CAAC;IACN,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAA;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;IACpC,UAAU,CAAC;QACT,OAAO,CAAC,IAAI,CAAC,MAAM,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KAAK,EAAE,CAAA;IACT,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA;AAED,MAAM,IAAI,GAAG;IACX,IAAI,EAAE,GAAG;CACV,CAAA;AACD,eAAe,IAAI,CAAC","sourcesContent":["\nconst maxRetries = 30\nconst send = (url: string, opts: Options, request: XMLHttpRequest, errorCount: number): void => {\n if (errorCount >= maxRetries) {\n request.abort();\n request = null\n return\n }\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, callback: (v: string) => void): XMLHttpRequest => {\n opts = {startLimit: 100, maxLimit: 3 * 1000, enableWithCredentials: false, ...opts};\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"]}
@@ -0,0 +1,43 @@
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
+ }
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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;IAC9C,OAAO,KAAK,IAAI,EAAE,CAAC;AACrB,CAAC,CAAA;AAED,MAAM,OAAO,MAAM;IAEjB,YAAY,WAAwB;QAGpC,QAAG,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE;YAChB,IAAI,IAAI,CAAC,WAAW,KAAK,YAAY,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBACrD,OAAO,CAAC,KAAK,EAAE,CAAA;gBACf,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC,CAAA;QAPC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,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"]}