From fb6e0b37fa6e1b1f9447aa6bf14941ec7b28f39e Mon Sep 17 00:00:00 2001 From: Louis <46361622+louis-lemon@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:32:04 +0900 Subject: [PATCH] Feature/louis update aws (#34) * chore: temp commit * fix: fix test error on browser env * docs: update CHANGELOG.md and version --- CHANGELOG.md | 6 + package.json | 2 +- pnpm-lock.yaml | 256 ++++++++++++++++----- src/core/auth.service.ts | 8 +- src/core/identity.service.ts | 18 +- src/helper/services/signed-http.service.ts | 14 +- src/helper/services/utils.ts | 7 +- src/vendor/sig-v4.service.ts | 13 +- 8 files changed, 240 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 648754a..00e5310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @lemoncloud/lemon-front-lib +## 1.3.18 + +### Patch Changes + +- fbb192f: fix test error + ## 1.3.16 ### Patch Changes diff --git a/package.json b/package.json index cfb9b57..8041e80 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lemoncloud/lemon-front-lib", - "version": "1.3.16", + "version": "1.3.18", "description": "Web Core Library for Lemoncloud", "exports": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc063af..4e0d606 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^2.1490.0 version: 2.1492.0 axios: - specifier: ^1.6.0 - version: 1.6.1 + specifier: 0.19.0 + version: 0.19.0 crypto-js: specifier: ^4.2.0 version: 4.2.0 @@ -25,6 +25,9 @@ devDependencies: '@types/crypto-js': specifier: ^4.2.1 version: 4.2.1 + '@types/jest': + specifier: ^29.5.8 + version: 29.5.10 '@types/node': specifier: ^20.9.0 version: 20.9.0 @@ -531,6 +534,32 @@ packages: resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} dev: true + /@jest/expect-utils@29.7.0: + resolution: {integrity: sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + jest-get-type: 29.6.3 + dev: true + + /@jest/schemas@29.6.3: + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@sinclair/typebox': 0.27.8 + dev: true + + /@jest/types@29.6.3: + resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/schemas': 29.6.3 + '@types/istanbul-lib-coverage': 2.0.6 + '@types/istanbul-reports': 3.0.4 + '@types/node': 20.9.0 + '@types/yargs': 17.0.32 + chalk: 4.1.2 + dev: true + /@jridgewell/gen-mapping@0.3.3: resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} engines: {node: '>=6.0.0'} @@ -602,6 +631,10 @@ packages: fastq: 1.15.0 dev: true + /@sinclair/typebox@0.27.8: + resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + dev: true + /@types/crypto-js@4.2.1: resolution: {integrity: sha512-FSPGd9+OcSok3RsM0UZ/9fcvMOXJ1ENE/ZbLfOPlBWj7BgXtEAM8VYfTtT760GiLbQIMoVozwVuisjvsVwqYWw==} dev: true @@ -612,6 +645,29 @@ packages: ci-info: 3.9.0 dev: true + /@types/istanbul-lib-coverage@2.0.6: + resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + dev: true + + /@types/istanbul-lib-report@3.0.3: + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + dependencies: + '@types/istanbul-lib-coverage': 2.0.6 + dev: true + + /@types/istanbul-reports@3.0.4: + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + dependencies: + '@types/istanbul-lib-report': 3.0.3 + dev: true + + /@types/jest@29.5.10: + resolution: {integrity: sha512-tE4yxKEphEyxj9s4inideLHktW/x6DwesIwWZ9NN1FKf9zbJYsnhBoA9vrHA/IuIOKwPa5PcFBNV4lpMIOEzyQ==} + dependencies: + expect: 29.7.0 + pretty-format: 29.7.0 + dev: true + /@types/json-schema@7.0.15: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true @@ -638,6 +694,20 @@ packages: resolution: {integrity: sha512-+d+WYC1BxJ6yVOgUgzK8gWvp5qF8ssV5r4nsDcZWKRWcDQLQ619tvWAxJQYGgBrO1MnLJC7a5GtiYsAoQ47dJg==} dev: true + /@types/stack-utils@2.0.3: + resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + dev: true + + /@types/yargs-parser@21.0.3: + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + dev: true + + /@types/yargs@17.0.32: + resolution: {integrity: sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==} + dependencies: + '@types/yargs-parser': 21.0.3 + dev: true + /@typescript-eslint/eslint-plugin@6.10.0(@typescript-eslint/parser@6.10.0)(eslint@8.53.0)(typescript@5.2.2): resolution: {integrity: sha512-uoLj4g2OTL8rfUQVx2AFO1hp/zja1wABJq77P6IclQs6I/m9GLrm7jCdgzZkvWdDCQf1uEvoa8s8CupsgWQgVg==} engines: {node: ^16.0.0 || >=18.0.0} @@ -832,6 +902,11 @@ packages: color-convert: 2.0.1 dev: true + /ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + dev: true + /ansi-styles@6.2.1: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} engines: {node: '>=12'} @@ -899,10 +974,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /asynckit@0.4.0: - resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - dev: false - /available-typed-arrays@1.0.5: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} @@ -923,14 +994,14 @@ packages: xml2js: 0.5.0 dev: false - /axios@1.6.1: - resolution: {integrity: sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==} + /axios@0.19.0: + resolution: {integrity: sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==} + deprecated: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 dependencies: - follow-redirects: 1.15.3 - form-data: 4.0.0 - proxy-from-env: 1.1.0 + follow-redirects: 1.5.10 + is-buffer: 2.0.5 transitivePeerDependencies: - - debug + - supports-color dev: false /balanced-match@1.0.2: @@ -1130,13 +1201,6 @@ packages: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} dev: true - /combined-stream@1.0.8: - resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} - engines: {node: '>= 0.8'} - dependencies: - delayed-stream: 1.0.0 - dev: false - /commander@11.0.0: resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} engines: {node: '>=16'} @@ -1194,6 +1258,17 @@ packages: stream-transform: 2.1.3 dev: true + /debug@3.1.0: + resolution: {integrity: sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.0.0 + dev: false + /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -1246,16 +1321,16 @@ packages: object-keys: 1.1.1 dev: true - /delayed-stream@1.0.0: - resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} - engines: {node: '>=0.4.0'} - dev: false - /detect-indent@6.1.0: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} dev: true + /diff-sequences@29.6.3: + resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true + /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -1405,6 +1480,11 @@ packages: engines: {node: '>=0.8.0'} dev: true + /escape-string-regexp@2.0.0: + resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==} + engines: {node: '>=8'} + dev: true + /escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} @@ -1568,6 +1648,17 @@ packages: strip-final-newline: 3.0.0 dev: true + /expect@29.7.0: + resolution: {integrity: sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/expect-utils': 29.7.0 + jest-get-type: 29.6.3 + jest-matcher-utils: 29.7.0 + jest-message-util: 29.7.0 + jest-util: 29.7.0 + dev: true + /extendable-error@0.1.7: resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} dev: true @@ -1660,14 +1751,13 @@ packages: resolution: {integrity: sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==} dev: true - /follow-redirects@1.15.3: - resolution: {integrity: sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==} + /follow-redirects@1.5.10: + resolution: {integrity: sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==} engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true + dependencies: + debug: 3.1.0 + transitivePeerDependencies: + - supports-color dev: false /for-each@0.3.3: @@ -1675,15 +1765,6 @@ packages: dependencies: is-callable: 1.2.7 - /form-data@4.0.0: - resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} - engines: {node: '>= 6'} - dependencies: - asynckit: 0.4.0 - combined-stream: 1.0.8 - mime-types: 2.1.35 - dev: false - /fs-extra@7.0.1: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} @@ -1998,6 +2079,11 @@ packages: has-tostringtag: 1.0.0 dev: true + /is-buffer@2.0.5: + resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} + engines: {node: '>=4'} + dev: false + /is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} @@ -2152,6 +2238,58 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true + /jest-diff@29.7.0: + resolution: {integrity: sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + chalk: 4.1.2 + diff-sequences: 29.6.3 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + dev: true + + /jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dev: true + + /jest-matcher-utils@29.7.0: + resolution: {integrity: sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + chalk: 4.1.2 + jest-diff: 29.7.0 + jest-get-type: 29.6.3 + pretty-format: 29.7.0 + dev: true + + /jest-message-util@29.7.0: + resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@babel/code-frame': 7.22.13 + '@jest/types': 29.6.3 + '@types/stack-utils': 2.0.3 + chalk: 4.1.2 + graceful-fs: 4.2.11 + micromatch: 4.0.5 + pretty-format: 29.7.0 + slash: 3.0.0 + stack-utils: 2.0.6 + dev: true + + /jest-util@29.7.0: + resolution: {integrity: sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/types': 29.6.3 + '@types/node': 20.9.0 + chalk: 4.1.2 + ci-info: 3.9.0 + graceful-fs: 4.2.11 + picomatch: 2.3.1 + dev: true + /jmespath@0.16.0: resolution: {integrity: sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==} engines: {node: '>= 0.6.0'} @@ -2383,18 +2521,6 @@ packages: picomatch: 2.3.1 dev: true - /mime-db@1.52.0: - resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} - engines: {node: '>= 0.6'} - dev: false - - /mime-types@2.1.35: - resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} - engines: {node: '>= 0.6'} - dependencies: - mime-db: 1.52.0 - dev: false - /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -2430,6 +2556,10 @@ packages: engines: {node: '>= 8.0.0'} dev: true + /ms@2.0.0: + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} + dev: false + /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true @@ -2701,9 +2831,14 @@ packages: hasBin: true dev: true - /proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: false + /pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.2.0 + dev: true /pseudomap@1.0.2: resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} @@ -2733,6 +2868,10 @@ packages: engines: {node: '>=8'} dev: true + /react-is@18.2.0: + resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} + dev: true + /read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -3019,6 +3158,13 @@ packages: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} dev: true + /stack-utils@2.0.6: + resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==} + engines: {node: '>=10'} + dependencies: + escape-string-regexp: 2.0.0 + dev: true + /stream-transform@2.1.3: resolution: {integrity: sha512-9GHUiM5hMiCi6Y03jD2ARC1ettBXkQBoQAe7nJsPknnI0ow10aXjTnew8QtYQmLjzn974BnmWEAJgCY6ZP1DeQ==} dependencies: diff --git a/src/core/auth.service.ts b/src/core/auth.service.ts index 982ca63..9045ac2 100644 --- a/src/core/auth.service.ts +++ b/src/core/auth.service.ts @@ -1,4 +1,4 @@ -import { Credentials } from 'aws-sdk/global'; +import * as AWS from 'aws-sdk/global.js'; import { LemonOAuthTokenResult, LemonOptions } from '../helper'; import { IdentityService } from './identity.service'; import { Storage } from './lemon-storage.service'; @@ -40,7 +40,7 @@ export class AuthService { * generate AWS Credentials with token issued through LEMON-OAUTH-API * @param token */ - async buildCredentialsByToken(token: LemonOAuthTokenResult): Promise { + async buildCredentialsByToken(token: LemonOAuthTokenResult): Promise { await this.identityService.buildCredentialsByToken(token); return await this.identityService.getCredentials(); } @@ -48,7 +48,7 @@ export class AuthService { /** * generate AWS Credentials from data stored on Local Storage */ - async buildCredentialsByStorage(): Promise { + async buildCredentialsByStorage(): Promise { await this.identityService.buildCredentialsByStorage(); return await this.identityService.getCredentials(); } @@ -56,7 +56,7 @@ export class AuthService { /** * get the current AWS Credentials and automatically renews the token when it expires. If has not, it returns null. */ - getCredentials(): Promise { + getCredentials(): Promise { return this.identityService.getCredentials().catch(() => null); } diff --git a/src/core/identity.service.ts b/src/core/identity.service.ts index 58155a3..6c7e4a9 100644 --- a/src/core/identity.service.ts +++ b/src/core/identity.service.ts @@ -1,4 +1,4 @@ -import { config as AWSConfig, Credentials } from 'aws-sdk/global'; +import * as AWS from 'aws-sdk/global.js'; // services import { LemonStorageService, Storage } from './lemon-storage.service'; import { calcSignature, createAsyncDelay, SignedHttpService } from '../helper'; @@ -115,7 +115,7 @@ export class IdentityService { return this.getCredentials().then(() => this.request(method, endpoint, path, params, body)); } - async getCredentials(): Promise { + async getCredentials(): Promise { const hasCachedToken = await this.lemonStorage.hasCachedToken(); if (!hasCachedToken) { this.logger.info('has no cached token!'); @@ -137,7 +137,7 @@ export class IdentityService { return new Promise(resolve => resolve(null)); } - const credentials = AWSConfig.credentials as Credentials; + const credentials = AWS.config.credentials as AWS.Credentials; const shouldRefresh = credentials.needsRefresh(); if (shouldRefresh) { return credentials.refreshPromise().then(() => this.getCurrentCredentials()); @@ -166,7 +166,7 @@ export class IdentityService { } return new Promise(resolve => { - (AWSConfig.credentials).get(error => { + (AWS.config.credentials).get(error => { if (error) { this.logger.error('get AWSConfig.credentials error: ', error); } @@ -177,7 +177,7 @@ export class IdentityService { } logout(): Promise { - AWSConfig.credentials = null; + AWS.config.credentials = null; return this.lemonStorage .clearLemonOAuthToken() .then(() => true) @@ -269,19 +269,19 @@ export class IdentityService { private static createAWSCredentials(credential: LemonCredentials) { const { AccessKeyId, SecretKey, SessionToken } = credential; - AWSConfig.credentials = new Credentials(AccessKeyId, SecretKey, SessionToken); + AWS.config.credentials = new AWS.Credentials(AccessKeyId, SecretKey, SessionToken); } - private getCurrentCredentials(): Promise { + private getCurrentCredentials(): Promise { return new Promise((resolve, reject) => { - const credentials = AWSConfig.credentials as Credentials; + const credentials = AWS.config.credentials as AWS.Credentials; credentials.get(error => { if (error) { this.logger.error('Error on getCurrentCredentials: ', error); reject(null); } this.logger.info('success to get AWS credentials'); - const awsCredentials = AWSConfig.credentials as Credentials; + const awsCredentials = AWS.config.credentials as AWS.Credentials; resolve(awsCredentials); }); }); diff --git a/src/helper/services/signed-http.service.ts b/src/helper/services/signed-http.service.ts index c4b9b74..f3ddbe7 100644 --- a/src/helper/services/signed-http.service.ts +++ b/src/helper/services/signed-http.service.ts @@ -1,4 +1,4 @@ -import { config as AWSConfig, Credentials } from 'aws-sdk/global'; +import * as AWS from 'aws-sdk/global.js'; import { AxiosService } from './axios.service'; import { LoggerService } from './logger.service'; import { sigV4Client } from '../../vendor'; @@ -16,12 +16,12 @@ export interface SignedHttpOptions { } export class SignedHttpService { - private providerCredential: Credentials; + private providerCredential: AWS.Credentials; private customHeader: any; private customOptions: any; private logger: LoggerService; - constructor(options: SignedHttpOptions = {}, credentials?: Credentials) { + constructor(options: SignedHttpOptions = {}, credentials?: AWS.Credentials) { const { customHeader, customOptions } = options; this.customHeader = customHeader ? { 'Content-Type': 'application/json', ...customHeader } @@ -53,13 +53,13 @@ export class SignedHttpService { return new Promise(resolve => { // prepare client - const ok = AWSConfig && AWSConfig.credentials; + const ok = AWS.config && AWS.config.credentials; let signedClient = ok && sigV4Client.newClient({ - accessKey: AWSConfig.credentials.accessKeyId, - secretKey: AWSConfig.credentials.secretAccessKey, - sessionToken: AWSConfig.credentials.sessionToken, + accessKey: AWS.config.credentials.accessKeyId, + secretKey: AWS.config.credentials.secretAccessKey, + sessionToken: AWS.config.credentials.sessionToken, region: 'ap-northeast-2', endpoint: endpoint, host: this.extractHostname(endpoint), diff --git a/src/helper/services/utils.ts b/src/helper/services/utils.ts index 9da58d8..e88c504 100644 --- a/src/helper/services/utils.ts +++ b/src/helper/services/utils.ts @@ -1,5 +1,6 @@ -import * as CryptoJS from 'crypto-js'; import { SignaturePayload } from '../types/lemon-oauth-token.type'; +import hmacSHA256 from 'crypto-js/hmac-sha256.js'; +import encBase64 from 'crypto-js/enc-base64.js'; export const createAsyncDelay = (duration: number) => { return new Promise(resolve => setTimeout(() => resolve(), duration)); @@ -25,8 +26,8 @@ export const withRetries = export const hmac = (message: string, key: string) => { //! INFO: lemon-account-api //! algorithm: sha256, encoding: base64 - const hash = CryptoJS.HmacSHA256(message, key); - return CryptoJS.enc.Base64.stringify(hash); + const hash = hmacSHA256(message, key); + return encBase64.stringify(hash); }; export const calcSignature = ( diff --git a/src/vendor/sig-v4.service.ts b/src/vendor/sig-v4.service.ts index 9179464..6703d69 100644 --- a/src/vendor/sig-v4.service.ts +++ b/src/vendor/sig-v4.service.ts @@ -14,11 +14,14 @@ * permissions and limitations under the License. */ -import * as CryptoJS from 'crypto-js'; - -const SHA256 = CryptoJS.SHA256; -const encHex = CryptoJS.enc.Hex; -const HmacSHA256 = CryptoJS.HmacSHA256; +// import * as CryptoJS from 'crypto-js'; +import sha256 from 'crypto-js/sha256.js'; +import hmacSHA256 from 'crypto-js/hmac-sha256.js'; +import Hex from 'crypto-js/enc-hex.js'; + +const SHA256 = sha256; +const encHex = Hex; +const HmacSHA256 = hmacSHA256; const sigV4Client: { [key: string]: any } = {};