{"version":3,"sources":["../src/index.ts","../src/vendor/sig-v4.service.ts","../src/helper/services/axios.service.ts","../src/helper/services/signed-http.service.ts","../src/helper/services/logger-helper.service.ts","../src/helper/services/logger.service.ts","../src/helper/services/storage.service.ts","../src/helper/services/utils.ts","../src/core/identity.service.ts","../src/core/lemon-storage.service.ts","../src/core/auth.service.ts"],"names":["sha256","hmacSHA256","Hex","SHA256","encHex","HmacSHA256","sigV4Client","config","AWS_SHA_256","AWS4_REQUEST","AWS4","X_AMZ_DATE","X_AMZ_SECURITY_TOKEN","HOST","AUTHORIZATION","hash","value","hexEncode","hmac","secret","buildCanonicalRequest","method","path","queryParams","headers","payload","buildCanonicalUri","buildCanonicalQueryString","buildCanonicalHeaders","buildCanonicalSignedHeaders","hashCanonicalRequest","request","uri","UriEncode","input","encodeSlash","result","i","ch","sortedQueryParams","property","canonicalQueryString","urlencode","text","canonicalHeaders","sortedKeys","buildStringToSign","datetime","credentialScope","hashedCanonicalRequest","buildCredentialScope","region","service","calculateSigningKey","secretKey","calculateSignature","key","stringToSign","buildAuthorizationHeader","accessKey","signature","awsSigV4Client","invokeUrl","endpoint","pathComponent","verb","body","canonicalRequest","signingKey","url","queryString","axios","AxiosService","requestOptions","__spreadValues","resolve","reject","response","err","AWS","format","NODE_COLORS","BROWSER_COLORS","LoggerHelperService","message","params","extraParams","type","name","param","LogType","LoggerService","namespace","options","formattedMessage","formattedText","shouldFormat","typeBlank","showTimestamp","showLogType","timestampFormat","typeFormat","textFormat","namespaceFormat","timestampLog","typeLog","namespaceLog","textLog","whiteColor","typeColor","blackColor","date","zeroOrNull","dt","year","month","day","hours","minutes","seconds","dateText","hoursText","SignedHttpService","credentials","customHeader","customOptions","allParams","signedClient","header","bodyReq","signedRequest","objParams","axiosService","hostname","dataMemory","MemoryStorage","LocalStorageService","exception","encBase64","createAsyncDelay","duration","withRetries","attempt","nthTry","delay","args","__async","retryCount","error","calcSignature","current","userAgent","authId","accountId","identityId","identityToken","data","LemonStorageService","project","storage","prefix","promise","item","tmpResult","expiredTime","accessKeyId","accessToken","hostKey","AccessKeyId","SecretKey","SessionToken","cloud","HostKey","token","credential","identityPoolId","TIME_DELAY","kms","kmsArn","IdentityService","_IdentityService","projectName","isAWS","isAzure","__spreadProps","oAuthEndpoint","extraHeader","extraOptions","originToken","bodyData","refreshResult","event","refreshToken","awsCredentials","_a","_b","AuthService"],"mappings":"ooBACA,MAAO,eCgBP,OAAOA,OAAY,sBACnB,OAAOC,OAAgB,2BACvB,OAAOC,OAAS,uBAEhB,IAAMC,GAASH,GACTI,GAASF,GACTG,GAAaJ,GAEbK,EAAsC,CAAC,EAE7CA,EAAY,UAAY,SAAUC,EAAa,CAC3C,IAAMC,EAAc,mBACdC,EAAe,eACfC,EAAO,OACPC,EAAa,aACbC,EAAuB,uBACvBC,EAAO,OACPC,EAAgB,gBAEtB,SAASC,EAAKC,EAAY,CACtB,OAAOb,GAAOa,CAAK,CACvB,CAEA,SAASC,EAAUD,EAAY,CAC3B,OAAOA,EAAM,SAASZ,EAAM,CAChC,CAEA,SAASc,EAAKC,EAAaH,EAAY,CACnC,OAAOX,GAAWW,EAAOG,CAAM,CACnC,CAEA,SAASC,EAAsBC,EAAaC,EAAWC,EAAkBC,EAAcC,EAAc,CACjG,OACIJ,EACA;AAAA,EACAK,EAAkBJ,CAAI,EACtB;AAAA,EACAK,EAA0BJ,CAAW,EACrC;AAAA,EACAK,EAAsBJ,CAAO,EAC7B;AAAA,EACAK,EAA4BL,CAAO,EACnC;AAAA,EACAP,EAAUF,EAAKU,CAAO,CAAC,CAE/B,CAEA,SAASK,EAAqBC,EAAc,CACxC,OAAOd,EAAUF,EAAKgB,CAAO,CAAC,CAClC,CAEA,SAASL,EAAkBM,EAAU,CAEjC,OAAWC,EAAUD,CAAG,CAC5B,CAIA,SAASC,EAAUC,EAAYC,EAAc,GAAO,CAChD,IAAMC,EAAS,CAAC,EAUhB,QAASC,EAAI,EAAGA,EAAIH,EAAM,OAAQG,IAAK,CACnC,IA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,KAAK,gBAAgB,WAAWA,CAAO,EACvC,KAAK,gBAAgB,oBAAoBA,EAAQ,OAAO,CAC5D,CAKA,iBAAoC,CAChC,OAAO,KAAK,gBAAgB,gBAAgB,CAChD,CAMM,wBAAwBgF,EAAwD,QAAA3B,EAAA,sBAClF,aAAM,KAAK,gBAAgB,wBAAwB2B,CAAK,EACjD,MAAM,KAAK,gBAAgB,eAAe,CACrD,GAKM,2BAAsD,QAAA3B,EAAA,sBACxD,aAAM,KAAK,gBAAgB,0BAA0B,EAC9C,MAAM,KAAK,gBAAgB,eAAe,CACrD,GAKM,QAAQ+B,EAA8B,QAAA/B,EAAA,sBACxC,MAAM,KAAK,gBAAgB,QAAQ+B,CAAG,CAC1C,GAKA,gBAAkD,CAC9C,OAAO,KAAK,gBAAgB,eAAe,EAAE,MAAM,IAAM,IAAI,CACjE,CAUA,QAAQ5J,EAAiB,MAAO0C,EAAkBzC,EAAc+D,EAAcnB,EAA0B,CACpG,OAAO,KAAK,gBAAgB,QAAQ7C,EAAQ0C,EAAUzC,EAAM+D,EAAQnB,CAAI,CAC5E,CAUA,uBACI7C,EAAiB,MACjB0C,EACAzC,EACA+D,EACAnB,EACY,CACZ,OAAO,KAAK,gBAAgB,uBAAuB7C,EAAQ0C,EAAUzC,EAAM+D,EAAQnB,CAAI,CAC3F,CAKA,QAA2B,CACvB,OAAO,KAAK,gBAAgB,OAAO,CACvC,CACJ","sourcesContent":["// for polyfill on IE11\nimport 'whatwg-fetch';\n\nexport * from './vendor';\nexport * from './helper';\nexport * from './core';\n","/* tslint:disable */\n/*\n * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\").\n * You may not use this file except in compliance with the License.\n * 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\n * on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied. See the License for the specific language governing\n * permissions and limitations under the License.\n */\n\n// import * as CryptoJS from 'crypto-js';\nimport sha256 from 'crypto-js/sha256.js';\nimport hmacSHA256 from 'crypto-js/hmac-sha256.js';\nimport Hex from 'crypto-js/enc-hex.js';\n\nconst SHA256 = sha256;\nconst encHex = Hex;\nconst HmacSHA256 = hmacSHA256;\n\nconst sigV4Client: { [key: string]: any } = {};\n\nsigV4Client.newClient = function (config: any) {\n    const AWS_SHA_256 = 'AWS4-HMAC-SHA256';\n    const AWS4_REQUEST = 'aws4_request';\n    const AWS4 = 'AWS4';\n    const X_AMZ_DATE = 'x-amz-date';\n    const X_AMZ_SECURITY_TOKEN = 'x-amz-security-token';\n    const HOST = 'host';\n    const AUTHORIZATION = 'Authorization';\n\n    function hash(value: any) {\n        return SHA256(value);\n    }\n\n    function hexEncode(value: any) {\n        return value.toString(encHex);\n    }\n\n    function hmac(secret: any, value: any) {\n        return HmacSHA256(value, secret); // eslint-disable-line\n    }\n\n    function buildCanonicalRequest(method: any, path: any, queryParams: any, headers: any, payload: any) {\n        return (\n            method +\n            '\\n' +\n            buildCanonicalUri(path) +\n            '\\n' +\n            buildCanonicalQueryString(queryParams) +\n            '\\n' +\n            buildCanonicalHeaders(headers) +\n            '\\n' +\n            buildCanonicalSignedHeaders(headers) +\n            '\\n' +\n            hexEncode(hash(payload))\n        );\n    }\n\n    function hashCanonicalRequest(request: any) {\n        return hexEncode(hash(request));\n    }\n\n    function buildCanonicalUri(uri: any) {\n        // eslint-disable-next-line no-constant-condition\n        return 1 ? UriEncode(uri) : encodeURI(uri);\n    }\n\n    //! code from: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-header-based-auth.html\n    //! '*' '+' '!' 같은 특수 문자가 들어갈 경우 인증 에러 발생할 수 있음.\n    function UriEncode(input: any, encodeSlash = false) {\n        const result = [];\n        // const toHexUTF8 = (str: any) => {\n        //     //TOOD - '한글' 인코딩시 utf8 으로 안하는듯.\n        //     str = str || '';\n        //     let hex = '';\n        //     for (let i = 0; i < str.length; i++) {\n        //         hex += '%' + str.charCodeAt(i).toString(16).toUpperCase();\n        //     }\n        //     return hex;\n        // };\n        for (let i = 0; i < input.length; i++) {\n            const ch = input.charAt(i);\n            if (\n                (ch >= 'A' && ch <= 'Z') ||\n                (ch >= 'a' && ch <= 'z') ||\n                (ch >= '0' && ch <= '9') ||\n                ch == '_' ||\n                ch == '-' ||\n                ch == '~' ||\n                ch == '.'\n            ) {\n                result.push(ch);\n            } else if (ch == '*') {\n                //TODO - encodeURIComponent()에서 인코딩이 안되서, 강제로 인코딩됨.\n                result.push('%2A');\n            } else if (ch == '!') {\n                //TODO - encodeURIComponent()에서 인코딩이 안되서, 강제로 인코딩됨.\n                result.push('%21');\n            } else if (ch == '(') {\n                //TODO - encodeURIComponent()에서 인코딩이 안되서, 강제로 인코딩됨.\n                result.push('%28');\n            } else if (ch == ')') {\n                //TODO - encodeURIComponent()에서 인코딩이 안되서, 강제로 인코딩됨.\n                result.push('%29');\n            } else if (ch == '/') {\n                result.push(encodeSlash ? '%2F' : ch);\n            } else {\n                // result.push(1 ? hexEncode(ch) : toHexUTF8(ch));\n                result.push(encodeURIComponent(ch));\n            }\n        }\n        // console.log('! encode=',result.join('').toString(), '<-', input);\n        return result.join('').toString();\n    }\n\n    function buildCanonicalQueryString(queryParams: any) {\n        if (Object.keys(queryParams).length < 1) {\n            return '';\n        }\n\n        const sortedQueryParams = [];\n        for (const property in queryParams) {\n            if (Object.prototype.hasOwnProperty.call(queryParams, property)) {\n                sortedQueryParams.push(property);\n            }\n        }\n        sortedQueryParams.sort();\n\n        let canonicalQueryString = '';\n        for (let i = 0; i < sortedQueryParams.length; i++) {\n            canonicalQueryString +=\n                sortedQueryParams[i] +\n                '=' +\n                //FIX - encoding problem: A-Z, a-z, 0-9, hyphen ( - ), underscore ( _ ), period ( . ), and tilde ( ~ ).\n                // https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html.\n                // encodeURIComponent(queryParams[sortedQueryParams[i]]) +\n                urlencode(queryParams[sortedQueryParams[i]]) +\n                '&';\n        }\n        return canonicalQueryString.substr(0, canonicalQueryString.length - 1);\n    }\n\n    //code from https://www.codeproject.com/Articles/1016044/JavaScript-URL-encode-decode-and-escape\n    function urlencode(text: any) {\n        return encodeURIComponent(text)\n            .replace(/!/g, '%21')\n            .replace(/'/g, '%27')\n            .replace(/\\(/g, '%28')\n            .replace(/\\)/g, '%29')\n            .replace(/\\*/g, '%2A')\n            .replace(/%20/g, '%20');\n    }\n\n    // function urldecode(text: any) {\n    //     return decodeURIComponent((text + '').replace(/\\+/g, '%20'));\n    // }\n\n    function buildCanonicalHeaders(headers: any) {\n        let canonicalHeaders = '';\n        const sortedKeys = [];\n        for (const property in headers) {\n            if (Object.prototype.hasOwnProperty.call(headers, property)) {\n                sortedKeys.push(property);\n            }\n        }\n        sortedKeys.sort();\n\n        for (let i = 0; i < sortedKeys.length; i++) {\n            canonicalHeaders += sortedKeys[i].toLowerCase() + ':' + headers[sortedKeys[i]] + '\\n';\n        }\n        return canonicalHeaders;\n    }\n\n    function buildCanonicalSignedHeaders(headers: any) {\n        const sortedKeys = [];\n        for (const property in headers) {\n            if (Object.prototype.hasOwnProperty.call(headers, property)) {\n                sortedKeys.push(property.toLowerCase());\n            }\n        }\n        sortedKeys.sort();\n\n        return sortedKeys.join(';');\n    }\n\n    function buildStringToSign(datetime: any, credentialScope: any, hashedCanonicalRequest: any) {\n        return AWS_SHA_256 + '\\n' + datetime + '\\n' + credentialScope + '\\n' + hashedCanonicalRequest;\n    }\n\n    function buildCredentialScope(datetime: any, region: any, service: any) {\n        return datetime.substr(0, 8) + '/' + region + '/' + service + '/' + AWS4_REQUEST;\n    }\n\n    function calculateSigningKey(secretKey: any, datetime: any, region: any, service: any) {\n        return hmac(hmac(hmac(hmac(AWS4 + secretKey, datetime.substr(0, 8)), region), service), AWS4_REQUEST);\n    }\n\n    function calculateSignature(key: any, stringToSign: any) {\n        return hexEncode(hmac(key, stringToSign));\n    }\n\n    function buildAuthorizationHeader(accessKey: any, credentialScope: any, headers: any, signature: any) {\n        return (\n            AWS_SHA_256 +\n            ' Credential=' +\n            accessKey +\n            '/' +\n            credentialScope +\n            ', SignedHeaders=' +\n            buildCanonicalSignedHeaders(headers) +\n            ', Signature=' +\n            signature\n        );\n    }\n\n    const awsSigV4Client: { [key: string]: any } = {};\n\n    if (config.accessKey === undefined || config.secretKey === undefined) {\n        return awsSigV4Client;\n    }\n\n    awsSigV4Client.host = config.host;\n    awsSigV4Client.accessKey = config.accessKey;\n    awsSigV4Client.secretKey = config.secretKey;\n    awsSigV4Client.sessionToken = config.sessionToken;\n    awsSigV4Client.serviceName = config.serviceName || 'execute-api';\n    awsSigV4Client.region = config.region || 'ap-northeast-2';\n    awsSigV4Client.defaultAcceptType = config.defaultAcceptType || 'application/json';\n    awsSigV4Client.defaultContentType = config.defaultContentType || 'application/json';\n\n    const invokeUrl = config.endpoint;\n    const endpoint = /(^https?:\\/\\/[^/]+)/g.exec(invokeUrl)[1];\n    const pathComponent = invokeUrl.substring(endpoint.length);\n\n    awsSigV4Client.endpoint = endpoint;\n    awsSigV4Client.pathComponent = pathComponent;\n\n    awsSigV4Client.signRequest = function (request: any) {\n        const verb = request.method.toUpperCase();\n        const path = awsSigV4Client.pathComponent + request.path;\n        const queryParams = request.queryParams || {}; //{ ...request.queryParams };\n        const headers = request.headers || {}; //{ ...request.headers };\n\n        // If the user has not specified an override for Content type the use default\n        if (headers['Content-Type'] === undefined) {\n            headers['Content-Type'] = awsSigV4Client.defaultContentType;\n        }\n\n        // If the user has not specified an override for Accept type the use default\n        if (headers['Accept'] === undefined) {\n            headers['Accept'] = awsSigV4Client.defaultAcceptType;\n        }\n\n        let body = request.body || {}; //{ ...request.body };\n        // override request body and set to empty when signing GET requests\n        if (request.body === undefined || verb === 'GET') {\n            body = '';\n        } else {\n            body = body && typeof body === 'object' ? JSON.stringify(body) : body;\n        }\n\n        // If there is no body remove the content-type header so it is not\n        // included in SigV4 calculation\n        if (body === '' || body === undefined || body === null) {\n            delete headers['Content-Type'];\n        }\n\n        const datetime = new Date()\n            .toISOString()\n            .replace(/\\.\\d{3}Z$/, 'Z')\n            .replace(/[:-]|\\.\\d{3}/g, '');\n        headers[X_AMZ_DATE] = datetime;\n        // let parser = new URL(awsSigV4Client.endpoint);\n        // headers[HOST] = parser.hostname;\n        headers[HOST] = awsSigV4Client.host;\n\n        const canonicalRequest = buildCanonicalRequest(verb, path, queryParams, headers, body);\n        const hashedCanonicalRequest = hashCanonicalRequest(canonicalRequest);\n        const credentialScope = buildCredentialScope(datetime, awsSigV4Client.region, awsSigV4Client.serviceName);\n        const stringToSign = buildStringToSign(datetime, credentialScope, hashedCanonicalRequest);\n        const signingKey = calculateSigningKey(\n            awsSigV4Client.secretKey,\n            datetime,\n            awsSigV4Client.region,\n            awsSigV4Client.serviceName\n        );\n        const signature = calculateSignature(signingKey, stringToSign);\n\n        headers[AUTHORIZATION] = buildAuthorizationHeader(\n            awsSigV4Client.accessKey,\n            credentialScope,\n            headers,\n            signature\n        );\n        if (awsSigV4Client.sessionToken !== undefined && awsSigV4Client.sessionToken !== '') {\n            headers[X_AMZ_SECURITY_TOKEN] = awsSigV4Client.sessionToken;\n        }\n        delete headers[HOST];\n\n        let url = awsSigV4Client.endpoint + path;\n        const queryString = buildCanonicalQueryString(queryParams);\n        if (queryString !== '') {\n            url += '?' + queryString;\n        }\n\n        // Need to re-attach Content-Type if it is not specified at this point\n        if (headers['Content-Type'] === undefined) {\n            headers['Content-Type'] = awsSigV4Client.defaultContentType;\n        }\n\n        return {\n            headers: headers,\n            url: url,\n        };\n    };\n\n    return awsSigV4Client;\n};\n\nexport { sigV4Client };\n","import axios, { AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse, Method } from 'axios';\n\nexport class AxiosService {\n    private options: AxiosRequestConfig;\n    private axiosInstance: AxiosInstance;\n\n    constructor(private requestOptions: AxiosRequestConfig = {}) {\n        this.options = requestOptions;\n        this.axiosInstance = axios.create();\n    }\n\n    public get<T>(url: string, queryParams?: object) {\n        return this.makeRequest<T>('GET', url, queryParams);\n    }\n\n    public post<T>(url: string, body: object, queryParams?: object) {\n        return this.makeRequest<T>('POST', url, queryParams, body);\n    }\n\n    public put<T>(url: string, body: object, queryParams?: object) {\n        return this.makeRequest<T>('PUT', url, queryParams, body);\n    }\n\n    public patch<T>(url: string, body: object, queryParams?: object) {\n        return this.makeRequest<T>('PATCH', url, queryParams, body);\n    }\n\n    public delete(url: string, queryParams?: object) {\n        return this.makeRequest('DELETE', url, queryParams);\n    }\n\n    private makeRequest<T>(method: Method, url: string, queryParams?: object, body?: object) {\n        let request: AxiosPromise<T>;\n\n        switch (method) {\n            case 'GET':\n                request = this.axiosInstance.get<T>(url, { params: queryParams, ...this.options });\n                break;\n            case 'POST':\n                request = this.axiosInstance.post<T>(url, body, { params: queryParams, ...this.options });\n                break;\n            case 'PUT':\n                request = this.axiosInstance.put<T>(url, body, { params: queryParams, ...this.options });\n                break;\n            case 'PATCH':\n                request = this.axiosInstance.patch<T>(url, body, { params: queryParams, ...this.options });\n                break;\n            case 'DELETE':\n                request = this.axiosInstance.delete(url, { params: queryParams, ...this.options });\n                break;\n            default:\n                throw new Error('Method not supported');\n        }\n\n        return new Promise((resolve, reject) => {\n            request.then((response: AxiosResponse) => resolve(response.data)).catch((err: Error) => reject(err));\n        });\n    }\n}\n","import * as AWS from 'aws-sdk/global.js';\nimport { AxiosService } from './axios.service';\nimport { LoggerService } from './logger.service';\nimport { sigV4Client } from '../../vendor';\n\nexport interface RequiredHttpParameters {\n    method: string;\n    path?: string;\n    queryParams?: any;\n    bodyReq?: any;\n}\n\nexport interface SignedHttpOptions {\n    customHeader?: any;\n    customOptions?: any;\n}\n\nexport class SignedHttpService {\n    private providerCredential: AWS.Credentials;\n    private customHeader: any;\n    private customOptions: any;\n    private logger: LoggerService;\n\n    constructor(options: SignedHttpOptions = {}, credentials?: AWS.Credentials) {\n        const { customHeader, customOptions } = options;\n        this.customHeader = customHeader\n            ? { 'Content-Type': 'application/json', ...customHeader }\n            : { 'Content-Type': 'application/json' };\n        this.customOptions = customOptions ? { ...customOptions } : {};\n        this.logger = new LoggerService();\n        if (credentials) {\n            this.providerCredential = credentials;\n        }\n    }\n\n    request(endpoint: string, allParams: RequiredHttpParameters) {\n        if (!endpoint) {\n            throw new Error('@endpoint (string) is required!');\n        }\n        if (!allParams) {\n            throw new Error('@allParams (RequiredHttpParameters) is required!');\n        }\n\n        return this.getSignedClient(endpoint)\n            .then(signedClient => this.getSignedHeader(signedClient, allParams))\n            .then(header => this.executeRequest(header, endpoint, allParams));\n    }\n\n    private getSignedClient(endpoint: string): Promise<any> {\n        if (!endpoint) {\n            throw new Error('@endpoint (string) is required!');\n        }\n\n        return new Promise(resolve => {\n            // prepare client\n            const ok = AWS.config && AWS.config.credentials;\n            let signedClient =\n                ok &&\n                sigV4Client.newClient({\n                    accessKey: AWS.config.credentials.accessKeyId,\n                    secretKey: AWS.config.credentials.secretAccessKey,\n                    sessionToken: AWS.config.credentials.sessionToken,\n                    region: 'ap-northeast-2',\n                    endpoint: endpoint,\n                    host: this.extractHostname(endpoint),\n                });\n\n            if (this.providerCredential) {\n                signedClient = sigV4Client.newClient({\n                    accessKey: this.providerCredential.accessKeyId,\n                    secretKey: this.providerCredential.secretAccessKey,\n                    sessionToken: this.providerCredential.sessionToken,\n                    region: 'ap-northeast-2',\n                    endpoint: endpoint,\n                    host: this.extractHostname(endpoint),\n                });\n            }\n\n            const hasNoSignedClient = signedClient === null || signedClient === undefined;\n            if (hasNoSignedClient) {\n                this.logger.warn('signedClient is missing => Request without signing');\n            }\n            resolve(signedClient);\n        });\n    }\n\n    private getSignedHeader(signedClient: any, params: RequiredHttpParameters): Promise<any> {\n        return new Promise(resolve => {\n            if (!signedClient) {\n                return resolve(null);\n            }\n\n            const { method, path, queryParams, bodyReq } = params;\n            // check signRequest instance.\n            const signedRequest = signedClient.signRequest({\n                method: method,\n                path: path,\n                headers: {},\n                queryParams: queryParams,\n                body: bodyReq,\n            });\n            const header = signedRequest && signedRequest.headers;\n\n            const hasNoHeader = header === null || header === undefined;\n            if (hasNoHeader) {\n                this.logger.warn('signedClient is missing => Request without signing');\n                return resolve(null);\n            }\n            return resolve(header);\n        });\n    }\n\n    private executeRequest(header: any, endpoint: string, objParams: RequiredHttpParameters) {\n        // execute http request.\n        const { method, path, queryParams, bodyReq } = objParams;\n        const headers = header ? { ...header, ...this.customHeader } : { ...this.customHeader };\n        const axiosService = new AxiosService({ headers, ...this.customOptions });\n        switch (method.toUpperCase()) {\n            case 'POST':\n                return axiosService.post(endpoint + path, bodyReq, queryParams);\n            case 'PUT':\n                return axiosService.put(endpoint + path, bodyReq, queryParams);\n            case 'DELETE':\n                return axiosService.delete(endpoint + path, queryParams);\n            case 'PATCH':\n                return axiosService.patch(endpoint + path, bodyReq, queryParams);\n            case 'GET':\n            default:\n                return axiosService.get(endpoint + path, queryParams);\n        }\n    }\n\n    // refer: https://stackoverflow.com/a/23945027/5268806\n    private extractHostname(url: string) {\n        let hostname;\n        // find & remove protocol (http, ftp, etc.) and get hostname\n        if (url.indexOf('//') > -1) {\n            hostname = url.split('/')[2];\n        } else {\n            hostname = url.split('/')[0];\n        }\n        // find & remove port number\n        hostname = hostname.split(':')[0];\n        // find & remove \"?\"\n        hostname = hostname.split('?')[0];\n        return hostname;\n    }\n}\n","import { format } from 'util';\nimport { LogType } from './logger.service';\n\nexport const NODE_COLORS = {\n    Black: 0,\n    Red: 1,\n    Green: 2,\n    Yellow: 3,\n    Blue: 4,\n    Magenta: 5,\n    Cyan: 6,\n    Grey: 7,\n    White: 9,\n};\n\nexport const BROWSER_COLORS = {\n    Black: 'Black',\n    Red: 'IndianRed',\n    Green: 'LimeGreen',\n    Yellow: 'Orange',\n    Blue: 'RoyalBlue',\n    Magenta: 'Orchid',\n    Cyan: 'SkyBlue',\n    Grey: 'DimGrey',\n    White: 'White',\n};\n\nexport class LoggerHelperService {\n    private colorSet: any;\n    private logColors: any;\n\n    constructor() {\n        this.colorSet = this.getColorSet();\n        this.logColors = {\n            DEBUG: this.colorSet.Blue,\n            INFO: this.colorSet.Green,\n            WARN: this.colorSet.Yellow,\n            ERROR: this.colorSet.Red,\n            DEFAULT: this.colorSet.Black,\n        };\n    }\n\n    public formatMessage(message: string, params: any[]) {\n        const extraParams = this.checkErrorInstance(params);\n        return format(message, ...extraParams);\n    }\n\n    public getColorAsType(type: LogType): string {\n        return this.logColors[type];\n    }\n\n    public getColorByName(name: string = 'Grey') {\n        return this.colorSet[name];\n    }\n\n    public isBrowser() {\n        return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n    }\n\n    public isNode() {\n        return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n    }\n\n    private checkErrorInstance(params: any[]) {\n        if (this.isNode()) {\n            return params;\n        }\n        // isBrowser\n        // browser에서 error message만 출력하는 이슈 해결 위해\n        return params.map(param => {\n            if (param instanceof Error) {\n                return { error: param.message, stack: param.stack };\n            } else {\n                return param;\n            }\n        });\n    }\n\n    private getColorSet() {\n        return this.isBrowser() ? BROWSER_COLORS : NODE_COLORS;\n    }\n}\n","// refer: https://github.com/lemoncloud-io/lemon-logger-lib\n// TODO: use @lemoncloud/lemon-logger-lib\nimport { LoggerHelperService } from './logger-helper.service';\n\nexport enum LogType {\n    DEBUG = 'DEBUG',\n    WARN = 'WARN',\n    INFO = 'INFO',\n    ERROR = 'ERROR',\n}\n\nexport interface LogInterface {\n    debug(message: string, ...extraParams: any[]): void;\n    warn(message: string, ...extraParams: any[]): void;\n    info(message: string, ...extraParams: any[]): void;\n    error(message: string, ...extraParams: any[]): void;\n}\n\nexport interface FormatInterface {\n    timestampFormat: string;\n    typeFormat: string;\n    textFormat: string;\n    namespaceFormat: string;\n}\n\nexport class LoggerService implements LogInterface {\n    private utils: LoggerHelperService;\n\n    private isNode: boolean;\n    private isBrowser: boolean;\n\n    private namespace: string;\n    private options = {\n        showTimestamp: true,\n        showLogType: true,\n    };\n\n    constructor(namespace: string = 'LEMON', options: any = {}) {\n        this.utils = new LoggerHelperService();\n        this.namespace = namespace;\n        this.options = { ...this.options, ...options };\n\n        this.isNode = this.utils.isNode();\n        this.isBrowser = this.utils.isBrowser();\n    }\n\n    log(message: string, ...extraParams: any[]) {\n        const formattedMessage = this.utils.formatMessage(message, extraParams);\n        this.writeLog(LogType.DEBUG, formattedMessage);\n        return;\n    }\n\n    debug(message: string, ...extraParams: any[]) {\n        const formattedMessage = this.utils.formatMessage(message, extraParams);\n        this.writeLog(LogType.DEBUG, formattedMessage);\n    }\n\n    warn(message: string, ...extraParams: any[]) {\n        const formattedMessage = this.utils.formatMessage(message, extraParams);\n        this.writeLog(LogType.WARN, formattedMessage);\n    }\n\n    info(message: string, ...extraParams: any[]) {\n        const formattedMessage = this.utils.formatMessage(message, extraParams);\n        this.writeLog(LogType.INFO, formattedMessage);\n    }\n\n    error(message: string, ...extraParams: any[]) {\n        const formattedMessage = this.utils.formatMessage(message, extraParams);\n        this.writeLog(LogType.ERROR, formattedMessage);\n    }\n\n    private writeLog(type: LogType, message: string) {\n        const format: FormatInterface = this.getFormat(type);\n        const formattedText = this.createLogMessage(type, message, format);\n        if (this.isNode) {\n            console.log(formattedText);\n            return;\n        }\n\n        // isBrowser\n        this.logOnBrowser(type, formattedText, format);\n        return;\n    }\n\n    private createLogMessage(type: LogType, text: string, format: FormatInterface, shouldFormat: boolean = true) {\n        const typeBlank = type === LogType.INFO || type === LogType.WARN ? ' ' : '';\n        const { showTimestamp, showLogType } = this.options;\n        let { timestampFormat, typeFormat, textFormat, namespaceFormat } = format;\n\n        if (this.isBrowser && shouldFormat) {\n            timestampFormat = '%c';\n            typeFormat = '%c';\n            namespaceFormat = '%c';\n            textFormat = ': %c';\n        }\n\n        const timestampLog = showTimestamp\n            ? `${timestampFormat}${this.createTimestamp(new Date())} `\n            : `${timestampFormat}`; // format 정해줘야 browser에서 포맷 안깨짐\n        const typeLog = showLogType ? `${typeFormat}[${type}]${typeBlank} ` : `${typeFormat}`;\n        const namespaceLog = `${namespaceFormat}${this.namespace}`;\n        const textLog = `${textFormat}${text}`;\n        return `${timestampLog}${typeLog}${namespaceLog}${textLog}`;\n    }\n\n    private logOnBrowser(type: LogType, message: string, format: FormatInterface) {\n        const { timestampFormat, typeFormat, namespaceFormat, textFormat } = format;\n        if (type === LogType.ERROR) {\n            console.error(message, timestampFormat, typeFormat, namespaceFormat, textFormat);\n        } else {\n            console.log(message, timestampFormat, typeFormat, namespaceFormat, textFormat);\n        }\n    }\n\n    private getFormat(type: LogType): FormatInterface {\n        if (this.isNode) {\n            return this.getNodeFormat(type);\n        }\n        // isBrowser\n        return this.getBrowserFormat(type);\n    }\n\n    private getNodeFormat(type: LogType): FormatInterface {\n        const whiteColor = this.utils.getColorByName('White');\n        const typeColor = this.utils.getColorAsType(type);\n        const greyColor = this.utils.getColorByName('Grey');\n\n        const timestampFormat = '\\u001b[3' + greyColor + 'm';\n        const typeFormat = '\\u001b[3' + typeColor + ';22m';\n        const namespaceFormat = '\\u001b[3' + whiteColor + ';1m';\n        const textFormat = '\\u001b[0m: ';\n\n        return { timestampFormat, typeFormat, textFormat, namespaceFormat };\n    }\n\n    private getBrowserFormat(type: LogType): FormatInterface {\n        const blackColor = this.utils.getColorByName('Black');\n        const typeColor = this.utils.getColorAsType(type);\n        const greyColor = this.utils.getColorByName('Grey');\n\n        const timestampFormat = 'color:' + greyColor;\n        const typeFormat = 'color:' + typeColor;\n        const namespaceFormat = 'color:' + blackColor + '; font-weight: bold';\n        const textFormat = ': ';\n\n        return { timestampFormat, typeFormat, textFormat, namespaceFormat };\n    }\n\n    //! timestamp like 2016-12-08 13:30:44 @lemon-engine\n    private createTimestamp(date: Date) {\n        const zeroOrNull = (text: number) => (text < 10 ? '0' : '');\n        const dt = date || new Date();\n        const [year, month, day, hours, minutes, seconds] = [\n            dt.getFullYear(),\n            dt.getMonth() + 1,\n            dt.getDate(),\n            dt.getHours(),\n            dt.getMinutes(),\n            dt.getSeconds(),\n        ];\n\n        const dateText = `${zeroOrNull(year)}${year}-${zeroOrNull(month)}${month}-${zeroOrNull(day)}${day}`; // yyyy-mm-dd\n        const hoursText = `${zeroOrNull(hours)}${hours}:${zeroOrNull(minutes)}${minutes}:${zeroOrNull(\n            seconds\n        )}${seconds}`; //hh:mm:ss\n        return `${dateText} ${hoursText}`;\n    }\n}\n","let dataMemory: any = {};\n\nclass MemoryStorage {\n    constructor() {}\n\n    public setItem(key: string, value: string) {\n        dataMemory[key] = value;\n        return dataMemory[key];\n    }\n\n    public getItem(key: string) {\n        return Object.prototype.hasOwnProperty.call(dataMemory, key) ? dataMemory[key] : undefined;\n    }\n\n    public removeItem(key: string) {\n        return delete dataMemory[key];\n    }\n\n    public clear() {\n        dataMemory = {};\n        return dataMemory;\n    }\n}\n\nexport class LocalStorageService {\n    private storage: any;\n\n    constructor() {\n        try {\n            this.storage = window.localStorage;\n            this.storage.setItem(`.test-value`, 1);\n            this.storage.removeItem(`.test-value`);\n        } catch (exception) {\n            this.storage = new MemoryStorage();\n        }\n    }\n\n    public setItem(key: string, value: string) {\n        this.storage.setItem(key, value);\n    }\n\n    public getItem(key: string) {\n        return this.storage.getItem(key);\n    }\n\n    public removeItem(key: string) {\n        this.storage.removeItem(key);\n    }\n}\n","import { SignaturePayload } from '../types/lemon-oauth-token.type';\nimport hmacSHA256 from 'crypto-js/hmac-sha256.js';\nimport encBase64 from 'crypto-js/enc-base64.js';\n\nexport const createAsyncDelay = (duration: number) => {\n    return new Promise<void>(resolve => setTimeout(() => resolve(), duration));\n};\n\nexport const withRetries =\n    (attempt: any, nthTry: number, delay: number) =>\n    async (...args: any[]) => {\n        let retryCount = 0;\n        do {\n            try {\n                return await attempt(...args);\n            } catch (error) {\n                const isLastAttempt = retryCount === nthTry;\n                if (isLastAttempt) {\n                    return Promise.reject(error);\n                }\n            }\n            await createAsyncDelay(delay);\n        } while (retryCount++ < nthTry);\n    };\n\nexport const hmac = (message: string, key: string) => {\n    //! INFO: lemon-account-api\n    //! algorithm: sha256, encoding: base64\n    const hash = hmacSHA256(message, key);\n    return encBase64.stringify(hash);\n};\n\nexport const calcSignature = (\n    payload: SignaturePayload,\n    current: string = new Date().toISOString(),\n    userAgent: string = navigator.userAgent\n) => {\n    const authId = payload.authId || '';\n    const accountId = payload.accountId || '';\n    const identityId = payload.identityId || '';\n    const identityToken = '';\n\n    //! build payload to sign......\n    const data = [current, accountId, identityId, identityToken, userAgent].join('&');\n    //! make signature with auth-id\n    const signature = hmac(hmac(hmac(data, authId), accountId), identityId);\n    //! returns signature..........\n    // return new Buffer(signature).toString('base64');\n    return signature;\n};\n","import * as AWS from 'aws-sdk/global.js';\n// services\nimport { AxiosService, calcSignature, Cloud, createAsyncDelay, LemonKMS, SignedHttpService } from '../helper';\nimport { LemonStorageService, Storage } from './lemon-storage.service';\n// types\nimport { AxiosRequestConfig } from 'axios';\nimport {\n    LemonCredentials,\n    LemonOAuthTokenResult,\n    LemonOptions,\n    LemonRefreshTokenResult,\n    LoggerService,\n    RequiredHttpParameters,\n    SignaturePayload,\n} from '../helper';\n\nexport class IdentityService {\n    private oauthURL: string;\n    private extraHeader: any = {};\n    private extraOptions: Omit<AxiosRequestConfig, 'headers'> = {};\n    private shouldUseXLemonIdentity: boolean = false;\n    private options: LemonOptions;\n\n    private readonly lemonStorage: LemonStorageService;\n    private readonly logger: LoggerService;\n\n    constructor(options: LemonOptions, storage?: Storage) {\n        this.logger = new LoggerService('IDS', options);\n        this.logger.log('initialize IdentityService(IDS)');\n\n        this.options = options;\n        const { project } = options;\n        this.lemonStorage = new LemonStorageService(project, storage);\n        this.setExtraData(options);\n\n        this.checkCachedToken()\n            .then(result => this.logger.log('checkCachedToken: ', result))\n            .catch(() => this.logger.log('checkCachedToken: has no token'));\n    }\n\n    setOptions(options: LemonOptions) {\n        this.options = options;\n        this.setExtraData(options);\n    }\n\n    updateStoragePrefix(projectName: string) {\n        this.lemonStorage.updatePrefix(projectName);\n    }\n\n    getSavedCredentials(): Promise<{ [key: string]: string }> {\n        return this.lemonStorage.getAllItems();\n    }\n\n    async saveKMS(kms: LemonKMS): Promise<void> {\n        const cloud = this.options.cloud;\n        if (cloud === 'aws') {\n            return await this.lemonStorage.saveKMS(kms);\n        }\n    }\n\n    async buildCredentialsByToken(token: LemonOAuthTokenResult): Promise<void> {\n        this.logger.log('buildCredentialsByToken()...');\n        // TODO: refactor below. create class\n        const cloud = this.options.cloud;\n\n        if (cloud === 'aws') {\n            this.logger.log('Using AWS platform');\n            return this.buildAWSCredentialsByToken(token, cloud);\n        }\n        if (cloud === 'azure') {\n            this.logger.log('Using Azure platform');\n            return await this.lemonStorage.saveLemonOAuthToken(token, cloud);\n        }\n    }\n\n    async buildCredentialsByStorage(): Promise<void> {\n        this.logger.log('buildCredentialsByStorage()...');\n        const credential = await this.lemonStorage.getCachedCredentialItems();\n        const isAWS = this.options.cloud === 'aws';\n        if (!isAWS) {\n            return;\n        }\n\n        const { AccessKeyId, SecretKey } = credential;\n        if (!AccessKeyId) {\n            throw new Error('.AccessKeyId (string) is required!');\n        }\n        if (!SecretKey) {\n            throw new Error('.SecretKey (string) is required!');\n        }\n        IdentityService.createAWSCredentials(credential);\n    }\n\n    async request(\n        method: string = 'GET',\n        endpoint: string,\n        path: string,\n        params: any = {},\n        bodyReq?: any\n    ): Promise<any> {\n        const isAWS = this.options.cloud === 'aws';\n        const isAzure = this.options.cloud === 'azure';\n        const identityToken = (await this.lemonStorage.getItem('identityToken')) || '';\n        let queryParams = { ...params };\n        let objParams: RequiredHttpParameters = { method, path, bodyReq };\n\n        if (isAWS) {\n            objParams = { method, path, queryParams, bodyReq };\n            if (!this.shouldUseXLemonIdentity) {\n                const options = { customHeader: this.extraHeader, customOptions: this.extraOptions };\n                const httpService = new SignedHttpService(options);\n                return httpService.request(endpoint, objParams);\n            }\n\n            // add X-Lemon-Identity\n            const identityId = (await this.lemonStorage.getItem('identityId')) || '';\n            const shouldSetXLemonIdentity = !!identityId && !!identityToken;\n            const customHeader = shouldSetXLemonIdentity\n                ? { ...this.extraHeader, 'x-lemon-identity': identityToken }\n                : { ...this.extraHeader };\n            const options = { customHeader, customOptions: this.extraOptions };\n            const httpService = new SignedHttpService(options);\n            return httpService.request(endpoint, objParams);\n        }\n\n        if (isAzure) {\n            const hostKey = (await this.lemonStorage.getItem('hostKey')) || '';\n            queryParams = { ...queryParams, code: hostKey, clientId: 'default' };\n            objParams = { ...objParams, queryParams: queryParams };\n            const accessToken = (await this.lemonStorage.getItem('accessToken')) || '';\n            const header = {\n                Authorization: `Bearer ${identityToken}`,\n                'x-lemon-identity': accessToken,\n            };\n\n            return this.executeRequest(header, endpoint, objParams);\n        }\n    }\n\n    requestWithCredentials(\n        method: string = 'GET',\n        endpoint: string,\n        path: string,\n        params: any = {},\n        body?: any\n    ): Promise<any> {\n        return this.getCredentials().then(() => this.request(method, endpoint, path, params, body));\n    }\n\n    async getCredentials(): Promise<AWS.Credentials | null> {\n        const isAWS = this.options.cloud === 'aws';\n\n        const hasCachedToken = await this.lemonStorage.hasCachedToken();\n        if (!hasCachedToken) {\n            this.logger.info('has no cached token!');\n            return new Promise(resolve => resolve(null));\n        }\n\n        const shouldRefreshToken = await this.lemonStorage.shouldRefreshToken();\n        if (shouldRefreshToken) {\n            this.logger.info('should refresh token!');\n            const refreshed = await this.refreshCachedToken();\n            if (refreshed) {\n                return await this.getCurrentCredentials();\n            }\n        }\n\n        const cachedToken = await this.lemonStorage.hasCachedToken();\n        if (!cachedToken) {\n            this.logger.info('has no cached token!');\n            return new Promise(resolve => resolve(null));\n        }\n\n        if (isAWS) {\n            const credentials = AWS.config.credentials as AWS.Credentials;\n            const shouldRefresh = credentials.needsRefresh();\n            if (shouldRefresh) {\n                return credentials.refreshPromise().then(() => this.getCurrentCredentials());\n            }\n        }\n        return null;\n    }\n\n    async isAuthenticated(): Promise<boolean> {\n        const isAWS = !!(await this.lemonStorage.getItem(`accessKeyId`));\n\n        const hasCachedToken = await this.lemonStorage.hasCachedToken();\n        if (!hasCachedToken) {\n            return false;\n        }\n\n        const shouldRefreshToken = await this.lemonStorage.shouldRefreshToken();\n        if (shouldRefreshToken) {\n            this.logger.info('return isAuthenticated after refresh token');\n            const refreshed = await this.refreshCachedToken();\n            if (refreshed) {\n                return true;\n            }\n        }\n\n        const cachedToken = await this.lemonStorage.hasCachedToken();\n        if (!cachedToken) {\n            return false;\n        }\n\n        if (isAWS) {\n            return new Promise(resolve => {\n                (<AWS.Credentials>AWS.config.credentials).get(error => {\n                    if (error) {\n                        this.logger.error('get AWSConfig.credentials error: ', error);\n                    }\n                    const isAuthenticated = !error;\n                    resolve(isAuthenticated);\n                });\n            });\n        }\n\n        // Note: Temporary solution that implies use of Azure platform since 'accessKeyId' property\n        //       is AWS specific and library currently support AWS and Azure only.\n        if (!isAWS) {\n            return new Promise(resolve => {\n                const isAuthenticated = true;\n                resolve(isAuthenticated);\n            });\n        }\n    }\n\n    logout(): Promise<boolean> {\n        AWS.config.credentials = null;\n        return this.lemonStorage\n            .clearLemonOAuthToken()\n            .then(() => true)\n            .catch(() => false);\n    }\n\n    private setExtraData(options: LemonOptions) {\n        const { oAuthEndpoint, extraHeader, extraOptions } = options;\n        this.oauthURL = oAuthEndpoint;\n        this.extraHeader = extraHeader ? extraHeader : {};\n        this.extraOptions = extraOptions ? extraOptions : {};\n        this.shouldUseXLemonIdentity = options.shouldUseXLemonIdentity || false;\n    }\n\n    private async checkCachedToken(): Promise<string> {\n        this.logger.log('checkCachedToken()...');\n        const hasCachedToken = await this.lemonStorage.hasCachedToken();\n        if (!hasCachedToken) {\n            throw Error('has no token!');\n        }\n\n        const shouldRefreshToken = await this.lemonStorage.shouldRefreshToken();\n        if (shouldRefreshToken) {\n            this.logger.info('should refresh token!');\n            const refreshed = await this.refreshCachedToken();\n            if (refreshed) {\n                await this.getCurrentCredentials();\n                return 'refresh token!';\n            }\n        }\n\n        const cachedToken = await this.lemonStorage.hasCachedToken();\n        if (!cachedToken) {\n            throw Error('has no token!');\n        }\n\n        // build AWS credential without refresh\n        const credential = await this.lemonStorage.getCachedCredentialItems();\n        IdentityService.createAWSCredentials(credential);\n        return 'build credentials!';\n    }\n\n    async refreshCachedToken(): Promise<LemonRefreshTokenResult | null> {\n        this.logger.log('refreshCachedToken()...');\n        const cloud = this.options.cloud;\n        const originToken: LemonOAuthTokenResult = await this.lemonStorage.getCachedLemonOAuthToken(cloud);\n        const payload: SignaturePayload = {\n            authId: originToken.authId,\n            accountId: originToken.accountId,\n            identityId: originToken.identityId,\n            identityToken: originToken.identityToken,\n        };\n        const current = new Date().toISOString();\n        const signature = calcSignature(payload, current);\n\n        //! lemon-accounts-api\n        //! $ http POST :8086/oauth/auth001/refresh 'current=2020-02-03T08:02:37.468Z' 'signature='\n        //! INFO: requestWithCredentials()의 경우, 내부에서 getCredential() 호출하기 때문에 recursive 발생함\n        this.logger.log('request refresh to OAUTH API');\n        const bodyData = { authId: originToken.authId, current, signature };\n        const refreshResult: LemonRefreshTokenResult = await this.requestRefreshWithRetries(bodyData).catch(\n            async err => {\n                if (err === 'logout') {\n                    if (window) {\n                        const event = new CustomEvent('LOGOUT_FROM_LIB', { detail: { authId: originToken.authId } });\n                        window.dispatchEvent(event);\n                    }\n                    this.logger.error('refresh token error:', err);\n                    this.logger.log('clear Storage...');\n                    await this.logout();\n                }\n                return null;\n            }\n        );\n        if (!refreshResult) {\n            return null;\n        }\n\n        const { credential } = refreshResult;\n        let refreshToken: LemonOAuthTokenResult = {\n            ...refreshResult,\n            identityToken: originToken.identityToken,\n        };\n        await this.lemonStorage.saveLemonOAuthToken(refreshToken, cloud);\n\n        if (cloud === 'aws') {\n            this.logger.log('create new credentials after refresh token');\n            refreshToken = {\n                ...refreshResult,\n                identityPoolId: originToken.identityPoolId || '',\n                identityToken: originToken.identityToken,\n            };\n            IdentityService.createAWSCredentials(credential);\n        }\n\n        return refreshResult;\n    }\n\n    private static createAWSCredentials(credential: LemonCredentials) {\n        const { AccessKeyId, SecretKey, SessionToken } = credential;\n        AWS.config.credentials = new AWS.Credentials(AccessKeyId, SecretKey, SessionToken);\n    }\n\n    private getCurrentCredentials(): Promise<AWS.Credentials> {\n        return new Promise((resolve, reject) => {\n            const credentials = AWS.config.credentials as AWS.Credentials;\n\n            credentials?.get(error => {\n                if (error) {\n                    this.logger.error('Error on getCurrentCredentials: ', error);\n                    reject(null);\n                }\n                this.logger.info('success to get AWS credentials');\n                const awsCredentials = AWS.config.credentials as AWS.Credentials;\n                resolve(awsCredentials);\n            });\n        });\n    }\n\n    private async requestRefreshWithRetries(data: { authId: string; current: string; signature: string }) {\n        const { authId, current, signature } = data;\n        let retryCount = 0;\n        const nthTry = 10;\n        do {\n            try {\n                return await this.request(\n                    'POST',\n                    this.oauthURL,\n                    `/oauth/${authId}/refresh`,\n                    {},\n                    { current, signature }\n                );\n            } catch (error) {\n                const is400Error =\n                    error.status === 400 ||\n                    error.status === '400' ||\n                    error.response?.status === 400 ||\n                    error.response?.status === '400';\n                if (is400Error) {\n                    return Promise.reject('logout');\n                }\n                const isLastAttempt = retryCount === nthTry;\n                if (isLastAttempt) {\n                    return Promise.reject(error);\n                }\n            }\n            await createAsyncDelay(500);\n        } while (retryCount++ < nthTry);\n    }\n\n    // TODO: abstract this\n    private executeRequest(header: any, endpoint: string, objParams: RequiredHttpParameters) {\n        // execute http request.\n        const { method, path, queryParams, bodyReq } = objParams;\n        const headers = header;\n        const axiosService = new AxiosService({ headers });\n        switch (method.toUpperCase()) {\n            case 'POST':\n                return axiosService.post(endpoint + path, bodyReq, queryParams);\n            case 'PUT':\n                return axiosService.put(endpoint + path, bodyReq, queryParams);\n            case 'DELETE':\n                return axiosService.delete(endpoint + path, queryParams);\n            case 'PATCH':\n                return axiosService.patch(endpoint + path, bodyReq, queryParams);\n            case 'GET':\n            default:\n                return axiosService.get(endpoint + path, queryParams);\n        }\n    }\n\n    private async buildAWSCredentialsByToken(token: LemonOAuthTokenResult, cloud: Cloud): Promise<void> {\n        const { credential } = token;\n        const { AccessKeyId, SecretKey } = credential;\n        if (!AccessKeyId) {\n            throw new Error('.AccessKeyId (string) is required!');\n        }\n        if (!SecretKey) {\n            throw new Error('.SecretKey (string) is required!');\n        }\n        this.logger.log('Using AWS platform');\n        await this.lemonStorage.saveLemonOAuthToken(token, cloud);\n        return IdentityService.createAWSCredentials(credential);\n    }\n}\n","import { Cloud, LemonCredentials, LemonKMS, LemonOAuthTokenResult, LocalStorageService } from '../helper';\n\nexport interface Storage {\n    getItem(key: string, ...params: any): any;\n    setItem(key: string, value: string, ...params: any): any;\n    removeItem(key: string, ...params: any): any;\n}\n\nexport class LemonStorageService {\n    private credentialItemList = [\n        'accountId',\n        'authId',\n        'identityId',\n        'identityPoolId',\n        'identityToken',\n        'accessKeyId',\n        'secretKey',\n        'sessionToken',\n        'expiredTime',\n        'hostKey',\n    ];\n    private prefix: string;\n    private storageService: Storage;\n\n    constructor(\n        private project: string = 'lemon',\n        private storage: Storage = new LocalStorageService()\n    ) {\n        this.prefix = `@${project}`;\n        this.storageService = storage;\n    }\n\n    updatePrefix(prefix: string) {\n        this.prefix = `@${prefix}`;\n    }\n\n    async setItem(key: string, value: string) {\n        return await this.storageService.setItem(`${this.prefix}.${key}`, value);\n    }\n\n    async getItem(key: string) {\n        return await this.storageService.getItem(`${this.prefix}.${key}`);\n    }\n\n    async getAllItems() {\n        return await this.credentialItemList.reduce(async (promise, item) => {\n            const tmpResult: { [key: string]: string } = await promise.then();\n            tmpResult[`${this.prefix}.${item}`] = await this.storageService.getItem(`${this.prefix}.${item}`);\n            return Promise.resolve(tmpResult);\n        }, Promise.resolve({}));\n    }\n\n    async hasCachedToken(): Promise<boolean> {\n        const expiredTime = await this.storageService.getItem(`${this.prefix}.expiredTime`);\n\n        // AWS\n        const accessKeyId = await this.storageService.getItem(`${this.prefix}.accessKeyId`);\n        const secretKey = await this.storageService.getItem(`${this.prefix}.secretKey`);\n\n        // Azure\n        const identityToken = await this.storageService.getItem(`${this.prefix}.identityToken`);\n        const accessToken = await this.storageService.getItem(`${this.prefix}.accessToken`);\n        const hostKey = await this.storageService.getItem(`${this.prefix}.hostKey`);\n\n        const hasAwsToken = accessKeyId !== null && secretKey !== null && expiredTime !== null;\n        const hasAzureToken =\n            identityToken !== null && accessToken !== null && hostKey !== null && expiredTime !== null;\n        return hasAwsToken || hasAzureToken;\n    }\n\n    async shouldRefreshToken(): Promise<boolean> {\n        const expiredTime = +(await this.storageService.getItem(`${this.prefix}.expiredTime`));\n        const now = new Date().getTime();\n        return now >= expiredTime;\n    }\n\n    async getCachedCredentialItems(): Promise<LemonCredentials> {\n        const AccessKeyId = await this.storageService.getItem(`${this.prefix}.accessKeyId`);\n        const SecretKey = await this.storageService.getItem(`${this.prefix}.secretKey`);\n        const SessionToken = await this.storageService.getItem(`${this.prefix}.sessionToken`);\n        return { AccessKeyId, SecretKey, SessionToken } as LemonCredentials;\n    }\n\n    async getCachedLemonOAuthToken(cloud: Cloud): Promise<LemonOAuthTokenResult> {\n        const result: any = await this.credentialItemList.reduce(async (promise, item) => {\n            const tmpResult: { [key: string]: string } = await promise.then();\n            tmpResult[item] = await this.storageService.getItem(`${this.prefix}.${item}`);\n            return Promise.resolve(tmpResult);\n        }, Promise.resolve({}));\n\n        if (cloud === 'aws') {\n            const AccessKeyId = await this.storageService.getItem(`${this.prefix}.accessKeyId`);\n            const SecretKey = await this.storageService.getItem(`${this.prefix}.secretKey`);\n            const SessionToken = await this.storageService.getItem(`${this.prefix}.sessionToken`);\n            result.credential = { AccessKeyId, SecretKey, SessionToken };\n\n            delete result.accessKeyId;\n            delete result.secretKey;\n            delete result.sessionToken;\n            delete result.expiredTime;\n        }\n\n        if (cloud === 'azure') {\n            const HostKey = await this.storageService.getItem(`${this.prefix}.hostKey`);\n            result.credential = { HostKey };\n\n            delete result.hostKey;\n            delete result.expiredTime;\n        }\n\n        return result;\n    }\n\n    /**\n     * Required Azure keys: accountId, identityToken\n     * @param token\n     * @returns\n     */\n    async saveLemonOAuthToken(token: LemonOAuthTokenResult, cloud: Cloud): Promise<void> {\n        const { accountId, authId, credential, identityId, identityPoolId, identityToken, accessToken } = token;\n        const { AccessKeyId, SecretKey, SessionToken, hostKey } = credential;\n\n        // save items...\n        this.storageService.setItem(`${this.prefix}.accountId`, accountId || '');\n        this.storageService.setItem(`${this.prefix}.authId`, authId || '');\n        this.storageService.setItem(`${this.prefix}.identityId`, identityId || '');\n        this.storageService.setItem(`${this.prefix}.identityToken`, identityToken || '');\n\n        if (cloud === 'aws') {\n            this.storageService.setItem(`${this.prefix}.identityPoolId`, identityPoolId || '');\n            this.storageService.setItem(`${this.prefix}.accessKeyId`, AccessKeyId || '');\n            this.storageService.setItem(`${this.prefix}.secretKey`, SecretKey || '');\n            this.storageService.setItem(`${this.prefix}.sessionToken`, SessionToken || '');\n        }\n\n        if (cloud === 'azure') {\n            this.storageService.setItem(`${this.prefix}.hostKey`, hostKey || '');\n            this.storageService.setItem(`${this.prefix}.accessToken`, accessToken || '');\n        }\n\n        // set expired time\n        const TIME_DELAY = 0.5; // 0.5 = 30minutes, 1 = 1hour\n        const expiredTime = new Date().getTime() + TIME_DELAY * 60 * 60 * 1000; // 30 minutes\n        this.storageService.setItem(`${this.prefix}.expiredTime`, expiredTime.toString());\n\n        return;\n    }\n\n    async clearLemonOAuthToken(): Promise<void> {\n        await Promise.all(\n            this.credentialItemList.map(item => this.storageService.removeItem(`${this.prefix}.${item}`))\n        );\n        return;\n    }\n\n    async saveKMS(kms: LemonKMS): Promise<void> {\n        const kmsArn = kms.arn;\n\n        this.storageService.setItem(`${this.prefix}.kmsArn`, kmsArn || '');\n\n        return;\n    }\n}\n","import * as AWS from 'aws-sdk/global.js';\nimport { LemonKMS, LemonOAuthTokenResult, LemonOptions } from '../helper';\nimport { IdentityService } from './identity.service';\nimport { Storage } from './lemon-storage.service';\n\n/**\n * core service for authentication processing\n */\nexport class AuthService {\n    private readonly identityService: IdentityService;\n\n    constructor(options: LemonOptions, storage?: Storage) {\n        this.identityService = new IdentityService(options, storage);\n    }\n\n    /**\n     * return token information stored in local storage\n     */\n    getSavedToken(): Promise<{ [key: string]: string }> {\n        return this.identityService.getSavedCredentials();\n    }\n\n    /**\n     * set a request header or set the Axios Request Config. If you no longer use extra options, you need to reset it after the request.\n     * @param options\n     */\n    setLemonOptions(options: LemonOptions) {\n        this.identityService.setOptions(options);\n        this.identityService.updateStoragePrefix(options.project);\n    }\n\n    /**\n     * check login status with AWS Credentials\n     */\n    isAuthenticated(): Promise<boolean> {\n        return this.identityService.isAuthenticated();\n    }\n\n    /**\n     * generate AWS Credentials with token issued through LEMON-OAUTH-API\n     * @param token\n     */\n    async buildCredentialsByToken(token: LemonOAuthTokenResult): Promise<AWS.Credentials> {\n        await this.identityService.buildCredentialsByToken(token);\n        return await this.identityService.getCredentials();\n    }\n\n    /**\n     * generate AWS Credentials from data stored on Local Storage\n     */\n    async buildCredentialsByStorage(): Promise<AWS.Credentials> {\n        await this.identityService.buildCredentialsByStorage();\n        return await this.identityService.getCredentials();\n    }\n\n    /**\n     * @param kms Save kms to LocalStorage\n     */\n    async saveKMS(kms: LemonKMS): Promise<void> {\n        await this.identityService.saveKMS(kms);\n    }\n\n    /**\n     * get the current AWS Credentials and automatically renews the token when it expires. If has not, it returns null.\n     */\n    getCredentials(): Promise<AWS.Credentials | null> {\n        return this.identityService.getCredentials().catch(() => null);\n    }\n\n    /**\n     * HTTP request using Axios. If there are AWS Credentials on browser, request HTTP with AWS V4 Signing\n     * @param method\n     * @param endpoint\n     * @param path\n     * @param params\n     * @param body\n     */\n    request(method: string = 'GET', endpoint: string, path: string, params?: any, body?: any): Promise<any> {\n        return this.identityService.request(method, endpoint, path, params, body);\n    }\n\n    /**\n     * execute the request() function above after executing getCredentials() function\n     * @param method\n     * @param endpoint\n     * @param path\n     * @param params\n     * @param body\n     */\n    requestWithCredentials(\n        method: string = 'GET',\n        endpoint: string,\n        path: string,\n        params?: any,\n        body?: any\n    ): Promise<any> {\n        return this.identityService.requestWithCredentials(method, endpoint, path, params, body);\n    }\n\n    /**\n     * clear AWS Credentials and delete Local Storage data\n     */\n    logout(): Promise<boolean> {\n        return this.identityService.logout();\n    }\n}\n"]}