\nCanonicalHeaders =\n CanonicalHeadersEntry0 + CanonicalHeadersEntry1 + ... + CanonicalHeadersEntryN\nCanonicalHeadersEntry =\n Lowercase(HeaderName) + ':' + Trimall(HeaderValue) + '\\n'\n\n*/\nvar canonical_headers = function (headers) {\n if (!headers || Object.keys(headers).length === 0) {\n return '';\n }\n return (Object.keys(headers)\n .map(function (key) {\n return {\n key: key.toLowerCase(),\n value: headers[key] ? headers[key].trim().replace(/\\s+/g, ' ') : '',\n };\n })\n .sort(function (a, b) {\n return a.key < b.key ? -1 : 1;\n })\n .map(function (item) {\n return item.key + ':' + item.value;\n })\n .join('\\n') + '\\n');\n};\n/**\n * List of header keys included in the canonical headers.\n * @access private\n */\nvar signed_headers = function (headers) {\n return Object.keys(headers)\n .map(function (key) {\n return key.toLowerCase();\n })\n .sort()\n .join(';');\n};\n/**\n* @private\n* Create canonical request\n* Refer to\n* {@link http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html|Create a Canonical Request}\n*\n
\nCanonicalRequest =\n HTTPRequestMethod + '\\n' +\n CanonicalURI + '\\n' +\n CanonicalQueryString + '\\n' +\n CanonicalHeaders + '\\n' +\n SignedHeaders + '\\n' +\n HexEncode(Hash(RequestPayload))\n\n*/\nvar canonical_request = function (request) {\n var url_info = url.parse(request.url);\n return [\n request.method || '/',\n encodeURIComponent(url_info.pathname).replace(/%2F/gi, '/'),\n canonical_query(url_info.query),\n canonical_headers(request.headers),\n signed_headers(request.headers),\n hash(request.data),\n ].join('\\n');\n};\nvar parse_service_info = function (request) {\n var url_info = url.parse(request.url), host = url_info.host;\n var matched = host.match(/([^\\.]+)\\.(?:([^\\.]*)\\.)?amazonaws\\.com$/);\n var parsed = (matched || []).slice(1, 3);\n if (parsed[1] === 'es') {\n // Elastic Search\n parsed = parsed.reverse();\n }\n return {\n service: request.service || parsed[0],\n region: request.region || parsed[1],\n };\n};\nvar credential_scope = function (d_str, region, service) {\n return [d_str, region, service, 'aws4_request'].join('/');\n};\n/**\n* @private\n* Create a string to sign\n* Refer to\n* {@link http://docs.aws.amazon.com/general/latest/gr/sigv4-create-string-to-sign.html|Create String to Sign}\n*\n
\nStringToSign =\n Algorithm + \\n +\n RequestDateTime + \\n +\n CredentialScope + \\n +\n HashedCanonicalRequest\n\n*/\nvar string_to_sign = function (algorithm, canonical_request, dt_str, scope) {\n return [algorithm, dt_str, scope, hash(canonical_request)].join('\\n');\n};\n/**\n* @private\n* Create signing key\n* Refer to\n* {@link http://docs.aws.amazon.com/general/latest/gr/sigv4-calculate-signature.html|Calculate Signature}\n*\n
\nkSecret = your secret access key\nkDate = HMAC(\"AWS4\" + kSecret, Date)\nkRegion = HMAC(kDate, Region)\nkService = HMAC(kRegion, Service)\nkSigning = HMAC(kService, \"aws4_request\")\n\n*/\nvar get_signing_key = function (secret_key, d_str, service_info) {\n logger.debug(service_info);\n var k = 'AWS4' + secret_key, k_date = encrypt(k, d_str), k_region = encrypt(k_date, service_info.region), k_service = encrypt(k_region, service_info.service), k_signing = encrypt(k_service, 'aws4_request');\n return k_signing;\n};\nvar get_signature = function (signing_key, str_to_sign) {\n return encrypt(signing_key, str_to_sign, 'hex');\n};\n/**\n * @private\n * Create authorization header\n * Refer to\n * {@link http://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html|Add the Signing Information}\n */\nvar get_authorization_header = function (algorithm, access_key, scope, signed_headers, signature) {\n return [\n algorithm + ' ' + 'Credential=' + access_key + '/' + scope,\n 'SignedHeaders=' + signed_headers,\n 'Signature=' + signature,\n ].join(', ');\n};\n/**\n * AWS request signer.\n * Refer to {@link http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html|Signature Version 4}\n *\n * @class Signer\n */\nvar Signer = /** @class */ (function () {\n function Signer() {\n }\n /**\n * Sign a HTTP request, add 'Authorization' header to request param\n * @method sign\n * @memberof Signer\n * @static\n *\n * @param {object} request - HTTP request object\n
\n request: {\n method: GET | POST | PUT ...\n url: ...,\n headers: {\n header1: ...\n },\n data: data\n }\n\n * @param {object} access_info - AWS access credential info\n
\n access_info: {\n access_key: ...,\n secret_key: ...,\n session_token: ...\n }\n\n * @param {object} [service_info] - AWS service type and region, optional,\n * if not provided then parse out from url\n
\n service_info: {\n service: ...,\n region: ...\n }\n\n *\n * @returns {object} Signed HTTP request\n */\n Signer.sign = function (request, access_info, service_info) {\n if (service_info === void 0) { service_info = null; }\n request.headers = request.headers || {};\n // datetime string and date string\n var dt = DateUtils.getDateWithClockOffset(), dt_str = dt.toISOString().replace(/[:\\-]|\\.\\d{3}/g, ''), d_str = dt_str.substr(0, 8);\n var url_info = url.parse(request.url);\n request.headers['host'] = url_info.host;\n request.headers['x-amz-date'] = dt_str;\n if (access_info.session_token) {\n request.headers['X-Amz-Security-Token'] = access_info.session_token;\n }\n // Task 1: Create a Canonical Request\n var request_str = canonical_request(request);\n logger.debug(request_str);\n // Task 2: Create a String to Sign\n var serviceInfo = service_info || parse_service_info(request), scope = credential_scope(d_str, serviceInfo.region, serviceInfo.service), str_to_sign = string_to_sign(DEFAULT_ALGORITHM, request_str, dt_str, scope);\n // Task 3: Calculate the Signature\n var signing_key = get_signing_key(access_info.secret_key, d_str, serviceInfo), signature = get_signature(signing_key, str_to_sign);\n // Task 4: Adding the Signing information to the Request\n var authorization_header = get_authorization_header(DEFAULT_ALGORITHM, access_info.access_key, scope, signed_headers(request.headers), signature);\n request.headers['Authorization'] = authorization_header;\n return request;\n };\n Signer.signUrl = function (urlOrRequest, accessInfo, serviceInfo, expiration) {\n var urlToSign = typeof urlOrRequest === 'object' ? urlOrRequest.url : urlOrRequest;\n var method = typeof urlOrRequest === 'object' ? urlOrRequest.method : 'GET';\n var body = typeof urlOrRequest === 'object' ? urlOrRequest.body : undefined;\n var now = DateUtils.getDateWithClockOffset()\n .toISOString()\n .replace(/[:\\-]|\\.\\d{3}/g, '');\n var today = now.substr(0, 8);\n // Intentionally discarding search\n var _a = url.parse(urlToSign, true, true), search = _a.search, parsedUrl = __rest(_a, [\"search\"]);\n var host = parsedUrl.host;\n var signedHeaders = { host: host };\n var _b = serviceInfo || parse_service_info({ url: url.format(parsedUrl) }), region = _b.region, service = _b.service;\n var credentialScope = credential_scope(today, region, service);\n // IoT service does not allow the session token in the canonical request\n // https://docs.aws.amazon.com/general/latest/gr/sigv4-add-signature-to-request.html\n var sessionTokenRequired = accessInfo.session_token && service !== IOT_SERVICE_NAME;\n var queryParams = __assign(__assign(__assign({ 'X-Amz-Algorithm': DEFAULT_ALGORITHM, 'X-Amz-Credential': [accessInfo.access_key, credentialScope].join('/'), 'X-Amz-Date': now.substr(0, 16) }, (sessionTokenRequired\n ? { 'X-Amz-Security-Token': \"\" + accessInfo.session_token }\n : {})), (expiration ? { 'X-Amz-Expires': \"\" + expiration } : {})), { 'X-Amz-SignedHeaders': Object.keys(signedHeaders).join(',') });\n var canonicalRequest = canonical_request({\n method: method,\n url: url.format(__assign(__assign({}, parsedUrl), { query: __assign(__assign({}, parsedUrl.query), queryParams) })),\n headers: signedHeaders,\n data: body,\n });\n var stringToSign = string_to_sign(DEFAULT_ALGORITHM, canonicalRequest, now, credentialScope);\n var signing_key = get_signing_key(accessInfo.secret_key, today, {\n region: region,\n service: service,\n });\n var signature = get_signature(signing_key, stringToSign);\n var additionalQueryParams = __assign({ 'X-Amz-Signature': signature }, (accessInfo.session_token && {\n 'X-Amz-Security-Token': accessInfo.session_token,\n }));\n var result = url.format({\n protocol: parsedUrl.protocol,\n slashes: true,\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n pathname: parsedUrl.pathname,\n query: __assign(__assign(__assign({}, parsedUrl.query), queryParams), additionalQueryParams),\n });\n return result;\n };\n return Signer;\n}());\nexport default Signer;\n//# sourceMappingURL=Signer.js.map","import { ConsoleLogger as Logger } from './Logger';\nvar logger = new Logger('Parser');\nvar Parser = /** @class */ (function () {\n function Parser() {\n }\n Parser.parseMobilehubConfig = function (config) {\n var amplifyConfig = {};\n // Analytics\n if (config['aws_mobile_analytics_app_id']) {\n var Analytics = {\n AWSPinpoint: {\n appId: config['aws_mobile_analytics_app_id'],\n region: config['aws_mobile_analytics_app_region'],\n },\n };\n amplifyConfig.Analytics = Analytics;\n }\n // Auth\n if (config['aws_cognito_identity_pool_id'] || config['aws_user_pools_id']) {\n var Auth = {\n userPoolId: config['aws_user_pools_id'],\n userPoolWebClientId: config['aws_user_pools_web_client_id'],\n region: config['aws_cognito_region'],\n identityPoolId: config['aws_cognito_identity_pool_id'],\n identityPoolRegion: config['aws_cognito_region'],\n mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable' ? true : false,\n };\n amplifyConfig.Auth = Auth;\n }\n // Storage\n var storageConfig;\n if (config['aws_user_files_s3_bucket']) {\n storageConfig = {\n AWSS3: {\n bucket: config['aws_user_files_s3_bucket'],\n region: config['aws_user_files_s3_bucket_region'],\n dangerouslyConnectToHttpEndpointForTesting: config['aws_user_files_s3_dangerously_connect_to_http_endpoint_for_testing'],\n },\n };\n }\n else {\n storageConfig = config ? config.Storage || config : {};\n }\n amplifyConfig.Analytics = Object.assign({}, amplifyConfig.Analytics, config.Analytics);\n amplifyConfig.Auth = Object.assign({}, amplifyConfig.Auth, config.Auth);\n amplifyConfig.Storage = Object.assign({}, storageConfig);\n logger.debug('parse config', config, 'to amplifyconfig', amplifyConfig);\n return amplifyConfig;\n };\n return Parser;\n}());\nexport default Parser;\n//# sourceMappingURL=Parser.js.map","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport { ConsoleLogger as Logger } from '../Logger';\nimport JS from '../JS';\nvar logger = new Logger('CognitoCredentials');\nvar waitForInit = new Promise(function (res, rej) {\n if (!JS.browserOrNode().isBrowser) {\n logger.debug('not in the browser, directly resolved');\n return res();\n }\n var ga = window['gapi'] && window['gapi'].auth2 ? window['gapi'].auth2 : null;\n if (ga) {\n logger.debug('google api already loaded');\n return res();\n }\n else {\n setTimeout(function () {\n return res();\n }, 2000);\n }\n});\nvar GoogleOAuth = /** @class */ (function () {\n function GoogleOAuth() {\n this.initialized = false;\n this.refreshGoogleToken = this.refreshGoogleToken.bind(this);\n this._refreshGoogleTokenImpl = this._refreshGoogleTokenImpl.bind(this);\n }\n GoogleOAuth.prototype.refreshGoogleToken = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!this.initialized) return [3 /*break*/, 2];\n logger.debug('need to wait for the Google SDK loaded');\n return [4 /*yield*/, waitForInit];\n case 1:\n _a.sent();\n this.initialized = true;\n logger.debug('finish waiting');\n _a.label = 2;\n case 2: return [2 /*return*/, this._refreshGoogleTokenImpl()];\n }\n });\n });\n };\n GoogleOAuth.prototype._refreshGoogleTokenImpl = function () {\n var ga = null;\n if (JS.browserOrNode().isBrowser)\n ga = window['gapi'] && window['gapi'].auth2 ? window['gapi'].auth2 : null;\n if (!ga) {\n logger.debug('no gapi auth2 available');\n return Promise.reject('no gapi auth2 available');\n }\n return new Promise(function (res, rej) {\n ga.getAuthInstance()\n .then(function (googleAuth) {\n if (!googleAuth) {\n console.log('google Auth undefiend');\n rej('google Auth undefiend');\n }\n var googleUser = googleAuth.currentUser.get();\n // refresh the token\n if (googleUser.isSignedIn()) {\n logger.debug('refreshing the google access token');\n googleUser.reloadAuthResponse().then(function (authResponse) {\n var id_token = authResponse.id_token, expires_at = authResponse.expires_at;\n var profile = googleUser.getBasicProfile();\n var user = {\n email: profile.getEmail(),\n name: profile.getName(),\n };\n res({ token: id_token, expires_at: expires_at });\n });\n }\n else {\n rej('User is not signed in with Google');\n }\n })\n .catch(function (err) {\n logger.debug('Failed to refresh google token', err);\n rej('Failed to refresh google token');\n });\n });\n };\n return GoogleOAuth;\n}());\nexport default GoogleOAuth;\n//# sourceMappingURL=GoogleOAuth.js.map","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport { ConsoleLogger as Logger } from '../Logger';\nimport JS from '../JS';\nvar logger = new Logger('CognitoCredentials');\nvar waitForInit = new Promise(function (res, rej) {\n if (!JS.browserOrNode().isBrowser) {\n logger.debug('not in the browser, directly resolved');\n return res();\n }\n var fb = window['FB'];\n if (fb) {\n logger.debug('FB SDK already loaded');\n return res();\n }\n else {\n setTimeout(function () {\n return res();\n }, 2000);\n }\n});\nvar FacebookOAuth = /** @class */ (function () {\n function FacebookOAuth() {\n this.initialized = false;\n this.refreshFacebookToken = this.refreshFacebookToken.bind(this);\n this._refreshFacebookTokenImpl = this._refreshFacebookTokenImpl.bind(this);\n }\n FacebookOAuth.prototype.refreshFacebookToken = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!!this.initialized) return [3 /*break*/, 2];\n logger.debug('need to wait for the Facebook SDK loaded');\n return [4 /*yield*/, waitForInit];\n case 1:\n _a.sent();\n this.initialized = true;\n logger.debug('finish waiting');\n _a.label = 2;\n case 2: return [2 /*return*/, this._refreshFacebookTokenImpl()];\n }\n });\n });\n };\n FacebookOAuth.prototype._refreshFacebookTokenImpl = function () {\n var fb = null;\n if (JS.browserOrNode().isBrowser)\n fb = window['FB'];\n if (!fb) {\n logger.debug('no fb sdk available');\n return Promise.reject('no fb sdk available');\n }\n return new Promise(function (res, rej) {\n fb.getLoginStatus(function (fbResponse) {\n if (!fbResponse || !fbResponse.authResponse) {\n logger.debug('no response from facebook when refreshing the jwt token');\n rej('no response from facebook when refreshing the jwt token');\n }\n var response = fbResponse.authResponse;\n var accessToken = response.accessToken, expiresIn = response.expiresIn;\n var date = new Date();\n var expires_at = expiresIn * 1000 + date.getTime();\n if (!accessToken) {\n logger.debug('the jwtToken is undefined');\n rej('the jwtToken is undefined');\n }\n res({ token: accessToken, expires_at: expires_at });\n }, { scope: 'public_profile,email' });\n });\n };\n return FacebookOAuth;\n}());\nexport default FacebookOAuth;\n//# sourceMappingURL=FacebookOAuth.js.map","/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport GoogleOAuthClass from './GoogleOAuth';\nimport FacebookOAuthClass from './FacebookOAuth';\nvar GoogleOAuth = new GoogleOAuthClass();\nvar FacebookOAuth = new FacebookOAuthClass();\nexport { GoogleOAuth, FacebookOAuth };\n//# sourceMappingURL=index.js.map","/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nvar dataMemory = {};\n/** @class */\nvar MemoryStorage = /** @class */ (function () {\n function MemoryStorage() {\n }\n /**\n * This is used to set a specific item in storage\n * @param {string} key - the key for the item\n * @param {object} value - the value\n * @returns {string} value that was set\n */\n MemoryStorage.setItem = function (key, value) {\n dataMemory[key] = value;\n return dataMemory[key];\n };\n /**\n * This is used to get a specific key from storage\n * @param {string} key - the key for the item\n * This is used to clear the storage\n * @returns {string} the data item\n */\n MemoryStorage.getItem = function (key) {\n return Object.prototype.hasOwnProperty.call(dataMemory, key)\n ? dataMemory[key]\n : undefined;\n };\n /**\n * This is used to remove an item from storage\n * @param {string} key - the key being set\n * @returns {string} value - value that was deleted\n */\n MemoryStorage.removeItem = function (key) {\n return delete dataMemory[key];\n };\n /**\n * This is used to clear the storage\n * @returns {string} nothing\n */\n MemoryStorage.clear = function () {\n dataMemory = {};\n return dataMemory;\n };\n return MemoryStorage;\n}());\nexport { MemoryStorage };\nvar StorageHelper = /** @class */ (function () {\n /**\n * This is used to get a storage object\n * @returns {object} the storage\n */\n function StorageHelper() {\n try {\n this.storageWindow = window.localStorage;\n this.storageWindow.setItem('aws.amplify.test-ls', 1);\n this.storageWindow.removeItem('aws.amplify.test-ls');\n }\n catch (exception) {\n this.storageWindow = MemoryStorage;\n }\n }\n /**\n * This is used to return the storage\n * @returns {object} the storage\n */\n StorageHelper.prototype.getStorage = function () {\n return this.storageWindow;\n };\n return StorageHelper;\n}());\nexport default StorageHelper;\n//# sourceMappingURL=index.js.map","/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport JS from '../JS';\nimport MemoryStorage from '../StorageHelper';\nvar Linking = {};\nvar AppState = {\n addEventListener: function (action, handler) {\n return;\n },\n};\n// if not in react native, just use local storage\nvar AsyncStorage = JS.browserOrNode().isBrowser\n ? new MemoryStorage().getStorage()\n : undefined;\nexport { Linking, AppState, AsyncStorage };\n//# sourceMappingURL=index.js.map","var __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n 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;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nimport { ConsoleLogger as Logger } from './Logger';\nimport StorageHelper from './StorageHelper';\nimport { AWS } from './Facet';\nimport JS from './JS';\nimport { FacebookOAuth, GoogleOAuth } from './OAuthHelper';\nimport Amplify from './Amplify';\nvar logger = new Logger('Credentials');\nvar CREDENTIALS_TTL = 50 * 60 * 1000; // 50 min, can be modified on config if required in the future\nvar Credentials = /** @class */ (function () {\n function Credentials(config) {\n this._gettingCredPromise = null;\n this._refreshHandlers = {};\n this.configure(config);\n this._refreshHandlers['google'] = GoogleOAuth.refreshGoogleToken;\n this._refreshHandlers['facebook'] = FacebookOAuth.refreshFacebookToken;\n }\n Credentials.prototype.getCredSource = function () {\n return this._credentials_source;\n };\n Credentials.prototype.configure = function (config) {\n if (!config)\n return this._config || {};\n this._config = Object.assign({}, this._config, config);\n var refreshHandlers = this._config.refreshHandlers;\n // If the developer has provided an object of refresh handlers,\n // then we can merge the provided handlers with the current handlers.\n if (refreshHandlers) {\n this._refreshHandlers = __assign(__assign({}, this._refreshHandlers), refreshHandlers);\n }\n this._storage = this._config.storage;\n if (!this._storage) {\n this._storage = new StorageHelper().getStorage();\n }\n this._storageSync = Promise.resolve();\n if (typeof this._storage['sync'] === 'function') {\n this._storageSync = this._storage['sync']();\n }\n return this._config;\n };\n Credentials.prototype.get = function () {\n logger.debug('getting credentials');\n return this._pickupCredentials();\n };\n Credentials.prototype._pickupCredentials = function () {\n logger.debug('picking up credentials');\n if (!this._gettingCredPromise || !this._gettingCredPromise.isPending()) {\n logger.debug('getting new cred promise');\n if (AWS.config &&\n AWS.config.credentials &&\n AWS.config.credentials instanceof AWS.Credentials) {\n this._gettingCredPromise = JS.makeQuerablePromise(this._setCredentialsFromAWS());\n }\n else {\n this._gettingCredPromise = JS.makeQuerablePromise(this._keepAlive());\n }\n }\n else {\n logger.debug('getting old cred promise');\n }\n return this._gettingCredPromise;\n };\n Credentials.prototype._keepAlive = function () {\n logger.debug('checking if credentials exists and not expired');\n var cred = this._credentials;\n if (cred && !this._isExpired(cred)) {\n logger.debug('credentials not changed and not expired, directly return');\n return Promise.resolve(cred);\n }\n logger.debug('need to get a new credential or refresh the existing one');\n if (Amplify.Auth &&\n typeof Amplify.Auth.currentUserCredentials === 'function') {\n return Amplify.Auth.currentUserCredentials();\n }\n else {\n return Promise.reject('No Auth module registered in Amplify');\n }\n };\n Credentials.prototype.refreshFederatedToken = function (federatedInfo) {\n var _this = this;\n logger.debug('Getting federated credentials');\n var provider = federatedInfo.provider, user = federatedInfo.user;\n var token = federatedInfo.token, expires_at = federatedInfo.expires_at, identity_id = federatedInfo.identity_id;\n var that = this;\n logger.debug('checking if federated jwt token expired');\n if (expires_at > new Date().getTime()) {\n // if not expired\n logger.debug('token not expired');\n return this._setCredentialsFromFederation({\n provider: provider,\n token: token,\n user: user,\n identity_id: identity_id,\n expires_at: expires_at,\n });\n }\n else {\n // if refresh handler exists\n if (that._refreshHandlers[provider] &&\n typeof that._refreshHandlers[provider] === 'function') {\n logger.debug('getting refreshed jwt token from federation provider');\n return that._refreshHandlers[provider]()\n .then(function (data) {\n logger.debug('refresh federated token sucessfully', data);\n token = data.token;\n identity_id = data.identity_id;\n expires_at = data.expires_at;\n return that._setCredentialsFromFederation({\n provider: provider,\n token: token,\n user: user,\n identity_id: identity_id,\n expires_at: expires_at,\n });\n })\n .catch(function (e) {\n logger.debug('refresh federated token failed', e);\n _this.clear();\n return Promise.reject('refreshing federation token failed: ' + e);\n });\n }\n else {\n logger.debug('no refresh handler for provider:', provider);\n this.clear();\n return Promise.reject('no refresh handler for provider');\n }\n }\n };\n Credentials.prototype._isExpired = function (credentials) {\n if (!credentials) {\n logger.debug('no credentials for expiration check');\n return true;\n }\n logger.debug('is this credentials expired?', credentials);\n var ts = new Date().getTime();\n var delta = 10 * 60 * 1000; // 10 minutes\n var expired = credentials.expired, expireTime = credentials.expireTime;\n if (!expired &&\n expireTime > ts + delta &&\n ts < this._nextCredentialsRefresh) {\n return false;\n }\n return true;\n };\n Credentials.prototype._setCredentialsForGuest = function () {\n return __awaiter(this, void 0, void 0, function () {\n var attempted, _a, identityPoolId, region, mandatorySignIn, identityId, e_1, credentials, that;\n var _this = this;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n attempted = false;\n logger.debug('setting credentials for guest');\n _a = this._config, identityPoolId = _a.identityPoolId, region = _a.region, mandatorySignIn = _a.mandatorySignIn;\n if (mandatorySignIn) {\n return [2 /*return*/, Promise.reject('cannot get guest credentials when mandatory signin enabled')];\n }\n if (!identityPoolId) {\n logger.debug('No Cognito Federated Identity pool provided');\n return [2 /*return*/, Promise.reject('No Cognito Federated Identity pool provided')];\n }\n identityId = undefined;\n _b.label = 1;\n case 1:\n _b.trys.push([1, 3, , 4]);\n return [4 /*yield*/, this._storageSync];\n case 2:\n _b.sent();\n identityId = this._storage.getItem('CognitoIdentityId-' + identityPoolId);\n return [3 /*break*/, 4];\n case 3:\n e_1 = _b.sent();\n logger.debug('Failed to get the cached identityId', e_1);\n return [3 /*break*/, 4];\n case 4:\n credentials = new AWS.CognitoIdentityCredentials({\n IdentityPoolId: identityPoolId,\n IdentityId: identityId ? identityId : undefined,\n }, {\n region: region,\n });\n that = this;\n return [2 /*return*/, this._loadCredentials(credentials, 'guest', false, null)\n .then(function (res) {\n return res;\n })\n .catch(function (e) { return __awaiter(_this, void 0, void 0, function () {\n var newCredentials;\n return __generator(this, function (_a) {\n // If identity id is deleted in the console, we make one attempt to recreate it\n // and remove existing id from cache.\n if (e.code === 'ResourceNotFoundException' &&\n e.message === \"Identity '\" + identityId + \"' not found.\" &&\n !attempted) {\n attempted = true;\n logger.debug('Failed to load guest credentials');\n this._storage.removeItem('CognitoIdentityId-' + identityPoolId);\n credentials.clearCachedId();\n newCredentials = new AWS.CognitoIdentityCredentials({\n IdentityPoolId: identityPoolId,\n IdentityId: undefined,\n }, {\n region: region,\n });\n return [2 /*return*/, this._loadCredentials(newCredentials, 'guest', false, null)];\n }\n else {\n return [2 /*return*/, e];\n }\n return [2 /*return*/];\n });\n }); })];\n }\n });\n });\n };\n Credentials.prototype._setCredentialsFromAWS = function () {\n var credentials = AWS.config.credentials;\n logger.debug('setting credentials from aws');\n var that = this;\n if (credentials instanceof AWS.Credentials) {\n return Promise.resolve(credentials);\n }\n else {\n logger.debug('AWS.config.credentials is not an instance of AWS Credentials');\n return Promise.reject('AWS.config.credentials is not an instance of AWS Credentials');\n }\n };\n Credentials.prototype._setCredentialsFromFederation = function (params) {\n var provider = params.provider, token = params.token, identity_id = params.identity_id, user = params.user, expires_at = params.expires_at;\n var domains = {\n google: 'accounts.google.com',\n facebook: 'graph.facebook.com',\n amazon: 'www.amazon.com',\n developer: 'cognito-identity.amazonaws.com',\n };\n // Use custom provider url instead of the predefined ones\n var domain = domains[provider] || provider;\n if (!domain) {\n return Promise.reject('You must specify a federated provider');\n }\n var logins = {};\n logins[domain] = token;\n var _a = this._config, identityPoolId = _a.identityPoolId, region = _a.region;\n if (!identityPoolId) {\n logger.debug('No Cognito Federated Identity pool provided');\n return Promise.reject('No Cognito Federated Identity pool provided');\n }\n var credentials = new AWS.CognitoIdentityCredentials({\n IdentityPoolId: identityPoolId,\n IdentityId: identity_id,\n Logins: logins,\n }, {\n region: region,\n });\n return this._loadCredentials(credentials, 'federated', true, params);\n };\n Credentials.prototype._setCredentialsFromSession = function (session) {\n logger.debug('set credentials from session');\n var idToken = session.getIdToken().getJwtToken();\n var _a = this._config, region = _a.region, userPoolId = _a.userPoolId, identityPoolId = _a.identityPoolId;\n if (!identityPoolId) {\n logger.debug('No Cognito Federated Identity pool provided');\n return Promise.reject('No Cognito Federated Identity pool provided');\n }\n var key = 'cognito-idp.' + region + '.amazonaws.com/' + userPoolId;\n var logins = {};\n logins[key] = idToken;\n var credentials = new AWS.CognitoIdentityCredentials({\n IdentityPoolId: identityPoolId,\n Logins: logins,\n }, {\n region: region,\n });\n return this._loadCredentials(credentials, 'userPool', true, null);\n };\n Credentials.prototype._loadCredentials = function (credentials, source, authenticated, info) {\n var _this = this;\n var that = this;\n var identityPoolId = this._config.identityPoolId;\n return new Promise(function (res, rej) {\n credentials.get(function (err) { return __awaiter(_this, void 0, void 0, function () {\n var user, provider, token, expires_at, identity_id, e_2;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (err) {\n logger.debug('Failed to load credentials', credentials);\n rej(err);\n return [2 /*return*/];\n }\n logger.debug('Load credentials successfully', credentials);\n that._credentials = credentials;\n that._credentials.authenticated = authenticated;\n that._credentials_source = source;\n that._nextCredentialsRefresh = new Date().getTime() + CREDENTIALS_TTL;\n if (!(source === 'federated')) return [3 /*break*/, 3];\n user = Object.assign({ id: this._credentials.identityId }, info.user);\n provider = info.provider, token = info.token, expires_at = info.expires_at, identity_id = info.identity_id;\n try {\n this._storage.setItem('aws-amplify-federatedInfo', JSON.stringify({\n provider: provider,\n token: token,\n user: user,\n expires_at: expires_at,\n identity_id: identity_id,\n }));\n }\n catch (e) {\n logger.debug('Failed to put federated info into auth storage', e);\n }\n if (!(Amplify.Cache && typeof Amplify.Cache.setItem === 'function')) return [3 /*break*/, 2];\n return [4 /*yield*/, Amplify.Cache.setItem('federatedInfo', {\n provider: provider,\n token: token,\n user: user,\n expires_at: expires_at,\n identity_id: identity_id,\n }, { priority: 1 })];\n case 1:\n _a.sent();\n return [3 /*break*/, 3];\n case 2:\n logger.debug('No Cache module registered in Amplify');\n _a.label = 3;\n case 3:\n if (!(source === 'guest')) return [3 /*break*/, 7];\n _a.label = 4;\n case 4:\n _a.trys.push([4, 6, , 7]);\n return [4 /*yield*/, this._storageSync];\n case 5:\n _a.sent();\n this._storage.setItem('CognitoIdentityId-' + identityPoolId, credentials.identityId);\n return [3 /*break*/, 7];\n case 6:\n e_2 = _a.sent();\n logger.debug('Failed to cache identityId', e_2);\n return [3 /*break*/, 7];\n case 7:\n res(that._credentials);\n return [2 /*return*/];\n }\n });\n }); });\n });\n };\n Credentials.prototype.set = function (params, source) {\n if (source === 'session') {\n return this._setCredentialsFromSession(params);\n }\n else if (source === 'federation') {\n return this._setCredentialsFromFederation(params);\n }\n else if (source === 'guest') {\n return this._setCredentialsForGuest();\n }\n else {\n logger.debug('no source specified for setting credentials');\n return Promise.reject('invalid source');\n }\n };\n Credentials.prototype.clear = function () {\n return __awaiter(this, void 0, void 0, function () {\n var _a, identityPoolId, region, credentials;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n _a = this._config, identityPoolId = _a.identityPoolId, region = _a.region;\n if (identityPoolId) {\n credentials = new AWS.CognitoIdentityCredentials({\n IdentityPoolId: identityPoolId,\n }, {\n region: region,\n });\n credentials.clearCachedId();\n }\n this._credentials = null;\n this._credentials_source = null;\n this._storage.removeItem('aws-amplify-federatedInfo');\n if (!(Amplify.Cache && typeof Amplify.Cache.setItem === 'function')) return [3 /*break*/, 2];\n return [4 /*yield*/, Amplify.Cache.removeItem('federatedInfo')];\n case 1:\n _b.sent();\n return [3 /*break*/, 3];\n case 2:\n logger.debug('No Cache module registered in Amplify');\n _b.label = 3;\n case 3: return [2 /*return*/];\n }\n });\n });\n };\n /**\n * Compact version of credentials\n * @param {Object} credentials\n * @return {Object} - Credentials\n */\n Credentials.prototype.shear = function (credentials) {\n return {\n accessKeyId: credentials.accessKeyId,\n sessionToken: credentials.sessionToken,\n secretAccessKey: credentials.secretAccessKey,\n identityId: credentials.identityId,\n authenticated: credentials.authenticated,\n };\n };\n return Credentials;\n}());\nexport { Credentials };\nvar instance = new Credentials(null);\nexport default instance;\n//# sourceMappingURL=Credentials.js.map","/**\n * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nimport { ConsoleLogger as Logger } from '../Logger';\nimport JS from '../JS';\nimport Amplify from '../Amplify';\n/**\n * Provides a means to registering a service worker in the browser\n * and communicating with it via postMessage events.\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/\n *\n * postMessage events are currently not supported in all browsers. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API\n *\n * At the minmum this class will register the service worker and listen\n * and attempt to dispatch messages on state change and record analytics\n * events based on the service worker lifecycle.\n */\nvar ServiceWorkerClass = /** @class */ (function () {\n function ServiceWorkerClass() {\n // The AWS Amplify logger\n this._logger = new Logger('ServiceWorker');\n }\n Object.defineProperty(ServiceWorkerClass.prototype, \"serviceWorker\", {\n /**\n * Get the currently active service worker\n */\n get: function () {\n return this._serviceWorker;\n },\n enumerable: true,\n configurable: true\n });\n /**\n * Register the service-worker.js file in the browser\n * Make sure the service-worker.js is part of the build\n * for example with Angular, modify the angular-cli.json file\n * and add to \"assets\" array \"service-worker.js\"\n * @param {string} - (optional) Service worker file. Defaults to \"/service-worker.js\"\n * @param {string} - (optional) The service worker scope. Defaults to \"/\"\n * - API Doc: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n * @returns {Promise}\n *\t- resolve(ServiceWorkerRegistration)\n *\t- reject(Error)\n **/\n ServiceWorkerClass.prototype.register = function (filePath, scope) {\n var _this = this;\n if (filePath === void 0) { filePath = '/service-worker.js'; }\n if (scope === void 0) { scope = '/'; }\n this._logger.debug(\"registering \" + filePath);\n this._logger.debug(\"registering service worker with scope \" + scope);\n return new Promise(function (resolve, reject) {\n if (navigator && 'serviceWorker' in navigator) {\n navigator.serviceWorker\n .register(filePath, {\n scope: scope,\n })\n .then(function (registration) {\n if (registration.installing) {\n _this._serviceWorker = registration.installing;\n }\n else if (registration.waiting) {\n _this._serviceWorker = registration.waiting;\n }\n else if (registration.active) {\n _this._serviceWorker = registration.active;\n }\n _this._registration = registration;\n _this._setupListeners();\n _this._logger.debug(\"Service Worker Registration Success: \" + registration);\n return resolve(registration);\n })\n .catch(function (error) {\n _this._logger.debug(\"Service Worker Registration Failed \" + error);\n return reject(error);\n });\n }\n else {\n return reject(new Error('Service Worker not available'));\n }\n });\n };\n /**\n * Enable web push notifications. If not subscribed, a new subscription will\n * be created and registered.\n * \tTest Push Server: https://web-push-codelab.glitch.me/\n * \tPush Server Libraries: https://github.com/web-push-libs/\n * \tAPI Doc: https://developers.google.com/web/fundamentals/codelabs/push-notifications/\n * @param publicKey\n * @returns {Promise}\n * \t- resolve(PushSubscription)\n * - reject(Error)\n */\n ServiceWorkerClass.prototype.enablePush = function (publicKey) {\n var _this = this;\n if (!this._registration)\n throw new Error('Service Worker not registered');\n this._publicKey = publicKey;\n return new Promise(function (resolve, reject) {\n if (JS.browserOrNode().isBrowser) {\n _this._registration.pushManager.getSubscription().then(function (subscription) {\n if (subscription) {\n _this._subscription = subscription;\n _this._logger.debug(\"User is subscribed to push: \" + JSON.stringify(subscription));\n resolve(subscription);\n }\n else {\n _this._logger.debug(\"User is NOT subscribed to push\");\n return _this._registration.pushManager\n .subscribe({\n userVisibleOnly: true,\n applicationServerKey: _this._urlB64ToUint8Array(publicKey),\n })\n .then(function (subscription) {\n _this._subscription = subscription;\n _this._logger.debug(\"User subscribed: \" + JSON.stringify(subscription));\n resolve(subscription);\n })\n .catch(function (error) {\n _this._logger.error(error);\n });\n }\n });\n }\n else {\n return reject(new Error('Service Worker not available'));\n }\n });\n };\n /**\n * Convert a base64 encoded string to a Uint8 array for the push server key\n * @param base64String\n */\n ServiceWorkerClass.prototype._urlB64ToUint8Array = function (base64String) {\n var padding = '='.repeat((4 - (base64String.length % 4)) % 4);\n var base64 = (base64String + padding)\n .replace(/\\-/g, '+')\n .replace(/_/g, '/');\n var rawData = window.atob(base64);\n var outputArray = new Uint8Array(rawData.length);\n for (var i = 0; i < rawData.length; ++i) {\n outputArray[i] = rawData.charCodeAt(i);\n }\n return outputArray;\n };\n /**\n * Send a message to the service worker. The service worker needs\n * to implement `self.addEventListener('message') to handle the\n * message. This ***currently*** does not work in Safari or IE.\n * @param {object | string} - An arbitrary JSON object or string message to send to the service worker\n *\t- see: https://developer.mozilla.org/en-US/docs/Web/API/Transferable\n * @returns {Promise}\n **/\n ServiceWorkerClass.prototype.send = function (message) {\n if (this._serviceWorker) {\n this._serviceWorker.postMessage(typeof message === 'object' ? JSON.stringify(message) : message);\n }\n };\n /**\n * Listen for service worker state change and message events\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state\n **/\n ServiceWorkerClass.prototype._setupListeners = function () {\n var _this = this;\n this._serviceWorker.addEventListener('statechange', function (event) {\n var currentState = _this._serviceWorker.state;\n _this._logger.debug(\"ServiceWorker statechange: \" + currentState);\n if (Amplify.Analytics && typeof Amplify.Analytics.record === 'function') {\n Amplify.Analytics.record({\n name: 'ServiceWorker',\n attributes: {\n state: currentState,\n },\n });\n }\n });\n this._serviceWorker.addEventListener('message', function (event) {\n _this._logger.debug(\"ServiceWorker message event: \" + event);\n });\n };\n return ServiceWorkerClass;\n}());\nexport default ServiceWorkerClass;\n//# sourceMappingURL=ServiceWorker.js.map","/*\n * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with\n * the License. A copy of the License is located at\n *\n * http://aws.amazon.com/apache2.0/\n *\n * or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions\n * and limitations under the License.\n */\nvar packageInfo = require('../../package.json');\nvar Platform = {\n userAgent: \"aws-amplify/\" + packageInfo.version + \" js\",\n product: '',\n navigator: null,\n isReactNative: false,\n};\nif (typeof navigator !== 'undefined' && navigator.product) {\n Platform.product = navigator.product || '';\n Platform.navigator = navigator || null;\n switch (navigator.product) {\n case 'ReactNative':\n Platform.userAgent = \"aws-amplify/\" + packageInfo.version + \" react-native\";\n Platform.isReactNative = true;\n break;\n default:\n Platform.userAgent = \"aws-amplify/\" + packageInfo.version + \" js\";\n Platform.isReactNative = false;\n break;\n }\n}\nexport default Platform;\n//# sourceMappingURL=index.js.map","export const VIEWBOX_WIDTH = 100;\nexport const VIEWBOX_HEIGHT = 100;\nexport const VIEWBOX_HEIGHT_HALF = 50;\nexport const VIEWBOX_CENTER_X = 50;\nexport const VIEWBOX_CENTER_Y = 50;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar tslib_1 = require(\"tslib\");\ntslib_1.__exportStar(require(\"./EventStreamMarshaller\"), exports);\ntslib_1.__exportStar(require(\"./Int64\"), exports);\n//# sourceMappingURL=index.js.map","import React from \"react\";\nimport { Router } from \"react-router\";\nimport { createBrowserHistory as createHistory } from \"history\";\nimport PropTypes from \"prop-types\";\nimport warning from \"tiny-warning\";\n\n/**\n * The public API for a