@everymatrix/general-player-sms-verification-form 0.0.318

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 ADDED
@@ -0,0 +1,37 @@
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 ADDED
@@ -0,0 +1 @@
1
+ import './dist/general-player-sms-verification-form.js';
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@everymatrix/general-player-sms-verification-form",
3
+ "version": "0.0.318",
4
+ "main": "index.js",
5
+ "svelte": "src/index.ts",
6
+ "scripts": {
7
+ "start": "sirv public",
8
+ "build": "cross-env NODE_ENV=production && rollup -c",
9
+ "dev": "cross-env NODE_ENV=\"development\" rollup -c -w",
10
+ "validate": "svelte-check",
11
+ "test": "echo"
12
+ },
13
+ "devDependencies": {
14
+ "@rollup/plugin-babel": "^5.3.0",
15
+ "@rollup/plugin-commonjs": "^16.0.0",
16
+ "@rollup/plugin-node-resolve": "^10.0.0",
17
+ "@rollup/plugin-typescript": "^6.0.0",
18
+ "@tsconfig/svelte": "^1.0.0",
19
+ "node-sass": "^5.0.0",
20
+ "rollup": "^2.3.4",
21
+ "rollup-plugin-dev-server": "^0.4.3",
22
+ "rollup-plugin-livereload": "^2.0.0",
23
+ "rollup-plugin-svelte": "^7.0.0",
24
+ "rollup-plugin-terser": "^7.0.0",
25
+ "rollup-plugin-uglify": "^6.0.4",
26
+ "svelte-check": "^1.0.0",
27
+ "svelte-preprocess": "^4.0.0",
28
+ "tslib": "^2.0.0",
29
+ "typescript": "^3.9.3"
30
+ },
31
+ "dependencies": {
32
+ "cross-env": "^7.0.3",
33
+ "sirv-cli": "^1.0.0",
34
+ "svelte": "^3.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "gitHead": "1eada1959a0f3cecaf9cbbb82243d5082534330e"
40
+ }
Binary file
@@ -0,0 +1,48 @@
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
+ }
@@ -0,0 +1,59 @@
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
+ };
@@ -0,0 +1,220 @@
1
+ <svelte:options tag={null} />
2
+ <script lang="ts">
3
+ import { onMount } from "svelte";
4
+ import { _, addNewMessages, setLocale, setupI18n } from './i18n';
5
+ import { SmsVerificationTranslations } from './translations';
6
+
7
+ export let endpoint;
8
+ export let tokenid;
9
+ export let playerid;
10
+ export let smstemplate = 'Please use this code {0} to activate your accout';
11
+ export let number;
12
+
13
+ let smsCode: number;
14
+ let isSmsValid: boolean = true;
15
+ let resend: boolean = false;
16
+ let smsSendApiFailed = false;
17
+
18
+ setupI18n({ withLocale: 'en', translations: {}});
19
+
20
+ Object.keys(SmsVerificationTranslations).forEach((item:any) => {
21
+ addNewMessages(item, SmsVerificationTranslations[item]);
22
+ });
23
+
24
+ const activateUser = async ():Promise<any> => {
25
+ try {
26
+ const res = await fetch(`${endpoint}/player/${playerid}/activateSMS?tokenId=${tokenid}&validationCode=${smsCode}`, {
27
+ headers: {
28
+ 'Content-Type': 'application/json',
29
+ accept: 'application/json'
30
+ }
31
+ });
32
+
33
+ if (res.ok) {
34
+ isSmsValid = true;
35
+ window.postMessage({ type: "SmsHasBeenValidated" }, window.location.href);
36
+ } else {
37
+ window.postMessage({ type: 'WidgetNotification', data: {
38
+ type: 'error',
39
+ message: "Could not activate user"
40
+ }}, window.location.href);
41
+ isSmsValid = false;
42
+ throw new Error('Could not activate user');
43
+ }
44
+ } catch (err) {
45
+ window.postMessage({ type: 'WidgetNotification', data: {
46
+ type: 'error',
47
+ message: "Could not activate user"
48
+ }}, window.location.href);
49
+ isSmsValid = false;
50
+ console.log(err);
51
+ }
52
+ }
53
+
54
+ const resendCode = async () => {
55
+ try {
56
+ const res = await fetch(`${endpoint}/player/sms/token`,{
57
+ method: 'POST',
58
+ headers: {
59
+ 'Content-Type': 'application/json',
60
+ accept: 'application/json',
61
+ },
62
+ body: JSON.stringify(
63
+ {
64
+ userId: playerid,
65
+ messageTemplate: smstemplate,
66
+ destination: number,
67
+ }
68
+ ),
69
+ });
70
+
71
+ const data = await res.json();
72
+
73
+ if(res.ok) {
74
+ tokenid = data.id;
75
+ smsSendApiFailed = false;
76
+ resend = false;
77
+ } else {
78
+ resend = false;
79
+ smsSendApiFailed = true;
80
+ throw new Error("Failed to fetch");
81
+ }
82
+ } catch(err) {
83
+ smsSendApiFailed = true;
84
+ console.error(err);
85
+ }
86
+ }
87
+
88
+ $: tokenid && playerid && endpoint;
89
+ </script>
90
+
91
+
92
+ <div class="Container SmsVerificationContainer" part="SmsVerificationContainer">
93
+ <h3 class="Title" part="Title">
94
+ {#if isSmsValid}
95
+ {$_('smsVerification.title')}
96
+ {:else}
97
+ {$_('smsVerification.errorTitle')}
98
+ {/if}
99
+ </h3>
100
+
101
+ <div class="Field SmsVerificationField {!isSmsValid ? 'InvalidField' : ''}" part="SmsVerificationField {!isSmsValid ? 'InvalidField' : ''}">
102
+ <label for="SmsCode">
103
+ {$_('smsVerification.code')}:<span class="FormRequired" part="FormRequired">*</span>
104
+ </label>
105
+ <input bind:value={smsCode} type="number" id="SmsCode" />
106
+
107
+ {#if !isSmsValid}
108
+ <p class="InvalidInput" part="InvalidInput">{$_('smsVerification.smsCodeError')}</p>
109
+ {/if}
110
+ </div>
111
+
112
+
113
+ <button
114
+ class="Button SmsVerificationValidate"
115
+ part="SmsVerificationValidate"
116
+ on:click={activateUser}>
117
+ {$_('smsVerification.activate')}
118
+ </button>
119
+
120
+ {#if resend}
121
+ <button
122
+ class="Button SmsVerificationResend"
123
+ part="SmsVerificationResend"
124
+ on:click={resendCode}>
125
+ {$_('smsVerification.resend')}
126
+ </button>
127
+ {/if}
128
+ </div>
129
+
130
+
131
+ <style lang="scss">
132
+ :host {
133
+ font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
134
+ }
135
+
136
+ *,
137
+ *::before,
138
+ *::after {
139
+ margin: 0;
140
+ padding: 0;
141
+ list-style: none;
142
+ text-decoration: none;
143
+ outline: none;
144
+ box-sizing: border-box;
145
+ }
146
+
147
+ .Title {
148
+ font-size: 14px;
149
+ margin: 0;
150
+ padding-bottom: 20px;
151
+ }
152
+
153
+ .Field {
154
+ color: var(--emfe-w-color-gray-300, #58586B);
155
+ display: flex;
156
+ flex-direction: column;
157
+ padding-bottom: 30px;
158
+ position: relative;
159
+
160
+ label {
161
+ font-size: 14px;
162
+ font-weight: 300;
163
+ padding-bottom: 5px;
164
+ }
165
+
166
+ input, select {
167
+ width: 100%;
168
+ height: 44px;
169
+ border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
170
+ border-radius: 5px;
171
+ box-sizing: border-box;
172
+ padding: 5px 15px;
173
+ font-size: 16px;
174
+ line-height: 18px;
175
+ }
176
+
177
+ &.InvalidField {
178
+ input {
179
+ border: 1px solid var(--emfe-w-color-primary, #D0046C);
180
+ background: var(--emfe-w-color-primary-50, #FBECF4);
181
+ color: var(--emfe-w-color-primary, #D0046C);
182
+ }
183
+ }
184
+
185
+ &.Hidden {
186
+ display: none;
187
+ }
188
+ }
189
+
190
+ .InvalidInput {
191
+ color: var(--emfe-w-color-error, #FD2839);
192
+ font-size: 10px;
193
+ line-height: 10px;
194
+ }
195
+
196
+ .ErrorMessage {
197
+ margin: 0 0 15px 0;
198
+ font-size: 12px;
199
+ color: var(--emfe-w-color-error, #FD2839);
200
+ }
201
+
202
+ .Button {
203
+ color: var(--emfe-w-color-white, #FFFFFF);
204
+ background: var(--emfe-w-color-primary, #D0046C);
205
+ border: 1px solid var(--emfe-w-color-primary, #D0046C);
206
+ border-radius: 5px;
207
+ width: 100%;
208
+ height: 60px;
209
+ padding: 0;
210
+ text-transform: uppercase;
211
+ font-size: 18px;
212
+ cursor: pointer;
213
+ margin-top: 24px;
214
+ &[disabled] {
215
+ background: var(--emfe-w-color-gray-100, #E6E6E6);
216
+ border: 1px solid var(--emfe-w-color-gray-100, #E6E6E6);
217
+ cursor: not-allowed;
218
+ }
219
+ }
220
+ </style>
package/src/i18n.js ADDED
@@ -0,0 +1,27 @@
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 ADDED
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,62 @@
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 ca resend the code',
8
+ activate: 'Activate Account',
9
+ resend: 'Resend'
10
+ }
11
+ },
12
+ fr: {
13
+ smsVerification: {
14
+ title: 'Please enter the verification code you received on your number',
15
+ errorTitle: 'Your code was invalid, you can resend the code and try again',
16
+ code: 'Sms code',
17
+ smsCodeError: 'Invalid sms code, you ca resend the code',
18
+ activate: 'Activate Account',
19
+ resend: 'Resend'
20
+ }
21
+ },
22
+ tr: {
23
+ smsVerification: {
24
+ title: 'Please enter the verification code you received on your number',
25
+ errorTitle: 'Your code was invalid, you can resend the code and try again',
26
+ code: 'Sms code',
27
+ smsCodeError: 'Invalid sms code, you ca resend the code',
28
+ activate: 'Activate Account',
29
+ resend: 'Resend'
30
+ }
31
+ },
32
+ ro: {
33
+ smsVerification: {
34
+ title: 'Please enter the verification code you received on your number',
35
+ errorTitle: 'Your code was invalid, you can resend the code and try again',
36
+ code: 'Sms code',
37
+ smsCodeError: 'Invalid sms code, you ca resend the code',
38
+ activate: 'Activate Account',
39
+ resend: 'Resend'
40
+ }
41
+ },
42
+ es: {
43
+ smsVerification: {
44
+ title: 'Please enter the verification code you received on your number',
45
+ errorTitle: 'Your code was invalid, you can resend the code and try again',
46
+ code: 'Sms code',
47
+ smsCodeError: 'Invalid sms code, you ca resend the code',
48
+ activate: 'Activate Account',
49
+ resend: 'Resend'
50
+ }
51
+ },
52
+ pt: {
53
+ smsVerification: {
54
+ title: 'Please enter the verification code you received on your number',
55
+ errorTitle: 'Your code was invalid, you can resend the code and try again',
56
+ code: 'Sms code',
57
+ smsCodeError: 'Invalid sms code, you ca resend the code',
58
+ activate: 'Activate Account',
59
+ resend: 'Resend'
60
+ }
61
+ },
62
+ };
@@ -0,0 +1,13 @@
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 ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "@tsconfig/svelte/tsconfig.json",
3
+
4
+ "include": ["src/**/*"],
5
+ "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
6
+ }