@everymatrix/general-player-sms-verification-form 1.0.15 → 1.0.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.html DELETED
@@ -1,37 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset='utf-8'>
5
- <meta name='viewport' content='width=device-width,initial-scale=1'>
6
-
7
- <title>
8
- general-player-sms-verification-form
9
- </title>
10
- <link rel="stylesheet" href="public/reset.css">
11
- <script src='dist/general-player-sms-verification-form.js'></script>
12
- </head>
13
-
14
- <body>
15
- <style>
16
- html,body { margin: 0; padding: 0; height: 100%; font-family: "Helvetica Neue", "Helvetica", sans-serif; }
17
- .header { display: flex; justify-content: center; align-items: center; padding: 10px 20px; margin-bottom: 20px; background: #42a3e2; box-shadow: 3px 4px 5px 0px rgba(0,0,0, .2); }
18
- .header__logo svg { height: 50px; width: 50px; margin-right: 5px; }
19
- .header__name { color: #fff; }
20
- .header__name span { margin-right: 10px; font-weight: bold; }
21
- .webcomponent { padding: 10px 20px; }
22
- </style>
23
- <header class="header">
24
- <div class="header__logo">
25
- <svg xmlns="http://www.w3.org/2000/svg" width="161" height="132" viewBox="0 0 161 132"><defs><linearGradient x1="0%" y1="50%" y2="50%" id="a"><stop stop-color="#2A3B8F" offset="0%"/><stop stop-color="#29ABE2" offset="100%"/></linearGradient><linearGradient x1="100%" y1="50%" x2="0%" y2="50%" id="c"><stop stop-color="#B4D44E" offset="0%"/><stop stop-color="#E7F716" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path fill="#166DA5" d="M160.6 65.9l-17.4 29.3-24.4-29.7 24.4-28.9z"/><path fill="#8FDB69" d="M141.3 100.2l-26.5-31.7-15.9 26.6 24.7 36.1z"/><path fill="#166DA5" d="M141 31.4l-26.2 31.8-15.9-26.6L123.6.9z"/><path fill="url(#a)" opacity=".95" d="M61.1 31.4H141L123.4.7H78.7z M114.8 63.3H159l-15.9-26.8H98.8"/><path fill="url(#c)" opacity=".95" d="M141.3 100.3H61l17.6 30.5h45z M114.8 68.4H159l-15.9 26.8H98.8"/><path fill="#010101" d="M78.6 130.8L41 65.8 79.1.8H37.9L.4 65.8l37.5 65z"/></g></svg>
26
- </div>
27
- <h1 class="header__name">
28
- <span>WEBCOMPONENT:</span> general-player-sms-verification-form
29
- </h1>
30
- </header>
31
-
32
- <div class="webcomponent">
33
- <general-player-sms-verification-form></general-player-sms-verification-form>
34
- </div>
35
-
36
- </body>
37
- </html>
package/index.js DELETED
@@ -1 +0,0 @@
1
- import './dist/general-player-sms-verification-form.js';
Binary file
package/public/reset.css DELETED
@@ -1,48 +0,0 @@
1
- /* http://meyerweb.com/eric/tools/css/reset/
2
- v2.0 | 20110126
3
- License: none (public domain)
4
- */
5
-
6
- html, body, div, span, applet, object, iframe,
7
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8
- a, abbr, acronym, address, big, cite, code,
9
- del, dfn, em, img, ins, kbd, q, s, samp,
10
- small, strike, strong, sub, sup, tt, var,
11
- b, u, i, center,
12
- dl, dt, dd, ol, ul, li,
13
- fieldset, form, label, legend,
14
- table, caption, tbody, tfoot, thead, tr, th, td,
15
- article, aside, canvas, details, embed,
16
- figure, figcaption, footer, header, hgroup,
17
- menu, nav, output, ruby, section, summary,
18
- time, mark, audio, video {
19
- margin: 0;
20
- padding: 0;
21
- border: 0;
22
- font-size: 100%;
23
- font: inherit;
24
- vertical-align: baseline;
25
- }
26
- /* HTML5 display-role reset for older browsers */
27
- article, aside, details, figcaption, figure,
28
- footer, header, hgroup, menu, nav, section {
29
- display: block;
30
- }
31
- body {
32
- line-height: 1;
33
- }
34
- ol, ul {
35
- list-style: none;
36
- }
37
- blockquote, q {
38
- quotes: none;
39
- }
40
- blockquote:before, blockquote:after,
41
- q:before, q:after {
42
- content: '';
43
- content: none;
44
- }
45
- table {
46
- border-collapse: collapse;
47
- border-spacing: 0;
48
- }
package/rollup.config.js DELETED
@@ -1,59 +0,0 @@
1
- import svelte from 'rollup-plugin-svelte';
2
- import commonjs from '@rollup/plugin-commonjs';
3
- import resolve from '@rollup/plugin-node-resolve';
4
- import serve from 'rollup-plugin-dev-server';
5
- import livereload from 'rollup-plugin-livereload';
6
- import { terser } from 'rollup-plugin-terser';
7
- import sveltePreprocess from 'svelte-preprocess';
8
- import typescript from '@rollup/plugin-typescript';
9
- const production = process.env.NODE_ENV === 'production';
10
- const dev = process.env.NODE_ENV === 'development';
11
-
12
- export default {
13
- input: 'src/index.ts',
14
- output: {
15
- sourcemap: true,
16
- format: 'umd',
17
- name: 'app',
18
- file: 'dist/general-player-sms-verification-form.js'
19
- },
20
- plugins: [
21
- svelte({
22
- preprocess: sveltePreprocess(),
23
- compilerOptions: {
24
- // enable run-time checks when not in production
25
- customElement: true,
26
- dev: !production
27
- }
28
- }),
29
- commonjs(),
30
- resolve({
31
- browser: true,
32
- dedupe: ['svelte']
33
- }),
34
- dev && serve({
35
- open: true,
36
- verbose: true,
37
- allowCrossOrigin: true,
38
- historyApiFallback: false,
39
- host: 'localhost',
40
- port: 5052,
41
- }),
42
- dev && livereload({ watch: ['', 'dist'] }),
43
- typescript({
44
- sourceMap: !production,
45
- inlineSources: !production,
46
- }),
47
- // If we're building for production (npm run build
48
- // instead of npm run dev), minify
49
- production &&
50
- terser({
51
- output: {
52
- comments: "all"
53
- },
54
- })
55
- ],
56
- watch: {
57
- clearScreen: false
58
- }
59
- };
@@ -1,253 +0,0 @@
1
- <svelte:options tag={null} />
2
-
3
- <script lang="ts">
4
- import { onMount } from "svelte";
5
- import { _, addNewMessages, setLocale, setupI18n } from './i18n';
6
- import { SmsVerificationTranslations } from './translations';
7
-
8
- export let endpoint:string = '';
9
- export let tokenid:string = '';
10
- export let playerid:string = '';
11
- export let smstemplate:string = 'Please use this code {0} to activate your accout';
12
- export let number:string = '';
13
- export let translationUrl:string = '';
14
-
15
- let smsCode: number;
16
- let isSmsValid: boolean = true;
17
- let smsSendApiFailed:boolean = false;
18
- let secondsLeft:number = 60;
19
- let timer:any;
20
-
21
- setupI18n({ withLocale: 'en', translations: {}});
22
-
23
- const setTranslationUrl = ():void => {
24
- let url:string = translationUrl;
25
-
26
- fetch(url).then((res:any) => res.json())
27
- .then((res) => {
28
- Object.keys(res).forEach((item:any):void => {
29
- addNewMessages(item, res[item]);
30
- });
31
- }).catch((err:any) => {
32
- console.log(err);
33
- });
34
- }
35
-
36
- Object.keys(SmsVerificationTranslations).forEach((item:any) => {
37
- addNewMessages(item, SmsVerificationTranslations[item]);
38
- });
39
-
40
- const activateUser = async ():Promise<any> => {
41
- try {
42
- const res = await fetch(`${endpoint}/player/${playerid}/activateSMS?tokenId=${tokenid}&validationCode=${smsCode}`, {
43
- headers: {
44
- 'Content-Type': 'application/json',
45
- accept: 'application/json'
46
- }
47
- });
48
-
49
- if (res.ok) {
50
- isSmsValid = true;
51
- window.postMessage({ type: "SmsHasBeenValidated" }, window.location.href);
52
- } else {
53
- window.postMessage({ type: 'WidgetNotification', data: {
54
- type: 'error',
55
- message: "Could not activate user"
56
- }}, window.location.href);
57
- isSmsValid = false;
58
- throw new Error('Could not activate user');
59
- }
60
- } catch (err) {
61
- window.postMessage({ type: 'WidgetNotification', data: {
62
- type: 'error',
63
- message: "Could not activate user"
64
- }}, window.location.href);
65
- isSmsValid = false;
66
- console.log(err);
67
- }
68
- }
69
-
70
- const resendCode = async () => {
71
- try {
72
- const res = await fetch(`${endpoint}/player/sms/token`,{
73
- method: 'POST',
74
- headers: {
75
- 'Content-Type': 'application/json',
76
- accept: 'application/json',
77
- },
78
- body: JSON.stringify(
79
- {
80
- userId: playerid,
81
- messageTemplate: smstemplate,
82
- destination: number,
83
- }
84
- ),
85
- });
86
-
87
- const data = await res.json();
88
-
89
- if(res.ok) {
90
- tokenid = data.id;
91
- smsSendApiFailed = false;
92
- timer = setInterval(() => {
93
- timerCountdown();
94
- }, 1000);
95
- } else {
96
- smsSendApiFailed = true;
97
- throw new Error("Failed to fetch");
98
- }
99
- } catch(err) {
100
- smsSendApiFailed = true;
101
- console.error(err);
102
- }
103
- }
104
-
105
- const timerCountdown = () => {
106
- if (secondsLeft > 0 ) {
107
- secondsLeft--;
108
- } else {
109
- clearInterval(timer);
110
- timer = false;
111
- secondsLeft = 60;
112
- }
113
- }
114
-
115
- $: tokenid && playerid && endpoint;
116
- $: translationUrl && setTranslationUrl();
117
- </script>
118
-
119
-
120
- <div class="Container SmsVerificationContainer" part="SmsVerificationContainer">
121
- <h3 class="Title" part="Title">
122
- {#if isSmsValid}
123
- {$_('smsVerification.title')}
124
- {:else}
125
- {$_('smsVerification.errorTitle')}
126
- {/if}
127
- </h3>
128
-
129
- <div class="Field SmsVerificationField {!isSmsValid ? 'InvalidField' : ''}" part="SmsVerificationField {!isSmsValid ? 'InvalidField' : ''}">
130
- <label for="SmsCode">
131
- {$_('smsVerification.code')}:<span class="FormRequired" part="FormRequired">*</span>
132
- </label>
133
- <input bind:value={smsCode} type="number" id="SmsCode" />
134
-
135
- {#if !isSmsValid}
136
- <p class="InvalidInput" part="InvalidInput">{$_('smsVerification.smsCodeError')}</p>
137
- {/if}
138
- </div>
139
-
140
- {#if timer}
141
- <p class="SmsVerificationResendMessage" part="SmsVerificationResendMessage">{$_('smsVerification.resendMessage')}</p>
142
- {/if}
143
-
144
- <button
145
- class="Button SmsVerificationValidate"
146
- part="SmsVerificationValidate"
147
- on:click={activateUser}>
148
- {$_('smsVerification.activate')}
149
- </button>
150
- <button
151
- class="Button SmsVerificationResend"
152
- part="SmsVerificationResend"
153
- on:click={resendCode}
154
- disabled={timer}>
155
- {$_('smsVerification.resend')} {#if timer}<span class="SmsVerificationResendTimer">(0:{secondsLeft < 10 ? '0' : ''}{secondsLeft})</span>{/if}
156
- </button>
157
- </div>
158
-
159
-
160
- <style lang="scss">
161
- :host {
162
- font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
163
- }
164
-
165
- *,
166
- *::before,
167
- *::after {
168
- margin: 0;
169
- padding: 0;
170
- list-style: none;
171
- text-decoration: none;
172
- outline: none;
173
- box-sizing: border-box;
174
- }
175
-
176
- .Title {
177
- font-size: 14px;
178
- margin: 0;
179
- padding-bottom: 20px;
180
- }
181
-
182
- .Field {
183
- color: var(--emfe-w-color-gray-300, #58586B);
184
- display: flex;
185
- flex-direction: column;
186
- padding-bottom: 30px;
187
- position: relative;
188
-
189
- label {
190
- font-size: 14px;
191
- font-weight: 300;
192
- padding-bottom: 5px;
193
- }
194
-
195
- input, select {
196
- width: 100%;
197
- height: 44px;
198
- border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
199
- border-radius: 5px;
200
- box-sizing: border-box;
201
- padding: 5px 15px;
202
- font-size: 16px;
203
- line-height: 18px;
204
- }
205
-
206
- &.InvalidField {
207
- input {
208
- border: 1px solid var(--emfe-w-color-primary, #D0046C);
209
- background: var(--emfe-w-color-primary-50, #FBECF4);
210
- color: var(--emfe-w-color-primary, #D0046C);
211
- }
212
- }
213
-
214
- &.Hidden {
215
- display: none;
216
- }
217
- }
218
-
219
- .InvalidInput {
220
- color: var(--emfe-w-color-error, #FD2839);
221
- font-size: 10px;
222
- line-height: 10px;
223
- }
224
-
225
- .ErrorMessage {
226
- margin: 0 0 15px 0;
227
- font-size: 12px;
228
- color: var(--emfe-w-color-error, #FD2839);
229
- }
230
-
231
- .Button {
232
- color: var(--emfe-w-color-white, #FFFFFF);
233
- background: var(--emfe-w-color-primary, #D0046C);
234
- border: 1px solid var(--emfe-w-color-primary, #D0046C);
235
- border-radius: 5px;
236
- width: 100%;
237
- height: 60px;
238
- padding: 0;
239
- text-transform: uppercase;
240
- font-size: 18px;
241
- cursor: pointer;
242
- margin-top: 24px;
243
- &[disabled] {
244
- background: var(--emfe-w-color-gray-100, #E6E6E6);
245
- border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
246
- cursor: not-allowed;
247
- }
248
- &.SmsVerificationResend {
249
- background: var(--emfe-w-color-gray-50, #F9F8F8);
250
- color: var(--emfe-w-color-black, #000000);
251
- }
252
- }
253
- </style>
package/src/i18n.js DELETED
@@ -1,27 +0,0 @@
1
- import {
2
- dictionary,
3
- locale,
4
- addMessages,
5
- _
6
- } from 'svelte-i18n';
7
-
8
- function setupI18n({ withLocale: _locale, translations }) {
9
- locale.subscribe((data) => {
10
- if (data == null) {
11
- dictionary.set(translations);
12
- locale.set(_locale);
13
- }
14
- }); // maybe we will need this to make sure that the i18n is set up only once
15
- /*dictionary.set(translations);
16
- locale.set(_locale);*/
17
- }
18
-
19
- function addNewMessages(lang, dict) {
20
- addMessages(lang, dict);
21
- }
22
-
23
- function setLocale(_locale) {
24
- locale.set(_locale);
25
- }
26
-
27
- export { _, setupI18n, addNewMessages, setLocale };
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import GeneralPlayerSmsVerificationForm from './GeneralPlayerSmsVerificationForm.svelte';
2
-
3
- !customElements.get('general-player-sms-verification-form') && customElements.define('general-player-sms-verification-form', GeneralPlayerSmsVerificationForm);
4
- export default GeneralPlayerSmsVerificationForm;
@@ -1,79 +0,0 @@
1
- export const SmsVerificationTranslations = {
2
- en: {
3
- smsVerification: {
4
- title: 'Please enter the verification code you received on your number',
5
- errorTitle: 'Your code was invalid, you can resend the code and try again',
6
- code: 'Sms code',
7
- smsCodeError: 'Invalid sms code, you can resend the code',
8
- resendMessage: 'A new verification code has been sent to your phone number.',
9
- activate: 'Activate Account',
10
- resend: 'Resend'
11
- }
12
- },
13
- zh: {
14
- smsVerification: {
15
- title: '请输入您在号码上收到的验证码',
16
- errorTitle: '您的代码无效,您可以重新发送代码并重试',
17
- code: '短信代码',
18
- smsCodeError: '短信验证码无效,请重新发送验证码',
19
- resendMessage: '新的验证码已发送到您的电话号码。',
20
- activate: '激活账户',
21
- resend: '重发'
22
- }
23
- },
24
- fr: {
25
- smsVerification: {
26
- title: 'Veuillez entrer le code de vérification que vous avez reçu sur votre numéro',
27
- errorTitle: 'Votre code n\'était pas valide, vous pouvez renvoyer le code et réessayer',
28
- code: 'Code SMS',
29
- smsCodeError: 'Code sms invalide, vous pouvez renvoyer le code',
30
- resendMessage: 'Un nouveau code de vérification a été envoyé à votre numéro de téléphone.',
31
- activate: 'Activer le compte',
32
- resend: 'Renvoyer'
33
- }
34
- },
35
- tr: {
36
- smsVerification: {
37
- title: 'Please enter the verification code you received on your number',
38
- errorTitle: 'Your code was invalid, you can resend the code and try again',
39
- code: 'Sms code',
40
- smsCodeError: 'Invalid sms code, you can resend the code',
41
- resendMessage: 'A new verification code has been sent to your phone number.',
42
- activate: 'Activate Account',
43
- resend: 'Resend'
44
- }
45
- },
46
- ro: {
47
- smsVerification: {
48
- title: 'Please enter the verification code you received on your number',
49
- errorTitle: 'Your code was invalid, you can resend the code and try again',
50
- code: 'Sms code',
51
- smsCodeError: 'Invalid sms code, you can resend the code',
52
- resendMessage: 'A new verification code has been sent to your phone number.',
53
- activate: 'Activate Account',
54
- resend: 'Resend'
55
- }
56
- },
57
- es: {
58
- smsVerification: {
59
- title: 'Please enter the verification code you received on your number',
60
- errorTitle: 'Your code was invalid, you can resend the code and try again',
61
- code: 'Sms code',
62
- smsCodeError: 'Invalid sms code, you can resend the code',
63
- resendMessage: 'A new verification code has been sent to your phone number.',
64
- activate: 'Activate Account',
65
- resend: 'Resend'
66
- }
67
- },
68
- pt: {
69
- smsVerification: {
70
- title: 'Please enter the verification code you received on your number',
71
- errorTitle: 'Your code was invalid, you can resend the code and try again',
72
- code: 'Sms code',
73
- smsCodeError: 'Invalid sms code, you can resend the code',
74
- resendMessage: 'A new verification code has been sent to your phone number.',
75
- activate: 'Activate Account',
76
- resend: 'Resend'
77
- }
78
- },
79
- };
@@ -1,13 +0,0 @@
1
- import { html } from 'lit-element';
2
-
3
- import GeneralPlayerSmsVerificationForm from '../src/GeneralPlayerSmsVerificationForm';
4
-
5
- // This default export determines where your story goes in the story list
6
- export default {
7
- title: 'GeneralPlayerSmsVerificationForm',
8
- };
9
-
10
- // 👇 We create a “template” of how args map to rendering
11
- const GeneralPlayerSmsVerificationForm = ({ aProperty }) => html`<general-player-sms-verification-form></general-player-sms-verification-form>`;
12
-
13
- export const FirstStory = GeneralPlayerSmsVerificationForm.bind({});
package/tsconfig.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": "@tsconfig/svelte/tsconfig.json",
3
-
4
- "include": ["src/**/*"],
5
- "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
- }