1 | (function webpackUniversalModuleDefinition(root, factory) {
|
2 | if(typeof exports === 'object' && typeof module === 'object')
|
3 | module.exports = factory(require("@aws-amplify/analytics"), require("@aws-amplify/api"), require("@aws-amplify/auth"), require("@aws-amplify/core"), require("@aws-amplify/interactions"), require("@aws-amplify/storage"), require("@aws-amplify/ui"), require("@aws-amplify/xr"), require("react"));
|
4 | else if(typeof define === 'function' && define.amd)
|
5 | define("aws_amplify_react", ["@aws-amplify/analytics", "@aws-amplify/api", "@aws-amplify/auth", "@aws-amplify/core", "@aws-amplify/interactions", "@aws-amplify/storage", "@aws-amplify/ui", "@aws-amplify/xr", "react"], factory);
|
6 | else if(typeof exports === 'object')
|
7 | exports["aws_amplify_react"] = factory(require("@aws-amplify/analytics"), require("@aws-amplify/api"), require("@aws-amplify/auth"), require("@aws-amplify/core"), require("@aws-amplify/interactions"), require("@aws-amplify/storage"), require("@aws-amplify/ui"), require("@aws-amplify/xr"), require("react"));
|
8 | else
|
9 | root["aws_amplify_react"] = factory(root["@aws-amplify/analytics"], root["@aws-amplify/api"], root["@aws-amplify/auth"], root["@aws-amplify/core"], root["@aws-amplify/interactions"], root["@aws-amplify/storage"], root["@aws-amplify/ui"], root["@aws-amplify/xr"], root["react"]);
|
10 | })(this, function(__WEBPACK_EXTERNAL_MODULE__aws_amplify_analytics__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_api__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_auth__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_interactions__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_storage__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_ui__, __WEBPACK_EXTERNAL_MODULE__aws_amplify_xr__, __WEBPACK_EXTERNAL_MODULE_react__) {
|
11 | return (function(modules) {
|
12 |
|
13 | var installedModules = {};
|
14 |
|
15 |
|
16 | function __webpack_require__(moduleId) {
|
17 |
|
18 |
|
19 | if(installedModules[moduleId]) {
|
20 | return installedModules[moduleId].exports;
|
21 | }
|
22 |
|
23 | var module = installedModules[moduleId] = {
|
24 | i: moduleId,
|
25 | l: false,
|
26 | exports: {}
|
27 | };
|
28 |
|
29 |
|
30 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31 |
|
32 |
|
33 | module.l = true;
|
34 |
|
35 |
|
36 | return module.exports;
|
37 | }
|
38 |
|
39 |
|
40 |
|
41 | __webpack_require__.m = modules;
|
42 |
|
43 |
|
44 | __webpack_require__.c = installedModules;
|
45 |
|
46 |
|
47 | __webpack_require__.d = function(exports, name, getter) {
|
48 | if(!__webpack_require__.o(exports, name)) {
|
49 | Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
50 | }
|
51 | };
|
52 |
|
53 |
|
54 | __webpack_require__.r = function(exports) {
|
55 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
56 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
57 | }
|
58 | Object.defineProperty(exports, '__esModule', { value: true });
|
59 | };
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | __webpack_require__.t = function(value, mode) {
|
67 | if(mode & 1) value = __webpack_require__(value);
|
68 | if(mode & 8) return value;
|
69 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
70 | var ns = Object.create(null);
|
71 | __webpack_require__.r(ns);
|
72 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
73 | if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
74 | return ns;
|
75 | };
|
76 |
|
77 |
|
78 | __webpack_require__.n = function(module) {
|
79 | var getter = module && module.__esModule ?
|
80 | function getDefault() { return module['default']; } :
|
81 | function getModuleExports() { return module; };
|
82 | __webpack_require__.d(getter, 'a', getter);
|
83 | return getter;
|
84 | };
|
85 |
|
86 |
|
87 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
88 |
|
89 |
|
90 | __webpack_require__.p = "";
|
91 |
|
92 |
|
93 |
|
94 | return __webpack_require__(__webpack_require__.s = "./lib/index.js");
|
95 | })
|
96 |
|
97 | ({
|
98 |
|
99 | "../../node_modules/object-assign/index.js":
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | (function(module, exports, __webpack_require__) {
|
105 |
|
106 | "use strict";
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
116 | var hasOwnProperty = Object.prototype.hasOwnProperty;
|
117 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
118 |
|
119 | function toObject(val) {
|
120 | if (val === null || val === undefined) {
|
121 | throw new TypeError('Object.assign cannot be called with null or undefined');
|
122 | }
|
123 |
|
124 | return Object(val);
|
125 | }
|
126 |
|
127 | function shouldUseNative() {
|
128 | try {
|
129 | if (!Object.assign) {
|
130 | return false;
|
131 | }
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | var test1 = new String('abc');
|
137 | test1[5] = 'de';
|
138 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
139 | return false;
|
140 | }
|
141 |
|
142 |
|
143 | var test2 = {};
|
144 | for (var i = 0; i < 10; i++) {
|
145 | test2['_' + String.fromCharCode(i)] = i;
|
146 | }
|
147 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
148 | return test2[n];
|
149 | });
|
150 | if (order2.join('') !== '0123456789') {
|
151 | return false;
|
152 | }
|
153 |
|
154 |
|
155 | var test3 = {};
|
156 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
157 | test3[letter] = letter;
|
158 | });
|
159 | if (Object.keys(Object.assign({}, test3)).join('') !==
|
160 | 'abcdefghijklmnopqrst') {
|
161 | return false;
|
162 | }
|
163 |
|
164 | return true;
|
165 | } catch (err) {
|
166 |
|
167 | return false;
|
168 | }
|
169 | }
|
170 |
|
171 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
172 | var from;
|
173 | var to = toObject(target);
|
174 | var symbols;
|
175 |
|
176 | for (var s = 1; s < arguments.length; s++) {
|
177 | from = Object(arguments[s]);
|
178 |
|
179 | for (var key in from) {
|
180 | if (hasOwnProperty.call(from, key)) {
|
181 | to[key] = from[key];
|
182 | }
|
183 | }
|
184 |
|
185 | if (getOwnPropertySymbols) {
|
186 | symbols = getOwnPropertySymbols(from);
|
187 | for (var i = 0; i < symbols.length; i++) {
|
188 | if (propIsEnumerable.call(from, symbols[i])) {
|
189 | to[symbols[i]] = from[symbols[i]];
|
190 | }
|
191 | }
|
192 | }
|
193 | }
|
194 |
|
195 | return to;
|
196 | };
|
197 |
|
198 |
|
199 | }),
|
200 |
|
201 | "../../node_modules/prop-types/checkPropTypes.js":
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | (function(module, exports, __webpack_require__) {
|
207 |
|
208 | "use strict";
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 | var printWarning = function() {};
|
219 |
|
220 | if (true) {
|
221 | var ReactPropTypesSecret = __webpack_require__( "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
|
222 | var loggedTypeFailures = {};
|
223 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
224 |
|
225 | printWarning = function(text) {
|
226 | var message = 'Warning: ' + text;
|
227 | if (typeof console !== 'undefined') {
|
228 | console.error(message);
|
229 | }
|
230 | try {
|
231 |
|
232 |
|
233 |
|
234 | throw new Error(message);
|
235 | } catch (x) {}
|
236 | };
|
237 | }
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
251 | if (true) {
|
252 | for (var typeSpecName in typeSpecs) {
|
253 | if (has(typeSpecs, typeSpecName)) {
|
254 | var error;
|
255 |
|
256 |
|
257 |
|
258 | try {
|
259 |
|
260 |
|
261 | if (typeof typeSpecs[typeSpecName] !== 'function') {
|
262 | var err = Error(
|
263 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
264 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
265 | );
|
266 | err.name = 'Invariant Violation';
|
267 | throw err;
|
268 | }
|
269 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
270 | } catch (ex) {
|
271 | error = ex;
|
272 | }
|
273 | if (error && !(error instanceof Error)) {
|
274 | printWarning(
|
275 | (componentName || 'React class') + ': type specification of ' +
|
276 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
277 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
278 | 'You may have forgotten to pass an argument to the type checker ' +
|
279 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
280 | 'shape all require an argument).'
|
281 | );
|
282 | }
|
283 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
284 |
|
285 |
|
286 | loggedTypeFailures[error.message] = true;
|
287 |
|
288 | var stack = getStack ? getStack() : '';
|
289 |
|
290 | printWarning(
|
291 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
292 | );
|
293 | }
|
294 | }
|
295 | }
|
296 | }
|
297 | }
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 | checkPropTypes.resetWarningCache = function() {
|
305 | if (true) {
|
306 | loggedTypeFailures = {};
|
307 | }
|
308 | }
|
309 |
|
310 | module.exports = checkPropTypes;
|
311 |
|
312 |
|
313 | }),
|
314 |
|
315 | "../../node_modules/prop-types/factoryWithTypeCheckers.js":
|
316 |
|
317 |
|
318 |
|
319 |
|
320 | (function(module, exports, __webpack_require__) {
|
321 |
|
322 | "use strict";
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 | var ReactIs = __webpack_require__( "../../node_modules/react-is/index.js");
|
333 | var assign = __webpack_require__( "../../node_modules/object-assign/index.js");
|
334 |
|
335 | var ReactPropTypesSecret = __webpack_require__( "../../node_modules/prop-types/lib/ReactPropTypesSecret.js");
|
336 | var checkPropTypes = __webpack_require__( "../../node_modules/prop-types/checkPropTypes.js");
|
337 |
|
338 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
339 | var printWarning = function() {};
|
340 |
|
341 | if (true) {
|
342 | printWarning = function(text) {
|
343 | var message = 'Warning: ' + text;
|
344 | if (typeof console !== 'undefined') {
|
345 | console.error(message);
|
346 | }
|
347 | try {
|
348 |
|
349 |
|
350 |
|
351 | throw new Error(message);
|
352 | } catch (x) {}
|
353 | };
|
354 | }
|
355 |
|
356 | function emptyFunctionThatReturnsNull() {
|
357 | return null;
|
358 | }
|
359 |
|
360 | module.exports = function(isValidElement, throwOnDirectAccess) {
|
361 |
|
362 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
363 | var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
364 |
|
365 | |
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 | function getIteratorFn(maybeIterable) {
|
380 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
|
381 | if (typeof iteratorFn === 'function') {
|
382 | return iteratorFn;
|
383 | }
|
384 | }
|
385 |
|
386 | |
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 | var ANONYMOUS = '<<anonymous>>';
|
434 |
|
435 |
|
436 |
|
437 | var ReactPropTypes = {
|
438 | array: createPrimitiveTypeChecker('array'),
|
439 | bool: createPrimitiveTypeChecker('boolean'),
|
440 | func: createPrimitiveTypeChecker('function'),
|
441 | number: createPrimitiveTypeChecker('number'),
|
442 | object: createPrimitiveTypeChecker('object'),
|
443 | string: createPrimitiveTypeChecker('string'),
|
444 | symbol: createPrimitiveTypeChecker('symbol'),
|
445 |
|
446 | any: createAnyTypeChecker(),
|
447 | arrayOf: createArrayOfTypeChecker,
|
448 | element: createElementTypeChecker(),
|
449 | elementType: createElementTypeTypeChecker(),
|
450 | instanceOf: createInstanceTypeChecker,
|
451 | node: createNodeChecker(),
|
452 | objectOf: createObjectOfTypeChecker,
|
453 | oneOf: createEnumTypeChecker,
|
454 | oneOfType: createUnionTypeChecker,
|
455 | shape: createShapeTypeChecker,
|
456 | exact: createStrictShapeTypeChecker,
|
457 | };
|
458 |
|
459 | |
460 |
|
461 |
|
462 |
|
463 |
|
464 | function is(x, y) {
|
465 |
|
466 | if (x === y) {
|
467 |
|
468 |
|
469 | return x !== 0 || 1 / x === 1 / y;
|
470 | } else {
|
471 |
|
472 | return x !== x && y !== y;
|
473 | }
|
474 | }
|
475 |
|
476 |
|
477 | |
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 | function PropTypeError(message) {
|
485 | this.message = message;
|
486 | this.stack = '';
|
487 | }
|
488 |
|
489 | PropTypeError.prototype = Error.prototype;
|
490 |
|
491 | function createChainableTypeChecker(validate) {
|
492 | if (true) {
|
493 | var manualPropTypeCallCache = {};
|
494 | var manualPropTypeWarningCount = 0;
|
495 | }
|
496 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
|
497 | componentName = componentName || ANONYMOUS;
|
498 | propFullName = propFullName || propName;
|
499 |
|
500 | if (secret !== ReactPropTypesSecret) {
|
501 | if (throwOnDirectAccess) {
|
502 |
|
503 | var err = new Error(
|
504 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
505 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
|
506 | 'Read more at http://fb.me/use-check-prop-types'
|
507 | );
|
508 | err.name = 'Invariant Violation';
|
509 | throw err;
|
510 | } else if ( true && typeof console !== 'undefined') {
|
511 |
|
512 | var cacheKey = componentName + ':' + propName;
|
513 | if (
|
514 | !manualPropTypeCallCache[cacheKey] &&
|
515 |
|
516 | manualPropTypeWarningCount < 3
|
517 | ) {
|
518 | printWarning(
|
519 | 'You are manually calling a React.PropTypes validation ' +
|
520 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
|
521 | 'and will throw in the standalone `prop-types` package. ' +
|
522 | 'You may be seeing this warning due to a third-party PropTypes ' +
|
523 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
|
524 | );
|
525 | manualPropTypeCallCache[cacheKey] = true;
|
526 | manualPropTypeWarningCount++;
|
527 | }
|
528 | }
|
529 | }
|
530 | if (props[propName] == null) {
|
531 | if (isRequired) {
|
532 | if (props[propName] === null) {
|
533 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
|
534 | }
|
535 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
|
536 | }
|
537 | return null;
|
538 | } else {
|
539 | return validate(props, propName, componentName, location, propFullName);
|
540 | }
|
541 | }
|
542 |
|
543 | var chainedCheckType = checkType.bind(null, false);
|
544 | chainedCheckType.isRequired = checkType.bind(null, true);
|
545 |
|
546 | return chainedCheckType;
|
547 | }
|
548 |
|
549 | function createPrimitiveTypeChecker(expectedType) {
|
550 | function validate(props, propName, componentName, location, propFullName, secret) {
|
551 | var propValue = props[propName];
|
552 | var propType = getPropType(propValue);
|
553 | if (propType !== expectedType) {
|
554 |
|
555 |
|
556 |
|
557 | var preciseType = getPreciseType(propValue);
|
558 |
|
559 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
|
560 | }
|
561 | return null;
|
562 | }
|
563 | return createChainableTypeChecker(validate);
|
564 | }
|
565 |
|
566 | function createAnyTypeChecker() {
|
567 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
|
568 | }
|
569 |
|
570 | function createArrayOfTypeChecker(typeChecker) {
|
571 | function validate(props, propName, componentName, location, propFullName) {
|
572 | if (typeof typeChecker !== 'function') {
|
573 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
|
574 | }
|
575 | var propValue = props[propName];
|
576 | if (!Array.isArray(propValue)) {
|
577 | var propType = getPropType(propValue);
|
578 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
|
579 | }
|
580 | for (var i = 0; i < propValue.length; i++) {
|
581 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
|
582 | if (error instanceof Error) {
|
583 | return error;
|
584 | }
|
585 | }
|
586 | return null;
|
587 | }
|
588 | return createChainableTypeChecker(validate);
|
589 | }
|
590 |
|
591 | function createElementTypeChecker() {
|
592 | function validate(props, propName, componentName, location, propFullName) {
|
593 | var propValue = props[propName];
|
594 | if (!isValidElement(propValue)) {
|
595 | var propType = getPropType(propValue);
|
596 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
|
597 | }
|
598 | return null;
|
599 | }
|
600 | return createChainableTypeChecker(validate);
|
601 | }
|
602 |
|
603 | function createElementTypeTypeChecker() {
|
604 | function validate(props, propName, componentName, location, propFullName) {
|
605 | var propValue = props[propName];
|
606 | if (!ReactIs.isValidElementType(propValue)) {
|
607 | var propType = getPropType(propValue);
|
608 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
|
609 | }
|
610 | return null;
|
611 | }
|
612 | return createChainableTypeChecker(validate);
|
613 | }
|
614 |
|
615 | function createInstanceTypeChecker(expectedClass) {
|
616 | function validate(props, propName, componentName, location, propFullName) {
|
617 | if (!(props[propName] instanceof expectedClass)) {
|
618 | var expectedClassName = expectedClass.name || ANONYMOUS;
|
619 | var actualClassName = getClassName(props[propName]);
|
620 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
|
621 | }
|
622 | return null;
|
623 | }
|
624 | return createChainableTypeChecker(validate);
|
625 | }
|
626 |
|
627 | function createEnumTypeChecker(expectedValues) {
|
628 | if (!Array.isArray(expectedValues)) {
|
629 | if (true) {
|
630 | if (arguments.length > 1) {
|
631 | printWarning(
|
632 | 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
|
633 | 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
|
634 | );
|
635 | } else {
|
636 | printWarning('Invalid argument supplied to oneOf, expected an array.');
|
637 | }
|
638 | }
|
639 | return emptyFunctionThatReturnsNull;
|
640 | }
|
641 |
|
642 | function validate(props, propName, componentName, location, propFullName) {
|
643 | var propValue = props[propName];
|
644 | for (var i = 0; i < expectedValues.length; i++) {
|
645 | if (is(propValue, expectedValues[i])) {
|
646 | return null;
|
647 | }
|
648 | }
|
649 |
|
650 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
|
651 | var type = getPreciseType(value);
|
652 | if (type === 'symbol') {
|
653 | return String(value);
|
654 | }
|
655 | return value;
|
656 | });
|
657 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
|
658 | }
|
659 | return createChainableTypeChecker(validate);
|
660 | }
|
661 |
|
662 | function createObjectOfTypeChecker(typeChecker) {
|
663 | function validate(props, propName, componentName, location, propFullName) {
|
664 | if (typeof typeChecker !== 'function') {
|
665 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
|
666 | }
|
667 | var propValue = props[propName];
|
668 | var propType = getPropType(propValue);
|
669 | if (propType !== 'object') {
|
670 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
|
671 | }
|
672 | for (var key in propValue) {
|
673 | if (has(propValue, key)) {
|
674 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
675 | if (error instanceof Error) {
|
676 | return error;
|
677 | }
|
678 | }
|
679 | }
|
680 | return null;
|
681 | }
|
682 | return createChainableTypeChecker(validate);
|
683 | }
|
684 |
|
685 | function createUnionTypeChecker(arrayOfTypeCheckers) {
|
686 | if (!Array.isArray(arrayOfTypeCheckers)) {
|
687 | true ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : undefined;
|
688 | return emptyFunctionThatReturnsNull;
|
689 | }
|
690 |
|
691 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
692 | var checker = arrayOfTypeCheckers[i];
|
693 | if (typeof checker !== 'function') {
|
694 | printWarning(
|
695 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
|
696 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
|
697 | );
|
698 | return emptyFunctionThatReturnsNull;
|
699 | }
|
700 | }
|
701 |
|
702 | function validate(props, propName, componentName, location, propFullName) {
|
703 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
|
704 | var checker = arrayOfTypeCheckers[i];
|
705 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
|
706 | return null;
|
707 | }
|
708 | }
|
709 |
|
710 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
|
711 | }
|
712 | return createChainableTypeChecker(validate);
|
713 | }
|
714 |
|
715 | function createNodeChecker() {
|
716 | function validate(props, propName, componentName, location, propFullName) {
|
717 | if (!isNode(props[propName])) {
|
718 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
|
719 | }
|
720 | return null;
|
721 | }
|
722 | return createChainableTypeChecker(validate);
|
723 | }
|
724 |
|
725 | function createShapeTypeChecker(shapeTypes) {
|
726 | function validate(props, propName, componentName, location, propFullName) {
|
727 | var propValue = props[propName];
|
728 | var propType = getPropType(propValue);
|
729 | if (propType !== 'object') {
|
730 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
731 | }
|
732 | for (var key in shapeTypes) {
|
733 | var checker = shapeTypes[key];
|
734 | if (!checker) {
|
735 | continue;
|
736 | }
|
737 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
738 | if (error) {
|
739 | return error;
|
740 | }
|
741 | }
|
742 | return null;
|
743 | }
|
744 | return createChainableTypeChecker(validate);
|
745 | }
|
746 |
|
747 | function createStrictShapeTypeChecker(shapeTypes) {
|
748 | function validate(props, propName, componentName, location, propFullName) {
|
749 | var propValue = props[propName];
|
750 | var propType = getPropType(propValue);
|
751 | if (propType !== 'object') {
|
752 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
|
753 | }
|
754 |
|
755 |
|
756 | var allKeys = assign({}, props[propName], shapeTypes);
|
757 | for (var key in allKeys) {
|
758 | var checker = shapeTypes[key];
|
759 | if (!checker) {
|
760 | return new PropTypeError(
|
761 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
|
762 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
|
763 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
|
764 | );
|
765 | }
|
766 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
|
767 | if (error) {
|
768 | return error;
|
769 | }
|
770 | }
|
771 | return null;
|
772 | }
|
773 |
|
774 | return createChainableTypeChecker(validate);
|
775 | }
|
776 |
|
777 | function isNode(propValue) {
|
778 | switch (typeof propValue) {
|
779 | case 'number':
|
780 | case 'string':
|
781 | case 'undefined':
|
782 | return true;
|
783 | case 'boolean':
|
784 | return !propValue;
|
785 | case 'object':
|
786 | if (Array.isArray(propValue)) {
|
787 | return propValue.every(isNode);
|
788 | }
|
789 | if (propValue === null || isValidElement(propValue)) {
|
790 | return true;
|
791 | }
|
792 |
|
793 | var iteratorFn = getIteratorFn(propValue);
|
794 | if (iteratorFn) {
|
795 | var iterator = iteratorFn.call(propValue);
|
796 | var step;
|
797 | if (iteratorFn !== propValue.entries) {
|
798 | while (!(step = iterator.next()).done) {
|
799 | if (!isNode(step.value)) {
|
800 | return false;
|
801 | }
|
802 | }
|
803 | } else {
|
804 |
|
805 | while (!(step = iterator.next()).done) {
|
806 | var entry = step.value;
|
807 | if (entry) {
|
808 | if (!isNode(entry[1])) {
|
809 | return false;
|
810 | }
|
811 | }
|
812 | }
|
813 | }
|
814 | } else {
|
815 | return false;
|
816 | }
|
817 |
|
818 | return true;
|
819 | default:
|
820 | return false;
|
821 | }
|
822 | }
|
823 |
|
824 | function isSymbol(propType, propValue) {
|
825 |
|
826 | if (propType === 'symbol') {
|
827 | return true;
|
828 | }
|
829 |
|
830 |
|
831 | if (!propValue) {
|
832 | return false;
|
833 | }
|
834 |
|
835 |
|
836 | if (propValue['@@toStringTag'] === 'Symbol') {
|
837 | return true;
|
838 | }
|
839 |
|
840 |
|
841 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
|
842 | return true;
|
843 | }
|
844 |
|
845 | return false;
|
846 | }
|
847 |
|
848 |
|
849 | function getPropType(propValue) {
|
850 | var propType = typeof propValue;
|
851 | if (Array.isArray(propValue)) {
|
852 | return 'array';
|
853 | }
|
854 | if (propValue instanceof RegExp) {
|
855 |
|
856 |
|
857 |
|
858 | return 'object';
|
859 | }
|
860 | if (isSymbol(propType, propValue)) {
|
861 | return 'symbol';
|
862 | }
|
863 | return propType;
|
864 | }
|
865 |
|
866 |
|
867 |
|
868 | function getPreciseType(propValue) {
|
869 | if (typeof propValue === 'undefined' || propValue === null) {
|
870 | return '' + propValue;
|
871 | }
|
872 | var propType = getPropType(propValue);
|
873 | if (propType === 'object') {
|
874 | if (propValue instanceof Date) {
|
875 | return 'date';
|
876 | } else if (propValue instanceof RegExp) {
|
877 | return 'regexp';
|
878 | }
|
879 | }
|
880 | return propType;
|
881 | }
|
882 |
|
883 |
|
884 |
|
885 | function getPostfixForTypeWarning(value) {
|
886 | var type = getPreciseType(value);
|
887 | switch (type) {
|
888 | case 'array':
|
889 | case 'object':
|
890 | return 'an ' + type;
|
891 | case 'boolean':
|
892 | case 'date':
|
893 | case 'regexp':
|
894 | return 'a ' + type;
|
895 | default:
|
896 | return type;
|
897 | }
|
898 | }
|
899 |
|
900 |
|
901 | function getClassName(propValue) {
|
902 | if (!propValue.constructor || !propValue.constructor.name) {
|
903 | return ANONYMOUS;
|
904 | }
|
905 | return propValue.constructor.name;
|
906 | }
|
907 |
|
908 | ReactPropTypes.checkPropTypes = checkPropTypes;
|
909 | ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
|
910 | ReactPropTypes.PropTypes = ReactPropTypes;
|
911 |
|
912 | return ReactPropTypes;
|
913 | };
|
914 |
|
915 |
|
916 | }),
|
917 |
|
918 | "../../node_modules/prop-types/index.js":
|
919 |
|
920 |
|
921 |
|
922 |
|
923 | (function(module, exports, __webpack_require__) {
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | if (true) {
|
933 | var ReactIs = __webpack_require__( "../../node_modules/react-is/index.js");
|
934 |
|
935 |
|
936 |
|
937 | var throwOnDirectAccess = true;
|
938 | module.exports = __webpack_require__( "../../node_modules/prop-types/factoryWithTypeCheckers.js")(ReactIs.isElement, throwOnDirectAccess);
|
939 | } else {}
|
940 |
|
941 |
|
942 | }),
|
943 |
|
944 | "../../node_modules/prop-types/lib/ReactPropTypesSecret.js":
|
945 |
|
946 |
|
947 |
|
948 |
|
949 | (function(module, exports, __webpack_require__) {
|
950 |
|
951 | "use strict";
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
962 |
|
963 | module.exports = ReactPropTypesSecret;
|
964 |
|
965 |
|
966 | }),
|
967 |
|
968 | "../../node_modules/qr.js/lib/8BitByte.js":
|
969 |
|
970 |
|
971 |
|
972 |
|
973 | (function(module, exports, __webpack_require__) {
|
974 |
|
975 | var mode = __webpack_require__( "../../node_modules/qr.js/lib/mode.js");
|
976 |
|
977 | function QR8bitByte(data) {
|
978 | this.mode = mode.MODE_8BIT_BYTE;
|
979 | this.data = data;
|
980 | }
|
981 |
|
982 | QR8bitByte.prototype = {
|
983 |
|
984 | getLength : function(buffer) {
|
985 | return this.data.length;
|
986 | },
|
987 |
|
988 | write : function(buffer) {
|
989 | for (var i = 0; i < this.data.length; i++) {
|
990 |
|
991 | buffer.put(this.data.charCodeAt(i), 8);
|
992 | }
|
993 | }
|
994 | };
|
995 |
|
996 | module.exports = QR8bitByte;
|
997 |
|
998 |
|
999 |
|
1000 | }),
|
1001 |
|
1002 | "../../node_modules/qr.js/lib/BitBuffer.js":
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 | (function(module, exports) {
|
1008 |
|
1009 | function QRBitBuffer() {
|
1010 | this.buffer = new Array();
|
1011 | this.length = 0;
|
1012 | }
|
1013 |
|
1014 | QRBitBuffer.prototype = {
|
1015 |
|
1016 | get : function(index) {
|
1017 | var bufIndex = Math.floor(index / 8);
|
1018 | return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
|
1019 | },
|
1020 |
|
1021 | put : function(num, length) {
|
1022 | for (var i = 0; i < length; i++) {
|
1023 | this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
|
1024 | }
|
1025 | },
|
1026 |
|
1027 | getLengthInBits : function() {
|
1028 | return this.length;
|
1029 | },
|
1030 |
|
1031 | putBit : function(bit) {
|
1032 |
|
1033 | var bufIndex = Math.floor(this.length / 8);
|
1034 | if (this.buffer.length <= bufIndex) {
|
1035 | this.buffer.push(0);
|
1036 | }
|
1037 |
|
1038 | if (bit) {
|
1039 | this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) );
|
1040 | }
|
1041 |
|
1042 | this.length++;
|
1043 | }
|
1044 | };
|
1045 |
|
1046 | module.exports = QRBitBuffer;
|
1047 |
|
1048 |
|
1049 | }),
|
1050 |
|
1051 | "../../node_modules/qr.js/lib/ErrorCorrectLevel.js":
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 | (function(module, exports) {
|
1057 |
|
1058 | module.exports = {
|
1059 | L : 1,
|
1060 | M : 0,
|
1061 | Q : 3,
|
1062 | H : 2
|
1063 | };
|
1064 |
|
1065 |
|
1066 |
|
1067 | }),
|
1068 |
|
1069 | "../../node_modules/qr.js/lib/Polynomial.js":
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 | (function(module, exports, __webpack_require__) {
|
1075 |
|
1076 | var math = __webpack_require__( "../../node_modules/qr.js/lib/math.js");
|
1077 |
|
1078 | function QRPolynomial(num, shift) {
|
1079 |
|
1080 | if (num.length == undefined) {
|
1081 | throw new Error(num.length + "/" + shift);
|
1082 | }
|
1083 |
|
1084 | var offset = 0;
|
1085 |
|
1086 | while (offset < num.length && num[offset] == 0) {
|
1087 | offset++;
|
1088 | }
|
1089 |
|
1090 | this.num = new Array(num.length - offset + shift);
|
1091 | for (var i = 0; i < num.length - offset; i++) {
|
1092 | this.num[i] = num[i + offset];
|
1093 | }
|
1094 | }
|
1095 |
|
1096 | QRPolynomial.prototype = {
|
1097 |
|
1098 | get : function(index) {
|
1099 | return this.num[index];
|
1100 | },
|
1101 |
|
1102 | getLength : function() {
|
1103 | return this.num.length;
|
1104 | },
|
1105 |
|
1106 | multiply : function(e) {
|
1107 |
|
1108 | var num = new Array(this.getLength() + e.getLength() - 1);
|
1109 |
|
1110 | for (var i = 0; i < this.getLength(); i++) {
|
1111 | for (var j = 0; j < e.getLength(); j++) {
|
1112 | num[i + j] ^= math.gexp(math.glog(this.get(i) ) + math.glog(e.get(j) ) );
|
1113 | }
|
1114 | }
|
1115 |
|
1116 | return new QRPolynomial(num, 0);
|
1117 | },
|
1118 |
|
1119 | mod : function(e) {
|
1120 |
|
1121 | if (this.getLength() - e.getLength() < 0) {
|
1122 | return this;
|
1123 | }
|
1124 |
|
1125 | var ratio = math.glog(this.get(0) ) - math.glog(e.get(0) );
|
1126 |
|
1127 | var num = new Array(this.getLength() );
|
1128 |
|
1129 | for (var i = 0; i < this.getLength(); i++) {
|
1130 | num[i] = this.get(i);
|
1131 | }
|
1132 |
|
1133 | for (var i = 0; i < e.getLength(); i++) {
|
1134 | num[i] ^= math.gexp(math.glog(e.get(i) ) + ratio);
|
1135 | }
|
1136 |
|
1137 |
|
1138 | return new QRPolynomial(num, 0).mod(e);
|
1139 | }
|
1140 | };
|
1141 |
|
1142 | module.exports = QRPolynomial;
|
1143 |
|
1144 |
|
1145 | }),
|
1146 |
|
1147 | "../../node_modules/qr.js/lib/QRCode.js":
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 | (function(module, exports, __webpack_require__) {
|
1153 |
|
1154 | var BitByte = __webpack_require__( "../../node_modules/qr.js/lib/8BitByte.js");
|
1155 | var RSBlock = __webpack_require__( "../../node_modules/qr.js/lib/RSBlock.js");
|
1156 | var BitBuffer = __webpack_require__( "../../node_modules/qr.js/lib/BitBuffer.js");
|
1157 | var util = __webpack_require__( "../../node_modules/qr.js/lib/util.js");
|
1158 | var Polynomial = __webpack_require__( "../../node_modules/qr.js/lib/Polynomial.js");
|
1159 |
|
1160 | function QRCode(typeNumber, errorCorrectLevel) {
|
1161 | this.typeNumber = typeNumber;
|
1162 | this.errorCorrectLevel = errorCorrectLevel;
|
1163 | this.modules = null;
|
1164 | this.moduleCount = 0;
|
1165 | this.dataCache = null;
|
1166 | this.dataList = [];
|
1167 | }
|
1168 |
|
1169 |
|
1170 | var proto = QRCode.prototype;
|
1171 |
|
1172 | proto.addData = function(data) {
|
1173 | var newData = new BitByte(data);
|
1174 | this.dataList.push(newData);
|
1175 | this.dataCache = null;
|
1176 | };
|
1177 |
|
1178 | proto.isDark = function(row, col) {
|
1179 | if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
|
1180 | throw new Error(row + "," + col);
|
1181 | }
|
1182 | return this.modules[row][col];
|
1183 | };
|
1184 |
|
1185 | proto.getModuleCount = function() {
|
1186 | return this.moduleCount;
|
1187 | };
|
1188 |
|
1189 | proto.make = function() {
|
1190 |
|
1191 | if (this.typeNumber < 1 ){
|
1192 | var typeNumber = 1;
|
1193 | for (typeNumber = 1; typeNumber < 40; typeNumber++) {
|
1194 | var rsBlocks = RSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
|
1195 |
|
1196 | var buffer = new BitBuffer();
|
1197 | var totalDataCount = 0;
|
1198 | for (var i = 0; i < rsBlocks.length; i++) {
|
1199 | totalDataCount += rsBlocks[i].dataCount;
|
1200 | }
|
1201 |
|
1202 | for (var i = 0; i < this.dataList.length; i++) {
|
1203 | var data = this.dataList[i];
|
1204 | buffer.put(data.mode, 4);
|
1205 | buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber) );
|
1206 | data.write(buffer);
|
1207 | }
|
1208 | if (buffer.getLengthInBits() <= totalDataCount * 8)
|
1209 | break;
|
1210 | }
|
1211 | this.typeNumber = typeNumber;
|
1212 | }
|
1213 | this.makeImpl(false, this.getBestMaskPattern() );
|
1214 | };
|
1215 |
|
1216 | proto.makeImpl = function(test, maskPattern) {
|
1217 |
|
1218 | this.moduleCount = this.typeNumber * 4 + 17;
|
1219 | this.modules = new Array(this.moduleCount);
|
1220 |
|
1221 | for (var row = 0; row < this.moduleCount; row++) {
|
1222 |
|
1223 | this.modules[row] = new Array(this.moduleCount);
|
1224 |
|
1225 | for (var col = 0; col < this.moduleCount; col++) {
|
1226 | this.modules[row][col] = null;
|
1227 | }
|
1228 | }
|
1229 |
|
1230 | this.setupPositionProbePattern(0, 0);
|
1231 | this.setupPositionProbePattern(this.moduleCount - 7, 0);
|
1232 | this.setupPositionProbePattern(0, this.moduleCount - 7);
|
1233 | this.setupPositionAdjustPattern();
|
1234 | this.setupTimingPattern();
|
1235 | this.setupTypeInfo(test, maskPattern);
|
1236 |
|
1237 | if (this.typeNumber >= 7) {
|
1238 | this.setupTypeNumber(test);
|
1239 | }
|
1240 |
|
1241 | if (this.dataCache == null) {
|
1242 | this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
|
1243 | }
|
1244 |
|
1245 | this.mapData(this.dataCache, maskPattern);
|
1246 | };
|
1247 |
|
1248 | proto.setupPositionProbePattern = function(row, col) {
|
1249 |
|
1250 | for (var r = -1; r <= 7; r++) {
|
1251 |
|
1252 | if (row + r <= -1 || this.moduleCount <= row + r) continue;
|
1253 |
|
1254 | for (var c = -1; c <= 7; c++) {
|
1255 |
|
1256 | if (col + c <= -1 || this.moduleCount <= col + c) continue;
|
1257 |
|
1258 | if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
|
1259 | || (0 <= c && c <= 6 && (r == 0 || r == 6) )
|
1260 | || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
|
1261 | this.modules[row + r][col + c] = true;
|
1262 | } else {
|
1263 | this.modules[row + r][col + c] = false;
|
1264 | }
|
1265 | }
|
1266 | }
|
1267 | };
|
1268 |
|
1269 | proto.getBestMaskPattern = function() {
|
1270 |
|
1271 | var minLostPoint = 0;
|
1272 | var pattern = 0;
|
1273 |
|
1274 | for (var i = 0; i < 8; i++) {
|
1275 |
|
1276 | this.makeImpl(true, i);
|
1277 |
|
1278 | var lostPoint = util.getLostPoint(this);
|
1279 |
|
1280 | if (i == 0 || minLostPoint > lostPoint) {
|
1281 | minLostPoint = lostPoint;
|
1282 | pattern = i;
|
1283 | }
|
1284 | }
|
1285 |
|
1286 | return pattern;
|
1287 | };
|
1288 |
|
1289 | proto.createMovieClip = function(target_mc, instance_name, depth) {
|
1290 |
|
1291 | var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
|
1292 | var cs = 1;
|
1293 |
|
1294 | this.make();
|
1295 |
|
1296 | for (var row = 0; row < this.modules.length; row++) {
|
1297 |
|
1298 | var y = row * cs;
|
1299 |
|
1300 | for (var col = 0; col < this.modules[row].length; col++) {
|
1301 |
|
1302 | var x = col * cs;
|
1303 | var dark = this.modules[row][col];
|
1304 |
|
1305 | if (dark) {
|
1306 | qr_mc.beginFill(0, 100);
|
1307 | qr_mc.moveTo(x, y);
|
1308 | qr_mc.lineTo(x + cs, y);
|
1309 | qr_mc.lineTo(x + cs, y + cs);
|
1310 | qr_mc.lineTo(x, y + cs);
|
1311 | qr_mc.endFill();
|
1312 | }
|
1313 | }
|
1314 | }
|
1315 |
|
1316 | return qr_mc;
|
1317 | };
|
1318 |
|
1319 | proto.setupTimingPattern = function() {
|
1320 |
|
1321 | for (var r = 8; r < this.moduleCount - 8; r++) {
|
1322 | if (this.modules[r][6] != null) {
|
1323 | continue;
|
1324 | }
|
1325 | this.modules[r][6] = (r % 2 == 0);
|
1326 | }
|
1327 |
|
1328 | for (var c = 8; c < this.moduleCount - 8; c++) {
|
1329 | if (this.modules[6][c] != null) {
|
1330 | continue;
|
1331 | }
|
1332 | this.modules[6][c] = (c % 2 == 0);
|
1333 | }
|
1334 | };
|
1335 |
|
1336 | proto.setupPositionAdjustPattern = function() {
|
1337 |
|
1338 | var pos = util.getPatternPosition(this.typeNumber);
|
1339 |
|
1340 | for (var i = 0; i < pos.length; i++) {
|
1341 |
|
1342 | for (var j = 0; j < pos.length; j++) {
|
1343 |
|
1344 | var row = pos[i];
|
1345 | var col = pos[j];
|
1346 |
|
1347 | if (this.modules[row][col] != null) {
|
1348 | continue;
|
1349 | }
|
1350 |
|
1351 | for (var r = -2; r <= 2; r++) {
|
1352 |
|
1353 | for (var c = -2; c <= 2; c++) {
|
1354 |
|
1355 | if (r == -2 || r == 2 || c == -2 || c == 2
|
1356 | || (r == 0 && c == 0) ) {
|
1357 | this.modules[row + r][col + c] = true;
|
1358 | } else {
|
1359 | this.modules[row + r][col + c] = false;
|
1360 | }
|
1361 | }
|
1362 | }
|
1363 | }
|
1364 | }
|
1365 | };
|
1366 |
|
1367 | proto.setupTypeNumber = function(test) {
|
1368 |
|
1369 | var bits = util.getBCHTypeNumber(this.typeNumber);
|
1370 |
|
1371 | for (var i = 0; i < 18; i++) {
|
1372 | var mod = (!test && ( (bits >> i) & 1) == 1);
|
1373 | this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
1374 | }
|
1375 |
|
1376 | for (var i = 0; i < 18; i++) {
|
1377 | var mod = (!test && ( (bits >> i) & 1) == 1);
|
1378 | this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
|
1379 | }
|
1380 | };
|
1381 |
|
1382 | proto.setupTypeInfo = function(test, maskPattern) {
|
1383 |
|
1384 | var data = (this.errorCorrectLevel << 3) | maskPattern;
|
1385 | var bits = util.getBCHTypeInfo(data);
|
1386 |
|
1387 |
|
1388 | for (var i = 0; i < 15; i++) {
|
1389 |
|
1390 | var mod = (!test && ( (bits >> i) & 1) == 1);
|
1391 |
|
1392 | if (i < 6) {
|
1393 | this.modules[i][8] = mod;
|
1394 | } else if (i < 8) {
|
1395 | this.modules[i + 1][8] = mod;
|
1396 | } else {
|
1397 | this.modules[this.moduleCount - 15 + i][8] = mod;
|
1398 | }
|
1399 | }
|
1400 |
|
1401 |
|
1402 | for (var i = 0; i < 15; i++) {
|
1403 |
|
1404 | var mod = (!test && ( (bits >> i) & 1) == 1);
|
1405 |
|
1406 | if (i < 8) {
|
1407 | this.modules[8][this.moduleCount - i - 1] = mod;
|
1408 | } else if (i < 9) {
|
1409 | this.modules[8][15 - i - 1 + 1] = mod;
|
1410 | } else {
|
1411 | this.modules[8][15 - i - 1] = mod;
|
1412 | }
|
1413 | }
|
1414 |
|
1415 |
|
1416 | this.modules[this.moduleCount - 8][8] = (!test);
|
1417 | };
|
1418 |
|
1419 | proto.mapData = function(data, maskPattern) {
|
1420 |
|
1421 | var inc = -1;
|
1422 | var row = this.moduleCount - 1;
|
1423 | var bitIndex = 7;
|
1424 | var byteIndex = 0;
|
1425 |
|
1426 | for (var col = this.moduleCount - 1; col > 0; col -= 2) {
|
1427 |
|
1428 | if (col == 6) col--;
|
1429 |
|
1430 | while (true) {
|
1431 |
|
1432 | for (var c = 0; c < 2; c++) {
|
1433 |
|
1434 | if (this.modules[row][col - c] == null) {
|
1435 |
|
1436 | var dark = false;
|
1437 |
|
1438 | if (byteIndex < data.length) {
|
1439 | dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
|
1440 | }
|
1441 |
|
1442 | var mask = util.getMask(maskPattern, row, col - c);
|
1443 |
|
1444 | if (mask) {
|
1445 | dark = !dark;
|
1446 | }
|
1447 |
|
1448 | this.modules[row][col - c] = dark;
|
1449 | bitIndex--;
|
1450 |
|
1451 | if (bitIndex == -1) {
|
1452 | byteIndex++;
|
1453 | bitIndex = 7;
|
1454 | }
|
1455 | }
|
1456 | }
|
1457 |
|
1458 | row += inc;
|
1459 |
|
1460 | if (row < 0 || this.moduleCount <= row) {
|
1461 | row -= inc;
|
1462 | inc = -inc;
|
1463 | break;
|
1464 | }
|
1465 | }
|
1466 | }
|
1467 | };
|
1468 |
|
1469 | QRCode.PAD0 = 0xEC;
|
1470 | QRCode.PAD1 = 0x11;
|
1471 |
|
1472 | QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) {
|
1473 |
|
1474 | var rsBlocks = RSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
|
1475 |
|
1476 | var buffer = new BitBuffer();
|
1477 |
|
1478 | for (var i = 0; i < dataList.length; i++) {
|
1479 | var data = dataList[i];
|
1480 | buffer.put(data.mode, 4);
|
1481 | buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber) );
|
1482 | data.write(buffer);
|
1483 | }
|
1484 |
|
1485 |
|
1486 | var totalDataCount = 0;
|
1487 | for (var i = 0; i < rsBlocks.length; i++) {
|
1488 | totalDataCount += rsBlocks[i].dataCount;
|
1489 | }
|
1490 |
|
1491 | if (buffer.getLengthInBits() > totalDataCount * 8) {
|
1492 | throw new Error("code length overflow. ("
|
1493 | + buffer.getLengthInBits()
|
1494 | + ">"
|
1495 | + totalDataCount * 8
|
1496 | + ")");
|
1497 | }
|
1498 |
|
1499 |
|
1500 | if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
|
1501 | buffer.put(0, 4);
|
1502 | }
|
1503 |
|
1504 |
|
1505 | while (buffer.getLengthInBits() % 8 != 0) {
|
1506 | buffer.putBit(false);
|
1507 | }
|
1508 |
|
1509 |
|
1510 | while (true) {
|
1511 |
|
1512 | if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
1513 | break;
|
1514 | }
|
1515 | buffer.put(QRCode.PAD0, 8);
|
1516 |
|
1517 | if (buffer.getLengthInBits() >= totalDataCount * 8) {
|
1518 | break;
|
1519 | }
|
1520 | buffer.put(QRCode.PAD1, 8);
|
1521 | }
|
1522 |
|
1523 | return QRCode.createBytes(buffer, rsBlocks);
|
1524 | };
|
1525 |
|
1526 | QRCode.createBytes = function(buffer, rsBlocks) {
|
1527 |
|
1528 | var offset = 0;
|
1529 |
|
1530 | var maxDcCount = 0;
|
1531 | var maxEcCount = 0;
|
1532 |
|
1533 | var dcdata = new Array(rsBlocks.length);
|
1534 | var ecdata = new Array(rsBlocks.length);
|
1535 |
|
1536 | for (var r = 0; r < rsBlocks.length; r++) {
|
1537 |
|
1538 | var dcCount = rsBlocks[r].dataCount;
|
1539 | var ecCount = rsBlocks[r].totalCount - dcCount;
|
1540 |
|
1541 | maxDcCount = Math.max(maxDcCount, dcCount);
|
1542 | maxEcCount = Math.max(maxEcCount, ecCount);
|
1543 |
|
1544 | dcdata[r] = new Array(dcCount);
|
1545 |
|
1546 | for (var i = 0; i < dcdata[r].length; i++) {
|
1547 | dcdata[r][i] = 0xff & buffer.buffer[i + offset];
|
1548 | }
|
1549 | offset += dcCount;
|
1550 |
|
1551 | var rsPoly = util.getErrorCorrectPolynomial(ecCount);
|
1552 | var rawPoly = new Polynomial(dcdata[r], rsPoly.getLength() - 1);
|
1553 |
|
1554 | var modPoly = rawPoly.mod(rsPoly);
|
1555 | ecdata[r] = new Array(rsPoly.getLength() - 1);
|
1556 | for (var i = 0; i < ecdata[r].length; i++) {
|
1557 | var modIndex = i + modPoly.getLength() - ecdata[r].length;
|
1558 | ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
|
1559 | }
|
1560 |
|
1561 | }
|
1562 |
|
1563 | var totalCodeCount = 0;
|
1564 | for (var i = 0; i < rsBlocks.length; i++) {
|
1565 | totalCodeCount += rsBlocks[i].totalCount;
|
1566 | }
|
1567 |
|
1568 | var data = new Array(totalCodeCount);
|
1569 | var index = 0;
|
1570 |
|
1571 | for (var i = 0; i < maxDcCount; i++) {
|
1572 | for (var r = 0; r < rsBlocks.length; r++) {
|
1573 | if (i < dcdata[r].length) {
|
1574 | data[index++] = dcdata[r][i];
|
1575 | }
|
1576 | }
|
1577 | }
|
1578 |
|
1579 | for (var i = 0; i < maxEcCount; i++) {
|
1580 | for (var r = 0; r < rsBlocks.length; r++) {
|
1581 | if (i < ecdata[r].length) {
|
1582 | data[index++] = ecdata[r][i];
|
1583 | }
|
1584 | }
|
1585 | }
|
1586 |
|
1587 | return data;
|
1588 | };
|
1589 |
|
1590 | module.exports = QRCode;
|
1591 |
|
1592 |
|
1593 |
|
1594 | }),
|
1595 |
|
1596 | "../../node_modules/qr.js/lib/RSBlock.js":
|
1597 |
|
1598 |
|
1599 |
|
1600 |
|
1601 | (function(module, exports, __webpack_require__) {
|
1602 |
|
1603 |
|
1604 | var ECL = __webpack_require__( "../../node_modules/qr.js/lib/ErrorCorrectLevel.js");
|
1605 |
|
1606 | function QRRSBlock(totalCount, dataCount) {
|
1607 | this.totalCount = totalCount;
|
1608 | this.dataCount = dataCount;
|
1609 | }
|
1610 |
|
1611 | QRRSBlock.RS_BLOCK_TABLE = [
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 | [1, 26, 19],
|
1620 | [1, 26, 16],
|
1621 | [1, 26, 13],
|
1622 | [1, 26, 9],
|
1623 |
|
1624 |
|
1625 | [1, 44, 34],
|
1626 | [1, 44, 28],
|
1627 | [1, 44, 22],
|
1628 | [1, 44, 16],
|
1629 |
|
1630 |
|
1631 | [1, 70, 55],
|
1632 | [1, 70, 44],
|
1633 | [2, 35, 17],
|
1634 | [2, 35, 13],
|
1635 |
|
1636 |
|
1637 | [1, 100, 80],
|
1638 | [2, 50, 32],
|
1639 | [2, 50, 24],
|
1640 | [4, 25, 9],
|
1641 |
|
1642 |
|
1643 | [1, 134, 108],
|
1644 | [2, 67, 43],
|
1645 | [2, 33, 15, 2, 34, 16],
|
1646 | [2, 33, 11, 2, 34, 12],
|
1647 |
|
1648 |
|
1649 | [2, 86, 68],
|
1650 | [4, 43, 27],
|
1651 | [4, 43, 19],
|
1652 | [4, 43, 15],
|
1653 |
|
1654 |
|
1655 | [2, 98, 78],
|
1656 | [4, 49, 31],
|
1657 | [2, 32, 14, 4, 33, 15],
|
1658 | [4, 39, 13, 1, 40, 14],
|
1659 |
|
1660 |
|
1661 | [2, 121, 97],
|
1662 | [2, 60, 38, 2, 61, 39],
|
1663 | [4, 40, 18, 2, 41, 19],
|
1664 | [4, 40, 14, 2, 41, 15],
|
1665 |
|
1666 |
|
1667 | [2, 146, 116],
|
1668 | [3, 58, 36, 2, 59, 37],
|
1669 | [4, 36, 16, 4, 37, 17],
|
1670 | [4, 36, 12, 4, 37, 13],
|
1671 |
|
1672 |
|
1673 | [2, 86, 68, 2, 87, 69],
|
1674 | [4, 69, 43, 1, 70, 44],
|
1675 | [6, 43, 19, 2, 44, 20],
|
1676 | [6, 43, 15, 2, 44, 16],
|
1677 |
|
1678 |
|
1679 | [4, 101, 81],
|
1680 | [1, 80, 50, 4, 81, 51],
|
1681 | [4, 50, 22, 4, 51, 23],
|
1682 | [3, 36, 12, 8, 37, 13],
|
1683 |
|
1684 |
|
1685 | [2, 116, 92, 2, 117, 93],
|
1686 | [6, 58, 36, 2, 59, 37],
|
1687 | [4, 46, 20, 6, 47, 21],
|
1688 | [7, 42, 14, 4, 43, 15],
|
1689 |
|
1690 |
|
1691 | [4, 133, 107],
|
1692 | [8, 59, 37, 1, 60, 38],
|
1693 | [8, 44, 20, 4, 45, 21],
|
1694 | [12, 33, 11, 4, 34, 12],
|
1695 |
|
1696 |
|
1697 | [3, 145, 115, 1, 146, 116],
|
1698 | [4, 64, 40, 5, 65, 41],
|
1699 | [11, 36, 16, 5, 37, 17],
|
1700 | [11, 36, 12, 5, 37, 13],
|
1701 |
|
1702 |
|
1703 | [5, 109, 87, 1, 110, 88],
|
1704 | [5, 65, 41, 5, 66, 42],
|
1705 | [5, 54, 24, 7, 55, 25],
|
1706 | [11, 36, 12],
|
1707 |
|
1708 |
|
1709 | [5, 122, 98, 1, 123, 99],
|
1710 | [7, 73, 45, 3, 74, 46],
|
1711 | [15, 43, 19, 2, 44, 20],
|
1712 | [3, 45, 15, 13, 46, 16],
|
1713 |
|
1714 |
|
1715 | [1, 135, 107, 5, 136, 108],
|
1716 | [10, 74, 46, 1, 75, 47],
|
1717 | [1, 50, 22, 15, 51, 23],
|
1718 | [2, 42, 14, 17, 43, 15],
|
1719 |
|
1720 |
|
1721 | [5, 150, 120, 1, 151, 121],
|
1722 | [9, 69, 43, 4, 70, 44],
|
1723 | [17, 50, 22, 1, 51, 23],
|
1724 | [2, 42, 14, 19, 43, 15],
|
1725 |
|
1726 |
|
1727 | [3, 141, 113, 4, 142, 114],
|
1728 | [3, 70, 44, 11, 71, 45],
|
1729 | [17, 47, 21, 4, 48, 22],
|
1730 | [9, 39, 13, 16, 40, 14],
|
1731 |
|
1732 |
|
1733 | [3, 135, 107, 5, 136, 108],
|
1734 | [3, 67, 41, 13, 68, 42],
|
1735 | [15, 54, 24, 5, 55, 25],
|
1736 | [15, 43, 15, 10, 44, 16],
|
1737 |
|
1738 |
|
1739 | [4, 144, 116, 4, 145, 117],
|
1740 | [17, 68, 42],
|
1741 | [17, 50, 22, 6, 51, 23],
|
1742 | [19, 46, 16, 6, 47, 17],
|
1743 |
|
1744 |
|
1745 | [2, 139, 111, 7, 140, 112],
|
1746 | [17, 74, 46],
|
1747 | [7, 54, 24, 16, 55, 25],
|
1748 | [34, 37, 13],
|
1749 |
|
1750 |
|
1751 | [4, 151, 121, 5, 152, 122],
|
1752 | [4, 75, 47, 14, 76, 48],
|
1753 | [11, 54, 24, 14, 55, 25],
|
1754 | [16, 45, 15, 14, 46, 16],
|
1755 |
|
1756 |
|
1757 | [6, 147, 117, 4, 148, 118],
|
1758 | [6, 73, 45, 14, 74, 46],
|
1759 | [11, 54, 24, 16, 55, 25],
|
1760 | [30, 46, 16, 2, 47, 17],
|
1761 |
|
1762 |
|
1763 | [8, 132, 106, 4, 133, 107],
|
1764 | [8, 75, 47, 13, 76, 48],
|
1765 | [7, 54, 24, 22, 55, 25],
|
1766 | [22, 45, 15, 13, 46, 16],
|
1767 |
|
1768 |
|
1769 | [10, 142, 114, 2, 143, 115],
|
1770 | [19, 74, 46, 4, 75, 47],
|
1771 | [28, 50, 22, 6, 51, 23],
|
1772 | [33, 46, 16, 4, 47, 17],
|
1773 |
|
1774 |
|
1775 | [8, 152, 122, 4, 153, 123],
|
1776 | [22, 73, 45, 3, 74, 46],
|
1777 | [8, 53, 23, 26, 54, 24],
|
1778 | [12, 45, 15, 28, 46, 16],
|
1779 |
|
1780 |
|
1781 | [3, 147, 117, 10, 148, 118],
|
1782 | [3, 73, 45, 23, 74, 46],
|
1783 | [4, 54, 24, 31, 55, 25],
|
1784 | [11, 45, 15, 31, 46, 16],
|
1785 |
|
1786 |
|
1787 | [7, 146, 116, 7, 147, 117],
|
1788 | [21, 73, 45, 7, 74, 46],
|
1789 | [1, 53, 23, 37, 54, 24],
|
1790 | [19, 45, 15, 26, 46, 16],
|
1791 |
|
1792 |
|
1793 | [5, 145, 115, 10, 146, 116],
|
1794 | [19, 75, 47, 10, 76, 48],
|
1795 | [15, 54, 24, 25, 55, 25],
|
1796 | [23, 45, 15, 25, 46, 16],
|
1797 |
|
1798 |
|
1799 | [13, 145, 115, 3, 146, 116],
|
1800 | [2, 74, 46, 29, 75, 47],
|
1801 | [42, 54, 24, 1, 55, 25],
|
1802 | [23, 45, 15, 28, 46, 16],
|
1803 |
|
1804 |
|
1805 | [17, 145, 115],
|
1806 | [10, 74, 46, 23, 75, 47],
|
1807 | [10, 54, 24, 35, 55, 25],
|
1808 | [19, 45, 15, 35, 46, 16],
|
1809 |
|
1810 |
|
1811 | [17, 145, 115, 1, 146, 116],
|
1812 | [14, 74, 46, 21, 75, 47],
|
1813 | [29, 54, 24, 19, 55, 25],
|
1814 | [11, 45, 15, 46, 46, 16],
|
1815 |
|
1816 |
|
1817 | [13, 145, 115, 6, 146, 116],
|
1818 | [14, 74, 46, 23, 75, 47],
|
1819 | [44, 54, 24, 7, 55, 25],
|
1820 | [59, 46, 16, 1, 47, 17],
|
1821 |
|
1822 |
|
1823 | [12, 151, 121, 7, 152, 122],
|
1824 | [12, 75, 47, 26, 76, 48],
|
1825 | [39, 54, 24, 14, 55, 25],
|
1826 | [22, 45, 15, 41, 46, 16],
|
1827 |
|
1828 |
|
1829 | [6, 151, 121, 14, 152, 122],
|
1830 | [6, 75, 47, 34, 76, 48],
|
1831 | [46, 54, 24, 10, 55, 25],
|
1832 | [2, 45, 15, 64, 46, 16],
|
1833 |
|
1834 |
|
1835 | [17, 152, 122, 4, 153, 123],
|
1836 | [29, 74, 46, 14, 75, 47],
|
1837 | [49, 54, 24, 10, 55, 25],
|
1838 | [24, 45, 15, 46, 46, 16],
|
1839 |
|
1840 |
|
1841 | [4, 152, 122, 18, 153, 123],
|
1842 | [13, 74, 46, 32, 75, 47],
|
1843 | [48, 54, 24, 14, 55, 25],
|
1844 | [42, 45, 15, 32, 46, 16],
|
1845 |
|
1846 |
|
1847 | [20, 147, 117, 4, 148, 118],
|
1848 | [40, 75, 47, 7, 76, 48],
|
1849 | [43, 54, 24, 22, 55, 25],
|
1850 | [10, 45, 15, 67, 46, 16],
|
1851 |
|
1852 |
|
1853 | [19, 148, 118, 6, 149, 119],
|
1854 | [18, 75, 47, 31, 76, 48],
|
1855 | [34, 54, 24, 34, 55, 25],
|
1856 | [20, 45, 15, 61, 46, 16]
|
1857 | ];
|
1858 |
|
1859 | QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
|
1860 |
|
1861 | var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
|
1862 |
|
1863 | if (rsBlock == undefined) {
|
1864 | throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
|
1865 | }
|
1866 |
|
1867 | var length = rsBlock.length / 3;
|
1868 |
|
1869 | var list = new Array();
|
1870 |
|
1871 | for (var i = 0; i < length; i++) {
|
1872 |
|
1873 | var count = rsBlock[i * 3 + 0];
|
1874 | var totalCount = rsBlock[i * 3 + 1];
|
1875 | var dataCount = rsBlock[i * 3 + 2];
|
1876 |
|
1877 | for (var j = 0; j < count; j++) {
|
1878 | list.push(new QRRSBlock(totalCount, dataCount) );
|
1879 | }
|
1880 | }
|
1881 |
|
1882 | return list;
|
1883 | }
|
1884 |
|
1885 | QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
|
1886 |
|
1887 | switch(errorCorrectLevel) {
|
1888 | case ECL.L :
|
1889 | return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
|
1890 | case ECL.M :
|
1891 | return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
|
1892 | case ECL.Q :
|
1893 | return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
|
1894 | case ECL.H :
|
1895 | return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
|
1896 | default :
|
1897 | return undefined;
|
1898 | }
|
1899 | }
|
1900 |
|
1901 | module.exports = QRRSBlock;
|
1902 |
|
1903 |
|
1904 | }),
|
1905 |
|
1906 | "../../node_modules/qr.js/lib/math.js":
|
1907 |
|
1908 |
|
1909 |
|
1910 |
|
1911 | (function(module, exports) {
|
1912 |
|
1913 | var QRMath = {
|
1914 |
|
1915 | glog : function(n) {
|
1916 |
|
1917 | if (n < 1) {
|
1918 | throw new Error("glog(" + n + ")");
|
1919 | }
|
1920 |
|
1921 | return QRMath.LOG_TABLE[n];
|
1922 | },
|
1923 |
|
1924 | gexp : function(n) {
|
1925 |
|
1926 | while (n < 0) {
|
1927 | n += 255;
|
1928 | }
|
1929 |
|
1930 | while (n >= 256) {
|
1931 | n -= 255;
|
1932 | }
|
1933 |
|
1934 | return QRMath.EXP_TABLE[n];
|
1935 | },
|
1936 |
|
1937 | EXP_TABLE : new Array(256),
|
1938 |
|
1939 | LOG_TABLE : new Array(256)
|
1940 |
|
1941 | };
|
1942 |
|
1943 | for (var i = 0; i < 8; i++) {
|
1944 | QRMath.EXP_TABLE[i] = 1 << i;
|
1945 | }
|
1946 | for (var i = 8; i < 256; i++) {
|
1947 | QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4]
|
1948 | ^ QRMath.EXP_TABLE[i - 5]
|
1949 | ^ QRMath.EXP_TABLE[i - 6]
|
1950 | ^ QRMath.EXP_TABLE[i - 8];
|
1951 | }
|
1952 | for (var i = 0; i < 255; i++) {
|
1953 | QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i;
|
1954 | }
|
1955 |
|
1956 | module.exports = QRMath;
|
1957 |
|
1958 |
|
1959 | }),
|
1960 |
|
1961 | "../../node_modules/qr.js/lib/mode.js":
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 | (function(module, exports) {
|
1967 |
|
1968 | module.exports = {
|
1969 | MODE_NUMBER : 1 << 0,
|
1970 | MODE_ALPHA_NUM : 1 << 1,
|
1971 | MODE_8BIT_BYTE : 1 << 2,
|
1972 | MODE_KANJI : 1 << 3
|
1973 | };
|
1974 |
|
1975 |
|
1976 | }),
|
1977 |
|
1978 | "../../node_modules/qr.js/lib/util.js":
|
1979 |
|
1980 |
|
1981 |
|
1982 |
|
1983 | (function(module, exports, __webpack_require__) {
|
1984 |
|
1985 | var Mode = __webpack_require__( "../../node_modules/qr.js/lib/mode.js");
|
1986 | var Polynomial = __webpack_require__( "../../node_modules/qr.js/lib/Polynomial.js");
|
1987 | var math = __webpack_require__( "../../node_modules/qr.js/lib/math.js");
|
1988 |
|
1989 | var QRMaskPattern = {
|
1990 | PATTERN000 : 0,
|
1991 | PATTERN001 : 1,
|
1992 | PATTERN010 : 2,
|
1993 | PATTERN011 : 3,
|
1994 | PATTERN100 : 4,
|
1995 | PATTERN101 : 5,
|
1996 | PATTERN110 : 6,
|
1997 | PATTERN111 : 7
|
1998 | };
|
1999 |
|
2000 | var QRUtil = {
|
2001 |
|
2002 | PATTERN_POSITION_TABLE : [
|
2003 | [],
|
2004 | [6, 18],
|
2005 | [6, 22],
|
2006 | [6, 26],
|
2007 | [6, 30],
|
2008 | [6, 34],
|
2009 | [6, 22, 38],
|
2010 | [6, 24, 42],
|
2011 | [6, 26, 46],
|
2012 | [6, 28, 50],
|
2013 | [6, 30, 54],
|
2014 | [6, 32, 58],
|
2015 | [6, 34, 62],
|
2016 | [6, 26, 46, 66],
|
2017 | [6, 26, 48, 70],
|
2018 | [6, 26, 50, 74],
|
2019 | [6, 30, 54, 78],
|
2020 | [6, 30, 56, 82],
|
2021 | [6, 30, 58, 86],
|
2022 | [6, 34, 62, 90],
|
2023 | [6, 28, 50, 72, 94],
|
2024 | [6, 26, 50, 74, 98],
|
2025 | [6, 30, 54, 78, 102],
|
2026 | [6, 28, 54, 80, 106],
|
2027 | [6, 32, 58, 84, 110],
|
2028 | [6, 30, 58, 86, 114],
|
2029 | [6, 34, 62, 90, 118],
|
2030 | [6, 26, 50, 74, 98, 122],
|
2031 | [6, 30, 54, 78, 102, 126],
|
2032 | [6, 26, 52, 78, 104, 130],
|
2033 | [6, 30, 56, 82, 108, 134],
|
2034 | [6, 34, 60, 86, 112, 138],
|
2035 | [6, 30, 58, 86, 114, 142],
|
2036 | [6, 34, 62, 90, 118, 146],
|
2037 | [6, 30, 54, 78, 102, 126, 150],
|
2038 | [6, 24, 50, 76, 102, 128, 154],
|
2039 | [6, 28, 54, 80, 106, 132, 158],
|
2040 | [6, 32, 58, 84, 110, 136, 162],
|
2041 | [6, 26, 54, 82, 110, 138, 166],
|
2042 | [6, 30, 58, 86, 114, 142, 170]
|
2043 | ],
|
2044 |
|
2045 | G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
|
2046 | G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
|
2047 | G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
|
2048 |
|
2049 | getBCHTypeInfo : function(data) {
|
2050 | var d = data << 10;
|
2051 | while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
|
2052 | d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) );
|
2053 | }
|
2054 | return ( (data << 10) | d) ^ QRUtil.G15_MASK;
|
2055 | },
|
2056 |
|
2057 | getBCHTypeNumber : function(data) {
|
2058 | var d = data << 12;
|
2059 | while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
2060 | d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) );
|
2061 | }
|
2062 | return (data << 12) | d;
|
2063 | },
|
2064 |
|
2065 | getBCHDigit : function(data) {
|
2066 |
|
2067 | var digit = 0;
|
2068 |
|
2069 | while (data != 0) {
|
2070 | digit++;
|
2071 | data >>>= 1;
|
2072 | }
|
2073 |
|
2074 | return digit;
|
2075 | },
|
2076 |
|
2077 | getPatternPosition : function(typeNumber) {
|
2078 | return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
2079 | },
|
2080 |
|
2081 | getMask : function(maskPattern, i, j) {
|
2082 |
|
2083 | switch (maskPattern) {
|
2084 |
|
2085 | case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0;
|
2086 | case QRMaskPattern.PATTERN001 : return i % 2 == 0;
|
2087 | case QRMaskPattern.PATTERN010 : return j % 3 == 0;
|
2088 | case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0;
|
2089 | case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0;
|
2090 | case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0;
|
2091 | case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0;
|
2092 | case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0;
|
2093 |
|
2094 | default :
|
2095 | throw new Error("bad maskPattern:" + maskPattern);
|
2096 | }
|
2097 | },
|
2098 |
|
2099 | getErrorCorrectPolynomial : function(errorCorrectLength) {
|
2100 |
|
2101 | var a = new Polynomial([1], 0);
|
2102 |
|
2103 | for (var i = 0; i < errorCorrectLength; i++) {
|
2104 | a = a.multiply(new Polynomial([1, math.gexp(i)], 0) );
|
2105 | }
|
2106 |
|
2107 | return a;
|
2108 | },
|
2109 |
|
2110 | getLengthInBits : function(mode, type) {
|
2111 |
|
2112 | if (1 <= type && type < 10) {
|
2113 |
|
2114 |
|
2115 |
|
2116 | switch(mode) {
|
2117 | case Mode.MODE_NUMBER : return 10;
|
2118 | case Mode.MODE_ALPHA_NUM : return 9;
|
2119 | case Mode.MODE_8BIT_BYTE : return 8;
|
2120 | case Mode.MODE_KANJI : return 8;
|
2121 | default :
|
2122 | throw new Error("mode:" + mode);
|
2123 | }
|
2124 |
|
2125 | } else if (type < 27) {
|
2126 |
|
2127 |
|
2128 |
|
2129 | switch(mode) {
|
2130 | case Mode.MODE_NUMBER : return 12;
|
2131 | case Mode.MODE_ALPHA_NUM : return 11;
|
2132 | case Mode.MODE_8BIT_BYTE : return 16;
|
2133 | case Mode.MODE_KANJI : return 10;
|
2134 | default :
|
2135 | throw new Error("mode:" + mode);
|
2136 | }
|
2137 |
|
2138 | } else if (type < 41) {
|
2139 |
|
2140 |
|
2141 |
|
2142 | switch(mode) {
|
2143 | case Mode.MODE_NUMBER : return 14;
|
2144 | case Mode.MODE_ALPHA_NUM : return 13;
|
2145 | case Mode.MODE_8BIT_BYTE : return 16;
|
2146 | case Mode.MODE_KANJI : return 12;
|
2147 | default :
|
2148 | throw new Error("mode:" + mode);
|
2149 | }
|
2150 |
|
2151 | } else {
|
2152 | throw new Error("type:" + type);
|
2153 | }
|
2154 | },
|
2155 |
|
2156 | getLostPoint : function(qrCode) {
|
2157 |
|
2158 | var moduleCount = qrCode.getModuleCount();
|
2159 |
|
2160 | var lostPoint = 0;
|
2161 |
|
2162 |
|
2163 |
|
2164 | for (var row = 0; row < moduleCount; row++) {
|
2165 |
|
2166 | for (var col = 0; col < moduleCount; col++) {
|
2167 |
|
2168 | var sameCount = 0;
|
2169 | var dark = qrCode.isDark(row, col);
|
2170 |
|
2171 | for (var r = -1; r <= 1; r++) {
|
2172 |
|
2173 | if (row + r < 0 || moduleCount <= row + r) {
|
2174 | continue;
|
2175 | }
|
2176 |
|
2177 | for (var c = -1; c <= 1; c++) {
|
2178 |
|
2179 | if (col + c < 0 || moduleCount <= col + c) {
|
2180 | continue;
|
2181 | }
|
2182 |
|
2183 | if (r == 0 && c == 0) {
|
2184 | continue;
|
2185 | }
|
2186 |
|
2187 | if (dark == qrCode.isDark(row + r, col + c) ) {
|
2188 | sameCount++;
|
2189 | }
|
2190 | }
|
2191 | }
|
2192 |
|
2193 | if (sameCount > 5) {
|
2194 | lostPoint += (3 + sameCount - 5);
|
2195 | }
|
2196 | }
|
2197 | }
|
2198 |
|
2199 |
|
2200 |
|
2201 | for (var row = 0; row < moduleCount - 1; row++) {
|
2202 | for (var col = 0; col < moduleCount - 1; col++) {
|
2203 | var count = 0;
|
2204 | if (qrCode.isDark(row, col ) ) count++;
|
2205 | if (qrCode.isDark(row + 1, col ) ) count++;
|
2206 | if (qrCode.isDark(row, col + 1) ) count++;
|
2207 | if (qrCode.isDark(row + 1, col + 1) ) count++;
|
2208 | if (count == 0 || count == 4) {
|
2209 | lostPoint += 3;
|
2210 | }
|
2211 | }
|
2212 | }
|
2213 |
|
2214 |
|
2215 |
|
2216 | for (var row = 0; row < moduleCount; row++) {
|
2217 | for (var col = 0; col < moduleCount - 6; col++) {
|
2218 | if (qrCode.isDark(row, col)
|
2219 | && !qrCode.isDark(row, col + 1)
|
2220 | && qrCode.isDark(row, col + 2)
|
2221 | && qrCode.isDark(row, col + 3)
|
2222 | && qrCode.isDark(row, col + 4)
|
2223 | && !qrCode.isDark(row, col + 5)
|
2224 | && qrCode.isDark(row, col + 6) ) {
|
2225 | lostPoint += 40;
|
2226 | }
|
2227 | }
|
2228 | }
|
2229 |
|
2230 | for (var col = 0; col < moduleCount; col++) {
|
2231 | for (var row = 0; row < moduleCount - 6; row++) {
|
2232 | if (qrCode.isDark(row, col)
|
2233 | && !qrCode.isDark(row + 1, col)
|
2234 | && qrCode.isDark(row + 2, col)
|
2235 | && qrCode.isDark(row + 3, col)
|
2236 | && qrCode.isDark(row + 4, col)
|
2237 | && !qrCode.isDark(row + 5, col)
|
2238 | && qrCode.isDark(row + 6, col) ) {
|
2239 | lostPoint += 40;
|
2240 | }
|
2241 | }
|
2242 | }
|
2243 |
|
2244 |
|
2245 |
|
2246 | var darkCount = 0;
|
2247 |
|
2248 | for (var col = 0; col < moduleCount; col++) {
|
2249 | for (var row = 0; row < moduleCount; row++) {
|
2250 | if (qrCode.isDark(row, col) ) {
|
2251 | darkCount++;
|
2252 | }
|
2253 | }
|
2254 | }
|
2255 |
|
2256 | var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
|
2257 | lostPoint += ratio * 10;
|
2258 |
|
2259 | return lostPoint;
|
2260 | }
|
2261 | };
|
2262 |
|
2263 | module.exports = QRUtil;
|
2264 |
|
2265 |
|
2266 | }),
|
2267 |
|
2268 | "../../node_modules/qrcode.react/lib/index.js":
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 | (function(module, exports, __webpack_require__) {
|
2274 |
|
2275 | "use strict";
|
2276 |
|
2277 |
|
2278 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
2279 |
|
2280 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2281 |
|
2282 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
2283 |
|
2284 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2285 |
|
2286 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
2287 |
|
2288 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
2289 |
|
2290 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
2291 |
|
2292 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
2293 |
|
2294 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
2295 |
|
2296 | var React = __webpack_require__( "react");
|
2297 |
|
2298 | var PropTypes = __webpack_require__( "../../node_modules/prop-types/index.js");
|
2299 |
|
2300 |
|
2301 |
|
2302 | var QRCodeImpl = __webpack_require__( "../../node_modules/qr.js/lib/QRCode.js");
|
2303 |
|
2304 | var ErrorCorrectLevel = __webpack_require__( "../../node_modules/qr.js/lib/ErrorCorrectLevel.js");
|
2305 |
|
2306 | function getBackingStorePixelRatio(ctx) {
|
2307 | return (
|
2308 | ctx.webkitBackingStorePixelRatio ||
|
2309 | ctx.mozBackingStorePixelRatio ||
|
2310 | ctx.msBackingStorePixelRatio ||
|
2311 | ctx.oBackingStorePixelRatio ||
|
2312 | ctx.backingStorePixelRatio || 1
|
2313 | );
|
2314 | }
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 | function convertStr(str) {
|
2322 | var out = '';
|
2323 |
|
2324 | for (var i = 0; i < str.length; i++) {
|
2325 | var charcode = str.charCodeAt(i);
|
2326 |
|
2327 | if (charcode < 0x0080) {
|
2328 | out += String.fromCharCode(charcode);
|
2329 | } else if (charcode < 0x0800) {
|
2330 | out += String.fromCharCode(0xc0 | charcode >> 6);
|
2331 | out += String.fromCharCode(0x80 | charcode & 0x3f);
|
2332 | } else if (charcode < 0xd800 || charcode >= 0xe000) {
|
2333 | out += String.fromCharCode(0xe0 | charcode >> 12);
|
2334 | out += String.fromCharCode(0x80 | charcode >> 6 & 0x3f);
|
2335 | out += String.fromCharCode(0x80 | charcode & 0x3f);
|
2336 | } else {
|
2337 |
|
2338 |
|
2339 | i++;
|
2340 | charcode = 0x10000 + ((charcode & 0x3ff) << 10 | str.charCodeAt(i) & 0x3ff);
|
2341 | out += String.fromCharCode(0xf0 | charcode >> 18);
|
2342 | out += String.fromCharCode(0x80 | charcode >> 12 & 0x3f);
|
2343 | out += String.fromCharCode(0x80 | charcode >> 6 & 0x3f);
|
2344 | out += String.fromCharCode(0x80 | charcode & 0x3f);
|
2345 | }
|
2346 | }
|
2347 |
|
2348 | return out;
|
2349 | }
|
2350 |
|
2351 | var DEFAULT_PROPS = {
|
2352 | size: 128,
|
2353 | level: 'L',
|
2354 | bgColor: '#FFFFFF',
|
2355 | fgColor: '#000000'
|
2356 | };
|
2357 | var PROP_TYPES = {
|
2358 | value: PropTypes.string.isRequired,
|
2359 | size: PropTypes.number,
|
2360 | level: PropTypes.oneOf(['L', 'M', 'Q', 'H']),
|
2361 | bgColor: PropTypes.string,
|
2362 | fgColor: PropTypes.string
|
2363 | };
|
2364 |
|
2365 | var QRCodeCanvas =
|
2366 |
|
2367 | function (_React$Component) {
|
2368 | _inherits(QRCodeCanvas, _React$Component);
|
2369 |
|
2370 | function QRCodeCanvas() {
|
2371 | var _ref;
|
2372 |
|
2373 | var _temp, _this;
|
2374 |
|
2375 | _classCallCheck(this, QRCodeCanvas);
|
2376 |
|
2377 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
2378 | args[_key] = arguments[_key];
|
2379 | }
|
2380 |
|
2381 | return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = QRCodeCanvas.__proto__ || Object.getPrototypeOf(QRCodeCanvas)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "_canvas", {
|
2382 | configurable: true,
|
2383 | enumerable: true,
|
2384 | writable: true,
|
2385 | value: void 0
|
2386 | }), _temp));
|
2387 | }
|
2388 |
|
2389 | _createClass(QRCodeCanvas, [{
|
2390 | key: "shouldComponentUpdate",
|
2391 | value: function shouldComponentUpdate(nextProps) {
|
2392 | var _this2 = this;
|
2393 |
|
2394 | return Object.keys(QRCodeCanvas.propTypes).some(function (k) {
|
2395 | return _this2.props[k] !== nextProps[k];
|
2396 | });
|
2397 | }
|
2398 | }, {
|
2399 | key: "componentDidMount",
|
2400 | value: function componentDidMount() {
|
2401 | this.update();
|
2402 | }
|
2403 | }, {
|
2404 | key: "componentDidUpdate",
|
2405 | value: function componentDidUpdate() {
|
2406 | this.update();
|
2407 | }
|
2408 | }, {
|
2409 | key: "update",
|
2410 | value: function update() {
|
2411 | var _props = this.props,
|
2412 | value = _props.value,
|
2413 | size = _props.size,
|
2414 | level = _props.level,
|
2415 | bgColor = _props.bgColor,
|
2416 | fgColor = _props.fgColor;
|
2417 |
|
2418 | var qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[level]);
|
2419 | qrcode.addData(convertStr(value));
|
2420 | qrcode.make();
|
2421 |
|
2422 | if (this._canvas != null) {
|
2423 | var canvas = this._canvas;
|
2424 | var ctx = canvas.getContext('2d');
|
2425 |
|
2426 | if (!ctx) {
|
2427 | return;
|
2428 | }
|
2429 |
|
2430 | var cells = qrcode.modules;
|
2431 |
|
2432 | if (cells === null) {
|
2433 | return;
|
2434 | }
|
2435 |
|
2436 | var tileW = size / cells.length;
|
2437 | var tileH = size / cells.length;
|
2438 | var scale = (window.devicePixelRatio || 1) / getBackingStorePixelRatio(ctx);
|
2439 | canvas.height = canvas.width = size * scale;
|
2440 | ctx.scale(scale, scale);
|
2441 | cells.forEach(function (row, rdx) {
|
2442 | row.forEach(function (cell, cdx) {
|
2443 | ctx && (ctx.fillStyle = cell ? fgColor : bgColor);
|
2444 | var w = Math.ceil((cdx + 1) * tileW) - Math.floor(cdx * tileW);
|
2445 | var h = Math.ceil((rdx + 1) * tileH) - Math.floor(rdx * tileH);
|
2446 | ctx && ctx.fillRect(Math.round(cdx * tileW), Math.round(rdx * tileH), w, h);
|
2447 | });
|
2448 | });
|
2449 | }
|
2450 | }
|
2451 | }, {
|
2452 | key: "render",
|
2453 | value: function render() {
|
2454 | var _this3 = this;
|
2455 |
|
2456 | var _props2 = this.props,
|
2457 | value = _props2.value,
|
2458 | size = _props2.size,
|
2459 | level = _props2.level,
|
2460 | bgColor = _props2.bgColor,
|
2461 | fgColor = _props2.fgColor,
|
2462 | style = _props2.style,
|
2463 | otherProps = _objectWithoutProperties(_props2, ["value", "size", "level", "bgColor", "fgColor", "style"]);
|
2464 |
|
2465 | var canvasStyle = _extends({
|
2466 | height: size,
|
2467 | width: size
|
2468 | }, style);
|
2469 |
|
2470 | return React.createElement("canvas", _extends({
|
2471 | style: canvasStyle,
|
2472 | height: size,
|
2473 | width: size,
|
2474 | ref: function ref(_ref2) {
|
2475 | return _this3._canvas = _ref2;
|
2476 | }
|
2477 | }, otherProps));
|
2478 | }
|
2479 | }]);
|
2480 |
|
2481 | return QRCodeCanvas;
|
2482 | }(React.Component);
|
2483 |
|
2484 | Object.defineProperty(QRCodeCanvas, "defaultProps", {
|
2485 | configurable: true,
|
2486 | enumerable: true,
|
2487 | writable: true,
|
2488 | value: DEFAULT_PROPS
|
2489 | });
|
2490 | Object.defineProperty(QRCodeCanvas, "propTypes", {
|
2491 | configurable: true,
|
2492 | enumerable: true,
|
2493 | writable: true,
|
2494 | value: PROP_TYPES
|
2495 | });
|
2496 |
|
2497 | var QRCodeSVG =
|
2498 |
|
2499 | function (_React$Component2) {
|
2500 | _inherits(QRCodeSVG, _React$Component2);
|
2501 |
|
2502 | function QRCodeSVG() {
|
2503 | _classCallCheck(this, QRCodeSVG);
|
2504 |
|
2505 | return _possibleConstructorReturn(this, (QRCodeSVG.__proto__ || Object.getPrototypeOf(QRCodeSVG)).apply(this, arguments));
|
2506 | }
|
2507 |
|
2508 | _createClass(QRCodeSVG, [{
|
2509 | key: "shouldComponentUpdate",
|
2510 | value: function shouldComponentUpdate(nextProps) {
|
2511 | var _this4 = this;
|
2512 |
|
2513 | return Object.keys(QRCodeCanvas.propTypes).some(function (k) {
|
2514 | return _this4.props[k] !== nextProps[k];
|
2515 | });
|
2516 | }
|
2517 | }, {
|
2518 | key: "render",
|
2519 | value: function render() {
|
2520 | var _props3 = this.props,
|
2521 | value = _props3.value,
|
2522 | size = _props3.size,
|
2523 | level = _props3.level,
|
2524 | bgColor = _props3.bgColor,
|
2525 | fgColor = _props3.fgColor,
|
2526 | otherProps = _objectWithoutProperties(_props3, ["value", "size", "level", "bgColor", "fgColor"]);
|
2527 |
|
2528 |
|
2529 | var qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[level]);
|
2530 | qrcode.addData(convertStr(value));
|
2531 | qrcode.make();
|
2532 | var cells = qrcode.modules;
|
2533 |
|
2534 | if (cells === null) {
|
2535 | return;
|
2536 | }
|
2537 |
|
2538 |
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 | var ops = [];
|
2545 | cells.forEach(function (row, y) {
|
2546 | var lastIsDark = false;
|
2547 | var start = null;
|
2548 | row.forEach(function (cell, x) {
|
2549 | if (!cell && start !== null) {
|
2550 |
|
2551 |
|
2552 | ops.push("M".concat(start, " ").concat(y, "h").concat(x - start, "v1H").concat(start, "z"));
|
2553 | start = null;
|
2554 | return;
|
2555 | }
|
2556 |
|
2557 |
|
2558 | if (x === row.length - 1) {
|
2559 | if (!cell) {
|
2560 |
|
2561 |
|
2562 | return;
|
2563 | }
|
2564 |
|
2565 | if (start === null) {
|
2566 |
|
2567 | ops.push("M".concat(x, ",").concat(y, " h1v1H").concat(x, "z"));
|
2568 | } else {
|
2569 |
|
2570 | ops.push("M".concat(start, ",").concat(y, " h").concat(x + 1 - start, "v1H").concat(start, "z"));
|
2571 | }
|
2572 |
|
2573 | return;
|
2574 | }
|
2575 |
|
2576 | if (cell && start === null) {
|
2577 | start = x;
|
2578 | }
|
2579 | });
|
2580 | });
|
2581 | return React.createElement("svg", _extends({
|
2582 | shapeRendering: "crispEdges",
|
2583 | height: size,
|
2584 | width: size,
|
2585 | viewBox: "0 0 ".concat(cells.length, " ").concat(cells.length)
|
2586 | }, otherProps), React.createElement("path", {
|
2587 | fill: bgColor,
|
2588 | d: "M0,0 h".concat(cells.length, "v").concat(cells.length, "H0z")
|
2589 | }), React.createElement("path", {
|
2590 | fill: fgColor,
|
2591 | d: ops.join('')
|
2592 | }));
|
2593 | }
|
2594 | }]);
|
2595 |
|
2596 | return QRCodeSVG;
|
2597 | }(React.Component);
|
2598 |
|
2599 | Object.defineProperty(QRCodeSVG, "defaultProps", {
|
2600 | configurable: true,
|
2601 | enumerable: true,
|
2602 | writable: true,
|
2603 | value: DEFAULT_PROPS
|
2604 | });
|
2605 | Object.defineProperty(QRCodeSVG, "propTypes", {
|
2606 | configurable: true,
|
2607 | enumerable: true,
|
2608 | writable: true,
|
2609 | value: PROP_TYPES
|
2610 | });
|
2611 |
|
2612 | var QRCode = function QRCode(props) {
|
2613 | var renderAs = props.renderAs,
|
2614 | otherProps = _objectWithoutProperties(props, ["renderAs"]);
|
2615 |
|
2616 | var Component = renderAs === 'svg' ? QRCodeSVG : QRCodeCanvas;
|
2617 | return React.createElement(Component, otherProps);
|
2618 | };
|
2619 |
|
2620 | QRCode.defaultProps = _extends({
|
2621 | renderAs: 'canvas'
|
2622 | }, DEFAULT_PROPS);
|
2623 | module.exports = QRCode;
|
2624 |
|
2625 | }),
|
2626 |
|
2627 | "../../node_modules/react-is/cjs/react-is.development.js":
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 | (function(module, exports, __webpack_require__) {
|
2633 |
|
2634 | "use strict";
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 | if (true) {
|
2649 | (function() {
|
2650 | 'use strict';
|
2651 |
|
2652 |
|
2653 |
|
2654 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
2655 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
2656 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
2657 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
2658 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
2659 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
2660 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
2661 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
2662 |
|
2663 |
|
2664 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
2665 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
2666 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
2667 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
2668 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
2669 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
2670 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
2671 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
2672 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
2673 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
2674 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
2675 |
|
2676 | function isValidElementType(type) {
|
2677 | return typeof type === 'string' || typeof type === 'function' ||
|
2678 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
2679 | }
|
2680 |
|
2681 | function typeOf(object) {
|
2682 | if (typeof object === 'object' && object !== null) {
|
2683 | var $$typeof = object.$$typeof;
|
2684 |
|
2685 | switch ($$typeof) {
|
2686 | case REACT_ELEMENT_TYPE:
|
2687 | var type = object.type;
|
2688 |
|
2689 | switch (type) {
|
2690 | case REACT_ASYNC_MODE_TYPE:
|
2691 | case REACT_CONCURRENT_MODE_TYPE:
|
2692 | case REACT_FRAGMENT_TYPE:
|
2693 | case REACT_PROFILER_TYPE:
|
2694 | case REACT_STRICT_MODE_TYPE:
|
2695 | case REACT_SUSPENSE_TYPE:
|
2696 | return type;
|
2697 |
|
2698 | default:
|
2699 | var $$typeofType = type && type.$$typeof;
|
2700 |
|
2701 | switch ($$typeofType) {
|
2702 | case REACT_CONTEXT_TYPE:
|
2703 | case REACT_FORWARD_REF_TYPE:
|
2704 | case REACT_LAZY_TYPE:
|
2705 | case REACT_MEMO_TYPE:
|
2706 | case REACT_PROVIDER_TYPE:
|
2707 | return $$typeofType;
|
2708 |
|
2709 | default:
|
2710 | return $$typeof;
|
2711 | }
|
2712 |
|
2713 | }
|
2714 |
|
2715 | case REACT_PORTAL_TYPE:
|
2716 | return $$typeof;
|
2717 | }
|
2718 | }
|
2719 |
|
2720 | return undefined;
|
2721 | }
|
2722 |
|
2723 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
2724 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
2725 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
2726 | var ContextProvider = REACT_PROVIDER_TYPE;
|
2727 | var Element = REACT_ELEMENT_TYPE;
|
2728 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
2729 | var Fragment = REACT_FRAGMENT_TYPE;
|
2730 | var Lazy = REACT_LAZY_TYPE;
|
2731 | var Memo = REACT_MEMO_TYPE;
|
2732 | var Portal = REACT_PORTAL_TYPE;
|
2733 | var Profiler = REACT_PROFILER_TYPE;
|
2734 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
2735 | var Suspense = REACT_SUSPENSE_TYPE;
|
2736 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
2737 |
|
2738 | function isAsyncMode(object) {
|
2739 | {
|
2740 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
2741 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
2742 |
|
2743 | console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
2744 | }
|
2745 | }
|
2746 |
|
2747 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
2748 | }
|
2749 | function isConcurrentMode(object) {
|
2750 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
2751 | }
|
2752 | function isContextConsumer(object) {
|
2753 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
2754 | }
|
2755 | function isContextProvider(object) {
|
2756 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
2757 | }
|
2758 | function isElement(object) {
|
2759 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
2760 | }
|
2761 | function isForwardRef(object) {
|
2762 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
2763 | }
|
2764 | function isFragment(object) {
|
2765 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
2766 | }
|
2767 | function isLazy(object) {
|
2768 | return typeOf(object) === REACT_LAZY_TYPE;
|
2769 | }
|
2770 | function isMemo(object) {
|
2771 | return typeOf(object) === REACT_MEMO_TYPE;
|
2772 | }
|
2773 | function isPortal(object) {
|
2774 | return typeOf(object) === REACT_PORTAL_TYPE;
|
2775 | }
|
2776 | function isProfiler(object) {
|
2777 | return typeOf(object) === REACT_PROFILER_TYPE;
|
2778 | }
|
2779 | function isStrictMode(object) {
|
2780 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
2781 | }
|
2782 | function isSuspense(object) {
|
2783 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
2784 | }
|
2785 |
|
2786 | exports.AsyncMode = AsyncMode;
|
2787 | exports.ConcurrentMode = ConcurrentMode;
|
2788 | exports.ContextConsumer = ContextConsumer;
|
2789 | exports.ContextProvider = ContextProvider;
|
2790 | exports.Element = Element;
|
2791 | exports.ForwardRef = ForwardRef;
|
2792 | exports.Fragment = Fragment;
|
2793 | exports.Lazy = Lazy;
|
2794 | exports.Memo = Memo;
|
2795 | exports.Portal = Portal;
|
2796 | exports.Profiler = Profiler;
|
2797 | exports.StrictMode = StrictMode;
|
2798 | exports.Suspense = Suspense;
|
2799 | exports.isAsyncMode = isAsyncMode;
|
2800 | exports.isConcurrentMode = isConcurrentMode;
|
2801 | exports.isContextConsumer = isContextConsumer;
|
2802 | exports.isContextProvider = isContextProvider;
|
2803 | exports.isElement = isElement;
|
2804 | exports.isForwardRef = isForwardRef;
|
2805 | exports.isFragment = isFragment;
|
2806 | exports.isLazy = isLazy;
|
2807 | exports.isMemo = isMemo;
|
2808 | exports.isPortal = isPortal;
|
2809 | exports.isProfiler = isProfiler;
|
2810 | exports.isStrictMode = isStrictMode;
|
2811 | exports.isSuspense = isSuspense;
|
2812 | exports.isValidElementType = isValidElementType;
|
2813 | exports.typeOf = typeOf;
|
2814 | })();
|
2815 | }
|
2816 |
|
2817 |
|
2818 | }),
|
2819 |
|
2820 | "../../node_modules/react-is/index.js":
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 | (function(module, exports, __webpack_require__) {
|
2826 |
|
2827 | "use strict";
|
2828 |
|
2829 |
|
2830 | if (false) {} else {
|
2831 | module.exports = __webpack_require__( "../../node_modules/react-is/cjs/react-is.development.js");
|
2832 | }
|
2833 |
|
2834 |
|
2835 | }),
|
2836 |
|
2837 | "../../node_modules/webpack/buildin/global.js":
|
2838 |
|
2839 |
|
2840 |
|
2841 |
|
2842 | (function(module, exports) {
|
2843 |
|
2844 | var g;
|
2845 |
|
2846 |
|
2847 | g = (function() {
|
2848 | return this;
|
2849 | })();
|
2850 |
|
2851 | try {
|
2852 |
|
2853 | g = g || new Function("return this")();
|
2854 | } catch (e) {
|
2855 |
|
2856 | if (typeof window === "object") g = window;
|
2857 | }
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 | module.exports = g;
|
2864 |
|
2865 |
|
2866 | }),
|
2867 |
|
2868 | "./lib/API/GraphQL/Connect.js":
|
2869 |
|
2870 |
|
2871 |
|
2872 |
|
2873 | (function(module, exports, __webpack_require__) {
|
2874 |
|
2875 | "use strict";
|
2876 |
|
2877 |
|
2878 | var __extends = this && this.__extends || function () {
|
2879 | var _extendStatics = function extendStatics(d, b) {
|
2880 | _extendStatics = Object.setPrototypeOf || {
|
2881 | __proto__: []
|
2882 | } instanceof Array && function (d, b) {
|
2883 | d.__proto__ = b;
|
2884 | } || function (d, b) {
|
2885 | for (var p in b) {
|
2886 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
2887 | }
|
2888 | };
|
2889 |
|
2890 | return _extendStatics(d, b);
|
2891 | };
|
2892 |
|
2893 | return function (d, b) {
|
2894 | _extendStatics(d, b);
|
2895 |
|
2896 | function __() {
|
2897 | this.constructor = d;
|
2898 | }
|
2899 |
|
2900 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2901 | };
|
2902 | }();
|
2903 |
|
2904 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
2905 | function adopt(value) {
|
2906 | return value instanceof P ? value : new P(function (resolve) {
|
2907 | resolve(value);
|
2908 | });
|
2909 | }
|
2910 |
|
2911 | return new (P || (P = Promise))(function (resolve, reject) {
|
2912 | function fulfilled(value) {
|
2913 | try {
|
2914 | step(generator.next(value));
|
2915 | } catch (e) {
|
2916 | reject(e);
|
2917 | }
|
2918 | }
|
2919 |
|
2920 | function rejected(value) {
|
2921 | try {
|
2922 | step(generator["throw"](value));
|
2923 | } catch (e) {
|
2924 | reject(e);
|
2925 | }
|
2926 | }
|
2927 |
|
2928 | function step(result) {
|
2929 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
2930 | }
|
2931 |
|
2932 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
2933 | });
|
2934 | };
|
2935 |
|
2936 | var __generator = this && this.__generator || function (thisArg, body) {
|
2937 | var _ = {
|
2938 | label: 0,
|
2939 | sent: function sent() {
|
2940 | if (t[0] & 1) throw t[1];
|
2941 | return t[1];
|
2942 | },
|
2943 | trys: [],
|
2944 | ops: []
|
2945 | },
|
2946 | f,
|
2947 | y,
|
2948 | t,
|
2949 | g;
|
2950 | return g = {
|
2951 | next: verb(0),
|
2952 | "throw": verb(1),
|
2953 | "return": verb(2)
|
2954 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
2955 | return this;
|
2956 | }), g;
|
2957 |
|
2958 | function verb(n) {
|
2959 | return function (v) {
|
2960 | return step([n, v]);
|
2961 | };
|
2962 | }
|
2963 |
|
2964 | function step(op) {
|
2965 | if (f) throw new TypeError("Generator is already executing.");
|
2966 |
|
2967 | while (_) {
|
2968 | try {
|
2969 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
2970 | if (y = 0, t) op = [op[0] & 2, t.value];
|
2971 |
|
2972 | switch (op[0]) {
|
2973 | case 0:
|
2974 | case 1:
|
2975 | t = op;
|
2976 | break;
|
2977 |
|
2978 | case 4:
|
2979 | _.label++;
|
2980 | return {
|
2981 | value: op[1],
|
2982 | done: false
|
2983 | };
|
2984 |
|
2985 | case 5:
|
2986 | _.label++;
|
2987 | y = op[1];
|
2988 | op = [0];
|
2989 | continue;
|
2990 |
|
2991 | case 7:
|
2992 | op = _.ops.pop();
|
2993 |
|
2994 | _.trys.pop();
|
2995 |
|
2996 | continue;
|
2997 |
|
2998 | default:
|
2999 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
3000 | _ = 0;
|
3001 | continue;
|
3002 | }
|
3003 |
|
3004 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
3005 | _.label = op[1];
|
3006 | break;
|
3007 | }
|
3008 |
|
3009 | if (op[0] === 6 && _.label < t[1]) {
|
3010 | _.label = t[1];
|
3011 | t = op;
|
3012 | break;
|
3013 | }
|
3014 |
|
3015 | if (t && _.label < t[2]) {
|
3016 | _.label = t[2];
|
3017 |
|
3018 | _.ops.push(op);
|
3019 |
|
3020 | break;
|
3021 | }
|
3022 |
|
3023 | if (t[2]) _.ops.pop();
|
3024 |
|
3025 | _.trys.pop();
|
3026 |
|
3027 | continue;
|
3028 | }
|
3029 |
|
3030 | op = body.call(thisArg, _);
|
3031 | } catch (e) {
|
3032 | op = [6, e];
|
3033 | y = 0;
|
3034 | } finally {
|
3035 | f = t = 0;
|
3036 | }
|
3037 | }
|
3038 |
|
3039 | if (op[0] & 5) throw op[1];
|
3040 | return {
|
3041 | value: op[0] ? op[1] : void 0,
|
3042 | done: true
|
3043 | };
|
3044 | }
|
3045 | };
|
3046 |
|
3047 | var __importStar = this && this.__importStar || function (mod) {
|
3048 | if (mod && mod.__esModule) return mod;
|
3049 | var result = {};
|
3050 | if (mod != null) for (var k in mod) {
|
3051 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
3052 | }
|
3053 | result["default"] = mod;
|
3054 | return result;
|
3055 | };
|
3056 |
|
3057 | Object.defineProperty(exports, "__esModule", {
|
3058 | value: true
|
3059 | });
|
3060 |
|
3061 | var React = __importStar(__webpack_require__( "react"));
|
3062 |
|
3063 | var api_1 = __webpack_require__( "@aws-amplify/api");
|
3064 |
|
3065 | var Connect =
|
3066 |
|
3067 | function (_super) {
|
3068 | __extends(Connect, _super);
|
3069 |
|
3070 | function Connect(props) {
|
3071 | var _this = _super.call(this, props) || this;
|
3072 |
|
3073 | _this.state = _this.getInitialState();
|
3074 | _this.subSubscription = null;
|
3075 | return _this;
|
3076 | }
|
3077 |
|
3078 | Connect.prototype.getInitialState = function () {
|
3079 | var query = this.props.query;
|
3080 | return {
|
3081 | loading: query && !!query.query,
|
3082 | data: {},
|
3083 | errors: [],
|
3084 | mutation: function mutation() {
|
3085 | return console.warn('Not implemented');
|
3086 | }
|
3087 | };
|
3088 | };
|
3089 |
|
3090 | Connect.prototype.getDefaultState = function () {
|
3091 | return {
|
3092 | loading: false,
|
3093 | data: {},
|
3094 | errors: [],
|
3095 | mutation: function mutation() {
|
3096 | return console.warn('Not implemented');
|
3097 | }
|
3098 | };
|
3099 | };
|
3100 |
|
3101 | Connect.prototype._fetchData = function () {
|
3102 | return __awaiter(this, void 0, void 0, function () {
|
3103 | var _a, _b, _c, query, _d, variables, _e, _f, mutation, _g, mutationVariables, subscription, _h, onSubscriptionMsg, _j, data, mutationProp, errors, hasValidQuery, hasValidMutation, hasValidSubscription, response, err_1, subsQuery, subsVars, observable;
|
3104 |
|
3105 | var _this = this;
|
3106 |
|
3107 | return __generator(this, function (_k) {
|
3108 | switch (_k.label) {
|
3109 | case 0:
|
3110 | this._unsubscribe();
|
3111 |
|
3112 | this.setState({
|
3113 | loading: true
|
3114 | });
|
3115 | _a = this.props, _b = _a.query, _c = _b === void 0 ? {} : _b, query = _c.query, _d = _c.variables, variables = _d === void 0 ? {} : _d, _e = _a.mutation, _f = _e === void 0 ? {} : _e, mutation = _f.query, _g = _f.mutationVariables, mutationVariables = _g === void 0 ? {} : _g, subscription = _a.subscription, _h = _a.onSubscriptionMsg, onSubscriptionMsg = _h === void 0 ? function (prevData) {
|
3116 | return prevData;
|
3117 | } : _h;
|
3118 | _j = this.getDefaultState(), data = _j.data, mutationProp = _j.mutation, errors = _j.errors;
|
3119 |
|
3120 | if (!api_1.API || typeof api_1.API.graphql !== 'function' || typeof api_1.API.getGraphqlOperationType !== 'function') {
|
3121 | throw new Error('No API module found, please ensure @aws-amplify/api is imported');
|
3122 | }
|
3123 |
|
3124 | hasValidQuery = query && api_1.API.getGraphqlOperationType(query) === 'query';
|
3125 | hasValidMutation = mutation && api_1.API.getGraphqlOperationType(mutation) === 'mutation';
|
3126 | hasValidSubscription = subscription && api_1.API.getGraphqlOperationType(subscription.query) === 'subscription';
|
3127 |
|
3128 | if (!hasValidQuery && !hasValidMutation && !hasValidSubscription) {
|
3129 | console.warn('No query, mutation or subscription was specified');
|
3130 | }
|
3131 |
|
3132 | if (!hasValidQuery) return [3
|
3133 |
|
3134 | , 4];
|
3135 | _k.label = 1;
|
3136 |
|
3137 | case 1:
|
3138 | _k.trys.push([1, 3,, 4]);
|
3139 |
|
3140 | data = null;
|
3141 | return [4
|
3142 |
|
3143 | , api_1.API.graphql({
|
3144 | query: query,
|
3145 | variables: variables
|
3146 | })];
|
3147 |
|
3148 | case 2:
|
3149 | response = _k.sent();
|
3150 |
|
3151 | data = response.data;
|
3152 | return [3
|
3153 |
|
3154 | , 4];
|
3155 |
|
3156 | case 3:
|
3157 | err_1 = _k.sent();
|
3158 | data = err_1.data;
|
3159 | errors = err_1.errors;
|
3160 | return [3
|
3161 |
|
3162 | , 4];
|
3163 |
|
3164 | case 4:
|
3165 | if (hasValidMutation) {
|
3166 |
|
3167 | mutationProp = function mutationProp(variables) {
|
3168 | return __awaiter(_this, void 0, void 0, function () {
|
3169 | var result;
|
3170 | return __generator(this, function (_a) {
|
3171 | switch (_a.label) {
|
3172 | case 0:
|
3173 | return [4
|
3174 |
|
3175 | , api_1.API.graphql({
|
3176 | query: mutation,
|
3177 | variables: variables
|
3178 | })];
|
3179 |
|
3180 | case 1:
|
3181 | result = _a.sent();
|
3182 | this.forceUpdate();
|
3183 | return [2
|
3184 |
|
3185 | , result];
|
3186 | }
|
3187 | });
|
3188 | });
|
3189 | };
|
3190 | }
|
3191 |
|
3192 | if (hasValidSubscription) {
|
3193 | subsQuery = subscription.query, subsVars = subscription.variables;
|
3194 |
|
3195 | try {
|
3196 | observable = api_1.API.graphql({
|
3197 | query: subsQuery,
|
3198 | variables: subsVars
|
3199 | });
|
3200 |
|
3201 | this.subSubscription = observable.subscribe({
|
3202 | next: function next(_a) {
|
3203 | var data = _a.value.data;
|
3204 | var prevData = _this.state.data;
|
3205 |
|
3206 | var newData = onSubscriptionMsg(prevData, data);
|
3207 |
|
3208 | if (_this.mounted) {
|
3209 | _this.setState({
|
3210 | data: newData
|
3211 | });
|
3212 | }
|
3213 | },
|
3214 | error: function error(err) {
|
3215 | return console.error(err);
|
3216 | }
|
3217 | });
|
3218 | } catch (err) {
|
3219 | errors = err.errors;
|
3220 | }
|
3221 | }
|
3222 |
|
3223 | this.setState({
|
3224 | data: data,
|
3225 | errors: errors,
|
3226 | mutation: mutationProp,
|
3227 | loading: false
|
3228 | });
|
3229 | return [2
|
3230 |
|
3231 | ];
|
3232 | }
|
3233 | });
|
3234 | });
|
3235 | };
|
3236 |
|
3237 | Connect.prototype._unsubscribe = function () {
|
3238 | if (this.subSubscription) {
|
3239 | this.subSubscription.unsubscribe();
|
3240 | }
|
3241 | };
|
3242 |
|
3243 | Connect.prototype.componentDidMount = function () {
|
3244 | return __awaiter(this, void 0, void 0, function () {
|
3245 | return __generator(this, function (_a) {
|
3246 | this._fetchData();
|
3247 |
|
3248 | this.mounted = true;
|
3249 | return [2
|
3250 |
|
3251 | ];
|
3252 | });
|
3253 | });
|
3254 | };
|
3255 |
|
3256 | Connect.prototype.componentWillUnmount = function () {
|
3257 | this._unsubscribe();
|
3258 |
|
3259 | this.mounted = false;
|
3260 | };
|
3261 |
|
3262 | Connect.prototype.componentDidUpdate = function (prevProps) {
|
3263 | var loading = this.state.loading;
|
3264 | var _a = this.props,
|
3265 | newQueryObj = _a.query,
|
3266 | newMutationObj = _a.mutation;
|
3267 | var prevQueryObj = prevProps.query,
|
3268 | prevMutationObj = prevProps.mutation;
|
3269 |
|
3270 |
|
3271 | var _b = newQueryObj || {},
|
3272 | newQuery = _b.query,
|
3273 | newQueryVariables = _b.variables;
|
3274 |
|
3275 |
|
3276 | var _c = prevQueryObj || {},
|
3277 | prevQuery = _c.query,
|
3278 | prevQueryVariables = _c.variables;
|
3279 |
|
3280 | var queryChanged = prevQuery !== newQuery || JSON.stringify(prevQueryVariables) !== JSON.stringify(newQueryVariables);
|
3281 |
|
3282 |
|
3283 | var _d = newMutationObj || {},
|
3284 | newMutation = _d.query,
|
3285 | newMutationVariables = _d.variables;
|
3286 |
|
3287 |
|
3288 | var _e = prevMutationObj || {},
|
3289 | prevMutation = _e.query,
|
3290 | prevMutationVariables = _e.variables;
|
3291 |
|
3292 | var mutationChanged = prevMutation !== newMutation || JSON.stringify(prevMutationVariables) !== JSON.stringify(newMutationVariables);
|
3293 |
|
3294 | if (!loading && (queryChanged || mutationChanged)) {
|
3295 | this._fetchData();
|
3296 | }
|
3297 | };
|
3298 |
|
3299 | Connect.prototype.render = function () {
|
3300 | var _a = this.state,
|
3301 | data = _a.data,
|
3302 | loading = _a.loading,
|
3303 | mutation = _a.mutation,
|
3304 | errors = _a.errors;
|
3305 |
|
3306 | return this.props.children({
|
3307 | data: data,
|
3308 | errors: errors,
|
3309 | loading: loading,
|
3310 | mutation: mutation
|
3311 | }) || null;
|
3312 | };
|
3313 |
|
3314 | return Connect;
|
3315 | }(React.Component);
|
3316 |
|
3317 | exports.Connect = Connect;
|
3318 |
|
3319 |
|
3320 |
|
3321 |
|
3322 | exports["default"] = Connect;
|
3323 |
|
3324 | }),
|
3325 |
|
3326 | "./lib/API/GraphQL/index.js":
|
3327 |
|
3328 |
|
3329 |
|
3330 |
|
3331 | (function(module, exports, __webpack_require__) {
|
3332 |
|
3333 | "use strict";
|
3334 |
|
3335 |
|
3336 |
|
3337 |
|
3338 |
|
3339 |
|
3340 |
|
3341 |
|
3342 |
|
3343 |
|
3344 |
|
3345 |
|
3346 |
|
3347 |
|
3348 | Object.defineProperty(exports, "__esModule", {
|
3349 | value: true
|
3350 | });
|
3351 |
|
3352 | var Connect_1 = __webpack_require__( "./lib/API/GraphQL/Connect.js");
|
3353 |
|
3354 | exports.Connect = Connect_1.Connect;
|
3355 |
|
3356 | }),
|
3357 |
|
3358 | "./lib/API/index.js":
|
3359 |
|
3360 |
|
3361 |
|
3362 |
|
3363 | (function(module, exports, __webpack_require__) {
|
3364 |
|
3365 | "use strict";
|
3366 |
|
3367 |
|
3368 | function __export(m) {
|
3369 | for (var p in m) {
|
3370 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
3371 | }
|
3372 | }
|
3373 |
|
3374 | Object.defineProperty(exports, "__esModule", {
|
3375 | value: true
|
3376 | });
|
3377 |
|
3378 | __export(__webpack_require__( "./lib/API/GraphQL/index.js"));
|
3379 |
|
3380 | }),
|
3381 |
|
3382 | "./lib/Amplify-UI/Amplify-UI-Components-React.js":
|
3383 |
|
3384 |
|
3385 |
|
3386 |
|
3387 | (function(module, exports, __webpack_require__) {
|
3388 |
|
3389 | "use strict";
|
3390 |
|
3391 |
|
3392 | var __assign = this && this.__assign || function () {
|
3393 | __assign = Object.assign || function (t) {
|
3394 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
3395 | s = arguments[i];
|
3396 |
|
3397 | for (var p in s) {
|
3398 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
3399 | }
|
3400 | }
|
3401 |
|
3402 | return t;
|
3403 | };
|
3404 |
|
3405 | return __assign.apply(this, arguments);
|
3406 | };
|
3407 |
|
3408 | var __importStar = this && this.__importStar || function (mod) {
|
3409 | if (mod && mod.__esModule) return mod;
|
3410 | var result = {};
|
3411 | if (mod != null) for (var k in mod) {
|
3412 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
3413 | }
|
3414 | result["default"] = mod;
|
3415 | return result;
|
3416 | };
|
3417 |
|
3418 | var __importDefault = this && this.__importDefault || function (mod) {
|
3419 | return mod && mod.__esModule ? mod : {
|
3420 | "default": mod
|
3421 | };
|
3422 | };
|
3423 |
|
3424 | Object.defineProperty(exports, "__esModule", {
|
3425 | value: true
|
3426 | });
|
3427 |
|
3428 | var React = __importStar(__webpack_require__( "react"));
|
3429 |
|
3430 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
3431 |
|
3432 | var AmplifyUI = __importStar(__webpack_require__( "@aws-amplify/ui"));
|
3433 |
|
3434 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
3435 |
|
3436 | exports.Container = function (props) {
|
3437 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3438 | var style = exports.propStyle(props, theme.container);
|
3439 | var p = core_1.objectLessAttributes(props, 'theme');
|
3440 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3441 | className: AmplifyUI.container,
|
3442 | style: style
|
3443 | }), props.children));
|
3444 | };
|
3445 |
|
3446 | exports.FormContainer = function (props) {
|
3447 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3448 | return exports.beforeAfter(React.createElement("div", {
|
3449 | className: AmplifyUI.formContainer,
|
3450 | style: theme.formContainer
|
3451 | }, props.children));
|
3452 | };
|
3453 |
|
3454 | exports.FormSection = function (props) {
|
3455 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3456 | var style = exports.propStyle(props, theme.formSection);
|
3457 | return React.createElement(exports.FormContainer, {
|
3458 | theme: theme
|
3459 | }, exports.beforeAfter(React.createElement("div", {
|
3460 | className: AmplifyUI.formSection,
|
3461 | style: style
|
3462 | }, props.children)));
|
3463 | };
|
3464 |
|
3465 | exports.SectionHeader = function (props) {
|
3466 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3467 | var style = exports.propStyle(props, theme.sectionHeader);
|
3468 | var p = core_1.objectLessAttributes(props, 'theme');
|
3469 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3470 | className: AmplifyUI.sectionHeader,
|
3471 | style: style
|
3472 | }), React.createElement(exports.SectionHeaderContent, {
|
3473 | theme: theme
|
3474 | }, props.children, props.hint && React.createElement("div", {
|
3475 | className: AmplifyUI.sectionHeaderHint
|
3476 | }, props.hint))));
|
3477 | };
|
3478 |
|
3479 | exports.SectionHeaderContent = function (props) {
|
3480 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3481 | var style = exports.propStyle(props, theme.sectionHeaderContent);
|
3482 | return exports.beforeAfter(React.createElement("span", {
|
3483 | className: AmplifyUI.sectionHeaderContent,
|
3484 | style: style
|
3485 | }, props.children));
|
3486 | };
|
3487 |
|
3488 | exports.SectionFooter = function (props) {
|
3489 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3490 | var style = exports.propStyle(props, theme.sectionFooter);
|
3491 | var p = core_1.objectLessAttributes(props, 'theme');
|
3492 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3493 | className: AmplifyUI.sectionFooter,
|
3494 | style: style
|
3495 | }), props.children));
|
3496 | };
|
3497 |
|
3498 | exports.SectionFooterPrimaryContent = function (props) {
|
3499 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3500 | var style = exports.propStyle(props, theme.sectionFooterPrimaryContent);
|
3501 | return exports.beforeAfter(React.createElement("span", {
|
3502 | className: AmplifyUI.sectionFooterPrimaryContent,
|
3503 | style: style
|
3504 | }, props.children));
|
3505 | };
|
3506 |
|
3507 | exports.SectionFooterSecondaryContent = function (props) {
|
3508 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3509 | var style = exports.propStyle(props, theme.sectionFooterSecondaryContent);
|
3510 | return exports.beforeAfter(React.createElement("span", {
|
3511 | className: AmplifyUI.sectionFooterSecondaryContent,
|
3512 | style: style
|
3513 | }, props.children));
|
3514 | };
|
3515 |
|
3516 | exports.SectionBody = function (props) {
|
3517 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3518 | var style = exports.propStyle(props, theme.sectionBody);
|
3519 | var p = core_1.objectLessAttributes(props, 'theme');
|
3520 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3521 | className: AmplifyUI.sectionBody,
|
3522 | style: style
|
3523 | }), props.children));
|
3524 | };
|
3525 |
|
3526 | exports.ActionRow = function (props) {
|
3527 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3528 | var style = exports.propStyle(props, theme.actionRow);
|
3529 | var p = core_1.objectLessAttributes(props, 'theme');
|
3530 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3531 | className: "amplify-action-row",
|
3532 | style: style
|
3533 | }), props.children));
|
3534 | };
|
3535 |
|
3536 | exports.Strike = function (props) {
|
3537 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3538 | var style = exports.propStyle(props, theme.strike);
|
3539 | return exports.beforeAfter(React.createElement("div", {
|
3540 | className: AmplifyUI.strike,
|
3541 | style: style
|
3542 | }, React.createElement(exports.StrikeContent, {
|
3543 | theme: theme
|
3544 | }, props.children)));
|
3545 | };
|
3546 |
|
3547 | exports.StrikeContent = function (props) {
|
3548 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3549 | return exports.beforeAfter(React.createElement("span", {
|
3550 | className: AmplifyUI.strikeContent,
|
3551 | style: theme.strikeContent
|
3552 | }, props.children));
|
3553 | };
|
3554 |
|
3555 | exports.FormRow = function (props) {
|
3556 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3557 | var style = exports.propStyle(props, theme.formRow);
|
3558 | var p = core_1.objectLessAttributes(props, 'theme');
|
3559 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3560 | className: AmplifyUI.formRow,
|
3561 | style: style
|
3562 | }), props.children));
|
3563 | };
|
3564 |
|
3565 | exports.RadioRow = function (props) {
|
3566 | var id = props.id || '_' + props.value;
|
3567 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3568 | return React.createElement(exports.FormRow, {
|
3569 | theme: theme
|
3570 | }, React.createElement(exports.Radio, __assign({}, props, {
|
3571 | id: id
|
3572 | })), React.createElement(exports.Label, {
|
3573 | htmlFor: id,
|
3574 | theme: theme
|
3575 | }, props.placeholder));
|
3576 | };
|
3577 |
|
3578 | exports.Radio = function (props) {
|
3579 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3580 | var style = exports.propStyle(props, theme.radio);
|
3581 | var p = core_1.objectLessAttributes(props, 'theme');
|
3582 | return exports.beforeAfter(React.createElement("input", __assign({}, p, {
|
3583 | type: "radio",
|
3584 | className: AmplifyUI.radio,
|
3585 | style: style
|
3586 | })));
|
3587 | };
|
3588 |
|
3589 | exports.InputRow = function (props) {
|
3590 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3591 | var style = exports.propStyle(props, theme.input);
|
3592 | var p = core_1.objectLessAttributes(props, 'theme');
|
3593 | return React.createElement(exports.FormRow, {
|
3594 | theme: theme
|
3595 | }, exports.beforeAfter(React.createElement("input", __assign({}, p, {
|
3596 | className: AmplifyUI.input,
|
3597 | style: style
|
3598 | }))));
|
3599 | };
|
3600 |
|
3601 | exports.Input = function (props) {
|
3602 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3603 | var style = exports.propStyle(props, theme.input);
|
3604 | var p = core_1.objectLessAttributes(props, 'theme');
|
3605 | return React.createElement("input", __assign({}, p, {
|
3606 | className: AmplifyUI.input,
|
3607 | style: style
|
3608 | }));
|
3609 | };
|
3610 |
|
3611 | exports.SelectInput = function (props) {
|
3612 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3613 | var style = exports.propStyle(props, theme.selectInput);
|
3614 | return React.createElement("div", {
|
3615 | className: AmplifyUI.selectInput,
|
3616 | style: style
|
3617 | }, props.children);
|
3618 | };
|
3619 |
|
3620 | exports.FormField = function (props) {
|
3621 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3622 | var style = exports.propStyle(props, theme.formField);
|
3623 | var p = core_1.objectLessAttributes(props, 'theme');
|
3624 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3625 | className: AmplifyUI.formField,
|
3626 | style: style
|
3627 | }), props.children));
|
3628 | };
|
3629 |
|
3630 | exports.Button = function (props) {
|
3631 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3632 | var style = exports.propStyle(props, theme.button);
|
3633 | var disabled = props.disabled || false;
|
3634 | var p = core_1.objectLessAttributes(props, 'theme');
|
3635 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
3636 | className: AmplifyUI.button,
|
3637 | style: style,
|
3638 | disabled: disabled
|
3639 | }), props.children));
|
3640 | };
|
3641 |
|
3642 | exports.PhotoPickerButton = function (props) {
|
3643 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3644 | var style = exports.propStyle(props, theme.photoPickerButton);
|
3645 | var p = core_1.objectLessAttributes(props, 'theme');
|
3646 | return React.createElement("button", __assign({}, p, {
|
3647 | className: [AmplifyUI.photoPickerButton, AmplifyUI.button].join(' '),
|
3648 | style: style
|
3649 | }), props.children);
|
3650 | };
|
3651 |
|
3652 | exports.SignInButton = function (props) {
|
3653 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3654 | var styles = Object.assign({}, theme.signInButton, theme[props.variant]);
|
3655 | var p = core_1.objectLessAttributes(props, 'theme');
|
3656 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
3657 | className: AmplifyUI.signInButton,
|
3658 | style: styles
|
3659 | }), props.children));
|
3660 | };
|
3661 |
|
3662 | exports.SignInButtonIcon = function (props) {
|
3663 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3664 | var style = exports.propStyle(props, theme.signInButtonIcon);
|
3665 | var p = core_1.objectLessAttributes(props, 'theme');
|
3666 | return exports.beforeAfter(React.createElement("span", __assign({}, p, {
|
3667 | className: AmplifyUI.signInButtonIcon,
|
3668 | style: style
|
3669 | }), props.children));
|
3670 | };
|
3671 |
|
3672 | exports.SignInButtonContent = function (props) {
|
3673 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3674 | var style = exports.propStyle(props, theme.signInButtonContent);
|
3675 | return exports.beforeAfter(React.createElement("span", {
|
3676 | className: AmplifyUI.signInButtonContent,
|
3677 | style: style
|
3678 | }, props.children));
|
3679 | };
|
3680 |
|
3681 | exports.Link = function (props) {
|
3682 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3683 | var style = exports.propStyle(props, theme.a);
|
3684 | var p = core_1.objectLessAttributes(props, 'theme');
|
3685 | return exports.beforeAfter(React.createElement("a", __assign({}, p, {
|
3686 | className: AmplifyUI.a,
|
3687 | style: style
|
3688 | }), props.children));
|
3689 | };
|
3690 |
|
3691 | exports.Label = function (props) {
|
3692 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3693 | var style = exports.propStyle(props, theme.label);
|
3694 | var p = core_1.objectLessAttributes(props, 'theme');
|
3695 | return exports.beforeAfter(React.createElement("label", __assign({}, p, {
|
3696 | className: AmplifyUI.label,
|
3697 | style: style
|
3698 | }), props.children));
|
3699 | };
|
3700 |
|
3701 | exports.Hint = function (props) {
|
3702 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3703 | var style = exports.propStyle(props, theme.hint);
|
3704 | return exports.beforeAfter(React.createElement("div", {
|
3705 | className: AmplifyUI.hint,
|
3706 | style: style
|
3707 | }, props.children));
|
3708 | };
|
3709 |
|
3710 | exports.InputLabel = function (props) {
|
3711 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3712 | var style = exports.propStyle(props, theme.inputLabel);
|
3713 | return exports.beforeAfter(React.createElement("div", {
|
3714 | className: AmplifyUI.inputLabel,
|
3715 | style: style
|
3716 | }, props.children));
|
3717 | };
|
3718 |
|
3719 | exports.NavBar = function (props) {
|
3720 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3721 | var style = exports.propStyle(props, theme.navBar);
|
3722 | var p = core_1.objectLessAttributes(props, 'theme');
|
3723 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3724 | className: AmplifyUI.navBar,
|
3725 | style: style
|
3726 | }), props.children));
|
3727 | };
|
3728 |
|
3729 | exports.Nav = function (props) {
|
3730 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3731 | var style = exports.propStyle(props, theme.nav);
|
3732 | var p = core_1.objectLessAttributes(props, 'theme');
|
3733 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3734 | className: AmplifyUI.nav,
|
3735 | style: style
|
3736 | }), props.children));
|
3737 | };
|
3738 |
|
3739 | exports.NavRight = function (props) {
|
3740 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3741 | var style = exports.propStyle(props, theme.navRight);
|
3742 | var p = core_1.objectLessAttributes(props, 'theme');
|
3743 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3744 | className: AmplifyUI.navRight,
|
3745 | style: style
|
3746 | }), props.children));
|
3747 | };
|
3748 |
|
3749 | exports.NavItem = function (props) {
|
3750 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3751 | var style = exports.propStyle(props, theme.navItem);
|
3752 | var p = core_1.objectLessAttributes(props, 'theme');
|
3753 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
3754 | className: AmplifyUI.navItem,
|
3755 | style: style
|
3756 | }), props.children));
|
3757 | };
|
3758 |
|
3759 | exports.NavButton = function (props) {
|
3760 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3761 | var style = exports.propStyle(props, theme.navButton);
|
3762 | var p = core_1.objectLessAttributes(props, 'theme');
|
3763 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
3764 | className: AmplifyUI.button,
|
3765 | style: style
|
3766 | }), exports.beforeAfter(React.createElement("span", null, props.children))));
|
3767 | };
|
3768 |
|
3769 | exports.Toast = function (props) {
|
3770 | var onClose = props.onClose;
|
3771 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3772 | return React.createElement("div", __assign({}, props, {
|
3773 | theme: theme,
|
3774 | className: AmplifyUI.toast,
|
3775 | style: theme.toast
|
3776 | }), React.createElement("span", null, props.children), React.createElement("a", {
|
3777 | className: AmplifyUI.toastClose,
|
3778 | onClick: onClose
|
3779 | }));
|
3780 | };
|
3781 |
|
3782 |
|
3783 | exports.Toast.defaultProps = {
|
3784 | onClose: function onClose() {
|
3785 | return void 0;
|
3786 | }
|
3787 | };
|
3788 |
|
3789 | exports.PhotoPlaceholder = function (props) {
|
3790 | var theme = props.theme || Amplify_UI_Theme_1["default"];
|
3791 | var style = exports.propStyle(props, theme.photoPlaceholder);
|
3792 | return React.createElement("div", {
|
3793 | className: AmplifyUI.photoPlaceholder,
|
3794 | style: style
|
3795 | }, React.createElement("div", {
|
3796 | className: AmplifyUI.photoPlaceholderIcon
|
3797 | }, React.createElement("svg", {
|
3798 | xmlns: "http://www.w3.org/2000/svg",
|
3799 | width: "64",
|
3800 | height: "64",
|
3801 | viewBox: "0 0 24 24"
|
3802 | }, React.createElement("circle", {
|
3803 | cx: "12",
|
3804 | cy: "12",
|
3805 | r: "3.2"
|
3806 | }), React.createElement("path", {
|
3807 | d: "M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"
|
3808 | }), React.createElement("path", {
|
3809 | d: "M0 0h24v24H0z",
|
3810 | fill: "none"
|
3811 | }))));
|
3812 | };
|
3813 |
|
3814 | exports.beforeAfter = function (el) {
|
3815 | var style = el.props.style || {};
|
3816 | var before = style.before,
|
3817 | after = style.after;
|
3818 |
|
3819 | if (!before && !after) {
|
3820 | return el;
|
3821 | }
|
3822 |
|
3823 | return React.createElement("span", {
|
3824 | style: {
|
3825 | position: 'relative'
|
3826 | }
|
3827 | }, before ? React.createElement("span", {
|
3828 | style: before
|
3829 | }, before.content) : null, el, after ? React.createElement("span", {
|
3830 | style: after
|
3831 | }, after.content) : null);
|
3832 | };
|
3833 |
|
3834 | exports.propStyle = function (props, themeStyle) {
|
3835 | var id = props.id,
|
3836 | style = props.style;
|
3837 | var styl = Object.assign({}, style, themeStyle);
|
3838 |
|
3839 | if (!id) {
|
3840 | return styl;
|
3841 | }
|
3842 |
|
3843 | var selector = '#' + id;
|
3844 | Object.assign(styl, styl[selector]);
|
3845 | return styl;
|
3846 | };
|
3847 |
|
3848 | }),
|
3849 |
|
3850 | "./lib/Amplify-UI/Amplify-UI-Theme.js":
|
3851 |
|
3852 |
|
3853 |
|
3854 |
|
3855 | (function(module, exports, __webpack_require__) {
|
3856 |
|
3857 | "use strict";
|
3858 |
|
3859 |
|
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 |
|
3869 |
|
3870 |
|
3871 |
|
3872 | Object.defineProperty(exports, "__esModule", {
|
3873 | value: true
|
3874 | });
|
3875 | exports.Container = {};
|
3876 | exports.FormContainer = {};
|
3877 | exports.FormSection = {};
|
3878 | exports.FormField = {};
|
3879 | exports.SectionHeader = {};
|
3880 | exports.SectionBody = {};
|
3881 | exports.SectionFooter = {};
|
3882 | exports.SectionFooterPrimaryContent = {};
|
3883 | exports.SectionFooterSecondaryContent = {};
|
3884 | exports.Input = {};
|
3885 | exports.Button = {};
|
3886 | exports.PhotoPickerButton = {};
|
3887 | exports.PhotoPlaceholder = {};
|
3888 | exports.SignInButton = {};
|
3889 | exports.SignInButtonIcon = {};
|
3890 | exports.SignInButtonContent = {};
|
3891 | exports.Strike = {};
|
3892 | exports.StrikeContent = {};
|
3893 | exports.ActionRow = {};
|
3894 | exports.FormRow = {};
|
3895 | exports.A = {};
|
3896 | exports.Hint = {};
|
3897 | exports.Radio = {};
|
3898 | exports.Label = {};
|
3899 | exports.InputLabel = {};
|
3900 | exports.AmazonSignInButton = {};
|
3901 | exports.FacebookSignInButton = {};
|
3902 | exports.GoogleSignInButton = {};
|
3903 | exports.OAuthSignInButton = {};
|
3904 | exports.Toast = {};
|
3905 | exports.NavBar = {};
|
3906 | exports.NavRight = {};
|
3907 | exports.Nav = {};
|
3908 | exports.NavItem = {};
|
3909 | exports.NavButton = {};
|
3910 | var AmplifyTheme = {
|
3911 | container: exports.Container,
|
3912 | formContainer: exports.FormContainer,
|
3913 | formSection: exports.FormSection,
|
3914 | formField: exports.FormField,
|
3915 | sectionHeader: exports.SectionHeader,
|
3916 | sectionBody: exports.SectionBody,
|
3917 | sectionFooter: exports.SectionFooter,
|
3918 | sectionFooterPrimaryContent: exports.SectionFooterPrimaryContent,
|
3919 | sectionFooterSecondaryContent: exports.SectionFooterSecondaryContent,
|
3920 | input: exports.Input,
|
3921 | button: exports.Button,
|
3922 | photoPickerButton: exports.PhotoPickerButton,
|
3923 | photoPlaceholder: exports.PhotoPlaceholder,
|
3924 | signInButton: exports.SignInButton,
|
3925 | signInButtonIcon: exports.SignInButtonIcon,
|
3926 | signInButtonContent: exports.SignInButtonContent,
|
3927 | amazonSignInButton: exports.AmazonSignInButton,
|
3928 | facebookSignInButton: exports.FacebookSignInButton,
|
3929 | googleSignInButton: exports.GoogleSignInButton,
|
3930 | oAuthSignInButton: exports.OAuthSignInButton,
|
3931 | formRow: exports.FormRow,
|
3932 | strike: exports.Strike,
|
3933 | strikeContent: exports.StrikeContent,
|
3934 | actionRow: exports.ActionRow,
|
3935 | a: exports.A,
|
3936 | hint: exports.Hint,
|
3937 | radio: exports.Radio,
|
3938 | label: exports.Label,
|
3939 | inputLabel: exports.InputLabel,
|
3940 | toast: exports.Toast,
|
3941 | navBar: exports.NavBar,
|
3942 | nav: exports.Nav,
|
3943 | navRight: exports.NavRight,
|
3944 | navItem: exports.NavItem,
|
3945 | navButton: exports.NavButton
|
3946 | };
|
3947 | exports["default"] = AmplifyTheme;
|
3948 |
|
3949 | }),
|
3950 |
|
3951 | "./lib/Amplify-UI/data-test-attributes.js":
|
3952 |
|
3953 |
|
3954 |
|
3955 |
|
3956 | (function(module, exports, __webpack_require__) {
|
3957 |
|
3958 | "use strict";
|
3959 |
|
3960 |
|
3961 | Object.defineProperty(exports, "__esModule", {
|
3962 | value: true
|
3963 | });
|
3964 |
|
3965 | var signIn = {
|
3966 | section: 'sign-in-section',
|
3967 | headerSection: 'sign-in-header-section',
|
3968 | bodySection: 'sign-in-body-section',
|
3969 | footerSection: 'sign-in-footer-section',
|
3970 | usernameInput: 'username-input',
|
3971 | passwordInput: 'sign-in-password-input',
|
3972 | forgotPasswordLink: 'sign-in-forgot-password-link',
|
3973 | signInButton: 'sign-in-sign-in-button',
|
3974 | createAccountLink: 'sign-in-create-account-link',
|
3975 | signInError: 'authenticator-error'
|
3976 | };
|
3977 | var signOut = {
|
3978 | button: 'sign-out-button',
|
3979 | section: 'sign-out-section'
|
3980 | };
|
3981 | var signUp = {
|
3982 | section: 'sign-up-section',
|
3983 | headerSection: 'sign-up-header-section',
|
3984 | bodySection: 'sign-up-body-section',
|
3985 | nonPhoneNumberInput: 'sign-up-non-phone-number-input',
|
3986 | phoneNumberInput: 'sign-up-phone-number-input',
|
3987 | dialCodeSelect: 'sign-up-dial-code-select',
|
3988 | footerSection: 'sign-up-footer-section',
|
3989 | createAccountButton: 'sign-up-create-account-button',
|
3990 | signInLink: 'sign-up-sign-in-link',
|
3991 | signUpButton: 'sign-up-sign-up-button',
|
3992 | signInButton: 'sign-up-sign-in-button',
|
3993 | confirmButton: 'sign-up-confirm-button'
|
3994 | };
|
3995 | var verifyContact = {
|
3996 | section: 'verify-contact-section',
|
3997 | headerSection: 'verify-contact-header-section',
|
3998 | bodySection: 'verify-contact-body-section',
|
3999 | submitButton: 'verify-contact-submit-button',
|
4000 | verifyButton: 'verify-contact-verify-button',
|
4001 | skipLink: 'verify-contact-skip-link'
|
4002 | };
|
4003 | var TOTPSetup = {
|
4004 | component: 'totp-setup-component'
|
4005 | };
|
4006 | var requireNewPassword = {
|
4007 | section: 'require-new-password-section',
|
4008 | headerSection: 'require-new-password-header-section',
|
4009 | footerSection: 'require-new-password-footer-section',
|
4010 | bodySection: 'require-new-password-body-section',
|
4011 | newPasswordInput: 'require-new-password-new-password-input',
|
4012 | backToSignInLink: 'require-new-password-back-to-sign-in-link',
|
4013 | submitButton: 'require-new-password-submit-button'
|
4014 | };
|
4015 | var loading = {
|
4016 | section: 'loading-secton'
|
4017 | };
|
4018 | var greetings = {
|
4019 | navBar: 'greetings-nav-bar',
|
4020 | nav: 'greetings-nav',
|
4021 | navRight: 'greetings-nav-right'
|
4022 | };
|
4023 |
|
4024 | var greeting = {
|
4025 | signOutButton: 'sign-out-button',
|
4026 | signOutLink: 'greeting-sign-out-link',
|
4027 | navRight: 'greetings-nav-right'
|
4028 | };
|
4029 | var federatedSignIn = {
|
4030 | section: 'federated-sign-in-section',
|
4031 | bodySection: 'federated-sign-in-body-section',
|
4032 | signInButtons: 'federated-sign-in-buttons'
|
4033 | };
|
4034 | var confirmSignUp = {
|
4035 | section: 'confirm-sign-up-section',
|
4036 | headerSection: 'confirm-sign-up-header-section',
|
4037 | bodySection: 'confirm-sign-up-body-section',
|
4038 | usernameInput: 'confirm-sign-up-username-input',
|
4039 | confirmationCodeInput: 'confirm-sign-up-confirmation-code-input',
|
4040 | resendCodeLink: 'confirm-sign-up-resend-code-link',
|
4041 | confirmButton: 'confirm-sign-up-confirm-button',
|
4042 | backToSignInLink: 'confirm-sign-up-back-to-sign-in-link'
|
4043 | };
|
4044 | var confirmSignIn = {
|
4045 | section: 'confirm-sign-in-section',
|
4046 | headerSection: 'confirm-sign-in-header-section',
|
4047 | bodySection: 'confirm-sign-in-body-section',
|
4048 | codeInput: 'confirm-sign-in-code-input',
|
4049 | confirmButton: 'confirm-sign-in-confirm-button',
|
4050 | backToSignInLink: 'confirm-sign-in-back-to-sign-in-link'
|
4051 | };
|
4052 | var setMFAComp = {
|
4053 | section: 'set-mfa-section',
|
4054 | headerSection: 'set-mfa-header-section',
|
4055 | bodySection: 'set-mfa-header-body-section',
|
4056 | smsInput: 'set-mfa-sms-input',
|
4057 | totpInput: 'set-mfa-totp-input',
|
4058 | noMfaInput: 'set-mfa-nomfa-input',
|
4059 | verificationCodeInput: 'set-mfa-verification-code-input',
|
4060 | setMfaButton: 'set-mfa-set-mfa-button',
|
4061 | verifyTotpTokenButton: 'set-mfa-verify-totp-token-button',
|
4062 | cancelButton: 'set-mfa-cancel-button'
|
4063 | };
|
4064 | var forgotPassword = {
|
4065 | section: 'forgot-password-section',
|
4066 | headerSection: 'forgot-password-header-section',
|
4067 | bodySection: 'forgot-password-body-section',
|
4068 | submitButton: 'forgot-password-submit-button',
|
4069 | sendCodeButton: 'forgot-password-send-code-button',
|
4070 | resendCodeLink: 'forgot-password-resend-code-link',
|
4071 | backToSignInLink: 'forgot-password-back-to-sign-in-link',
|
4072 | usernameInput: 'username-input',
|
4073 | codeInput: 'forgot-password-code-input',
|
4074 | newPasswordInput: 'forgot-password-new-password-input'
|
4075 | };
|
4076 | exports.sumerianScene = {
|
4077 | container: 'sumerian-scene-container',
|
4078 | sumerianScene: 'sumerian-scene',
|
4079 | loading: 'sumerian-scene-loading',
|
4080 | loadingLogo: 'sumerian-scene-loading-logo',
|
4081 | loadingSceneName: 'sumerian-scene-loading-scene-name',
|
4082 | loadingBar: 'sumerian-scene-loading-bar',
|
4083 | errorText: 'sumerian-scene-error-text',
|
4084 | bar: 'sumerian-scene-bar',
|
4085 | actions: 'sumerian-scene-actions'
|
4086 | };
|
4087 | exports.genericAttrs = {
|
4088 | usernameInput: 'username-input',
|
4089 | emailInput: 'email-input',
|
4090 | phoneNumberInput: 'phone-number-input',
|
4091 | dialCodeSelect: 'dial-code-select'
|
4092 | };
|
4093 | exports.chatBot = {
|
4094 | title: 'chatbot-title',
|
4095 | dialog: 'chatbot-dialog',
|
4096 | messageInput: 'chatbot-message-input',
|
4097 | sendMessageButton: 'chatbot-send-message-button'
|
4098 | };
|
4099 | exports.auth = {
|
4100 | signIn: signIn,
|
4101 | signOut: signOut,
|
4102 | signUp: signUp,
|
4103 | verifyContact: verifyContact,
|
4104 | TOTPSetup: TOTPSetup,
|
4105 | requireNewPassword: requireNewPassword,
|
4106 | loading: loading,
|
4107 | genericAttrs: exports.genericAttrs,
|
4108 | greetings: greetings,
|
4109 | greeting: greeting,
|
4110 | federatedSignIn: federatedSignIn,
|
4111 | confirmSignUp: confirmSignUp,
|
4112 | confirmSignIn: confirmSignIn,
|
4113 | setMFAComp: setMFAComp,
|
4114 | forgotPassword: forgotPassword
|
4115 | };
|
4116 |
|
4117 | }),
|
4118 |
|
4119 | "./lib/AmplifyI18n.js":
|
4120 |
|
4121 |
|
4122 |
|
4123 |
|
4124 | (function(module, exports, __webpack_require__) {
|
4125 |
|
4126 | "use strict";
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 |
|
4139 |
|
4140 |
|
4141 | Object.defineProperty(exports, "__esModule", {
|
4142 | value: true
|
4143 | });
|
4144 | exports.dict = {
|
4145 | de: {
|
4146 | 'Sign In': 'Anmelden',
|
4147 | 'Sign Up': 'Registrieren',
|
4148 | 'Sign Out': 'Abmelden',
|
4149 | 'Sign in to your account': 'Melden Sie sich mit Ihrem Account an',
|
4150 | Username: 'Benutzername',
|
4151 | Password: 'Passwort',
|
4152 | 'Enter your username': 'Geben Sie Ihren Benutzernamen ein',
|
4153 | 'Enter your password': 'Geben Sie Ihr Passwort ein',
|
4154 | 'No account? ': 'Kein Account? ',
|
4155 | 'Forgot your password? ': 'Passwort vergessen? ',
|
4156 | 'Reset password': 'Passwort zurücksetzen',
|
4157 | 'User does not exist': 'Dieser Benutzer existiert nicht',
|
4158 | 'User already exists': 'Dieser Benutzer existiert bereits',
|
4159 | 'Incorrect username or password': 'Falscher Benutzername oder falsches Passwort',
|
4160 | 'Invalid password format': 'Ungültiges Passwort-Format',
|
4161 | 'Create account': 'Hier registrieren',
|
4162 | 'Forgot Password': 'Passwort vergessen',
|
4163 | 'Change Password': 'Passwort ändern',
|
4164 | 'New Password': 'Neues Passwort',
|
4165 | Email: 'Email',
|
4166 | 'Phone Number': 'Telefonnummer',
|
4167 | 'Confirm a Code': 'Code bestätigen',
|
4168 | 'Confirm Sign In': 'Anmeldung bestätigen',
|
4169 | 'Confirm Sign Up': 'Registrierung bestätigen',
|
4170 | 'Back to Sign In': 'Zurück zur Anmeldung',
|
4171 | 'Send Code': 'Code senden',
|
4172 | Confirm: 'Bestätigen',
|
4173 | 'Resend Code': 'Code erneut senden',
|
4174 | Submit: 'Abschicken',
|
4175 | Skip: 'Überspringen',
|
4176 | Verify: 'Verifizieren',
|
4177 | 'Verify Contact': 'Kontakt verifizieren',
|
4178 | Code: 'Code',
|
4179 | 'Confirmation Code': 'Bestätigungs-Code',
|
4180 | 'Lost your code? ': 'Code verloren? ',
|
4181 | 'Account recovery requires verified contact information': 'Zurücksetzen des Account benötigt einen verifizierten Account',
|
4182 | 'Invalid phone number format': "Ung\xFCltiges Telefonummern-Format.\n Benutze eine Nummer im Format: +12345678900",
|
4183 | 'Create Account': 'Account erstellen',
|
4184 | 'Have an account? ': 'Schon registriert? ',
|
4185 | 'Sign in': 'Anmelden',
|
4186 | 'Create a new account': 'Erstelle einen neuen Account',
|
4187 | 'Reset your password': 'Zurücksetzen des Passworts',
|
4188 | 'An account with the given email already exists.': 'Ein Account mit dieser Email existiert bereits.',
|
4189 | 'Username cannot be empty': 'Benutzername darf nicht leer sein',
|
4190 | 'Password attempts exceeded': 'Die maximale Anzahl der fehlerhaften Anmeldeversuche wurde erreicht'
|
4191 | },
|
4192 | fr: {
|
4193 | Hello: 'Bonjour',
|
4194 | 'Loading...': 'Chargement...',
|
4195 | 'Sign In': 'Se connecter',
|
4196 | 'Sign In with Amazon': 'Se connecter avec Amazon',
|
4197 | 'Sign In with Facebook': 'Se connecter avec Facebook',
|
4198 | 'Sign In with Google': 'Se connecter avec Google',
|
4199 | 'Sign in with AWS': 'Se connecter avec AWS',
|
4200 | 'Sign Up': "S'inscrire",
|
4201 | 'Sign Out': 'Déconnexion',
|
4202 | 'Forgot Password': 'Mot de passe oublié',
|
4203 | Username: "Nom d'utilisateur",
|
4204 | Password: 'Mot de passe',
|
4205 | 'Change Password': 'Modifier le mot de passe',
|
4206 | Change: 'Modifier',
|
4207 | 'New Password': 'Nouveau mot de passe',
|
4208 | Email: 'Email',
|
4209 | 'Phone Number': 'Numéro de téléphone',
|
4210 | 'Confirm a Code': 'Confirmer un code',
|
4211 | 'Confirm Sign In': 'Confirmer la connexion',
|
4212 | 'Confirm Sign Up': "Confirmer l'inscription",
|
4213 | 'Back to Sign In': 'Retour à la connexion',
|
4214 | Send: 'Envoyer',
|
4215 | 'Send Code': "M'envoyer un code",
|
4216 | Confirm: 'Confirmer',
|
4217 | SMS: 'SMS',
|
4218 | 'Confirm SMS Code': 'Confirmer le code SMS',
|
4219 | 'Confirm TOTP Code': 'Confirmer le code TOTP',
|
4220 | 'Resend a Code': 'Renvoyer un code',
|
4221 | Submit: 'Soumettre',
|
4222 | Skip: 'Passer',
|
4223 | Verify: 'Vérifier',
|
4224 | 'Verify Contact': 'Vérifier le contact',
|
4225 | Code: 'Code',
|
4226 | 'Confirmation Code': 'Code de confirmation',
|
4227 | 'Account recovery requires verified contact information': 'La récupération du compte nécessite des informations de contact vérifiées',
|
4228 | 'User does not exist': "L'utilisateur n'existe pas",
|
4229 | 'User already exists': "L'utilisateur existe déjà",
|
4230 | 'Incorrect username or password': 'Identifiant ou mot de passe incorrect',
|
4231 | 'Invalid password format': 'Format de mot de passe invalide',
|
4232 | 'Invalid phone number format': "Format de num\xE9ro de t\xE9l\xE9phone invalide. Veuillez utiliser un format +12345678900",
|
4233 | 'Username/client id combination not found.': "L'utilisateur n'existe pas",
|
4234 | 'Network error': 'Erreur réseau',
|
4235 | 'Sign in to your account': 'Connexion à votre compte',
|
4236 | 'Forgot your password? ': 'Mot de passe oublié ? ',
|
4237 | 'Reset password': 'Réinitialisez votre mot de passe',
|
4238 | 'No account? ': 'Pas de compte ? ',
|
4239 | 'Create account': 'Créer un compte',
|
4240 | 'Create Account': 'Créer un compte',
|
4241 | 'Have an account? ': 'Déjà un compte ? ',
|
4242 | 'Sign in': 'Se connecter',
|
4243 | 'Create a new account': 'Créer un nouveau compte',
|
4244 | 'Reset your password': 'Réinitialisez votre mot de passe',
|
4245 | 'Enter your username': "Saisissez votre nom d'utilisateur",
|
4246 | 'Enter your password': 'Saisissez votre mot de passe',
|
4247 | 'Enter your phone number': 'Saisissez votre numéro de téléphone',
|
4248 | 'Enter your email': 'Saisissez votre adresse email',
|
4249 | 'Enter your code': 'Saisissez cotre code de confirmation',
|
4250 | 'Lost your code? ': 'Vous avez perdu votre code ? ',
|
4251 | 'Resend Code': 'Renvoyer le code',
|
4252 | or: 'ou',
|
4253 | 'An account with the given email already exists.': 'Un utilisateur avec cette adresse email existe déjà.',
|
4254 | 'Username cannot be empty': "Le nom d'utilisateur doit être renseigné"
|
4255 | },
|
4256 | es: {
|
4257 | 'Sign in to your account': 'Iniciar sesíon',
|
4258 | 'Loading...': 'Cargando...',
|
4259 | 'Confirmation Code': 'Codigo de confirmación',
|
4260 | 'Sign In': 'Iniciar sesíon',
|
4261 | 'Sign Up': 'Regístrase',
|
4262 | 'Sign Out': 'Desconectar',
|
4263 | 'Forgot Password': 'Se te olvidó la contraseña?',
|
4264 | Username: 'Nombre de usuario',
|
4265 | Password: 'Contraseña',
|
4266 | 'Change Password': 'Cambia la contraseña',
|
4267 | 'New Password': 'Nueva contraseña',
|
4268 | Email: 'Email',
|
4269 | 'Phone Number': 'Número de teléfono',
|
4270 | 'Resend Code': 'Mandar codigo otra vez',
|
4271 | 'Create a new account': 'Crear una cuenta nueva',
|
4272 | 'Confirm a Code': 'Confirmar un código',
|
4273 | 'Confirm Sign In': 'Confirmar inicio de sesión',
|
4274 | 'Confirm Sign Up': 'Confirmar Registración',
|
4275 | 'Back to Sign In': 'Iniciar sesión',
|
4276 | 'Send Code': 'Enviar código',
|
4277 | Confirm: 'Confirmar',
|
4278 | 'Resend a Code': 'Reenviar un código',
|
4279 | Submit: 'Enviar',
|
4280 | Skip: 'Omitir',
|
4281 | Verify: 'Verificar',
|
4282 | 'Verify Contact': 'Verificar contacto',
|
4283 | Code: 'Código',
|
4284 | 'Account recovery requires verified contact information': 'La recuperación de la cuenta requiere información de contacto verificada',
|
4285 | 'Username cannot be empty': 'El campo de usuario no puede estar vacido',
|
4286 | 'User does not exist': 'El usuario no existe',
|
4287 | 'User already exists': 'El usuario ya existe',
|
4288 | 'Incorrect username or password': 'Nombre de usuario o contraseña incorrecta',
|
4289 | 'Invalid password format': 'Formato de contraseña inválido',
|
4290 | 'Invalid phone number format': 'Formato de n\xFAmero de tel\xE9fono inv\xE1lido.\nUtilice el formato de n\xFAmero de tel\xE9fono +12345678900'
|
4291 | },
|
4292 | it: {
|
4293 | 'Account recovery requires verified contact information': 'Ripristino del conto richiede un account verificati',
|
4294 | 'An account with the given email already exists.': 'Un account con questa email esiste già.',
|
4295 | 'Back to Sign In': 'Torna alla Accesso',
|
4296 | 'Change Password': 'Cambia la password',
|
4297 | Code: 'Codice',
|
4298 | Confirm: 'Conferma',
|
4299 | 'Confirm Sign In': 'Conferma di applicazione',
|
4300 | 'Confirm Sign Up': 'Registrazione Conferma',
|
4301 | 'Confirm a Code': 'Codice Conferma',
|
4302 | 'Confirmation Code': 'Codice di verifica',
|
4303 | 'Create Account': 'Crea account',
|
4304 | 'Create a new account': 'Creare un nuovo account',
|
4305 | 'Create account': 'Registrati',
|
4306 | Email: 'E-mail',
|
4307 | 'Enter your password': 'Inserire la password',
|
4308 | 'Enter your username': 'Inserisci il tuo nome utente',
|
4309 | 'Forgot your password?': 'Password dimenticata?',
|
4310 | 'Forgot Password': 'Password dimenticata',
|
4311 | 'Have an account? ': 'Già registrato?',
|
4312 | 'Incorrect username or password': 'Nome utente o password errati',
|
4313 | 'Invalid password format': 'Formato della password non valido',
|
4314 | 'Invalid phone number format': 'Utilizzo non valido Telefonummern formattare un numero nel formato :. 12.345.678,9 mille',
|
4315 | 'Lost your code?': 'Perso codice?',
|
4316 | 'New Password': 'Nuova password',
|
4317 | 'No account? ': 'Nessun account?',
|
4318 | Password: 'Password',
|
4319 | 'Password attempts exceeded': 'Il numero massimo di tentativi di accesso falliti è stato raggiunto',
|
4320 | 'Phone Number': 'Numero di telefono',
|
4321 | 'Resend Code': 'Codice Rispedisci',
|
4322 | 'Reset password': 'Ripristina password',
|
4323 | 'Reset your password': 'Resetta password',
|
4324 | 'Send Code': 'Invia codice',
|
4325 | 'Sign In': 'Accesso',
|
4326 | 'Sign Out': 'Esci',
|
4327 | 'Sign Up': 'Iscriviti',
|
4328 | 'Sign in': 'Accesso',
|
4329 | 'Sign in to your account': 'Accedi con il tuo account a',
|
4330 | Skip: 'Salta',
|
4331 | Submit: 'Sottoscrivi',
|
4332 | 'User already exists': 'Questo utente esiste già',
|
4333 | 'User does not exist': 'Questo utente non esiste',
|
4334 | Username: 'Nome utente',
|
4335 | 'Username cannot be empty': 'Nome utente non può essere vuoto',
|
4336 | Verify: 'Verifica',
|
4337 | 'Verify Contact': 'Contatto verifica'
|
4338 | },
|
4339 | zh: {
|
4340 | 'Sign In': '登录',
|
4341 | 'Sign Up': '注册',
|
4342 | 'Sign Out': '退出',
|
4343 | 'Forgot Password': '忘记密码',
|
4344 | Username: '用户名',
|
4345 | Password: '密码',
|
4346 | 'Change Password': '改变密码',
|
4347 | 'New Password': '新密码',
|
4348 | Email: '邮箱',
|
4349 | 'Phone Number': '电话',
|
4350 | 'Confirm a Code': '确认码',
|
4351 | 'Confirm Sign In': '确认登录',
|
4352 | 'Confirm Sign Up': '确认注册',
|
4353 | 'Back to Sign In': '回到登录',
|
4354 | 'Send Code': '发送确认码',
|
4355 | Confirm: '确认',
|
4356 | 'Resend a Code': '重发确认码',
|
4357 | Submit: '提交',
|
4358 | Skip: '跳过',
|
4359 | Verify: '验证',
|
4360 | 'Verify Contact': '验证联系方式',
|
4361 | Code: '确认码',
|
4362 | 'Account recovery requires verified contact information': '账户恢复需要验证过的联系方式',
|
4363 | 'User does not exist': '用户不存在',
|
4364 | 'User already exists': '用户已经存在',
|
4365 | 'Incorrect username or password': '用户名或密码错误',
|
4366 | 'Invalid password format': '密码格式错误',
|
4367 | 'Invalid phone number format': '电话格式错误,请使用格式 +12345678900'
|
4368 | },
|
4369 | ja: {
|
4370 | 'Sign In': 'サインイン ',
|
4371 | 'Sign Up': '登録 ',
|
4372 | 'Sign Out': 'サインアウト ',
|
4373 | 'Sign in to your account': 'アカウントにサインイン ',
|
4374 | Username: 'ユーザー名 ',
|
4375 | Password: 'パスワード ',
|
4376 | 'Enter your username': 'ユーザー名を入力 ',
|
4377 | 'Enter your password': 'パスワードを入力 ',
|
4378 | 'No account? ': 'アカウントが無いとき ',
|
4379 | 'Forgot your password? ': 'パスワードを忘れましたか? ',
|
4380 | 'Reset password': 'パスワードをリセット ',
|
4381 | 'User does not exist': 'ユーザーが存在しません ',
|
4382 | 'User already exists': '既にユーザーが存在しています ',
|
4383 | 'Incorrect username or password': 'ユーザー名かパスワードが異なります ',
|
4384 | 'Invalid password format': 'パスワードの形式が無効です ',
|
4385 | 'Create account': 'アカウントを作る ',
|
4386 | 'Forgot Password': 'パスワードを忘れた ',
|
4387 | 'Change Password': 'パスワードを変える ',
|
4388 | 'New Password': '新しいパスワード',
|
4389 | Email: 'メールアドレス',
|
4390 | 'Phone Number': '電話番号',
|
4391 | 'Confirm a Code': 'コードを確認',
|
4392 | 'Confirm Sign In': 'サインインする',
|
4393 | 'Confirm Sign Up': '登録する',
|
4394 | 'Back to Sign In': 'サインインに戻る',
|
4395 | 'Send Code': 'コードを送信',
|
4396 | Confirm: '確定',
|
4397 | 'Resend Code': 'コードを再送信',
|
4398 | Submit: '送信',
|
4399 | Skip: 'スキップ',
|
4400 | Verify: '確認',
|
4401 | 'Verify Contact': '連絡先を確認',
|
4402 | Code: 'コード',
|
4403 | 'Confirmation Code': '確認コード',
|
4404 | 'Lost your code? ': 'コードを失くしましたか?',
|
4405 | 'Account recovery requires verified contact information': 'アカウントの復旧には確認済みの連絡先が必要です',
|
4406 | 'Invalid phone number format': '不正な電話番号の形式です。\n+12345678900 の形式で入力してください',
|
4407 | 'Create Account': 'アカウントを作る',
|
4408 | 'Have an account? ': 'アカウントを持っていますか?',
|
4409 | 'Sign in': 'サインイン',
|
4410 | 'Create a new account': '新しいアカウントを作る',
|
4411 | 'Reset your password': 'パスワードをリセットする',
|
4412 | 'An account with the given email already exists.': '入力されたメールアドレスのアカウントが既に存在します',
|
4413 | 'Username cannot be empty': 'ユーザー名は入力必須です',
|
4414 | 'Password attempts exceeded': 'サインインの試行回数が上限に達しました',
|
4415 | 'Sign In with Google': 'Googleでサインイン',
|
4416 | 'Sign In with Facebook': 'Facebookでサインイン'
|
4417 | }
|
4418 | };
|
4419 |
|
4420 | }),
|
4421 |
|
4422 | "./lib/AmplifyMessageMap.js":
|
4423 |
|
4424 |
|
4425 |
|
4426 |
|
4427 | (function(module, exports, __webpack_require__) {
|
4428 |
|
4429 | "use strict";
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 | Object.defineProperty(exports, "__esModule", {
|
4445 | value: true
|
4446 | });
|
4447 |
|
4448 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
4449 |
|
4450 | exports.MapEntries = [['User does not exist', /user.*not.*exist/i], ['User already exists', /user.*already.*exist/i], ['Incorrect username or password', /incorrect.*username.*password/i], ['Invalid password format', /validation.*password/i], ['Invalid phone number format', /invalid.*phone/i, 'Invalid phone number format. Please use a phone number format of +12345678900']];
|
4451 |
|
4452 | function AmplifyMessageMap(message) {
|
4453 |
|
4454 | var match = exports.MapEntries.filter(function (entry) {
|
4455 | return entry[1].test(message);
|
4456 | });
|
4457 |
|
4458 | if (match.length === 0) {
|
4459 | return message;
|
4460 | }
|
4461 |
|
4462 | var entry = match[0];
|
4463 | var msg = entry.length > 2 ? entry[2] : entry[0];
|
4464 | return core_1.I18n.get(entry[0], msg);
|
4465 | }
|
4466 |
|
4467 | exports.AmplifyMessageMap = AmplifyMessageMap;
|
4468 |
|
4469 | }),
|
4470 |
|
4471 | "./lib/AmplifyTheme.js":
|
4472 |
|
4473 |
|
4474 |
|
4475 |
|
4476 | (function(module, exports, __webpack_require__) {
|
4477 |
|
4478 | "use strict";
|
4479 |
|
4480 |
|
4481 | Object.defineProperty(exports, "__esModule", {
|
4482 | value: true
|
4483 | });
|
4484 |
|
4485 |
|
4486 |
|
4487 |
|
4488 |
|
4489 |
|
4490 |
|
4491 |
|
4492 |
|
4493 |
|
4494 |
|
4495 |
|
4496 |
|
4497 | exports.Container = {
|
4498 | fontFamily: "-apple-system,\n BlinkMacSystemFont,\n \"Segoe UI\",\n Roboto,\n \"Helvetica Neue\",\n Arial,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\"",
|
4499 | fontWeight: '400',
|
4500 | lineHeight: '1.5',
|
4501 | color: '#212529',
|
4502 | textAlign: 'left',
|
4503 | paddingLeft: '15px',
|
4504 | paddingRight: '15px'
|
4505 | };
|
4506 | exports.NavBar = {
|
4507 | position: 'relative',
|
4508 | border: '1px solid transparent',
|
4509 | borderColor: '#e7e7e7'
|
4510 | };
|
4511 | exports.NavRight = {
|
4512 | textAlign: 'right'
|
4513 | };
|
4514 | exports.Nav = {
|
4515 | margin: '7.5px'
|
4516 | };
|
4517 | exports.NavItem = {
|
4518 | display: 'inline-block',
|
4519 | padding: '10px 5px',
|
4520 | lineHeight: '20px'
|
4521 | };
|
4522 | exports.NavButton = {
|
4523 | display: 'inline-block',
|
4524 | padding: '6px 12px',
|
4525 | marginTop: '8px',
|
4526 | marginBottom: '8px',
|
4527 | fontSize: '14px',
|
4528 | fontWeight: 400,
|
4529 | lineHeight: '1.42857143',
|
4530 | textAlign: 'center',
|
4531 | whiteSpace: 'nowrap',
|
4532 | verticalAlign: 'middle',
|
4533 | touchAction: 'manipulation',
|
4534 | cursor: 'pointer',
|
4535 | userSelect: 'none',
|
4536 | backgroundImage: 'none',
|
4537 | border: '1px solid transparent',
|
4538 | borderRadius: '4px',
|
4539 | color: '#333',
|
4540 | backgroundColor: '#fff',
|
4541 | borderColor: '#ccc'
|
4542 | };
|
4543 | exports.FormContainer = {
|
4544 | textAlign: 'center'
|
4545 | };
|
4546 | exports.FormSection = {
|
4547 | marginBottom: '20px',
|
4548 | backgroundColor: '#fff',
|
4549 | border: '1px solid #ddd',
|
4550 | borderRadius: '4px',
|
4551 | textAlign: 'left',
|
4552 | width: '400px',
|
4553 | display: 'inline-block'
|
4554 | };
|
4555 | exports.ErrorSection = {
|
4556 | marginBottom: '20px',
|
4557 | color: '#fff',
|
4558 | backgroundColor: '#f0ad4e',
|
4559 | border: '1px solid #eea236',
|
4560 | borderRadius: '4px',
|
4561 | textAlign: 'left'
|
4562 | };
|
4563 | exports.SectionHeader = {
|
4564 | color: '#fff',
|
4565 | backgroundColor: '#337ab7',
|
4566 | borderColor: '#337ab7',
|
4567 | padding: '10px 15px',
|
4568 | borderBottom: '1px solid transparent',
|
4569 | borderTopLeftRadius: '3px',
|
4570 | borderTopRightRadius: '3px',
|
4571 | textAlign: 'center'
|
4572 | };
|
4573 | exports.SectionFooter = {
|
4574 | color: '#333',
|
4575 | backgroundColor: '#f5f5f5',
|
4576 | padding: '10px 15px',
|
4577 | borderTop: '1px solid #ddd',
|
4578 | borderTopLeftRadius: '3px',
|
4579 | borderTopRightRadius: '3px'
|
4580 | };
|
4581 | exports.SectionBody = {
|
4582 | padding: '15px'
|
4583 | };
|
4584 | exports.FormRow = {
|
4585 | marginBottom: '15px'
|
4586 | };
|
4587 | exports.ActionRow = {
|
4588 | marginBottom: '15px'
|
4589 | };
|
4590 | exports.Input = {
|
4591 | display: 'block',
|
4592 | width: '100%',
|
4593 | height: '34px',
|
4594 | padding: '6px 12px',
|
4595 | fontSize: '14px',
|
4596 | lineHeight: '1.42857143',
|
4597 | color: '#555',
|
4598 | backgroundColor: '#fff',
|
4599 | backgroundImage: 'none',
|
4600 | border: '1px solid #ccc',
|
4601 | borderRadius: '4px',
|
4602 | boxShadow: 'inset 0 1px 1px rgba(0,0,0,.075)',
|
4603 | boxSizing: 'border-box',
|
4604 | transition: 'border-color ease-in-out .15s,box-shadow ease-in-out .15s'
|
4605 | };
|
4606 | exports.Button = {
|
4607 | display: 'inline-block',
|
4608 | padding: '6px 12px',
|
4609 | marginBottom: '0',
|
4610 | fontSize: '14px',
|
4611 | fontWeight: 400,
|
4612 | lineHeight: '1.42857143',
|
4613 | textAlign: 'center',
|
4614 | whiteSpace: 'nowrap',
|
4615 | verticalAlign: 'middle',
|
4616 | touchAction: 'manipulation',
|
4617 | cursor: 'pointer',
|
4618 | userSelect: 'none',
|
4619 | backgroundImage: 'none',
|
4620 | border: '1px solid transparent',
|
4621 | borderRadius: '4px',
|
4622 | color: '#333',
|
4623 | backgroundColor: '#fff',
|
4624 | borderColor: '#ccc'
|
4625 | };
|
4626 | exports.SignInButton = {
|
4627 | position: 'relative',
|
4628 | padding: '6px 12px 6px 44px',
|
4629 | fontSize: '14px',
|
4630 | textAlign: 'left',
|
4631 | whiteSpace: 'nowrap',
|
4632 | overflow: 'hidden',
|
4633 | textOverflow: 'ellipsis',
|
4634 | display: 'block',
|
4635 | width: '100%',
|
4636 | marginTop: '2px',
|
4637 | '#google_signin_btn': {
|
4638 | color: '#fff',
|
4639 | backgroundColor: '#dd4b39',
|
4640 | borderColor: 'rgba(0,0,0,0.2)'
|
4641 | },
|
4642 | '#facebook_signin_btn': {
|
4643 | color: '#fff',
|
4644 | backgroundColor: '#3b5998',
|
4645 | borderColor: 'rgba(0,0,0,0.2)'
|
4646 | }
|
4647 | };
|
4648 | exports.Space = {
|
4649 | display: 'inline-block',
|
4650 | width: '20px'
|
4651 | };
|
4652 | exports.A = {
|
4653 | color: '#007bff',
|
4654 | cursor: 'pointer'
|
4655 | };
|
4656 | exports.Pre = {
|
4657 | overflow: 'auto',
|
4658 | fontFamily: "Menlo,\n Monaco,\n Consolas,\n \"Courier New\",\n monospace",
|
4659 | display: 'block',
|
4660 | padding: '9.5px',
|
4661 | margin: '0 0 10px',
|
4662 | fontSize: '13px',
|
4663 | lineHeight: '1.42857143',
|
4664 | color: '#333',
|
4665 | wordBreak: 'break-all',
|
4666 | wordWrap: 'break-word',
|
4667 | backgroundColor: '#f5f5f5',
|
4668 | border: '1px solid #ccc',
|
4669 | borderRadius: '4px'
|
4670 | };
|
4671 | exports.Col1 = {
|
4672 | display: 'inline-block',
|
4673 | width: '8.33333333%'
|
4674 | };
|
4675 | exports.Col2 = {
|
4676 | display: 'inline-block',
|
4677 | width: '16.66666667%'
|
4678 | };
|
4679 | exports.Col3 = {
|
4680 | display: 'inline-block',
|
4681 | width: '25%'
|
4682 | };
|
4683 | exports.Col4 = {
|
4684 | display: 'inline-block',
|
4685 | width: '33.33333333%'
|
4686 | };
|
4687 | exports.Col5 = {
|
4688 | display: 'inline-block',
|
4689 | width: '41.66666667%'
|
4690 | };
|
4691 | exports.Col6 = {
|
4692 | display: 'inline-block',
|
4693 | width: '50%'
|
4694 | };
|
4695 | exports.Col7 = {
|
4696 | display: 'inline-block',
|
4697 | width: '58.33333333%'
|
4698 | };
|
4699 | exports.Col8 = {
|
4700 | display: 'inline-block',
|
4701 | width: '66.66666667%'
|
4702 | };
|
4703 | exports.Col9 = {
|
4704 | display: 'inline-block',
|
4705 | width: '75%'
|
4706 | };
|
4707 | exports.Col10 = {
|
4708 | display: 'inline-block',
|
4709 | width: '83.33333333%'
|
4710 | };
|
4711 | exports.Col11 = {
|
4712 | display: 'inline-block',
|
4713 | width: '91.66666667%'
|
4714 | };
|
4715 | exports.Col12 = {
|
4716 | display: 'inline-block',
|
4717 | width: '100%'
|
4718 | };
|
4719 | exports.Hidden = {
|
4720 | display: 'none'
|
4721 | };
|
4722 | exports.Bootstrap = {
|
4723 | container: exports.Container,
|
4724 | navBar: exports.NavBar,
|
4725 | nav: exports.Nav,
|
4726 | navRight: exports.NavRight,
|
4727 | navItem: exports.NavItem,
|
4728 | navButton: exports.NavButton,
|
4729 | formContainer: exports.FormContainer,
|
4730 | formSection: exports.FormSection,
|
4731 | errorSection: exports.ErrorSection,
|
4732 | sectionHeader: exports.SectionHeader,
|
4733 | sectionBody: exports.SectionBody,
|
4734 | sectionFooter: exports.SectionFooter,
|
4735 | formRow: exports.FormRow,
|
4736 | actionRow: exports.ActionRow,
|
4737 | space: exports.Space,
|
4738 | signInButton: exports.SignInButton,
|
4739 | input: exports.Input,
|
4740 | button: exports.Button,
|
4741 | a: exports.A,
|
4742 | pre: exports.Pre,
|
4743 | col1: exports.Col1,
|
4744 | col2: exports.Col2,
|
4745 | col3: exports.Col3,
|
4746 | col4: exports.Col4,
|
4747 | col5: exports.Col5,
|
4748 | col6: exports.Col6,
|
4749 | col7: exports.Col7,
|
4750 | col8: exports.Col8,
|
4751 | col9: exports.Col9,
|
4752 | col10: exports.Col10,
|
4753 | col11: exports.Col11,
|
4754 | col12: exports.Col12,
|
4755 | hidden: exports.Hidden
|
4756 | };
|
4757 |
|
4758 |
|
4759 |
|
4760 |
|
4761 | exports["default"] = exports.Bootstrap;
|
4762 |
|
4763 | }),
|
4764 |
|
4765 | "./lib/AmplifyUI.js":
|
4766 |
|
4767 |
|
4768 |
|
4769 |
|
4770 | (function(module, exports, __webpack_require__) {
|
4771 |
|
4772 | "use strict";
|
4773 |
|
4774 |
|
4775 |
|
4776 |
|
4777 |
|
4778 |
|
4779 |
|
4780 |
|
4781 |
|
4782 |
|
4783 |
|
4784 |
|
4785 |
|
4786 |
|
4787 | var __assign = this && this.__assign || function () {
|
4788 | __assign = Object.assign || function (t) {
|
4789 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4790 | s = arguments[i];
|
4791 |
|
4792 | for (var p in s) {
|
4793 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
4794 | }
|
4795 | }
|
4796 |
|
4797 | return t;
|
4798 | };
|
4799 |
|
4800 | return __assign.apply(this, arguments);
|
4801 | };
|
4802 |
|
4803 | var __importStar = this && this.__importStar || function (mod) {
|
4804 | if (mod && mod.__esModule) return mod;
|
4805 | var result = {};
|
4806 | if (mod != null) for (var k in mod) {
|
4807 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
4808 | }
|
4809 | result["default"] = mod;
|
4810 | return result;
|
4811 | };
|
4812 |
|
4813 | var __importDefault = this && this.__importDefault || function (mod) {
|
4814 | return mod && mod.__esModule ? mod : {
|
4815 | "default": mod
|
4816 | };
|
4817 | };
|
4818 |
|
4819 | Object.defineProperty(exports, "__esModule", {
|
4820 | value: true
|
4821 | });
|
4822 |
|
4823 | var React = __importStar(__webpack_require__( "react"));
|
4824 |
|
4825 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
4826 |
|
4827 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
4828 |
|
4829 | exports.Container = function (props) {
|
4830 | var theme = props.theme || AmplifyTheme_1["default"];
|
4831 | var style = exports.propStyle(props, theme.container);
|
4832 | var p = core_1.objectLessAttributes(props, 'theme');
|
4833 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4834 | className: "amplify-container",
|
4835 | style: style
|
4836 | }), props.children));
|
4837 | };
|
4838 |
|
4839 | exports.FormContainer = function (props) {
|
4840 | var theme = props.theme || AmplifyTheme_1["default"];
|
4841 | var style = exports.propStyle(props, theme.formContainer);
|
4842 | return exports.beforeAfter(React.createElement("div", {
|
4843 | className: "amplify-form-container",
|
4844 | style: style
|
4845 | }, props.children));
|
4846 | };
|
4847 |
|
4848 | exports.FormSection = function (props) {
|
4849 | var theme = props.theme || AmplifyTheme_1["default"];
|
4850 | var style = exports.propStyle(props, theme.formSection);
|
4851 | return React.createElement(exports.FormContainer, {
|
4852 | theme: theme
|
4853 | }, exports.beforeAfter(React.createElement("div", {
|
4854 | className: "amplify-form-section",
|
4855 | style: style
|
4856 | }, props.children)));
|
4857 | };
|
4858 |
|
4859 | exports.ErrorSection = function (props) {
|
4860 | var theme = props.theme || AmplifyTheme_1["default"];
|
4861 | var style = exports.propStyle(props, theme.errorSection);
|
4862 | var p = core_1.objectLessAttributes(props, 'theme');
|
4863 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4864 | className: "amplify-error-section",
|
4865 | style: style
|
4866 | }), React.createElement(exports.ErrorSectionContent, null, props.children)));
|
4867 | };
|
4868 |
|
4869 | exports.ErrorSectionContent = function (props) {
|
4870 | var theme = props.theme || AmplifyTheme_1["default"];
|
4871 | var style = exports.propStyle(props, theme.errorSectionContent);
|
4872 | return exports.beforeAfter(React.createElement("span", {
|
4873 | className: "amplify-error-section-content",
|
4874 | style: style
|
4875 | }, props.children));
|
4876 | };
|
4877 |
|
4878 | exports.SectionHeader = function (props) {
|
4879 | var theme = props.theme || AmplifyTheme_1["default"];
|
4880 | var style = exports.propStyle(props, theme.sectionHeader);
|
4881 | var p = core_1.objectLessAttributes(props, 'theme');
|
4882 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4883 | className: "amplify-section-header",
|
4884 | style: style
|
4885 | }), React.createElement(exports.SectionHeaderContent, {
|
4886 | theme: theme
|
4887 | }, props.children)));
|
4888 | };
|
4889 |
|
4890 | exports.SectionHeaderContent = function (props) {
|
4891 | var theme = props.theme || AmplifyTheme_1["default"];
|
4892 | var style = exports.propStyle(props, theme.sectionHeaderContent);
|
4893 | return exports.beforeAfter(React.createElement("span", {
|
4894 | className: "amplify-section-header-content",
|
4895 | style: style
|
4896 | }, props.children));
|
4897 | };
|
4898 |
|
4899 | exports.SectionFooter = function (props) {
|
4900 | var theme = props.theme || AmplifyTheme_1["default"];
|
4901 | var style = exports.propStyle(props, theme.sectionFooter);
|
4902 | var p = core_1.objectLessAttributes(props, 'theme');
|
4903 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4904 | className: "amplify-section-footer",
|
4905 | style: style
|
4906 | }), React.createElement(exports.SectionFooterContent, {
|
4907 | theme: theme
|
4908 | }, props.children)));
|
4909 | };
|
4910 |
|
4911 | exports.SectionFooterContent = function (props) {
|
4912 | var theme = props.theme || AmplifyTheme_1["default"];
|
4913 | var style = exports.propStyle(props, theme.sectionFooterContent);
|
4914 | return exports.beforeAfter(React.createElement("span", {
|
4915 | className: "amplify-section-footer-content",
|
4916 | style: style
|
4917 | }, props.children));
|
4918 | };
|
4919 |
|
4920 | exports.SectionBody = function (props) {
|
4921 | var theme = props.theme || AmplifyTheme_1["default"];
|
4922 | var style = exports.propStyle(props, theme.sectionBody);
|
4923 | var p = core_1.objectLessAttributes(props, 'theme');
|
4924 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4925 | className: "amplify-section-body",
|
4926 | style: style
|
4927 | }), props.children));
|
4928 | };
|
4929 |
|
4930 | exports.ActionRow = function (props) {
|
4931 | var theme = props.theme || AmplifyTheme_1["default"];
|
4932 | var style = exports.propStyle(props, theme.actionRow);
|
4933 | var p = core_1.objectLessAttributes(props, 'theme');
|
4934 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4935 | className: "amplify-action-row",
|
4936 | style: style
|
4937 | }), props.children));
|
4938 | };
|
4939 |
|
4940 | exports.FormRow = function (props) {
|
4941 | var theme = props.theme || AmplifyTheme_1["default"];
|
4942 | var style = exports.propStyle(props, theme.formRow);
|
4943 | var p = core_1.objectLessAttributes(props, 'theme');
|
4944 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
4945 | className: "amplify-form-row",
|
4946 | style: style
|
4947 | }), props.children));
|
4948 | };
|
4949 |
|
4950 | exports.InputRow = function (props) {
|
4951 | var theme = props.theme || AmplifyTheme_1["default"];
|
4952 | var style = exports.propStyle(props, theme.input);
|
4953 | var p = core_1.objectLessAttributes(props, 'theme');
|
4954 | return React.createElement(exports.FormRow, {
|
4955 | theme: theme
|
4956 | }, exports.beforeAfter(React.createElement("input", __assign({}, p, {
|
4957 | className: "amplify-input",
|
4958 | style: style
|
4959 | }))));
|
4960 | };
|
4961 |
|
4962 | exports.RadioRow = function (props) {
|
4963 | var id = props.id || '_' + props.value;
|
4964 | var theme = props.theme || AmplifyTheme_1["default"];
|
4965 | return React.createElement(exports.FormRow, {
|
4966 | theme: theme
|
4967 | }, React.createElement(exports.Radio, __assign({}, props, {
|
4968 | id: id
|
4969 | })), React.createElement(exports.Label, {
|
4970 | htmlFor: id,
|
4971 | theme: theme
|
4972 | }, props.placeholder));
|
4973 | };
|
4974 |
|
4975 | exports.Radio = function (props) {
|
4976 | var theme = props.theme || AmplifyTheme_1["default"];
|
4977 | var style = exports.propStyle(props, theme.radio);
|
4978 | var p = core_1.objectLessAttributes(props, 'theme');
|
4979 | return exports.beforeAfter(React.createElement("input", __assign({}, p, {
|
4980 | type: "radio",
|
4981 | className: "amplify-radio",
|
4982 | style: style
|
4983 | })));
|
4984 | };
|
4985 |
|
4986 | exports.CheckboxRow = function (props) {
|
4987 | var id = props.id || '_' + props.name;
|
4988 | var theme = props.theme || AmplifyTheme_1["default"];
|
4989 | return React.createElement(exports.FormRow, {
|
4990 | theme: theme
|
4991 | }, React.createElement(exports.Checkbox, __assign({}, props, {
|
4992 | id: id
|
4993 | })), React.createElement(exports.Label, {
|
4994 | htmlFor: id,
|
4995 | theme: theme
|
4996 | }, props.placeholder));
|
4997 | };
|
4998 |
|
4999 | exports.Checkbox = function (props) {
|
5000 | var theme = props.theme || AmplifyTheme_1["default"];
|
5001 | var style = exports.propStyle(props, theme.checkbox);
|
5002 | var p = core_1.objectLessAttributes(props, 'theme');
|
5003 | return exports.beforeAfter(React.createElement("input", __assign({}, p, {
|
5004 | type: "checkbox",
|
5005 | className: "amplify-checkbox",
|
5006 | style: style
|
5007 | })));
|
5008 | };
|
5009 |
|
5010 | exports.MessageRow = function (props) {
|
5011 | var theme = props.theme || AmplifyTheme_1["default"];
|
5012 | return React.createElement(exports.FormRow, {
|
5013 | theme: theme
|
5014 | }, React.createElement(exports.MessageContent, {
|
5015 | theme: theme
|
5016 | }, props.children));
|
5017 | };
|
5018 |
|
5019 | exports.MessageContent = function (props) {
|
5020 | var theme = props.theme || AmplifyTheme_1["default"];
|
5021 | return exports.beforeAfter(React.createElement("span", {
|
5022 | className: "amplify-message-content",
|
5023 | style: theme.messageContent
|
5024 | }, props.children));
|
5025 | };
|
5026 |
|
5027 | exports.ButtonRow = function (props) {
|
5028 | var theme = props.theme || AmplifyTheme_1["default"];
|
5029 | return exports.beforeAfter(React.createElement("div", {
|
5030 | className: "amplify-action-row",
|
5031 | style: theme.actionRow
|
5032 | }, React.createElement(exports.Button, __assign({}, props))));
|
5033 | };
|
5034 |
|
5035 | exports.Button = function (props) {
|
5036 | var theme = props.theme || AmplifyTheme_1["default"];
|
5037 | var style = exports.propStyle(props, theme.button);
|
5038 | var p = core_1.objectLessAttributes(props, 'theme');
|
5039 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
5040 | className: "amplify-button",
|
5041 | style: style
|
5042 | }), React.createElement(exports.ButtonContent, {
|
5043 | theme: theme
|
5044 | }, props.children)));
|
5045 | };
|
5046 |
|
5047 | exports.ButtonContent = function (props) {
|
5048 | var theme = props.theme || AmplifyTheme_1["default"];
|
5049 | return exports.beforeAfter(React.createElement("span", {
|
5050 | className: "amplify-button-content",
|
5051 | style: theme.buttonContent
|
5052 | }, props.children));
|
5053 | };
|
5054 |
|
5055 | exports.SignInButton = function (props) {
|
5056 | var theme = props.theme || AmplifyTheme_1["default"];
|
5057 | var style = exports.propStyle(props, theme.signInButton);
|
5058 | var p = core_1.objectLessAttributes(props, 'theme');
|
5059 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
5060 | className: "amplify-signin-button",
|
5061 | style: style
|
5062 | }), props.children));
|
5063 | };
|
5064 |
|
5065 | exports.Link = function (props) {
|
5066 | var theme = props.theme || AmplifyTheme_1["default"];
|
5067 | var style = exports.propStyle(props, theme.a);
|
5068 | var p = core_1.objectLessAttributes(props, 'theme');
|
5069 | return exports.beforeAfter(React.createElement("a", __assign({}, p, {
|
5070 | className: "amplify-a",
|
5071 | style: style
|
5072 | }), props.children));
|
5073 | };
|
5074 |
|
5075 | exports.Label = function (props) {
|
5076 | var theme = props.theme || AmplifyTheme_1["default"];
|
5077 | var style = exports.propStyle(props, theme.label);
|
5078 | var p = core_1.objectLessAttributes(props, 'theme');
|
5079 | return exports.beforeAfter(React.createElement("label", __assign({}, p, {
|
5080 | className: "amplify-label",
|
5081 | style: style
|
5082 | }), props.children));
|
5083 | };
|
5084 |
|
5085 | exports.Space = function (props) {
|
5086 | var theme = props.theme || AmplifyTheme_1["default"];
|
5087 | var style = exports.propStyle(props, theme.space);
|
5088 | var p = core_1.objectLessAttributes(props, 'theme');
|
5089 | return exports.beforeAfter(React.createElement("span", __assign({}, p, {
|
5090 | className: "amplify-space",
|
5091 | style: style
|
5092 | }), props.children));
|
5093 | };
|
5094 |
|
5095 | exports.NavBar = function (props) {
|
5096 | var theme = props.theme || AmplifyTheme_1["default"];
|
5097 | var style = exports.propStyle(props, theme.navBar);
|
5098 | var p = core_1.objectLessAttributes(props, 'theme');
|
5099 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
5100 | className: "amplify-nav-bar",
|
5101 | style: style
|
5102 | }), props.children));
|
5103 | };
|
5104 |
|
5105 | exports.Nav = function (props) {
|
5106 | var theme = props.theme || AmplifyTheme_1["default"];
|
5107 | var style = exports.propStyle(props, theme.nav);
|
5108 | var p = core_1.objectLessAttributes(props, 'theme');
|
5109 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
5110 | className: "amplify-nav",
|
5111 | style: style
|
5112 | }), props.children));
|
5113 | };
|
5114 |
|
5115 | exports.NavRight = function (props) {
|
5116 | var theme = props.theme || AmplifyTheme_1["default"];
|
5117 | var style = exports.propStyle(props, theme.navRight);
|
5118 | var p = core_1.objectLessAttributes(props, 'theme');
|
5119 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
5120 | className: "amplify-nav-right",
|
5121 | style: style
|
5122 | }), props.children));
|
5123 | };
|
5124 |
|
5125 | exports.NavItem = function (props) {
|
5126 | var theme = props.theme || AmplifyTheme_1["default"];
|
5127 | var style = exports.propStyle(props, theme.navItem);
|
5128 | var p = core_1.objectLessAttributes(props, 'theme');
|
5129 | return exports.beforeAfter(React.createElement("div", __assign({}, p, {
|
5130 | className: "amplify-nav-item",
|
5131 | style: style
|
5132 | }), props.children));
|
5133 | };
|
5134 |
|
5135 | exports.NavButton = function (props) {
|
5136 | var theme = props.theme || AmplifyTheme_1["default"];
|
5137 | var style = exports.propStyle(props, theme.navButton);
|
5138 | var p = core_1.objectLessAttributes(props, 'theme');
|
5139 | return exports.beforeAfter(React.createElement("button", __assign({}, p, {
|
5140 | className: "amplify-nav-button",
|
5141 | style: style
|
5142 | }), exports.beforeAfter(React.createElement("span", {
|
5143 | style: theme.navButtonContent
|
5144 | }, props.children))));
|
5145 | };
|
5146 |
|
5147 | exports.beforeAfter = function (el) {
|
5148 | var style = el.props.style || {};
|
5149 | var before = style.before,
|
5150 | after = style.after;
|
5151 |
|
5152 | if (!before && !after) {
|
5153 | return el;
|
5154 | }
|
5155 |
|
5156 | return React.createElement("span", {
|
5157 | style: {
|
5158 | position: 'relative'
|
5159 | }
|
5160 | }, before ? React.createElement("span", {
|
5161 | style: before
|
5162 | }, before.content) : null, el, after ? React.createElement("span", {
|
5163 | style: after
|
5164 | }, after.content) : null);
|
5165 | };
|
5166 |
|
5167 | exports.propStyle = function (props, themeStyle) {
|
5168 | var id = props.id,
|
5169 | style = props.style;
|
5170 | var styl = Object.assign({}, style, themeStyle);
|
5171 |
|
5172 | if (!id) {
|
5173 | return styl;
|
5174 | }
|
5175 |
|
5176 | var selector = '#' + id;
|
5177 | Object.assign(styl, styl[selector]);
|
5178 | return styl;
|
5179 | };
|
5180 |
|
5181 | exports.transparent1X1 = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
|
5182 | exports.white1X1 = 'data:image/gif;base64,R0lGODlhAQABAIAAAP7//wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
|
5183 |
|
5184 | }),
|
5185 |
|
5186 | "./lib/Analytics/index.js":
|
5187 |
|
5188 |
|
5189 |
|
5190 |
|
5191 | (function(module, exports, __webpack_require__) {
|
5192 |
|
5193 | "use strict";
|
5194 |
|
5195 |
|
5196 |
|
5197 |
|
5198 |
|
5199 |
|
5200 |
|
5201 |
|
5202 |
|
5203 |
|
5204 |
|
5205 |
|
5206 |
|
5207 |
|
5208 | function __export(m) {
|
5209 | for (var p in m) {
|
5210 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
5211 | }
|
5212 | }
|
5213 |
|
5214 | Object.defineProperty(exports, "__esModule", {
|
5215 | value: true
|
5216 | });
|
5217 |
|
5218 | __export(__webpack_require__( "./lib/Analytics/trackLifecycle.js"));
|
5219 |
|
5220 | __export(__webpack_require__( "./lib/Analytics/trackUpdate.js"));
|
5221 |
|
5222 | }),
|
5223 |
|
5224 | "./lib/Analytics/trackLifecycle.js":
|
5225 |
|
5226 |
|
5227 |
|
5228 |
|
5229 | (function(module, exports, __webpack_require__) {
|
5230 |
|
5231 | "use strict";
|
5232 |
|
5233 |
|
5234 |
|
5235 |
|
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 |
|
5241 |
|
5242 |
|
5243 |
|
5244 |
|
5245 |
|
5246 | var __extends = this && this.__extends || function () {
|
5247 | var _extendStatics = function extendStatics(d, b) {
|
5248 | _extendStatics = Object.setPrototypeOf || {
|
5249 | __proto__: []
|
5250 | } instanceof Array && function (d, b) {
|
5251 | d.__proto__ = b;
|
5252 | } || function (d, b) {
|
5253 | for (var p in b) {
|
5254 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
5255 | }
|
5256 | };
|
5257 |
|
5258 | return _extendStatics(d, b);
|
5259 | };
|
5260 |
|
5261 | return function (d, b) {
|
5262 | _extendStatics(d, b);
|
5263 |
|
5264 | function __() {
|
5265 | this.constructor = d;
|
5266 | }
|
5267 |
|
5268 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5269 | };
|
5270 | }();
|
5271 |
|
5272 | var __assign = this && this.__assign || function () {
|
5273 | __assign = Object.assign || function (t) {
|
5274 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5275 | s = arguments[i];
|
5276 |
|
5277 | for (var p in s) {
|
5278 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
5279 | }
|
5280 | }
|
5281 |
|
5282 | return t;
|
5283 | };
|
5284 |
|
5285 | return __assign.apply(this, arguments);
|
5286 | };
|
5287 |
|
5288 | var __importStar = this && this.__importStar || function (mod) {
|
5289 | if (mod && mod.__esModule) return mod;
|
5290 | var result = {};
|
5291 | if (mod != null) for (var k in mod) {
|
5292 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
5293 | }
|
5294 | result["default"] = mod;
|
5295 | return result;
|
5296 | };
|
5297 |
|
5298 | Object.defineProperty(exports, "__esModule", {
|
5299 | value: true
|
5300 | });
|
5301 |
|
5302 | var React = __importStar(__webpack_require__( "react"));
|
5303 |
|
5304 | var analytics_1 = __webpack_require__( "@aws-amplify/analytics");
|
5305 |
|
5306 | var Default_Track_Events = ['componentDidMount', 'componentDidUpdate', 'compomentWillUnmount', 'compomentDidCatch', 'render'];
|
5307 |
|
5308 | function trackLifecycle(Comp, trackerName, events) {
|
5309 | if (events === void 0) {
|
5310 | events = Default_Track_Events;
|
5311 | }
|
5312 |
|
5313 | return (
|
5314 |
|
5315 | function (_super) {
|
5316 | __extends(WithTrackLifecycle, _super);
|
5317 |
|
5318 | function WithTrackLifecycle(props) {
|
5319 | var _this = _super.call(this, props) || this;
|
5320 |
|
5321 | _this.trackerName = trackerName;
|
5322 | _this.trackEvents = events;
|
5323 |
|
5324 | _this.track('constructor');
|
5325 |
|
5326 | return _this;
|
5327 | }
|
5328 |
|
5329 | WithTrackLifecycle.prototype.track = function (event) {
|
5330 | var filtered = this.trackEvents.filter(function (item) {
|
5331 | return item === event;
|
5332 | });
|
5333 |
|
5334 | if (filtered.length > 0) {
|
5335 | if (analytics_1.Analytics && typeof analytics_1.Analytics.record === 'function') {
|
5336 | analytics_1.Analytics.record({
|
5337 | name: this.trackerName,
|
5338 | attributes: {
|
5339 | event: event
|
5340 | }
|
5341 | });
|
5342 | } else {
|
5343 | throw new Error('No Analytics module found, please ensure @aws-amplify/analytics is imported');
|
5344 | }
|
5345 | }
|
5346 | };
|
5347 |
|
5348 | WithTrackLifecycle.prototype.componentWillMount = function () {
|
5349 | this.track('componentWillMount');
|
5350 | };
|
5351 |
|
5352 | WithTrackLifecycle.prototype.componentDidMount = function () {
|
5353 | this.track('componentDidMount');
|
5354 | };
|
5355 |
|
5356 | WithTrackLifecycle.prototype.componentWillUnmount = function () {
|
5357 | this.track('componentWillUnmount');
|
5358 | };
|
5359 |
|
5360 | WithTrackLifecycle.prototype.componentDidCatch = function () {
|
5361 | this.track('componentDidCatch');
|
5362 | };
|
5363 |
|
5364 | WithTrackLifecycle.prototype.componentWillReceiveProps = function () {
|
5365 | this.track('componentWillReceiveProps');
|
5366 | };
|
5367 |
|
5368 | WithTrackLifecycle.prototype.shouldComponentUpdate = function () {
|
5369 | this.track('shouldComponentUpdate');
|
5370 | return true;
|
5371 | };
|
5372 |
|
5373 | WithTrackLifecycle.prototype.componentWillUpdate = function () {
|
5374 | this.track('componentWillUpdate');
|
5375 | };
|
5376 |
|
5377 | WithTrackLifecycle.prototype.componentDidUpdate = function () {
|
5378 | this.track('componentDidUpdate');
|
5379 | };
|
5380 |
|
5381 | WithTrackLifecycle.prototype.setState = function () {
|
5382 | this.track('setState');
|
5383 | };
|
5384 |
|
5385 | WithTrackLifecycle.prototype.forceUpdate = function () {
|
5386 | this.track('forceUpdate');
|
5387 | };
|
5388 |
|
5389 | WithTrackLifecycle.prototype.render = function () {
|
5390 | this.track('render');
|
5391 | return React.createElement(Comp, __assign({}, this.props));
|
5392 | };
|
5393 |
|
5394 | return WithTrackLifecycle;
|
5395 | }(React.Component)
|
5396 | );
|
5397 | }
|
5398 |
|
5399 | exports.trackLifecycle = trackLifecycle;
|
5400 |
|
5401 | }),
|
5402 |
|
5403 | "./lib/Analytics/trackUpdate.js":
|
5404 |
|
5405 |
|
5406 |
|
5407 |
|
5408 | (function(module, exports, __webpack_require__) {
|
5409 |
|
5410 | "use strict";
|
5411 |
|
5412 |
|
5413 |
|
5414 |
|
5415 |
|
5416 |
|
5417 |
|
5418 |
|
5419 |
|
5420 |
|
5421 |
|
5422 |
|
5423 |
|
5424 |
|
5425 | var __extends = this && this.__extends || function () {
|
5426 | var _extendStatics = function extendStatics(d, b) {
|
5427 | _extendStatics = Object.setPrototypeOf || {
|
5428 | __proto__: []
|
5429 | } instanceof Array && function (d, b) {
|
5430 | d.__proto__ = b;
|
5431 | } || function (d, b) {
|
5432 | for (var p in b) {
|
5433 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
5434 | }
|
5435 | };
|
5436 |
|
5437 | return _extendStatics(d, b);
|
5438 | };
|
5439 |
|
5440 | return function (d, b) {
|
5441 | _extendStatics(d, b);
|
5442 |
|
5443 | function __() {
|
5444 | this.constructor = d;
|
5445 | }
|
5446 |
|
5447 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5448 | };
|
5449 | }();
|
5450 |
|
5451 | var __assign = this && this.__assign || function () {
|
5452 | __assign = Object.assign || function (t) {
|
5453 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5454 | s = arguments[i];
|
5455 |
|
5456 | for (var p in s) {
|
5457 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
5458 | }
|
5459 | }
|
5460 |
|
5461 | return t;
|
5462 | };
|
5463 |
|
5464 | return __assign.apply(this, arguments);
|
5465 | };
|
5466 |
|
5467 | var __importStar = this && this.__importStar || function (mod) {
|
5468 | if (mod && mod.__esModule) return mod;
|
5469 | var result = {};
|
5470 | if (mod != null) for (var k in mod) {
|
5471 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
5472 | }
|
5473 | result["default"] = mod;
|
5474 | return result;
|
5475 | };
|
5476 |
|
5477 | Object.defineProperty(exports, "__esModule", {
|
5478 | value: true
|
5479 | });
|
5480 |
|
5481 | var React = __importStar(__webpack_require__( "react"));
|
5482 |
|
5483 | var analytics_1 = __webpack_require__( "@aws-amplify/analytics");
|
5484 |
|
5485 | function trackUpdate(Comp, trackerName) {
|
5486 | return (
|
5487 |
|
5488 | function (_super) {
|
5489 | __extends(class_1, _super);
|
5490 |
|
5491 | function class_1(props) {
|
5492 | var _this = _super.call(this, props) || this;
|
5493 |
|
5494 | _this.trackerName = trackerName;
|
5495 | return _this;
|
5496 | }
|
5497 |
|
5498 | class_1.prototype.componentDidUpdate = function (prevProps, prevState) {
|
5499 | var attributes = Object.assign({}, this.props, this.state);
|
5500 |
|
5501 | if (analytics_1.Analytics && typeof analytics_1.Analytics.record === 'function') {
|
5502 | analytics_1.Analytics.record({
|
5503 | name: this.trackerName,
|
5504 | attributes: attributes
|
5505 | });
|
5506 | } else {
|
5507 | throw new Error('No Analytics module found, please ensure @aws-amplify/analytics is imported');
|
5508 | }
|
5509 | };
|
5510 |
|
5511 | class_1.prototype.render = function () {
|
5512 | return React.createElement(Comp, __assign({}, this.props));
|
5513 | };
|
5514 |
|
5515 | return class_1;
|
5516 | }(React.Component)
|
5517 | );
|
5518 | }
|
5519 |
|
5520 | exports.trackUpdate = trackUpdate;
|
5521 |
|
5522 | }),
|
5523 |
|
5524 | "./lib/Auth/AuthPiece.js":
|
5525 |
|
5526 |
|
5527 |
|
5528 |
|
5529 | (function(module, exports, __webpack_require__) {
|
5530 |
|
5531 | "use strict";
|
5532 |
|
5533 |
|
5534 |
|
5535 |
|
5536 |
|
5537 |
|
5538 |
|
5539 |
|
5540 |
|
5541 |
|
5542 |
|
5543 |
|
5544 |
|
5545 |
|
5546 | function _typeof(obj) {
|
5547 | "@babel/helpers - typeof";
|
5548 |
|
5549 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
5550 | _typeof = function _typeof(obj) {
|
5551 | return typeof obj;
|
5552 | };
|
5553 | } else {
|
5554 | _typeof = function _typeof(obj) {
|
5555 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
5556 | };
|
5557 | }
|
5558 |
|
5559 | return _typeof(obj);
|
5560 | }
|
5561 |
|
5562 | var __extends = this && this.__extends || function () {
|
5563 | var _extendStatics = function extendStatics(d, b) {
|
5564 | _extendStatics = Object.setPrototypeOf || {
|
5565 | __proto__: []
|
5566 | } instanceof Array && function (d, b) {
|
5567 | d.__proto__ = b;
|
5568 | } || function (d, b) {
|
5569 | for (var p in b) {
|
5570 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
5571 | }
|
5572 | };
|
5573 |
|
5574 | return _extendStatics(d, b);
|
5575 | };
|
5576 |
|
5577 | return function (d, b) {
|
5578 | _extendStatics(d, b);
|
5579 |
|
5580 | function __() {
|
5581 | this.constructor = d;
|
5582 | }
|
5583 |
|
5584 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5585 | };
|
5586 | }();
|
5587 |
|
5588 | var __importStar = this && this.__importStar || function (mod) {
|
5589 | if (mod && mod.__esModule) return mod;
|
5590 | var result = {};
|
5591 | if (mod != null) for (var k in mod) {
|
5592 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
5593 | }
|
5594 | result["default"] = mod;
|
5595 | return result;
|
5596 | };
|
5597 |
|
5598 | var __importDefault = this && this.__importDefault || function (mod) {
|
5599 | return mod && mod.__esModule ? mod : {
|
5600 | "default": mod
|
5601 | };
|
5602 | };
|
5603 |
|
5604 | var _a;
|
5605 |
|
5606 | Object.defineProperty(exports, "__esModule", {
|
5607 | value: true
|
5608 | });
|
5609 |
|
5610 | var React = __importStar(__webpack_require__( "react"));
|
5611 |
|
5612 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
5613 |
|
5614 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
5615 |
|
5616 | var types_1 = __webpack_require__( "./lib/Auth/common/types.js");
|
5617 |
|
5618 | var PhoneField_1 = __webpack_require__( "./lib/Auth/PhoneField.js");
|
5619 |
|
5620 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
5621 |
|
5622 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
5623 |
|
5624 | var labelMap = (_a = {}, _a[types_1.UsernameAttributes.EMAIL] = 'Email', _a[types_1.UsernameAttributes.PHONE_NUMBER] = 'Phone Number', _a[types_1.UsernameAttributes.USERNAME] = 'Username', _a);
|
5625 |
|
5626 | var AuthPiece =
|
5627 |
|
5628 | function (_super) {
|
5629 | __extends(AuthPiece, _super);
|
5630 |
|
5631 | function AuthPiece(props) {
|
5632 | var _this = _super.call(this, props) || this;
|
5633 |
|
5634 | _this.inputs = {};
|
5635 | _this._isHidden = true;
|
5636 | _this._validAuthStates = [];
|
5637 | _this.phone_number = '';
|
5638 | _this.changeState = _this.changeState.bind(_this);
|
5639 | _this.error = _this.error.bind(_this);
|
5640 | _this.handleInputChange = _this.handleInputChange.bind(_this);
|
5641 | _this.renderUsernameField = _this.renderUsernameField.bind(_this);
|
5642 | _this.getUsernameFromInput = _this.getUsernameFromInput.bind(_this);
|
5643 | _this.onPhoneNumberChanged = _this.onPhoneNumberChanged.bind(_this);
|
5644 | return _this;
|
5645 | }
|
5646 |
|
5647 | AuthPiece.prototype.componentDidMount = function () {
|
5648 | if (window && window.location && window.location.search) {
|
5649 | if (!this.props.authData || !this.props.authData.username) {
|
5650 | var searchParams = new URLSearchParams(window.location.search);
|
5651 | var username = searchParams ? searchParams.get('username') : undefined;
|
5652 | this.setState({
|
5653 | username: username
|
5654 | });
|
5655 | }
|
5656 | }
|
5657 | };
|
5658 |
|
5659 | AuthPiece.prototype.getUsernameFromInput = function () {
|
5660 | var _a = this.props.usernameAttributes,
|
5661 | usernameAttributes = _a === void 0 ? 'username' : _a;
|
5662 |
|
5663 | switch (usernameAttributes) {
|
5664 | case types_1.UsernameAttributes.EMAIL:
|
5665 | return this.inputs.email;
|
5666 |
|
5667 | case types_1.UsernameAttributes.PHONE_NUMBER:
|
5668 | return this.phone_number;
|
5669 |
|
5670 | default:
|
5671 | return this.inputs.username || this.state.username;
|
5672 | }
|
5673 | };
|
5674 |
|
5675 | AuthPiece.prototype.onPhoneNumberChanged = function (phone_number) {
|
5676 | this.phone_number = phone_number;
|
5677 | };
|
5678 |
|
5679 | AuthPiece.prototype.renderUsernameField = function (theme) {
|
5680 | var _a = this.props.usernameAttributes,
|
5681 | usernameAttributes = _a === void 0 ? [] : _a;
|
5682 |
|
5683 | if (usernameAttributes === types_1.UsernameAttributes.EMAIL) {
|
5684 | return React.createElement(Amplify_UI_Components_React_1.FormField, {
|
5685 | theme: theme
|
5686 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
5687 | theme: theme
|
5688 | }, core_1.I18n.get('Email'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
5689 | autoFocus: true,
|
5690 | placeholder: core_1.I18n.get('Enter your email'),
|
5691 | theme: theme,
|
5692 | key: "email",
|
5693 | name: "email",
|
5694 | type: "email",
|
5695 | onChange: this.handleInputChange,
|
5696 | "data-test": data_test_attributes_1.auth.genericAttrs.emailInput
|
5697 | }));
|
5698 | } else if (usernameAttributes === types_1.UsernameAttributes.PHONE_NUMBER) {
|
5699 | return React.createElement(PhoneField_1.PhoneField, {
|
5700 | theme: theme,
|
5701 | onChangeText: this.onPhoneNumberChanged
|
5702 | });
|
5703 | } else {
|
5704 | return React.createElement(Amplify_UI_Components_React_1.FormField, {
|
5705 | theme: theme
|
5706 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
5707 | theme: theme
|
5708 | }, core_1.I18n.get(this.getUsernameLabel()), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
5709 | defaultValue: this.state.username,
|
5710 | autoFocus: true,
|
5711 | placeholder: core_1.I18n.get('Enter your username'),
|
5712 | theme: theme,
|
5713 | key: "username",
|
5714 | name: "username",
|
5715 | onChange: this.handleInputChange,
|
5716 | "data-test": data_test_attributes_1.auth.genericAttrs.usernameInput
|
5717 | }));
|
5718 | }
|
5719 | };
|
5720 |
|
5721 | AuthPiece.prototype.getUsernameLabel = function () {
|
5722 | var _a = this.props.usernameAttributes,
|
5723 | usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
|
5724 | return labelMap[usernameAttributes] || usernameAttributes;
|
5725 | };
|
5726 |
|
5727 |
|
5728 | AuthPiece.prototype.usernameFromAuthData = function () {
|
5729 | var authData = this.props.authData;
|
5730 |
|
5731 | if (!authData) {
|
5732 | return '';
|
5733 | }
|
5734 |
|
5735 | var username = '';
|
5736 |
|
5737 | if (_typeof(authData) === 'object') {
|
5738 |
|
5739 | username = authData.user ? authData.user.username : authData.username;
|
5740 | } else {
|
5741 | username = authData;
|
5742 | }
|
5743 |
|
5744 | return username;
|
5745 | };
|
5746 |
|
5747 | AuthPiece.prototype.errorMessage = function (err) {
|
5748 | if (typeof err === 'string') {
|
5749 | return err;
|
5750 | }
|
5751 |
|
5752 | return err.message ? err.message : JSON.stringify(err);
|
5753 | };
|
5754 |
|
5755 | AuthPiece.prototype.triggerAuthEvent = function (event) {
|
5756 | var state = this.props.authState;
|
5757 |
|
5758 | if (this.props.onAuthEvent) {
|
5759 | this.props.onAuthEvent(state, event);
|
5760 | }
|
5761 | };
|
5762 |
|
5763 | AuthPiece.prototype.changeState = function (state, data) {
|
5764 | if (this.props.onStateChange) {
|
5765 | this.props.onStateChange(state, data);
|
5766 | }
|
5767 |
|
5768 | this.triggerAuthEvent({
|
5769 | type: 'stateChange',
|
5770 | data: state
|
5771 | });
|
5772 | };
|
5773 |
|
5774 | AuthPiece.prototype.error = function (err) {
|
5775 | this.triggerAuthEvent({
|
5776 | type: 'error',
|
5777 | data: this.errorMessage(err)
|
5778 | });
|
5779 | };
|
5780 |
|
5781 | AuthPiece.prototype.handleInputChange = function (evt) {
|
5782 | this.inputs = this.inputs || {};
|
5783 | var _a = evt.target,
|
5784 | name = _a.name,
|
5785 | value = _a.value,
|
5786 | type = _a.type,
|
5787 | checked = _a.checked;
|
5788 | var check_type = ['radio', 'checkbox'].includes(type);
|
5789 | this.inputs[name] = check_type ? checked : value;
|
5790 | this.inputs['checkedValue'] = check_type ? value : null;
|
5791 | };
|
5792 |
|
5793 | AuthPiece.prototype.render = function () {
|
5794 | if (!this._validAuthStates.includes(this.props.authState)) {
|
5795 | this._isHidden = true;
|
5796 | this.inputs = {};
|
5797 | return null;
|
5798 | }
|
5799 |
|
5800 | if (this._isHidden) {
|
5801 | this.inputs = {};
|
5802 | var track = this.props.track;
|
5803 | if (track) track();
|
5804 | }
|
5805 |
|
5806 | this._isHidden = false;
|
5807 | return this.showComponent(this.props.theme || AmplifyTheme_1["default"]);
|
5808 | };
|
5809 |
|
5810 | AuthPiece.prototype.showComponent = function (_theme) {
|
5811 | throw 'You must implement showComponent(theme) and don\'t forget to set this._validAuthStates.';
|
5812 | };
|
5813 |
|
5814 | return AuthPiece;
|
5815 | }(React.Component);
|
5816 |
|
5817 | exports.AuthPiece = AuthPiece;
|
5818 |
|
5819 |
|
5820 |
|
5821 |
|
5822 | exports["default"] = AuthPiece;
|
5823 |
|
5824 | }),
|
5825 |
|
5826 | "./lib/Auth/Authenticator.js":
|
5827 |
|
5828 |
|
5829 |
|
5830 |
|
5831 | (function(module, exports, __webpack_require__) {
|
5832 |
|
5833 | "use strict";
|
5834 |
|
5835 |
|
5836 |
|
5837 |
|
5838 |
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 | function _typeof(obj) {
|
5849 | "@babel/helpers - typeof";
|
5850 |
|
5851 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
5852 | _typeof = function _typeof(obj) {
|
5853 | return typeof obj;
|
5854 | };
|
5855 | } else {
|
5856 | _typeof = function _typeof(obj) {
|
5857 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
5858 | };
|
5859 | }
|
5860 |
|
5861 | return _typeof(obj);
|
5862 | }
|
5863 |
|
5864 | var __extends = this && this.__extends || function () {
|
5865 | var _extendStatics = function extendStatics(d, b) {
|
5866 | _extendStatics = Object.setPrototypeOf || {
|
5867 | __proto__: []
|
5868 | } instanceof Array && function (d, b) {
|
5869 | d.__proto__ = b;
|
5870 | } || function (d, b) {
|
5871 | for (var p in b) {
|
5872 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
5873 | }
|
5874 | };
|
5875 |
|
5876 | return _extendStatics(d, b);
|
5877 | };
|
5878 |
|
5879 | return function (d, b) {
|
5880 | _extendStatics(d, b);
|
5881 |
|
5882 | function __() {
|
5883 | this.constructor = d;
|
5884 | }
|
5885 |
|
5886 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
5887 | };
|
5888 | }();
|
5889 |
|
5890 | var __importStar = this && this.__importStar || function (mod) {
|
5891 | if (mod && mod.__esModule) return mod;
|
5892 | var result = {};
|
5893 | if (mod != null) for (var k in mod) {
|
5894 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
5895 | }
|
5896 | result["default"] = mod;
|
5897 | return result;
|
5898 | };
|
5899 |
|
5900 | var __importDefault = this && this.__importDefault || function (mod) {
|
5901 | return mod && mod.__esModule ? mod : {
|
5902 | "default": mod
|
5903 | };
|
5904 | };
|
5905 |
|
5906 | Object.defineProperty(exports, "__esModule", {
|
5907 | value: true
|
5908 | });
|
5909 |
|
5910 | var React = __importStar(__webpack_require__( "react"));
|
5911 |
|
5912 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
5913 |
|
5914 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
5915 |
|
5916 | var Greetings_1 = __webpack_require__( "./lib/Auth/Greetings.js");
|
5917 |
|
5918 | var SignIn_1 = __webpack_require__( "./lib/Auth/SignIn.js");
|
5919 |
|
5920 | var ConfirmSignIn_1 = __webpack_require__( "./lib/Auth/ConfirmSignIn.js");
|
5921 |
|
5922 | var RequireNewPassword_1 = __webpack_require__( "./lib/Auth/RequireNewPassword.js");
|
5923 |
|
5924 | var SignUp_1 = __webpack_require__( "./lib/Auth/SignUp.js");
|
5925 |
|
5926 | var Loading_1 = __webpack_require__( "./lib/Auth/Loading.js");
|
5927 |
|
5928 | var ConfirmSignUp_1 = __webpack_require__( "./lib/Auth/ConfirmSignUp.js");
|
5929 |
|
5930 | var VerifyContact_1 = __webpack_require__( "./lib/Auth/VerifyContact.js");
|
5931 |
|
5932 | var ForgotPassword_1 = __webpack_require__( "./lib/Auth/ForgotPassword.js");
|
5933 |
|
5934 | var TOTPSetup_1 = __webpack_require__( "./lib/Auth/TOTPSetup.js");
|
5935 |
|
5936 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
5937 |
|
5938 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
5939 |
|
5940 | var AmplifyMessageMap_1 = __webpack_require__( "./lib/AmplifyMessageMap.js");
|
5941 |
|
5942 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
5943 |
|
5944 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
5945 |
|
5946 | var logger = new core_1.ConsoleLogger('Authenticator');
|
5947 | var AUTHENTICATOR_AUTHSTATE = 'amplify-authenticator-authState';
|
5948 |
|
5949 | exports.EmptyContainer = function (_a) {
|
5950 | var children = _a.children;
|
5951 | return React.createElement(React.Fragment, null, children);
|
5952 | };
|
5953 |
|
5954 | var Authenticator =
|
5955 |
|
5956 | function (_super) {
|
5957 | __extends(Authenticator, _super);
|
5958 |
|
5959 | function Authenticator(props) {
|
5960 | var _this = _super.call(this, props) || this;
|
5961 |
|
5962 | _this.handleStateChange = _this.handleStateChange.bind(_this);
|
5963 | _this.handleAuthEvent = _this.handleAuthEvent.bind(_this);
|
5964 | _this.onHubCapsule = _this.onHubCapsule.bind(_this);
|
5965 | _this._initialAuthState = _this.props.authState || 'signIn';
|
5966 | _this.state = {
|
5967 | authState: 'loading'
|
5968 | };
|
5969 | core_1.Hub.listen('auth', _this.onHubCapsule);
|
5970 | return _this;
|
5971 | }
|
5972 |
|
5973 | Authenticator.prototype.componentDidMount = function () {
|
5974 | var config = this.props.amplifyConfig;
|
5975 |
|
5976 | if (config) {
|
5977 | core_1.Amplify.configure(config);
|
5978 | }
|
5979 |
|
5980 | this._isMounted = true;
|
5981 |
|
5982 |
|
5983 |
|
5984 |
|
5985 |
|
5986 |
|
5987 | var byHostedUI = localStorage.getItem(constants_1.Constants.REDIRECTED_FROM_HOSTED_UI);
|
5988 | localStorage.removeItem(constants_1.Constants.REDIRECTED_FROM_HOSTED_UI);
|
5989 | if (byHostedUI !== 'true') this.checkUser();
|
5990 | };
|
5991 |
|
5992 | Authenticator.prototype.componentWillUnmount = function () {
|
5993 | this._isMounted = false;
|
5994 | };
|
5995 |
|
5996 | Authenticator.prototype.checkUser = function () {
|
5997 | var _this = this;
|
5998 |
|
5999 | if (!auth_1.Auth || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
|
6000 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6001 | }
|
6002 |
|
6003 | return auth_1.Auth.currentAuthenticatedUser().then(function (user) {
|
6004 | if (!_this._isMounted) {
|
6005 | return;
|
6006 | }
|
6007 |
|
6008 | _this.handleStateChange('signedIn', user);
|
6009 | })["catch"](function (err) {
|
6010 | if (!_this._isMounted) {
|
6011 | return;
|
6012 | }
|
6013 |
|
6014 | var cachedAuthState = null;
|
6015 |
|
6016 | try {
|
6017 | cachedAuthState = localStorage.getItem(AUTHENTICATOR_AUTHSTATE);
|
6018 | } catch (e) {
|
6019 | logger.debug('Failed to get the auth state from local storage', e);
|
6020 | }
|
6021 |
|
6022 | var promise = cachedAuthState === 'signedIn' ? auth_1.Auth.signOut() : Promise.resolve();
|
6023 | promise.then(function () {
|
6024 | return _this.handleStateChange(_this._initialAuthState);
|
6025 | })["catch"](function (e) {
|
6026 | logger.debug('Failed to sign out', e);
|
6027 | });
|
6028 | });
|
6029 | };
|
6030 |
|
6031 | Authenticator.prototype.checkContact = function (user, changeState) {
|
6032 | if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
|
6033 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6034 | }
|
6035 |
|
6036 | auth_1.Auth.verifiedContact(user).then(function (data) {
|
6037 | if (!core_1.isEmpty(data.verified)) {
|
6038 | changeState('signedIn', user);
|
6039 | } else {
|
6040 | user = Object.assign(user, data);
|
6041 | changeState('verifyContact', user);
|
6042 | }
|
6043 | });
|
6044 | };
|
6045 |
|
6046 | Authenticator.prototype.onHubCapsule = function (capsule) {
|
6047 | var channel = capsule.channel,
|
6048 | payload = capsule.payload,
|
6049 | source = capsule.source;
|
6050 |
|
6051 | if (channel === 'auth') {
|
6052 | switch (payload.event) {
|
6053 | case 'cognitoHostedUI':
|
6054 | case 'signIn':
|
6055 | this.checkContact(payload.data, this.handleStateChange);
|
6056 | break;
|
6057 |
|
6058 | case 'cognitoHostedUI_failure':
|
6059 | this.handleStateChange('signIn', null);
|
6060 | break;
|
6061 |
|
6062 | case 'parsingUrl_failure':
|
6063 | this.handleStateChange('signIn', null);
|
6064 | break;
|
6065 |
|
6066 | case 'signOut':
|
6067 | this.handleStateChange('signIn', null);
|
6068 | break;
|
6069 |
|
6070 | case 'customGreetingSignOut':
|
6071 | this.handleStateChange('signIn', null);
|
6072 | break;
|
6073 |
|
6074 | default:
|
6075 | break;
|
6076 | }
|
6077 | }
|
6078 | };
|
6079 |
|
6080 | Authenticator.prototype.handleStateChange = function (state, data) {
|
6081 | logger.debug('authenticator state change ' + state, data);
|
6082 |
|
6083 | if (state === this.state.authState) {
|
6084 | return;
|
6085 | }
|
6086 |
|
6087 | if (state === 'signedOut') {
|
6088 | state = 'signIn';
|
6089 | }
|
6090 |
|
6091 | try {
|
6092 | localStorage.setItem(AUTHENTICATOR_AUTHSTATE, state);
|
6093 | } catch (e) {
|
6094 | logger.debug('Failed to set the auth state into local storage', e);
|
6095 | }
|
6096 |
|
6097 | if (this._isMounted) {
|
6098 | this.setState({
|
6099 | authState: state,
|
6100 | authData: data,
|
6101 | error: null,
|
6102 | showToast: false
|
6103 | });
|
6104 | }
|
6105 |
|
6106 | if (this.props.onStateChange) {
|
6107 | this.props.onStateChange(state, data);
|
6108 | }
|
6109 | };
|
6110 |
|
6111 | Authenticator.prototype.handleAuthEvent = function (state, event, showToast) {
|
6112 | if (showToast === void 0) {
|
6113 | showToast = true;
|
6114 | }
|
6115 |
|
6116 | if (event.type === 'error') {
|
6117 | var map = this.props.errorMessage || AmplifyMessageMap_1.AmplifyMessageMap;
|
6118 | var message = typeof map === 'string' ? map : map(event.data);
|
6119 | this.setState({
|
6120 | error: message,
|
6121 | showToast: showToast
|
6122 | });
|
6123 | }
|
6124 | };
|
6125 |
|
6126 | Authenticator.prototype.render = function () {
|
6127 | var _this = this;
|
6128 |
|
6129 | var _a = this.state,
|
6130 | authState = _a.authState,
|
6131 | authData = _a.authData;
|
6132 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
6133 | var messageMap = this.props.errorMessage || AmplifyMessageMap_1.AmplifyMessageMap;
|
6134 |
|
6135 |
|
6136 |
|
6137 | var Wrapper = this.props.container === undefined ? Amplify_UI_Components_React_1.Container : this.props.container || exports.EmptyContainer;
|
6138 | var _b = this.props,
|
6139 | hideDefault = _b.hideDefault,
|
6140 | _c = _b.hide,
|
6141 | hide = _c === void 0 ? [] : _c,
|
6142 | federated = _b.federated,
|
6143 | signUpConfig = _b.signUpConfig,
|
6144 | usernameAttributes = _b.usernameAttributes;
|
6145 |
|
6146 | if (hideDefault) {
|
6147 | hide = hide.concat([Greetings_1.Greetings, SignIn_1.SignIn, ConfirmSignIn_1.ConfirmSignIn, RequireNewPassword_1.RequireNewPassword, SignUp_1.SignUp, ConfirmSignUp_1.ConfirmSignUp, VerifyContact_1.VerifyContact, ForgotPassword_1.ForgotPassword, TOTPSetup_1.TOTPSetup, Loading_1.Loading]);
|
6148 | }
|
6149 |
|
6150 | var props_children = [];
|
6151 |
|
6152 | if (_typeof(this.props.children) === 'object') {
|
6153 | if (Array.isArray(this.props.children)) {
|
6154 | props_children = this.props.children;
|
6155 | } else {
|
6156 | props_children.push(this.props.children);
|
6157 | }
|
6158 | }
|
6159 |
|
6160 | var default_children = [React.createElement(Greetings_1.Greetings, {
|
6161 | federated: federated
|
6162 | }), React.createElement(SignIn_1.SignIn, {
|
6163 | federated: federated
|
6164 | }), React.createElement(ConfirmSignIn_1.ConfirmSignIn, null), React.createElement(RequireNewPassword_1.RequireNewPassword, null), React.createElement(SignUp_1.SignUp, {
|
6165 | signUpConfig: signUpConfig
|
6166 | }), React.createElement(ConfirmSignUp_1.ConfirmSignUp, null), React.createElement(VerifyContact_1.VerifyContact, null), React.createElement(ForgotPassword_1.ForgotPassword, null), React.createElement(TOTPSetup_1.TOTPSetup, null), React.createElement(Loading_1.Loading, null)];
|
6167 | var props_children_override = React.Children.map(props_children, function (child) {
|
6168 | return child.props.override;
|
6169 | });
|
6170 | hide = hide.filter(function (component) {
|
6171 | return !props_children.find(function (child) {
|
6172 | return child.type === component;
|
6173 | });
|
6174 | });
|
6175 | var render_props_children = React.Children.map(props_children, function (child, index) {
|
6176 | return React.cloneElement(child, {
|
6177 | key: 'aws-amplify-authenticator-props-children-' + index,
|
6178 | theme: theme,
|
6179 | messageMap: messageMap,
|
6180 | authState: authState,
|
6181 | authData: authData,
|
6182 | onStateChange: _this.handleStateChange,
|
6183 | onAuthEvent: _this.handleAuthEvent,
|
6184 | hide: hide,
|
6185 | override: props_children_override,
|
6186 | usernameAttributes: usernameAttributes
|
6187 | });
|
6188 | });
|
6189 | var render_default_children = hideDefault ? [] : React.Children.map(default_children, function (child, index) {
|
6190 | return React.cloneElement(child, {
|
6191 | key: 'aws-amplify-authenticator-default-children-' + index,
|
6192 | theme: theme,
|
6193 | messageMap: messageMap,
|
6194 | authState: authState,
|
6195 | authData: authData,
|
6196 | onStateChange: _this.handleStateChange,
|
6197 | onAuthEvent: _this.handleAuthEvent,
|
6198 | hide: hide,
|
6199 | override: props_children_override,
|
6200 | usernameAttributes: usernameAttributes
|
6201 | });
|
6202 | });
|
6203 | var render_children = render_default_children.concat(render_props_children);
|
6204 | var error = this.state.error;
|
6205 | return React.createElement(Wrapper, {
|
6206 | theme: theme
|
6207 | }, this.state.showToast && React.createElement(Amplify_UI_Components_React_1.Toast, {
|
6208 | theme: theme,
|
6209 | onClose: function onClose() {
|
6210 | return _this.setState({
|
6211 | showToast: false
|
6212 | });
|
6213 | },
|
6214 | "data-test": data_test_attributes_1.auth.signIn.signInError
|
6215 | }, core_1.I18n.get(error)), render_children);
|
6216 | };
|
6217 |
|
6218 | return Authenticator;
|
6219 | }(React.Component);
|
6220 |
|
6221 | exports.Authenticator = Authenticator;
|
6222 |
|
6223 |
|
6224 |
|
6225 |
|
6226 | exports["default"] = Authenticator;
|
6227 |
|
6228 | }),
|
6229 |
|
6230 | "./lib/Auth/ConfirmSignIn.js":
|
6231 |
|
6232 |
|
6233 |
|
6234 |
|
6235 | (function(module, exports, __webpack_require__) {
|
6236 |
|
6237 | "use strict";
|
6238 |
|
6239 |
|
6240 |
|
6241 |
|
6242 |
|
6243 |
|
6244 |
|
6245 |
|
6246 |
|
6247 |
|
6248 |
|
6249 |
|
6250 |
|
6251 |
|
6252 | var __extends = this && this.__extends || function () {
|
6253 | var _extendStatics = function extendStatics(d, b) {
|
6254 | _extendStatics = Object.setPrototypeOf || {
|
6255 | __proto__: []
|
6256 | } instanceof Array && function (d, b) {
|
6257 | d.__proto__ = b;
|
6258 | } || function (d, b) {
|
6259 | for (var p in b) {
|
6260 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
6261 | }
|
6262 | };
|
6263 |
|
6264 | return _extendStatics(d, b);
|
6265 | };
|
6266 |
|
6267 | return function (d, b) {
|
6268 | _extendStatics(d, b);
|
6269 |
|
6270 | function __() {
|
6271 | this.constructor = d;
|
6272 | }
|
6273 |
|
6274 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6275 | };
|
6276 | }();
|
6277 |
|
6278 | var __importStar = this && this.__importStar || function (mod) {
|
6279 | if (mod && mod.__esModule) return mod;
|
6280 | var result = {};
|
6281 | if (mod != null) for (var k in mod) {
|
6282 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6283 | }
|
6284 | result["default"] = mod;
|
6285 | return result;
|
6286 | };
|
6287 |
|
6288 | Object.defineProperty(exports, "__esModule", {
|
6289 | value: true
|
6290 | });
|
6291 |
|
6292 | var React = __importStar(__webpack_require__( "react"));
|
6293 |
|
6294 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
6295 |
|
6296 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
6297 |
|
6298 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
6299 |
|
6300 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
6301 |
|
6302 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
6303 |
|
6304 | var ConfirmSignIn =
|
6305 |
|
6306 | function (_super) {
|
6307 | __extends(ConfirmSignIn, _super);
|
6308 |
|
6309 | function ConfirmSignIn(props) {
|
6310 | var _this = _super.call(this, props) || this;
|
6311 |
|
6312 | _this._validAuthStates = ['confirmSignIn'];
|
6313 | _this.confirm = _this.confirm.bind(_this);
|
6314 | _this.checkContact = _this.checkContact.bind(_this);
|
6315 | _this.state = {
|
6316 | mfaType: 'SMS'
|
6317 | };
|
6318 | return _this;
|
6319 | }
|
6320 |
|
6321 | ConfirmSignIn.prototype.checkContact = function (user) {
|
6322 | var _this = this;
|
6323 |
|
6324 | if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
|
6325 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6326 | }
|
6327 |
|
6328 | auth_1.Auth.verifiedContact(user).then(function (data) {
|
6329 | if (!core_1.isEmpty(data.verified)) {
|
6330 | _this.changeState('signedIn', user);
|
6331 | } else {
|
6332 | var newUser = Object.assign(user, data);
|
6333 |
|
6334 | _this.changeState('verifyContact', newUser);
|
6335 | }
|
6336 | });
|
6337 | };
|
6338 |
|
6339 | ConfirmSignIn.prototype.confirm = function (event) {
|
6340 | var _this = this;
|
6341 |
|
6342 | if (event) {
|
6343 | event.preventDefault();
|
6344 | }
|
6345 |
|
6346 | var user = this.props.authData;
|
6347 | var code = this.inputs.code;
|
6348 | var mfaType = user.challengeName === 'SOFTWARE_TOKEN_MFA' ? 'SOFTWARE_TOKEN_MFA' : null;
|
6349 |
|
6350 | if (!auth_1.Auth || typeof auth_1.Auth.confirmSignIn !== 'function') {
|
6351 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6352 | }
|
6353 |
|
6354 | auth_1.Auth.confirmSignIn(user, code, mfaType).then(function () {
|
6355 | _this.checkContact(user);
|
6356 | })["catch"](function (err) {
|
6357 | return _this.error(err);
|
6358 | });
|
6359 | };
|
6360 |
|
6361 | ConfirmSignIn.prototype.componentDidUpdate = function () {
|
6362 |
|
6363 | var user = this.props.authData;
|
6364 | var mfaType = user && user.challengeName === 'SOFTWARE_TOKEN_MFA' ? 'TOTP' : 'SMS';
|
6365 | if (this.state.mfaType !== mfaType) this.setState({
|
6366 | mfaType: mfaType
|
6367 | });
|
6368 | };
|
6369 |
|
6370 | ConfirmSignIn.prototype.showComponent = function (theme) {
|
6371 | var _this = this;
|
6372 |
|
6373 | var hide = this.props.hide;
|
6374 |
|
6375 | if (hide && hide.includes(ConfirmSignIn)) {
|
6376 | return null;
|
6377 | }
|
6378 |
|
6379 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
6380 | theme: theme,
|
6381 | "data-test": data_test_attributes_1.auth.confirmSignIn.section
|
6382 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
6383 | theme: theme,
|
6384 | "data-test": data_test_attributes_1.auth.confirmSignIn.headerSection
|
6385 | }, core_1.I18n.get('Confirm ' + this.state.mfaType + ' Code')), React.createElement("form", {
|
6386 | onSubmit: this.confirm,
|
6387 | "data-test": data_test_attributes_1.auth.confirmSignIn.bodySection
|
6388 | }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
6389 | theme: theme
|
6390 | }, React.createElement(Amplify_UI_Components_React_1.FormField, {
|
6391 | theme: theme
|
6392 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
6393 | theme: theme
|
6394 | }, core_1.I18n.get('Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
6395 | autoFocus: true,
|
6396 | placeholder: core_1.I18n.get('Code'),
|
6397 | theme: theme,
|
6398 | key: "code",
|
6399 | name: "code",
|
6400 | autoComplete: "off",
|
6401 | onChange: this.handleInputChange,
|
6402 | "data-test": data_test_attributes_1.auth.confirmSignIn.codeInput
|
6403 | }))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
6404 | theme: theme
|
6405 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
6406 | theme: theme,
|
6407 | "data-test": data_test_attributes_1.auth.confirmSignIn.confirmButton
|
6408 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
6409 | theme: theme,
|
6410 | type: "submit"
|
6411 | }, core_1.I18n.get('Confirm'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
6412 | theme: theme
|
6413 | }, React.createElement(Amplify_UI_Components_React_1.Link, {
|
6414 | theme: theme,
|
6415 | onClick: function onClick() {
|
6416 | return _this.changeState('signIn');
|
6417 | },
|
6418 | "data-test": data_test_attributes_1.auth.confirmSignIn.backToSignInLink
|
6419 | }, core_1.I18n.get('Back to Sign In'))))));
|
6420 | };
|
6421 |
|
6422 | return ConfirmSignIn;
|
6423 | }(AuthPiece_1.AuthPiece);
|
6424 |
|
6425 | exports.ConfirmSignIn = ConfirmSignIn;
|
6426 |
|
6427 |
|
6428 |
|
6429 |
|
6430 | exports["default"] = ConfirmSignIn;
|
6431 |
|
6432 | }),
|
6433 |
|
6434 | "./lib/Auth/ConfirmSignUp.js":
|
6435 |
|
6436 |
|
6437 |
|
6438 |
|
6439 | (function(module, exports, __webpack_require__) {
|
6440 |
|
6441 | "use strict";
|
6442 |
|
6443 |
|
6444 |
|
6445 |
|
6446 |
|
6447 |
|
6448 |
|
6449 |
|
6450 |
|
6451 |
|
6452 |
|
6453 |
|
6454 |
|
6455 |
|
6456 | var __extends = this && this.__extends || function () {
|
6457 | var _extendStatics = function extendStatics(d, b) {
|
6458 | _extendStatics = Object.setPrototypeOf || {
|
6459 | __proto__: []
|
6460 | } instanceof Array && function (d, b) {
|
6461 | d.__proto__ = b;
|
6462 | } || function (d, b) {
|
6463 | for (var p in b) {
|
6464 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
6465 | }
|
6466 | };
|
6467 |
|
6468 | return _extendStatics(d, b);
|
6469 | };
|
6470 |
|
6471 | return function (d, b) {
|
6472 | _extendStatics(d, b);
|
6473 |
|
6474 | function __() {
|
6475 | this.constructor = d;
|
6476 | }
|
6477 |
|
6478 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6479 | };
|
6480 | }();
|
6481 |
|
6482 | var __importStar = this && this.__importStar || function (mod) {
|
6483 | if (mod && mod.__esModule) return mod;
|
6484 | var result = {};
|
6485 | if (mod != null) for (var k in mod) {
|
6486 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6487 | }
|
6488 | result["default"] = mod;
|
6489 | return result;
|
6490 | };
|
6491 |
|
6492 | Object.defineProperty(exports, "__esModule", {
|
6493 | value: true
|
6494 | });
|
6495 |
|
6496 | var React = __importStar(__webpack_require__( "react"));
|
6497 |
|
6498 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
6499 |
|
6500 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
6501 |
|
6502 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
6503 |
|
6504 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
6505 |
|
6506 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
6507 |
|
6508 | var logger = new core_1.ConsoleLogger('ConfirmSignUp');
|
6509 |
|
6510 | var ConfirmSignUp =
|
6511 |
|
6512 | function (_super) {
|
6513 | __extends(ConfirmSignUp, _super);
|
6514 |
|
6515 | function ConfirmSignUp(props) {
|
6516 | var _this = _super.call(this, props) || this;
|
6517 |
|
6518 | _this._validAuthStates = ['confirmSignUp'];
|
6519 | _this.confirm = _this.confirm.bind(_this);
|
6520 | _this.resend = _this.resend.bind(_this);
|
6521 | return _this;
|
6522 | }
|
6523 |
|
6524 | ConfirmSignUp.prototype.confirm = function () {
|
6525 | var _this = this;
|
6526 |
|
6527 | var username = this.usernameFromAuthData() || this.inputs.username;
|
6528 | var code = this.inputs.code;
|
6529 |
|
6530 | if (!auth_1.Auth || typeof auth_1.Auth.confirmSignUp !== 'function') {
|
6531 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6532 | }
|
6533 |
|
6534 | auth_1.Auth.confirmSignUp(username, code).then(function () {
|
6535 | return _this.changeState('signedUp');
|
6536 | })["catch"](function (err) {
|
6537 | return _this.error(err);
|
6538 | });
|
6539 | };
|
6540 |
|
6541 | ConfirmSignUp.prototype.resend = function () {
|
6542 | var _this = this;
|
6543 |
|
6544 | var username = this.usernameFromAuthData() || this.inputs.username;
|
6545 |
|
6546 | if (!auth_1.Auth || typeof auth_1.Auth.resendSignUp !== 'function') {
|
6547 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6548 | }
|
6549 |
|
6550 | auth_1.Auth.resendSignUp(username).then(function () {
|
6551 | return logger.debug('code resent');
|
6552 | })["catch"](function (err) {
|
6553 | return _this.error(err);
|
6554 | });
|
6555 | };
|
6556 |
|
6557 | ConfirmSignUp.prototype.showComponent = function (theme) {
|
6558 | var _this = this;
|
6559 |
|
6560 | var hide = this.props.hide;
|
6561 | var username = this.usernameFromAuthData();
|
6562 |
|
6563 | if (hide && hide.includes(ConfirmSignUp)) {
|
6564 | return null;
|
6565 | }
|
6566 |
|
6567 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
6568 | theme: theme,
|
6569 | "data-test": data_test_attributes_1.auth.confirmSignUp.section
|
6570 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
6571 | theme: theme,
|
6572 | "data-test": data_test_attributes_1.auth.confirmSignUp.headerSection
|
6573 | }, core_1.I18n.get('Confirm Sign Up')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
6574 | theme: theme,
|
6575 | "data-test": data_test_attributes_1.auth.confirmSignUp.bodySection
|
6576 | }, React.createElement(Amplify_UI_Components_React_1.FormField, {
|
6577 | theme: theme
|
6578 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
6579 | theme: theme
|
6580 | }, core_1.I18n.get(this.getUsernameLabel()), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
6581 | placeholder: core_1.I18n.get('Username'),
|
6582 | theme: theme,
|
6583 | key: "username",
|
6584 | name: "username",
|
6585 | onChange: this.handleInputChange,
|
6586 | disabled: username,
|
6587 | value: username ? username : '',
|
6588 | "data-test": data_test_attributes_1.auth.confirmSignUp.usernameInput
|
6589 | })), React.createElement(Amplify_UI_Components_React_1.FormField, {
|
6590 | theme: theme
|
6591 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
6592 | theme: theme
|
6593 | }, core_1.I18n.get('Confirmation Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
6594 | autoFocus: true,
|
6595 | placeholder: core_1.I18n.get('Enter your code'),
|
6596 | theme: theme,
|
6597 | key: "code",
|
6598 | name: "code",
|
6599 | autoComplete: "off",
|
6600 | onChange: this.handleInputChange,
|
6601 | "data-test": data_test_attributes_1.auth.confirmSignUp.confirmationCodeInput
|
6602 | }), React.createElement(Amplify_UI_Components_React_1.Hint, {
|
6603 | theme: theme
|
6604 | }, core_1.I18n.get('Lost your code? '), React.createElement(Amplify_UI_Components_React_1.Link, {
|
6605 | theme: theme,
|
6606 | onClick: this.resend,
|
6607 | "data-test": data_test_attributes_1.auth.confirmSignUp.resendCodeLink
|
6608 | }, core_1.I18n.get('Resend Code'))))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
6609 | theme: theme
|
6610 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
6611 | theme: theme
|
6612 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
6613 | theme: theme,
|
6614 | onClick: this.confirm,
|
6615 | "data-test": data_test_attributes_1.auth.confirmSignUp.confirmButton
|
6616 | }, core_1.I18n.get('Confirm'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
6617 | theme: theme
|
6618 | }, React.createElement(Amplify_UI_Components_React_1.Link, {
|
6619 | theme: theme,
|
6620 | onClick: function onClick() {
|
6621 | return _this.changeState('signIn');
|
6622 | },
|
6623 | "data-test": data_test_attributes_1.auth.confirmSignUp.backToSignInLink
|
6624 | }, core_1.I18n.get('Back to Sign In')))));
|
6625 | };
|
6626 |
|
6627 | return ConfirmSignUp;
|
6628 | }(AuthPiece_1.AuthPiece);
|
6629 |
|
6630 | exports.ConfirmSignUp = ConfirmSignUp;
|
6631 |
|
6632 |
|
6633 |
|
6634 |
|
6635 | exports["default"] = ConfirmSignUp;
|
6636 |
|
6637 | }),
|
6638 |
|
6639 | "./lib/Auth/FederatedSignIn.js":
|
6640 |
|
6641 |
|
6642 |
|
6643 |
|
6644 | (function(module, exports, __webpack_require__) {
|
6645 |
|
6646 | "use strict";
|
6647 |
|
6648 |
|
6649 | var __extends = this && this.__extends || function () {
|
6650 | var _extendStatics = function extendStatics(d, b) {
|
6651 | _extendStatics = Object.setPrototypeOf || {
|
6652 | __proto__: []
|
6653 | } instanceof Array && function (d, b) {
|
6654 | d.__proto__ = b;
|
6655 | } || function (d, b) {
|
6656 | for (var p in b) {
|
6657 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
6658 | }
|
6659 | };
|
6660 |
|
6661 | return _extendStatics(d, b);
|
6662 | };
|
6663 |
|
6664 | return function (d, b) {
|
6665 | _extendStatics(d, b);
|
6666 |
|
6667 | function __() {
|
6668 | this.constructor = d;
|
6669 | }
|
6670 |
|
6671 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6672 | };
|
6673 | }();
|
6674 |
|
6675 | var __importStar = this && this.__importStar || function (mod) {
|
6676 | if (mod && mod.__esModule) return mod;
|
6677 | var result = {};
|
6678 | if (mod != null) for (var k in mod) {
|
6679 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6680 | }
|
6681 | result["default"] = mod;
|
6682 | return result;
|
6683 | };
|
6684 |
|
6685 | var __importDefault = this && this.__importDefault || function (mod) {
|
6686 | return mod && mod.__esModule ? mod : {
|
6687 | "default": mod
|
6688 | };
|
6689 | };
|
6690 |
|
6691 | Object.defineProperty(exports, "__esModule", {
|
6692 | value: true
|
6693 | });
|
6694 |
|
6695 | var React = __importStar(__webpack_require__( "react"));
|
6696 |
|
6697 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
6698 |
|
6699 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
6700 |
|
6701 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
6702 |
|
6703 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
6704 |
|
6705 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
6706 |
|
6707 | var Provider_1 = __webpack_require__( "./lib/Auth/Provider/index.js");
|
6708 |
|
6709 | var logger = new core_1.ConsoleLogger('FederatedSignIn');
|
6710 |
|
6711 | var FederatedButtons =
|
6712 |
|
6713 | function (_super) {
|
6714 | __extends(FederatedButtons, _super);
|
6715 |
|
6716 | function FederatedButtons() {
|
6717 | return _super !== null && _super.apply(this, arguments) || this;
|
6718 | }
|
6719 |
|
6720 | FederatedButtons.prototype.google = function (google_client_id) {
|
6721 | if (!google_client_id) {
|
6722 | return null;
|
6723 | }
|
6724 |
|
6725 | var _a = this.props,
|
6726 | theme = _a.theme,
|
6727 | onStateChange = _a.onStateChange;
|
6728 | return React.createElement(Provider_1.GoogleButton, {
|
6729 | google_client_id: google_client_id,
|
6730 | theme: theme,
|
6731 | onStateChange: onStateChange
|
6732 | });
|
6733 | };
|
6734 |
|
6735 | FederatedButtons.prototype.facebook = function (facebook_app_id) {
|
6736 | if (!facebook_app_id) {
|
6737 | return null;
|
6738 | }
|
6739 |
|
6740 | var _a = this.props,
|
6741 | theme = _a.theme,
|
6742 | onStateChange = _a.onStateChange;
|
6743 | return React.createElement(Provider_1.FacebookButton, {
|
6744 | facebook_app_id: facebook_app_id,
|
6745 | theme: theme,
|
6746 | onStateChange: onStateChange
|
6747 | });
|
6748 | };
|
6749 |
|
6750 | FederatedButtons.prototype.amazon = function (amazon_client_id) {
|
6751 | if (!amazon_client_id) {
|
6752 | return null;
|
6753 | }
|
6754 |
|
6755 | var _a = this.props,
|
6756 | theme = _a.theme,
|
6757 | onStateChange = _a.onStateChange;
|
6758 | return React.createElement(Provider_1.AmazonButton, {
|
6759 | amazon_client_id: amazon_client_id,
|
6760 | theme: theme,
|
6761 | onStateChange: onStateChange
|
6762 | });
|
6763 | };
|
6764 |
|
6765 | FederatedButtons.prototype.OAuth = function (oauth_config) {
|
6766 | if (!oauth_config) {
|
6767 | return null;
|
6768 | }
|
6769 |
|
6770 | var _a = this.props,
|
6771 | theme = _a.theme,
|
6772 | onStateChange = _a.onStateChange;
|
6773 | return React.createElement(Provider_1.OAuthButton, {
|
6774 | label: oauth_config ? oauth_config.label : undefined,
|
6775 | theme: theme,
|
6776 | onStateChange: onStateChange
|
6777 | });
|
6778 | };
|
6779 |
|
6780 | FederatedButtons.prototype.auth0 = function (auth0) {
|
6781 | if (!auth0) {
|
6782 | return null;
|
6783 | }
|
6784 |
|
6785 | var _a = this.props,
|
6786 | theme = _a.theme,
|
6787 | onStateChange = _a.onStateChange;
|
6788 | return React.createElement(Provider_1.Auth0Button, {
|
6789 | label: auth0 ? auth0.label : undefined,
|
6790 | theme: theme,
|
6791 | onStateChange: onStateChange,
|
6792 | auth0: auth0
|
6793 | });
|
6794 | };
|
6795 |
|
6796 | FederatedButtons.prototype.render = function () {
|
6797 | var authState = this.props.authState;
|
6798 |
|
6799 | if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
|
6800 | return null;
|
6801 | }
|
6802 |
|
6803 | var federated = this.props.federated || {};
|
6804 |
|
6805 | if (!auth_1.Auth || typeof auth_1.Auth.configure !== 'function') {
|
6806 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6807 | }
|
6808 |
|
6809 |
|
6810 | var _a = auth_1.Auth.configure().oauth,
|
6811 | oauth = _a === void 0 ? {} : _a;
|
6812 |
|
6813 | if (oauth['domain']) {
|
6814 | federated.oauth_config = Object.assign({}, federated.oauth_config, oauth);
|
6815 | } else if (oauth.awsCognito) {
|
6816 |
|
6817 | federated.oauth_config = Object.assign({}, federated.oauth_config,
|
6818 | oauth.awsCognito);
|
6819 | }
|
6820 |
|
6821 |
|
6822 | if (oauth.auth0) {
|
6823 |
|
6824 | federated.auth0 = Object.assign({}, federated.auth0, oauth.auth0);
|
6825 | }
|
6826 |
|
6827 | if (core_1.isEmpty(federated)) {
|
6828 | return null;
|
6829 | }
|
6830 |
|
6831 | var google_client_id = federated.google_client_id,
|
6832 | facebook_app_id = federated.facebook_app_id,
|
6833 | amazon_client_id = federated.amazon_client_id,
|
6834 | oauth_config = federated.oauth_config,
|
6835 | auth0 = federated.auth0;
|
6836 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
6837 | return React.createElement("div", null, React.createElement("div", null, this.google(google_client_id)), React.createElement("div", null, this.facebook(facebook_app_id)), React.createElement("div", null, this.amazon(amazon_client_id)), React.createElement("div", null, this.OAuth(oauth_config)), React.createElement("div", null, this.auth0(auth0)), React.createElement(Amplify_UI_Components_React_1.Strike, {
|
6838 | theme: theme
|
6839 | }, core_1.I18n.get('or')));
|
6840 | };
|
6841 |
|
6842 | return FederatedButtons;
|
6843 | }(React.Component);
|
6844 |
|
6845 | exports.FederatedButtons = FederatedButtons;
|
6846 |
|
6847 | var FederatedSignIn =
|
6848 |
|
6849 | function (_super) {
|
6850 | __extends(FederatedSignIn, _super);
|
6851 |
|
6852 | function FederatedSignIn() {
|
6853 | return _super !== null && _super.apply(this, arguments) || this;
|
6854 | }
|
6855 |
|
6856 | FederatedSignIn.prototype.render = function () {
|
6857 | var _a = this.props,
|
6858 | authState = _a.authState,
|
6859 | onStateChange = _a.onStateChange;
|
6860 | var federated = this.props.federated || {};
|
6861 |
|
6862 | if (!auth_1.Auth || typeof auth_1.Auth.configure !== 'function') {
|
6863 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
6864 | }
|
6865 |
|
6866 |
|
6867 | var _b = auth_1.Auth.configure().oauth,
|
6868 | oauth = _b === void 0 ? {} : _b;
|
6869 |
|
6870 | if (oauth['domain']) {
|
6871 | federated.oauth_config = Object.assign({}, federated.oauth_config, oauth);
|
6872 | } else if (oauth.awsCognito) {
|
6873 |
|
6874 | federated.oauth_config = Object.assign({}, federated.oauth_config,
|
6875 | oauth.awsCognito);
|
6876 | }
|
6877 |
|
6878 |
|
6879 | if (oauth.auth0) {
|
6880 |
|
6881 | federated.auth0 = Object.assign({}, federated.auth0, oauth.auth0);
|
6882 | }
|
6883 |
|
6884 | if (!federated) {
|
6885 | logger.debug('federated prop is empty. show nothing');
|
6886 | logger.debug('federated={google_client_id: , facebook_app_id: , amazon_client_id}');
|
6887 | return null;
|
6888 | }
|
6889 |
|
6890 |
|
6891 | if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
|
6892 | return null;
|
6893 | }
|
6894 |
|
6895 | logger.debug('federated Config is', federated);
|
6896 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
6897 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
6898 | theme: theme,
|
6899 | "data-test": data_test_attributes_1.auth.federatedSignIn.section
|
6900 | }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
6901 | theme: theme,
|
6902 | "data-test": data_test_attributes_1.auth.federatedSignIn.bodySection
|
6903 | }, React.createElement(FederatedButtons, {
|
6904 | federated: federated,
|
6905 | theme: theme,
|
6906 | authState: authState,
|
6907 | onStateChange: onStateChange,
|
6908 | "data-test": data_test_attributes_1.auth.federatedSignIn.signInButtons
|
6909 | })));
|
6910 | };
|
6911 |
|
6912 | return FederatedSignIn;
|
6913 | }(React.Component);
|
6914 |
|
6915 | exports.FederatedSignIn = FederatedSignIn;
|
6916 |
|
6917 |
|
6918 |
|
6919 |
|
6920 | exports["default"] = FederatedSignIn;
|
6921 |
|
6922 | }),
|
6923 |
|
6924 | "./lib/Auth/ForgotPassword.js":
|
6925 |
|
6926 |
|
6927 |
|
6928 |
|
6929 | (function(module, exports, __webpack_require__) {
|
6930 |
|
6931 | "use strict";
|
6932 |
|
6933 |
|
6934 |
|
6935 |
|
6936 |
|
6937 |
|
6938 |
|
6939 |
|
6940 |
|
6941 |
|
6942 |
|
6943 |
|
6944 |
|
6945 |
|
6946 | var __extends = this && this.__extends || function () {
|
6947 | var _extendStatics = function extendStatics(d, b) {
|
6948 | _extendStatics = Object.setPrototypeOf || {
|
6949 | __proto__: []
|
6950 | } instanceof Array && function (d, b) {
|
6951 | d.__proto__ = b;
|
6952 | } || function (d, b) {
|
6953 | for (var p in b) {
|
6954 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
6955 | }
|
6956 | };
|
6957 |
|
6958 | return _extendStatics(d, b);
|
6959 | };
|
6960 |
|
6961 | return function (d, b) {
|
6962 | _extendStatics(d, b);
|
6963 |
|
6964 | function __() {
|
6965 | this.constructor = d;
|
6966 | }
|
6967 |
|
6968 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
6969 | };
|
6970 | }();
|
6971 |
|
6972 | var __importStar = this && this.__importStar || function (mod) {
|
6973 | if (mod && mod.__esModule) return mod;
|
6974 | var result = {};
|
6975 | if (mod != null) for (var k in mod) {
|
6976 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
6977 | }
|
6978 | result["default"] = mod;
|
6979 | return result;
|
6980 | };
|
6981 |
|
6982 | var __importDefault = this && this.__importDefault || function (mod) {
|
6983 | return mod && mod.__esModule ? mod : {
|
6984 | "default": mod
|
6985 | };
|
6986 | };
|
6987 |
|
6988 | Object.defineProperty(exports, "__esModule", {
|
6989 | value: true
|
6990 | });
|
6991 |
|
6992 | var React = __importStar(__webpack_require__( "react"));
|
6993 |
|
6994 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
6995 |
|
6996 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
6997 |
|
6998 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
6999 |
|
7000 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
7001 |
|
7002 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
7003 |
|
7004 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
7005 |
|
7006 | var logger = new core_1.ConsoleLogger('ForgotPassword');
|
7007 |
|
7008 | var ForgotPassword =
|
7009 |
|
7010 | function (_super) {
|
7011 | __extends(ForgotPassword, _super);
|
7012 |
|
7013 | function ForgotPassword(props) {
|
7014 | var _this = _super.call(this, props) || this;
|
7015 |
|
7016 | _this.send = _this.send.bind(_this);
|
7017 | _this.submit = _this.submit.bind(_this);
|
7018 | _this._validAuthStates = ['forgotPassword'];
|
7019 | _this.state = {
|
7020 | delivery: null
|
7021 | };
|
7022 | return _this;
|
7023 | }
|
7024 |
|
7025 | ForgotPassword.prototype.send = function () {
|
7026 | var _this = this;
|
7027 |
|
7028 | var _a = this.props.authData,
|
7029 | authData = _a === void 0 ? {} : _a;
|
7030 | var username = this.getUsernameFromInput() || authData.username;
|
7031 |
|
7032 | if (!auth_1.Auth || typeof auth_1.Auth.forgotPassword !== 'function') {
|
7033 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
7034 | }
|
7035 |
|
7036 | auth_1.Auth.forgotPassword(username).then(function (data) {
|
7037 | logger.debug(data);
|
7038 |
|
7039 | _this.setState({
|
7040 | delivery: data.CodeDeliveryDetails
|
7041 | });
|
7042 | })["catch"](function (err) {
|
7043 | return _this.error(err);
|
7044 | });
|
7045 | };
|
7046 |
|
7047 | ForgotPassword.prototype.submit = function () {
|
7048 | var _this = this;
|
7049 |
|
7050 | var _a = this.props.authData,
|
7051 | authData = _a === void 0 ? {} : _a;
|
7052 | var _b = this.inputs,
|
7053 | code = _b.code,
|
7054 | password = _b.password;
|
7055 | var username = this.getUsernameFromInput() || authData.username;
|
7056 |
|
7057 | if (!auth_1.Auth || typeof auth_1.Auth.forgotPasswordSubmit !== 'function') {
|
7058 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
7059 | }
|
7060 |
|
7061 | auth_1.Auth.forgotPasswordSubmit(username, code, password).then(function (data) {
|
7062 | logger.debug(data);
|
7063 |
|
7064 | _this.changeState('signIn');
|
7065 |
|
7066 | _this.setState({
|
7067 | delivery: null
|
7068 | });
|
7069 | })["catch"](function (err) {
|
7070 | return _this.error(err);
|
7071 | });
|
7072 | };
|
7073 |
|
7074 | ForgotPassword.prototype.sendView = function () {
|
7075 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
7076 | return React.createElement("div", null, this.renderUsernameField(theme));
|
7077 | };
|
7078 |
|
7079 | ForgotPassword.prototype.submitView = function () {
|
7080 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
7081 | return React.createElement("div", null, React.createElement(Amplify_UI_Components_React_1.FormField, {
|
7082 | theme: theme
|
7083 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
7084 | theme: theme
|
7085 | }, core_1.I18n.get('Code'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
7086 | placeholder: core_1.I18n.get('Code'),
|
7087 | theme: theme,
|
7088 | key: "code",
|
7089 | name: "code",
|
7090 | autoComplete: "off",
|
7091 | onChange: this.handleInputChange
|
7092 | })), React.createElement(Amplify_UI_Components_React_1.FormField, {
|
7093 | theme: theme
|
7094 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
7095 | theme: theme
|
7096 | }, core_1.I18n.get('New Password'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
7097 | placeholder: core_1.I18n.get('New Password'),
|
7098 | theme: theme,
|
7099 | type: "password",
|
7100 | key: "password",
|
7101 | name: "password",
|
7102 | autoComplete: "off",
|
7103 | onChange: this.handleInputChange
|
7104 | })));
|
7105 | };
|
7106 |
|
7107 | ForgotPassword.prototype.showComponent = function (theme) {
|
7108 | var _this = this;
|
7109 |
|
7110 | var _a = this.props,
|
7111 | authState = _a.authState,
|
7112 | hide = _a.hide,
|
7113 | _b = _a.authData,
|
7114 | authData = _b === void 0 ? {} : _b;
|
7115 |
|
7116 | if (hide && hide.includes(ForgotPassword)) {
|
7117 | return null;
|
7118 | }
|
7119 |
|
7120 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
7121 | theme: theme,
|
7122 | "data-test": data_test_attributes_1.auth.forgotPassword.section
|
7123 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
7124 | theme: theme,
|
7125 | "data-test": data_test_attributes_1.auth.forgotPassword.headerSection
|
7126 | }, core_1.I18n.get('Reset your password')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
7127 | theme: theme,
|
7128 | "data-test": data_test_attributes_1.auth.forgotPassword.bodySection
|
7129 | }, this.state.delivery || authData.username ? this.submitView() : this.sendView()), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
7130 | theme: theme
|
7131 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
7132 | theme: theme
|
7133 | }, this.state.delivery || authData.username ? React.createElement(Amplify_UI_Components_React_1.Button, {
|
7134 | theme: theme,
|
7135 | onClick: this.submit,
|
7136 | "data-test": data_test_attributes_1.auth.forgotPassword.submitButton
|
7137 | }, core_1.I18n.get('Submit')) : React.createElement(Amplify_UI_Components_React_1.Button, {
|
7138 | theme: theme,
|
7139 | onClick: this.send,
|
7140 | "data-test": data_test_attributes_1.auth.forgotPassword.sendCodeButton
|
7141 | }, core_1.I18n.get('Send Code'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
7142 | theme: theme
|
7143 | }, this.state.delivery || authData.username ? React.createElement(Amplify_UI_Components_React_1.Link, {
|
7144 | theme: theme,
|
7145 | onClick: this.send,
|
7146 | "data-test": data_test_attributes_1.auth.forgotPassword.resendCodeLink
|
7147 | }, core_1.I18n.get('Resend Code')) : React.createElement(Amplify_UI_Components_React_1.Link, {
|
7148 | theme: theme,
|
7149 | onClick: function onClick() {
|
7150 | return _this.changeState('signIn');
|
7151 | },
|
7152 | "data-test": data_test_attributes_1.auth.forgotPassword.backToSignInLink
|
7153 | }, core_1.I18n.get('Back to Sign In')))));
|
7154 | };
|
7155 |
|
7156 | return ForgotPassword;
|
7157 | }(AuthPiece_1.AuthPiece);
|
7158 |
|
7159 | exports.ForgotPassword = ForgotPassword;
|
7160 |
|
7161 |
|
7162 |
|
7163 |
|
7164 | exports["default"] = ForgotPassword;
|
7165 |
|
7166 | }),
|
7167 |
|
7168 | "./lib/Auth/Greetings.js":
|
7169 |
|
7170 |
|
7171 |
|
7172 |
|
7173 | (function(module, exports, __webpack_require__) {
|
7174 |
|
7175 | "use strict";
|
7176 |
|
7177 |
|
7178 |
|
7179 |
|
7180 |
|
7181 |
|
7182 |
|
7183 |
|
7184 |
|
7185 |
|
7186 |
|
7187 |
|
7188 |
|
7189 |
|
7190 | var __extends = this && this.__extends || function () {
|
7191 | var _extendStatics = function extendStatics(d, b) {
|
7192 | _extendStatics = Object.setPrototypeOf || {
|
7193 | __proto__: []
|
7194 | } instanceof Array && function (d, b) {
|
7195 | d.__proto__ = b;
|
7196 | } || function (d, b) {
|
7197 | for (var p in b) {
|
7198 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
7199 | }
|
7200 | };
|
7201 |
|
7202 | return _extendStatics(d, b);
|
7203 | };
|
7204 |
|
7205 | return function (d, b) {
|
7206 | _extendStatics(d, b);
|
7207 |
|
7208 | function __() {
|
7209 | this.constructor = d;
|
7210 | }
|
7211 |
|
7212 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7213 | };
|
7214 | }();
|
7215 |
|
7216 | var __assign = this && this.__assign || function () {
|
7217 | __assign = Object.assign || function (t) {
|
7218 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
7219 | s = arguments[i];
|
7220 |
|
7221 | for (var p in s) {
|
7222 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
7223 | }
|
7224 | }
|
7225 |
|
7226 | return t;
|
7227 | };
|
7228 |
|
7229 | return __assign.apply(this, arguments);
|
7230 | };
|
7231 |
|
7232 | var __importStar = this && this.__importStar || function (mod) {
|
7233 | if (mod && mod.__esModule) return mod;
|
7234 | var result = {};
|
7235 | if (mod != null) for (var k in mod) {
|
7236 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
7237 | }
|
7238 | result["default"] = mod;
|
7239 | return result;
|
7240 | };
|
7241 |
|
7242 | var __importDefault = this && this.__importDefault || function (mod) {
|
7243 | return mod && mod.__esModule ? mod : {
|
7244 | "default": mod
|
7245 | };
|
7246 | };
|
7247 |
|
7248 | Object.defineProperty(exports, "__esModule", {
|
7249 | value: true
|
7250 | });
|
7251 |
|
7252 | var React = __importStar(__webpack_require__( "react"));
|
7253 |
|
7254 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
7255 |
|
7256 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
7257 |
|
7258 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
7259 |
|
7260 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
7261 |
|
7262 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
7263 |
|
7264 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
7265 |
|
7266 | var SignOut_1 = __webpack_require__( "./lib/Auth/SignOut.js");
|
7267 |
|
7268 | var Provider_1 = __webpack_require__( "./lib/Auth/Provider/index.js");
|
7269 |
|
7270 | var types_1 = __webpack_require__( "./lib/Auth/common/types.js");
|
7271 |
|
7272 | var logger = new core_1.ConsoleLogger('Greetings');
|
7273 |
|
7274 | var Greetings =
|
7275 |
|
7276 | function (_super) {
|
7277 | __extends(Greetings, _super);
|
7278 |
|
7279 | function Greetings(props) {
|
7280 | var _this = _super.call(this, props) || this;
|
7281 |
|
7282 | _this.state = {};
|
7283 | _this.onHubCapsule = _this.onHubCapsule.bind(_this);
|
7284 | _this.inGreeting = _this.inGreeting.bind(_this);
|
7285 | core_1.Hub.listen('auth', _this.onHubCapsule);
|
7286 | _this._validAuthStates = ['signedIn'];
|
7287 | return _this;
|
7288 | }
|
7289 |
|
7290 | Greetings.prototype.componentDidMount = function () {
|
7291 | this._isMounted = true;
|
7292 | this.findState();
|
7293 | };
|
7294 |
|
7295 | Greetings.prototype.componentWillUnmount = function () {
|
7296 | this._isMounted = false;
|
7297 | };
|
7298 |
|
7299 | Greetings.prototype.findState = function () {
|
7300 | var _this = this;
|
7301 |
|
7302 | if (!this.props.authState && !this.props.authData) {
|
7303 | auth_1.Auth.currentAuthenticatedUser().then(function (user) {
|
7304 | _this.setState({
|
7305 | authState: 'signedIn',
|
7306 | authData: user,
|
7307 | stateFromStorage: true
|
7308 | });
|
7309 | })["catch"](function (err) {
|
7310 | return logger.debug(err);
|
7311 | });
|
7312 | }
|
7313 | };
|
7314 |
|
7315 | Greetings.prototype.onHubCapsule = function (capsule) {
|
7316 | if (this._isMounted) {
|
7317 | var channel = capsule.channel,
|
7318 | payload = capsule.payload;
|
7319 |
|
7320 | if (channel === 'auth' && payload.event === 'signIn') {
|
7321 | this.setState({
|
7322 | authState: 'signedIn',
|
7323 | authData: payload.data
|
7324 | });
|
7325 |
|
7326 | if (!this.props.authState) {
|
7327 | this.setState({
|
7328 | stateFromStorage: true
|
7329 | });
|
7330 | }
|
7331 | } else if (channel === 'auth' && payload.event === 'signOut' && !this.props.authState) {
|
7332 | this.setState({
|
7333 | authState: 'signIn'
|
7334 | });
|
7335 | }
|
7336 | }
|
7337 | };
|
7338 |
|
7339 | Greetings.prototype.inGreeting = function (name) {
|
7340 | var _a = this.props.usernameAttributes,
|
7341 | usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
|
7342 | var prefix = usernameAttributes === types_1.UsernameAttributes.USERNAME ? core_1.I18n.get('Hello') + " " : '';
|
7343 | return "" + prefix + name;
|
7344 | };
|
7345 |
|
7346 | Greetings.prototype.outGreeting = function () {
|
7347 | return '';
|
7348 | };
|
7349 |
|
7350 | Greetings.prototype.userGreetings = function (theme) {
|
7351 | var user = this.props.authData || this.state.authData;
|
7352 | var greeting = this.props.inGreeting || this.inGreeting;
|
7353 |
|
7354 | var _a = this.props.usernameAttributes,
|
7355 | usernameAttributes = _a === void 0 ? 'username' : _a;
|
7356 | var name = '';
|
7357 |
|
7358 | switch (usernameAttributes) {
|
7359 | case types_1.UsernameAttributes.EMAIL:
|
7360 |
|
7361 | name = user.attributes ? user.attributes.email : user.username;
|
7362 | break;
|
7363 |
|
7364 | case types_1.UsernameAttributes.PHONE_NUMBER:
|
7365 |
|
7366 | name = user.attributes ? user.attributes.phone_number : user.username;
|
7367 | break;
|
7368 |
|
7369 | default:
|
7370 | var nameFromAttr = user.attributes ? user.attributes.name || (user.attributes.given_name ? user.attributes.given_name + ' ' + user.attributes.family_name : undefined) : undefined;
|
7371 | name = nameFromAttr || user.name || user.username;
|
7372 | break;
|
7373 | }
|
7374 |
|
7375 | var message = typeof greeting === 'function' ? greeting(name) : greeting;
|
7376 | return React.createElement("span", null, React.createElement(Amplify_UI_Components_React_1.NavItem, {
|
7377 | theme: theme
|
7378 | }, message), this.renderSignOutButton());
|
7379 | };
|
7380 |
|
7381 | Greetings.prototype.renderSignOutButton = function () {
|
7382 | var _a = this.props.federated,
|
7383 | federated = _a === void 0 ? {} : _a;
|
7384 | var google_client_id = federated.google_client_id,
|
7385 | facebook_app_id = federated.facebook_app_id,
|
7386 | amazon_client_id = federated.amazon_client_id,
|
7387 | auth0 = federated.auth0;
|
7388 |
|
7389 | var config = auth_1.Auth.configure();
|
7390 | var _b = config.oauth,
|
7391 | oauth = _b === void 0 ? {} : _b;
|
7392 |
|
7393 | var googleClientId = google_client_id || config.googleClientId;
|
7394 |
|
7395 | var facebookAppId = facebook_app_id || config.facebookClientId;
|
7396 |
|
7397 | var amazonClientId = amazon_client_id || config.amazonClientId;
|
7398 |
|
7399 | var auth0_config = auth0 || oauth.auth0;
|
7400 | var SignOutComponent = SignOut_1.SignOut;
|
7401 |
|
7402 | if (googleClientId) SignOutComponent = Provider_1.withGoogle(SignOut_1.SignOut);
|
7403 |
|
7404 | if (facebookAppId) SignOutComponent = Provider_1.withFacebook(SignOut_1.SignOut);
|
7405 |
|
7406 | if (amazonClientId) SignOutComponent = Provider_1.withAmazon(SignOut_1.SignOut);
|
7407 |
|
7408 | if (auth0_config) SignOutComponent = Provider_1.withAuth0(SignOut_1.SignOut);
|
7409 | var stateAndProps = Object.assign({}, this.props, this.state);
|
7410 | return React.createElement(SignOutComponent, __assign({}, stateAndProps));
|
7411 | };
|
7412 |
|
7413 | Greetings.prototype.noUserGreetings = function (theme) {
|
7414 | var greeting = this.props.outGreeting || this.outGreeting;
|
7415 | var message = typeof greeting === 'function' ? greeting() : greeting;
|
7416 | return message ? React.createElement(Amplify_UI_Components_React_1.NavItem, {
|
7417 | theme: theme
|
7418 | }, message) : null;
|
7419 | };
|
7420 |
|
7421 | Greetings.prototype.render = function () {
|
7422 | var hide = this.props.hide;
|
7423 |
|
7424 | if (hide && hide.includes(Greetings)) {
|
7425 | return null;
|
7426 | }
|
7427 |
|
7428 | var authState = this.props.authState || this.state.authState;
|
7429 | var signedIn = authState === 'signedIn';
|
7430 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
7431 | var greeting = signedIn ? this.userGreetings(theme) : this.noUserGreetings(theme);
|
7432 |
|
7433 | if (!greeting) {
|
7434 | return null;
|
7435 | }
|
7436 |
|
7437 | return React.createElement(Amplify_UI_Components_React_1.NavBar, {
|
7438 | theme: theme,
|
7439 | "data-test": data_test_attributes_1.auth.greetings.navBar
|
7440 | }, React.createElement(Amplify_UI_Components_React_1.Nav, {
|
7441 | theme: theme,
|
7442 | "data-test": data_test_attributes_1.auth.greetings.nav
|
7443 | }, React.createElement(Amplify_UI_Components_React_1.NavRight, {
|
7444 | theme: theme,
|
7445 | "data-test": data_test_attributes_1.auth.greetings.navRight
|
7446 | }, greeting)));
|
7447 | };
|
7448 |
|
7449 | return Greetings;
|
7450 | }(AuthPiece_1.AuthPiece);
|
7451 |
|
7452 | exports.Greetings = Greetings;
|
7453 |
|
7454 |
|
7455 |
|
7456 |
|
7457 | exports["default"] = Greetings;
|
7458 |
|
7459 | }),
|
7460 |
|
7461 | "./lib/Auth/Loading.js":
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 | (function(module, exports, __webpack_require__) {
|
7467 |
|
7468 | "use strict";
|
7469 |
|
7470 |
|
7471 |
|
7472 |
|
7473 |
|
7474 |
|
7475 |
|
7476 |
|
7477 |
|
7478 |
|
7479 |
|
7480 |
|
7481 |
|
7482 |
|
7483 | var __extends = this && this.__extends || function () {
|
7484 | var _extendStatics = function extendStatics(d, b) {
|
7485 | _extendStatics = Object.setPrototypeOf || {
|
7486 | __proto__: []
|
7487 | } instanceof Array && function (d, b) {
|
7488 | d.__proto__ = b;
|
7489 | } || function (d, b) {
|
7490 | for (var p in b) {
|
7491 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
7492 | }
|
7493 | };
|
7494 |
|
7495 | return _extendStatics(d, b);
|
7496 | };
|
7497 |
|
7498 | return function (d, b) {
|
7499 | _extendStatics(d, b);
|
7500 |
|
7501 | function __() {
|
7502 | this.constructor = d;
|
7503 | }
|
7504 |
|
7505 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7506 | };
|
7507 | }();
|
7508 |
|
7509 | var __importStar = this && this.__importStar || function (mod) {
|
7510 | if (mod && mod.__esModule) return mod;
|
7511 | var result = {};
|
7512 | if (mod != null) for (var k in mod) {
|
7513 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
7514 | }
|
7515 | result["default"] = mod;
|
7516 | return result;
|
7517 | };
|
7518 |
|
7519 | Object.defineProperty(exports, "__esModule", {
|
7520 | value: true
|
7521 | });
|
7522 |
|
7523 | var React = __importStar(__webpack_require__( "react"));
|
7524 |
|
7525 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
7526 |
|
7527 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
7528 |
|
7529 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
7530 |
|
7531 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
7532 |
|
7533 | var Loading =
|
7534 |
|
7535 | function (_super) {
|
7536 | __extends(Loading, _super);
|
7537 |
|
7538 | function Loading(props) {
|
7539 | var _this = _super.call(this, props) || this;
|
7540 |
|
7541 | _this._validAuthStates = ['loading'];
|
7542 | return _this;
|
7543 | }
|
7544 |
|
7545 | Loading.prototype.showComponent = function (theme) {
|
7546 | var hide = this.props.hide;
|
7547 |
|
7548 | if (hide && hide.includes(Loading)) {
|
7549 | return null;
|
7550 | }
|
7551 |
|
7552 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
7553 | theme: theme,
|
7554 | "data-test": data_test_attributes_1.auth.loading.section
|
7555 | }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
7556 | theme: theme
|
7557 | }, core_1.I18n.get('Loading...')));
|
7558 | };
|
7559 |
|
7560 | return Loading;
|
7561 | }(AuthPiece_1.AuthPiece);
|
7562 |
|
7563 | exports.Loading = Loading;
|
7564 |
|
7565 | }),
|
7566 |
|
7567 | "./lib/Auth/PhoneField.js":
|
7568 |
|
7569 |
|
7570 |
|
7571 |
|
7572 | (function(module, exports, __webpack_require__) {
|
7573 |
|
7574 | "use strict";
|
7575 |
|
7576 |
|
7577 | var __extends = this && this.__extends || function () {
|
7578 | var _extendStatics = function extendStatics(d, b) {
|
7579 | _extendStatics = Object.setPrototypeOf || {
|
7580 | __proto__: []
|
7581 | } instanceof Array && function (d, b) {
|
7582 | d.__proto__ = b;
|
7583 | } || function (d, b) {
|
7584 | for (var p in b) {
|
7585 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
7586 | }
|
7587 | };
|
7588 |
|
7589 | return _extendStatics(d, b);
|
7590 | };
|
7591 |
|
7592 | return function (d, b) {
|
7593 | _extendStatics(d, b);
|
7594 |
|
7595 | function __() {
|
7596 | this.constructor = d;
|
7597 | }
|
7598 |
|
7599 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7600 | };
|
7601 | }();
|
7602 |
|
7603 | var __importStar = this && this.__importStar || function (mod) {
|
7604 | if (mod && mod.__esModule) return mod;
|
7605 | var result = {};
|
7606 | if (mod != null) for (var k in mod) {
|
7607 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
7608 | }
|
7609 | result["default"] = mod;
|
7610 | return result;
|
7611 | };
|
7612 |
|
7613 | var __importDefault = this && this.__importDefault || function (mod) {
|
7614 | return mod && mod.__esModule ? mod : {
|
7615 | "default": mod
|
7616 | };
|
7617 | };
|
7618 |
|
7619 | Object.defineProperty(exports, "__esModule", {
|
7620 | value: true
|
7621 | });
|
7622 |
|
7623 | var React = __importStar(__webpack_require__( "react"));
|
7624 |
|
7625 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
7626 |
|
7627 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
7628 |
|
7629 | var country_dial_codes_1 = __webpack_require__( "./lib/Auth/common/country-dial-codes.js");
|
7630 |
|
7631 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
7632 |
|
7633 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
7634 |
|
7635 | var PhoneField =
|
7636 |
|
7637 | function (_super) {
|
7638 | __extends(PhoneField, _super);
|
7639 |
|
7640 | function PhoneField(props) {
|
7641 | var _this = _super.call(this, props) || this;
|
7642 |
|
7643 | _this.handleInputChange = _this.handleInputChange.bind(_this);
|
7644 | _this.composePhoneNumber = _this.composePhoneNumber.bind(_this);
|
7645 | _this.inputs = {
|
7646 | dial_code: _this.props.defaultDialCode || '+1',
|
7647 | phone_line_number: ''
|
7648 | };
|
7649 | return _this;
|
7650 | }
|
7651 |
|
7652 | PhoneField.prototype.composePhoneNumber = function (dial_code, phone_line_number) {
|
7653 | return "" + (dial_code || '+1') + phone_line_number.replace(/[-()]/g, '');
|
7654 | };
|
7655 |
|
7656 | PhoneField.prototype.handleInputChange = function (evt) {
|
7657 | var _a = evt.target,
|
7658 | name = _a.name,
|
7659 | value = _a.value;
|
7660 | this.inputs[name] = value;
|
7661 |
|
7662 | if (this.props.onChangeText) {
|
7663 | this.props.onChangeText(this.composePhoneNumber(this.inputs.dial_code, this.inputs.phone_line_number));
|
7664 | }
|
7665 | };
|
7666 |
|
7667 | PhoneField.prototype.render = function () {
|
7668 | var _a = this.props,
|
7669 | _b = _a.theme,
|
7670 | theme = _b === void 0 ? Amplify_UI_Theme_1["default"] : _b,
|
7671 | _c = _a.required,
|
7672 | required = _c === void 0 ? true : _c,
|
7673 | _d = _a.defaultDialCode,
|
7674 | defaultDialCode = _d === void 0 ? '+1' : _d,
|
7675 | _e = _a.label,
|
7676 | label = _e === void 0 ? 'Phone Number' : _e,
|
7677 | _f = _a.placeholder,
|
7678 | placeholder = _f === void 0 ? 'Enter your phone number' : _f;
|
7679 | return React.createElement(Amplify_UI_Components_React_1.FormField, {
|
7680 | theme: theme,
|
7681 | key: "phone_number"
|
7682 | }, required ? React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
7683 | theme: theme
|
7684 | }, core_1.I18n.get(label), " *") : React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
7685 | theme: theme
|
7686 | }, core_1.I18n.get(label)), React.createElement(Amplify_UI_Components_React_1.SelectInput, {
|
7687 | theme: theme
|
7688 | }, React.createElement("select", {
|
7689 | name: "dial_code",
|
7690 | defaultValue: defaultDialCode,
|
7691 | onChange: this.handleInputChange,
|
7692 | "data-test": data_test_attributes_1.auth.genericAttrs.dialCodeSelect
|
7693 | }, country_dial_codes_1.countryDialCodes.map(function (dialCode) {
|
7694 | return React.createElement("option", {
|
7695 | key: dialCode,
|
7696 | value: dialCode
|
7697 | }, dialCode);
|
7698 | })), React.createElement(Amplify_UI_Components_React_1.Input, {
|
7699 | placeholder: core_1.I18n.get(placeholder),
|
7700 | theme: theme,
|
7701 | type: "tel",
|
7702 | id: "phone_line_number",
|
7703 | key: "phone_line_number",
|
7704 | name: "phone_line_number",
|
7705 | onChange: this.handleInputChange,
|
7706 | "data-test": data_test_attributes_1.auth.genericAttrs.phoneNumberInput
|
7707 | })));
|
7708 | };
|
7709 |
|
7710 | return PhoneField;
|
7711 | }(React.Component);
|
7712 |
|
7713 | exports.PhoneField = PhoneField;
|
7714 |
|
7715 |
|
7716 |
|
7717 |
|
7718 | exports["default"] = PhoneField;
|
7719 |
|
7720 | }),
|
7721 |
|
7722 | "./lib/Auth/Provider/index.js":
|
7723 |
|
7724 |
|
7725 |
|
7726 |
|
7727 | (function(module, exports, __webpack_require__) {
|
7728 |
|
7729 | "use strict";
|
7730 |
|
7731 |
|
7732 |
|
7733 |
|
7734 |
|
7735 |
|
7736 |
|
7737 |
|
7738 |
|
7739 |
|
7740 |
|
7741 |
|
7742 |
|
7743 |
|
7744 | var __extends = this && this.__extends || function () {
|
7745 | var _extendStatics = function extendStatics(d, b) {
|
7746 | _extendStatics = Object.setPrototypeOf || {
|
7747 | __proto__: []
|
7748 | } instanceof Array && function (d, b) {
|
7749 | d.__proto__ = b;
|
7750 | } || function (d, b) {
|
7751 | for (var p in b) {
|
7752 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
7753 | }
|
7754 | };
|
7755 |
|
7756 | return _extendStatics(d, b);
|
7757 | };
|
7758 |
|
7759 | return function (d, b) {
|
7760 | _extendStatics(d, b);
|
7761 |
|
7762 | function __() {
|
7763 | this.constructor = d;
|
7764 | }
|
7765 |
|
7766 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7767 | };
|
7768 | }();
|
7769 |
|
7770 | var __assign = this && this.__assign || function () {
|
7771 | __assign = Object.assign || function (t) {
|
7772 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
7773 | s = arguments[i];
|
7774 |
|
7775 | for (var p in s) {
|
7776 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
7777 | }
|
7778 | }
|
7779 |
|
7780 | return t;
|
7781 | };
|
7782 |
|
7783 | return __assign.apply(this, arguments);
|
7784 | };
|
7785 |
|
7786 | var __importStar = this && this.__importStar || function (mod) {
|
7787 | if (mod && mod.__esModule) return mod;
|
7788 | var result = {};
|
7789 | if (mod != null) for (var k in mod) {
|
7790 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
7791 | }
|
7792 | result["default"] = mod;
|
7793 | return result;
|
7794 | };
|
7795 |
|
7796 | Object.defineProperty(exports, "__esModule", {
|
7797 | value: true
|
7798 | });
|
7799 |
|
7800 | var React = __importStar(__webpack_require__( "react"));
|
7801 |
|
7802 | var withGoogle_1 = __webpack_require__( "./lib/Auth/Provider/withGoogle.js");
|
7803 |
|
7804 | var withFacebook_1 = __webpack_require__( "./lib/Auth/Provider/withFacebook.js");
|
7805 |
|
7806 | var withAmazon_1 = __webpack_require__( "./lib/Auth/Provider/withAmazon.js");
|
7807 |
|
7808 | var withOAuth_1 = __webpack_require__( "./lib/Auth/Provider/withOAuth.js");
|
7809 |
|
7810 | var withAuth0_1 = __webpack_require__( "./lib/Auth/Provider/withAuth0.js");
|
7811 |
|
7812 | var withGoogle_2 = __webpack_require__( "./lib/Auth/Provider/withGoogle.js");
|
7813 |
|
7814 | exports.withGoogle = withGoogle_2.withGoogle;
|
7815 | exports.GoogleButton = withGoogle_2.GoogleButton;
|
7816 |
|
7817 | var withFacebook_2 = __webpack_require__( "./lib/Auth/Provider/withFacebook.js");
|
7818 |
|
7819 | exports.withFacebook = withFacebook_2.withFacebook;
|
7820 | exports.FacebookButton = withFacebook_2.FacebookButton;
|
7821 |
|
7822 | var withAmazon_2 = __webpack_require__( "./lib/Auth/Provider/withAmazon.js");
|
7823 |
|
7824 | exports.withAmazon = withAmazon_2.withAmazon;
|
7825 | exports.AmazonButton = withAmazon_2.AmazonButton;
|
7826 |
|
7827 | var withOAuth_2 = __webpack_require__( "./lib/Auth/Provider/withOAuth.js");
|
7828 |
|
7829 | exports.withOAuth = withOAuth_2.withOAuth;
|
7830 | exports.OAuthButton = withOAuth_2.OAuthButton;
|
7831 |
|
7832 | var withAuth0_2 = __webpack_require__( "./lib/Auth/Provider/withAuth0.js");
|
7833 |
|
7834 | exports.withAuth0 = withAuth0_2.withAuth0;
|
7835 | exports.Auth0Button = withAuth0_2.Auth0Button;
|
7836 |
|
7837 | function withFederated(Comp) {
|
7838 | var Federated = withAuth0_1.withAuth0(withOAuth_1.withOAuth(withAmazon_1.withAmazon(withGoogle_1.withGoogle(withFacebook_1.withFacebook(Comp)))));
|
7839 | return (
|
7840 |
|
7841 | function (_super) {
|
7842 | __extends(class_1, _super);
|
7843 |
|
7844 | function class_1() {
|
7845 | return _super !== null && _super.apply(this, arguments) || this;
|
7846 | }
|
7847 |
|
7848 | class_1.prototype.render = function () {
|
7849 |
|
7850 | var federated = this.props.federated || {};
|
7851 | return React.createElement(Federated, __assign({}, this.props, federated));
|
7852 | };
|
7853 |
|
7854 | return class_1;
|
7855 | }(React.Component)
|
7856 | );
|
7857 | }
|
7858 |
|
7859 | exports.withFederated = withFederated;
|
7860 |
|
7861 | }),
|
7862 |
|
7863 | "./lib/Auth/Provider/withAmazon.js":
|
7864 |
|
7865 |
|
7866 |
|
7867 |
|
7868 | (function(module, exports, __webpack_require__) {
|
7869 |
|
7870 | "use strict";
|
7871 |
|
7872 |
|
7873 |
|
7874 |
|
7875 |
|
7876 |
|
7877 |
|
7878 |
|
7879 |
|
7880 |
|
7881 |
|
7882 |
|
7883 |
|
7884 |
|
7885 | var __extends = this && this.__extends || function () {
|
7886 | var _extendStatics = function extendStatics(d, b) {
|
7887 | _extendStatics = Object.setPrototypeOf || {
|
7888 | __proto__: []
|
7889 | } instanceof Array && function (d, b) {
|
7890 | d.__proto__ = b;
|
7891 | } || function (d, b) {
|
7892 | for (var p in b) {
|
7893 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
7894 | }
|
7895 | };
|
7896 |
|
7897 | return _extendStatics(d, b);
|
7898 | };
|
7899 |
|
7900 | return function (d, b) {
|
7901 | _extendStatics(d, b);
|
7902 |
|
7903 | function __() {
|
7904 | this.constructor = d;
|
7905 | }
|
7906 |
|
7907 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
7908 | };
|
7909 | }();
|
7910 |
|
7911 | var __assign = this && this.__assign || function () {
|
7912 | __assign = Object.assign || function (t) {
|
7913 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
7914 | s = arguments[i];
|
7915 |
|
7916 | for (var p in s) {
|
7917 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
7918 | }
|
7919 | }
|
7920 |
|
7921 | return t;
|
7922 | };
|
7923 |
|
7924 | return __assign.apply(this, arguments);
|
7925 | };
|
7926 |
|
7927 | var __importStar = this && this.__importStar || function (mod) {
|
7928 | if (mod && mod.__esModule) return mod;
|
7929 | var result = {};
|
7930 | if (mod != null) for (var k in mod) {
|
7931 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
7932 | }
|
7933 | result["default"] = mod;
|
7934 | return result;
|
7935 | };
|
7936 |
|
7937 | var __importDefault = this && this.__importDefault || function (mod) {
|
7938 | return mod && mod.__esModule ? mod : {
|
7939 | "default": mod
|
7940 | };
|
7941 | };
|
7942 |
|
7943 | Object.defineProperty(exports, "__esModule", {
|
7944 | value: true
|
7945 | });
|
7946 |
|
7947 | var React = __importStar(__webpack_require__( "react"));
|
7948 |
|
7949 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
7950 |
|
7951 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
7952 |
|
7953 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
7954 |
|
7955 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
7956 |
|
7957 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
7958 |
|
7959 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
7960 |
|
7961 | var logger = new core_1.ConsoleLogger('withAmazon');
|
7962 |
|
7963 | function withAmazon(Comp) {
|
7964 | return (
|
7965 |
|
7966 | function (_super) {
|
7967 | __extends(class_1, _super);
|
7968 |
|
7969 | function class_1(props) {
|
7970 | var _this = _super.call(this, props) || this;
|
7971 |
|
7972 | _this.initAmazon = _this.initAmazon.bind(_this);
|
7973 | _this.signIn = _this.signIn.bind(_this);
|
7974 | _this.signOut = _this.signOut.bind(_this);
|
7975 | _this.federatedSignIn = _this.federatedSignIn.bind(_this);
|
7976 | _this.state = {};
|
7977 | return _this;
|
7978 | }
|
7979 |
|
7980 | class_1.prototype.signIn = function () {
|
7981 | var _this = this;
|
7982 |
|
7983 | var amz = window.amazon;
|
7984 | var options = {
|
7985 | scope: 'profile'
|
7986 | };
|
7987 | amz.Login.authorize(options, function (response) {
|
7988 | if (response.error) {
|
7989 | logger.debug('Failed to login with amazon: ' + response.error);
|
7990 | return;
|
7991 | }
|
7992 |
|
7993 | var payload = {
|
7994 | provider: constants_1.Constants.AMAZON
|
7995 | };
|
7996 |
|
7997 | try {
|
7998 | localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
|
7999 | } catch (e) {
|
8000 | logger.debug('Failed to cache auth source into localStorage', e);
|
8001 | }
|
8002 |
|
8003 | _this.federatedSignIn(response);
|
8004 | });
|
8005 | };
|
8006 |
|
8007 | class_1.prototype.federatedSignIn = function (response) {
|
8008 | var access_token = response.access_token,
|
8009 | expires_in = response.expires_in;
|
8010 | var onStateChange = this.props.onStateChange;
|
8011 | var date = new Date();
|
8012 | var expires_at = expires_in * 1000 + date.getTime();
|
8013 |
|
8014 | if (!access_token) {
|
8015 | return;
|
8016 | }
|
8017 |
|
8018 | var amz = window.amazon;
|
8019 | amz.Login.retrieveProfile(function (userInfo) {
|
8020 | if (!userInfo.success) {
|
8021 | logger.debug('Get user Info failed');
|
8022 | return;
|
8023 | }
|
8024 |
|
8025 | var user = {
|
8026 | name: userInfo.profile.Name,
|
8027 | email: userInfo.profile.PrimaryEmail
|
8028 | };
|
8029 |
|
8030 | if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
|
8031 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
8032 | }
|
8033 |
|
8034 | auth_1.Auth.federatedSignIn('amazon', {
|
8035 | token: access_token,
|
8036 | expires_at: expires_at
|
8037 | }, user).then(function (credentials) {
|
8038 | return auth_1.Auth.currentAuthenticatedUser();
|
8039 | }).then(function (authUser) {
|
8040 | if (onStateChange) {
|
8041 | onStateChange('signedIn', authUser);
|
8042 | }
|
8043 | });
|
8044 | });
|
8045 | };
|
8046 |
|
8047 | class_1.prototype.signOut = function () {
|
8048 | var amz = window.amazon;
|
8049 |
|
8050 | if (!amz) {
|
8051 | logger.debug('Amazon Login sdk undefined');
|
8052 | return Promise.resolve();
|
8053 | }
|
8054 |
|
8055 | logger.debug('Amazon signing out');
|
8056 | amz.Login.logout();
|
8057 | };
|
8058 |
|
8059 | class_1.prototype.componentDidMount = function () {
|
8060 | var amazon_client_id = this.props.amazon_client_id;
|
8061 | if (amazon_client_id && !window.amazon) this.createScript();
|
8062 | };
|
8063 |
|
8064 | class_1.prototype.createScript = function () {
|
8065 | var script = document.createElement('script');
|
8066 | script.src = 'https://api-cdn.amazon.com/sdk/login1.js';
|
8067 | script.async = true;
|
8068 | script.onload = this.initAmazon;
|
8069 | document.body.appendChild(script);
|
8070 | };
|
8071 |
|
8072 | class_1.prototype.initAmazon = function () {
|
8073 | logger.debug('init amazon');
|
8074 | var amazon_client_id = this.props.amazon_client_id;
|
8075 | var amz = window.amazon;
|
8076 | amz.Login.setClientId(amazon_client_id);
|
8077 | };
|
8078 |
|
8079 | class_1.prototype.render = function () {
|
8080 | var amz = window.amazon;
|
8081 | return React.createElement(Comp, __assign({}, this.props, {
|
8082 | amz: amz,
|
8083 | amazonSignIn: this.signIn,
|
8084 | amazonSignOut: this.signOut
|
8085 | }));
|
8086 | };
|
8087 |
|
8088 | return class_1;
|
8089 | }(React.Component)
|
8090 | );
|
8091 | }
|
8092 |
|
8093 | exports.withAmazon = withAmazon;
|
8094 |
|
8095 | var Button = function Button(props) {
|
8096 | return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
|
8097 | id: ui_1.amazonSignInButton,
|
8098 | onClick: props.amazonSignIn,
|
8099 | theme: props.theme || Amplify_UI_Theme_1["default"],
|
8100 | variant: 'amazonSignInButton'
|
8101 | }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
|
8102 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8103 | }, React.createElement("svg", {
|
8104 | viewBox: "0 0 248 268",
|
8105 | xmlns: "http://www.w3.org/2000/svg"
|
8106 | }, React.createElement("g", {
|
8107 | id: "Artboard-Copy-2",
|
8108 | fill: "none",
|
8109 | fillRule: "evenodd"
|
8110 | }, React.createElement("path", {
|
8111 | d: "M139.056521,147.024612 C133.548808,156.744524 124.782731,162.726926 115.087401,162.726926 C101.790721,162.726926 93.9937779,152.612964 93.9937779,137.68681 C93.9937779,108.224571 120.447551,102.879017 145.533369,102.879017 L145.533369,110.365976 C145.533369,123.831358 145.876354,135.063787 139.056521,147.024612 M207.206992,162.579655 C209.400505,165.692256 209.887066,169.437725 207.063416,171.770186 C199.996315,177.653081 187.429476,188.590967 180.513926,194.716661 L180.46208,194.621133 C178.176838,196.663031 174.862638,196.810303 172.27828,195.445057 C160.780281,185.9162 158.686473,181.494078 152.405048,172.403055 C133.405233,191.751331 119.909143,197.534719 95.309886,197.534719 C66.1281801,197.534719 43.4791563,179.599451 43.4791563,143.669212 C43.4791563,115.616003 58.6782107,96.5105248 80.4019706,87.1727225 C99.2063636,78.9096034 125.464714,77.4528107 145.533369,75.1641337 L145.533369,70.694248 C145.533369,62.4749122 146.167493,52.7510201 141.297893,45.6541312 C137.110277,39.2856386 129.018206,36.6586354 121.859376,36.6586354 C108.658413,36.6586354 96.9171331,43.4171982 94.0416364,57.4199213 C93.4593582,60.532522 91.1701278,63.5933787 88.003492,63.7406501 L54.4387473,60.1424518 C51.6150972,59.5095829 48.4484614,57.2248862 49.2740201,52.8982915 C56.9712583,12.2553679 93.7983558,0 126.732964,0 C143.587124,0 165.606011,4.47386604 178.902691,17.2148315 C195.760839,32.917146 194.149604,53.8694866 194.149604,76.6726704 L194.149604,130.542157 C194.149604,146.734049 200.87372,153.830938 207.206992,162.579655 Z M233.826346,208.038962 C230.467669,203.683255 211.550709,205.9821 203.056405,206.998432 C200.470662,207.321077 200.076227,205.042397 202.406981,203.404973 C217.475208,192.664928 242.201125,195.766353 245.081698,199.363845 C247.966255,202.981502 244.336653,228.071183 230.172839,240.049379 C228.001452,241.888455 225.929671,240.904388 226.89783,238.468418 C230.077218,230.430525 237.204944,212.418868 233.826346,208.038962 Z M126.768855,264 C74.0234043,264 42.0764048,241.955028 17.7852554,217.541992 C12.9733903,212.705982 6.71799208,206.295994 3.31151296,200.690918 C1.90227474,198.372135 5.59096074,195.021875 8.0442063,196.84375 C38.2390146,219.267578 82.1011654,239.538304 125.529506,239.538304 C154.819967,239.538304 191.046475,227.469543 220.66851,214.867659 C225.146771,212.966167 225.146771,219.180222 224.511585,221.060516 C224.183264,222.03242 209.514625,236.221149 189.247207,247.047411 C170.304273,257.166172 146.397132,264 126.768855,264 Z",
|
8112 | id: "Fill-6",
|
8113 | fill: "#FFF"
|
8114 | })))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
|
8115 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8116 | }, core_1.I18n.get('Sign In with Amazon')));
|
8117 | };
|
8118 |
|
8119 | exports.AmazonButton = withAmazon(Button);
|
8120 |
|
8121 |
|
8122 |
|
8123 |
|
8124 | exports["default"] = withAmazon;
|
8125 |
|
8126 | }),
|
8127 |
|
8128 | "./lib/Auth/Provider/withAuth0.js":
|
8129 |
|
8130 |
|
8131 |
|
8132 |
|
8133 | (function(module, exports, __webpack_require__) {
|
8134 |
|
8135 | "use strict";
|
8136 |
|
8137 |
|
8138 |
|
8139 |
|
8140 |
|
8141 |
|
8142 |
|
8143 |
|
8144 |
|
8145 |
|
8146 |
|
8147 |
|
8148 |
|
8149 |
|
8150 | var __extends = this && this.__extends || function () {
|
8151 | var _extendStatics = function extendStatics(d, b) {
|
8152 | _extendStatics = Object.setPrototypeOf || {
|
8153 | __proto__: []
|
8154 | } instanceof Array && function (d, b) {
|
8155 | d.__proto__ = b;
|
8156 | } || function (d, b) {
|
8157 | for (var p in b) {
|
8158 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
8159 | }
|
8160 | };
|
8161 |
|
8162 | return _extendStatics(d, b);
|
8163 | };
|
8164 |
|
8165 | return function (d, b) {
|
8166 | _extendStatics(d, b);
|
8167 |
|
8168 | function __() {
|
8169 | this.constructor = d;
|
8170 | }
|
8171 |
|
8172 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8173 | };
|
8174 | }();
|
8175 |
|
8176 | var __assign = this && this.__assign || function () {
|
8177 | __assign = Object.assign || function (t) {
|
8178 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
8179 | s = arguments[i];
|
8180 |
|
8181 | for (var p in s) {
|
8182 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
8183 | }
|
8184 | }
|
8185 |
|
8186 | return t;
|
8187 | };
|
8188 |
|
8189 | return __assign.apply(this, arguments);
|
8190 | };
|
8191 |
|
8192 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
8193 | function adopt(value) {
|
8194 | return value instanceof P ? value : new P(function (resolve) {
|
8195 | resolve(value);
|
8196 | });
|
8197 | }
|
8198 |
|
8199 | return new (P || (P = Promise))(function (resolve, reject) {
|
8200 | function fulfilled(value) {
|
8201 | try {
|
8202 | step(generator.next(value));
|
8203 | } catch (e) {
|
8204 | reject(e);
|
8205 | }
|
8206 | }
|
8207 |
|
8208 | function rejected(value) {
|
8209 | try {
|
8210 | step(generator["throw"](value));
|
8211 | } catch (e) {
|
8212 | reject(e);
|
8213 | }
|
8214 | }
|
8215 |
|
8216 | function step(result) {
|
8217 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
8218 | }
|
8219 |
|
8220 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8221 | });
|
8222 | };
|
8223 |
|
8224 | var __generator = this && this.__generator || function (thisArg, body) {
|
8225 | var _ = {
|
8226 | label: 0,
|
8227 | sent: function sent() {
|
8228 | if (t[0] & 1) throw t[1];
|
8229 | return t[1];
|
8230 | },
|
8231 | trys: [],
|
8232 | ops: []
|
8233 | },
|
8234 | f,
|
8235 | y,
|
8236 | t,
|
8237 | g;
|
8238 | return g = {
|
8239 | next: verb(0),
|
8240 | "throw": verb(1),
|
8241 | "return": verb(2)
|
8242 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
8243 | return this;
|
8244 | }), g;
|
8245 |
|
8246 | function verb(n) {
|
8247 | return function (v) {
|
8248 | return step([n, v]);
|
8249 | };
|
8250 | }
|
8251 |
|
8252 | function step(op) {
|
8253 | if (f) throw new TypeError("Generator is already executing.");
|
8254 |
|
8255 | while (_) {
|
8256 | try {
|
8257 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
8258 | if (y = 0, t) op = [op[0] & 2, t.value];
|
8259 |
|
8260 | switch (op[0]) {
|
8261 | case 0:
|
8262 | case 1:
|
8263 | t = op;
|
8264 | break;
|
8265 |
|
8266 | case 4:
|
8267 | _.label++;
|
8268 | return {
|
8269 | value: op[1],
|
8270 | done: false
|
8271 | };
|
8272 |
|
8273 | case 5:
|
8274 | _.label++;
|
8275 | y = op[1];
|
8276 | op = [0];
|
8277 | continue;
|
8278 |
|
8279 | case 7:
|
8280 | op = _.ops.pop();
|
8281 |
|
8282 | _.trys.pop();
|
8283 |
|
8284 | continue;
|
8285 |
|
8286 | default:
|
8287 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
8288 | _ = 0;
|
8289 | continue;
|
8290 | }
|
8291 |
|
8292 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
8293 | _.label = op[1];
|
8294 | break;
|
8295 | }
|
8296 |
|
8297 | if (op[0] === 6 && _.label < t[1]) {
|
8298 | _.label = t[1];
|
8299 | t = op;
|
8300 | break;
|
8301 | }
|
8302 |
|
8303 | if (t && _.label < t[2]) {
|
8304 | _.label = t[2];
|
8305 |
|
8306 | _.ops.push(op);
|
8307 |
|
8308 | break;
|
8309 | }
|
8310 |
|
8311 | if (t[2]) _.ops.pop();
|
8312 |
|
8313 | _.trys.pop();
|
8314 |
|
8315 | continue;
|
8316 | }
|
8317 |
|
8318 | op = body.call(thisArg, _);
|
8319 | } catch (e) {
|
8320 | op = [6, e];
|
8321 | y = 0;
|
8322 | } finally {
|
8323 | f = t = 0;
|
8324 | }
|
8325 | }
|
8326 |
|
8327 | if (op[0] & 5) throw op[1];
|
8328 | return {
|
8329 | value: op[0] ? op[1] : void 0,
|
8330 | done: true
|
8331 | };
|
8332 | }
|
8333 | };
|
8334 |
|
8335 | var __importStar = this && this.__importStar || function (mod) {
|
8336 | if (mod && mod.__esModule) return mod;
|
8337 | var result = {};
|
8338 | if (mod != null) for (var k in mod) {
|
8339 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
8340 | }
|
8341 | result["default"] = mod;
|
8342 | return result;
|
8343 | };
|
8344 |
|
8345 | var __importDefault = this && this.__importDefault || function (mod) {
|
8346 | return mod && mod.__esModule ? mod : {
|
8347 | "default": mod
|
8348 | };
|
8349 | };
|
8350 |
|
8351 | Object.defineProperty(exports, "__esModule", {
|
8352 | value: true
|
8353 | });
|
8354 |
|
8355 | var React = __importStar(__webpack_require__( "react"));
|
8356 |
|
8357 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
8358 |
|
8359 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
8360 |
|
8361 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
8362 |
|
8363 |
|
8364 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
8365 |
|
8366 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
8367 |
|
8368 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
8369 |
|
8370 | var logger = new core_1.ConsoleLogger('withAuth0');
|
8371 |
|
8372 | function withAuth0(Comp, options) {
|
8373 | return (
|
8374 |
|
8375 | function (_super) {
|
8376 | __extends(class_1, _super);
|
8377 |
|
8378 | function class_1(props) {
|
8379 | var _this = _super.call(this, props) || this;
|
8380 |
|
8381 | _this._auth0 = null;
|
8382 | _this.initialize = _this.initialize.bind(_this);
|
8383 | _this.signIn = _this.signIn.bind(_this);
|
8384 | _this.signOut = _this.signOut.bind(_this);
|
8385 | return _this;
|
8386 | }
|
8387 |
|
8388 | class_1.prototype.componentDidMount = function () {
|
8389 | if (!window.auth0) {
|
8390 | this.createScript();
|
8391 | } else {
|
8392 | this.initialize();
|
8393 | }
|
8394 | };
|
8395 |
|
8396 | class_1.prototype.createScript = function () {
|
8397 | var script = document.createElement('script');
|
8398 | script.src = 'https://cdn.auth0.com/js/auth0/9.8.1/auth0.min.js';
|
8399 | script.async = true;
|
8400 | script.onload = this.initialize;
|
8401 | document.body.appendChild(script);
|
8402 | };
|
8403 |
|
8404 | class_1.prototype.initialize = function () {
|
8405 | var _this = this;
|
8406 |
|
8407 |
|
8408 | var _a = auth_1.Auth.configure().oauth,
|
8409 | oauth = _a === void 0 ? {} : _a;
|
8410 |
|
8411 | var config = this.props.auth0 || options || oauth.auth0;
|
8412 | var _b = this.props,
|
8413 | onError = _b.onError,
|
8414 | onStateChange = _b.onStateChange,
|
8415 | authState = _b.authState;
|
8416 |
|
8417 | if (!config) {
|
8418 | logger.debug('Auth0 is not configured');
|
8419 | return;
|
8420 | }
|
8421 |
|
8422 | logger.debug('withAuth0 configuration', config);
|
8423 |
|
8424 | if (!this._auth0) {
|
8425 | this._auth0 = new window['auth0'].WebAuth(config);
|
8426 | window.auth0_client = this._auth0;
|
8427 | }
|
8428 |
|
8429 | if (authState !== 'signedIn') {
|
8430 | this._auth0.parseHash(function (err, authResult) {
|
8431 | if (err || !authResult) {
|
8432 | logger.debug('Failed to parse the url for Auth0', err);
|
8433 | return;
|
8434 | }
|
8435 |
|
8436 | var payload = {
|
8437 | provider: constants_1.Constants.AUTH0,
|
8438 | opts: {
|
8439 | returnTo: config.returnTo,
|
8440 | clientID: config.clientID,
|
8441 | federated: config.federated
|
8442 | }
|
8443 | };
|
8444 |
|
8445 | try {
|
8446 | localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
|
8447 | } catch (e) {
|
8448 | logger.debug('Failed to cache auth source into localStorage', e);
|
8449 | }
|
8450 |
|
8451 | _this._auth0.client.userInfo(authResult.accessToken, function (err, user) {
|
8452 | var username = undefined;
|
8453 | var email = undefined;
|
8454 | var picture = undefined;
|
8455 |
|
8456 | if (err) {
|
8457 | logger.debug('Failed to get the user info', err);
|
8458 | } else {
|
8459 | username = user.name;
|
8460 | email = user.email;
|
8461 | picture = user.picture;
|
8462 | }
|
8463 |
|
8464 | auth_1.Auth.federatedSignIn(config.domain, {
|
8465 | token: authResult.idToken,
|
8466 | expires_at: authResult.expiresIn * 1000 + new Date().getTime()
|
8467 | }, {
|
8468 | name: username,
|
8469 | email: email,
|
8470 | picture: picture
|
8471 | }).then(function () {
|
8472 | if (onStateChange) {
|
8473 | auth_1.Auth.currentAuthenticatedUser().then(function (user) {
|
8474 | onStateChange('signedIn', user);
|
8475 | });
|
8476 | }
|
8477 | })["catch"](function (e) {
|
8478 | logger.debug('Failed to get the aws credentials', e);
|
8479 | if (onError) onError(e);
|
8480 | });
|
8481 | });
|
8482 | });
|
8483 | }
|
8484 | };
|
8485 |
|
8486 | class_1.prototype.signIn = function () {
|
8487 | return __awaiter(this, void 0, void 0, function () {
|
8488 | return __generator(this, function (_a) {
|
8489 | if (this._auth0) this._auth0.authorize();else {
|
8490 | throw new Error('the auth0 client is not configured');
|
8491 | }
|
8492 | return [2
|
8493 |
|
8494 | ];
|
8495 | });
|
8496 | });
|
8497 | };
|
8498 |
|
8499 | class_1.prototype.signOut = function (opts) {
|
8500 | if (opts === void 0) {
|
8501 | opts = {};
|
8502 | }
|
8503 |
|
8504 | var auth0 = window.auth0_client;
|
8505 |
|
8506 | var returnTo = opts.returnTo,
|
8507 | clientID = opts.clientID,
|
8508 | federated = opts.federated;
|
8509 |
|
8510 | if (!auth0) {
|
8511 | logger.debug('auth0 sdk undefined');
|
8512 | return Promise.resolve();
|
8513 | }
|
8514 |
|
8515 | auth0.logout({
|
8516 | returnTo: returnTo,
|
8517 | clientID: clientID,
|
8518 | federated: federated
|
8519 | });
|
8520 | };
|
8521 |
|
8522 | class_1.prototype.render = function () {
|
8523 | return React.createElement(Comp, __assign({}, this.props, {
|
8524 | auth0: this._auth0,
|
8525 | auth0SignIn: this.signIn,
|
8526 | auth0SignOut: this.signOut
|
8527 | }));
|
8528 | };
|
8529 |
|
8530 | return class_1;
|
8531 | }(React.Component)
|
8532 | );
|
8533 | }
|
8534 |
|
8535 | exports.withAuth0 = withAuth0;
|
8536 |
|
8537 | var Button = function Button(props) {
|
8538 | return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
|
8539 | id: ui_1.auth0SignInButton,
|
8540 | onClick: props.auth0SignIn,
|
8541 | theme: props.theme || Amplify_UI_Theme_1["default"],
|
8542 | variant: 'auth0SignInButton'
|
8543 | }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
|
8544 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8545 | }, React.createElement("svg", {
|
8546 | id: "artwork",
|
8547 | xmlns: "http://www.w3.org/2000/svg",
|
8548 | viewBox: "0 0 193.7 216.6"
|
8549 | }, React.createElement("path", {
|
8550 | id: "NEW",
|
8551 | className: "st0",
|
8552 | d: "M189,66.9L167.2,0H96.8l21.8,66.9H189z M96.8,0H26.5L4.8,66.9h70.4L96.8,0z M4.8,66.9L4.8,66.9\tc-13,39.9,1.2,83.6,35.2,108.3l21.7-66.9L4.8,66.9z M189,66.9L189,66.9l-57,41.4l21.7,66.9l0,0C187.7,150.6,201.9,106.8,189,66.9\tL189,66.9z M39.9,175.2L39.9,175.2l56.9,41.4l56.9-41.4l-56.9-41.4L39.9,175.2z"
|
8553 | }))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
|
8554 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8555 | }, props.label || 'Sign In with Auth0'));
|
8556 | };
|
8557 |
|
8558 | exports.Auth0Button = withAuth0(Button);
|
8559 |
|
8560 |
|
8561 |
|
8562 |
|
8563 | exports["default"] = withAuth0;
|
8564 |
|
8565 | }),
|
8566 |
|
8567 | "./lib/Auth/Provider/withFacebook.js":
|
8568 |
|
8569 |
|
8570 |
|
8571 |
|
8572 | (function(module, exports, __webpack_require__) {
|
8573 |
|
8574 | "use strict";
|
8575 |
|
8576 |
|
8577 |
|
8578 |
|
8579 |
|
8580 |
|
8581 |
|
8582 |
|
8583 |
|
8584 |
|
8585 |
|
8586 |
|
8587 |
|
8588 |
|
8589 | var __extends = this && this.__extends || function () {
|
8590 | var _extendStatics = function extendStatics(d, b) {
|
8591 | _extendStatics = Object.setPrototypeOf || {
|
8592 | __proto__: []
|
8593 | } instanceof Array && function (d, b) {
|
8594 | d.__proto__ = b;
|
8595 | } || function (d, b) {
|
8596 | for (var p in b) {
|
8597 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
8598 | }
|
8599 | };
|
8600 |
|
8601 | return _extendStatics(d, b);
|
8602 | };
|
8603 |
|
8604 | return function (d, b) {
|
8605 | _extendStatics(d, b);
|
8606 |
|
8607 | function __() {
|
8608 | this.constructor = d;
|
8609 | }
|
8610 |
|
8611 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8612 | };
|
8613 | }();
|
8614 |
|
8615 | var __assign = this && this.__assign || function () {
|
8616 | __assign = Object.assign || function (t) {
|
8617 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
8618 | s = arguments[i];
|
8619 |
|
8620 | for (var p in s) {
|
8621 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
8622 | }
|
8623 | }
|
8624 |
|
8625 | return t;
|
8626 | };
|
8627 |
|
8628 | return __assign.apply(this, arguments);
|
8629 | };
|
8630 |
|
8631 | var __importStar = this && this.__importStar || function (mod) {
|
8632 | if (mod && mod.__esModule) return mod;
|
8633 | var result = {};
|
8634 | if (mod != null) for (var k in mod) {
|
8635 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
8636 | }
|
8637 | result["default"] = mod;
|
8638 | return result;
|
8639 | };
|
8640 |
|
8641 | var __importDefault = this && this.__importDefault || function (mod) {
|
8642 | return mod && mod.__esModule ? mod : {
|
8643 | "default": mod
|
8644 | };
|
8645 | };
|
8646 |
|
8647 | Object.defineProperty(exports, "__esModule", {
|
8648 | value: true
|
8649 | });
|
8650 |
|
8651 | var React = __importStar(__webpack_require__( "react"));
|
8652 |
|
8653 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
8654 |
|
8655 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
8656 |
|
8657 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
8658 |
|
8659 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
8660 |
|
8661 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
8662 |
|
8663 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
8664 |
|
8665 | var logger = new core_1.ConsoleLogger('withFacebook');
|
8666 |
|
8667 | function withFacebook(Comp) {
|
8668 | return (
|
8669 |
|
8670 | function (_super) {
|
8671 | __extends(class_1, _super);
|
8672 |
|
8673 | function class_1(props) {
|
8674 | var _this = _super.call(this, props) || this;
|
8675 |
|
8676 | _this.fbAsyncInit = _this.fbAsyncInit.bind(_this);
|
8677 | _this.initFB = _this.initFB.bind(_this);
|
8678 | _this.signIn = _this.signIn.bind(_this);
|
8679 | _this.signOut = _this.signOut.bind(_this);
|
8680 | _this.federatedSignIn = _this.federatedSignIn.bind(_this);
|
8681 | _this.state = {};
|
8682 | return _this;
|
8683 | }
|
8684 |
|
8685 | class_1.prototype.signIn = function () {
|
8686 | var _this = this;
|
8687 |
|
8688 | var fb = window.FB;
|
8689 | fb.getLoginStatus(function (response) {
|
8690 | var payload = {
|
8691 | provider: constants_1.Constants.FACEBOOK
|
8692 | };
|
8693 |
|
8694 | try {
|
8695 | localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
|
8696 | } catch (e) {
|
8697 | logger.debug('Failed to cache auth source into localStorage', e);
|
8698 | }
|
8699 |
|
8700 | if (response.status === 'connected') {
|
8701 | _this.federatedSignIn(response.authResponse);
|
8702 | } else {
|
8703 | fb.login(function (response) {
|
8704 | if (!response || !response.authResponse) {
|
8705 | return;
|
8706 | }
|
8707 |
|
8708 | _this.federatedSignIn(response.authResponse);
|
8709 | }, {
|
8710 | scope: 'public_profile,email'
|
8711 | });
|
8712 | }
|
8713 | });
|
8714 | };
|
8715 |
|
8716 | class_1.prototype.federatedSignIn = function (response) {
|
8717 | logger.debug(response);
|
8718 | var onStateChange = this.props.onStateChange;
|
8719 | var accessToken = response.accessToken,
|
8720 | expiresIn = response.expiresIn;
|
8721 | var date = new Date();
|
8722 | var expires_at = expiresIn * 1000 + date.getTime();
|
8723 |
|
8724 | if (!accessToken) {
|
8725 | return;
|
8726 | }
|
8727 |
|
8728 | var fb = window.FB;
|
8729 | fb.api('/me', {
|
8730 | fields: 'name,email,picture'
|
8731 | }, function (response) {
|
8732 | var user = {
|
8733 | name: response.name,
|
8734 | email: response.email,
|
8735 | picture: response.picture.data.url
|
8736 | };
|
8737 |
|
8738 | if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
|
8739 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
8740 | }
|
8741 |
|
8742 | auth_1.Auth.federatedSignIn('facebook', {
|
8743 | token: accessToken,
|
8744 | expires_at: expires_at
|
8745 | }, user).then(function (credentials) {
|
8746 | return auth_1.Auth.currentAuthenticatedUser();
|
8747 | }).then(function (authUser) {
|
8748 | if (onStateChange) {
|
8749 | onStateChange('signedIn', authUser);
|
8750 | }
|
8751 | });
|
8752 | });
|
8753 | };
|
8754 |
|
8755 | class_1.prototype.signOut = function () {
|
8756 | var fb = window.FB;
|
8757 |
|
8758 | if (!fb) {
|
8759 | logger.debug('FB sdk undefined');
|
8760 | return Promise.resolve();
|
8761 | }
|
8762 |
|
8763 | fb.getLoginStatus(function (response) {
|
8764 | if (response.status === 'connected') {
|
8765 | return new Promise(function (res, rej) {
|
8766 | logger.debug('facebook signing out');
|
8767 | fb.logout(function (response) {
|
8768 | res(response);
|
8769 | });
|
8770 | });
|
8771 | } else {
|
8772 | return Promise.resolve();
|
8773 | }
|
8774 | });
|
8775 | };
|
8776 |
|
8777 | class_1.prototype.componentDidMount = function () {
|
8778 | var facebook_app_id = this.props.facebook_app_id;
|
8779 | if (facebook_app_id && !window.FB) this.createScript();
|
8780 | };
|
8781 |
|
8782 | class_1.prototype.fbAsyncInit = function () {
|
8783 | logger.debug('init FB');
|
8784 | var facebook_app_id = this.props.facebook_app_id;
|
8785 | var fb = window.FB;
|
8786 | fb.init({
|
8787 | appId: facebook_app_id,
|
8788 | cookie: true,
|
8789 | xfbml: true,
|
8790 | version: 'v2.11'
|
8791 | });
|
8792 | fb.getLoginStatus(function (response) {
|
8793 | return logger.debug(response);
|
8794 | });
|
8795 | };
|
8796 |
|
8797 | class_1.prototype.initFB = function () {
|
8798 | var fb = window.FB;
|
8799 | logger.debug('FB inited');
|
8800 | };
|
8801 |
|
8802 | class_1.prototype.createScript = function () {
|
8803 | window.fbAsyncInit = this.fbAsyncInit;
|
8804 | var script = document.createElement('script');
|
8805 | script.src = 'https://connect.facebook.net/en_US/sdk.js';
|
8806 | script.async = true;
|
8807 | script.onload = this.initFB;
|
8808 | document.body.appendChild(script);
|
8809 | };
|
8810 |
|
8811 | class_1.prototype.render = function () {
|
8812 | var fb = window.FB;
|
8813 | return React.createElement(Comp, __assign({}, this.props, {
|
8814 | fb: fb,
|
8815 | facebookSignIn: this.signIn,
|
8816 | facebookSignOut: this.signOut
|
8817 | }));
|
8818 | };
|
8819 |
|
8820 | return class_1;
|
8821 | }(React.Component)
|
8822 | );
|
8823 | }
|
8824 |
|
8825 | exports.withFacebook = withFacebook;
|
8826 |
|
8827 | var Button = function Button(props) {
|
8828 | return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
|
8829 | id: ui_1.facebookSignInButton,
|
8830 | onClick: props.facebookSignIn,
|
8831 | theme: props.theme || Amplify_UI_Theme_1["default"],
|
8832 | variant: 'facebookSignInButton'
|
8833 | }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
|
8834 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8835 | }, React.createElement("svg", {
|
8836 | viewBox: "0 0 279 538",
|
8837 | xmlns: "http://www.w3.org/2000/svg"
|
8838 | }, React.createElement("g", {
|
8839 | id: "Page-1",
|
8840 | fill: "none",
|
8841 | fillRule: "evenodd"
|
8842 | }, React.createElement("g", {
|
8843 | id: "Artboard",
|
8844 | fill: "#FFF"
|
8845 | }, React.createElement("path", {
|
8846 | d: "M82.3409742,538 L82.3409742,292.936652 L0,292.936652 L0,196.990154 L82.2410458,196.990154 L82.2410458,126.4295 C82.2410458,44.575144 132.205229,0 205.252865,0 C240.227794,0 270.306232,2.59855099 279,3.79788222 L279,89.2502322 L228.536175,89.2502322 C188.964542,89.2502322 181.270057,108.139699 181.270057,135.824262 L181.270057,196.89021 L276.202006,196.89021 L263.810888,292.836708 L181.16913,292.836708 L181.16913,538 L82.3409742,538 Z",
|
8847 | id: "Fill-1"
|
8848 | }))))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
|
8849 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
8850 | }, core_1.I18n.get('Sign In with Facebook')));
|
8851 | };
|
8852 |
|
8853 | exports.FacebookButton = withFacebook(Button);
|
8854 |
|
8855 |
|
8856 |
|
8857 |
|
8858 | exports["default"] = withFacebook;
|
8859 |
|
8860 | }),
|
8861 |
|
8862 | "./lib/Auth/Provider/withGoogle.js":
|
8863 |
|
8864 |
|
8865 |
|
8866 |
|
8867 | (function(module, exports, __webpack_require__) {
|
8868 |
|
8869 | "use strict";
|
8870 |
|
8871 |
|
8872 |
|
8873 |
|
8874 |
|
8875 |
|
8876 |
|
8877 |
|
8878 |
|
8879 |
|
8880 |
|
8881 |
|
8882 |
|
8883 |
|
8884 | var __extends = this && this.__extends || function () {
|
8885 | var _extendStatics = function extendStatics(d, b) {
|
8886 | _extendStatics = Object.setPrototypeOf || {
|
8887 | __proto__: []
|
8888 | } instanceof Array && function (d, b) {
|
8889 | d.__proto__ = b;
|
8890 | } || function (d, b) {
|
8891 | for (var p in b) {
|
8892 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
8893 | }
|
8894 | };
|
8895 |
|
8896 | return _extendStatics(d, b);
|
8897 | };
|
8898 |
|
8899 | return function (d, b) {
|
8900 | _extendStatics(d, b);
|
8901 |
|
8902 | function __() {
|
8903 | this.constructor = d;
|
8904 | }
|
8905 |
|
8906 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
8907 | };
|
8908 | }();
|
8909 |
|
8910 | var __assign = this && this.__assign || function () {
|
8911 | __assign = Object.assign || function (t) {
|
8912 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
8913 | s = arguments[i];
|
8914 |
|
8915 | for (var p in s) {
|
8916 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
8917 | }
|
8918 | }
|
8919 |
|
8920 | return t;
|
8921 | };
|
8922 |
|
8923 | return __assign.apply(this, arguments);
|
8924 | };
|
8925 |
|
8926 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
8927 | function adopt(value) {
|
8928 | return value instanceof P ? value : new P(function (resolve) {
|
8929 | resolve(value);
|
8930 | });
|
8931 | }
|
8932 |
|
8933 | return new (P || (P = Promise))(function (resolve, reject) {
|
8934 | function fulfilled(value) {
|
8935 | try {
|
8936 | step(generator.next(value));
|
8937 | } catch (e) {
|
8938 | reject(e);
|
8939 | }
|
8940 | }
|
8941 |
|
8942 | function rejected(value) {
|
8943 | try {
|
8944 | step(generator["throw"](value));
|
8945 | } catch (e) {
|
8946 | reject(e);
|
8947 | }
|
8948 | }
|
8949 |
|
8950 | function step(result) {
|
8951 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
8952 | }
|
8953 |
|
8954 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8955 | });
|
8956 | };
|
8957 |
|
8958 | var __generator = this && this.__generator || function (thisArg, body) {
|
8959 | var _ = {
|
8960 | label: 0,
|
8961 | sent: function sent() {
|
8962 | if (t[0] & 1) throw t[1];
|
8963 | return t[1];
|
8964 | },
|
8965 | trys: [],
|
8966 | ops: []
|
8967 | },
|
8968 | f,
|
8969 | y,
|
8970 | t,
|
8971 | g;
|
8972 | return g = {
|
8973 | next: verb(0),
|
8974 | "throw": verb(1),
|
8975 | "return": verb(2)
|
8976 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
8977 | return this;
|
8978 | }), g;
|
8979 |
|
8980 | function verb(n) {
|
8981 | return function (v) {
|
8982 | return step([n, v]);
|
8983 | };
|
8984 | }
|
8985 |
|
8986 | function step(op) {
|
8987 | if (f) throw new TypeError("Generator is already executing.");
|
8988 |
|
8989 | while (_) {
|
8990 | try {
|
8991 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
8992 | if (y = 0, t) op = [op[0] & 2, t.value];
|
8993 |
|
8994 | switch (op[0]) {
|
8995 | case 0:
|
8996 | case 1:
|
8997 | t = op;
|
8998 | break;
|
8999 |
|
9000 | case 4:
|
9001 | _.label++;
|
9002 | return {
|
9003 | value: op[1],
|
9004 | done: false
|
9005 | };
|
9006 |
|
9007 | case 5:
|
9008 | _.label++;
|
9009 | y = op[1];
|
9010 | op = [0];
|
9011 | continue;
|
9012 |
|
9013 | case 7:
|
9014 | op = _.ops.pop();
|
9015 |
|
9016 | _.trys.pop();
|
9017 |
|
9018 | continue;
|
9019 |
|
9020 | default:
|
9021 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
9022 | _ = 0;
|
9023 | continue;
|
9024 | }
|
9025 |
|
9026 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
9027 | _.label = op[1];
|
9028 | break;
|
9029 | }
|
9030 |
|
9031 | if (op[0] === 6 && _.label < t[1]) {
|
9032 | _.label = t[1];
|
9033 | t = op;
|
9034 | break;
|
9035 | }
|
9036 |
|
9037 | if (t && _.label < t[2]) {
|
9038 | _.label = t[2];
|
9039 |
|
9040 | _.ops.push(op);
|
9041 |
|
9042 | break;
|
9043 | }
|
9044 |
|
9045 | if (t[2]) _.ops.pop();
|
9046 |
|
9047 | _.trys.pop();
|
9048 |
|
9049 | continue;
|
9050 | }
|
9051 |
|
9052 | op = body.call(thisArg, _);
|
9053 | } catch (e) {
|
9054 | op = [6, e];
|
9055 | y = 0;
|
9056 | } finally {
|
9057 | f = t = 0;
|
9058 | }
|
9059 | }
|
9060 |
|
9061 | if (op[0] & 5) throw op[1];
|
9062 | return {
|
9063 | value: op[0] ? op[1] : void 0,
|
9064 | done: true
|
9065 | };
|
9066 | }
|
9067 | };
|
9068 |
|
9069 | var __importStar = this && this.__importStar || function (mod) {
|
9070 | if (mod && mod.__esModule) return mod;
|
9071 | var result = {};
|
9072 | if (mod != null) for (var k in mod) {
|
9073 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
9074 | }
|
9075 | result["default"] = mod;
|
9076 | return result;
|
9077 | };
|
9078 |
|
9079 | var __importDefault = this && this.__importDefault || function (mod) {
|
9080 | return mod && mod.__esModule ? mod : {
|
9081 | "default": mod
|
9082 | };
|
9083 | };
|
9084 |
|
9085 | Object.defineProperty(exports, "__esModule", {
|
9086 | value: true
|
9087 | });
|
9088 |
|
9089 | var React = __importStar(__webpack_require__( "react"));
|
9090 |
|
9091 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
9092 |
|
9093 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
9094 |
|
9095 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
9096 |
|
9097 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
9098 |
|
9099 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
9100 |
|
9101 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
9102 |
|
9103 | var logger = new core_1.ConsoleLogger('withGoogle');
|
9104 |
|
9105 | function withGoogle(Comp) {
|
9106 | return (
|
9107 |
|
9108 | function (_super) {
|
9109 | __extends(class_1, _super);
|
9110 |
|
9111 | function class_1(props) {
|
9112 | var _this = _super.call(this, props) || this;
|
9113 |
|
9114 | _this.initGapi = _this.initGapi.bind(_this);
|
9115 | _this.signIn = _this.signIn.bind(_this);
|
9116 | _this.signOut = _this.signOut.bind(_this);
|
9117 | _this.federatedSignIn = _this.federatedSignIn.bind(_this);
|
9118 | _this.state = {};
|
9119 | return _this;
|
9120 | }
|
9121 |
|
9122 | class_1.prototype.signIn = function () {
|
9123 | var _this = this;
|
9124 |
|
9125 | var ga = window.gapi.auth2.getAuthInstance();
|
9126 | var onError = this.props.onError;
|
9127 | ga.signIn().then(function (googleUser) {
|
9128 | _this.federatedSignIn(googleUser);
|
9129 |
|
9130 | var payload = {
|
9131 | provider: constants_1.Constants.GOOGLE
|
9132 | };
|
9133 |
|
9134 | try {
|
9135 | localStorage.setItem(constants_1.Constants.AUTH_SOURCE_KEY, JSON.stringify(payload));
|
9136 | } catch (e) {
|
9137 | logger.debug('Failed to cache auth source into localStorage', e);
|
9138 | }
|
9139 | }, function (error) {
|
9140 | if (onError) onError(error);else throw error;
|
9141 | });
|
9142 | };
|
9143 |
|
9144 | class_1.prototype.federatedSignIn = function (googleUser) {
|
9145 | return __awaiter(this, void 0, void 0, function () {
|
9146 | var _a, id_token, expires_at, profile, user, onStateChange;
|
9147 |
|
9148 | return __generator(this, function (_b) {
|
9149 | switch (_b.label) {
|
9150 | case 0:
|
9151 | _a = googleUser.getAuthResponse(), id_token = _a.id_token, expires_at = _a.expires_at;
|
9152 | profile = googleUser.getBasicProfile();
|
9153 | user = {
|
9154 | email: profile.getEmail(),
|
9155 | name: profile.getName(),
|
9156 | picture: profile.getImageUrl()
|
9157 | };
|
9158 | onStateChange = this.props.onStateChange;
|
9159 |
|
9160 | if (!auth_1.Auth || typeof auth_1.Auth.federatedSignIn !== 'function' || typeof auth_1.Auth.currentAuthenticatedUser !== 'function') {
|
9161 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
9162 | }
|
9163 |
|
9164 | return [4
|
9165 |
|
9166 | , auth_1.Auth.federatedSignIn('google', {
|
9167 | token: id_token,
|
9168 | expires_at: expires_at
|
9169 | }, user)];
|
9170 |
|
9171 | case 1:
|
9172 | _b.sent();
|
9173 |
|
9174 | return [4
|
9175 |
|
9176 | , auth_1.Auth.currentAuthenticatedUser()];
|
9177 |
|
9178 | case 2:
|
9179 | user = _b.sent();
|
9180 |
|
9181 | if (onStateChange) {
|
9182 | onStateChange('signedIn', user);
|
9183 | }
|
9184 |
|
9185 | return [2
|
9186 |
|
9187 | ];
|
9188 | }
|
9189 | });
|
9190 | });
|
9191 | };
|
9192 |
|
9193 | class_1.prototype.signOut = function () {
|
9194 | var authInstance = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
|
9195 |
|
9196 | if (!authInstance) {
|
9197 | return Promise.resolve();
|
9198 | }
|
9199 |
|
9200 | authInstance.then(function (googleAuth) {
|
9201 | if (!googleAuth) {
|
9202 | logger.debug('google Auth undefined');
|
9203 | return Promise.resolve();
|
9204 | }
|
9205 |
|
9206 | logger.debug('google signing out');
|
9207 | return googleAuth.signOut();
|
9208 | });
|
9209 | };
|
9210 |
|
9211 | class_1.prototype.componentDidMount = function () {
|
9212 | var google_client_id = this.props.google_client_id;
|
9213 | var ga = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
|
9214 | if (google_client_id && !ga) this.createScript();
|
9215 | };
|
9216 |
|
9217 | class_1.prototype.createScript = function () {
|
9218 | var script = document.createElement('script');
|
9219 | script.src = 'https://apis.google.com/js/platform.js';
|
9220 | script.async = true;
|
9221 | script.onload = this.initGapi;
|
9222 | document.body.appendChild(script);
|
9223 | };
|
9224 |
|
9225 | class_1.prototype.initGapi = function () {
|
9226 | logger.debug('init gapi');
|
9227 | var that = this;
|
9228 | var google_client_id = this.props.google_client_id;
|
9229 | var g = window.gapi;
|
9230 | g.load('auth2', function () {
|
9231 | g.auth2.init({
|
9232 | client_id: google_client_id,
|
9233 | scope: 'profile email openid'
|
9234 | });
|
9235 | });
|
9236 | };
|
9237 |
|
9238 | class_1.prototype.render = function () {
|
9239 | var ga = window.gapi && window.gapi.auth2 ? window.gapi.auth2.getAuthInstance() : null;
|
9240 | return React.createElement(Comp, __assign({}, this.props, {
|
9241 | ga: ga,
|
9242 | googleSignIn: this.signIn,
|
9243 | googleSignOut: this.signOut
|
9244 | }));
|
9245 | };
|
9246 |
|
9247 | return class_1;
|
9248 | }(React.Component)
|
9249 | );
|
9250 | }
|
9251 |
|
9252 | exports.withGoogle = withGoogle;
|
9253 |
|
9254 | var Button = function Button(props) {
|
9255 | return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
|
9256 | id: ui_1.googleSignInButton,
|
9257 | onClick: props.googleSignIn,
|
9258 | theme: props.theme || Amplify_UI_Theme_1["default"],
|
9259 | variant: "googleSignInButton"
|
9260 | }, React.createElement(Amplify_UI_Components_React_1.SignInButtonIcon, {
|
9261 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
9262 | }, React.createElement("svg", {
|
9263 | viewBox: "0 0 256 262",
|
9264 | xmlns: "http://ww0w.w3.org/2000/svg",
|
9265 | preserveAspectRatio: "xMidYMid"
|
9266 | }, React.createElement("path", {
|
9267 | d: "M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027",
|
9268 | fill: "#4285F4"
|
9269 | }), React.createElement("path", {
|
9270 | d: "M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1",
|
9271 | fill: "#34A853"
|
9272 | }), React.createElement("path", {
|
9273 | d: "M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782",
|
9274 | fill: "#FBBC05"
|
9275 | }), React.createElement("path", {
|
9276 | d: "M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251",
|
9277 | fill: "#EB4335"
|
9278 | }))), React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
|
9279 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
9280 | }, core_1.I18n.get('Sign In with Google')));
|
9281 | };
|
9282 |
|
9283 | exports.GoogleButton = withGoogle(Button);
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 | exports["default"] = withGoogle;
|
9289 |
|
9290 | }),
|
9291 |
|
9292 | "./lib/Auth/Provider/withOAuth.js":
|
9293 |
|
9294 |
|
9295 |
|
9296 |
|
9297 | (function(module, exports, __webpack_require__) {
|
9298 |
|
9299 | "use strict";
|
9300 |
|
9301 |
|
9302 |
|
9303 |
|
9304 |
|
9305 |
|
9306 |
|
9307 |
|
9308 |
|
9309 |
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 | var __extends = this && this.__extends || function () {
|
9315 | var _extendStatics = function extendStatics(d, b) {
|
9316 | _extendStatics = Object.setPrototypeOf || {
|
9317 | __proto__: []
|
9318 | } instanceof Array && function (d, b) {
|
9319 | d.__proto__ = b;
|
9320 | } || function (d, b) {
|
9321 | for (var p in b) {
|
9322 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
9323 | }
|
9324 | };
|
9325 |
|
9326 | return _extendStatics(d, b);
|
9327 | };
|
9328 |
|
9329 | return function (d, b) {
|
9330 | _extendStatics(d, b);
|
9331 |
|
9332 | function __() {
|
9333 | this.constructor = d;
|
9334 | }
|
9335 |
|
9336 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9337 | };
|
9338 | }();
|
9339 |
|
9340 | var __assign = this && this.__assign || function () {
|
9341 | __assign = Object.assign || function (t) {
|
9342 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
9343 | s = arguments[i];
|
9344 |
|
9345 | for (var p in s) {
|
9346 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
9347 | }
|
9348 | }
|
9349 |
|
9350 | return t;
|
9351 | };
|
9352 |
|
9353 | return __assign.apply(this, arguments);
|
9354 | };
|
9355 |
|
9356 | var __importStar = this && this.__importStar || function (mod) {
|
9357 | if (mod && mod.__esModule) return mod;
|
9358 | var result = {};
|
9359 | if (mod != null) for (var k in mod) {
|
9360 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
9361 | }
|
9362 | result["default"] = mod;
|
9363 | return result;
|
9364 | };
|
9365 |
|
9366 | var __importDefault = this && this.__importDefault || function (mod) {
|
9367 | return mod && mod.__esModule ? mod : {
|
9368 | "default": mod
|
9369 | };
|
9370 | };
|
9371 |
|
9372 | Object.defineProperty(exports, "__esModule", {
|
9373 | value: true
|
9374 | });
|
9375 |
|
9376 | var React = __importStar(__webpack_require__( "react"));
|
9377 |
|
9378 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
9379 |
|
9380 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
9381 |
|
9382 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
9383 |
|
9384 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
9385 |
|
9386 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
9387 |
|
9388 | function withOAuth(Comp) {
|
9389 | return (
|
9390 |
|
9391 | function (_super) {
|
9392 | __extends(class_1, _super);
|
9393 |
|
9394 | function class_1(props) {
|
9395 | var _this = _super.call(this, props) || this;
|
9396 |
|
9397 | _this.signIn = _this.signIn.bind(_this);
|
9398 | return _this;
|
9399 | }
|
9400 |
|
9401 | class_1.prototype.signIn = function (_e, provider) {
|
9402 | auth_1.Auth.federatedSignIn({
|
9403 | provider: provider
|
9404 | });
|
9405 | };
|
9406 |
|
9407 | class_1.prototype.render = function () {
|
9408 | return React.createElement(Comp, __assign({}, this.props, {
|
9409 | OAuthSignIn: this.signIn
|
9410 | }));
|
9411 | };
|
9412 |
|
9413 | return class_1;
|
9414 | }(React.Component)
|
9415 | );
|
9416 | }
|
9417 |
|
9418 | exports.withOAuth = withOAuth;
|
9419 |
|
9420 | var Button = function Button(props) {
|
9421 | return React.createElement(Amplify_UI_Components_React_1.SignInButton, {
|
9422 | id: ui_1.oAuthSignInButton,
|
9423 | onClick: function onClick() {
|
9424 | return props.OAuthSignIn();
|
9425 | },
|
9426 | theme: props.theme || Amplify_UI_Theme_1["default"],
|
9427 | variant: 'oAuthSignInButton'
|
9428 | }, React.createElement(Amplify_UI_Components_React_1.SignInButtonContent, {
|
9429 | theme: props.theme || Amplify_UI_Theme_1["default"]
|
9430 | }, core_1.I18n.get(props.label || 'Sign in with AWS')));
|
9431 | };
|
9432 |
|
9433 | exports.OAuthButton = withOAuth(Button);
|
9434 |
|
9435 |
|
9436 |
|
9437 |
|
9438 | exports["default"] = withOAuth;
|
9439 |
|
9440 | }),
|
9441 |
|
9442 | "./lib/Auth/RequireNewPassword.js":
|
9443 |
|
9444 |
|
9445 |
|
9446 |
|
9447 | (function(module, exports, __webpack_require__) {
|
9448 |
|
9449 | "use strict";
|
9450 |
|
9451 |
|
9452 |
|
9453 |
|
9454 |
|
9455 |
|
9456 |
|
9457 |
|
9458 |
|
9459 |
|
9460 |
|
9461 |
|
9462 |
|
9463 |
|
9464 | var __extends = this && this.__extends || function () {
|
9465 | var _extendStatics = function extendStatics(d, b) {
|
9466 | _extendStatics = Object.setPrototypeOf || {
|
9467 | __proto__: []
|
9468 | } instanceof Array && function (d, b) {
|
9469 | d.__proto__ = b;
|
9470 | } || function (d, b) {
|
9471 | for (var p in b) {
|
9472 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
9473 | }
|
9474 | };
|
9475 |
|
9476 | return _extendStatics(d, b);
|
9477 | };
|
9478 |
|
9479 | return function (d, b) {
|
9480 | _extendStatics(d, b);
|
9481 |
|
9482 | function __() {
|
9483 | this.constructor = d;
|
9484 | }
|
9485 |
|
9486 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9487 | };
|
9488 | }();
|
9489 |
|
9490 | var __importStar = this && this.__importStar || function (mod) {
|
9491 | if (mod && mod.__esModule) return mod;
|
9492 | var result = {};
|
9493 | if (mod != null) for (var k in mod) {
|
9494 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
9495 | }
|
9496 | result["default"] = mod;
|
9497 | return result;
|
9498 | };
|
9499 |
|
9500 | Object.defineProperty(exports, "__esModule", {
|
9501 | value: true
|
9502 | });
|
9503 |
|
9504 | var React = __importStar(__webpack_require__( "react"));
|
9505 |
|
9506 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
9507 |
|
9508 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
9509 |
|
9510 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
9511 |
|
9512 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
9513 |
|
9514 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
9515 |
|
9516 | var logger = new core_1.ConsoleLogger('RequireNewPassword');
|
9517 |
|
9518 | var RequireNewPassword =
|
9519 |
|
9520 | function (_super) {
|
9521 | __extends(RequireNewPassword, _super);
|
9522 |
|
9523 | function RequireNewPassword(props) {
|
9524 | var _this = _super.call(this, props) || this;
|
9525 |
|
9526 | _this._validAuthStates = ['requireNewPassword'];
|
9527 | _this.change = _this.change.bind(_this);
|
9528 | _this.checkContact = _this.checkContact.bind(_this);
|
9529 | return _this;
|
9530 | }
|
9531 |
|
9532 | RequireNewPassword.prototype.checkContact = function (user) {
|
9533 | var _this = this;
|
9534 |
|
9535 | if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
|
9536 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
9537 | }
|
9538 |
|
9539 | auth_1.Auth.verifiedContact(user).then(function (data) {
|
9540 | if (!core_1.isEmpty(data.verified)) {
|
9541 | _this.changeState('signedIn', user);
|
9542 | } else {
|
9543 | user = Object.assign(user, data);
|
9544 |
|
9545 | _this.changeState('verifyContact', user);
|
9546 | }
|
9547 | });
|
9548 | };
|
9549 |
|
9550 | RequireNewPassword.prototype.change = function () {
|
9551 | var _this = this;
|
9552 |
|
9553 | var user = this.props.authData;
|
9554 | var password = this.inputs.password;
|
9555 | var requiredAttributes = user.challengeParam.requiredAttributes;
|
9556 | var attrs = objectWithProperties(this.inputs, requiredAttributes);
|
9557 |
|
9558 | if (!auth_1.Auth || typeof auth_1.Auth.completeNewPassword !== 'function') {
|
9559 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
9560 | }
|
9561 |
|
9562 | auth_1.Auth.completeNewPassword(user, password, attrs).then(function (user) {
|
9563 | logger.debug('complete new password', user);
|
9564 |
|
9565 | if (user.challengeName === 'SMS_MFA') {
|
9566 | _this.changeState('confirmSignIn', user);
|
9567 | } else if (user.challengeName === 'MFA_SETUP') {
|
9568 | logger.debug('TOTP setup', user.challengeParam);
|
9569 |
|
9570 | _this.changeState('TOTPSetup', user);
|
9571 | } else {
|
9572 | _this.checkContact(user);
|
9573 | }
|
9574 | })["catch"](function (err) {
|
9575 | return _this.error(err);
|
9576 | });
|
9577 | };
|
9578 |
|
9579 | RequireNewPassword.prototype.showComponent = function (theme) {
|
9580 | var _this = this;
|
9581 |
|
9582 | var hide = this.props.hide;
|
9583 |
|
9584 | if (hide && hide.includes(RequireNewPassword)) {
|
9585 | return null;
|
9586 | }
|
9587 |
|
9588 | var user = this.props.authData;
|
9589 | var requiredAttributes = user.challengeParam.requiredAttributes;
|
9590 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
9591 | theme: theme,
|
9592 | "data-test": data_test_attributes_1.auth.requireNewPassword.section
|
9593 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
9594 | theme: theme,
|
9595 | "data-test": data_test_attributes_1.auth.requireNewPassword.headerSection
|
9596 | }, core_1.I18n.get('Change Password')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
9597 | theme: theme,
|
9598 | "data-test": data_test_attributes_1.auth.requireNewPassword.bodySection
|
9599 | }, React.createElement(Amplify_UI_Components_React_1.Input, {
|
9600 | autoFocus: true,
|
9601 | placeholder: core_1.I18n.get('New Password'),
|
9602 | theme: theme,
|
9603 | key: "password",
|
9604 | name: "password",
|
9605 | type: "password",
|
9606 | onChange: this.handleInputChange,
|
9607 | "data-test": data_test_attributes_1.auth.requireNewPassword.newPasswordInput
|
9608 | }), requiredAttributes.map(function (attribute) {
|
9609 | return React.createElement(Amplify_UI_Components_React_1.Input, {
|
9610 | placeholder: core_1.I18n.get(convertToPlaceholder(attribute)),
|
9611 | theme: theme,
|
9612 | key: attribute,
|
9613 | name: attribute,
|
9614 | type: "text",
|
9615 | onChange: _this.handleInputChange
|
9616 | });
|
9617 | })), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
9618 | theme: theme
|
9619 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
9620 | theme: theme
|
9621 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
9622 | theme: theme,
|
9623 | onClick: this.change
|
9624 | }, core_1.I18n.get('Change'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
9625 | theme: theme
|
9626 | }, React.createElement(Amplify_UI_Components_React_1.Link, {
|
9627 | theme: theme,
|
9628 | onClick: function onClick() {
|
9629 | return _this.changeState('signIn');
|
9630 | },
|
9631 | "data-test": data_test_attributes_1.auth.requireNewPassword.backToSignInLink
|
9632 | }, core_1.I18n.get('Back to Sign In')))));
|
9633 | };
|
9634 |
|
9635 | return RequireNewPassword;
|
9636 | }(AuthPiece_1.AuthPiece);
|
9637 |
|
9638 | exports.RequireNewPassword = RequireNewPassword;
|
9639 |
|
9640 | function convertToPlaceholder(str) {
|
9641 | return str.split('_').map(function (part) {
|
9642 | return part.charAt(0).toUpperCase() + part.substr(1).toLowerCase();
|
9643 | }).join(' ');
|
9644 | }
|
9645 |
|
9646 | function objectWithProperties(obj, keys) {
|
9647 | var target = {};
|
9648 |
|
9649 | for (var key in obj) {
|
9650 | if (keys.indexOf(key) === -1) {
|
9651 | continue;
|
9652 | }
|
9653 |
|
9654 | if (!Object.prototype.hasOwnProperty.call(obj, key)) {
|
9655 | continue;
|
9656 | }
|
9657 |
|
9658 | target[key] = obj[key];
|
9659 | }
|
9660 |
|
9661 | return target;
|
9662 | }
|
9663 |
|
9664 |
|
9665 |
|
9666 |
|
9667 |
|
9668 | exports["default"] = RequireNewPassword;
|
9669 |
|
9670 | }),
|
9671 |
|
9672 | "./lib/Auth/SignIn.js":
|
9673 |
|
9674 |
|
9675 |
|
9676 |
|
9677 | (function(module, exports, __webpack_require__) {
|
9678 |
|
9679 | "use strict";
|
9680 |
|
9681 |
|
9682 |
|
9683 |
|
9684 |
|
9685 |
|
9686 |
|
9687 |
|
9688 |
|
9689 |
|
9690 |
|
9691 |
|
9692 |
|
9693 |
|
9694 | var __extends = this && this.__extends || function () {
|
9695 | var _extendStatics = function extendStatics(d, b) {
|
9696 | _extendStatics = Object.setPrototypeOf || {
|
9697 | __proto__: []
|
9698 | } instanceof Array && function (d, b) {
|
9699 | d.__proto__ = b;
|
9700 | } || function (d, b) {
|
9701 | for (var p in b) {
|
9702 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
9703 | }
|
9704 | };
|
9705 |
|
9706 | return _extendStatics(d, b);
|
9707 | };
|
9708 |
|
9709 | return function (d, b) {
|
9710 | _extendStatics(d, b);
|
9711 |
|
9712 | function __() {
|
9713 | this.constructor = d;
|
9714 | }
|
9715 |
|
9716 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9717 | };
|
9718 | }();
|
9719 |
|
9720 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
9721 | function adopt(value) {
|
9722 | return value instanceof P ? value : new P(function (resolve) {
|
9723 | resolve(value);
|
9724 | });
|
9725 | }
|
9726 |
|
9727 | return new (P || (P = Promise))(function (resolve, reject) {
|
9728 | function fulfilled(value) {
|
9729 | try {
|
9730 | step(generator.next(value));
|
9731 | } catch (e) {
|
9732 | reject(e);
|
9733 | }
|
9734 | }
|
9735 |
|
9736 | function rejected(value) {
|
9737 | try {
|
9738 | step(generator["throw"](value));
|
9739 | } catch (e) {
|
9740 | reject(e);
|
9741 | }
|
9742 | }
|
9743 |
|
9744 | function step(result) {
|
9745 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
9746 | }
|
9747 |
|
9748 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9749 | });
|
9750 | };
|
9751 |
|
9752 | var __generator = this && this.__generator || function (thisArg, body) {
|
9753 | var _ = {
|
9754 | label: 0,
|
9755 | sent: function sent() {
|
9756 | if (t[0] & 1) throw t[1];
|
9757 | return t[1];
|
9758 | },
|
9759 | trys: [],
|
9760 | ops: []
|
9761 | },
|
9762 | f,
|
9763 | y,
|
9764 | t,
|
9765 | g;
|
9766 | return g = {
|
9767 | next: verb(0),
|
9768 | "throw": verb(1),
|
9769 | "return": verb(2)
|
9770 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
9771 | return this;
|
9772 | }), g;
|
9773 |
|
9774 | function verb(n) {
|
9775 | return function (v) {
|
9776 | return step([n, v]);
|
9777 | };
|
9778 | }
|
9779 |
|
9780 | function step(op) {
|
9781 | if (f) throw new TypeError("Generator is already executing.");
|
9782 |
|
9783 | while (_) {
|
9784 | try {
|
9785 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
9786 | if (y = 0, t) op = [op[0] & 2, t.value];
|
9787 |
|
9788 | switch (op[0]) {
|
9789 | case 0:
|
9790 | case 1:
|
9791 | t = op;
|
9792 | break;
|
9793 |
|
9794 | case 4:
|
9795 | _.label++;
|
9796 | return {
|
9797 | value: op[1],
|
9798 | done: false
|
9799 | };
|
9800 |
|
9801 | case 5:
|
9802 | _.label++;
|
9803 | y = op[1];
|
9804 | op = [0];
|
9805 | continue;
|
9806 |
|
9807 | case 7:
|
9808 | op = _.ops.pop();
|
9809 |
|
9810 | _.trys.pop();
|
9811 |
|
9812 | continue;
|
9813 |
|
9814 | default:
|
9815 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
9816 | _ = 0;
|
9817 | continue;
|
9818 | }
|
9819 |
|
9820 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
9821 | _.label = op[1];
|
9822 | break;
|
9823 | }
|
9824 |
|
9825 | if (op[0] === 6 && _.label < t[1]) {
|
9826 | _.label = t[1];
|
9827 | t = op;
|
9828 | break;
|
9829 | }
|
9830 |
|
9831 | if (t && _.label < t[2]) {
|
9832 | _.label = t[2];
|
9833 |
|
9834 | _.ops.push(op);
|
9835 |
|
9836 | break;
|
9837 | }
|
9838 |
|
9839 | if (t[2]) _.ops.pop();
|
9840 |
|
9841 | _.trys.pop();
|
9842 |
|
9843 | continue;
|
9844 | }
|
9845 |
|
9846 | op = body.call(thisArg, _);
|
9847 | } catch (e) {
|
9848 | op = [6, e];
|
9849 | y = 0;
|
9850 | } finally {
|
9851 | f = t = 0;
|
9852 | }
|
9853 | }
|
9854 |
|
9855 | if (op[0] & 5) throw op[1];
|
9856 | return {
|
9857 | value: op[0] ? op[1] : void 0,
|
9858 | done: true
|
9859 | };
|
9860 | }
|
9861 | };
|
9862 |
|
9863 | var __importStar = this && this.__importStar || function (mod) {
|
9864 | if (mod && mod.__esModule) return mod;
|
9865 | var result = {};
|
9866 | if (mod != null) for (var k in mod) {
|
9867 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
9868 | }
|
9869 | result["default"] = mod;
|
9870 | return result;
|
9871 | };
|
9872 |
|
9873 | Object.defineProperty(exports, "__esModule", {
|
9874 | value: true
|
9875 | });
|
9876 |
|
9877 | var React = __importStar(__webpack_require__( "react"));
|
9878 |
|
9879 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
9880 |
|
9881 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
9882 |
|
9883 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
9884 |
|
9885 | var FederatedSignIn_1 = __webpack_require__( "./lib/Auth/FederatedSignIn.js");
|
9886 |
|
9887 | var SignUp_1 = __webpack_require__( "./lib/Auth/SignUp.js");
|
9888 |
|
9889 | var ForgotPassword_1 = __webpack_require__( "./lib/Auth/ForgotPassword.js");
|
9890 |
|
9891 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
9892 |
|
9893 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
9894 |
|
9895 | var logger = new core_1.ConsoleLogger('SignIn');
|
9896 |
|
9897 | var SignIn =
|
9898 |
|
9899 | function (_super) {
|
9900 | __extends(SignIn, _super);
|
9901 |
|
9902 | function SignIn(props) {
|
9903 | var _this = _super.call(this, props) || this;
|
9904 |
|
9905 | _this.checkContact = _this.checkContact.bind(_this);
|
9906 | _this.signIn = _this.signIn.bind(_this);
|
9907 | _this._validAuthStates = ['signIn', 'signedOut', 'signedUp'];
|
9908 | _this.state = {};
|
9909 | return _this;
|
9910 | }
|
9911 |
|
9912 | SignIn.prototype.checkContact = function (user) {
|
9913 | var _this = this;
|
9914 |
|
9915 | if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
|
9916 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
9917 | }
|
9918 |
|
9919 | auth_1.Auth.verifiedContact(user).then(function (data) {
|
9920 | if (!core_1.isEmpty(data.verified)) {
|
9921 | _this.changeState('signedIn', user);
|
9922 | } else {
|
9923 | user = Object.assign(user, data);
|
9924 |
|
9925 | _this.changeState('verifyContact', user);
|
9926 | }
|
9927 | });
|
9928 | };
|
9929 |
|
9930 | SignIn.prototype.signIn = function (event) {
|
9931 | return __awaiter(this, void 0, void 0, function () {
|
9932 | var username, password, user, err_1;
|
9933 | return __generator(this, function (_a) {
|
9934 | switch (_a.label) {
|
9935 | case 0:
|
9936 |
|
9937 | if (event) {
|
9938 | event.preventDefault();
|
9939 | }
|
9940 |
|
9941 | username = this.getUsernameFromInput() || '';
|
9942 | password = this.inputs.password;
|
9943 |
|
9944 | if (!auth_1.Auth || typeof auth_1.Auth.signIn !== 'function') {
|
9945 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
9946 | }
|
9947 |
|
9948 | this.setState({
|
9949 | loading: true
|
9950 | });
|
9951 | _a.label = 1;
|
9952 |
|
9953 | case 1:
|
9954 | _a.trys.push([1, 3, 4, 5]);
|
9955 |
|
9956 | return [4
|
9957 |
|
9958 | , auth_1.Auth.signIn(username, password)];
|
9959 |
|
9960 | case 2:
|
9961 | user = _a.sent();
|
9962 | logger.debug(user);
|
9963 |
|
9964 | if (user.challengeName === 'SMS_MFA' || user.challengeName === 'SOFTWARE_TOKEN_MFA') {
|
9965 | logger.debug('confirm user with ' + user.challengeName);
|
9966 | this.changeState('confirmSignIn', user);
|
9967 | } else if (user.challengeName === 'NEW_PASSWORD_REQUIRED') {
|
9968 | logger.debug('require new password', user.challengeParam);
|
9969 | this.changeState('requireNewPassword', user);
|
9970 | } else if (user.challengeName === 'MFA_SETUP') {
|
9971 | logger.debug('TOTP setup', user.challengeParam);
|
9972 | this.changeState('TOTPSetup', user);
|
9973 | } else if (user.challengeName === 'CUSTOM_CHALLENGE' && user.challengeParam && user.challengeParam.trigger === 'true') {
|
9974 | logger.debug('custom challenge', user.challengeParam);
|
9975 | this.changeState('customConfirmSignIn', user);
|
9976 | } else {
|
9977 | this.checkContact(user);
|
9978 | }
|
9979 |
|
9980 | return [3
|
9981 |
|
9982 | , 5];
|
9983 |
|
9984 | case 3:
|
9985 | err_1 = _a.sent();
|
9986 |
|
9987 | if (err_1.code === 'UserNotConfirmedException') {
|
9988 | logger.debug('the user is not confirmed');
|
9989 | this.changeState('confirmSignUp', {
|
9990 | username: username
|
9991 | });
|
9992 | } else if (err_1.code === 'PasswordResetRequiredException') {
|
9993 | logger.debug('the user requires a new password');
|
9994 | this.changeState('forgotPassword', {
|
9995 | username: username
|
9996 | });
|
9997 | } else {
|
9998 | this.error(err_1);
|
9999 | }
|
10000 |
|
10001 | return [3
|
10002 |
|
10003 | , 5];
|
10004 |
|
10005 | case 4:
|
10006 | this.setState({
|
10007 | loading: false
|
10008 | });
|
10009 | return [7
|
10010 |
|
10011 | ];
|
10012 |
|
10013 | case 5:
|
10014 | return [2
|
10015 |
|
10016 | ];
|
10017 | }
|
10018 | });
|
10019 | });
|
10020 | };
|
10021 |
|
10022 | SignIn.prototype.showComponent = function (theme) {
|
10023 | var _this = this;
|
10024 |
|
10025 | var _a = this.props,
|
10026 | authState = _a.authState,
|
10027 | _b = _a.hide,
|
10028 | hide = _b === void 0 ? [] : _b,
|
10029 | federated = _a.federated,
|
10030 | onStateChange = _a.onStateChange,
|
10031 | onAuthEvent = _a.onAuthEvent,
|
10032 | _c = _a.override,
|
10033 | override = _c === void 0 ? [] : _c;
|
10034 |
|
10035 | if (hide && hide.includes(SignIn)) {
|
10036 | return null;
|
10037 | }
|
10038 |
|
10039 | var hideSignUp = !override.includes('SignUp') && hide.some(function (component) {
|
10040 | return component === SignUp_1.SignUp;
|
10041 | });
|
10042 | var hideForgotPassword = !override.includes('ForgotPassword') && hide.some(function (component) {
|
10043 | return component === ForgotPassword_1.ForgotPassword;
|
10044 | });
|
10045 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
10046 | theme: theme,
|
10047 | "data-test": data_test_attributes_1.auth.signIn.section
|
10048 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
10049 | theme: theme,
|
10050 | "data-test": data_test_attributes_1.auth.signIn.headerSection
|
10051 | }, core_1.I18n.get('Sign in to your account')), React.createElement(FederatedSignIn_1.FederatedButtons, {
|
10052 | federated: federated,
|
10053 | theme: theme,
|
10054 | authState: authState,
|
10055 | onStateChange: onStateChange,
|
10056 | onAuthEvent: onAuthEvent
|
10057 | }), React.createElement("form", {
|
10058 | onSubmit: this.signIn
|
10059 | }, React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
10060 | theme: theme
|
10061 | }, this.renderUsernameField(theme), React.createElement(Amplify_UI_Components_React_1.FormField, {
|
10062 | theme: theme
|
10063 | }, React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
10064 | theme: theme
|
10065 | }, core_1.I18n.get('Password'), " *"), React.createElement(Amplify_UI_Components_React_1.Input, {
|
10066 | placeholder: core_1.I18n.get('Enter your password'),
|
10067 | theme: theme,
|
10068 | key: "password",
|
10069 | type: "password",
|
10070 | name: "password",
|
10071 | onChange: this.handleInputChange,
|
10072 | "data-test": data_test_attributes_1.auth.signIn.passwordInput
|
10073 | }), !hideForgotPassword && React.createElement(Amplify_UI_Components_React_1.Hint, {
|
10074 | theme: theme
|
10075 | }, core_1.I18n.get('Forgot your password? '), React.createElement(Amplify_UI_Components_React_1.Link, {
|
10076 | theme: theme,
|
10077 | onClick: function onClick() {
|
10078 | return _this.changeState('forgotPassword');
|
10079 | },
|
10080 | "data-test": data_test_attributes_1.auth.signIn.forgotPasswordLink
|
10081 | }, core_1.I18n.get('Reset password'))))), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
10082 | theme: theme,
|
10083 | "data-test": data_test_attributes_1.auth.signIn.footerSection
|
10084 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
10085 | theme: theme
|
10086 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
10087 | theme: theme,
|
10088 | type: "submit",
|
10089 | disabled: this.state.loading,
|
10090 | "data-test": data_test_attributes_1.auth.signIn.signInButton
|
10091 | }, core_1.I18n.get('Sign In'))), !hideSignUp && React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
10092 | theme: theme
|
10093 | }, core_1.I18n.get('No account? '), React.createElement(Amplify_UI_Components_React_1.Link, {
|
10094 | theme: theme,
|
10095 | onClick: function onClick() {
|
10096 | return _this.changeState('signUp');
|
10097 | },
|
10098 | "data-test": data_test_attributes_1.auth.signIn.createAccountLink
|
10099 | }, core_1.I18n.get('Create account'))))));
|
10100 | };
|
10101 |
|
10102 | return SignIn;
|
10103 | }(AuthPiece_1.AuthPiece);
|
10104 |
|
10105 | exports.SignIn = SignIn;
|
10106 |
|
10107 |
|
10108 |
|
10109 |
|
10110 | exports["default"] = SignIn;
|
10111 |
|
10112 | }),
|
10113 |
|
10114 | "./lib/Auth/SignOut.js":
|
10115 |
|
10116 |
|
10117 |
|
10118 |
|
10119 | (function(module, exports, __webpack_require__) {
|
10120 |
|
10121 | "use strict";
|
10122 |
|
10123 |
|
10124 |
|
10125 |
|
10126 |
|
10127 |
|
10128 |
|
10129 |
|
10130 |
|
10131 |
|
10132 |
|
10133 |
|
10134 |
|
10135 |
|
10136 | var __extends = this && this.__extends || function () {
|
10137 | var _extendStatics = function extendStatics(d, b) {
|
10138 | _extendStatics = Object.setPrototypeOf || {
|
10139 | __proto__: []
|
10140 | } instanceof Array && function (d, b) {
|
10141 | d.__proto__ = b;
|
10142 | } || function (d, b) {
|
10143 | for (var p in b) {
|
10144 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
10145 | }
|
10146 | };
|
10147 |
|
10148 | return _extendStatics(d, b);
|
10149 | };
|
10150 |
|
10151 | return function (d, b) {
|
10152 | _extendStatics(d, b);
|
10153 |
|
10154 | function __() {
|
10155 | this.constructor = d;
|
10156 | }
|
10157 |
|
10158 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10159 | };
|
10160 | }();
|
10161 |
|
10162 | var __importStar = this && this.__importStar || function (mod) {
|
10163 | if (mod && mod.__esModule) return mod;
|
10164 | var result = {};
|
10165 | if (mod != null) for (var k in mod) {
|
10166 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
10167 | }
|
10168 | result["default"] = mod;
|
10169 | return result;
|
10170 | };
|
10171 |
|
10172 | var __importDefault = this && this.__importDefault || function (mod) {
|
10173 | return mod && mod.__esModule ? mod : {
|
10174 | "default": mod
|
10175 | };
|
10176 | };
|
10177 |
|
10178 | Object.defineProperty(exports, "__esModule", {
|
10179 | value: true
|
10180 | });
|
10181 |
|
10182 | var React = __importStar(__webpack_require__( "react"));
|
10183 |
|
10184 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
10185 |
|
10186 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
10187 |
|
10188 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
10189 |
|
10190 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
10191 |
|
10192 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
10193 |
|
10194 | var constants_1 = __webpack_require__( "./lib/Auth/common/constants.js");
|
10195 |
|
10196 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
10197 |
|
10198 | var logger = new core_1.ConsoleLogger('SignOut');
|
10199 |
|
10200 | var SignOut =
|
10201 |
|
10202 | function (_super) {
|
10203 | __extends(SignOut, _super);
|
10204 |
|
10205 | function SignOut(props) {
|
10206 | var _this = _super.call(this, props) || this;
|
10207 |
|
10208 | _this.signOut = _this.signOut.bind(_this);
|
10209 | _this.onHubCapsule = _this.onHubCapsule.bind(_this);
|
10210 | core_1.Hub.listen('auth', _this.onHubCapsule);
|
10211 | _this.state = {};
|
10212 | return _this;
|
10213 | }
|
10214 |
|
10215 | SignOut.prototype.componentDidMount = function () {
|
10216 | this._isMounted = true;
|
10217 | this.findState();
|
10218 | };
|
10219 |
|
10220 | SignOut.prototype.componentWillUnmount = function () {
|
10221 | this._isMounted = false;
|
10222 | };
|
10223 |
|
10224 | SignOut.prototype.findState = function () {
|
10225 | var _this = this;
|
10226 |
|
10227 | if (!this.props.authState && !this.props.authData) {
|
10228 | auth_1.Auth.currentAuthenticatedUser().then(function (user) {
|
10229 | _this.setState({
|
10230 | authState: 'signedIn',
|
10231 | authData: user,
|
10232 | stateFromStorage: true
|
10233 | });
|
10234 | })["catch"](function (err) {
|
10235 | return logger.error(err);
|
10236 | });
|
10237 | } else if (this.props.stateFromStorage) {
|
10238 | this.setState({
|
10239 | stateFromStorage: true
|
10240 | });
|
10241 | }
|
10242 | };
|
10243 |
|
10244 | SignOut.prototype.onHubCapsule = function (capsule) {
|
10245 | if (this._isMounted) {
|
10246 | var channel = capsule.channel,
|
10247 | payload = capsule.payload,
|
10248 | source = capsule.source;
|
10249 |
|
10250 | if (channel === 'auth' && payload.event === 'signIn') {
|
10251 | this.setState({
|
10252 | authState: 'signedIn',
|
10253 | authData: payload.data
|
10254 | });
|
10255 | } else if (channel === 'auth' && payload.event === 'signOut' && !this.props.authState) {
|
10256 | this.setState({
|
10257 | authState: 'signIn'
|
10258 | });
|
10259 | }
|
10260 |
|
10261 | if (channel === 'auth' && payload.event === 'signIn' && !this.props.authState) {
|
10262 | this.setState({
|
10263 | stateFromStorage: true
|
10264 | });
|
10265 | }
|
10266 | }
|
10267 | };
|
10268 |
|
10269 | SignOut.prototype.signOut = function () {
|
10270 | var _this = this;
|
10271 |
|
10272 | var payload = {};
|
10273 |
|
10274 | try {
|
10275 | payload = JSON.parse(localStorage.getItem(constants_1.Constants.AUTH_SOURCE_KEY)) || {};
|
10276 | localStorage.removeItem(constants_1.Constants.AUTH_SOURCE_KEY);
|
10277 | } catch (e) {
|
10278 | logger.debug("Failed to parse the info from " + constants_1.Constants.AUTH_SOURCE_KEY + " from localStorage with " + e);
|
10279 | }
|
10280 |
|
10281 | logger.debug('sign out from the source', payload);
|
10282 | var _a = this.props,
|
10283 | googleSignOut = _a.googleSignOut,
|
10284 | facebookSignOut = _a.facebookSignOut,
|
10285 | amazonSignOut = _a.amazonSignOut,
|
10286 | auth0SignOut = _a.auth0SignOut;
|
10287 |
|
10288 | switch (payload.provider) {
|
10289 | case constants_1.Constants.GOOGLE:
|
10290 | if (googleSignOut) googleSignOut();else logger.debug('No Google signout method provided');
|
10291 | break;
|
10292 |
|
10293 | case constants_1.Constants.FACEBOOK:
|
10294 | if (facebookSignOut) facebookSignOut();else logger.debug('No Facebook signout method provided');
|
10295 | break;
|
10296 |
|
10297 | case constants_1.Constants.AMAZON:
|
10298 | if (amazonSignOut) amazonSignOut();else logger.debug('No Amazon signout method provided');
|
10299 | break;
|
10300 |
|
10301 | case constants_1.Constants.AUTH0:
|
10302 |
|
10303 | if (auth0SignOut) auth0SignOut(payload.opts);else logger.debug('No Auth0 signout method provided');
|
10304 | break;
|
10305 |
|
10306 | default:
|
10307 | break;
|
10308 | }
|
10309 |
|
10310 | if (!auth_1.Auth || typeof auth_1.Auth.signOut !== 'function') {
|
10311 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
10312 | }
|
10313 |
|
10314 | auth_1.Auth.signOut().then(function () {
|
10315 | if (!_this.state.stateFromStorage) {
|
10316 | _this.changeState('signedOut');
|
10317 | }
|
10318 | })["catch"](function (err) {
|
10319 | logger.debug(err);
|
10320 |
|
10321 | _this.error(err);
|
10322 | });
|
10323 | };
|
10324 |
|
10325 | SignOut.prototype.render = function () {
|
10326 | var hide = this.props.hide;
|
10327 |
|
10328 | if (hide && hide.includes(SignOut)) {
|
10329 | return null;
|
10330 | }
|
10331 |
|
10332 | var authState = this.props.authState || this.state.authState;
|
10333 | var signedIn = authState === 'signedIn';
|
10334 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
10335 |
|
10336 | if (!signedIn) {
|
10337 | return null;
|
10338 | }
|
10339 |
|
10340 | return React.createElement(Amplify_UI_Components_React_1.NavButton, {
|
10341 | theme: theme,
|
10342 | onClick: this.signOut,
|
10343 | "data-test": data_test_attributes_1.auth.signOut.button
|
10344 | }, core_1.I18n.get('Sign Out'));
|
10345 | };
|
10346 |
|
10347 | return SignOut;
|
10348 | }(AuthPiece_1.AuthPiece);
|
10349 |
|
10350 | exports.SignOut = SignOut;
|
10351 |
|
10352 |
|
10353 |
|
10354 |
|
10355 | exports["default"] = SignOut;
|
10356 |
|
10357 | }),
|
10358 |
|
10359 | "./lib/Auth/SignUp.js":
|
10360 |
|
10361 |
|
10362 |
|
10363 |
|
10364 | (function(module, exports, __webpack_require__) {
|
10365 |
|
10366 | "use strict";
|
10367 |
|
10368 |
|
10369 |
|
10370 |
|
10371 |
|
10372 |
|
10373 |
|
10374 |
|
10375 |
|
10376 |
|
10377 |
|
10378 |
|
10379 |
|
10380 |
|
10381 | var __extends = this && this.__extends || function () {
|
10382 | var _extendStatics = function extendStatics(d, b) {
|
10383 | _extendStatics = Object.setPrototypeOf || {
|
10384 | __proto__: []
|
10385 | } instanceof Array && function (d, b) {
|
10386 | d.__proto__ = b;
|
10387 | } || function (d, b) {
|
10388 | for (var p in b) {
|
10389 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
10390 | }
|
10391 | };
|
10392 |
|
10393 | return _extendStatics(d, b);
|
10394 | };
|
10395 |
|
10396 | return function (d, b) {
|
10397 | _extendStatics(d, b);
|
10398 |
|
10399 | function __() {
|
10400 | this.constructor = d;
|
10401 | }
|
10402 |
|
10403 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10404 | };
|
10405 | }();
|
10406 |
|
10407 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
10408 | function adopt(value) {
|
10409 | return value instanceof P ? value : new P(function (resolve) {
|
10410 | resolve(value);
|
10411 | });
|
10412 | }
|
10413 |
|
10414 | return new (P || (P = Promise))(function (resolve, reject) {
|
10415 | function fulfilled(value) {
|
10416 | try {
|
10417 | step(generator.next(value));
|
10418 | } catch (e) {
|
10419 | reject(e);
|
10420 | }
|
10421 | }
|
10422 |
|
10423 | function rejected(value) {
|
10424 | try {
|
10425 | step(generator["throw"](value));
|
10426 | } catch (e) {
|
10427 | reject(e);
|
10428 | }
|
10429 | }
|
10430 |
|
10431 | function step(result) {
|
10432 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
10433 | }
|
10434 |
|
10435 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10436 | });
|
10437 | };
|
10438 |
|
10439 | var __generator = this && this.__generator || function (thisArg, body) {
|
10440 | var _ = {
|
10441 | label: 0,
|
10442 | sent: function sent() {
|
10443 | if (t[0] & 1) throw t[1];
|
10444 | return t[1];
|
10445 | },
|
10446 | trys: [],
|
10447 | ops: []
|
10448 | },
|
10449 | f,
|
10450 | y,
|
10451 | t,
|
10452 | g;
|
10453 | return g = {
|
10454 | next: verb(0),
|
10455 | "throw": verb(1),
|
10456 | "return": verb(2)
|
10457 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
10458 | return this;
|
10459 | }), g;
|
10460 |
|
10461 | function verb(n) {
|
10462 | return function (v) {
|
10463 | return step([n, v]);
|
10464 | };
|
10465 | }
|
10466 |
|
10467 | function step(op) {
|
10468 | if (f) throw new TypeError("Generator is already executing.");
|
10469 |
|
10470 | while (_) {
|
10471 | try {
|
10472 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
10473 | if (y = 0, t) op = [op[0] & 2, t.value];
|
10474 |
|
10475 | switch (op[0]) {
|
10476 | case 0:
|
10477 | case 1:
|
10478 | t = op;
|
10479 | break;
|
10480 |
|
10481 | case 4:
|
10482 | _.label++;
|
10483 | return {
|
10484 | value: op[1],
|
10485 | done: false
|
10486 | };
|
10487 |
|
10488 | case 5:
|
10489 | _.label++;
|
10490 | y = op[1];
|
10491 | op = [0];
|
10492 | continue;
|
10493 |
|
10494 | case 7:
|
10495 | op = _.ops.pop();
|
10496 |
|
10497 | _.trys.pop();
|
10498 |
|
10499 | continue;
|
10500 |
|
10501 | default:
|
10502 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
10503 | _ = 0;
|
10504 | continue;
|
10505 | }
|
10506 |
|
10507 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
10508 | _.label = op[1];
|
10509 | break;
|
10510 | }
|
10511 |
|
10512 | if (op[0] === 6 && _.label < t[1]) {
|
10513 | _.label = t[1];
|
10514 | t = op;
|
10515 | break;
|
10516 | }
|
10517 |
|
10518 | if (t && _.label < t[2]) {
|
10519 | _.label = t[2];
|
10520 |
|
10521 | _.ops.push(op);
|
10522 |
|
10523 | break;
|
10524 | }
|
10525 |
|
10526 | if (t[2]) _.ops.pop();
|
10527 |
|
10528 | _.trys.pop();
|
10529 |
|
10530 | continue;
|
10531 | }
|
10532 |
|
10533 | op = body.call(thisArg, _);
|
10534 | } catch (e) {
|
10535 | op = [6, e];
|
10536 | y = 0;
|
10537 | } finally {
|
10538 | f = t = 0;
|
10539 | }
|
10540 | }
|
10541 |
|
10542 | if (op[0] & 5) throw op[1];
|
10543 | return {
|
10544 | value: op[0] ? op[1] : void 0,
|
10545 | done: true
|
10546 | };
|
10547 | }
|
10548 | };
|
10549 |
|
10550 | var __importStar = this && this.__importStar || function (mod) {
|
10551 | if (mod && mod.__esModule) return mod;
|
10552 | var result = {};
|
10553 | if (mod != null) for (var k in mod) {
|
10554 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
10555 | }
|
10556 | result["default"] = mod;
|
10557 | return result;
|
10558 | };
|
10559 |
|
10560 | Object.defineProperty(exports, "__esModule", {
|
10561 | value: true
|
10562 | });
|
10563 |
|
10564 | var React = __importStar(__webpack_require__( "react"));
|
10565 |
|
10566 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
10567 |
|
10568 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
10569 |
|
10570 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
10571 |
|
10572 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
10573 |
|
10574 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
10575 |
|
10576 | var country_dial_codes_1 = __webpack_require__( "./lib/Auth/common/country-dial-codes.js");
|
10577 |
|
10578 | var default_sign_up_fields_1 = __webpack_require__( "./lib/Auth/common/default-sign-up-fields.js");
|
10579 |
|
10580 | var types_1 = __webpack_require__( "./lib/Auth/common/types.js");
|
10581 |
|
10582 | var PhoneField_1 = __webpack_require__( "./lib/Auth/PhoneField.js");
|
10583 |
|
10584 | var logger = new core_1.ConsoleLogger('SignUp');
|
10585 |
|
10586 | var SignUp =
|
10587 |
|
10588 | function (_super) {
|
10589 | __extends(SignUp, _super);
|
10590 |
|
10591 | function SignUp(props) {
|
10592 | var _this = _super.call(this, props) || this;
|
10593 |
|
10594 | _this.state = {
|
10595 | requestPending: false
|
10596 | };
|
10597 | _this._validAuthStates = ['signUp'];
|
10598 | _this.signUp = _this.signUp.bind(_this);
|
10599 | _this.sortFields = _this.sortFields.bind(_this);
|
10600 | _this.getDefaultDialCode = _this.getDefaultDialCode.bind(_this);
|
10601 | _this.checkCustomSignUpFields = _this.checkCustomSignUpFields.bind(_this);
|
10602 | _this.needPrefix = _this.needPrefix.bind(_this);
|
10603 | _this.header = _this.props && _this.props.signUpConfig && _this.props.signUpConfig.header ? _this.props.signUpConfig.header : 'Create a new account';
|
10604 | var _a = (_this.props || {}).usernameAttributes,
|
10605 | usernameAttributes = _a === void 0 ? types_1.UsernameAttributes.USERNAME : _a;
|
10606 |
|
10607 | if (usernameAttributes === types_1.UsernameAttributes.EMAIL) {
|
10608 | _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithEmailFields;
|
10609 | } else if (usernameAttributes === types_1.UsernameAttributes.PHONE_NUMBER) {
|
10610 | _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithPhoneNumberFields;
|
10611 | } else {
|
10612 | _this.defaultSignUpFields = default_sign_up_fields_1.signUpWithUsernameFields;
|
10613 | }
|
10614 |
|
10615 | return _this;
|
10616 | }
|
10617 |
|
10618 | SignUp.prototype.validate = function () {
|
10619 | var _this = this;
|
10620 |
|
10621 | var invalids = [];
|
10622 | this.signUpFields.map(function (el) {
|
10623 | if (el.key !== 'phone_number') {
|
10624 | if (el.required && !_this.inputs[el.key]) {
|
10625 | el.invalid = true;
|
10626 | invalids.push(el.label);
|
10627 | } else {
|
10628 | el.invalid = false;
|
10629 | }
|
10630 | } else {
|
10631 | if (el.required && !_this.phone_number) {
|
10632 | el.invalid = true;
|
10633 | invalids.push(el.label);
|
10634 | } else {
|
10635 | el.invalid = false;
|
10636 | }
|
10637 | }
|
10638 | });
|
10639 | return invalids;
|
10640 | };
|
10641 |
|
10642 | SignUp.prototype.sortFields = function () {
|
10643 | var _this = this;
|
10644 |
|
10645 | if (this.props.signUpConfig && this.props.signUpConfig.hiddenDefaults && this.props.signUpConfig.hiddenDefaults.length > 0) {
|
10646 | this.defaultSignUpFields = this.defaultSignUpFields.filter(function (d) {
|
10647 | return !_this.props.signUpConfig.hiddenDefaults.includes(d.key);
|
10648 | });
|
10649 | }
|
10650 |
|
10651 | if (this.checkCustomSignUpFields()) {
|
10652 | if (!this.props.signUpConfig || !this.props.signUpConfig.hideAllDefaults) {
|
10653 |
|
10654 | this.defaultSignUpFields.forEach(function (f) {
|
10655 | var matchKey = _this.signUpFields.findIndex(function (d) {
|
10656 | return d.key === f.key;
|
10657 | });
|
10658 |
|
10659 | if (matchKey === -1) {
|
10660 | _this.signUpFields.push(f);
|
10661 | }
|
10662 | });
|
10663 | }
|
10664 | |
10665 |
|
10666 |
|
10667 |
|
10668 |
|
10669 |
|
10670 |
|
10671 |
|
10672 | this.signUpFields.sort(function (a, b) {
|
10673 | if (a.displayOrder && b.displayOrder) {
|
10674 | if (a.displayOrder < b.displayOrder) {
|
10675 | return -1;
|
10676 | } else if (a.displayOrder > b.displayOrder) {
|
10677 | return 1;
|
10678 | } else {
|
10679 | if (a.key < b.key) {
|
10680 | return -1;
|
10681 | } else {
|
10682 | return 1;
|
10683 | }
|
10684 | }
|
10685 | } else if (!a.displayOrder && b.displayOrder) {
|
10686 | return 1;
|
10687 | } else if (a.displayOrder && !b.displayOrder) {
|
10688 | return -1;
|
10689 | } else if (!a.displayOrder && !b.displayOrder) {
|
10690 | if (a.key < b.key) {
|
10691 | return -1;
|
10692 | } else {
|
10693 | return 1;
|
10694 | }
|
10695 | }
|
10696 | });
|
10697 | } else {
|
10698 | this.signUpFields = this.defaultSignUpFields;
|
10699 | }
|
10700 | };
|
10701 |
|
10702 | SignUp.prototype.needPrefix = function (key) {
|
10703 | var field = this.signUpFields.find(function (e) {
|
10704 | return e.key === key;
|
10705 | });
|
10706 |
|
10707 | if (key.indexOf('custom:') !== 0) {
|
10708 | return field.custom;
|
10709 | } else if (key.indexOf('custom:') === 0 && field.custom === false) {
|
10710 | logger.warn('Custom prefix prepended to key but custom field flag is set to false; retaining manually entered prefix');
|
10711 | }
|
10712 |
|
10713 | return null;
|
10714 | };
|
10715 |
|
10716 | SignUp.prototype.getDefaultDialCode = function () {
|
10717 | return this.props.signUpConfig && this.props.signUpConfig.defaultCountryCode && country_dial_codes_1.countryDialCodes.indexOf("+" + this.props.signUpConfig.defaultCountryCode) !== -1 ? "+" + this.props.signUpConfig.defaultCountryCode : '+1';
|
10718 | };
|
10719 |
|
10720 | SignUp.prototype.checkCustomSignUpFields = function () {
|
10721 | return this.props.signUpConfig && this.props.signUpConfig.signUpFields && this.props.signUpConfig.signUpFields.length > 0;
|
10722 | };
|
10723 |
|
10724 | SignUp.prototype.signUp = function () {
|
10725 | return __awaiter(this, void 0, void 0, function () {
|
10726 | var validation, signup_info, inputKeys, inputVals, labelCheck, data, err_1;
|
10727 |
|
10728 | var _this = this;
|
10729 |
|
10730 | return __generator(this, function (_a) {
|
10731 | switch (_a.label) {
|
10732 | case 0:
|
10733 | this.setState({
|
10734 | requestPending: true
|
10735 | });
|
10736 |
|
10737 | if (!this.inputs.dial_code) {
|
10738 | this.inputs.dial_code = this.getDefaultDialCode();
|
10739 | }
|
10740 |
|
10741 | validation = this.validate();
|
10742 |
|
10743 | if (validation && validation.length > 0) {
|
10744 | this.setState({
|
10745 | requestPending: false
|
10746 | });
|
10747 | return [2
|
10748 |
|
10749 | , this.error("The following fields need to be filled out: " + validation.join(', '))];
|
10750 | }
|
10751 |
|
10752 | if (!auth_1.Auth || typeof auth_1.Auth.signUp !== 'function') {
|
10753 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
10754 | }
|
10755 |
|
10756 | signup_info = {
|
10757 | username: this.inputs.username,
|
10758 | password: this.inputs.password,
|
10759 | attributes: {}
|
10760 | };
|
10761 | inputKeys = Object.keys(this.inputs);
|
10762 | inputVals = Object.values(this.inputs);
|
10763 | inputKeys.forEach(function (key, index) {
|
10764 | if (!['username', 'password', 'checkedValue', 'dial_code'].includes(key)) {
|
10765 | if (key !== 'phone_line_number' && key !== 'dial_code' && key !== 'error') {
|
10766 | var newKey = "" + (_this.needPrefix(key) ? 'custom:' : '') + key;
|
10767 | signup_info.attributes[newKey] = inputVals[index];
|
10768 | }
|
10769 | }
|
10770 | });
|
10771 | if (this.phone_number) signup_info.attributes['phone_number'] = this.phone_number;
|
10772 | labelCheck = false;
|
10773 | this.signUpFields.forEach(function (field) {
|
10774 | if (field.label === _this.getUsernameLabel()) {
|
10775 | logger.debug("Changing the username to the value of " + field.label);
|
10776 | signup_info.username = signup_info.attributes[field.key] || signup_info.username;
|
10777 | labelCheck = true;
|
10778 | }
|
10779 | });
|
10780 |
|
10781 | if (!labelCheck && !signup_info.username) {
|
10782 |
|
10783 |
|
10784 |
|
10785 | throw new Error("Couldn't find the label: " + this.getUsernameLabel() + ", in sign up fields according to usernameAttributes!");
|
10786 | }
|
10787 |
|
10788 | _a.label = 1;
|
10789 |
|
10790 | case 1:
|
10791 | _a.trys.push([1, 3, 4, 5]);
|
10792 |
|
10793 | return [4
|
10794 |
|
10795 | , auth_1.Auth.signUp(signup_info)];
|
10796 |
|
10797 | case 2:
|
10798 | data = _a.sent();
|
10799 |
|
10800 | this.changeState('confirmSignUp', data.user.username);
|
10801 | return [3
|
10802 |
|
10803 | , 5];
|
10804 |
|
10805 | case 3:
|
10806 | err_1 = _a.sent();
|
10807 | this.error(err_1);
|
10808 | return [3
|
10809 |
|
10810 | , 5];
|
10811 |
|
10812 | case 4:
|
10813 | this.setState({
|
10814 | requestPending: false
|
10815 | });
|
10816 | return [7
|
10817 |
|
10818 | ];
|
10819 |
|
10820 | case 5:
|
10821 | return [2
|
10822 |
|
10823 | ];
|
10824 | }
|
10825 | });
|
10826 | });
|
10827 | };
|
10828 |
|
10829 | SignUp.prototype.showComponent = function (theme) {
|
10830 | var _this = this;
|
10831 |
|
10832 | var hide = this.props.hide;
|
10833 |
|
10834 | if (hide && hide.includes(SignUp)) {
|
10835 | return null;
|
10836 | }
|
10837 |
|
10838 | if (this.checkCustomSignUpFields()) {
|
10839 | this.signUpFields = this.props.signUpConfig.signUpFields;
|
10840 | }
|
10841 |
|
10842 | this.sortFields();
|
10843 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
10844 | theme: theme,
|
10845 | "data-test": data_test_attributes_1.auth.signUp.section
|
10846 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
10847 | theme: theme,
|
10848 | "data-test": data_test_attributes_1.auth.signUp.headerSection
|
10849 | }, core_1.I18n.get(this.header)), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
10850 | theme: theme,
|
10851 | "data-test": data_test_attributes_1.auth.signUp.bodySection
|
10852 | }, this.signUpFields.map(function (field) {
|
10853 | return field.key !== 'phone_number' ? React.createElement(Amplify_UI_Components_React_1.FormField, {
|
10854 | theme: theme,
|
10855 | key: field.key
|
10856 | }, field.required ? React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
10857 | theme: theme
|
10858 | }, core_1.I18n.get(field.label), " *") : React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
10859 | theme: theme
|
10860 | }, core_1.I18n.get(field.label)), React.createElement(Amplify_UI_Components_React_1.Input, {
|
10861 | autoFocus: _this.signUpFields.findIndex(function (f) {
|
10862 | return f.key === field.key;
|
10863 | }) === 0,
|
10864 | placeholder: core_1.I18n.get(field.placeholder),
|
10865 | theme: theme,
|
10866 | type: field.type,
|
10867 | name: field.key,
|
10868 | key: field.key,
|
10869 | onChange: _this.handleInputChange,
|
10870 | "data-test": data_test_attributes_1.auth.signUp.nonPhoneNumberInput
|
10871 | })) : React.createElement(PhoneField_1.PhoneField, {
|
10872 | theme: theme,
|
10873 | required: field.required,
|
10874 | defaultDialCode: _this.getDefaultDialCode(),
|
10875 | label: field.label,
|
10876 | placeholder: field.placeholder,
|
10877 | onChangeText: _this.onPhoneNumberChanged,
|
10878 | key: "phone_number"
|
10879 | });
|
10880 | })), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
10881 | theme: theme,
|
10882 | "data-test": data_test_attributes_1.auth.signUp.footerSection
|
10883 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
10884 | theme: theme
|
10885 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
10886 | disabled: this.state.requestPending,
|
10887 | onClick: this.signUp,
|
10888 | theme: theme,
|
10889 | "data-test": data_test_attributes_1.auth.signUp.createAccountButton
|
10890 | }, core_1.I18n.get('Create Account'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
10891 | theme: theme
|
10892 | }, core_1.I18n.get('Have an account? '), React.createElement(Amplify_UI_Components_React_1.Link, {
|
10893 | theme: theme,
|
10894 | onClick: function onClick() {
|
10895 | return _this.changeState('signIn');
|
10896 | },
|
10897 | "data-test": data_test_attributes_1.auth.signUp.signInLink
|
10898 | }, core_1.I18n.get('Sign in')))));
|
10899 | };
|
10900 |
|
10901 | return SignUp;
|
10902 | }(AuthPiece_1.AuthPiece);
|
10903 |
|
10904 | exports.SignUp = SignUp;
|
10905 |
|
10906 |
|
10907 |
|
10908 |
|
10909 | exports["default"] = SignUp;
|
10910 |
|
10911 | }),
|
10912 |
|
10913 | "./lib/Auth/TOTPSetup.js":
|
10914 |
|
10915 |
|
10916 |
|
10917 |
|
10918 | (function(module, exports, __webpack_require__) {
|
10919 |
|
10920 | "use strict";
|
10921 |
|
10922 |
|
10923 |
|
10924 |
|
10925 |
|
10926 |
|
10927 |
|
10928 |
|
10929 |
|
10930 |
|
10931 |
|
10932 |
|
10933 |
|
10934 |
|
10935 | var __extends = this && this.__extends || function () {
|
10936 | var _extendStatics = function extendStatics(d, b) {
|
10937 | _extendStatics = Object.setPrototypeOf || {
|
10938 | __proto__: []
|
10939 | } instanceof Array && function (d, b) {
|
10940 | d.__proto__ = b;
|
10941 | } || function (d, b) {
|
10942 | for (var p in b) {
|
10943 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
10944 | }
|
10945 | };
|
10946 |
|
10947 | return _extendStatics(d, b);
|
10948 | };
|
10949 |
|
10950 | return function (d, b) {
|
10951 | _extendStatics(d, b);
|
10952 |
|
10953 | function __() {
|
10954 | this.constructor = d;
|
10955 | }
|
10956 |
|
10957 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
10958 | };
|
10959 | }();
|
10960 |
|
10961 | var __assign = this && this.__assign || function () {
|
10962 | __assign = Object.assign || function (t) {
|
10963 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
10964 | s = arguments[i];
|
10965 |
|
10966 | for (var p in s) {
|
10967 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
10968 | }
|
10969 | }
|
10970 |
|
10971 | return t;
|
10972 | };
|
10973 |
|
10974 | return __assign.apply(this, arguments);
|
10975 | };
|
10976 |
|
10977 | var __importStar = this && this.__importStar || function (mod) {
|
10978 | if (mod && mod.__esModule) return mod;
|
10979 | var result = {};
|
10980 | if (mod != null) for (var k in mod) {
|
10981 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
10982 | }
|
10983 | result["default"] = mod;
|
10984 | return result;
|
10985 | };
|
10986 |
|
10987 | Object.defineProperty(exports, "__esModule", {
|
10988 | value: true
|
10989 | });
|
10990 |
|
10991 | var React = __importStar(__webpack_require__( "react"));
|
10992 |
|
10993 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
10994 |
|
10995 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
10996 |
|
10997 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
10998 |
|
10999 | var TOTPSetupComp_1 = __webpack_require__( "./lib/Widget/TOTPSetupComp.js");
|
11000 |
|
11001 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
11002 |
|
11003 | var logger = new core_1.ConsoleLogger('TOTPSetup');
|
11004 |
|
11005 | var TOTPSetup =
|
11006 |
|
11007 | function (_super) {
|
11008 | __extends(TOTPSetup, _super);
|
11009 |
|
11010 | function TOTPSetup(props) {
|
11011 | var _this = _super.call(this, props) || this;
|
11012 |
|
11013 | _this._validAuthStates = ['TOTPSetup'];
|
11014 | _this.onTOTPEvent = _this.onTOTPEvent.bind(_this);
|
11015 | _this.checkContact = _this.checkContact.bind(_this);
|
11016 | return _this;
|
11017 | }
|
11018 |
|
11019 | TOTPSetup.prototype.checkContact = function (user) {
|
11020 | var _this = this;
|
11021 |
|
11022 | if (!auth_1.Auth || typeof auth_1.Auth.verifiedContact !== 'function') {
|
11023 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
11024 | }
|
11025 |
|
11026 | auth_1.Auth.verifiedContact(user).then(function (data) {
|
11027 | if (!core_1.isEmpty(data.verified)) {
|
11028 | _this.changeState('signedIn', user);
|
11029 | } else {
|
11030 | var newUser = Object.assign(user, data);
|
11031 |
|
11032 | _this.changeState('verifyContact', newUser);
|
11033 | }
|
11034 | });
|
11035 | };
|
11036 |
|
11037 | TOTPSetup.prototype.onTOTPEvent = function (event, data, user) {
|
11038 | logger.debug('on totp event', event, data);
|
11039 |
|
11040 | if (event === 'Setup TOTP') {
|
11041 | if (data === 'SUCCESS') {
|
11042 | this.checkContact(user);
|
11043 | }
|
11044 | }
|
11045 | };
|
11046 |
|
11047 | TOTPSetup.prototype.showComponent = function (theme) {
|
11048 | var hide = this.props.hide;
|
11049 |
|
11050 | if (hide && hide.includes(TOTPSetup)) {
|
11051 | return null;
|
11052 | }
|
11053 |
|
11054 | return React.createElement(TOTPSetupComp_1.TOTPSetupComp, __assign({}, this.props, {
|
11055 | onTOTPEvent: this.onTOTPEvent,
|
11056 | "data-test": data_test_attributes_1.auth.TOTPSetup.component
|
11057 | }));
|
11058 | };
|
11059 |
|
11060 | return TOTPSetup;
|
11061 | }(AuthPiece_1.AuthPiece);
|
11062 |
|
11063 | exports.TOTPSetup = TOTPSetup;
|
11064 |
|
11065 |
|
11066 |
|
11067 |
|
11068 | exports["default"] = TOTPSetup;
|
11069 |
|
11070 | }),
|
11071 |
|
11072 | "./lib/Auth/VerifyContact.js":
|
11073 |
|
11074 |
|
11075 |
|
11076 |
|
11077 | (function(module, exports, __webpack_require__) {
|
11078 |
|
11079 | "use strict";
|
11080 |
|
11081 |
|
11082 |
|
11083 |
|
11084 |
|
11085 |
|
11086 |
|
11087 |
|
11088 |
|
11089 |
|
11090 |
|
11091 |
|
11092 |
|
11093 |
|
11094 | var __extends = this && this.__extends || function () {
|
11095 | var _extendStatics = function extendStatics(d, b) {
|
11096 | _extendStatics = Object.setPrototypeOf || {
|
11097 | __proto__: []
|
11098 | } instanceof Array && function (d, b) {
|
11099 | d.__proto__ = b;
|
11100 | } || function (d, b) {
|
11101 | for (var p in b) {
|
11102 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
11103 | }
|
11104 | };
|
11105 |
|
11106 | return _extendStatics(d, b);
|
11107 | };
|
11108 |
|
11109 | return function (d, b) {
|
11110 | _extendStatics(d, b);
|
11111 |
|
11112 | function __() {
|
11113 | this.constructor = d;
|
11114 | }
|
11115 |
|
11116 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
11117 | };
|
11118 | }();
|
11119 |
|
11120 | var __importStar = this && this.__importStar || function (mod) {
|
11121 | if (mod && mod.__esModule) return mod;
|
11122 | var result = {};
|
11123 | if (mod != null) for (var k in mod) {
|
11124 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
11125 | }
|
11126 | result["default"] = mod;
|
11127 | return result;
|
11128 | };
|
11129 |
|
11130 | var __importDefault = this && this.__importDefault || function (mod) {
|
11131 | return mod && mod.__esModule ? mod : {
|
11132 | "default": mod
|
11133 | };
|
11134 | };
|
11135 |
|
11136 | Object.defineProperty(exports, "__esModule", {
|
11137 | value: true
|
11138 | });
|
11139 |
|
11140 | var React = __importStar(__webpack_require__( "react"));
|
11141 |
|
11142 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
11143 |
|
11144 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
11145 |
|
11146 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
11147 |
|
11148 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
11149 |
|
11150 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
11151 |
|
11152 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
11153 |
|
11154 | var logger = new core_1.ConsoleLogger('VerifyContact');
|
11155 |
|
11156 | var VerifyContact =
|
11157 |
|
11158 | function (_super) {
|
11159 | __extends(VerifyContact, _super);
|
11160 |
|
11161 | function VerifyContact(props) {
|
11162 | var _this = _super.call(this, props) || this;
|
11163 |
|
11164 | _this._validAuthStates = ['verifyContact'];
|
11165 | _this.verify = _this.verify.bind(_this);
|
11166 | _this.submit = _this.submit.bind(_this);
|
11167 | _this.state = {
|
11168 | verifyAttr: null
|
11169 | };
|
11170 | return _this;
|
11171 | }
|
11172 |
|
11173 | VerifyContact.prototype.verify = function () {
|
11174 | var _this = this;
|
11175 |
|
11176 | var _a = this.inputs,
|
11177 | contact = _a.contact,
|
11178 | checkedValue = _a.checkedValue;
|
11179 |
|
11180 | if (!contact) {
|
11181 | this.error('Neither Email nor Phone Number selected');
|
11182 | return;
|
11183 | }
|
11184 |
|
11185 | if (!auth_1.Auth || typeof auth_1.Auth.verifyCurrentUserAttribute !== 'function') {
|
11186 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
11187 | }
|
11188 |
|
11189 | auth_1.Auth.verifyCurrentUserAttribute(checkedValue).then(function (data) {
|
11190 | logger.debug(data);
|
11191 |
|
11192 | _this.setState({
|
11193 | verifyAttr: checkedValue
|
11194 | });
|
11195 | })["catch"](function (err) {
|
11196 | return _this.error(err);
|
11197 | });
|
11198 | };
|
11199 |
|
11200 | VerifyContact.prototype.submit = function () {
|
11201 | var _this = this;
|
11202 |
|
11203 | var attr = this.state.verifyAttr;
|
11204 | var code = this.inputs.code;
|
11205 |
|
11206 | if (!auth_1.Auth || typeof auth_1.Auth.verifyCurrentUserAttributeSubmit !== 'function') {
|
11207 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
11208 | }
|
11209 |
|
11210 | auth_1.Auth.verifyCurrentUserAttributeSubmit(attr, code).then(function (data) {
|
11211 | logger.debug(data);
|
11212 |
|
11213 | _this.changeState('signedIn', _this.props.authData);
|
11214 |
|
11215 | _this.setState({
|
11216 | verifyAttr: null
|
11217 | });
|
11218 | })["catch"](function (err) {
|
11219 | return _this.error(err);
|
11220 | });
|
11221 | };
|
11222 |
|
11223 | VerifyContact.prototype.verifyView = function () {
|
11224 | var user = this.props.authData;
|
11225 |
|
11226 | if (!user) {
|
11227 | logger.debug('no user for verify');
|
11228 | return null;
|
11229 | }
|
11230 |
|
11231 | var unverified = user.unverified;
|
11232 |
|
11233 | if (!unverified) {
|
11234 | logger.debug('no unverified on user');
|
11235 | return null;
|
11236 | }
|
11237 |
|
11238 | var email = unverified.email,
|
11239 | phone_number = unverified.phone_number;
|
11240 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
11241 | return React.createElement("div", null, email ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
|
11242 | placeholder: core_1.I18n.get('Email'),
|
11243 | theme: theme,
|
11244 | key: "email",
|
11245 | name: "contact",
|
11246 | value: "email",
|
11247 | onChange: this.handleInputChange
|
11248 | }) : null, phone_number ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
|
11249 | placeholder: core_1.I18n.get('Phone Number'),
|
11250 | theme: theme,
|
11251 | key: "phone_number",
|
11252 | name: "contact",
|
11253 | value: "phone_number",
|
11254 | onChange: this.handleInputChange
|
11255 | }) : null);
|
11256 | };
|
11257 |
|
11258 | VerifyContact.prototype.submitView = function () {
|
11259 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
11260 | return React.createElement("div", null, React.createElement(Amplify_UI_Components_React_1.Input, {
|
11261 | placeholder: core_1.I18n.get('Code'),
|
11262 | theme: theme,
|
11263 | key: "code",
|
11264 | name: "code",
|
11265 | autoComplete: "off",
|
11266 | onChange: this.handleInputChange
|
11267 | }));
|
11268 | };
|
11269 |
|
11270 | VerifyContact.prototype.showComponent = function (theme) {
|
11271 | var _this = this;
|
11272 |
|
11273 | var _a = this.props,
|
11274 | authData = _a.authData,
|
11275 | hide = _a.hide;
|
11276 |
|
11277 | if (hide && hide.includes(VerifyContact)) {
|
11278 | return null;
|
11279 | }
|
11280 |
|
11281 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
11282 | theme: theme,
|
11283 | "data-test": data_test_attributes_1.auth.verifyContact.section
|
11284 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
11285 | theme: theme,
|
11286 | "data-test": data_test_attributes_1.auth.verifyContact.headerSection
|
11287 | }, core_1.I18n.get('Account recovery requires verified contact information')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
11288 | theme: theme,
|
11289 | "data-test": data_test_attributes_1.auth.verifyContact.bodySection
|
11290 | }, this.state.verifyAttr ? this.submitView() : this.verifyView()), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
11291 | theme: theme
|
11292 | }, React.createElement(Amplify_UI_Components_React_1.SectionFooterPrimaryContent, {
|
11293 | theme: theme
|
11294 | }, this.state.verifyAttr ? React.createElement(Amplify_UI_Components_React_1.Button, {
|
11295 | theme: theme,
|
11296 | onClick: this.submit,
|
11297 | "data-test": data_test_attributes_1.auth.verifyContact.submitButton
|
11298 | }, core_1.I18n.get('Submit')) : React.createElement(Amplify_UI_Components_React_1.Button, {
|
11299 | theme: theme,
|
11300 | onClick: this.verify,
|
11301 | "data-test": data_test_attributes_1.auth.verifyContact.verifyButton
|
11302 | }, core_1.I18n.get('Verify'))), React.createElement(Amplify_UI_Components_React_1.SectionFooterSecondaryContent, {
|
11303 | theme: theme
|
11304 | }, React.createElement(Amplify_UI_Components_React_1.Link, {
|
11305 | theme: theme,
|
11306 | onClick: function onClick() {
|
11307 | return _this.changeState('signedIn', authData);
|
11308 | },
|
11309 | "data-test": data_test_attributes_1.auth.verifyContact.skipLink
|
11310 | }, core_1.I18n.get('Skip')))));
|
11311 | };
|
11312 |
|
11313 | return VerifyContact;
|
11314 | }(AuthPiece_1.AuthPiece);
|
11315 |
|
11316 | exports.VerifyContact = VerifyContact;
|
11317 |
|
11318 |
|
11319 |
|
11320 |
|
11321 | exports["default"] = VerifyContact;
|
11322 |
|
11323 | }),
|
11324 |
|
11325 | "./lib/Auth/common/constants.js":
|
11326 |
|
11327 |
|
11328 |
|
11329 |
|
11330 | (function(module, exports, __webpack_require__) {
|
11331 |
|
11332 | "use strict";
|
11333 |
|
11334 |
|
11335 | Object.defineProperty(exports, "__esModule", {
|
11336 | value: true
|
11337 | });
|
11338 | exports.Constants = {
|
11339 | AUTH_SOURCE_KEY: 'amplify-react-auth-source',
|
11340 | AUTH0: 'auth0',
|
11341 | GOOGLE: 'google',
|
11342 | FACEBOOK: 'facebook',
|
11343 | AMAZON: 'amazon',
|
11344 | REDIRECTED_FROM_HOSTED_UI: 'amplify-redirected-from-hosted-ui'
|
11345 | };
|
11346 |
|
11347 | }),
|
11348 |
|
11349 | "./lib/Auth/common/country-dial-codes.js":
|
11350 |
|
11351 |
|
11352 |
|
11353 |
|
11354 | (function(module, exports, __webpack_require__) {
|
11355 |
|
11356 | "use strict";
|
11357 |
|
11358 |
|
11359 | Object.defineProperty(exports, "__esModule", {
|
11360 | value: true
|
11361 | });
|
11362 | exports.countryDialCodes = ['+1', '+7', '+20', '+27', '+30', '+31', '+32', '+33', '+34', '+36', '+39', '+40', '+41', '+43', '+44', '+45', '+46', '+47', '+48', '+49', '+51', '+52', '+53', '+54', '+55', '+56', '+57', '+58', '+60', '+61', '+62', '+63', '+64', '+65', '+66', '+81', '+82', '+84', '+86', '+90', '+91', '+92', '+93', '+94', '+95', '+98', '+212', '+213', '+216', '+218', '+220', '+221', '+222', '+223', '+224', '+225', '+226', '+227', '+228', '+229', '+230', '+231', '+232', '+233', '+234', '+235', '+236', '+237', '+238', '+239', '+240', '+241', '+242', '+243', '+244', '+245', '+246', '+248', '+249', '+250', '+251', '+252', '+253', '+254', '+255', '+256', '+257', '+258', '+260', '+261', '+262', '+263', '+264', '+265', '+266', '+267', '+268', '+269', '+290', '+291', '+297', '+298', '+299', '+345', '+350', '+351', '+352', '+353', '+354', '+355', '+356', '+357', '+358', '+359', '+370', '+371', '+372', '+373', '+374', '+375', '+376', '+377', '+378', '+379', '+380', '+381', '+382', '+385', '+386', '+387', '+389', '+420', '+421', '+423', '+500', '+501', '+502', '+503', '+504', '+505', '+506', '+507', '+508', '+509', '+537', '+590', '+591', '+593', '+594', '+595', '+596', '+597', '+598', '+599', '+670', '+672', '+673', '+674', '+675', '+676', '+677', '+678', '+679', '+680', '+681', '+682', '+683', '+685', '+686', '+687', '+688', '+689', '+690', '+691', '+692', '+850', '+852', '+853', '+855', '+856', '+872', '+880', '+886', '+960', '+961', '+962', '+963', '+964', '+965', '+966', '+967', '+968', '+970', '+971', '+972', '+973', '+974', '+975', '+976', '+977', '+992', '+993', '+994', '+995', '+996', '+998'];
|
11363 |
|
11364 | }),
|
11365 |
|
11366 | "./lib/Auth/common/default-sign-up-fields.js":
|
11367 |
|
11368 |
|
11369 |
|
11370 |
|
11371 | (function(module, exports, __webpack_require__) {
|
11372 |
|
11373 | "use strict";
|
11374 |
|
11375 |
|
11376 | Object.defineProperty(exports, "__esModule", {
|
11377 | value: true
|
11378 | });
|
11379 | exports.signUpWithUsernameFields = [{
|
11380 | label: 'Username',
|
11381 | key: 'username',
|
11382 | required: true,
|
11383 | placeholder: 'Username',
|
11384 | displayOrder: 1
|
11385 | }, {
|
11386 | label: 'Password',
|
11387 | key: 'password',
|
11388 | required: true,
|
11389 | placeholder: 'Password',
|
11390 | type: 'password',
|
11391 | displayOrder: 2
|
11392 | }, {
|
11393 | label: 'Email',
|
11394 | key: 'email',
|
11395 | required: true,
|
11396 | placeholder: 'Email',
|
11397 | type: 'email',
|
11398 | displayOrder: 3
|
11399 | }, {
|
11400 | label: 'Phone Number',
|
11401 | key: 'phone_number',
|
11402 | placeholder: 'Phone Number',
|
11403 | required: true,
|
11404 | displayOrder: 4
|
11405 | }];
|
11406 | exports.signUpWithEmailFields = [{
|
11407 | label: 'Email',
|
11408 | key: 'email',
|
11409 | required: true,
|
11410 | placeholder: 'Email',
|
11411 | type: 'email',
|
11412 | displayOrder: 1
|
11413 | }, {
|
11414 | label: 'Password',
|
11415 | key: 'password',
|
11416 | required: true,
|
11417 | placeholder: 'Password',
|
11418 | type: 'password',
|
11419 | displayOrder: 2
|
11420 | }, {
|
11421 | label: 'Phone Number',
|
11422 | key: 'phone_number',
|
11423 | placeholder: 'Phone Number',
|
11424 | required: true,
|
11425 | displayOrder: 3
|
11426 | }];
|
11427 | exports.signUpWithPhoneNumberFields = [{
|
11428 | label: 'Phone Number',
|
11429 | key: 'phone_number',
|
11430 | placeholder: 'Phone Number',
|
11431 | required: true,
|
11432 | displayOrder: 1
|
11433 | }, {
|
11434 | label: 'Password',
|
11435 | key: 'password',
|
11436 | required: true,
|
11437 | placeholder: 'Password',
|
11438 | type: 'password',
|
11439 | displayOrder: 2
|
11440 | }, {
|
11441 | label: 'Email',
|
11442 | key: 'email',
|
11443 | required: true,
|
11444 | placeholder: 'Email',
|
11445 | type: 'email',
|
11446 | displayOrder: 3
|
11447 | }];
|
11448 |
|
11449 | }),
|
11450 |
|
11451 | "./lib/Auth/common/types.js":
|
11452 |
|
11453 |
|
11454 |
|
11455 |
|
11456 | (function(module, exports, __webpack_require__) {
|
11457 |
|
11458 | "use strict";
|
11459 |
|
11460 |
|
11461 | Object.defineProperty(exports, "__esModule", {
|
11462 | value: true
|
11463 | });
|
11464 | var UsernameAttributes;
|
11465 |
|
11466 | (function (UsernameAttributes) {
|
11467 | UsernameAttributes["EMAIL"] = "email";
|
11468 | UsernameAttributes["PHONE_NUMBER"] = "phone_number";
|
11469 | UsernameAttributes["USERNAME"] = "username";
|
11470 | })(UsernameAttributes = exports.UsernameAttributes || (exports.UsernameAttributes = {}));
|
11471 |
|
11472 | }),
|
11473 |
|
11474 | "./lib/Auth/index.js":
|
11475 |
|
11476 |
|
11477 |
|
11478 |
|
11479 | (function(module, exports, __webpack_require__) {
|
11480 |
|
11481 | "use strict";
|
11482 |
|
11483 |
|
11484 |
|
11485 |
|
11486 |
|
11487 |
|
11488 |
|
11489 |
|
11490 |
|
11491 |
|
11492 |
|
11493 |
|
11494 |
|
11495 |
|
11496 | function _typeof(obj) {
|
11497 | "@babel/helpers - typeof";
|
11498 |
|
11499 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
11500 | _typeof = function _typeof(obj) {
|
11501 | return typeof obj;
|
11502 | };
|
11503 | } else {
|
11504 | _typeof = function _typeof(obj) {
|
11505 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
11506 | };
|
11507 | }
|
11508 |
|
11509 | return _typeof(obj);
|
11510 | }
|
11511 |
|
11512 | var __extends = this && this.__extends || function () {
|
11513 | var _extendStatics = function extendStatics(d, b) {
|
11514 | _extendStatics = Object.setPrototypeOf || {
|
11515 | __proto__: []
|
11516 | } instanceof Array && function (d, b) {
|
11517 | d.__proto__ = b;
|
11518 | } || function (d, b) {
|
11519 | for (var p in b) {
|
11520 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
11521 | }
|
11522 | };
|
11523 |
|
11524 | return _extendStatics(d, b);
|
11525 | };
|
11526 |
|
11527 | return function (d, b) {
|
11528 | _extendStatics(d, b);
|
11529 |
|
11530 | function __() {
|
11531 | this.constructor = d;
|
11532 | }
|
11533 |
|
11534 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
11535 | };
|
11536 | }();
|
11537 |
|
11538 | var __assign = this && this.__assign || function () {
|
11539 | __assign = Object.assign || function (t) {
|
11540 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
11541 | s = arguments[i];
|
11542 |
|
11543 | for (var p in s) {
|
11544 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
11545 | }
|
11546 | }
|
11547 |
|
11548 | return t;
|
11549 | };
|
11550 |
|
11551 | return __assign.apply(this, arguments);
|
11552 | };
|
11553 |
|
11554 | function __export(m) {
|
11555 | for (var p in m) {
|
11556 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
11557 | }
|
11558 | }
|
11559 |
|
11560 | var __importStar = this && this.__importStar || function (mod) {
|
11561 | if (mod && mod.__esModule) return mod;
|
11562 | var result = {};
|
11563 | if (mod != null) for (var k in mod) {
|
11564 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
11565 | }
|
11566 | result["default"] = mod;
|
11567 | return result;
|
11568 | };
|
11569 |
|
11570 | Object.defineProperty(exports, "__esModule", {
|
11571 | value: true
|
11572 | });
|
11573 |
|
11574 | var React = __importStar(__webpack_require__( "react"));
|
11575 |
|
11576 | var Authenticator_1 = __webpack_require__( "./lib/Auth/Authenticator.js");
|
11577 |
|
11578 | var Authenticator_2 = __webpack_require__( "./lib/Auth/Authenticator.js");
|
11579 |
|
11580 | exports.Authenticator = Authenticator_2.Authenticator;
|
11581 |
|
11582 | var AuthPiece_1 = __webpack_require__( "./lib/Auth/AuthPiece.js");
|
11583 |
|
11584 | exports.AuthPiece = AuthPiece_1.AuthPiece;
|
11585 |
|
11586 | var SignIn_1 = __webpack_require__( "./lib/Auth/SignIn.js");
|
11587 |
|
11588 | exports.SignIn = SignIn_1.SignIn;
|
11589 |
|
11590 | var ConfirmSignIn_1 = __webpack_require__( "./lib/Auth/ConfirmSignIn.js");
|
11591 |
|
11592 | exports.ConfirmSignIn = ConfirmSignIn_1.ConfirmSignIn;
|
11593 |
|
11594 | var SignOut_1 = __webpack_require__( "./lib/Auth/SignOut.js");
|
11595 |
|
11596 | exports.SignOut = SignOut_1.SignOut;
|
11597 |
|
11598 | var RequireNewPassword_1 = __webpack_require__( "./lib/Auth/RequireNewPassword.js");
|
11599 |
|
11600 | exports.RequireNewPassword = RequireNewPassword_1.RequireNewPassword;
|
11601 |
|
11602 | var SignUp_1 = __webpack_require__( "./lib/Auth/SignUp.js");
|
11603 |
|
11604 | exports.SignUp = SignUp_1.SignUp;
|
11605 |
|
11606 | var ConfirmSignUp_1 = __webpack_require__( "./lib/Auth/ConfirmSignUp.js");
|
11607 |
|
11608 | exports.ConfirmSignUp = ConfirmSignUp_1.ConfirmSignUp;
|
11609 |
|
11610 | var VerifyContact_1 = __webpack_require__( "./lib/Auth/VerifyContact.js");
|
11611 |
|
11612 | exports.VerifyContact = VerifyContact_1.VerifyContact;
|
11613 |
|
11614 | var ForgotPassword_1 = __webpack_require__( "./lib/Auth/ForgotPassword.js");
|
11615 |
|
11616 | exports.ForgotPassword = ForgotPassword_1.ForgotPassword;
|
11617 |
|
11618 | var Greetings_1 = __webpack_require__( "./lib/Auth/Greetings.js");
|
11619 |
|
11620 | exports.Greetings = Greetings_1.Greetings;
|
11621 |
|
11622 | var FederatedSignIn_1 = __webpack_require__( "./lib/Auth/FederatedSignIn.js");
|
11623 |
|
11624 | exports.FederatedSignIn = FederatedSignIn_1.FederatedSignIn;
|
11625 | exports.FederatedButtons = FederatedSignIn_1.FederatedButtons;
|
11626 |
|
11627 | var TOTPSetup_1 = __webpack_require__( "./lib/Auth/TOTPSetup.js");
|
11628 |
|
11629 | exports.TOTPSetup = TOTPSetup_1.TOTPSetup;
|
11630 |
|
11631 | var Loading_1 = __webpack_require__( "./lib/Auth/Loading.js");
|
11632 |
|
11633 | exports.Loading = Loading_1.Loading;
|
11634 |
|
11635 | __export(__webpack_require__( "./lib/Auth/Provider/index.js"));
|
11636 |
|
11637 | __export(__webpack_require__( "./lib/Auth/common/types.js"));
|
11638 |
|
11639 | function withAuthenticator(Comp, includeGreetings, authenticatorComponents, federated, theme, signUpConfig) {
|
11640 | if (includeGreetings === void 0) {
|
11641 | includeGreetings = false;
|
11642 | }
|
11643 |
|
11644 | if (authenticatorComponents === void 0) {
|
11645 | authenticatorComponents = [];
|
11646 | }
|
11647 |
|
11648 | if (federated === void 0) {
|
11649 | federated = null;
|
11650 | }
|
11651 |
|
11652 | if (theme === void 0) {
|
11653 | theme = null;
|
11654 | }
|
11655 |
|
11656 | if (signUpConfig === void 0) {
|
11657 | signUpConfig = {};
|
11658 | }
|
11659 |
|
11660 | return (
|
11661 |
|
11662 | function (_super) {
|
11663 | __extends(class_1, _super);
|
11664 |
|
11665 | function class_1(props) {
|
11666 | var _this = _super.call(this, props) || this;
|
11667 |
|
11668 | _this.handleAuthStateChange = _this.handleAuthStateChange.bind(_this);
|
11669 | _this.state = {
|
11670 | authState: props.authState || null,
|
11671 | authData: props.authData || null
|
11672 | };
|
11673 | _this.authConfig = {};
|
11674 |
|
11675 | if (_typeof(includeGreetings) === 'object' && includeGreetings !== null) {
|
11676 | _this.authConfig = Object.assign(_this.authConfig, includeGreetings);
|
11677 | } else {
|
11678 | _this.authConfig = {
|
11679 | includeGreetings: includeGreetings,
|
11680 | authenticatorComponents: authenticatorComponents,
|
11681 | federated: federated,
|
11682 | theme: theme,
|
11683 | signUpConfig: signUpConfig
|
11684 | };
|
11685 | }
|
11686 |
|
11687 | return _this;
|
11688 | }
|
11689 |
|
11690 | class_1.prototype.handleAuthStateChange = function (state, data) {
|
11691 | this.setState({
|
11692 | authState: state,
|
11693 | authData: data
|
11694 | });
|
11695 | };
|
11696 |
|
11697 | class_1.prototype.render = function () {
|
11698 | var _a = this.state,
|
11699 | authState = _a.authState,
|
11700 | authData = _a.authData;
|
11701 |
|
11702 | if (authState === 'signedIn') {
|
11703 | return React.createElement(React.Fragment, null, this.authConfig.includeGreetings ? React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
|
11704 | theme: this.authConfig.theme,
|
11705 | federated: this.authConfig.federated || this.props.federated,
|
11706 | hideDefault: this.authConfig.authenticatorComponents && this.authConfig.authenticatorComponents.length > 0,
|
11707 | signUpConfig: this.authConfig.signUpConfig,
|
11708 | usernameAttributes: this.authConfig.usernameAttributes,
|
11709 | onStateChange: this.handleAuthStateChange,
|
11710 | children: this.authConfig.authenticatorComponents || []
|
11711 | })) : null, React.createElement(Comp, __assign({}, this.props, {
|
11712 | authState: authState,
|
11713 | authData: authData,
|
11714 | onStateChange: this.handleAuthStateChange
|
11715 | })));
|
11716 | }
|
11717 |
|
11718 | return React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
|
11719 | theme: this.authConfig.theme,
|
11720 | federated: this.authConfig.federated || this.props.federated,
|
11721 | hideDefault: this.authConfig.authenticatorComponents && this.authConfig.authenticatorComponents.length > 0,
|
11722 | signUpConfig: this.authConfig.signUpConfig,
|
11723 | usernameAttributes: this.authConfig.usernameAttributes,
|
11724 | onStateChange: this.handleAuthStateChange,
|
11725 | children: this.authConfig.authenticatorComponents || []
|
11726 | }));
|
11727 | };
|
11728 |
|
11729 | return class_1;
|
11730 | }(React.Component)
|
11731 | );
|
11732 | }
|
11733 |
|
11734 | exports.withAuthenticator = withAuthenticator;
|
11735 |
|
11736 | var AuthenticatorWrapper =
|
11737 |
|
11738 | function (_super) {
|
11739 | __extends(AuthenticatorWrapper, _super);
|
11740 |
|
11741 | function AuthenticatorWrapper(props) {
|
11742 | var _this = _super.call(this, props) || this;
|
11743 |
|
11744 | _this.state = {
|
11745 | auth: 'init'
|
11746 | };
|
11747 | _this.handleAuthState = _this.handleAuthState.bind(_this);
|
11748 | _this.renderChildren = _this.renderChildren.bind(_this);
|
11749 | return _this;
|
11750 | }
|
11751 |
|
11752 | AuthenticatorWrapper.prototype.handleAuthState = function (state, data) {
|
11753 | this.setState({
|
11754 | auth: state,
|
11755 | authData: data
|
11756 | });
|
11757 | };
|
11758 |
|
11759 | AuthenticatorWrapper.prototype.renderChildren = function () {
|
11760 |
|
11761 | return this.props.children(this.state.auth);
|
11762 | };
|
11763 |
|
11764 | AuthenticatorWrapper.prototype.render = function () {
|
11765 | return React.createElement("div", null, React.createElement(Authenticator_1.Authenticator, __assign({}, this.props, {
|
11766 | onStateChange: this.handleAuthState
|
11767 | })), this.renderChildren());
|
11768 | };
|
11769 |
|
11770 | return AuthenticatorWrapper;
|
11771 | }(React.Component);
|
11772 |
|
11773 | exports.AuthenticatorWrapper = AuthenticatorWrapper;
|
11774 |
|
11775 | }),
|
11776 |
|
11777 | "./lib/Interactions/ChatBot.js":
|
11778 |
|
11779 |
|
11780 |
|
11781 |
|
11782 | (function(module, exports, __webpack_require__) {
|
11783 |
|
11784 | "use strict";
|
11785 | (function(global) {
|
11786 |
|
11787 | var __extends = this && this.__extends || function () {
|
11788 | var _extendStatics = function extendStatics(d, b) {
|
11789 | _extendStatics = Object.setPrototypeOf || {
|
11790 | __proto__: []
|
11791 | } instanceof Array && function (d, b) {
|
11792 | d.__proto__ = b;
|
11793 | } || function (d, b) {
|
11794 | for (var p in b) {
|
11795 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
11796 | }
|
11797 | };
|
11798 |
|
11799 | return _extendStatics(d, b);
|
11800 | };
|
11801 |
|
11802 | return function (d, b) {
|
11803 | _extendStatics(d, b);
|
11804 |
|
11805 | function __() {
|
11806 | this.constructor = d;
|
11807 | }
|
11808 |
|
11809 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
11810 | };
|
11811 | }();
|
11812 |
|
11813 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
11814 | function adopt(value) {
|
11815 | return value instanceof P ? value : new P(function (resolve) {
|
11816 | resolve(value);
|
11817 | });
|
11818 | }
|
11819 |
|
11820 | return new (P || (P = Promise))(function (resolve, reject) {
|
11821 | function fulfilled(value) {
|
11822 | try {
|
11823 | step(generator.next(value));
|
11824 | } catch (e) {
|
11825 | reject(e);
|
11826 | }
|
11827 | }
|
11828 |
|
11829 | function rejected(value) {
|
11830 | try {
|
11831 | step(generator["throw"](value));
|
11832 | } catch (e) {
|
11833 | reject(e);
|
11834 | }
|
11835 | }
|
11836 |
|
11837 | function step(result) {
|
11838 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
11839 | }
|
11840 |
|
11841 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
11842 | });
|
11843 | };
|
11844 |
|
11845 | var __generator = this && this.__generator || function (thisArg, body) {
|
11846 | var _ = {
|
11847 | label: 0,
|
11848 | sent: function sent() {
|
11849 | if (t[0] & 1) throw t[1];
|
11850 | return t[1];
|
11851 | },
|
11852 | trys: [],
|
11853 | ops: []
|
11854 | },
|
11855 | f,
|
11856 | y,
|
11857 | t,
|
11858 | g;
|
11859 | return g = {
|
11860 | next: verb(0),
|
11861 | "throw": verb(1),
|
11862 | "return": verb(2)
|
11863 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
11864 | return this;
|
11865 | }), g;
|
11866 |
|
11867 | function verb(n) {
|
11868 | return function (v) {
|
11869 | return step([n, v]);
|
11870 | };
|
11871 | }
|
11872 |
|
11873 | function step(op) {
|
11874 | if (f) throw new TypeError("Generator is already executing.");
|
11875 |
|
11876 | while (_) {
|
11877 | try {
|
11878 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
11879 | if (y = 0, t) op = [op[0] & 2, t.value];
|
11880 |
|
11881 | switch (op[0]) {
|
11882 | case 0:
|
11883 | case 1:
|
11884 | t = op;
|
11885 | break;
|
11886 |
|
11887 | case 4:
|
11888 | _.label++;
|
11889 | return {
|
11890 | value: op[1],
|
11891 | done: false
|
11892 | };
|
11893 |
|
11894 | case 5:
|
11895 | _.label++;
|
11896 | y = op[1];
|
11897 | op = [0];
|
11898 | continue;
|
11899 |
|
11900 | case 7:
|
11901 | op = _.ops.pop();
|
11902 |
|
11903 | _.trys.pop();
|
11904 |
|
11905 | continue;
|
11906 |
|
11907 | default:
|
11908 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
11909 | _ = 0;
|
11910 | continue;
|
11911 | }
|
11912 |
|
11913 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
11914 | _.label = op[1];
|
11915 | break;
|
11916 | }
|
11917 |
|
11918 | if (op[0] === 6 && _.label < t[1]) {
|
11919 | _.label = t[1];
|
11920 | t = op;
|
11921 | break;
|
11922 | }
|
11923 |
|
11924 | if (t && _.label < t[2]) {
|
11925 | _.label = t[2];
|
11926 |
|
11927 | _.ops.push(op);
|
11928 |
|
11929 | break;
|
11930 | }
|
11931 |
|
11932 | if (t[2]) _.ops.pop();
|
11933 |
|
11934 | _.trys.pop();
|
11935 |
|
11936 | continue;
|
11937 | }
|
11938 |
|
11939 | op = body.call(thisArg, _);
|
11940 | } catch (e) {
|
11941 | op = [6, e];
|
11942 | y = 0;
|
11943 | } finally {
|
11944 | f = t = 0;
|
11945 | }
|
11946 | }
|
11947 |
|
11948 | if (op[0] & 5) throw op[1];
|
11949 | return {
|
11950 | value: op[0] ? op[1] : void 0,
|
11951 | done: true
|
11952 | };
|
11953 | }
|
11954 | };
|
11955 |
|
11956 | var __read = this && this.__read || function (o, n) {
|
11957 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
11958 | if (!m) return o;
|
11959 | var i = m.call(o),
|
11960 | r,
|
11961 | ar = [],
|
11962 | e;
|
11963 |
|
11964 | try {
|
11965 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
11966 | ar.push(r.value);
|
11967 | }
|
11968 | } catch (error) {
|
11969 | e = {
|
11970 | error: error
|
11971 | };
|
11972 | } finally {
|
11973 | try {
|
11974 | if (r && !r.done && (m = i["return"])) m.call(i);
|
11975 | } finally {
|
11976 | if (e) throw e.error;
|
11977 | }
|
11978 | }
|
11979 |
|
11980 | return ar;
|
11981 | };
|
11982 |
|
11983 | var __spread = this && this.__spread || function () {
|
11984 | for (var ar = [], i = 0; i < arguments.length; i++) {
|
11985 | ar = ar.concat(__read(arguments[i]));
|
11986 | }
|
11987 |
|
11988 | return ar;
|
11989 | };
|
11990 |
|
11991 | var __importStar = this && this.__importStar || function (mod) {
|
11992 | if (mod && mod.__esModule) return mod;
|
11993 | var result = {};
|
11994 | if (mod != null) for (var k in mod) {
|
11995 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
11996 | }
|
11997 | result["default"] = mod;
|
11998 | return result;
|
11999 | };
|
12000 |
|
12001 | Object.defineProperty(exports, "__esModule", {
|
12002 | value: true
|
12003 | });
|
12004 |
|
12005 | var React = __importStar(__webpack_require__( "react"));
|
12006 |
|
12007 | var AmplifyUI_1 = __webpack_require__( "./lib/AmplifyUI.js");
|
12008 |
|
12009 | var AmplifyTheme_1 = __webpack_require__( "./lib/AmplifyTheme.js");
|
12010 |
|
12011 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
12012 |
|
12013 | var interactions_1 = __webpack_require__( "@aws-amplify/interactions");
|
12014 |
|
12015 | var core_2 = __webpack_require__( "@aws-amplify/core");
|
12016 |
|
12017 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
12018 |
|
12019 | var logger = new core_2.ConsoleLogger('ChatBot');
|
12020 |
|
12021 | var styles = {
|
12022 | itemMe: {
|
12023 | padding: 10,
|
12024 | fontSize: 12,
|
12025 | color: 'gray',
|
12026 | marginTop: 4,
|
12027 | textAlign: 'right'
|
12028 | },
|
12029 | itemBot: {
|
12030 | fontSize: 12,
|
12031 | textAlign: 'left'
|
12032 | },
|
12033 | list: {
|
12034 | height: '300px',
|
12035 | overflow: 'auto'
|
12036 | },
|
12037 | textInput: Object.assign({}, AmplifyTheme_1.Input, {
|
12038 | display: 'inline-block',
|
12039 | width: 'calc(100% - 90px - 15px)'
|
12040 | }),
|
12041 |
|
12042 | button: Object.assign({}, AmplifyTheme_1.Button, {
|
12043 | width: '60px',
|
12044 | "float": 'right'
|
12045 | }),
|
12046 |
|
12047 | mic: Object.assign({}, AmplifyTheme_1.Button, {
|
12048 | width: '40px',
|
12049 | "float": 'right'
|
12050 | })
|
12051 | };
|
12052 | var STATES = {
|
12053 | INITIAL: {
|
12054 | MESSAGE: 'Type your message or click 🎤',
|
12055 | ICON: '🎤'
|
12056 | },
|
12057 | LISTENING: {
|
12058 | MESSAGE: 'Listening... click 🔴 again to cancel',
|
12059 | ICON: '🔴'
|
12060 | },
|
12061 | SENDING: {
|
12062 | MESSAGE: 'Please wait...',
|
12063 | ICON: '🔊'
|
12064 | },
|
12065 | SPEAKING: {
|
12066 | MESSAGE: 'Speaking...',
|
12067 | ICON: '...'
|
12068 | }
|
12069 | };
|
12070 | var defaultVoiceConfig = {
|
12071 | silenceDetectionConfig: {
|
12072 | time: 2000,
|
12073 | amplitude: 0.2
|
12074 | }
|
12075 | };
|
12076 | var audioControl;
|
12077 |
|
12078 | var ChatBot =
|
12079 |
|
12080 | function (_super) {
|
12081 | __extends(ChatBot, _super);
|
12082 |
|
12083 | function ChatBot(props) {
|
12084 | var _this = _super.call(this, props) || this;
|
12085 |
|
12086 | if (_this.props.voiceEnabled) {
|
12087 | __webpack_require__( "./lib/Interactions/aws-lex-audio.js");
|
12088 |
|
12089 |
|
12090 | audioControl = new global.LexAudio.audioControl();
|
12091 | }
|
12092 |
|
12093 | if (!_this.props.textEnabled && _this.props.voiceEnabled) {
|
12094 | STATES.INITIAL.MESSAGE = 'Click the mic button';
|
12095 | styles.textInput = Object.assign({}, AmplifyTheme_1.Input, {
|
12096 | display: 'inline-block',
|
12097 | width: 'calc(100% - 40px - 15px)'
|
12098 | });
|
12099 | }
|
12100 |
|
12101 | if (_this.props.textEnabled && !_this.props.voiceEnabled) {
|
12102 | STATES.INITIAL.MESSAGE = 'Type a message';
|
12103 | styles.textInput = Object.assign({}, AmplifyTheme_1.Input, {
|
12104 | display: 'inline-block',
|
12105 | width: 'calc(100% - 60px - 15px)'
|
12106 | });
|
12107 | }
|
12108 |
|
12109 | if (!_this.props.voiceConfig.silenceDetectionConfig) {
|
12110 | throw new Error('voiceConfig prop is missing silenceDetectionConfig');
|
12111 | }
|
12112 |
|
12113 | _this.state = {
|
12114 | dialog: [{
|
12115 | message: _this.props.welcomeMessage || 'Welcome to Lex',
|
12116 | from: 'system'
|
12117 | }],
|
12118 | inputText: '',
|
12119 | currentVoiceState: STATES.INITIAL,
|
12120 | inputDisabled: false,
|
12121 | micText: STATES.INITIAL.ICON,
|
12122 | continueConversation: false,
|
12123 | micButtonDisabled: false
|
12124 | };
|
12125 | _this.micButtonHandler = _this.micButtonHandler.bind(_this);
|
12126 | _this.changeInputText = _this.changeInputText.bind(_this);
|
12127 | _this.listItems = _this.listItems.bind(_this);
|
12128 | _this.submit = _this.submit.bind(_this);
|
12129 |
|
12130 | _this.listItemsRef = React.createRef();
|
12131 | _this.onSilenceHandler = _this.onSilenceHandler.bind(_this);
|
12132 | _this.doneSpeakingHandler = _this.doneSpeakingHandler.bind(_this);
|
12133 | _this.lexResponseHandler = _this.lexResponseHandler.bind(_this);
|
12134 | return _this;
|
12135 | }
|
12136 |
|
12137 | ChatBot.prototype.micButtonHandler = function () {
|
12138 | return __awaiter(this, void 0, void 0, function () {
|
12139 | var _this = this;
|
12140 |
|
12141 | return __generator(this, function (_a) {
|
12142 | if (this.state.continueConversation) {
|
12143 | this.reset();
|
12144 | } else {
|
12145 | this.setState({
|
12146 | inputDisabled: true,
|
12147 | continueConversation: true,
|
12148 | currentVoiceState: STATES.LISTENING,
|
12149 | micText: STATES.LISTENING.ICON,
|
12150 | micButtonDisabled: false
|
12151 | }, function () {
|
12152 | audioControl.startRecording(_this.onSilenceHandler, null, _this.props.voiceConfig.silenceDetectionConfig);
|
12153 | });
|
12154 | }
|
12155 |
|
12156 | return [2
|
12157 |
|
12158 | ];
|
12159 | });
|
12160 | });
|
12161 | };
|
12162 |
|
12163 | ChatBot.prototype.onSilenceHandler = function () {
|
12164 | var _this = this;
|
12165 |
|
12166 | audioControl.stopRecording();
|
12167 |
|
12168 | if (!this.state.continueConversation) {
|
12169 | return;
|
12170 | }
|
12171 |
|
12172 | audioControl.exportWAV(function (blob) {
|
12173 | _this.setState({
|
12174 | currentVoiceState: STATES.SENDING,
|
12175 | audioInput: blob,
|
12176 | micText: STATES.SENDING.ICON,
|
12177 | micButtonDisabled: true
|
12178 | }, function () {
|
12179 | _this.lexResponseHandler();
|
12180 | });
|
12181 | });
|
12182 | };
|
12183 |
|
12184 | ChatBot.prototype.lexResponseHandler = function () {
|
12185 | return __awaiter(this, void 0, void 0, function () {
|
12186 | var interactionsMessage, response;
|
12187 |
|
12188 | var _this = this;
|
12189 |
|
12190 | return __generator(this, function (_a) {
|
12191 | switch (_a.label) {
|
12192 | case 0:
|
12193 | if (!interactions_1.Interactions || typeof interactions_1.Interactions.send !== 'function') {
|
12194 | throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
|
12195 | }
|
12196 |
|
12197 | if (!this.state.continueConversation) {
|
12198 | return [2
|
12199 |
|
12200 | ];
|
12201 | }
|
12202 |
|
12203 | interactionsMessage = {
|
12204 | content: this.state.audioInput,
|
12205 | options: {
|
12206 | messageType: 'voice'
|
12207 | }
|
12208 | };
|
12209 | return [4
|
12210 |
|
12211 | , interactions_1.Interactions.send(this.props.botName, interactionsMessage)];
|
12212 |
|
12213 | case 1:
|
12214 | response = _a.sent();
|
12215 | this.setState({
|
12216 | lexResponse: response,
|
12217 | currentVoiceState: STATES.SPEAKING,
|
12218 | micText: STATES.SPEAKING.ICON,
|
12219 | micButtonDisabled: true,
|
12220 | dialog: __spread(this.state.dialog, [
|
12221 | {
|
12222 | message: response.inputTranscript,
|
12223 | from: 'me'
|
12224 | },
|
12225 | response && {
|
12226 | from: 'bot',
|
12227 | message: response.message
|
12228 | }]),
|
12229 | inputText: ''
|
12230 | }, function () {
|
12231 | _this.doneSpeakingHandler();
|
12232 | });
|
12233 | this.listItemsRef.current.scrollTop = this.listItemsRef.current.scrollHeight;
|
12234 | return [2
|
12235 |
|
12236 | ];
|
12237 | }
|
12238 | });
|
12239 | });
|
12240 | };
|
12241 |
|
12242 | ChatBot.prototype.doneSpeakingHandler = function () {
|
12243 | var _this = this;
|
12244 |
|
12245 | if (!this.state.continueConversation) {
|
12246 | return;
|
12247 | }
|
12248 |
|
12249 | if (this.state.lexResponse.contentType === 'audio/mpeg') {
|
12250 | audioControl.play(this.state.lexResponse.audioStream, function () {
|
12251 | if (_this.state.lexResponse.dialogState === 'ReadyForFulfillment' || _this.state.lexResponse.dialogState === 'Fulfilled' || _this.state.lexResponse.dialogState === 'Failed' || !_this.props.conversationModeOn) {
|
12252 | _this.setState({
|
12253 | inputDisabled: false,
|
12254 | currentVoiceState: STATES.INITIAL,
|
12255 | micText: STATES.INITIAL.ICON,
|
12256 | micButtonDisabled: false,
|
12257 | continueConversation: false
|
12258 | });
|
12259 | } else {
|
12260 | _this.setState({
|
12261 | currentVoiceState: STATES.LISTENING,
|
12262 | micText: STATES.LISTENING.ICON,
|
12263 | micButtonDisabled: false
|
12264 | }, function () {
|
12265 | audioControl.startRecording(_this.onSilenceHandler, null, _this.props.voiceConfig.silenceDetectionConfig);
|
12266 | });
|
12267 | }
|
12268 | });
|
12269 | } else {
|
12270 | this.setState({
|
12271 | inputDisabled: false,
|
12272 | currentVoiceState: STATES.INITIAL,
|
12273 | micText: STATES.INITIAL.ICON,
|
12274 | micButtonDisabled: false,
|
12275 | continueConversation: false
|
12276 | });
|
12277 | }
|
12278 | };
|
12279 |
|
12280 | ChatBot.prototype.reset = function () {
|
12281 | this.setState({
|
12282 | inputText: '',
|
12283 | currentVoiceState: STATES.INITIAL,
|
12284 | inputDisabled: false,
|
12285 | micText: STATES.INITIAL.ICON,
|
12286 | continueConversation: false,
|
12287 | micButtonDisabled: false
|
12288 | }, function () {
|
12289 | audioControl.clear();
|
12290 | });
|
12291 | };
|
12292 |
|
12293 | ChatBot.prototype.listItems = function () {
|
12294 | return this.state.dialog.map(function (m, i) {
|
12295 | if (m.from === 'me') {
|
12296 | return React.createElement("div", {
|
12297 | key: i,
|
12298 | style: styles.itemMe,
|
12299 | "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
|
12300 | }, m.message);
|
12301 | } else if (m.from === 'system') {
|
12302 | return React.createElement("div", {
|
12303 | key: i,
|
12304 | style: styles.itemBot,
|
12305 | "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
|
12306 | }, m.message);
|
12307 | } else {
|
12308 | return React.createElement("div", {
|
12309 | key: i,
|
12310 | style: styles.itemBot,
|
12311 | "data-test": data_test_attributes_1.chatBot.dialog + "-" + i
|
12312 | }, m.message);
|
12313 | }
|
12314 | });
|
12315 | };
|
12316 |
|
12317 | ChatBot.prototype.submit = function (e) {
|
12318 | return __awaiter(this, void 0, void 0, function () {
|
12319 | var response;
|
12320 |
|
12321 | var _this = this;
|
12322 |
|
12323 | return __generator(this, function (_a) {
|
12324 | switch (_a.label) {
|
12325 | case 0:
|
12326 | e.preventDefault();
|
12327 |
|
12328 | if (!this.state.inputText) {
|
12329 | return [2
|
12330 |
|
12331 | ];
|
12332 | }
|
12333 |
|
12334 | return [4
|
12335 |
|
12336 | , new Promise(function (resolve) {
|
12337 | return _this.setState({
|
12338 | dialog: __spread(_this.state.dialog, [{
|
12339 | message: _this.state.inputText,
|
12340 | from: 'me'
|
12341 | }])
|
12342 | }, resolve);
|
12343 | })];
|
12344 |
|
12345 | case 1:
|
12346 | _a.sent();
|
12347 |
|
12348 | if (!interactions_1.Interactions || typeof interactions_1.Interactions.send !== 'function') {
|
12349 | throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
|
12350 | }
|
12351 |
|
12352 | return [4
|
12353 |
|
12354 | , interactions_1.Interactions.send(this.props.botName, this.state.inputText)];
|
12355 |
|
12356 | case 2:
|
12357 | response = _a.sent();
|
12358 | this.setState({
|
12359 |
|
12360 | dialog: __spread(this.state.dialog, [
|
12361 | response && {
|
12362 | from: 'bot',
|
12363 | message: response.message
|
12364 | }]),
|
12365 | inputText: ''
|
12366 | });
|
12367 | this.listItemsRef.current.scrollTop = this.listItemsRef.current.scrollHeight;
|
12368 | return [2
|
12369 |
|
12370 | ];
|
12371 | }
|
12372 | });
|
12373 | });
|
12374 | };
|
12375 |
|
12376 | ChatBot.prototype.changeInputText = function (event) {
|
12377 | return __awaiter(this, void 0, void 0, function () {
|
12378 | return __generator(this, function (_a) {
|
12379 | switch (_a.label) {
|
12380 | case 0:
|
12381 | return [4
|
12382 |
|
12383 | , this.setState({
|
12384 | inputText: event.target.value
|
12385 | })];
|
12386 |
|
12387 | case 1:
|
12388 | _a.sent();
|
12389 |
|
12390 | return [2
|
12391 |
|
12392 | ];
|
12393 | }
|
12394 | });
|
12395 | });
|
12396 | };
|
12397 |
|
12398 | ChatBot.prototype.getOnComplete = function (fn) {
|
12399 | var _this = this;
|
12400 |
|
12401 | return function () {
|
12402 | var args = [];
|
12403 |
|
12404 | for (var _i = 0; _i < arguments.length; _i++) {
|
12405 | args[_i] = arguments[_i];
|
12406 | }
|
12407 |
|
12408 | var clearOnComplete = _this.props.clearOnComplete;
|
12409 | var message = fn.apply(void 0, __spread(args));
|
12410 |
|
12411 | _this.setState({
|
12412 | dialog: __spread(clearOnComplete ? [] : _this.state.dialog, [message && {
|
12413 | from: 'bot',
|
12414 | message: message
|
12415 | }]).filter(Boolean)
|
12416 | }, function () {
|
12417 | _this.listItemsRef.current.scrollTop = _this.listItemsRef.current.scrollHeight;
|
12418 | });
|
12419 | };
|
12420 | };
|
12421 |
|
12422 | ChatBot.prototype.componentDidMount = function () {
|
12423 | var _a = this.props,
|
12424 | onComplete = _a.onComplete,
|
12425 | botName = _a.botName;
|
12426 |
|
12427 | if (onComplete && botName) {
|
12428 | if (!interactions_1.Interactions || typeof interactions_1.Interactions.onComplete !== 'function') {
|
12429 | throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
|
12430 | }
|
12431 |
|
12432 |
|
12433 | interactions_1.Interactions.onComplete(botName, this.getOnComplete(onComplete, this));
|
12434 | }
|
12435 | };
|
12436 |
|
12437 | ChatBot.prototype.componentDidUpdate = function (prevProps) {
|
12438 | var _a = this.props,
|
12439 | onComplete = _a.onComplete,
|
12440 | botName = _a.botName;
|
12441 |
|
12442 | if (botName && this.props.onComplete !== prevProps.onComplete) {
|
12443 | if (!interactions_1.Interactions || typeof interactions_1.Interactions.onComplete !== 'function') {
|
12444 | throw new Error('No Interactions module found, please ensure @aws-amplify/interactions is imported');
|
12445 | }
|
12446 |
|
12447 |
|
12448 | interactions_1.Interactions.onComplete(botName, this.getOnComplete(onComplete, this));
|
12449 | }
|
12450 | };
|
12451 |
|
12452 | ChatBot.prototype.render = function () {
|
12453 | var _a = this.props,
|
12454 | title = _a.title,
|
12455 | theme = _a.theme,
|
12456 | onComplete = _a.onComplete;
|
12457 | return React.createElement(AmplifyUI_1.FormSection, {
|
12458 | theme: theme
|
12459 | }, title && React.createElement(AmplifyUI_1.SectionHeader, {
|
12460 | theme: theme,
|
12461 | "data-test": data_test_attributes_1.chatBot.title
|
12462 | }, core_1.I18n.get(title)), React.createElement(AmplifyUI_1.SectionBody, {
|
12463 | theme: theme
|
12464 | }, React.createElement("div", {
|
12465 | ref: this.listItemsRef,
|
12466 | style: styles.list
|
12467 | }, this.listItems())), React.createElement(AmplifyUI_1.SectionFooter, {
|
12468 | theme: theme
|
12469 | }, React.createElement(ChatBotInputs, {
|
12470 | micText: this.state.micText,
|
12471 | voiceEnabled: this.props.voiceEnabled,
|
12472 | textEnabled: this.props.textEnabled,
|
12473 | styles: styles,
|
12474 | onChange: this.changeInputText,
|
12475 | inputText: this.state.inputText,
|
12476 | onSubmit: this.submit,
|
12477 | inputDisabled: this.state.inputDisabled,
|
12478 | micButtonDisabled: this.state.micButtonDisabled,
|
12479 | handleMicButton: this.micButtonHandler,
|
12480 | currentVoiceState: this.state.currentVoiceState
|
12481 | })));
|
12482 | };
|
12483 |
|
12484 | return ChatBot;
|
12485 | }(React.Component);
|
12486 |
|
12487 | exports.ChatBot = ChatBot;
|
12488 |
|
12489 | function ChatBotTextInput(props) {
|
12490 | var styles = props.styles;
|
12491 | var onChange = props.onChange;
|
12492 | var inputText = props.inputText;
|
12493 | var inputDisabled = props.inputDisabled;
|
12494 | var currentVoiceState = props.currentVoiceState;
|
12495 | return React.createElement("input", {
|
12496 | style: styles.textInput,
|
12497 | type: "text",
|
12498 | placeholder: core_1.I18n.get(currentVoiceState.MESSAGE),
|
12499 | onChange: onChange,
|
12500 | value: inputText,
|
12501 | disabled: inputDisabled,
|
12502 | "data-test": data_test_attributes_1.chatBot.messageInput
|
12503 | });
|
12504 | }
|
12505 |
|
12506 | function ChatBotMicButton(props) {
|
12507 | var voiceEnabled = props.voiceEnabled;
|
12508 | var styles = props.styles;
|
12509 | var micButtonDisabled = props.micButtonDisabled;
|
12510 | var handleMicButton = props.handleMicButton;
|
12511 | var micText = props.micText;
|
12512 |
|
12513 | if (!voiceEnabled) {
|
12514 | return null;
|
12515 | }
|
12516 |
|
12517 | return React.createElement("button", {
|
12518 | style: styles.mic,
|
12519 | disabled: micButtonDisabled,
|
12520 | onClick: handleMicButton
|
12521 | }, micText);
|
12522 | }
|
12523 |
|
12524 | function ChatBotTextButton(props) {
|
12525 | var textEnabled = props.textEnabled;
|
12526 | var styles = props.styles;
|
12527 | var inputDisabled = props.inputDisabled;
|
12528 |
|
12529 | if (!textEnabled) {
|
12530 | return null;
|
12531 | }
|
12532 |
|
12533 | return React.createElement("button", {
|
12534 | type: "submit",
|
12535 | style: styles.button,
|
12536 | disabled: inputDisabled,
|
12537 | "data-test": data_test_attributes_1.chatBot.sendMessageButton
|
12538 | }, core_1.I18n.get('Send'));
|
12539 | }
|
12540 |
|
12541 | function ChatBotInputs(props) {
|
12542 | var voiceEnabled = props.voiceEnabled;
|
12543 | var textEnabled = props.textEnabled;
|
12544 | var styles = props.styles;
|
12545 | var onChange = props.onChange;
|
12546 | var inputDisabled = props.inputDisabled;
|
12547 | var micButtonDisabled = props.micButtonDisabled;
|
12548 | var inputText = props.inputText;
|
12549 | var onSubmit = props.onSubmit;
|
12550 | var handleMicButton = props.handleMicButton;
|
12551 | var micText = props.micText;
|
12552 | var currentVoiceState = props.currentVoiceState;
|
12553 |
|
12554 | if (voiceEnabled && !textEnabled) {
|
12555 | inputDisabled = true;
|
12556 | }
|
12557 |
|
12558 | if (!voiceEnabled && !textEnabled) {
|
12559 | return React.createElement("div", null, "No Chatbot inputs enabled. Set at least one of voiceEnabled or textEnabled in the props.", ' ');
|
12560 | }
|
12561 |
|
12562 | return React.createElement("form", {
|
12563 | onSubmit: onSubmit
|
12564 | }, React.createElement(ChatBotTextInput, {
|
12565 | onSubmit: onSubmit,
|
12566 | styles: styles,
|
12567 | type: "text",
|
12568 | currentVoiceState: currentVoiceState,
|
12569 | onChange: onChange,
|
12570 | inputText: inputText,
|
12571 | inputDisabled: inputDisabled
|
12572 | }), React.createElement(ChatBotTextButton, {
|
12573 | onSubmit: onSubmit,
|
12574 | type: "submit",
|
12575 | styles: styles,
|
12576 | inputDisabled: inputDisabled,
|
12577 | textEnabled: textEnabled
|
12578 | }), React.createElement(ChatBotMicButton, {
|
12579 | styles: styles,
|
12580 | micButtonDisabled: micButtonDisabled,
|
12581 | handleMicButton: handleMicButton,
|
12582 | micText: micText,
|
12583 | voiceEnabled: voiceEnabled
|
12584 | }));
|
12585 | }
|
12586 |
|
12587 |
|
12588 | ChatBot.defaultProps = {
|
12589 | title: '',
|
12590 | botName: '',
|
12591 | onComplete: undefined,
|
12592 | clearOnComplete: false,
|
12593 | voiceConfig: defaultVoiceConfig,
|
12594 | conversationModeOn: false,
|
12595 | voiceEnabled: false,
|
12596 | textEnabled: true
|
12597 | };
|
12598 |
|
12599 |
|
12600 |
|
12601 |
|
12602 | exports["default"] = ChatBot;
|
12603 | }.call(this, __webpack_require__( "../../node_modules/webpack/buildin/global.js")))
|
12604 |
|
12605 | }),
|
12606 |
|
12607 | "./lib/Interactions/aws-lex-audio.js":
|
12608 |
|
12609 |
|
12610 |
|
12611 |
|
12612 | (function(module, exports, __webpack_require__) {
|
12613 |
|
12614 | (function(global) {var require;var require;
|
12615 |
|
12616 |
|
12617 |
|
12618 |
|
12619 |
|
12620 |
|
12621 |
|
12622 |
|
12623 |
|
12624 |
|
12625 |
|
12626 |
|
12627 | (function e(t, n, r) {
|
12628 | function s(o, u) {
|
12629 | if (!n[o]) {
|
12630 | if (!t[o]) {
|
12631 | var a = typeof require == 'function' && require;
|
12632 |
|
12633 | if (!u && a) return require(o, !0);
|
12634 |
|
12635 | if (i) return i(o, !0);
|
12636 | var f = new Error("Cannot find module '" + o + "'");
|
12637 |
|
12638 | throw f.code = 'MODULE_NOT_FOUND', f;
|
12639 | }
|
12640 |
|
12641 | var l = n[o] = {
|
12642 | exports: {}
|
12643 | };
|
12644 | t[o][0].call(l.exports, function (e) {
|
12645 | var n = t[o][1][e];
|
12646 |
|
12647 | return s(n ? n : e);
|
12648 | }, l, l.exports, e, t, n, r);
|
12649 | }
|
12650 |
|
12651 | return n[o].exports;
|
12652 | }
|
12653 |
|
12654 | var i = typeof require == 'function' && require;
|
12655 |
|
12656 | for (var o = 0; o < r.length; o++) {
|
12657 | s(r[o]);
|
12658 | }
|
12659 |
|
12660 | return s;
|
12661 | })({
|
12662 | 1: [function (require, module, exports) {
|
12663 | (function () {
|
12664 | 'use strict';
|
12665 |
|
12666 | var rec = require('./recorder.js');
|
12667 |
|
12668 | var recorder,
|
12669 | audioRecorder,
|
12670 | checkAudioSupport,
|
12671 | audioSupported,
|
12672 | playbackSource,
|
12673 | UNSUPPORTED = 'Audio is not supported.';
|
12674 | |
12675 |
|
12676 |
|
12677 |
|
12678 |
|
12679 |
|
12680 | exports.audioControl = function (options) {
|
12681 | options = options || {};
|
12682 | this.checkAudioSupport = options.checkAudioSupport !== false;
|
12683 | |
12684 |
|
12685 |
|
12686 |
|
12687 |
|
12688 |
|
12689 | |
12690 |
|
12691 |
|
12692 |
|
12693 |
|
12694 |
|
12695 |
|
12696 |
|
12697 | |
12698 |
|
12699 |
|
12700 |
|
12701 |
|
12702 |
|
12703 |
|
12704 |
|
12705 |
|
12706 | var startRecording = function startRecording(onSilence, visualizer, silenceDetectionConfig) {
|
12707 | onSilence = onSilence || function () {
|
12708 |
|
12709 | };
|
12710 |
|
12711 | visualizer = visualizer || function () {
|
12712 |
|
12713 | };
|
12714 |
|
12715 | audioSupported = audioSupported !== false;
|
12716 |
|
12717 | if (!audioSupported) {
|
12718 | throw new Error(UNSUPPORTED);
|
12719 | }
|
12720 |
|
12721 | var context = audioRecorder.audioContext();
|
12722 | context.resume().then(function () {
|
12723 | recorder = audioRecorder.createRecorder(silenceDetectionConfig);
|
12724 | recorder.record(onSilence, visualizer);
|
12725 | });
|
12726 | };
|
12727 | |
12728 |
|
12729 |
|
12730 |
|
12731 |
|
12732 |
|
12733 |
|
12734 | var stopRecording = function stopRecording() {
|
12735 | audioSupported = audioSupported !== false;
|
12736 |
|
12737 | if (!audioSupported) {
|
12738 | throw new Error(UNSUPPORTED);
|
12739 | }
|
12740 |
|
12741 | recorder.stop();
|
12742 | };
|
12743 | |
12744 |
|
12745 |
|
12746 |
|
12747 |
|
12748 |
|
12749 |
|
12750 | |
12751 |
|
12752 |
|
12753 |
|
12754 |
|
12755 |
|
12756 |
|
12757 |
|
12758 |
|
12759 | var exportWAV = function exportWAV(callback, sampleRate) {
|
12760 | audioSupported = audioSupported !== false;
|
12761 |
|
12762 | if (!audioSupported) {
|
12763 | throw new Error(UNSUPPORTED);
|
12764 | }
|
12765 |
|
12766 | if (!(callback && typeof callback === 'function')) {
|
12767 | throw new Error('You must pass a callback function to export.');
|
12768 | }
|
12769 |
|
12770 | sampleRate = typeof sampleRate !== 'undefined' ? sampleRate : 16000;
|
12771 | recorder.exportWAV(callback, sampleRate);
|
12772 | recorder.clear();
|
12773 | };
|
12774 | |
12775 |
|
12776 |
|
12777 |
|
12778 |
|
12779 |
|
12780 | |
12781 |
|
12782 |
|
12783 |
|
12784 |
|
12785 |
|
12786 |
|
12787 | var playHtmlAudioElement = function playHtmlAudioElement(buffer, callback) {
|
12788 | if (typeof buffer === 'undefined') {
|
12789 | return;
|
12790 | }
|
12791 |
|
12792 | var myBlob = new Blob([buffer]);
|
12793 | var audio = document.createElement('audio');
|
12794 | var objectUrl = window.URL.createObjectURL(myBlob);
|
12795 | audio.src = objectUrl;
|
12796 | audio.addEventListener('ended', function () {
|
12797 | audio.currentTime = 0;
|
12798 |
|
12799 | if (typeof callback === 'function') {
|
12800 | callback();
|
12801 | }
|
12802 | });
|
12803 | audio.play();
|
12804 | };
|
12805 | |
12806 |
|
12807 |
|
12808 |
|
12809 |
|
12810 |
|
12811 | |
12812 |
|
12813 |
|
12814 |
|
12815 |
|
12816 |
|
12817 |
|
12818 | var play = function play(buffer, callback) {
|
12819 | if (typeof buffer === 'undefined') {
|
12820 | return;
|
12821 | }
|
12822 |
|
12823 | var myBlob = new Blob([buffer]);
|
12824 |
|
12825 | var fileReader = new FileReader();
|
12826 |
|
12827 | fileReader.onload = function () {
|
12828 |
|
12829 | playbackSource = audioRecorder.audioContext().createBufferSource();
|
12830 | audioRecorder.audioContext().decodeAudioData(this.result, function (buf) {
|
12831 |
|
12832 | playbackSource.buffer = buf;
|
12833 |
|
12834 | playbackSource.connect(audioRecorder.audioContext().destination);
|
12835 |
|
12836 | playbackSource.onended = function (event) {
|
12837 | if (typeof callback === 'function') {
|
12838 | callback();
|
12839 | }
|
12840 | };
|
12841 |
|
12842 |
|
12843 | playbackSource.start(0);
|
12844 | });
|
12845 | };
|
12846 |
|
12847 | fileReader.readAsArrayBuffer(myBlob);
|
12848 | };
|
12849 | |
12850 |
|
12851 |
|
12852 |
|
12853 |
|
12854 |
|
12855 | var stop = function stop() {
|
12856 | if (typeof playbackSource === 'undefined') {
|
12857 | return;
|
12858 | }
|
12859 |
|
12860 | playbackSource.stop();
|
12861 | };
|
12862 | |
12863 |
|
12864 |
|
12865 |
|
12866 |
|
12867 | var clear = function clear() {
|
12868 | recorder.clear();
|
12869 | };
|
12870 | |
12871 |
|
12872 |
|
12873 |
|
12874 |
|
12875 |
|
12876 |
|
12877 | |
12878 |
|
12879 |
|
12880 |
|
12881 |
|
12882 |
|
12883 | var supportsAudio = function supportsAudio(callback) {
|
12884 | callback = callback || function () {
|
12885 |
|
12886 | };
|
12887 |
|
12888 | if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
12889 | audioRecorder = rec.audioRecorder();
|
12890 | audioRecorder.requestDevice().then(function (stream) {
|
12891 | audioSupported = true;
|
12892 | callback(audioSupported);
|
12893 | })["catch"](function (error) {
|
12894 | audioSupported = false;
|
12895 | callback(audioSupported);
|
12896 | });
|
12897 | } else {
|
12898 | audioSupported = false;
|
12899 | callback(audioSupported);
|
12900 | }
|
12901 | };
|
12902 |
|
12903 | if (this.checkAudioSupport) {
|
12904 |
|
12905 | supportsAudio();
|
12906 | }
|
12907 |
|
12908 | return {
|
12909 | startRecording: startRecording,
|
12910 | stopRecording: stopRecording,
|
12911 | exportWAV: exportWAV,
|
12912 | play: play,
|
12913 | stop: stop,
|
12914 | clear: clear,
|
12915 | playHtmlAudioElement: playHtmlAudioElement,
|
12916 | supportsAudio: supportsAudio
|
12917 | };
|
12918 | };
|
12919 | })();
|
12920 | }, {
|
12921 | './recorder.js': 5
|
12922 | }],
|
12923 | 2: [function (require, module, exports) {
|
12924 | (function () {
|
12925 | 'use strict';
|
12926 |
|
12927 | var AudioControl = require('./control.js').audioControl;
|
12928 |
|
12929 | var DEFAULT_LATEST = '$LATEST';
|
12930 | var DEFAULT_CONTENT_TYPE = 'audio/x-l16; sample-rate=16000';
|
12931 | var DEFAULT_USER_ID = 'userId';
|
12932 | var DEFAULT_ACCEPT_HEADER_VALUE = 'audio/mpeg';
|
12933 | var MESSAGES = Object.freeze({
|
12934 | PASSIVE: 'Passive',
|
12935 | LISTENING: 'Listening',
|
12936 | SENDING: 'Sending',
|
12937 | SPEAKING: 'Speaking'
|
12938 | });
|
12939 | var lexruntime,
|
12940 | audioControl = new AudioControl({
|
12941 | checkAudioSupport: false
|
12942 | });
|
12943 |
|
12944 | exports.conversation = function (config, onStateChange, onSuccess, onError, onAudioData) {
|
12945 | var currentState;
|
12946 |
|
12947 | this.config = applyDefaults(config);
|
12948 | this.lexConfig = this.config.lexConfig;
|
12949 | this.messages = MESSAGES;
|
12950 |
|
12951 | onStateChange = onStateChange || function () {
|
12952 |
|
12953 | };
|
12954 |
|
12955 | this.onSuccess = onSuccess || function () {
|
12956 |
|
12957 | };
|
12958 |
|
12959 | this.onError = onError || function () {
|
12960 |
|
12961 | };
|
12962 |
|
12963 | this.onAudioData = onAudioData || function () {
|
12964 |
|
12965 | };
|
12966 |
|
12967 |
|
12968 | if (!this.config.lexConfig.botName) {
|
12969 | this.onError('A Bot name must be provided.');
|
12970 | return;
|
12971 | }
|
12972 |
|
12973 |
|
12974 | if (!AWS.config.credentials) {
|
12975 | this.onError('AWS Credentials must be provided.');
|
12976 | return;
|
12977 | }
|
12978 |
|
12979 |
|
12980 | if (!AWS.config.region) {
|
12981 | this.onError('A Region value must be provided.');
|
12982 | return;
|
12983 | }
|
12984 |
|
12985 |
|
12986 | lexruntime = new AWS.LexRuntime();
|
12987 |
|
12988 | this.onSilence = function () {
|
12989 | if (config.silenceDetection) {
|
12990 | audioControl.stopRecording();
|
12991 | currentState.advanceConversation();
|
12992 | }
|
12993 | };
|
12994 |
|
12995 | this.transition = function (conversation) {
|
12996 | currentState = conversation;
|
12997 | var state = currentState.state;
|
12998 | onStateChange(state.message);
|
12999 |
|
13000 |
|
13001 | if (state.message === state.messages.SENDING || state.message === state.messages.SPEAKING) {
|
13002 | currentState.advanceConversation();
|
13003 | }
|
13004 |
|
13005 |
|
13006 |
|
13007 | if (state.message === state.messages.SENDING && !this.config.silenceDetection) {
|
13008 | audioControl.stopRecording();
|
13009 | }
|
13010 | };
|
13011 |
|
13012 | this.advanceConversation = function () {
|
13013 | audioControl.supportsAudio(function (supported) {
|
13014 | if (supported) {
|
13015 | currentState.advanceConversation();
|
13016 | } else {
|
13017 | onError('Audio is not supported.');
|
13018 | }
|
13019 | });
|
13020 | };
|
13021 |
|
13022 | this.updateConfig = function (newValue) {
|
13023 | this.config = applyDefaults(newValue);
|
13024 | this.lexConfig = this.config.lexConfig;
|
13025 | };
|
13026 |
|
13027 | this.reset = function () {
|
13028 | audioControl.clear();
|
13029 | currentState = new Initial(currentState.state);
|
13030 | };
|
13031 |
|
13032 | currentState = new Initial(this);
|
13033 | return {
|
13034 | advanceConversation: this.advanceConversation,
|
13035 | updateConfig: this.updateConfig,
|
13036 | reset: this.reset
|
13037 | };
|
13038 | };
|
13039 |
|
13040 | var Initial = function Initial(state) {
|
13041 | this.state = state;
|
13042 | state.message = state.messages.PASSIVE;
|
13043 |
|
13044 | this.advanceConversation = function () {
|
13045 | audioControl.startRecording(state.onSilence, state.onAudioData, state.config.silenceDetectionConfig);
|
13046 | state.transition(new Listening(state));
|
13047 | };
|
13048 | };
|
13049 |
|
13050 | var Listening = function Listening(state) {
|
13051 | this.state = state;
|
13052 | state.message = state.messages.LISTENING;
|
13053 |
|
13054 | this.advanceConversation = function () {
|
13055 | audioControl.exportWAV(function (blob) {
|
13056 | state.audioInput = blob;
|
13057 | state.transition(new Sending(state));
|
13058 | });
|
13059 | };
|
13060 | };
|
13061 |
|
13062 | var Sending = function Sending(state) {
|
13063 | this.state = state;
|
13064 | state.message = state.messages.SENDING;
|
13065 |
|
13066 | this.advanceConversation = function () {
|
13067 | state.lexConfig.inputStream = state.audioInput;
|
13068 | lexruntime.postContent(state.lexConfig, function (err, data) {
|
13069 | if (err) {
|
13070 | state.onError(err);
|
13071 | state.transition(new Initial(state));
|
13072 | } else {
|
13073 | state.audioOutput = data;
|
13074 | state.transition(new Speaking(state));
|
13075 | state.onSuccess(data);
|
13076 | }
|
13077 | });
|
13078 | };
|
13079 | };
|
13080 |
|
13081 | var Speaking = function Speaking(state) {
|
13082 | this.state = state;
|
13083 | state.message = state.messages.SPEAKING;
|
13084 |
|
13085 | this.advanceConversation = function () {
|
13086 | if (state.audioOutput.contentType === 'audio/mpeg') {
|
13087 | audioControl.play(state.audioOutput.audioStream, function () {
|
13088 | if (state.audioOutput.dialogState === 'ReadyForFulfillment' || state.audioOutput.dialogState === 'Fulfilled' || state.audioOutput.dialogState === 'Failed' || !state.config.silenceDetection) {
|
13089 | state.transition(new Initial(state));
|
13090 | } else {
|
13091 | audioControl.startRecording(state.onSilence, state.onAudioData, state.config.silenceDetectionConfig);
|
13092 | state.transition(new Listening(state));
|
13093 | }
|
13094 | });
|
13095 | } else {
|
13096 | state.transition(new Initial(state));
|
13097 | }
|
13098 | };
|
13099 | };
|
13100 |
|
13101 | var applyDefaults = function applyDefaults(config) {
|
13102 | config = config || {};
|
13103 | config.silenceDetection = config.hasOwnProperty('silenceDetection') ? config.silenceDetection : true;
|
13104 | var lexConfig = config.lexConfig || {};
|
13105 | lexConfig.botAlias = lexConfig.hasOwnProperty('botAlias') ? lexConfig.botAlias : DEFAULT_LATEST;
|
13106 | lexConfig.botName = lexConfig.hasOwnProperty('botName') ? lexConfig.botName : '';
|
13107 | lexConfig.contentType = lexConfig.hasOwnProperty('contentType') ? lexConfig.contentType : DEFAULT_CONTENT_TYPE;
|
13108 | lexConfig.userId = lexConfig.hasOwnProperty('userId') ? lexConfig.userId : DEFAULT_USER_ID;
|
13109 | lexConfig.accept = lexConfig.hasOwnProperty('accept') ? lexConfig.accept : DEFAULT_ACCEPT_HEADER_VALUE;
|
13110 | config.lexConfig = lexConfig;
|
13111 | return config;
|
13112 | };
|
13113 | })();
|
13114 | }, {
|
13115 | './control.js': 1
|
13116 | }],
|
13117 | 3: [function (require, module, exports) {
|
13118 | (function (global) {
|
13119 | |
13120 |
|
13121 |
|
13122 |
|
13123 | global.LexAudio = global.LexAudio || {};
|
13124 | global.LexAudio.audioControl = require('./control.js').audioControl;
|
13125 | global.LexAudio.conversation = require('./conversation.js').conversation;
|
13126 | module.exports = global.LexAudio;
|
13127 | }).call(this, typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : {});
|
13128 | }, {
|
13129 | './control.js': 1,
|
13130 | './conversation.js': 2
|
13131 | }],
|
13132 | 4: [function (require, module, exports) {
|
13133 | var bundleFn = arguments[3];
|
13134 | var sources = arguments[4];
|
13135 | var cache = arguments[5];
|
13136 | var stringify = JSON.stringify;
|
13137 |
|
13138 | module.exports = function (fn, options) {
|
13139 | var wkey;
|
13140 | var cacheKeys = Object.keys(cache);
|
13141 |
|
13142 | for (var i = 0, l = cacheKeys.length; i < l; i++) {
|
13143 | var key = cacheKeys[i];
|
13144 | var exp = cache[key].exports;
|
13145 |
|
13146 |
|
13147 |
|
13148 |
|
13149 | if (exp === fn || exp && exp["default"] === fn) {
|
13150 | wkey = key;
|
13151 | break;
|
13152 | }
|
13153 | }
|
13154 |
|
13155 | if (!wkey) {
|
13156 | wkey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
|
13157 | var wcache = {};
|
13158 |
|
13159 | for (var i = 0, l = cacheKeys.length; i < l; i++) {
|
13160 | var key = cacheKeys[i];
|
13161 | wcache[key] = key;
|
13162 | }
|
13163 |
|
13164 | sources[wkey] = [
|
13165 | Function(['require', 'module', 'exports'], '(' + fn + ')(self)'), wcache];
|
13166 | }
|
13167 |
|
13168 | var skey = Math.floor(Math.pow(16, 8) * Math.random()).toString(16);
|
13169 | var scache = {};
|
13170 | scache[wkey] = wkey;
|
13171 | sources[skey] = [
|
13172 | Function(
|
13173 | ['require'],
|
13174 |
|
13175 | 'var f = require(' + stringify(wkey) + ');' + '(f.default ? f.default : f)(self);'), scache];
|
13176 | var workerSources = {};
|
13177 | resolveSources(skey);
|
13178 |
|
13179 | function resolveSources(key) {
|
13180 | workerSources[key] = true;
|
13181 |
|
13182 | for (var depPath in sources[key][1]) {
|
13183 | var depKey = sources[key][1][depPath];
|
13184 |
|
13185 | if (!workerSources[depKey]) {
|
13186 | resolveSources(depKey);
|
13187 | }
|
13188 | }
|
13189 | }
|
13190 |
|
13191 | var src = '(' + bundleFn + ')({' + Object.keys(workerSources).map(function (key) {
|
13192 | return stringify(key) + ':[' + sources[key][0] + ',' + stringify(sources[key][1]) + ']';
|
13193 | }).join(',') + '},{},[' + stringify(skey) + '])';
|
13194 |
|
13195 | var URL =
|
13196 | window.URL || window.webkitURL || window.mozURL || window.msURL;
|
13197 | var blob = new Blob([src], {
|
13198 | type: 'text/javascript'
|
13199 | });
|
13200 |
|
13201 | if (options && options.bare) {
|
13202 | return blob;
|
13203 | }
|
13204 |
|
13205 | var workerUrl = URL.createObjectURL(blob);
|
13206 | var worker = new Worker(workerUrl);
|
13207 |
|
13208 | worker.objectURL = workerUrl;
|
13209 | return worker;
|
13210 | };
|
13211 | }, {}],
|
13212 | 5: [function (require, module, exports) {
|
13213 | (function () {
|
13214 | 'use strict';
|
13215 |
|
13216 | var work = require('webworkify');
|
13217 |
|
13218 | var worker = work(require('./worker.js'));
|
13219 | var audio_context, audio_stream;
|
13220 | |
13221 |
|
13222 |
|
13223 |
|
13224 |
|
13225 | var recorder = function recorder(source, silenceDetectionConfig) {
|
13226 | silenceDetectionConfig = silenceDetectionConfig || {};
|
13227 | silenceDetectionConfig.time = silenceDetectionConfig.hasOwnProperty('time') ? silenceDetectionConfig.time : 1500;
|
13228 | silenceDetectionConfig.amplitude = silenceDetectionConfig.hasOwnProperty('amplitude') ? silenceDetectionConfig.amplitude : 0.2;
|
13229 | var recording = false,
|
13230 | currCallback,
|
13231 | start,
|
13232 | silenceCallback,
|
13233 | visualizationCallback;
|
13234 |
|
13235 | var node = source.context.createScriptProcessor(4096, 1, 1);
|
13236 |
|
13237 | worker.onmessage = function (message) {
|
13238 | var blob = message.data;
|
13239 | currCallback(blob);
|
13240 | };
|
13241 |
|
13242 | worker.postMessage({
|
13243 | command: 'init',
|
13244 | config: {
|
13245 | sampleRate: source.context.sampleRate
|
13246 | }
|
13247 | });
|
13248 | |
13249 |
|
13250 |
|
13251 |
|
13252 |
|
13253 |
|
13254 | var record = function record(onSilence, visualizer) {
|
13255 | silenceCallback = onSilence;
|
13256 | visualizationCallback = visualizer;
|
13257 | start = Date.now();
|
13258 | recording = true;
|
13259 | };
|
13260 | |
13261 |
|
13262 |
|
13263 |
|
13264 |
|
13265 | var stop = function stop() {
|
13266 | recording = false;
|
13267 | };
|
13268 | |
13269 |
|
13270 |
|
13271 |
|
13272 |
|
13273 | var clear = function clear() {
|
13274 | stop();
|
13275 | worker.postMessage({
|
13276 | command: 'clear'
|
13277 | });
|
13278 | };
|
13279 | |
13280 |
|
13281 |
|
13282 |
|
13283 |
|
13284 |
|
13285 |
|
13286 | var exportWAV = function exportWAV(callback, sampleRate) {
|
13287 | currCallback = callback;
|
13288 | worker.postMessage({
|
13289 | command: 'export',
|
13290 | sampleRate: sampleRate
|
13291 | });
|
13292 | };
|
13293 | |
13294 |
|
13295 |
|
13296 |
|
13297 |
|
13298 |
|
13299 |
|
13300 |
|
13301 | var analyse = function analyse() {
|
13302 | analyser.fftSize = 2048;
|
13303 | var bufferLength = analyser.fftSize;
|
13304 | var dataArray = new Uint8Array(bufferLength);
|
13305 | var amplitude = silenceDetectionConfig.amplitude;
|
13306 | var time = silenceDetectionConfig.time;
|
13307 | analyser.getByteTimeDomainData(dataArray);
|
13308 |
|
13309 | if (typeof visualizationCallback === 'function') {
|
13310 | visualizationCallback(dataArray, bufferLength);
|
13311 | }
|
13312 |
|
13313 | for (var i = 0; i < bufferLength; i++) {
|
13314 |
|
13315 | var curr_value_time = dataArray[i] / 128 - 1.0;
|
13316 |
|
13317 | if (curr_value_time > amplitude || curr_value_time < -1 * amplitude) {
|
13318 | start = Date.now();
|
13319 | }
|
13320 | }
|
13321 |
|
13322 | var newtime = Date.now();
|
13323 | var elapsedTime = newtime - start;
|
13324 |
|
13325 | if (elapsedTime > time) {
|
13326 | silenceCallback();
|
13327 | }
|
13328 | };
|
13329 | |
13330 |
|
13331 |
|
13332 |
|
13333 |
|
13334 |
|
13335 |
|
13336 | node.onaudioprocess = function (audioProcessingEvent) {
|
13337 | if (!recording) {
|
13338 | return;
|
13339 | }
|
13340 |
|
13341 | worker.postMessage({
|
13342 | command: 'record',
|
13343 | buffer: [audioProcessingEvent.inputBuffer.getChannelData(0)]
|
13344 | });
|
13345 | analyse();
|
13346 | };
|
13347 |
|
13348 | var analyser = source.context.createAnalyser();
|
13349 | analyser.minDecibels = -90;
|
13350 | analyser.maxDecibels = -10;
|
13351 | analyser.smoothingTimeConstant = 0.85;
|
13352 | source.connect(analyser);
|
13353 | analyser.connect(node);
|
13354 | node.connect(source.context.destination);
|
13355 | return {
|
13356 | record: record,
|
13357 | stop: stop,
|
13358 | clear: clear,
|
13359 | exportWAV: exportWAV
|
13360 | };
|
13361 | };
|
13362 | |
13363 |
|
13364 |
|
13365 |
|
13366 |
|
13367 |
|
13368 | exports.audioRecorder = function () {
|
13369 | |
13370 |
|
13371 |
|
13372 | var requestDevice = function requestDevice() {
|
13373 | if (typeof audio_context === 'undefined') {
|
13374 |
|
13375 | window.AudioContext =
|
13376 | window.AudioContext || window.webkitAudioContext;
|
13377 | audio_context = new AudioContext();
|
13378 | }
|
13379 |
|
13380 | return navigator.mediaDevices.getUserMedia({
|
13381 | audio: true
|
13382 | }).then(function (stream) {
|
13383 | audio_stream = stream;
|
13384 | });
|
13385 | };
|
13386 |
|
13387 | var createRecorder = function createRecorder(silenceDetectionConfig) {
|
13388 | return recorder(audio_context.createMediaStreamSource(audio_stream), silenceDetectionConfig);
|
13389 | };
|
13390 |
|
13391 | var audioContext = function audioContext() {
|
13392 | return audio_context;
|
13393 | };
|
13394 |
|
13395 | return {
|
13396 | requestDevice: requestDevice,
|
13397 | createRecorder: createRecorder,
|
13398 | audioContext: audioContext
|
13399 | };
|
13400 | };
|
13401 | })();
|
13402 | }, {
|
13403 | './worker.js': 6,
|
13404 | webworkify: 4
|
13405 | }],
|
13406 | 6: [function (require, module, exports) {
|
13407 | module.exports = function (self) {
|
13408 | 'use strict';
|
13409 |
|
13410 | var recLength = 0,
|
13411 | recBuffer = [],
|
13412 | recordSampleRate;
|
13413 | self.addEventListener('message', function (e) {
|
13414 | switch (e.data.command) {
|
13415 | case 'init':
|
13416 | init(e.data.config);
|
13417 | break;
|
13418 |
|
13419 | case 'record':
|
13420 | record(e.data.buffer);
|
13421 | break;
|
13422 |
|
13423 | case 'export':
|
13424 | exportBuffer(e.data.sampleRate);
|
13425 | break;
|
13426 |
|
13427 | case 'clear':
|
13428 | clear();
|
13429 | break;
|
13430 | }
|
13431 | });
|
13432 |
|
13433 | function init(config) {
|
13434 | recordSampleRate = config.sampleRate;
|
13435 | }
|
13436 |
|
13437 | function record(inputBuffer) {
|
13438 | recBuffer.push(inputBuffer[0]);
|
13439 | recLength += inputBuffer[0].length;
|
13440 | }
|
13441 |
|
13442 | function exportBuffer(exportSampleRate) {
|
13443 | var mergedBuffers = mergeBuffers(recBuffer, recLength);
|
13444 | var downsampledBuffer = downsampleBuffer(mergedBuffers, exportSampleRate);
|
13445 | var encodedWav = encodeWAV(downsampledBuffer);
|
13446 | var audioBlob = new Blob([encodedWav], {
|
13447 | type: 'application/octet-stream'
|
13448 | });
|
13449 |
|
13450 | postMessage(audioBlob);
|
13451 | }
|
13452 |
|
13453 | function clear() {
|
13454 | recLength = 0;
|
13455 | recBuffer = [];
|
13456 | }
|
13457 |
|
13458 | function downsampleBuffer(buffer, exportSampleRate) {
|
13459 | if (exportSampleRate === recordSampleRate) {
|
13460 | return buffer;
|
13461 | }
|
13462 |
|
13463 | var sampleRateRatio = recordSampleRate / exportSampleRate;
|
13464 | var newLength = Math.round(buffer.length / sampleRateRatio);
|
13465 | var result = new Float32Array(newLength);
|
13466 | var offsetResult = 0;
|
13467 | var offsetBuffer = 0;
|
13468 |
|
13469 | while (offsetResult < result.length) {
|
13470 | var nextOffsetBuffer = Math.round((offsetResult + 1) * sampleRateRatio);
|
13471 | var accum = 0,
|
13472 | count = 0;
|
13473 |
|
13474 | for (var i = offsetBuffer; i < nextOffsetBuffer && i < buffer.length; i++) {
|
13475 | accum += buffer[i];
|
13476 | count++;
|
13477 | }
|
13478 |
|
13479 | result[offsetResult] = accum / count;
|
13480 | offsetResult++;
|
13481 | offsetBuffer = nextOffsetBuffer;
|
13482 | }
|
13483 |
|
13484 | return result;
|
13485 | }
|
13486 |
|
13487 | function mergeBuffers(bufferArray, recLength) {
|
13488 | var result = new Float32Array(recLength);
|
13489 | var offset = 0;
|
13490 |
|
13491 | for (var i = 0; i < bufferArray.length; i++) {
|
13492 | result.set(bufferArray[i], offset);
|
13493 | offset += bufferArray[i].length;
|
13494 | }
|
13495 |
|
13496 | return result;
|
13497 | }
|
13498 |
|
13499 | function floatTo16BitPCM(output, offset, input) {
|
13500 | for (var i = 0; i < input.length; i++, offset += 2) {
|
13501 | var s = Math.max(-1, Math.min(1, input[i]));
|
13502 | output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
|
13503 | }
|
13504 | }
|
13505 |
|
13506 | function writeString(view, offset, string) {
|
13507 | for (var i = 0; i < string.length; i++) {
|
13508 | view.setUint8(offset + i, string.charCodeAt(i));
|
13509 | }
|
13510 | }
|
13511 |
|
13512 | function encodeWAV(samples) {
|
13513 | var buffer = new ArrayBuffer(44 + samples.length * 2);
|
13514 | var view = new DataView(buffer);
|
13515 | writeString(view, 0, 'RIFF');
|
13516 | view.setUint32(4, 32 + samples.length * 2, true);
|
13517 | writeString(view, 8, 'WAVE');
|
13518 | writeString(view, 12, 'fmt ');
|
13519 | view.setUint32(16, 16, true);
|
13520 | view.setUint16(20, 1, true);
|
13521 | view.setUint16(22, 1, true);
|
13522 | view.setUint32(24, recordSampleRate, true);
|
13523 | view.setUint32(28, recordSampleRate * 2, true);
|
13524 | view.setUint16(32, 2, true);
|
13525 | view.setUint16(34, 16, true);
|
13526 | writeString(view, 36, 'data');
|
13527 | view.setUint32(40, samples.length * 2, true);
|
13528 | floatTo16BitPCM(view, 44, samples);
|
13529 | return view;
|
13530 | }
|
13531 | };
|
13532 | }, {}]
|
13533 | }, {}, [3]);
|
13534 | }.call(this, __webpack_require__( "../../node_modules/webpack/buildin/global.js")))
|
13535 |
|
13536 | }),
|
13537 |
|
13538 | "./lib/Interactions/index.js":
|
13539 |
|
13540 |
|
13541 |
|
13542 |
|
13543 | (function(module, exports, __webpack_require__) {
|
13544 |
|
13545 | "use strict";
|
13546 |
|
13547 |
|
13548 | function __export(m) {
|
13549 | for (var p in m) {
|
13550 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
13551 | }
|
13552 | }
|
13553 |
|
13554 | Object.defineProperty(exports, "__esModule", {
|
13555 | value: true
|
13556 | });
|
13557 |
|
13558 | __export(__webpack_require__( "./lib/Interactions/ChatBot.js"));
|
13559 |
|
13560 | }),
|
13561 |
|
13562 | "./lib/Storage/Common.js":
|
13563 |
|
13564 |
|
13565 |
|
13566 |
|
13567 | (function(module, exports, __webpack_require__) {
|
13568 |
|
13569 | "use strict";
|
13570 |
|
13571 |
|
13572 |
|
13573 |
|
13574 |
|
13575 |
|
13576 |
|
13577 |
|
13578 |
|
13579 |
|
13580 |
|
13581 |
|
13582 |
|
13583 |
|
13584 | function _typeof(obj) {
|
13585 | "@babel/helpers - typeof";
|
13586 |
|
13587 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
13588 | _typeof = function _typeof(obj) {
|
13589 | return typeof obj;
|
13590 | };
|
13591 | } else {
|
13592 | _typeof = function _typeof(obj) {
|
13593 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
13594 | };
|
13595 | }
|
13596 |
|
13597 | return _typeof(obj);
|
13598 | }
|
13599 |
|
13600 | Object.defineProperty(exports, "__esModule", {
|
13601 | value: true
|
13602 | });
|
13603 |
|
13604 | function calcKey(file, fileToKey) {
|
13605 | var name = file.name,
|
13606 | size = file.size,
|
13607 | type = file.type;
|
13608 | var key = encodeURI(name);
|
13609 |
|
13610 | if (fileToKey) {
|
13611 | var callback_type = _typeof(fileToKey);
|
13612 |
|
13613 | if (callback_type === 'string') {
|
13614 | key = fileToKey;
|
13615 | } else if (callback_type === 'function') {
|
13616 | key = fileToKey({
|
13617 | name: name,
|
13618 | size: size,
|
13619 | type: type
|
13620 | });
|
13621 | } else {
|
13622 | key = encodeURI(JSON.stringify(fileToKey));
|
13623 | }
|
13624 |
|
13625 | if (!key) {
|
13626 | key = 'empty_key';
|
13627 | }
|
13628 | }
|
13629 |
|
13630 | return key.replace(/\s/g, '_');
|
13631 | }
|
13632 |
|
13633 | exports.calcKey = calcKey;
|
13634 |
|
13635 | }),
|
13636 |
|
13637 | "./lib/Storage/S3Album.js":
|
13638 |
|
13639 |
|
13640 |
|
13641 |
|
13642 | (function(module, exports, __webpack_require__) {
|
13643 |
|
13644 | "use strict";
|
13645 |
|
13646 |
|
13647 |
|
13648 |
|
13649 |
|
13650 |
|
13651 |
|
13652 |
|
13653 |
|
13654 |
|
13655 |
|
13656 |
|
13657 |
|
13658 |
|
13659 | function _typeof(obj) {
|
13660 | "@babel/helpers - typeof";
|
13661 |
|
13662 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
13663 | _typeof = function _typeof(obj) {
|
13664 | return typeof obj;
|
13665 | };
|
13666 | } else {
|
13667 | _typeof = function _typeof(obj) {
|
13668 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
13669 | };
|
13670 | }
|
13671 |
|
13672 | return _typeof(obj);
|
13673 | }
|
13674 |
|
13675 | var __extends = this && this.__extends || function () {
|
13676 | var _extendStatics = function extendStatics(d, b) {
|
13677 | _extendStatics = Object.setPrototypeOf || {
|
13678 | __proto__: []
|
13679 | } instanceof Array && function (d, b) {
|
13680 | d.__proto__ = b;
|
13681 | } || function (d, b) {
|
13682 | for (var p in b) {
|
13683 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
13684 | }
|
13685 | };
|
13686 |
|
13687 | return _extendStatics(d, b);
|
13688 | };
|
13689 |
|
13690 | return function (d, b) {
|
13691 | _extendStatics(d, b);
|
13692 |
|
13693 | function __() {
|
13694 | this.constructor = d;
|
13695 | }
|
13696 |
|
13697 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
13698 | };
|
13699 | }();
|
13700 |
|
13701 | var __importStar = this && this.__importStar || function (mod) {
|
13702 | if (mod && mod.__esModule) return mod;
|
13703 | var result = {};
|
13704 | if (mod != null) for (var k in mod) {
|
13705 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
13706 | }
|
13707 | result["default"] = mod;
|
13708 | return result;
|
13709 | };
|
13710 |
|
13711 | var __importDefault = this && this.__importDefault || function (mod) {
|
13712 | return mod && mod.__esModule ? mod : {
|
13713 | "default": mod
|
13714 | };
|
13715 | };
|
13716 |
|
13717 | Object.defineProperty(exports, "__esModule", {
|
13718 | value: true
|
13719 | });
|
13720 |
|
13721 | var React = __importStar(__webpack_require__( "react"));
|
13722 |
|
13723 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
13724 |
|
13725 | var storage_1 = __webpack_require__( "@aws-amplify/storage");
|
13726 |
|
13727 | var Picker_1 = __webpack_require__( "./lib/Widget/Picker.js");
|
13728 |
|
13729 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
13730 |
|
13731 | var S3Image_1 = __webpack_require__( "./lib/Storage/S3Image.js");
|
13732 |
|
13733 | var S3Text_1 = __webpack_require__( "./lib/Storage/S3Text.js");
|
13734 |
|
13735 | var logger = new core_1.ConsoleLogger('Storage.S3Album');
|
13736 |
|
13737 | var S3Album =
|
13738 |
|
13739 | function (_super) {
|
13740 | __extends(S3Album, _super);
|
13741 |
|
13742 | function S3Album(props) {
|
13743 | var _this = _super.call(this, props) || this;
|
13744 |
|
13745 | _this._isMounted = false;
|
13746 | _this.handlePick = _this.handlePick.bind(_this);
|
13747 | _this.handleClick = _this.handleClick.bind(_this);
|
13748 | _this.list = _this.list.bind(_this);
|
13749 | _this.marshal = _this.marshal.bind(_this);
|
13750 | _this.state = {
|
13751 | items: [],
|
13752 | ts: new Date().getTime()
|
13753 | };
|
13754 | return _this;
|
13755 | }
|
13756 |
|
13757 | S3Album.prototype.getKey = function (file) {
|
13758 | var fileToKey = this.props.fileToKey;
|
13759 | var name = file.name,
|
13760 | size = file.size,
|
13761 | type = file.type;
|
13762 | var key = encodeURI(name);
|
13763 |
|
13764 | if (fileToKey) {
|
13765 | var callback_type = _typeof(fileToKey);
|
13766 |
|
13767 | if (callback_type === 'string') {
|
13768 | key = fileToKey;
|
13769 | } else if (callback_type === 'function') {
|
13770 | key = fileToKey({
|
13771 | name: name,
|
13772 | size: size,
|
13773 | type: type
|
13774 | });
|
13775 | } else {
|
13776 | key = encodeURI(JSON.stringify(fileToKey));
|
13777 | }
|
13778 |
|
13779 | if (!key) {
|
13780 | logger.debug('key is empty');
|
13781 | key = 'empty_key';
|
13782 | }
|
13783 | }
|
13784 |
|
13785 | return key.replace(/\s/g, '_');
|
13786 | };
|
13787 |
|
13788 | S3Album.prototype.handlePick = function (data) {
|
13789 | var _this = this;
|
13790 |
|
13791 | var _a = this.props,
|
13792 | onPick = _a.onPick,
|
13793 | onLoad = _a.onLoad,
|
13794 | onError = _a.onError,
|
13795 | track = _a.track,
|
13796 | level = _a.level;
|
13797 |
|
13798 | if (onPick) {
|
13799 | onPick(data);
|
13800 | }
|
13801 |
|
13802 | var path = this.props.path || '';
|
13803 | var file = data.file,
|
13804 | name = data.name,
|
13805 | size = data.size,
|
13806 | type = data.type;
|
13807 | var key = path + this.getKey(data);
|
13808 |
|
13809 | if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
|
13810 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
13811 | }
|
13812 |
|
13813 | storage_1.Storage.put(key, file, {
|
13814 | level: level ? level : 'public',
|
13815 | contentType: type,
|
13816 | track: track
|
13817 | }).then(function (data) {
|
13818 | logger.debug('handle pick data', data);
|
13819 | var items = _this.state.items;
|
13820 |
|
13821 | if (items.filter(function (item) {
|
13822 | return item.key === key;
|
13823 | }).length === 0) {
|
13824 | var list = items.concat(data);
|
13825 |
|
13826 | _this.marshal(list);
|
13827 | } else {
|
13828 | logger.debug('update an item');
|
13829 | }
|
13830 |
|
13831 | if (onLoad) {
|
13832 | onLoad(data);
|
13833 | }
|
13834 | })["catch"](function (err) {
|
13835 | logger.debug('handle pick error', err);
|
13836 |
|
13837 | if (onError) {
|
13838 | onError(err);
|
13839 | }
|
13840 | });
|
13841 |
|
13842 | if (this._isMounted) {
|
13843 | this.setState({
|
13844 | ts: new Date().getTime()
|
13845 | });
|
13846 | }
|
13847 | };
|
13848 |
|
13849 | S3Album.prototype.handleClick = function (item) {
|
13850 | var _a = this.props,
|
13851 | onClickItem = _a.onClickItem,
|
13852 | select = _a.select,
|
13853 | onSelect = _a.onSelect;
|
13854 |
|
13855 | if (onClickItem) {
|
13856 | onClickItem(item);
|
13857 | }
|
13858 |
|
13859 | if (!select) {
|
13860 | return;
|
13861 | }
|
13862 |
|
13863 | item.selected = !item.selected;
|
13864 |
|
13865 | if (this._isMounted) {
|
13866 | this.setState({
|
13867 | items: this.state.items.slice()
|
13868 | });
|
13869 | }
|
13870 |
|
13871 | if (!onSelect) {
|
13872 | return;
|
13873 | }
|
13874 |
|
13875 | var selected_items = this.state.items.filter(function (item) {
|
13876 | return item.selected;
|
13877 | });
|
13878 | onSelect(item, selected_items);
|
13879 | };
|
13880 |
|
13881 | S3Album.prototype.componentDidMount = function () {
|
13882 | this._isMounted = true;
|
13883 | this.list();
|
13884 | };
|
13885 |
|
13886 | S3Album.prototype.componentWillUnmount = function () {
|
13887 | this._isMounted = false;
|
13888 | };
|
13889 |
|
13890 | S3Album.prototype.componentDidUpdate = function (prevProps, prevState) {
|
13891 | if (this.props.path === prevProps.path && this.props.ts === prevProps.ts && this.props.select === prevProps.select) {
|
13892 | return;
|
13893 | }
|
13894 |
|
13895 | if (!this.props.select) {
|
13896 | this.state.items.forEach(function (item) {
|
13897 | return item.selected = false;
|
13898 | });
|
13899 | }
|
13900 |
|
13901 | if (this.props.onSelect) {
|
13902 | this.props.onSelect(null, []);
|
13903 | }
|
13904 |
|
13905 | this.list();
|
13906 | };
|
13907 |
|
13908 | S3Album.prototype.list = function () {
|
13909 | var _this = this;
|
13910 |
|
13911 | var _a = this.props,
|
13912 | path = _a.path,
|
13913 | level = _a.level,
|
13914 | track = _a.track,
|
13915 | identityId = _a.identityId;
|
13916 | logger.debug('Album path: ' + path);
|
13917 |
|
13918 | if (!storage_1.Storage || typeof storage_1.Storage.list !== 'function') {
|
13919 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
13920 | }
|
13921 |
|
13922 | return storage_1.Storage.list(path, {
|
13923 | level: level ? level : 'public',
|
13924 | track: track,
|
13925 | identityId: identityId
|
13926 | }).then(function (data) {
|
13927 | logger.debug('album list', data);
|
13928 |
|
13929 | _this.marshal(data);
|
13930 | })["catch"](function (err) {
|
13931 | logger.warn(err);
|
13932 | return [];
|
13933 | });
|
13934 | };
|
13935 |
|
13936 | S3Album.prototype.contentType = function (item) {
|
13937 | return core_1.filenameToContentType(item.key, 'image/*');
|
13938 | };
|
13939 |
|
13940 | S3Album.prototype.marshal = function (list) {
|
13941 | var _this = this;
|
13942 |
|
13943 | var contentType = this.props.contentType || '';
|
13944 | list.forEach(function (item) {
|
13945 | if (item.contentType) {
|
13946 | return;
|
13947 | }
|
13948 |
|
13949 | var isString = typeof contentType === 'string';
|
13950 | item.contentType = isString ? contentType : contentType(item);
|
13951 |
|
13952 | if (!item.contentType) {
|
13953 | item.contentType = _this.contentType(item);
|
13954 | }
|
13955 | });
|
13956 | var items = this.filter(list);
|
13957 | items = this.sort(items);
|
13958 |
|
13959 | if (this._isMounted) {
|
13960 | this.setState({
|
13961 | items: items
|
13962 | });
|
13963 | }
|
13964 | };
|
13965 |
|
13966 | S3Album.prototype.filter = function (list) {
|
13967 | var filter = this.props.filter;
|
13968 | return filter ? filter(list) : list;
|
13969 | };
|
13970 |
|
13971 | S3Album.prototype.sort = function (list) {
|
13972 | var sort = this.props.sort;
|
13973 |
|
13974 | var typeof_sort = _typeof(sort);
|
13975 |
|
13976 | if (typeof_sort === 'function') {
|
13977 | return sort(list);
|
13978 | }
|
13979 |
|
13980 |
|
13981 | if (['string', 'undefined'].includes(typeof_sort)) {
|
13982 | var sort_str = sort ? sort : 'lastModified';
|
13983 | var parts = sort_str.split(/\s+/);
|
13984 | var field = parts[0];
|
13985 | var dir = parts.length > 1 ? parts[1] : '';
|
13986 |
|
13987 | if (field === 'lastModified') {
|
13988 | dir = dir === 'asc' ? 'asc' : 'desc';
|
13989 | } else {
|
13990 | dir = dir === 'desc' ? 'desc' : 'asc';
|
13991 | }
|
13992 |
|
13993 | core_1.sortByField(list, field, dir);
|
13994 | return list;
|
13995 | }
|
13996 |
|
13997 | logger.warn('invalid sort. done nothing. should be a string or function');
|
13998 | return list;
|
13999 | };
|
14000 |
|
14001 | S3Album.prototype.render = function () {
|
14002 | var _this = this;
|
14003 |
|
14004 | var _a = this.props,
|
14005 | picker = _a.picker,
|
14006 | translateItem = _a.translateItem,
|
14007 | level = _a.level,
|
14008 | identityId = _a.identityId;
|
14009 | var _b = this.state,
|
14010 | items = _b.items,
|
14011 | ts = _b.ts;
|
14012 | var pickerTitle = this.props.pickerTitle || 'Pick';
|
14013 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
14014 | var list = items.map(function (item) {
|
14015 | var isText = item.contentType && core_1.isTextFile(item.contentType);
|
14016 | return isText ? React.createElement(S3Text_1.S3Text, {
|
14017 | key: item.key,
|
14018 | textKey: item.key,
|
14019 | theme: theme,
|
14020 | style: theme.albumText,
|
14021 | selected: item.selected,
|
14022 | translate: translateItem,
|
14023 | level: level,
|
14024 | identityId: identityId,
|
14025 | onClick: function onClick() {
|
14026 | return _this.handleClick(item);
|
14027 | }
|
14028 | }) : React.createElement(S3Image_1.S3Image, {
|
14029 | key: item.key,
|
14030 | imgKey: item.key,
|
14031 | theme: theme,
|
14032 | style: theme.albumPhoto,
|
14033 | selected: item.selected,
|
14034 | translate: translateItem,
|
14035 | level: level,
|
14036 | identityId: identityId,
|
14037 | onClick: function onClick() {
|
14038 | return _this.handleClick(item);
|
14039 | }
|
14040 | });
|
14041 | });
|
14042 | return React.createElement("div", null, React.createElement("div", {
|
14043 | style: theme.album
|
14044 | }, list), picker ? React.createElement(Picker_1.Picker, {
|
14045 | key: ts,
|
14046 | title: pickerTitle,
|
14047 | accept: "image/*, text/*",
|
14048 | onPick: this.handlePick,
|
14049 | theme: theme
|
14050 | }) : null);
|
14051 | };
|
14052 |
|
14053 | return S3Album;
|
14054 | }(React.Component);
|
14055 |
|
14056 | exports.S3Album = S3Album;
|
14057 |
|
14058 |
|
14059 |
|
14060 |
|
14061 | exports["default"] = S3Album;
|
14062 |
|
14063 | }),
|
14064 |
|
14065 | "./lib/Storage/S3Image.js":
|
14066 |
|
14067 |
|
14068 |
|
14069 |
|
14070 | (function(module, exports, __webpack_require__) {
|
14071 |
|
14072 | "use strict";
|
14073 |
|
14074 |
|
14075 |
|
14076 |
|
14077 |
|
14078 |
|
14079 |
|
14080 |
|
14081 |
|
14082 |
|
14083 |
|
14084 |
|
14085 |
|
14086 |
|
14087 | var __extends = this && this.__extends || function () {
|
14088 | var _extendStatics = function extendStatics(d, b) {
|
14089 | _extendStatics = Object.setPrototypeOf || {
|
14090 | __proto__: []
|
14091 | } instanceof Array && function (d, b) {
|
14092 | d.__proto__ = b;
|
14093 | } || function (d, b) {
|
14094 | for (var p in b) {
|
14095 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
14096 | }
|
14097 | };
|
14098 |
|
14099 | return _extendStatics(d, b);
|
14100 | };
|
14101 |
|
14102 | return function (d, b) {
|
14103 | _extendStatics(d, b);
|
14104 |
|
14105 | function __() {
|
14106 | this.constructor = d;
|
14107 | }
|
14108 |
|
14109 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14110 | };
|
14111 | }();
|
14112 |
|
14113 | var __importStar = this && this.__importStar || function (mod) {
|
14114 | if (mod && mod.__esModule) return mod;
|
14115 | var result = {};
|
14116 | if (mod != null) for (var k in mod) {
|
14117 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
14118 | }
|
14119 | result["default"] = mod;
|
14120 | return result;
|
14121 | };
|
14122 |
|
14123 | var __importDefault = this && this.__importDefault || function (mod) {
|
14124 | return mod && mod.__esModule ? mod : {
|
14125 | "default": mod
|
14126 | };
|
14127 | };
|
14128 |
|
14129 | Object.defineProperty(exports, "__esModule", {
|
14130 | value: true
|
14131 | });
|
14132 |
|
14133 | var React = __importStar(__webpack_require__( "react"));
|
14134 |
|
14135 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
14136 |
|
14137 | var storage_1 = __webpack_require__( "@aws-amplify/storage");
|
14138 |
|
14139 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
14140 |
|
14141 | var AmplifyUI_1 = __webpack_require__( "./lib/AmplifyUI.js");
|
14142 |
|
14143 | var PhotoPicker_1 = __webpack_require__( "./lib/Widget/PhotoPicker.js");
|
14144 |
|
14145 | var Common_1 = __webpack_require__( "./lib/Storage/Common.js");
|
14146 |
|
14147 | var logger = new core_1.ConsoleLogger('Storage.S3Image');
|
14148 |
|
14149 | var S3Image =
|
14150 |
|
14151 | function (_super) {
|
14152 | __extends(S3Image, _super);
|
14153 |
|
14154 | function S3Image(props) {
|
14155 | var _this = _super.call(this, props) || this;
|
14156 |
|
14157 | _this._isMounted = false;
|
14158 | _this.handleOnLoad = _this.handleOnLoad.bind(_this);
|
14159 | _this.handleOnError = _this.handleOnError.bind(_this);
|
14160 | _this.handlePick = _this.handlePick.bind(_this);
|
14161 | _this.handleClick = _this.handleClick.bind(_this);
|
14162 | var initSrc = _this.props.src || AmplifyUI_1.transparent1X1;
|
14163 | _this.state = {
|
14164 | src: initSrc
|
14165 | };
|
14166 | return _this;
|
14167 | }
|
14168 |
|
14169 | S3Image.prototype.getImageSource = function (key, level, track, identityId) {
|
14170 | var _this = this;
|
14171 |
|
14172 | if (!storage_1.Storage || typeof storage_1.Storage.get !== 'function') {
|
14173 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14174 | }
|
14175 |
|
14176 | storage_1.Storage.get(key, {
|
14177 | level: level ? level : 'public',
|
14178 | track: track,
|
14179 | identityId: identityId
|
14180 | }).then(function (url) {
|
14181 | if (_this._isMounted) {
|
14182 | _this.setState({
|
14183 | src: url
|
14184 | });
|
14185 | }
|
14186 | })["catch"](function (err) {
|
14187 | return logger.debug(err);
|
14188 | });
|
14189 | };
|
14190 |
|
14191 | S3Image.prototype.load = function () {
|
14192 | var _a = this.props,
|
14193 | imgKey = _a.imgKey,
|
14194 | path = _a.path,
|
14195 | body = _a.body,
|
14196 | contentType = _a.contentType,
|
14197 | level = _a.level,
|
14198 | track = _a.track,
|
14199 | identityId = _a.identityId;
|
14200 |
|
14201 | if (!imgKey && !path) {
|
14202 | logger.debug('empty imgKey and path');
|
14203 | return;
|
14204 | }
|
14205 |
|
14206 | var that = this;
|
14207 | var key = imgKey || path;
|
14208 | logger.debug('loading ' + key + '...');
|
14209 |
|
14210 | if (body) {
|
14211 | var type = contentType || 'binary/octet-stream';
|
14212 |
|
14213 | if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
|
14214 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14215 | }
|
14216 |
|
14217 | var ret = storage_1.Storage.put(key, body, {
|
14218 | contentType: type,
|
14219 | level: level ? level : 'public',
|
14220 | track: track
|
14221 | });
|
14222 | ret.then(function (data) {
|
14223 | logger.debug(data);
|
14224 | that.getImageSource(key, level, track, identityId);
|
14225 | })["catch"](function (err) {
|
14226 | return logger.debug(err);
|
14227 | });
|
14228 | } else {
|
14229 | that.getImageSource(key, level, track, identityId);
|
14230 | }
|
14231 | };
|
14232 |
|
14233 | S3Image.prototype.handleOnLoad = function (evt) {
|
14234 | var onLoad = this.props.onLoad;
|
14235 |
|
14236 | if (onLoad) {
|
14237 | onLoad(this.state.src);
|
14238 | }
|
14239 | };
|
14240 |
|
14241 | S3Image.prototype.handleOnError = function (evt) {
|
14242 | var onError = this.props.onError;
|
14243 |
|
14244 | if (onError) {
|
14245 | onError(this.state.src);
|
14246 | }
|
14247 | };
|
14248 |
|
14249 | S3Image.prototype.handlePick = function (data) {
|
14250 | var that = this;
|
14251 | var _a = this.props,
|
14252 | imgKey = _a.imgKey,
|
14253 | level = _a.level,
|
14254 | fileToKey = _a.fileToKey,
|
14255 | track = _a.track,
|
14256 | identityId = _a.identityId,
|
14257 | _b = _a.path,
|
14258 | path = _b === void 0 ? '' : _b,
|
14259 | onUploadSuccess = _a.onUploadSuccess;
|
14260 | var file = data.file,
|
14261 | type = data.type;
|
14262 | var key = imgKey || path + Common_1.calcKey(data, fileToKey);
|
14263 |
|
14264 | if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
|
14265 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14266 | }
|
14267 |
|
14268 | storage_1.Storage.put(key, file, {
|
14269 | level: level ? level : 'public',
|
14270 | contentType: type,
|
14271 | track: track
|
14272 | }).then(function (data) {
|
14273 | logger.debug('handle pick data', data);
|
14274 | that.getImageSource(key, level, track, identityId);
|
14275 | if (onUploadSuccess) onUploadSuccess();
|
14276 | })["catch"](function (err) {
|
14277 | return logger.debug('handle pick error', err);
|
14278 | });
|
14279 | };
|
14280 |
|
14281 | S3Image.prototype.handleClick = function (evt) {
|
14282 | var onClick = this.props.onClick;
|
14283 |
|
14284 | if (onClick) {
|
14285 | onClick(evt);
|
14286 | }
|
14287 | };
|
14288 |
|
14289 | S3Image.prototype.componentDidMount = function () {
|
14290 | this._isMounted = true;
|
14291 | this.load();
|
14292 | };
|
14293 |
|
14294 | S3Image.prototype.componentWillUnmount = function () {
|
14295 | this._isMounted = false;
|
14296 | };
|
14297 |
|
14298 | S3Image.prototype.componentDidUpdate = function (prevProps) {
|
14299 | var update = prevProps.path !== this.props.path || prevProps.imgKey !== this.props.imgKey || prevProps.body !== this.props.body || prevProps.level !== this.props.level;
|
14300 |
|
14301 | if (update) {
|
14302 | this.load();
|
14303 | }
|
14304 | };
|
14305 |
|
14306 | S3Image.prototype.imageEl = function (src, theme) {
|
14307 | if (!src) {
|
14308 | return null;
|
14309 | }
|
14310 |
|
14311 | var _a = this.props,
|
14312 | className = _a.className,
|
14313 | selected = _a.selected;
|
14314 | var containerStyle = {
|
14315 | position: 'relative'
|
14316 | };
|
14317 | return React.createElement("div", {
|
14318 | style: containerStyle,
|
14319 | onClick: this.handleClick
|
14320 | }, React.createElement("img", {
|
14321 | className: className,
|
14322 | style: theme.photoImg,
|
14323 | src: src,
|
14324 | onLoad: this.handleOnLoad,
|
14325 | onError: this.handleOnError
|
14326 | }), React.createElement("div", {
|
14327 | style: selected ? theme.overlaySelected : theme.overlay
|
14328 | }));
|
14329 | };
|
14330 |
|
14331 | S3Image.prototype.render = function () {
|
14332 | var _a = this.props,
|
14333 | hidden = _a.hidden,
|
14334 | style = _a.style,
|
14335 | picker = _a.picker,
|
14336 | translate = _a.translate,
|
14337 | imgKey = _a.imgKey;
|
14338 | var src = this.state.src;
|
14339 |
|
14340 | if (translate) {
|
14341 | src = typeof translate === 'string' ? translate : translate({
|
14342 | type: 'image',
|
14343 | key: imgKey,
|
14344 | content: src
|
14345 | });
|
14346 | }
|
14347 |
|
14348 | if (!src && !picker) {
|
14349 | return null;
|
14350 | }
|
14351 |
|
14352 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
14353 | var photoStyle = hidden ? AmplifyTheme_1["default"].hidden : Object.assign({}, theme.photo, style);
|
14354 | return React.createElement("div", {
|
14355 | style: photoStyle
|
14356 | }, photoStyle ? this.imageEl(src, theme) : null, picker ? React.createElement("div", null, React.createElement(PhotoPicker_1.PhotoPicker, {
|
14357 | key: "picker",
|
14358 | onPick: this.handlePick,
|
14359 | theme: theme
|
14360 | })) : null);
|
14361 | };
|
14362 |
|
14363 | return S3Image;
|
14364 | }(React.Component);
|
14365 |
|
14366 | exports.S3Image = S3Image;
|
14367 |
|
14368 |
|
14369 |
|
14370 |
|
14371 | exports["default"] = S3Image;
|
14372 |
|
14373 | }),
|
14374 |
|
14375 | "./lib/Storage/S3Text.js":
|
14376 |
|
14377 |
|
14378 |
|
14379 |
|
14380 | (function(module, exports, __webpack_require__) {
|
14381 |
|
14382 | "use strict";
|
14383 |
|
14384 |
|
14385 |
|
14386 |
|
14387 |
|
14388 |
|
14389 |
|
14390 |
|
14391 |
|
14392 |
|
14393 |
|
14394 |
|
14395 |
|
14396 |
|
14397 | var __extends = this && this.__extends || function () {
|
14398 | var _extendStatics = function extendStatics(d, b) {
|
14399 | _extendStatics = Object.setPrototypeOf || {
|
14400 | __proto__: []
|
14401 | } instanceof Array && function (d, b) {
|
14402 | d.__proto__ = b;
|
14403 | } || function (d, b) {
|
14404 | for (var p in b) {
|
14405 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
14406 | }
|
14407 | };
|
14408 |
|
14409 | return _extendStatics(d, b);
|
14410 | };
|
14411 |
|
14412 | return function (d, b) {
|
14413 | _extendStatics(d, b);
|
14414 |
|
14415 | function __() {
|
14416 | this.constructor = d;
|
14417 | }
|
14418 |
|
14419 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14420 | };
|
14421 | }();
|
14422 |
|
14423 | var __importStar = this && this.__importStar || function (mod) {
|
14424 | if (mod && mod.__esModule) return mod;
|
14425 | var result = {};
|
14426 | if (mod != null) for (var k in mod) {
|
14427 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
14428 | }
|
14429 | result["default"] = mod;
|
14430 | return result;
|
14431 | };
|
14432 |
|
14433 | var __importDefault = this && this.__importDefault || function (mod) {
|
14434 | return mod && mod.__esModule ? mod : {
|
14435 | "default": mod
|
14436 | };
|
14437 | };
|
14438 |
|
14439 | Object.defineProperty(exports, "__esModule", {
|
14440 | value: true
|
14441 | });
|
14442 |
|
14443 | var React = __importStar(__webpack_require__( "react"));
|
14444 |
|
14445 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
14446 |
|
14447 | var storage_1 = __webpack_require__( "@aws-amplify/storage");
|
14448 |
|
14449 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
14450 |
|
14451 | var TextPicker_1 = __webpack_require__( "./lib/Widget/TextPicker.js");
|
14452 |
|
14453 | var Common_1 = __webpack_require__( "./lib/Storage/Common.js");
|
14454 |
|
14455 | var logger = new core_1.ConsoleLogger('Storage.S3Text');
|
14456 |
|
14457 | var S3Text =
|
14458 |
|
14459 | function (_super) {
|
14460 | __extends(S3Text, _super);
|
14461 |
|
14462 | function S3Text(props) {
|
14463 | var _this = _super.call(this, props) || this;
|
14464 |
|
14465 | _this._isMounted = false;
|
14466 | _this.handleOnLoad = _this.handleOnLoad.bind(_this);
|
14467 | _this.handleOnError = _this.handleOnError.bind(_this);
|
14468 | _this.handlePick = _this.handlePick.bind(_this);
|
14469 | _this.handleClick = _this.handleClick.bind(_this);
|
14470 | var text = props.text,
|
14471 | textKey = props.textKey;
|
14472 | _this.state = {
|
14473 | text: text || '',
|
14474 | textKey: textKey || ''
|
14475 | };
|
14476 | return _this;
|
14477 | }
|
14478 |
|
14479 | S3Text.prototype.getText = function (key, level, track, identityId) {
|
14480 | var _this = this;
|
14481 |
|
14482 | if (!storage_1.Storage || typeof storage_1.Storage.get !== 'function') {
|
14483 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14484 | }
|
14485 |
|
14486 | storage_1.Storage.get(key, {
|
14487 | download: true,
|
14488 | level: level ? level : 'public',
|
14489 | track: track,
|
14490 | identityId: identityId
|
14491 | }).then(function (data) {
|
14492 | logger.debug(data);
|
14493 |
|
14494 | var text = data.Body.toString('utf8');
|
14495 |
|
14496 | if (_this._isMounted) {
|
14497 | _this.setState({
|
14498 | text: text
|
14499 | });
|
14500 | }
|
14501 |
|
14502 | _this.handleOnLoad(text);
|
14503 | })["catch"](function (err) {
|
14504 | logger.debug(err);
|
14505 |
|
14506 | _this.handleOnError(err);
|
14507 | });
|
14508 | };
|
14509 |
|
14510 | S3Text.prototype.load = function () {
|
14511 | var _a = this.props,
|
14512 | path = _a.path,
|
14513 | textKey = _a.textKey,
|
14514 | body = _a.body,
|
14515 | contentType = _a.contentType,
|
14516 | level = _a.level,
|
14517 | track = _a.track,
|
14518 | identityId = _a.identityId;
|
14519 |
|
14520 | if (!textKey && !path) {
|
14521 | logger.debug('empty textKey and path');
|
14522 | return;
|
14523 | }
|
14524 |
|
14525 | var that = this;
|
14526 | var key = textKey || path;
|
14527 | logger.debug('loading ' + key + '...');
|
14528 |
|
14529 | if (body) {
|
14530 | var type = contentType || 'text/*';
|
14531 |
|
14532 | if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
|
14533 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14534 | }
|
14535 |
|
14536 | var ret = storage_1.Storage.put(key, body, {
|
14537 | contentType: type,
|
14538 | level: level ? level : 'public',
|
14539 | track: track
|
14540 | });
|
14541 | ret.then(function (data) {
|
14542 | logger.debug(data);
|
14543 | that.getText(key, level, track, identityId);
|
14544 | })["catch"](function (err) {
|
14545 | return logger.debug(err);
|
14546 | });
|
14547 | } else {
|
14548 | that.getText(key, level, track, identityId);
|
14549 | }
|
14550 | };
|
14551 |
|
14552 | S3Text.prototype.handleOnLoad = function (text) {
|
14553 | var onLoad = this.props.onLoad;
|
14554 |
|
14555 | if (onLoad) {
|
14556 | onLoad(text);
|
14557 | }
|
14558 | };
|
14559 |
|
14560 | S3Text.prototype.handleOnError = function (err) {
|
14561 | var onError = this.props.onError;
|
14562 |
|
14563 | if (onError) {
|
14564 | onError(err);
|
14565 | }
|
14566 | };
|
14567 |
|
14568 | S3Text.prototype.handlePick = function (data) {
|
14569 | var that = this;
|
14570 | var path = this.props.path || '';
|
14571 | var _a = this.props,
|
14572 | textKey = _a.textKey,
|
14573 | level = _a.level,
|
14574 | fileToKey = _a.fileToKey,
|
14575 | track = _a.track,
|
14576 | identityId = _a.identityId;
|
14577 | var file = data.file,
|
14578 | name = data.name,
|
14579 | size = data.size,
|
14580 | type = data.type;
|
14581 | var key = textKey || path + Common_1.calcKey(data, fileToKey);
|
14582 |
|
14583 | if (!storage_1.Storage || typeof storage_1.Storage.put !== 'function') {
|
14584 | throw new Error('No Storage module found, please ensure @aws-amplify/storage is imported');
|
14585 | }
|
14586 |
|
14587 | storage_1.Storage.put(key, file, {
|
14588 | level: level ? level : 'public',
|
14589 | contentType: type,
|
14590 | track: track
|
14591 | }).then(function (data) {
|
14592 | logger.debug('handle pick data', data);
|
14593 | that.getText(key, level, track, identityId);
|
14594 | })["catch"](function (err) {
|
14595 | return logger.debug('handle pick error', err);
|
14596 | });
|
14597 | };
|
14598 |
|
14599 | S3Text.prototype.handleClick = function (evt) {
|
14600 | var onClick = this.props.onClick;
|
14601 |
|
14602 | if (onClick) {
|
14603 | onClick(evt);
|
14604 | }
|
14605 | };
|
14606 |
|
14607 | S3Text.prototype.componentDidMount = function () {
|
14608 | this._isMounted = true;
|
14609 | this.load();
|
14610 | };
|
14611 |
|
14612 | S3Text.prototype.componentWillUnmount = function () {
|
14613 | this._isMounted = false;
|
14614 | };
|
14615 |
|
14616 | S3Text.prototype.componentDidUpdate = function (prevProps) {
|
14617 | var update = prevProps.path !== this.props.path || prevProps.textKey !== this.props.textKey || prevProps.body !== this.props.body;
|
14618 |
|
14619 | if (update) {
|
14620 | this.load();
|
14621 | }
|
14622 | };
|
14623 |
|
14624 | S3Text.prototype.textEl = function (text, theme) {
|
14625 | if (!text) {
|
14626 | return null;
|
14627 | }
|
14628 |
|
14629 | var selected = this.props.selected;
|
14630 | var containerStyle = {
|
14631 | position: 'relative'
|
14632 | };
|
14633 | return React.createElement("div", {
|
14634 | style: containerStyle,
|
14635 | onClick: this.handleClick
|
14636 | }, React.createElement("pre", {
|
14637 | style: theme.pre
|
14638 | }, text), React.createElement("div", {
|
14639 | style: selected ? theme.overlaySelected : theme.overlay
|
14640 | }));
|
14641 | };
|
14642 |
|
14643 | S3Text.prototype.render = function () {
|
14644 | var _a = this.props,
|
14645 | hidden = _a.hidden,
|
14646 | style = _a.style,
|
14647 | picker = _a.picker,
|
14648 | translate = _a.translate,
|
14649 | textKey = _a.textKey;
|
14650 | var text = this.state.text;
|
14651 |
|
14652 | if (translate) {
|
14653 | text = typeof translate === 'string' ? translate : translate({
|
14654 | type: 'text',
|
14655 | key: textKey,
|
14656 | content: text
|
14657 | });
|
14658 | }
|
14659 |
|
14660 | if (!text && !picker) {
|
14661 | return null;
|
14662 | }
|
14663 |
|
14664 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
14665 | var textStyle = hidden ? AmplifyTheme_1["default"].hidden : Object.assign({}, theme.text, style);
|
14666 | return React.createElement("div", {
|
14667 | style: textStyle
|
14668 | }, textStyle ? this.textEl(text, theme) : null, picker ? React.createElement("div", null, React.createElement(TextPicker_1.TextPicker, {
|
14669 | key: "picker",
|
14670 | onPick: this.handlePick,
|
14671 | theme: theme
|
14672 | })) : null);
|
14673 | };
|
14674 |
|
14675 | return S3Text;
|
14676 | }(React.Component);
|
14677 |
|
14678 | exports.S3Text = S3Text;
|
14679 |
|
14680 |
|
14681 |
|
14682 |
|
14683 | exports["default"] = S3Text;
|
14684 |
|
14685 | }),
|
14686 |
|
14687 | "./lib/Storage/index.js":
|
14688 |
|
14689 |
|
14690 |
|
14691 |
|
14692 | (function(module, exports, __webpack_require__) {
|
14693 |
|
14694 | "use strict";
|
14695 |
|
14696 |
|
14697 |
|
14698 |
|
14699 |
|
14700 |
|
14701 |
|
14702 |
|
14703 |
|
14704 |
|
14705 |
|
14706 |
|
14707 |
|
14708 |
|
14709 | Object.defineProperty(exports, "__esModule", {
|
14710 | value: true
|
14711 | });
|
14712 |
|
14713 | var S3Album_1 = __webpack_require__( "./lib/Storage/S3Album.js");
|
14714 |
|
14715 | exports.S3Album = S3Album_1.S3Album;
|
14716 |
|
14717 | var S3Image_1 = __webpack_require__( "./lib/Storage/S3Image.js");
|
14718 |
|
14719 | exports.S3Image = S3Image_1.S3Image;
|
14720 |
|
14721 | var S3Text_1 = __webpack_require__( "./lib/Storage/S3Text.js");
|
14722 |
|
14723 | exports.S3Text = S3Text_1.S3Text;
|
14724 |
|
14725 | }),
|
14726 |
|
14727 | "./lib/Widget/PhotoPicker.js":
|
14728 |
|
14729 |
|
14730 |
|
14731 |
|
14732 | (function(module, exports, __webpack_require__) {
|
14733 |
|
14734 | "use strict";
|
14735 |
|
14736 |
|
14737 |
|
14738 |
|
14739 |
|
14740 |
|
14741 |
|
14742 |
|
14743 |
|
14744 |
|
14745 |
|
14746 |
|
14747 |
|
14748 |
|
14749 | var __extends = this && this.__extends || function () {
|
14750 | var _extendStatics = function extendStatics(d, b) {
|
14751 | _extendStatics = Object.setPrototypeOf || {
|
14752 | __proto__: []
|
14753 | } instanceof Array && function (d, b) {
|
14754 | d.__proto__ = b;
|
14755 | } || function (d, b) {
|
14756 | for (var p in b) {
|
14757 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
14758 | }
|
14759 | };
|
14760 |
|
14761 | return _extendStatics(d, b);
|
14762 | };
|
14763 |
|
14764 | return function (d, b) {
|
14765 | _extendStatics(d, b);
|
14766 |
|
14767 | function __() {
|
14768 | this.constructor = d;
|
14769 | }
|
14770 |
|
14771 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14772 | };
|
14773 | }();
|
14774 |
|
14775 | var __importStar = this && this.__importStar || function (mod) {
|
14776 | if (mod && mod.__esModule) return mod;
|
14777 | var result = {};
|
14778 | if (mod != null) for (var k in mod) {
|
14779 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
14780 | }
|
14781 | result["default"] = mod;
|
14782 | return result;
|
14783 | };
|
14784 |
|
14785 | var __importDefault = this && this.__importDefault || function (mod) {
|
14786 | return mod && mod.__esModule ? mod : {
|
14787 | "default": mod
|
14788 | };
|
14789 | };
|
14790 |
|
14791 | Object.defineProperty(exports, "__esModule", {
|
14792 | value: true
|
14793 | });
|
14794 |
|
14795 | var React = __importStar(__webpack_require__( "react"));
|
14796 |
|
14797 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
14798 |
|
14799 | var Picker_1 = __webpack_require__( "./lib/Widget/Picker.js");
|
14800 |
|
14801 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
14802 |
|
14803 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
14804 |
|
14805 | var PickerPreview = {
|
14806 | maxWidth: '100%'
|
14807 | };
|
14808 | var logger = new core_1.ConsoleLogger('PhotoPicker');
|
14809 |
|
14810 | var PhotoPicker =
|
14811 |
|
14812 | function (_super) {
|
14813 | __extends(PhotoPicker, _super);
|
14814 |
|
14815 | function PhotoPicker(props) {
|
14816 | var _this = _super.call(this, props) || this;
|
14817 |
|
14818 | _this.handlePick = _this.handlePick.bind(_this);
|
14819 | _this.state = {
|
14820 | previewSrc: props.previewSrc
|
14821 | };
|
14822 | return _this;
|
14823 | }
|
14824 |
|
14825 | PhotoPicker.prototype.handlePick = function (data) {
|
14826 | var that = this;
|
14827 | var file = data.file,
|
14828 | name = data.name,
|
14829 | size = data.size,
|
14830 | type = data.type;
|
14831 | var _a = this.props,
|
14832 | preview = _a.preview,
|
14833 | onPick = _a.onPick,
|
14834 | onLoad = _a.onLoad;
|
14835 |
|
14836 | if (onPick) {
|
14837 | onPick(data);
|
14838 | }
|
14839 |
|
14840 | if (preview) {
|
14841 | var reader = new FileReader();
|
14842 |
|
14843 | reader.onload = function (e) {
|
14844 | var url = e.target.result;
|
14845 |
|
14846 | that.setState({
|
14847 | previewSrc: url
|
14848 | });
|
14849 |
|
14850 | if (onLoad) {
|
14851 | onLoad(url);
|
14852 | }
|
14853 | };
|
14854 |
|
14855 | reader.readAsDataURL(file);
|
14856 | }
|
14857 | };
|
14858 |
|
14859 | PhotoPicker.prototype.render = function () {
|
14860 | var preview = this.props.preview;
|
14861 | var previewSrc = this.state.previewSrc;
|
14862 | var headerText = this.props.headerText || 'Photos';
|
14863 | var headerHint = this.props.headerHint || 'Add your photos by clicking below';
|
14864 | var title = this.props.title || 'Select a Photo';
|
14865 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
14866 | var previewStyle = Object.assign({}, PickerPreview, theme.pickerPreview);
|
14867 | var previewHidden = !(preview && preview !== 'hidden');
|
14868 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
14869 | theme: theme
|
14870 | }, React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
14871 | theme: theme,
|
14872 | hint: headerHint
|
14873 | }, core_1.I18n.get(headerText)), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
14874 | theme: theme
|
14875 | }, previewSrc ? previewHidden ? 'The image has been selected' : React.createElement("img", {
|
14876 | src: previewSrc,
|
14877 | style: previewStyle
|
14878 | }) : React.createElement(Amplify_UI_Components_React_1.PhotoPlaceholder, {
|
14879 | theme: theme
|
14880 | })), React.createElement(Picker_1.Picker, {
|
14881 | title: title,
|
14882 | accept: "image/*",
|
14883 | theme: theme,
|
14884 | onPick: this.handlePick
|
14885 | }));
|
14886 | };
|
14887 |
|
14888 | return PhotoPicker;
|
14889 | }(React.Component);
|
14890 |
|
14891 | exports.PhotoPicker = PhotoPicker;
|
14892 |
|
14893 |
|
14894 |
|
14895 |
|
14896 | exports["default"] = PhotoPicker;
|
14897 |
|
14898 | }),
|
14899 |
|
14900 | "./lib/Widget/Picker.js":
|
14901 |
|
14902 |
|
14903 |
|
14904 |
|
14905 | (function(module, exports, __webpack_require__) {
|
14906 |
|
14907 | "use strict";
|
14908 |
|
14909 |
|
14910 |
|
14911 |
|
14912 |
|
14913 |
|
14914 |
|
14915 |
|
14916 |
|
14917 |
|
14918 |
|
14919 |
|
14920 |
|
14921 |
|
14922 | var __extends = this && this.__extends || function () {
|
14923 | var _extendStatics = function extendStatics(d, b) {
|
14924 | _extendStatics = Object.setPrototypeOf || {
|
14925 | __proto__: []
|
14926 | } instanceof Array && function (d, b) {
|
14927 | d.__proto__ = b;
|
14928 | } || function (d, b) {
|
14929 | for (var p in b) {
|
14930 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
14931 | }
|
14932 | };
|
14933 |
|
14934 | return _extendStatics(d, b);
|
14935 | };
|
14936 |
|
14937 | return function (d, b) {
|
14938 | _extendStatics(d, b);
|
14939 |
|
14940 | function __() {
|
14941 | this.constructor = d;
|
14942 | }
|
14943 |
|
14944 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
14945 | };
|
14946 | }();
|
14947 |
|
14948 | var __importStar = this && this.__importStar || function (mod) {
|
14949 | if (mod && mod.__esModule) return mod;
|
14950 | var result = {};
|
14951 | if (mod != null) for (var k in mod) {
|
14952 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
14953 | }
|
14954 | result["default"] = mod;
|
14955 | return result;
|
14956 | };
|
14957 |
|
14958 | var __importDefault = this && this.__importDefault || function (mod) {
|
14959 | return mod && mod.__esModule ? mod : {
|
14960 | "default": mod
|
14961 | };
|
14962 | };
|
14963 |
|
14964 | Object.defineProperty(exports, "__esModule", {
|
14965 | value: true
|
14966 | });
|
14967 |
|
14968 | var React = __importStar(__webpack_require__( "react"));
|
14969 |
|
14970 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
14971 |
|
14972 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
14973 |
|
14974 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
14975 |
|
14976 | var PickerInput = {
|
14977 | width: '100%',
|
14978 | height: '100%',
|
14979 | display: 'inline-block',
|
14980 | position: 'absolute',
|
14981 | left: 0,
|
14982 | top: 0,
|
14983 | opacity: 0,
|
14984 | cursor: 'pointer'
|
14985 | };
|
14986 | var logger = new core_1.ConsoleLogger('Picker');
|
14987 |
|
14988 | var Picker =
|
14989 |
|
14990 | function (_super) {
|
14991 | __extends(Picker, _super);
|
14992 |
|
14993 | function Picker() {
|
14994 | return _super !== null && _super.apply(this, arguments) || this;
|
14995 | }
|
14996 |
|
14997 | Picker.prototype.handleInput = function (e) {
|
14998 | var that = this;
|
14999 | var file = e.target.files[0];
|
15000 |
|
15001 | if (!file) {
|
15002 | return;
|
15003 | }
|
15004 |
|
15005 | var name = file.name,
|
15006 | size = file.size,
|
15007 | type = file.type;
|
15008 | logger.debug(file);
|
15009 | var onPick = this.props.onPick;
|
15010 |
|
15011 | if (onPick) {
|
15012 | onPick({
|
15013 | file: file,
|
15014 | name: name,
|
15015 | size: size,
|
15016 | type: type
|
15017 | });
|
15018 | }
|
15019 | };
|
15020 |
|
15021 | Picker.prototype.render = function () {
|
15022 | var _this = this;
|
15023 |
|
15024 | var title = this.props.title || 'Pick a File';
|
15025 | var accept = this.props.accept || '*/*';
|
15026 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
15027 | var pickerStyle = Object.assign({}, {
|
15028 | position: 'relative'
|
15029 | }, theme.pickerPicker);
|
15030 | var inputStyle = Object.assign({}, PickerInput, theme.pickerInput);
|
15031 | return React.createElement("div", {
|
15032 | style: pickerStyle
|
15033 | }, React.createElement(Amplify_UI_Components_React_1.PhotoPickerButton, {
|
15034 | theme: theme
|
15035 | }, core_1.I18n.get(title)), React.createElement("input", {
|
15036 | title: core_1.I18n.get(title),
|
15037 | type: "file",
|
15038 | accept: accept,
|
15039 | style: inputStyle,
|
15040 | onChange: function onChange(e) {
|
15041 | return _this.handleInput(e);
|
15042 | }
|
15043 | }));
|
15044 | };
|
15045 |
|
15046 | return Picker;
|
15047 | }(React.Component);
|
15048 |
|
15049 | exports.Picker = Picker;
|
15050 |
|
15051 |
|
15052 |
|
15053 |
|
15054 | exports["default"] = Picker;
|
15055 |
|
15056 | }),
|
15057 |
|
15058 | "./lib/Widget/SelectMFAType.js":
|
15059 |
|
15060 |
|
15061 |
|
15062 |
|
15063 | (function(module, exports, __webpack_require__) {
|
15064 |
|
15065 | "use strict";
|
15066 |
|
15067 |
|
15068 |
|
15069 |
|
15070 |
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 |
|
15076 |
|
15077 |
|
15078 |
|
15079 |
|
15080 | var __extends = this && this.__extends || function () {
|
15081 | var _extendStatics = function extendStatics(d, b) {
|
15082 | _extendStatics = Object.setPrototypeOf || {
|
15083 | __proto__: []
|
15084 | } instanceof Array && function (d, b) {
|
15085 | d.__proto__ = b;
|
15086 | } || function (d, b) {
|
15087 | for (var p in b) {
|
15088 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
15089 | }
|
15090 | };
|
15091 |
|
15092 | return _extendStatics(d, b);
|
15093 | };
|
15094 |
|
15095 | return function (d, b) {
|
15096 | _extendStatics(d, b);
|
15097 |
|
15098 | function __() {
|
15099 | this.constructor = d;
|
15100 | }
|
15101 |
|
15102 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15103 | };
|
15104 | }();
|
15105 |
|
15106 | var __assign = this && this.__assign || function () {
|
15107 | __assign = Object.assign || function (t) {
|
15108 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
15109 | s = arguments[i];
|
15110 |
|
15111 | for (var p in s) {
|
15112 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
15113 | }
|
15114 | }
|
15115 |
|
15116 | return t;
|
15117 | };
|
15118 |
|
15119 | return __assign.apply(this, arguments);
|
15120 | };
|
15121 |
|
15122 | var __importStar = this && this.__importStar || function (mod) {
|
15123 | if (mod && mod.__esModule) return mod;
|
15124 | var result = {};
|
15125 | if (mod != null) for (var k in mod) {
|
15126 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
15127 | }
|
15128 | result["default"] = mod;
|
15129 | return result;
|
15130 | };
|
15131 |
|
15132 | var __importDefault = this && this.__importDefault || function (mod) {
|
15133 | return mod && mod.__esModule ? mod : {
|
15134 | "default": mod
|
15135 | };
|
15136 | };
|
15137 |
|
15138 | Object.defineProperty(exports, "__esModule", {
|
15139 | value: true
|
15140 | });
|
15141 |
|
15142 | var React = __importStar(__webpack_require__( "react"));
|
15143 |
|
15144 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
15145 |
|
15146 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
15147 |
|
15148 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
15149 |
|
15150 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
15151 |
|
15152 | var TOTPSetupComp_1 = __webpack_require__( "./lib/Widget/TOTPSetupComp.js");
|
15153 |
|
15154 | var logger = new core_1.ConsoleLogger('SelectMFAType');
|
15155 |
|
15156 | var SelectMFAType =
|
15157 |
|
15158 | function (_super) {
|
15159 | __extends(SelectMFAType, _super);
|
15160 |
|
15161 | function SelectMFAType(props) {
|
15162 | var _this = _super.call(this, props) || this;
|
15163 |
|
15164 | _this.verify = _this.verify.bind(_this);
|
15165 | _this.handleInputChange = _this.handleInputChange.bind(_this);
|
15166 | _this.state = {
|
15167 | TOTPSetup: false,
|
15168 | selectMessage: null
|
15169 | };
|
15170 | return _this;
|
15171 | }
|
15172 |
|
15173 | SelectMFAType.prototype.handleInputChange = function (evt) {
|
15174 |
|
15175 | this.setState({
|
15176 | TOTPSetup: false,
|
15177 | selectMessage: null
|
15178 | });
|
15179 | this.inputs = {};
|
15180 | var _a = evt.target,
|
15181 | name = _a.name,
|
15182 | value = _a.value,
|
15183 | type = _a.type,
|
15184 | checked = _a.checked;
|
15185 |
|
15186 | var check_type = ['radio', 'checkbox'].includes(type);
|
15187 | this.inputs[value] = check_type ? checked : value;
|
15188 | };
|
15189 |
|
15190 | SelectMFAType.prototype.verify = function () {
|
15191 | var _this = this;
|
15192 |
|
15193 | logger.debug('mfatypes inputs', this.inputs);
|
15194 |
|
15195 | if (!this.inputs) {
|
15196 | logger.debug('No mfa type selected');
|
15197 | return;
|
15198 | }
|
15199 |
|
15200 | var _a = this.inputs,
|
15201 | TOTP = _a.TOTP,
|
15202 | SMS = _a.SMS,
|
15203 | NOMFA = _a.NOMFA;
|
15204 | var mfaMethod = null;
|
15205 |
|
15206 | if (TOTP) {
|
15207 | mfaMethod = 'TOTP';
|
15208 | } else if (SMS) {
|
15209 | mfaMethod = 'SMS';
|
15210 | } else if (NOMFA) {
|
15211 | mfaMethod = 'NOMFA';
|
15212 | }
|
15213 |
|
15214 | var user = this.props.authData;
|
15215 |
|
15216 | if (!auth_1.Auth || typeof auth_1.Auth.setPreferredMFA !== 'function') {
|
15217 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
15218 | }
|
15219 |
|
15220 | auth_1.Auth.setPreferredMFA(user, mfaMethod).then(function (data) {
|
15221 | logger.debug('set preferred mfa success', data);
|
15222 |
|
15223 | _this.setState({
|
15224 | selectMessage: 'Success! Your MFA Type is now: ' + mfaMethod,
|
15225 | showToast: true
|
15226 | });
|
15227 | })["catch"](function (err) {
|
15228 | var message = err.message;
|
15229 |
|
15230 | if (message === 'User has not set up software token mfa' || message === 'User has not verified software token mfa') {
|
15231 | _this.setState({
|
15232 | TOTPSetup: true,
|
15233 | selectMessage: 'You need to setup TOTP',
|
15234 | showToast: true
|
15235 | });
|
15236 | } else {
|
15237 | logger.debug('set preferred mfa failed', err);
|
15238 |
|
15239 | _this.setState({
|
15240 | selectMessage: 'Failed! You cannot select MFA Type for now!',
|
15241 | showToast: true
|
15242 | });
|
15243 | }
|
15244 | });
|
15245 | };
|
15246 |
|
15247 | SelectMFAType.prototype.selectView = function (theme) {
|
15248 | var _this = this;
|
15249 |
|
15250 | var MFATypes = this.props.MFATypes;
|
15251 |
|
15252 | if (!MFATypes || Object.keys(MFATypes).length < 2) {
|
15253 | logger.debug('less than 2 mfa types available');
|
15254 | return React.createElement("div", null, React.createElement("a", null, "less than 2 mfa types available"));
|
15255 | }
|
15256 |
|
15257 | var SMS = MFATypes.SMS,
|
15258 | TOTP = MFATypes.TOTP,
|
15259 | Optional = MFATypes.Optional;
|
15260 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
15261 | theme: theme
|
15262 | }, this.state.showToast && this.state.selectMessage && React.createElement(Amplify_UI_Components_React_1.Toast, {
|
15263 | theme: theme,
|
15264 | onClose: function onClose() {
|
15265 | return _this.setState({
|
15266 | showToast: false
|
15267 | });
|
15268 | }
|
15269 | }, core_1.I18n.get(this.state.selectMessage)), React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
15270 | theme: theme
|
15271 | }, core_1.I18n.get('Select MFA Type')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
15272 | theme: theme
|
15273 | }, React.createElement("div", null, SMS ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
|
15274 | placeholder: core_1.I18n.get('SMS'),
|
15275 | theme: theme,
|
15276 | key: "sms",
|
15277 | name: "MFAType",
|
15278 | value: "SMS",
|
15279 | onChange: this.handleInputChange
|
15280 | }) : null, TOTP ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
|
15281 | placeholder: core_1.I18n.get('TOTP'),
|
15282 | theme: theme,
|
15283 | key: "totp",
|
15284 | name: "MFAType",
|
15285 | value: "TOTP",
|
15286 | onChange: this.handleInputChange
|
15287 | }) : null, Optional ? React.createElement(Amplify_UI_Components_React_1.RadioRow, {
|
15288 | placeholder: core_1.I18n.get('No MFA'),
|
15289 | theme: theme,
|
15290 | key: "noMFA",
|
15291 | name: "MFAType",
|
15292 | value: "NOMFA",
|
15293 | onChange: this.handleInputChange
|
15294 | }) : null)), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
15295 | theme: theme
|
15296 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
15297 | theme: theme,
|
15298 | onClick: this.verify
|
15299 | }, core_1.I18n.get('Verify'))));
|
15300 | };
|
15301 |
|
15302 | SelectMFAType.prototype.render = function () {
|
15303 | var theme = this.props.theme || Amplify_UI_Theme_1["default"];
|
15304 | return React.createElement("div", null, this.selectView(theme), this.state.TOTPSetup ? React.createElement(TOTPSetupComp_1.TOTPSetupComp, __assign({}, this.props)) : null);
|
15305 | };
|
15306 |
|
15307 | return SelectMFAType;
|
15308 | }(React.Component);
|
15309 |
|
15310 | exports.SelectMFAType = SelectMFAType;
|
15311 |
|
15312 |
|
15313 |
|
15314 |
|
15315 | exports["default"] = SelectMFAType;
|
15316 |
|
15317 | }),
|
15318 |
|
15319 | "./lib/Widget/TOTPSetupComp.js":
|
15320 |
|
15321 |
|
15322 |
|
15323 |
|
15324 | (function(module, exports, __webpack_require__) {
|
15325 |
|
15326 | "use strict";
|
15327 |
|
15328 |
|
15329 |
|
15330 |
|
15331 |
|
15332 |
|
15333 |
|
15334 |
|
15335 |
|
15336 |
|
15337 |
|
15338 |
|
15339 |
|
15340 |
|
15341 | var __extends = this && this.__extends || function () {
|
15342 | var _extendStatics = function extendStatics(d, b) {
|
15343 | _extendStatics = Object.setPrototypeOf || {
|
15344 | __proto__: []
|
15345 | } instanceof Array && function (d, b) {
|
15346 | d.__proto__ = b;
|
15347 | } || function (d, b) {
|
15348 | for (var p in b) {
|
15349 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
15350 | }
|
15351 | };
|
15352 |
|
15353 | return _extendStatics(d, b);
|
15354 | };
|
15355 |
|
15356 | return function (d, b) {
|
15357 | _extendStatics(d, b);
|
15358 |
|
15359 | function __() {
|
15360 | this.constructor = d;
|
15361 | }
|
15362 |
|
15363 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15364 | };
|
15365 | }();
|
15366 |
|
15367 | var __importStar = this && this.__importStar || function (mod) {
|
15368 | if (mod && mod.__esModule) return mod;
|
15369 | var result = {};
|
15370 | if (mod != null) for (var k in mod) {
|
15371 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
15372 | }
|
15373 | result["default"] = mod;
|
15374 | return result;
|
15375 | };
|
15376 |
|
15377 | var __importDefault = this && this.__importDefault || function (mod) {
|
15378 | return mod && mod.__esModule ? mod : {
|
15379 | "default": mod
|
15380 | };
|
15381 | };
|
15382 |
|
15383 | Object.defineProperty(exports, "__esModule", {
|
15384 | value: true
|
15385 | });
|
15386 |
|
15387 | var React = __importStar(__webpack_require__( "react"));
|
15388 |
|
15389 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
15390 |
|
15391 | var auth_1 = __webpack_require__( "@aws-amplify/auth");
|
15392 |
|
15393 | var Amplify_UI_Theme_1 = __importDefault(__webpack_require__( "./lib/Amplify-UI/Amplify-UI-Theme.js"));
|
15394 |
|
15395 | var Amplify_UI_Components_React_1 = __webpack_require__( "./lib/Amplify-UI/Amplify-UI-Components-React.js");
|
15396 |
|
15397 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
15398 |
|
15399 | var qrcode_react_1 = __importDefault(__webpack_require__( "../../node_modules/qrcode.react/lib/index.js"));
|
15400 |
|
15401 | var logger = new core_1.ConsoleLogger('TOTPSetupComp');
|
15402 |
|
15403 | var TOTPSetupComp =
|
15404 |
|
15405 | function (_super) {
|
15406 | __extends(TOTPSetupComp, _super);
|
15407 |
|
15408 | function TOTPSetupComp(props) {
|
15409 | var _this = _super.call(this, props) || this;
|
15410 |
|
15411 | _this.setup = _this.setup.bind(_this);
|
15412 | _this.showSecretCode = _this.showSecretCode.bind(_this);
|
15413 | _this.verifyTotpToken = _this.verifyTotpToken.bind(_this);
|
15414 | _this.handleInputChange = _this.handleInputChange.bind(_this);
|
15415 | _this.triggerTOTPEvent = _this.triggerTOTPEvent.bind(_this);
|
15416 | _this.state = {
|
15417 | code: null,
|
15418 | setupMessage: null
|
15419 | };
|
15420 | return _this;
|
15421 | }
|
15422 |
|
15423 | TOTPSetupComp.prototype.componentDidMount = function () {
|
15424 | this.setup();
|
15425 | };
|
15426 |
|
15427 | TOTPSetupComp.prototype.triggerTOTPEvent = function (event, data, user) {
|
15428 | if (this.props.onTOTPEvent) {
|
15429 | this.props.onTOTPEvent(event, data, user);
|
15430 | }
|
15431 | };
|
15432 |
|
15433 | TOTPSetupComp.prototype.handleInputChange = function (evt) {
|
15434 | this.setState({
|
15435 | setupMessage: null
|
15436 | });
|
15437 | this.inputs = {};
|
15438 | var _a = evt.target,
|
15439 | name = _a.name,
|
15440 | value = _a.value,
|
15441 | type = _a.type,
|
15442 | checked = _a.checked;
|
15443 |
|
15444 | var check_type = ['radio', 'checkbox'].includes(type);
|
15445 | this.inputs[name] = check_type ? checked : value;
|
15446 | };
|
15447 |
|
15448 | TOTPSetupComp.prototype.setup = function () {
|
15449 | var _this = this;
|
15450 |
|
15451 | this.setState({
|
15452 | setupMessage: null
|
15453 | });
|
15454 | var user = this.props.authData;
|
15455 | var issuer = encodeURI(core_1.I18n.get('AWSCognito'));
|
15456 |
|
15457 | if (!auth_1.Auth || typeof auth_1.Auth.setupTOTP !== 'function') {
|
15458 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
15459 | }
|
15460 |
|
15461 | auth_1.Auth.setupTOTP(user).then(function (data) {
|
15462 | logger.debug('secret key', data);
|
15463 | var code = 'otpauth://totp/' + issuer + ':' + user.username + '?secret=' + data + '&issuer=' + issuer;
|
15464 |
|
15465 | _this.setState({
|
15466 | code: code
|
15467 | });
|
15468 | })["catch"](function (err) {
|
15469 | return logger.debug('totp setup failed', err);
|
15470 | });
|
15471 | };
|
15472 |
|
15473 | TOTPSetupComp.prototype.verifyTotpToken = function () {
|
15474 | var _this = this;
|
15475 |
|
15476 | if (!this.inputs) {
|
15477 | logger.debug('no input');
|
15478 | return;
|
15479 | }
|
15480 |
|
15481 | var user = this.props.authData;
|
15482 | var totpCode = this.inputs.totpCode;
|
15483 |
|
15484 | if (!auth_1.Auth || typeof auth_1.Auth.verifyTotpToken !== 'function' || typeof auth_1.Auth.setPreferredMFA !== 'function') {
|
15485 | throw new Error('No Auth module found, please ensure @aws-amplify/auth is imported');
|
15486 | }
|
15487 |
|
15488 | return auth_1.Auth.verifyTotpToken(user, totpCode).then(function () {
|
15489 |
|
15490 | return auth_1.Auth.setPreferredMFA(user, 'TOTP').then(function () {
|
15491 | _this.setState({
|
15492 | setupMessage: 'Setup TOTP successfully!'
|
15493 | });
|
15494 |
|
15495 | logger.debug('set up totp success!');
|
15496 |
|
15497 | _this.triggerTOTPEvent('Setup TOTP', 'SUCCESS', user);
|
15498 | })["catch"](function (err) {
|
15499 | _this.setState({
|
15500 | setupMessage: 'Setup TOTP failed!'
|
15501 | });
|
15502 |
|
15503 | logger.error(err);
|
15504 | });
|
15505 | })["catch"](function (err) {
|
15506 | _this.setState({
|
15507 | setupMessage: 'Setup TOTP failed!'
|
15508 | });
|
15509 |
|
15510 | logger.error(err);
|
15511 | });
|
15512 | };
|
15513 |
|
15514 | TOTPSetupComp.prototype.showSecretCode = function (code, theme) {
|
15515 | if (!code) return null;
|
15516 | return React.createElement("div", null, React.createElement("div", {
|
15517 | className: ui_1.totpQrcode
|
15518 | }, React.createElement(qrcode_react_1["default"], {
|
15519 | value: code
|
15520 | })), React.createElement(Amplify_UI_Components_React_1.InputLabel, {
|
15521 | theme: theme
|
15522 | }, core_1.I18n.get('Enter Security Code:')), React.createElement(Amplify_UI_Components_React_1.Input, {
|
15523 | autoFocus: true,
|
15524 | theme: theme,
|
15525 | key: "totpCode",
|
15526 | name: "totpCode",
|
15527 | onChange: this.handleInputChange
|
15528 | }));
|
15529 | };
|
15530 |
|
15531 | TOTPSetupComp.prototype.render = function () {
|
15532 | var theme = this.props.theme ? this.props.theme : Amplify_UI_Theme_1["default"];
|
15533 | var code = this.state.code;
|
15534 | return React.createElement(Amplify_UI_Components_React_1.FormSection, {
|
15535 | theme: theme
|
15536 | }, this.state.setupMessage && React.createElement(Amplify_UI_Components_React_1.Toast, null, core_1.I18n.get(this.state.setupMessage)), React.createElement(Amplify_UI_Components_React_1.SectionHeader, {
|
15537 | theme: theme
|
15538 | }, core_1.I18n.get('Scan then enter verification code')), React.createElement(Amplify_UI_Components_React_1.SectionBody, {
|
15539 | theme: theme
|
15540 | }, this.showSecretCode(code, theme), this.state.setupMessage && core_1.I18n.get(this.state.setupMessage)), React.createElement(Amplify_UI_Components_React_1.SectionFooter, {
|
15541 | theme: theme
|
15542 | }, React.createElement(Amplify_UI_Components_React_1.Button, {
|
15543 | theme: theme,
|
15544 | onClick: this.verifyTotpToken,
|
15545 | style: {
|
15546 | width: '100%'
|
15547 | }
|
15548 | }, core_1.I18n.get('Verify Security Token'))));
|
15549 | };
|
15550 |
|
15551 | return TOTPSetupComp;
|
15552 | }(React.Component);
|
15553 |
|
15554 | exports.TOTPSetupComp = TOTPSetupComp;
|
15555 |
|
15556 |
|
15557 |
|
15558 |
|
15559 | exports["default"] = TOTPSetupComp;
|
15560 |
|
15561 | }),
|
15562 |
|
15563 | "./lib/Widget/TextPicker.js":
|
15564 |
|
15565 |
|
15566 |
|
15567 |
|
15568 | (function(module, exports, __webpack_require__) {
|
15569 |
|
15570 | "use strict";
|
15571 |
|
15572 |
|
15573 |
|
15574 |
|
15575 |
|
15576 |
|
15577 |
|
15578 |
|
15579 |
|
15580 |
|
15581 |
|
15582 |
|
15583 |
|
15584 |
|
15585 | var __extends = this && this.__extends || function () {
|
15586 | var _extendStatics = function extendStatics(d, b) {
|
15587 | _extendStatics = Object.setPrototypeOf || {
|
15588 | __proto__: []
|
15589 | } instanceof Array && function (d, b) {
|
15590 | d.__proto__ = b;
|
15591 | } || function (d, b) {
|
15592 | for (var p in b) {
|
15593 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
15594 | }
|
15595 | };
|
15596 |
|
15597 | return _extendStatics(d, b);
|
15598 | };
|
15599 |
|
15600 | return function (d, b) {
|
15601 | _extendStatics(d, b);
|
15602 |
|
15603 | function __() {
|
15604 | this.constructor = d;
|
15605 | }
|
15606 |
|
15607 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15608 | };
|
15609 | }();
|
15610 |
|
15611 | var __importStar = this && this.__importStar || function (mod) {
|
15612 | if (mod && mod.__esModule) return mod;
|
15613 | var result = {};
|
15614 | if (mod != null) for (var k in mod) {
|
15615 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
15616 | }
|
15617 | result["default"] = mod;
|
15618 | return result;
|
15619 | };
|
15620 |
|
15621 | var __importDefault = this && this.__importDefault || function (mod) {
|
15622 | return mod && mod.__esModule ? mod : {
|
15623 | "default": mod
|
15624 | };
|
15625 | };
|
15626 |
|
15627 | Object.defineProperty(exports, "__esModule", {
|
15628 | value: true
|
15629 | });
|
15630 |
|
15631 | var React = __importStar(__webpack_require__( "react"));
|
15632 |
|
15633 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
15634 |
|
15635 | var AmplifyTheme_1 = __importDefault(__webpack_require__( "./lib/AmplifyTheme.js"));
|
15636 |
|
15637 | var Picker_1 = __webpack_require__( "./lib/Widget/Picker.js");
|
15638 |
|
15639 | var Container = {};
|
15640 | var PickerPreview = {
|
15641 | maxWidth: '100%'
|
15642 | };
|
15643 | var logger = new core_1.ConsoleLogger('TextPicker');
|
15644 |
|
15645 | var TextPicker =
|
15646 |
|
15647 | function (_super) {
|
15648 | __extends(TextPicker, _super);
|
15649 |
|
15650 | function TextPicker(props) {
|
15651 | var _this = _super.call(this, props) || this;
|
15652 |
|
15653 | _this.handlePick = _this.handlePick.bind(_this);
|
15654 | _this.state = {
|
15655 | previewText: props.previewText
|
15656 | };
|
15657 | return _this;
|
15658 | }
|
15659 |
|
15660 | TextPicker.prototype.handlePick = function (data) {
|
15661 | var that = this;
|
15662 | var file = data.file,
|
15663 | name = data.name,
|
15664 | size = data.size,
|
15665 | type = data.type;
|
15666 | var _a = this.props,
|
15667 | preview = _a.preview,
|
15668 | onPick = _a.onPick,
|
15669 | onLoad = _a.onLoad;
|
15670 |
|
15671 | if (onPick) {
|
15672 | onPick(data);
|
15673 | }
|
15674 |
|
15675 | if (preview) {
|
15676 | var reader = new FileReader();
|
15677 |
|
15678 | reader.onload = function (e) {
|
15679 | var text = e.target.result;
|
15680 |
|
15681 | that.setState({
|
15682 | previewText: text
|
15683 | });
|
15684 |
|
15685 | if (onLoad) {
|
15686 | onLoad(text);
|
15687 | }
|
15688 | };
|
15689 |
|
15690 | reader.readAsText(file);
|
15691 | }
|
15692 | };
|
15693 |
|
15694 | TextPicker.prototype.render = function () {
|
15695 | var preview = this.props.preview;
|
15696 | var previewText = this.state.previewText;
|
15697 | var title = this.props.title || 'Pick a File';
|
15698 | var theme = this.props.theme || AmplifyTheme_1["default"];
|
15699 | var containerStyle = Object.assign({}, Container, theme.picker);
|
15700 | var previewStyle = Object.assign({}, PickerPreview, theme.pickerPreview, theme.halfHeight, preview && preview !== 'hidden' ? {} : AmplifyTheme_1["default"].hidden);
|
15701 | return React.createElement("div", {
|
15702 | style: containerStyle
|
15703 | }, previewText ? React.createElement("div", {
|
15704 | style: previewStyle
|
15705 | }, React.createElement("pre", {
|
15706 | style: theme.pre
|
15707 | }, previewText)) : null, React.createElement(Picker_1.Picker, {
|
15708 | title: title,
|
15709 | accept: "text/*",
|
15710 | theme: theme,
|
15711 | onPick: this.handlePick
|
15712 | }));
|
15713 | };
|
15714 |
|
15715 | return TextPicker;
|
15716 | }(React.Component);
|
15717 |
|
15718 | exports.TextPicker = TextPicker;
|
15719 |
|
15720 |
|
15721 |
|
15722 |
|
15723 | exports["default"] = TextPicker;
|
15724 |
|
15725 | }),
|
15726 |
|
15727 | "./lib/Widget/index.js":
|
15728 |
|
15729 |
|
15730 |
|
15731 |
|
15732 | (function(module, exports, __webpack_require__) {
|
15733 |
|
15734 | "use strict";
|
15735 |
|
15736 |
|
15737 | Object.defineProperty(exports, "__esModule", {
|
15738 | value: true
|
15739 | });
|
15740 |
|
15741 | var Picker_1 = __webpack_require__( "./lib/Widget/Picker.js");
|
15742 |
|
15743 | exports.Picker = Picker_1.Picker;
|
15744 |
|
15745 | var PhotoPicker_1 = __webpack_require__( "./lib/Widget/PhotoPicker.js");
|
15746 |
|
15747 | exports.PhotoPicker = PhotoPicker_1.PhotoPicker;
|
15748 |
|
15749 | var TextPicker_1 = __webpack_require__( "./lib/Widget/TextPicker.js");
|
15750 |
|
15751 | exports.TextPicker = TextPicker_1.TextPicker;
|
15752 |
|
15753 | var SelectMFAType_1 = __webpack_require__( "./lib/Widget/SelectMFAType.js");
|
15754 |
|
15755 | exports.SelectMFAType = SelectMFAType_1.SelectMFAType;
|
15756 |
|
15757 | var TOTPSetupComp_1 = __webpack_require__( "./lib/Widget/TOTPSetupComp.js");
|
15758 |
|
15759 | exports.TOTPSetupComp = TOTPSetupComp_1.TOTPSetupComp;
|
15760 |
|
15761 | }),
|
15762 |
|
15763 | "./lib/XR/IconButton.js":
|
15764 |
|
15765 |
|
15766 |
|
15767 |
|
15768 | (function(module, exports, __webpack_require__) {
|
15769 |
|
15770 | "use strict";
|
15771 |
|
15772 |
|
15773 | var __importStar = this && this.__importStar || function (mod) {
|
15774 | if (mod && mod.__esModule) return mod;
|
15775 | var result = {};
|
15776 | if (mod != null) for (var k in mod) {
|
15777 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
15778 | }
|
15779 | result["default"] = mod;
|
15780 | return result;
|
15781 | };
|
15782 |
|
15783 | var __importDefault = this && this.__importDefault || function (mod) {
|
15784 | return mod && mod.__esModule ? mod : {
|
15785 | "default": mod
|
15786 | };
|
15787 | };
|
15788 |
|
15789 | Object.defineProperty(exports, "__esModule", {
|
15790 | value: true
|
15791 | });
|
15792 |
|
15793 |
|
15794 |
|
15795 |
|
15796 |
|
15797 |
|
15798 |
|
15799 |
|
15800 |
|
15801 |
|
15802 |
|
15803 |
|
15804 |
|
15805 | var React = __importStar(__webpack_require__( "react"));
|
15806 |
|
15807 | var Tooltip_1 = __importDefault(__webpack_require__( "./lib/XR/Tooltip.js"));
|
15808 |
|
15809 | var AmplifyUI = __importStar(__webpack_require__( "@aws-amplify/ui"));
|
15810 |
|
15811 | exports.IconButton = function (props) {
|
15812 | var buttonIcon;
|
15813 |
|
15814 | switch (props.variant) {
|
15815 | case 'sound-mute':
|
15816 | buttonIcon = React.createElement("svg", {
|
15817 | width: "19",
|
15818 | height: "19",
|
15819 | viewBox: "0 0 19 19",
|
15820 | xmlns: "http://www.w3.org/2000/svg"
|
15821 | }, React.createElement("g", {
|
15822 | id: "icons/minis/volumeOff",
|
15823 | fill: "none",
|
15824 | fillRule: "evenodd"
|
15825 | }, React.createElement("path", {
|
15826 | d: "M3.48026899,12.9630494 C3.63825091,12.9630494 3.79237961,13.0108921 3.92264322,13.1003479 L8.77467683,16.8113609 C9.29423971,17.1679383 10,16.7950396 10,16.1637406 L10,3.78619489 C10,3.15489596 9.29423971,2.78199725 8.77467683,3.13857463 L3.92264322,6.84545211 C3.79237961,6.93490793 3.63825091,6.9827506 3.48026899,6.9827506 L1.78294894,6.9827506 C1.3505185,6.9827506 1,7.33409518 1,7.76754476 L1,12.1781306 C1,12.6117048 1.3505185,12.9630494 1.78294894,12.9630494 L3.48026899,12.9630494 Z M17.2118156,7 L15.0918385,9.11997713 L12.9718614,7 L12,7.97174685 L14.1200917,10.091724 L12,12.2118156 L12.9718614,13.1835625 L15.0918385,11.0635854 L17.2118156,13.1835625 L18.1835625,12.2118156 L16.0635854,10.091724 L18.1835625,7.97174685 L17.2118156,7 Z",
|
15827 | id: "Fill-2",
|
15828 | fill: "#FFF"
|
15829 | })));
|
15830 | break;
|
15831 |
|
15832 | case 'sound':
|
15833 | buttonIcon = React.createElement("svg", {
|
15834 | width: "19",
|
15835 | height: "19",
|
15836 | viewBox: "0 0 19 19",
|
15837 | xmlns: "http://www.w3.org/2000/svg"
|
15838 | }, React.createElement("g", {
|
15839 | id: "icons/minis/volumeOn",
|
15840 | fill: "none",
|
15841 | fillRule: "evenodd"
|
15842 | }, React.createElement("path", {
|
15843 | d: "M3.48026899,12.9630494 L1.78294894,12.9630494 C1.3505185,12.9630494 1,12.6117048 1,12.1781306 L1,7.76754476 C1,7.33409518 1.3505185,6.9827506 1.78294894,6.9827506 L3.48026899,6.9827506 C3.63825091,6.9827506 3.79237961,6.93490793 3.92264322,6.84545211 L8.77467683,3.13857463 C9.29423971,2.78199725 10,3.15489596 10,3.78619489 L10,16.1637406 C10,16.7950396 9.29423971,17.1679383 8.77467683,16.8113609 L3.92264322,13.1003479 C3.79237961,13.0108921 3.63825091,12.9630494 3.48026899,12.9630494 Z M14.9270376,3.03232286 C15.1729267,3.03232286 15.4040399,3.12815658 15.5777627,3.3022351 C17.3699891,5.09889099 18.3570052,7.48235058 18.3570052,10.0135053 C18.3570052,12.54466 17.3699891,14.9281196 15.5777627,16.7247755 C15.4041045,16.898854 15.1729914,16.9947524 14.9270052,16.9947524 C14.6820861,16.9947524 14.4515549,16.899436 14.2777674,16.7263598 C13.9192316,16.3684383 13.9185203,15.7852882 14.2762477,15.4264291 C15.7222893,13.9769926 16.5186727,12.0545954 16.5186727,10.0135053 C16.5186727,7.97241524 15.7222893,6.05001801 14.2762154,4.60058152 C13.9184879,4.24175473 13.9191992,3.65857229 14.277832,3.30065081 C14.4514256,3.1275746 14.6819567,3.03232286 14.9270376,3.03232286 Z M13.5730665,6.11570485 C14.6133991,7.15574642 15.1862998,8.54003279 15.1862998,10.0134924 C15.1862998,11.4892799 14.6113945,12.8741159 13.5675376,13.9128965 C13.3942351,14.0855848 13.1639626,14.1806425 12.9191727,14.1806425 C12.6727016,14.1806425 12.4412975,14.0844531 12.2677039,13.9097926 C12.0944984,13.7358111 11.9994406,13.5047303 11.9999903,13.2592291 C12.0005723,13.0136956 12.096794,12.7831644 12.2708079,12.6100882 C12.9654406,11.9185917 13.3479995,10.996467 13.3479995,10.0134924 C13.3479995,9.03119677 12.966346,8.1086194 12.2733298,7.4157649 C11.9150203,7.05745543 11.9149233,6.47436998 12.2731358,6.11589885 C12.4467617,5.94224065 12.6775838,5.84666559 12.923085,5.84666559 C13.1685538,5.84666559 13.3993436,5.94220831 13.5730665,6.11570485 Z",
|
15844 | id: "Fill-2",
|
15845 | fill: "#FFF"
|
15846 | })));
|
15847 | break;
|
15848 |
|
15849 | case 'maximize':
|
15850 | buttonIcon = React.createElement("svg", {
|
15851 | width: "19",
|
15852 | height: "19",
|
15853 | viewBox: "0 0 19 19",
|
15854 | xmlns: "http://www.w3.org/2000/svg"
|
15855 | }, React.createElement("g", {
|
15856 | id: "icons/minis/screenfull",
|
15857 | fill: "none",
|
15858 | fillRule: "evenodd"
|
15859 | }, React.createElement("path", {
|
15860 | d: "M2.04162598,3 L2.04162598,16 L17.0147705,16 L17.0147705,3 L2.04162598,3 Z M1,2 L18,2 L18,17 L1,17 L1,2 Z M3,4 L16,4 L16,15 L3,15 L3,4 Z",
|
15861 | id: "Rectangle-Copy",
|
15862 | fill: "#FFF",
|
15863 | fillRule: "nonzero"
|
15864 | })));
|
15865 | break;
|
15866 |
|
15867 | case 'minimize':
|
15868 | buttonIcon = React.createElement("svg", {
|
15869 | width: "19",
|
15870 | height: "19",
|
15871 | viewBox: "0 0 19 19",
|
15872 | xmlns: "http://www.w3.org/2000/svg"
|
15873 | }, React.createElement("g", {
|
15874 | id: "icons/minis/screensmall",
|
15875 | fill: "none",
|
15876 | fillRule: "evenodd"
|
15877 | }, React.createElement("path", {
|
15878 | d: "M11,16 L17.0147705,16 L17.0147705,3 L2.04162598,3 L2.04162598,10 L11,10 L11,16 Z M1,2 L18,2 L18,17 L1,17 L1,2 Z",
|
15879 | id: "Rectangle",
|
15880 | fill: "#FFF",
|
15881 | fillRule: "nonzero"
|
15882 | })));
|
15883 | break;
|
15884 |
|
15885 | case 'enter-vr':
|
15886 | buttonIcon = React.createElement("svg", {
|
15887 | width: "19",
|
15888 | height: "19",
|
15889 | viewBox: "0 0 17 10",
|
15890 | xmlns: "http://www.w3.org/2000/svg"
|
15891 | }, React.createElement("g", {
|
15892 | id: "Page-1",
|
15893 | fill: "none",
|
15894 | fillRule: "evenodd"
|
15895 | }, React.createElement("g", {
|
15896 | id: "VRon",
|
15897 | fill: "#FFF",
|
15898 | fillRule: "nonzero"
|
15899 | }, React.createElement("path", {
|
15900 | d: "M15.7856977,0.02395184 L15.8915734,0.02395184 C16.5037405,0.02395184 17,0.520211324 17,1.13237842 L17,1.54663675 L17,8.8915038 C17,9.5034193 16.4560011,10 15.7856977,10 L12.0095825,10 C9.98324439,7.1593807 8.80676009,5.741338 8.48012959,5.74587199 C8.16206045,5.75028714 7.01003321,7.1683298 5.02404785,10 L1.21426911,10 C0.543965735,10 3.32031236e-05,9.5034193 3.32031236e-05,8.8915038 L3.32031236e-05,1.54663675 L3.32031236e-05,1.13237842 L3.32031236e-05,1.13237842 C3.32031236e-05,0.520211324 0.496292687,0.02395184 1.10845978,0.02395184 L1.21426911,0.02395184 L15.7856977,0.02395184 Z M4.5,6 C5.32842712,6 6,5.32842712 6,4.5 C6,3.67157288 5.32842712,3 4.5,3 C3.67157288,3 3,3.67157288 3,4.5 C3,5.32842712 3.67157288,6 4.5,6 Z M12.5,6 C13.3284271,6 14,5.32842712 14,4.5 C14,3.67157288 13.3284271,3 12.5,3 C11.6715729,3 11,3.67157288 11,4.5 C11,5.32842712 11.6715729,6 12.5,6 Z",
|
15901 | id: "Fill-1"
|
15902 | }))));
|
15903 | break;
|
15904 |
|
15905 | case 'exit-vr':
|
15906 | buttonIcon = React.createElement("svg", {
|
15907 | width: "19",
|
15908 | height: "19",
|
15909 | viewBox: "0 0 19 19",
|
15910 | xmlns: "http://www.w3.org/2000/svg"
|
15911 | }, React.createElement("g", {
|
15912 | id: "icons/minis/VRon-Copy",
|
15913 | fill: "none",
|
15914 | fillRule: "evenodd"
|
15915 | }, React.createElement("g", {
|
15916 | id: "Group-7-Copy",
|
15917 | transform: "translate(1 3)",
|
15918 | fill: "#FFF"
|
15919 | }, React.createElement("path", {
|
15920 | d: "M15.7856977,3.02395184 L17,3.02395184 L17,4.13237842 L17,4.54663675 L17,11.8915038 C17,12.5034193 16.4560011,13 15.7856977,13 L12.0095825,13 C9.98324439,10.1593807 8.80676009,8.741338 8.48012959,8.74587199 C8.16206045,8.75028714 7.01003321,10.1683298 5.02404785,13 L1.21426911,13 C0.543965735,13 3.32031236e-05,12.5034193 3.32031236e-05,11.8915038 L3.32031236e-05,4.54663675 L3.32031236e-05,4.13237842 L3.32031236e-05,3.02395184 L1.21426911,3.02395184 L15.7856977,3.02395184 Z M4.5,9 C5.32842712,9 6,8.32842712 6,7.5 C6,6.67157288 5.32842712,6 4.5,6 C3.67157288,6 3,6.67157288 3,7.5 C3,8.32842712 3.67157288,9 4.5,9 Z M12.5,9 C13.3284271,9 14,8.32842712 14,7.5 C14,6.67157288 13.3284271,6 12.5,6 C11.6715729,6 11,6.67157288 11,7.5 C11,8.32842712 11.6715729,9 12.5,9 Z M2.5486669,0 L14.420089,0 C14.7977406,0 15.1613805,0.149260956 15.4374308,0.417695511 L16.9999668,2.00634766 L0,2.00634766 L1.58537972,0.395493117 C1.84682061,0.141306827 2.19106994,0 2.5486669,0 Z",
|
15921 | id: "Fill-1"
|
15922 | }))));
|
15923 | break;
|
15924 |
|
15925 | default:
|
15926 | buttonIcon = null;
|
15927 | break;
|
15928 | }
|
15929 |
|
15930 | return React.createElement(Tooltip_1["default"], {
|
15931 | text: props.tooltip,
|
15932 | autoShowTooltip: props.autoShowTooltip
|
15933 | }, React.createElement("button", {
|
15934 | className: AmplifyUI.actionButton,
|
15935 | onClick: props.onClick
|
15936 | }, buttonIcon));
|
15937 | };
|
15938 |
|
15939 |
|
15940 |
|
15941 |
|
15942 |
|
15943 | exports["default"] = exports.IconButton;
|
15944 |
|
15945 | }),
|
15946 |
|
15947 | "./lib/XR/Loading.js":
|
15948 |
|
15949 |
|
15950 |
|
15951 |
|
15952 | (function(module, exports, __webpack_require__) {
|
15953 |
|
15954 | "use strict";
|
15955 |
|
15956 |
|
15957 | var __importStar = this && this.__importStar || function (mod) {
|
15958 | if (mod && mod.__esModule) return mod;
|
15959 | var result = {};
|
15960 | if (mod != null) for (var k in mod) {
|
15961 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
15962 | }
|
15963 | result["default"] = mod;
|
15964 | return result;
|
15965 | };
|
15966 |
|
15967 | Object.defineProperty(exports, "__esModule", {
|
15968 | value: true
|
15969 | });
|
15970 |
|
15971 |
|
15972 |
|
15973 |
|
15974 |
|
15975 |
|
15976 |
|
15977 |
|
15978 |
|
15979 |
|
15980 |
|
15981 |
|
15982 |
|
15983 | var React = __importStar(__webpack_require__( "react"));
|
15984 |
|
15985 | var AmplifyUI = __importStar(__webpack_require__( "@aws-amplify/ui"));
|
15986 |
|
15987 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
15988 |
|
15989 | exports.Loading = function (props) {
|
15990 | return React.createElement("div", {
|
15991 | className: AmplifyUI.loadingOverlay,
|
15992 | "data-test": data_test_attributes_1.sumerianScene.loading
|
15993 | }, React.createElement("div", {
|
15994 | className: AmplifyUI.loadingContainer
|
15995 | }, React.createElement("div", {
|
15996 | className: AmplifyUI.loadingLogo,
|
15997 | "data-test": data_test_attributes_1.sumerianScene.loadingLogo
|
15998 | }, React.createElement("svg", {
|
15999 | viewBox: "0 0 800 481",
|
16000 | xmlns: "http://www.w3.org/2000/svg"
|
16001 | }, React.createElement("g", {
|
16002 | id: "Page-1",
|
16003 | fillRule: "evenodd"
|
16004 | }, React.createElement("g", {
|
16005 | id: "AWS_logo_RGB-(1)",
|
16006 | transform: "translate(-16 -17)",
|
16007 | fillRule: "nonzero"
|
16008 | }, React.createElement("path", {
|
16009 | d: "M241.371,190.172 C241.371,197.487 241.371,204.801 245.028,212.115 C245.028,219.43 248.685,226.744 252.343,234.058 C252.343,234.058 252.343,237.715 256,241.373 C256,245.03 252.343,248.688 252.343,248.688 L234.058,256.002 C230.401,256.002 230.401,259.659 226.743,259.659 C223.085,259.659 219.428,259.659 219.428,256.002 C219.428,252.345 212.113,248.687 208.457,245.031 C208.457,237.716 204.8,234.06 201.142,226.745 C182.856,248.688 153.599,263.317 124.342,263.317 C106.057,263.317 84.114,256.002 69.485,245.031 C54.856,230.402 51.2,212.116 51.2,193.831 C51.2,171.888 58.515,153.603 73.143,138.974 C91.428,124.345 113.371,117.031 138.972,117.031 C149.943,117.031 157.258,117.031 168.229,120.688 C179.2,120.688 186.515,124.345 197.486,128.003 L197.486,106.06 C197.486,91.431 193.829,76.803 186.515,62.174 C171.886,54.859 157.258,51.203 142.629,51.203 C131.658,51.203 124.344,51.203 113.372,54.86 C102.4,58.517 95.087,62.175 84.115,65.832 C80.458,65.832 76.801,69.489 73.143,69.489 L69.486,69.489 C65.829,69.489 62.171,65.832 62.171,62.174 L62.171,47.545 C62.171,43.888 62.171,40.23 65.828,36.574 C69.485,36.574 73.142,32.917 73.142,32.917 C84.114,29.26 95.085,25.603 109.714,21.946 C124.343,18.289 138.971,18.289 149.942,18.289 C175.542,14.632 201.142,21.946 219.428,36.574 C234.057,54.859 245.028,76.802 241.371,102.403 L241.371,190.175 L241.371,190.172 Z M131.657,230.4 C142.628,230.4 149.942,230.4 160.914,226.743 C171.886,223.086 179.199,215.772 186.514,208.457 C190.171,204.8 193.829,197.486 193.829,193.828 C197.486,182.857 197.486,175.543 197.486,168.228 L197.486,157.257 C190.171,157.257 182.857,153.6 171.886,153.6 C164.571,153.6 153.6,153.6 146.286,153.6 C135.315,149.943 120.686,153.6 109.714,160.915 C98.742,168.23 95.085,179.2 95.085,190.172 C95.085,201.143 98.742,212.115 106.057,219.429 C113.372,226.743 124.342,230.4 131.657,230.4 Z M347.428,259.657 C343.771,259.657 340.113,259.657 336.457,256 C332.801,252.343 332.8,248.685 332.8,245.029 L270.629,40.229 C270.629,36.572 266.972,32.914 266.972,29.258 C266.972,29.258 266.972,25.601 266.972,25.601 C266.972,25.601 270.629,21.944 270.629,25.601 L296.229,25.601 C299.886,25.601 303.544,25.601 307.2,29.258 C310.857,29.258 314.515,32.915 314.515,36.573 L358.4,212.116 L402.285,36.573 C402.285,32.916 405.942,29.259 405.942,25.602 C409.599,21.945 413.257,21.945 416.913,21.945 L438.856,21.945 C442.513,21.945 446.171,21.945 449.827,25.602 C453.483,29.259 453.484,32.917 453.484,36.573 L493.712,215.773 L541.255,36.573 C541.255,32.916 544.912,29.259 544.912,25.602 C548.569,21.945 552.226,21.945 555.883,21.945 L581.483,21.945 C581.483,21.945 585.14,21.945 585.14,21.945 C585.14,21.945 588.797,25.602 585.14,25.602 C585.14,25.602 585.14,29.259 585.14,29.259 C585.14,32.916 585.14,32.916 581.483,36.573 L515.655,241.373 C515.655,245.03 511.998,248.688 508.34,252.344 C504.682,256 501.025,256.001 497.369,256.001 L475.426,256.001 C471.769,256.001 468.111,256.001 464.455,252.344 C460.799,248.687 460.798,245.029 460.798,241.373 L427.884,73.145 L387.656,245.031 C387.656,248.688 383.999,252.346 383.999,256.002 C380.342,259.659 376.684,259.659 373.028,259.659 L347.428,259.659 L347.428,259.657 Z M687.543,266.971 C672.914,266.971 658.286,266.971 647.314,263.314 C636.342,259.657 625.371,255.999 618.057,252.343 C610.743,248.686 607.086,245.028 607.086,237.714 L607.086,223.085 C607.086,215.77 610.743,215.77 614.4,215.77 C614.4,215.77 618.057,215.77 618.057,215.77 L625.371,219.427 C636.342,223.084 643.656,226.742 654.628,230.398 C665.6,234.054 676.571,234.055 687.542,234.055 C702.171,234.055 713.142,230.398 727.771,226.74 C735.085,223.083 742.4,212.111 742.4,201.14 C742.4,193.825 738.743,186.511 735.086,182.855 C727.772,175.54 716.801,171.884 705.829,168.226 L665.6,157.255 C650.971,153.598 636.343,142.626 625.372,131.655 C618.058,120.683 610.743,106.055 610.743,91.427 C610.743,80.455 614.4,69.484 618.057,62.17 C621.714,54.856 629.028,47.541 636.342,40.227 C643.656,32.912 654.627,29.256 661.942,25.598 C672.913,21.941 683.885,21.941 694.856,21.941 C702.17,21.941 705.827,21.941 713.141,21.941 C720.455,21.941 724.112,21.941 731.426,25.598 C735.083,25.598 742.397,29.255 746.055,29.255 C749.713,29.255 753.369,32.912 757.026,32.912 C760.683,32.912 764.34,36.569 764.34,40.227 C767.997,36.57 767.997,40.227 767.997,43.884 L767.997,54.855 C767.997,62.17 764.34,62.17 760.683,62.17 C757.026,62.17 753.369,62.17 749.712,58.513 C735.083,51.198 716.798,47.542 698.512,47.542 C687.541,47.542 672.912,51.199 661.94,54.857 C658.283,65.829 654.626,73.142 654.626,84.114 C654.626,91.428 658.283,98.743 661.94,102.399 C669.254,109.713 680.225,113.371 691.197,117.028 L727.769,128 C742.398,131.657 757.026,142.629 767.997,153.6 C775.311,164.571 782.626,179.2 778.968,193.828 C778.968,204.799 775.311,215.771 771.654,223.085 C767.997,234.056 760.683,241.37 753.369,245.028 C746.055,252.343 735.084,255.999 724.112,259.656 C713.14,263.313 702.169,266.971 687.54,266.971 L687.543,266.971 Z",
|
16010 | id: "Shape"
|
16011 | }), React.createElement("path", {
|
16012 | d: "M738.743,398.628 C650.972,464.457 522.972,497.371 416.914,497.371 C270.628,497.371 128,446.171 21.943,347.428 C10.971,336.457 18.286,329.142 29.257,332.8 C149.943,402.286 285.257,438.857 424.228,438.857 C526.628,438.857 629.028,416.914 727.771,376.686 C742.4,369.371 753.371,387.657 738.742,398.629 L738.743,398.628 Z",
|
16013 | id: "Shape"
|
16014 | }), React.createElement("path", {
|
16015 | d: "M775.314,354.743 C764.343,340.115 702.171,347.428 672.914,351.086 C665.6,351.086 661.943,343.771 669.257,340.115 C720.457,303.543 800.914,314.515 811.886,325.487 C822.858,336.459 808.229,420.572 760.686,460.802 C753.372,468.117 746.057,464.459 749.715,457.145 C764.344,427.888 786.287,369.373 775.315,354.745 L775.314,354.743 Z",
|
16016 | id: "Shape"
|
16017 | }))))), React.createElement("div", {
|
16018 | className: AmplifyUI.loadingSceneName,
|
16019 | "data-test": data_test_attributes_1.sumerianScene.loadingSceneName
|
16020 | }, props.sceneName), props.sceneError ? React.createElement("div", {
|
16021 | className: AmplifyUI.sceneErrorText,
|
16022 | "data-test": data_test_attributes_1.sumerianScene.errorText
|
16023 | }, props.sceneError.displayText) : React.createElement("div", {
|
16024 | className: AmplifyUI.loadingBar,
|
16025 | "data-test": data_test_attributes_1.sumerianScene.loadingBar
|
16026 | }, React.createElement("div", {
|
16027 | className: AmplifyUI.loadingBarFill,
|
16028 | style: {
|
16029 | width: props.percentage + "%"
|
16030 | }
|
16031 | }))));
|
16032 | };
|
16033 |
|
16034 |
|
16035 |
|
16036 |
|
16037 |
|
16038 | exports["default"] = exports.Loading;
|
16039 |
|
16040 | }),
|
16041 |
|
16042 | "./lib/XR/SumerianScene.js":
|
16043 |
|
16044 |
|
16045 |
|
16046 |
|
16047 | (function(module, exports, __webpack_require__) {
|
16048 |
|
16049 | "use strict";
|
16050 |
|
16051 |
|
16052 | var __extends = this && this.__extends || function () {
|
16053 | var _extendStatics = function extendStatics(d, b) {
|
16054 | _extendStatics = Object.setPrototypeOf || {
|
16055 | __proto__: []
|
16056 | } instanceof Array && function (d, b) {
|
16057 | d.__proto__ = b;
|
16058 | } || function (d, b) {
|
16059 | for (var p in b) {
|
16060 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
16061 | }
|
16062 | };
|
16063 |
|
16064 | return _extendStatics(d, b);
|
16065 | };
|
16066 |
|
16067 | return function (d, b) {
|
16068 | _extendStatics(d, b);
|
16069 |
|
16070 | function __() {
|
16071 | this.constructor = d;
|
16072 | }
|
16073 |
|
16074 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
16075 | };
|
16076 | }();
|
16077 |
|
16078 | var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
16079 | function adopt(value) {
|
16080 | return value instanceof P ? value : new P(function (resolve) {
|
16081 | resolve(value);
|
16082 | });
|
16083 | }
|
16084 |
|
16085 | return new (P || (P = Promise))(function (resolve, reject) {
|
16086 | function fulfilled(value) {
|
16087 | try {
|
16088 | step(generator.next(value));
|
16089 | } catch (e) {
|
16090 | reject(e);
|
16091 | }
|
16092 | }
|
16093 |
|
16094 | function rejected(value) {
|
16095 | try {
|
16096 | step(generator["throw"](value));
|
16097 | } catch (e) {
|
16098 | reject(e);
|
16099 | }
|
16100 | }
|
16101 |
|
16102 | function step(result) {
|
16103 | result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
16104 | }
|
16105 |
|
16106 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
16107 | });
|
16108 | };
|
16109 |
|
16110 | var __generator = this && this.__generator || function (thisArg, body) {
|
16111 | var _ = {
|
16112 | label: 0,
|
16113 | sent: function sent() {
|
16114 | if (t[0] & 1) throw t[1];
|
16115 | return t[1];
|
16116 | },
|
16117 | trys: [],
|
16118 | ops: []
|
16119 | },
|
16120 | f,
|
16121 | y,
|
16122 | t,
|
16123 | g;
|
16124 | return g = {
|
16125 | next: verb(0),
|
16126 | "throw": verb(1),
|
16127 | "return": verb(2)
|
16128 | }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
16129 | return this;
|
16130 | }), g;
|
16131 |
|
16132 | function verb(n) {
|
16133 | return function (v) {
|
16134 | return step([n, v]);
|
16135 | };
|
16136 | }
|
16137 |
|
16138 | function step(op) {
|
16139 | if (f) throw new TypeError("Generator is already executing.");
|
16140 |
|
16141 | while (_) {
|
16142 | try {
|
16143 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
16144 | if (y = 0, t) op = [op[0] & 2, t.value];
|
16145 |
|
16146 | switch (op[0]) {
|
16147 | case 0:
|
16148 | case 1:
|
16149 | t = op;
|
16150 | break;
|
16151 |
|
16152 | case 4:
|
16153 | _.label++;
|
16154 | return {
|
16155 | value: op[1],
|
16156 | done: false
|
16157 | };
|
16158 |
|
16159 | case 5:
|
16160 | _.label++;
|
16161 | y = op[1];
|
16162 | op = [0];
|
16163 | continue;
|
16164 |
|
16165 | case 7:
|
16166 | op = _.ops.pop();
|
16167 |
|
16168 | _.trys.pop();
|
16169 |
|
16170 | continue;
|
16171 |
|
16172 | default:
|
16173 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
16174 | _ = 0;
|
16175 | continue;
|
16176 | }
|
16177 |
|
16178 | if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
16179 | _.label = op[1];
|
16180 | break;
|
16181 | }
|
16182 |
|
16183 | if (op[0] === 6 && _.label < t[1]) {
|
16184 | _.label = t[1];
|
16185 | t = op;
|
16186 | break;
|
16187 | }
|
16188 |
|
16189 | if (t && _.label < t[2]) {
|
16190 | _.label = t[2];
|
16191 |
|
16192 | _.ops.push(op);
|
16193 |
|
16194 | break;
|
16195 | }
|
16196 |
|
16197 | if (t[2]) _.ops.pop();
|
16198 |
|
16199 | _.trys.pop();
|
16200 |
|
16201 | continue;
|
16202 | }
|
16203 |
|
16204 | op = body.call(thisArg, _);
|
16205 | } catch (e) {
|
16206 | op = [6, e];
|
16207 | y = 0;
|
16208 | } finally {
|
16209 | f = t = 0;
|
16210 | }
|
16211 | }
|
16212 |
|
16213 | if (op[0] & 5) throw op[1];
|
16214 | return {
|
16215 | value: op[0] ? op[1] : void 0,
|
16216 | done: true
|
16217 | };
|
16218 | }
|
16219 | };
|
16220 |
|
16221 | var __importStar = this && this.__importStar || function (mod) {
|
16222 | if (mod && mod.__esModule) return mod;
|
16223 | var result = {};
|
16224 | if (mod != null) for (var k in mod) {
|
16225 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
16226 | }
|
16227 | result["default"] = mod;
|
16228 | return result;
|
16229 | };
|
16230 |
|
16231 | Object.defineProperty(exports, "__esModule", {
|
16232 | value: true
|
16233 | });
|
16234 |
|
16235 |
|
16236 |
|
16237 |
|
16238 |
|
16239 |
|
16240 |
|
16241 |
|
16242 |
|
16243 |
|
16244 |
|
16245 |
|
16246 |
|
16247 | var React = __importStar(__webpack_require__( "react"));
|
16248 |
|
16249 | var xr_1 = __webpack_require__( "@aws-amplify/xr");
|
16250 |
|
16251 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
16252 |
|
16253 | var IconButton_1 = __webpack_require__( "./lib/XR/IconButton.js");
|
16254 |
|
16255 | var Loading_1 = __webpack_require__( "./lib/XR/Loading.js");
|
16256 |
|
16257 | var AmplifyUI = __importStar(__webpack_require__( "@aws-amplify/ui"));
|
16258 |
|
16259 | var data_test_attributes_1 = __webpack_require__( "./lib/Amplify-UI/data-test-attributes.js");
|
16260 |
|
16261 | var SCENE_CONTAINER_DOM_ID = 'scene-container-dom-id';
|
16262 | var SCENE_DOM_ID = 'scene-dom-id';
|
16263 | var logger = new core_1.ConsoleLogger('SumerianScene');
|
16264 |
|
16265 | var SumerianScene =
|
16266 |
|
16267 | function (_super) {
|
16268 | __extends(SumerianScene, _super);
|
16269 |
|
16270 | function SumerianScene(props) {
|
16271 | var _this = _super.call(this, props) || this;
|
16272 |
|
16273 | _this.state = {
|
16274 | showEnableAudio: false,
|
16275 | muted: false,
|
16276 | loading: true,
|
16277 | percentage: 0,
|
16278 | isFullscreen: false,
|
16279 | sceneError: null,
|
16280 | isVRPresentationActive: false
|
16281 | };
|
16282 | return _this;
|
16283 | }
|
16284 |
|
16285 | SumerianScene.prototype.setStateAsync = function (state) {
|
16286 | var _this = this;
|
16287 |
|
16288 | return new Promise(function (resolve) {
|
16289 | _this.setState(state, resolve);
|
16290 | });
|
16291 | };
|
16292 |
|
16293 | SumerianScene.prototype.componentDidMount = function () {
|
16294 | document.addEventListener('fullscreenchange', this.onFullscreenChange.bind(this));
|
16295 | document.addEventListener('webkitfullscreenchange', this.onFullscreenChange.bind(this));
|
16296 | document.addEventListener('mozfullscreenchange', this.onFullscreenChange.bind(this));
|
16297 | document.addEventListener('MSFullscreenChange', this.onFullscreenChange.bind(this));
|
16298 | this.loadAndSetupScene(this.props.sceneName, SCENE_DOM_ID);
|
16299 | };
|
16300 |
|
16301 | SumerianScene.prototype.componentWillUnmount = function () {
|
16302 | document.removeEventListener('fullscreenchange', this.onFullscreenChange.bind(this));
|
16303 | document.removeEventListener('webkitfullscreenchange', this.onFullscreenChange.bind(this));
|
16304 | document.removeEventListener('mozfullscreenchange', this.onFullscreenChange.bind(this));
|
16305 | document.removeEventListener('MSFullscreenChange', this.onFullscreenChange.bind(this));
|
16306 | };
|
16307 |
|
16308 | SumerianScene.prototype.loadAndSetupScene = function (sceneName, sceneDomId) {
|
16309 | return __awaiter(this, void 0, void 0, function () {
|
16310 | var sceneOptions, e_1, sceneError;
|
16311 |
|
16312 | var _this = this;
|
16313 |
|
16314 | return __generator(this, function (_a) {
|
16315 | switch (_a.label) {
|
16316 | case 0:
|
16317 | this.setStateAsync({
|
16318 | loading: true
|
16319 | });
|
16320 | sceneOptions = {
|
16321 | progressCallback: function progressCallback(progress) {
|
16322 | var percentage = progress * 100;
|
16323 |
|
16324 | _this.setState({
|
16325 | percentage: percentage
|
16326 | });
|
16327 | }
|
16328 | };
|
16329 | _a.label = 1;
|
16330 |
|
16331 | case 1:
|
16332 | _a.trys.push([1, 3,, 4]);
|
16333 |
|
16334 | return [4
|
16335 |
|
16336 | , xr_1.XR.loadScene(sceneName, sceneDomId, sceneOptions)];
|
16337 |
|
16338 | case 2:
|
16339 | _a.sent();
|
16340 |
|
16341 | return [3
|
16342 |
|
16343 | , 4];
|
16344 |
|
16345 | case 3:
|
16346 | e_1 = _a.sent();
|
16347 | sceneError = {
|
16348 | displayText: 'Failed to load scene',
|
16349 | error: e_1
|
16350 | };
|
16351 | logger.error(sceneError.displayText, sceneError.error);
|
16352 | this.setStateAsync({
|
16353 | sceneError: sceneError
|
16354 | });
|
16355 | return [2
|
16356 |
|
16357 | ];
|
16358 |
|
16359 | case 4:
|
16360 | xr_1.XR.start(sceneName);
|
16361 | this.setStateAsync({
|
16362 | muted: xr_1.XR.isMuted(sceneName),
|
16363 | isVRPresentationActive: xr_1.XR.isVRPresentationActive(sceneName),
|
16364 | loading: false
|
16365 | });
|
16366 | xr_1.XR.onSceneEvent(sceneName, 'AudioEnabled', function () {
|
16367 | return _this.setStateAsync({
|
16368 | showEnableAudio: false
|
16369 | });
|
16370 | });
|
16371 | xr_1.XR.onSceneEvent(sceneName, 'AudioDisabled', function () {
|
16372 | return _this.setStateAsync({
|
16373 | showEnableAudio: true
|
16374 | });
|
16375 | });
|
16376 | return [2
|
16377 |
|
16378 | ];
|
16379 | }
|
16380 | });
|
16381 | });
|
16382 | };
|
16383 |
|
16384 | SumerianScene.prototype.setMuted = function (muted) {
|
16385 | if (this.state.showEnableAudio) {
|
16386 | xr_1.XR.enableAudio(this.props.sceneName);
|
16387 | this.setState({
|
16388 | showEnableAudio: false
|
16389 | });
|
16390 | }
|
16391 |
|
16392 | xr_1.XR.setMuted(this.props.sceneName, muted);
|
16393 | this.setState({
|
16394 | muted: muted
|
16395 | });
|
16396 | };
|
16397 |
|
16398 | SumerianScene.prototype.onFullscreenChange = function () {
|
16399 | var doc = document;
|
16400 | this.setState({
|
16401 | isFullscreen: doc.fullscreenElement !== null
|
16402 | });
|
16403 | };
|
16404 |
|
16405 | SumerianScene.prototype.maximize = function () {
|
16406 | return __awaiter(this, void 0, void 0, function () {
|
16407 | var sceneDomElement;
|
16408 | return __generator(this, function (_a) {
|
16409 | switch (_a.label) {
|
16410 | case 0:
|
16411 | sceneDomElement = document.getElementById(SCENE_CONTAINER_DOM_ID);
|
16412 | return [4
|
16413 |
|
16414 | , sceneDomElement.requestFullscreen()];
|
16415 |
|
16416 | case 1:
|
16417 | _a.sent();
|
16418 |
|
16419 | return [2
|
16420 |
|
16421 | ];
|
16422 | }
|
16423 | });
|
16424 | });
|
16425 | };
|
16426 |
|
16427 | SumerianScene.prototype.minimize = function () {
|
16428 | return __awaiter(this, void 0, void 0, function () {
|
16429 | var doc;
|
16430 | return __generator(this, function (_a) {
|
16431 | doc = document;
|
16432 |
|
16433 | if (doc.exitFullscreen) {
|
16434 | doc.exitFullscreen();
|
16435 | } else if (doc.mozCancelFullScreen) {
|
16436 | doc.mozCancelFullScreen();
|
16437 | } else if (doc.webkitExitFullscreen) {
|
16438 | doc.webkitExitFullscreen();
|
16439 | }
|
16440 |
|
16441 | return [2
|
16442 |
|
16443 | ];
|
16444 | });
|
16445 | });
|
16446 | };
|
16447 |
|
16448 | SumerianScene.prototype.toggleVRPresentation = function () {
|
16449 | try {
|
16450 | if (this.state.isVRPresentationActive) {
|
16451 | xr_1.XR.exitVR(this.props.sceneName);
|
16452 | } else {
|
16453 | xr_1.XR.enterVR(this.props.sceneName);
|
16454 | }
|
16455 | } catch (e) {
|
16456 | logger.error('Unable to start/stop WebVR System: ' + e.message);
|
16457 | return;
|
16458 | }
|
16459 |
|
16460 | this.setState({
|
16461 | isVRPresentationActive: !this.state.isVRPresentationActive
|
16462 | });
|
16463 | };
|
16464 |
|
16465 | SumerianScene.prototype.render = function () {
|
16466 | var _this = this;
|
16467 |
|
16468 | var muteButton;
|
16469 | var enterOrExitVRButton;
|
16470 | var screenSizeButton;
|
16471 |
|
16472 | if (xr_1.XR.isSceneLoaded(this.props.sceneName)) {
|
16473 | if (this.state.showEnableAudio) {
|
16474 | muteButton = React.createElement(IconButton_1.IconButton, {
|
16475 | variant: "sound-mute",
|
16476 | tooltip: "The scene is muted. Click to unmute.",
|
16477 | onClick: function onClick() {
|
16478 | return _this.setMuted(false);
|
16479 | },
|
16480 | autoShowTooltip: true
|
16481 | });
|
16482 | } else if (xr_1.XR.isMuted(this.props.sceneName)) {
|
16483 | muteButton = React.createElement(IconButton_1.IconButton, {
|
16484 | variant: "sound-mute",
|
16485 | tooltip: "Unmute",
|
16486 | onClick: function onClick() {
|
16487 | return _this.setMuted(false);
|
16488 | }
|
16489 | });
|
16490 | } else {
|
16491 | muteButton = React.createElement(IconButton_1.IconButton, {
|
16492 | variant: "sound",
|
16493 | tooltip: "Mute",
|
16494 | onClick: function onClick() {
|
16495 | return _this.setMuted(true);
|
16496 | }
|
16497 | });
|
16498 | }
|
16499 |
|
16500 | if (xr_1.XR.isVRCapable(this.props.sceneName)) {
|
16501 | if (this.state.isVRPresentationActive) {
|
16502 | logger.info('VR Presentation Active');
|
16503 | enterOrExitVRButton = React.createElement(IconButton_1.IconButton, {
|
16504 | variant: "exit-vr",
|
16505 | tooltip: "Exit VR",
|
16506 | onClick: function onClick() {
|
16507 | return _this.toggleVRPresentation();
|
16508 | }
|
16509 | });
|
16510 | } else {
|
16511 | logger.info('VR Presentation Inactive');
|
16512 | enterOrExitVRButton = React.createElement(IconButton_1.IconButton, {
|
16513 | variant: "enter-vr",
|
16514 | tooltip: "Enter VR",
|
16515 | onClick: function onClick() {
|
16516 | return _this.toggleVRPresentation();
|
16517 | }
|
16518 | });
|
16519 | }
|
16520 | }
|
16521 |
|
16522 | if (this.state.isFullscreen) {
|
16523 | screenSizeButton = React.createElement(IconButton_1.IconButton, {
|
16524 | variant: "minimize",
|
16525 | tooltip: "Exit Fullscreen",
|
16526 | onClick: function onClick() {
|
16527 | return _this.minimize();
|
16528 | }
|
16529 | });
|
16530 | } else {
|
16531 | screenSizeButton = React.createElement(IconButton_1.IconButton, {
|
16532 | variant: "maximize",
|
16533 | tooltip: "Fullscreen",
|
16534 | onClick: function onClick() {
|
16535 | return _this.maximize();
|
16536 | }
|
16537 | });
|
16538 | }
|
16539 | }
|
16540 |
|
16541 | return React.createElement("div", {
|
16542 | id: SCENE_CONTAINER_DOM_ID,
|
16543 | className: AmplifyUI.sumerianSceneContainer,
|
16544 | "data-test": data_test_attributes_1.sumerianScene.container
|
16545 | }, React.createElement("div", {
|
16546 | id: SCENE_DOM_ID,
|
16547 | className: AmplifyUI.sumerianScene,
|
16548 | "data-test": data_test_attributes_1.sumerianScene.sumerianScene
|
16549 | }, this.state.loading && React.createElement(Loading_1.Loading, {
|
16550 | sceneName: this.props.sceneName,
|
16551 | percentage: this.state.percentage,
|
16552 | sceneError: this.state.sceneError
|
16553 | })), React.createElement("div", {
|
16554 | className: AmplifyUI.sceneBar,
|
16555 | "data-test": data_test_attributes_1.sumerianScene.bar
|
16556 | }, React.createElement("span", {
|
16557 | className: AmplifyUI.sceneActions,
|
16558 | "data-test": data_test_attributes_1.sumerianScene.actions
|
16559 | }, muteButton, enterOrExitVRButton, screenSizeButton)));
|
16560 | };
|
16561 |
|
16562 | return SumerianScene;
|
16563 | }(React.Component);
|
16564 |
|
16565 | exports.SumerianScene = SumerianScene;
|
16566 |
|
16567 |
|
16568 |
|
16569 |
|
16570 | exports["default"] = SumerianScene;
|
16571 |
|
16572 | }),
|
16573 |
|
16574 | "./lib/XR/Tooltip.js":
|
16575 |
|
16576 |
|
16577 |
|
16578 |
|
16579 | (function(module, exports, __webpack_require__) {
|
16580 |
|
16581 | "use strict";
|
16582 |
|
16583 |
|
16584 | var __importStar = this && this.__importStar || function (mod) {
|
16585 | if (mod && mod.__esModule) return mod;
|
16586 | var result = {};
|
16587 | if (mod != null) for (var k in mod) {
|
16588 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
16589 | }
|
16590 | result["default"] = mod;
|
16591 | return result;
|
16592 | };
|
16593 |
|
16594 | Object.defineProperty(exports, "__esModule", {
|
16595 | value: true
|
16596 | });
|
16597 |
|
16598 |
|
16599 |
|
16600 |
|
16601 |
|
16602 |
|
16603 |
|
16604 |
|
16605 |
|
16606 |
|
16607 |
|
16608 |
|
16609 |
|
16610 | var React = __importStar(__webpack_require__( "react"));
|
16611 |
|
16612 | var ui_1 = __webpack_require__( "@aws-amplify/ui");
|
16613 |
|
16614 | exports.Tooltip = function (props) {
|
16615 | var classes = "" + ui_1.tooltip;
|
16616 |
|
16617 | if (props.autoShowTooltip) {
|
16618 | classes = ui_1.tooltip + " " + ui_1.autoShowTooltip;
|
16619 | }
|
16620 |
|
16621 | return React.createElement("div", {
|
16622 | className: classes,
|
16623 | "data-text": props.text
|
16624 | }, props.children);
|
16625 | };
|
16626 |
|
16627 |
|
16628 |
|
16629 |
|
16630 |
|
16631 | exports["default"] = exports.Tooltip;
|
16632 |
|
16633 | }),
|
16634 |
|
16635 | "./lib/XR/index.js":
|
16636 |
|
16637 |
|
16638 |
|
16639 |
|
16640 | (function(module, exports, __webpack_require__) {
|
16641 |
|
16642 | "use strict";
|
16643 |
|
16644 |
|
16645 | Object.defineProperty(exports, "__esModule", {
|
16646 | value: true
|
16647 | });
|
16648 |
|
16649 |
|
16650 |
|
16651 |
|
16652 |
|
16653 |
|
16654 |
|
16655 |
|
16656 |
|
16657 |
|
16658 |
|
16659 |
|
16660 |
|
16661 | var SumerianScene_1 = __webpack_require__( "./lib/XR/SumerianScene.js");
|
16662 |
|
16663 | exports.SumerianScene = SumerianScene_1.SumerianScene;
|
16664 |
|
16665 | }),
|
16666 |
|
16667 | "./lib/index.js":
|
16668 |
|
16669 |
|
16670 |
|
16671 |
|
16672 | (function(module, exports, __webpack_require__) {
|
16673 |
|
16674 | "use strict";
|
16675 |
|
16676 |
|
16677 | function __export(m) {
|
16678 | for (var p in m) {
|
16679 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
16680 | }
|
16681 | }
|
16682 |
|
16683 | Object.defineProperty(exports, "__esModule", {
|
16684 | value: true
|
16685 | });
|
16686 |
|
16687 |
|
16688 |
|
16689 |
|
16690 |
|
16691 |
|
16692 |
|
16693 |
|
16694 |
|
16695 |
|
16696 |
|
16697 |
|
16698 |
|
16699 | var core_1 = __webpack_require__( "@aws-amplify/core");
|
16700 |
|
16701 | var AmplifyI18n_1 = __webpack_require__( "./lib/AmplifyI18n.js");
|
16702 |
|
16703 | __export(__webpack_require__( "./lib/AmplifyUI.js"));
|
16704 |
|
16705 | __export(__webpack_require__( "./lib/Auth/index.js"));
|
16706 |
|
16707 | __export(__webpack_require__( "./lib/Analytics/index.js"));
|
16708 |
|
16709 | __export(__webpack_require__( "./lib/Storage/index.js"));
|
16710 |
|
16711 | __export(__webpack_require__( "./lib/Widget/index.js"));
|
16712 |
|
16713 | __export(__webpack_require__( "./lib/API/index.js"));
|
16714 |
|
16715 | __export(__webpack_require__( "./lib/Interactions/index.js"));
|
16716 |
|
16717 | __export(__webpack_require__( "./lib/XR/index.js"));
|
16718 |
|
16719 | var AmplifyTheme_1 = __webpack_require__( "./lib/AmplifyTheme.js");
|
16720 |
|
16721 | exports.AmplifyTheme = AmplifyTheme_1.Bootstrap;
|
16722 |
|
16723 | var AmplifyMessageMap_1 = __webpack_require__( "./lib/AmplifyMessageMap.js");
|
16724 |
|
16725 | exports.AmplifyMessageMapEntries = AmplifyMessageMap_1.MapEntries;
|
16726 |
|
16727 | var AmplifyUI_1 = __webpack_require__( "./lib/AmplifyUI.js");
|
16728 |
|
16729 | exports.transparent1X1 = AmplifyUI_1.transparent1X1;
|
16730 | exports.white1X1 = AmplifyUI_1.white1X1;
|
16731 | core_1.I18n.putVocabularies(AmplifyI18n_1.dict);
|
16732 |
|
16733 | }),
|
16734 |
|
16735 | "@aws-amplify/analytics":
|
16736 |
|
16737 |
|
16738 |
|
16739 |
|
16740 | (function(module, exports) {
|
16741 |
|
16742 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_analytics__;
|
16743 |
|
16744 | }),
|
16745 |
|
16746 | "@aws-amplify/api":
|
16747 |
|
16748 |
|
16749 |
|
16750 |
|
16751 | (function(module, exports) {
|
16752 |
|
16753 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_api__;
|
16754 |
|
16755 | }),
|
16756 |
|
16757 | "@aws-amplify/auth":
|
16758 |
|
16759 |
|
16760 |
|
16761 |
|
16762 | (function(module, exports) {
|
16763 |
|
16764 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_auth__;
|
16765 |
|
16766 | }),
|
16767 |
|
16768 | "@aws-amplify/core":
|
16769 |
|
16770 |
|
16771 |
|
16772 |
|
16773 | (function(module, exports) {
|
16774 |
|
16775 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_core__;
|
16776 |
|
16777 | }),
|
16778 |
|
16779 | "@aws-amplify/interactions":
|
16780 |
|
16781 |
|
16782 |
|
16783 |
|
16784 | (function(module, exports) {
|
16785 |
|
16786 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_interactions__;
|
16787 |
|
16788 | }),
|
16789 |
|
16790 | "@aws-amplify/storage":
|
16791 |
|
16792 |
|
16793 |
|
16794 |
|
16795 | (function(module, exports) {
|
16796 |
|
16797 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_storage__;
|
16798 |
|
16799 | }),
|
16800 |
|
16801 | "@aws-amplify/ui":
|
16802 |
|
16803 |
|
16804 |
|
16805 |
|
16806 | (function(module, exports) {
|
16807 |
|
16808 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_ui__;
|
16809 |
|
16810 | }),
|
16811 |
|
16812 | "@aws-amplify/xr":
|
16813 |
|
16814 |
|
16815 |
|
16816 |
|
16817 | (function(module, exports) {
|
16818 |
|
16819 | module.exports = __WEBPACK_EXTERNAL_MODULE__aws_amplify_xr__;
|
16820 |
|
16821 | }),
|
16822 |
|
16823 | "react":
|
16824 |
|
16825 |
|
16826 |
|
16827 |
|
16828 | (function(module, exports) {
|
16829 |
|
16830 | module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
|
16831 |
|
16832 | })
|
16833 |
|
16834 | });
|
16835 | });
|
16836 |
|
\ | No newline at end of file |