From 6d56f9a7794ccb5117a91e33f67b022a5444c31f Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Tue, 8 Feb 2022 15:29:12 -0600 Subject: [PATCH 1/3] Making opaque parameter optional as per https://github.com/rearn/axios-digest/issues/22 --- index.ts | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index efc9639..d2b9216 100644 --- a/index.ts +++ b/index.ts @@ -105,7 +105,7 @@ export default class AxiosDigest { }); return t; }); - const calams = ['realm', 'nonce', 'qop', 'opaque']; + const calams = ['realm', 'nonce', 'qop']; const paramsCalamsOk = paramsMapArray.map((v) => { if (!('algorithm' in v)) { // eslint-disable-next-line no-param-reassign diff --git a/package.json b/package.json index 3bd6681..9eb783c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "axios-digest", - "version": "0.3.0", + "version": "0.3.1", "description": "", "main": "index.js", "scripts": { From a1e88183766dc2141106403fbcb688a0c791391a Mon Sep 17 00:00:00 2001 From: Andrew Bird Date: Fri, 25 Feb 2022 11:22:56 -0600 Subject: [PATCH 2/3] Improved error handling for when axios doesn't get a response --- index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index d2b9216..40c6dd4 100644 --- a/index.ts +++ b/index.ts @@ -78,9 +78,11 @@ export default class AxiosDigest { // eslint-disable-next-line class-methods-use-this private getWwwAuth(r: any) { - const { status } = r.response; - if (status === 401) { - return r.response.headers['www-authenticate']; + if (r.response) { + const { status } = r.response; + if (status === 401) { + return r.response.headers['www-authenticate']; + } } throw r; } From fd4dc735e10fed6159bd693f18aa9b6cecb876b2 Mon Sep 17 00:00:00 2001 From: Austin See Date: Fri, 4 Nov 2022 12:23:07 -0500 Subject: [PATCH 3/3] upgrade axios, add prettier, clean up eslint --- .eslintrc.json | 39 ++--- .prettierrc | 12 ++ README.md | 30 ++-- index.d.ts | 39 +++-- index.test.ts | 80 +++++----- index.ts | 365 +++++++++++++++++++++++----------------------- package-lock.json | 80 ++++++---- package.json | 112 +++++++------- tsconfig.json | 36 ++--- 9 files changed, 411 insertions(+), 382 deletions(-) create mode 100644 .prettierrc diff --git a/.eslintrc.json b/.eslintrc.json index d000fa8..16b6993 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,20 +1,23 @@ { - "env": { - "browser": true, - "es2020": true, - "node": true - }, - "extends": [ - "airbnb-base" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 11, - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - } + "env": { + "browser": true, + "es2020": true, + "node": true + }, + "extends": ["airbnb-base"], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 11, + "sourceType": "module" + }, + "plugins": ["@typescript-eslint"], + "rules": { + "lines-between-class-members": "off", + "no-tabs": "off", + "indent": ["error", "tab"], + "max-len": ["error", 120], + "implicit-arrow-linebreak": "off", + "function-paren-newline": "off", + "object-curly-newline": "off" + } } diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..3a12996 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "arrowParens": "always", + "bracketSameLine": true, + "bracketSpacing": true, + "endOfLine": "lf", + "printWidth": 120, + "semi": true, + "singleQuote": true, + "useTabs": true, + "tabWidth": 4, + "trailingComma": "all" +} diff --git a/README.md b/README.md index f3162db..ffac96f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # axios-digest -[![Build Status](https://travis-ci.com/rearn/axios-digest.svg?branch=master)](https://travis-ci.com/rearn/axios-digest) `axios-digest` is axios add digest auth. ## Installation -``` sh +```sh npm install --save axios-digest ``` ## Usage + See test code. (`index.test.ts`) It pretty much is a wrapper around Axios. the primary or most commonly-used HTTP methods only are available -> `POST, PUT, PATCH, GET, DELETE, HEAD`. See below for usage upfront (It was inspired from the test file). @@ -17,9 +17,9 @@ It pretty much is a wrapper around Axios. the primary or most commonly-used HTTP ### Parameters -- `username`: Not optional | `string`. -- `password`: Not optional | `string`. -- `customAxios`: Optional. An existing axios instance | `AxiosInstance|AxiosStatic`. +- `username`: Not optional | `string`. +- `password`: Not optional | `string`. +- `customAxios`: Optional. An existing axios instance | `AxiosInstance|AxiosStatic`. ```js import AxiosDigest from '.'; @@ -31,7 +31,6 @@ const base = 'http://localhost'; const axiosDigest = new AxiosDigest(username, passwd); // Go ahead and make them request! - ``` ### Fields && Methods @@ -39,10 +38,10 @@ const axiosDigest = new AxiosDigest(username, passwd); #### axiosDigest.info Interface for setting the username && password beyond the `constructor`. It does not include a custom Axios instance as in the constructor. -It receives an object and the fields `username` && `passwd` are not Optional, and returns the same, only that the value for field `passwd` is masked. +It receives an object and the fields `username` && `passwd` are not Optional, and returns the same, only that the value for field `passwd` is masked. ```js -axiosDigest.info = {username, passwd}; +axiosDigest.info = { username, passwd }; const info = axiosDigest.info; // { username: '[username]', passwd: '***' } ``` @@ -52,10 +51,9 @@ The HTTP Methods available have been previously highlighted and returns a Promis ### Similar Parameters -- `path`: Not optional | `string`. -- `data`: Optional | `any`. -- `config`: Optional | `AxiosRequestConfig`. - +- `path`: Not optional | `string`. +- `data`: Optional | `any`. +- `config`: Optional | `AxiosRequestConfig`. #### axiosDigest.head @@ -64,7 +62,7 @@ Makes a `HEAD` request. ```js axiosDigest.head(path: string, config?: AxiosRequestConfig): Promise; ``` - + #### axiosDigest.delete Makes a `DELETE` request. @@ -72,7 +70,7 @@ Makes a `DELETE` request. ```js axiosDigest.delete(path: string, config?: AxiosRequestConfig): Promise; ``` - + #### axiosDigest.get Makes a `GET` request. @@ -80,7 +78,7 @@ Makes a `GET` request. ```js axiosDigest.get(path: string, config?: AxiosRequestConfig): Promise; ``` - + #### axiosDigest.patch Makes a `PATCH` request. @@ -96,7 +94,7 @@ Makes a `PUT` request. ```js axiosDigest.put(path: string, data: any, config?: AxiosRequestConfig): Promise; ``` - + #### axiosDigest.post Makes a `POST` request. diff --git a/index.d.ts b/index.d.ts index cc4a1bd..459909a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,23 +1,22 @@ +/* eslint-disable no-unused-vars */ import { AxiosInstance, AxiosRequestConfig, AxiosStatic } from 'axios'; + export default class AxiosDigest { - private readonly axios; - private username; - private passwd; - constructor(username: string, passwd: string, customAxios?: AxiosInstance | AxiosStatic); - set info(d: { - username: string; - passwd: string; - }); - get info(): { - username: string; - passwd: string; - }; - get(path: string, config?: AxiosRequestConfig): Promise>; - post(path: string, data?: any, config?: AxiosRequestConfig): Promise>; - put(path: string, data?: any, config?: AxiosRequestConfig): Promise>; - delete(path: string, config?: AxiosRequestConfig): Promise>; - head(path: string, config?: AxiosRequestConfig): Promise>; - patch(path: string, data?: any, config?: AxiosRequestConfig): Promise>; - private getWwwAuth; - private getAuthHeader; + private readonly axios; + private username; + private passwd; + constructor(username: string, passwd: string, customAxios?: AxiosInstance | AxiosStatic); + set info(d: { username: string; passwd: string }); + get info(): { + username: string; + passwd: string; + }; + get(path: string, config?: AxiosRequestConfig): Promise>; + post(path: string, data?: any, config?: AxiosRequestConfig): Promise>; + put(path: string, data?: any, config?: AxiosRequestConfig): Promise>; + delete(path: string, config?: AxiosRequestConfig): Promise>; + head(path: string, config?: AxiosRequestConfig): Promise>; + patch(path: string, data?: any, config?: AxiosRequestConfig): Promise>; + private getWwwAuth; + private getAuthHeader; } diff --git a/index.test.ts b/index.test.ts index 4357e0e..7061af5 100644 --- a/index.test.ts +++ b/index.test.ts @@ -10,49 +10,49 @@ const base = 'http://localhost'; const axios = new AxiosDigest(username, passwd); describe('digest', () => { - const url = `/digest-auth/auth/${username}/${passwd}/`; - test('MD5', async () => { - const a = await axios.get(`${base}${url}MD5`); - expect(a.status).toBe(200); - }); - test('SHA-256', async () => { - const a = await axios.get(`${base}${url}SHA-256`); - expect(a.status).toBe(200); - }); - test('SHA-512', async () => { - const a = await axios.get(`${base}${url}SHA-512`); - expect(a.status).toBe(200); - }); + const url = `/digest-auth/auth/${username}/${passwd}/`; + test('MD5', async () => { + const a = await axios.get(`${base}${url}MD5`); + expect(a.status).toBe(200); + }); + test('SHA-256', async () => { + const a = await axios.get(`${base}${url}SHA-256`); + expect(a.status).toBe(200); + }); + test('SHA-512', async () => { + const a = await axios.get(`${base}${url}SHA-512`); + expect(a.status).toBe(200); + }); }); describe('digest-int', () => { - const url = `/digest-auth/auth-int/${username}/${passwd}/`; - test('MD5-int (not support)', () => { - expect(axios.get(`${base}${url}MD5`)).rejects.toThrow('error'); - }); - test('SHA-256-int (not support)', () => { - expect(axios.get(`${base}${url}SHA-256`)).rejects.toThrow('error'); - }); - test('SHA-512-int (not support)', () => { - expect(axios.get(`${base}${url}SHA-512`)).rejects.toThrow('error'); - }); + const url = `/digest-auth/auth-int/${username}/${passwd}/`; + test('MD5-int (not support)', () => { + expect(axios.get(`${base}${url}MD5`)).rejects.toThrow('error'); + }); + test('SHA-256-int (not support)', () => { + expect(axios.get(`${base}${url}SHA-256`)).rejects.toThrow('error'); + }); + test('SHA-512-int (not support)', () => { + expect(axios.get(`${base}${url}SHA-512`)).rejects.toThrow('error'); + }); }); describe('no auth', () => { - const url = '/status/200'; - test('GET', async () => { - const a = await axios.get(`${base}${url}`); - expect(a.status).toBe(200); - }); - test('POST', async () => { - const a = await axios.post(`${base}${url}`); - expect(a.status).toBe(200); - }); - test('PUT', async () => { - const a = await axios.put(`${base}${url}`); - expect(a.status).toBe(200); - }); - test('DELETE', async () => { - const a = await axios.delete(`${base}${url}`); - expect(a.status).toBe(200); - }); + const url = '/status/200'; + test('GET', async () => { + const a = await axios.get(`${base}${url}`); + expect(a.status).toBe(200); + }); + test('POST', async () => { + const a = await axios.post(`${base}${url}`); + expect(a.status).toBe(200); + }); + test('PUT', async () => { + const a = await axios.put(`${base}${url}`); + expect(a.status).toBe(200); + }); + test('DELETE', async () => { + const a = await axios.delete(`${base}${url}`); + expect(a.status).toBe(200); + }); }); diff --git a/index.ts b/index.ts index 40c6dd4..ecbeb8c 100644 --- a/index.ts +++ b/index.ts @@ -5,184 +5,189 @@ import { sha256 } from 'js-sha256'; import { sha512, sha512_256 as sha512256 } from 'js-sha512'; export default class AxiosDigest { - private readonly axios: AxiosInstance|AxiosStatic; - - private username: string; - - private passwd: string; - - constructor(username: string, passwd: string, customAxios?: AxiosInstance|AxiosStatic) { - this.axios = customAxios !== undefined ? customAxios : axios; - this.username = username; - this.passwd = passwd; - } - - set info(d: {username: string, passwd: string}) { - this.username = d.username; - this.passwd = d.passwd; - } - - get info() { - return { username: this.username, passwd: '***' }; - } - - public async get(path: string, config?: AxiosRequestConfig) { - try { - return await this.axios.get(path, config); - } catch (v) { - const c = this.getAuthHeader(this.getWwwAuth(v), 'GET', path, config); - return this.axios.get(path, c); - } - } - - public async post(path: string, data?: any, config?: AxiosRequestConfig) { - try { - return await this.axios.post(path, data, config); - } catch (v) { - const c = this.getAuthHeader(this.getWwwAuth(v), 'POST', path, config); - return this.axios.post(path, data, c); - } - } - - public async put(path: string, data?: any, config?: AxiosRequestConfig) { - try { - return await this.axios.put(path, data, config); - } catch (v) { - const c = this.getAuthHeader(this.getWwwAuth(v), 'PUT', path, config); - return this.axios.put(path, data, c); - } - } - - public async delete(path: string, config?: AxiosRequestConfig) { - try { - return await this.axios.delete(path, config); - } catch (v) { - const c = this.getAuthHeader(this.getWwwAuth(v), 'DELETE', path, config); - return this.axios.delete(path, c); - } - } - - public head(path: string, config?: AxiosRequestConfig) { - return this.axios.head(path, config).catch(this.getWwwAuth).then((wwwAuth) => { - const c = this.getAuthHeader(wwwAuth, 'HEAD', path, config); - return this.axios.head(path, c); - }); - } - - public patch(path: string, data?: any, config?: AxiosRequestConfig) { - return this.axios.patch(path, data, config).catch(this.getWwwAuth).then((wwwAuth) => { - const c = this.getAuthHeader(wwwAuth, 'PATCH', path, config); - return this.axios.patch(path, data, c); - }); - } - - // eslint-disable-next-line class-methods-use-this - private getWwwAuth(r: any) { - if (r.response) { - const { status } = r.response; - if (status === 401) { - return r.response.headers['www-authenticate']; - } - } - throw r; - } - - private getAuthHeader( - authHeader: string, - method: string, - url: string, - config?: AxiosRequestConfig, - ) { - const paramsString: string[] = authHeader.split(/\s*,?\s*Digest\s*/).filter((v) => v !== ''); - const paramsArray: string[][] = paramsString.map((v) => v.split(/\s*,(?=(?:[^"]*"[^"]*")*)\s*/)); - const paramsKvArray: [string, string][][] = paramsArray.map((v) => v.map((value) => { - const ret = value.split(/\s*=(?:(?=[^"]*"[^"]*")|(?!"))\s*/, 2).map((v2) => v2.replace(/^"/, '').replace(/"$/, '')); - return [ret[0], ret[1]]; - })); - const paramsMapArray: {[s: string]: string}[] = paramsKvArray.map((v) => { - const t: {[s: string]: string} = {}; - v.forEach((w) => { - // eslint-disable-next-line prefer-destructuring - t[w[0]] = w[1]; - }); - return t; - }); - const calams = ['realm', 'nonce', 'qop']; - const paramsCalamsOk = paramsMapArray.map((v) => { - if (!('algorithm' in v)) { - // eslint-disable-next-line no-param-reassign - v.algorithm = 'MD5'; - } - return v; - }).filter((v) => ['MD5', 'SHA-256', 'SHA-512-256', 'SHA-512'].findIndex((i) => i === v.algorithm) >= 0) - .filter((v) => calams.filter((value) => !(value in v)).length === 0) - .filter((v) => v.qop.split(/\s*,\s*/).filter((v2) => v2 === 'auth').length !== 0); - - if (paramsCalamsOk.length === 0) { - throw new Error('Auth params error.'); - } - paramsCalamsOk.sort((a, b) => { - const [aEval, bEval] = [a.algorithm, b.algorithm].map((v) => { - if (v === 'MD5') return 0; - if (v === 'SHA-256') return 1; - if (v === 'SHA-512-256') return 2; - return 3; - }); - return bEval - aEval; - }); - const params: {[s: string]: string} = paramsCalamsOk[0]; - const { username } = this; - const { passwd } = this; - const { - realm, - nonce, - opaque, - algorithm, - } = params; - const uri: string = url.split(/^https?:\/\/[^/]+/).filter((v) => v !== '')[0]; - const cnonce: string = Math.random().toString(36).substring(2, 10); - const nc: string = '00000001'; - const qop: string = 'auth'; - - const hashHex = ((): (str: string) => string => { - if (algorithm === 'MD5') return md5; - if (algorithm === 'SHA-256') return sha256; - if (algorithm === 'SHA-512-256') return sha512256; - return sha512; - })(); - - const hashHexArray = (data: string[]) => hashHex(data.join(':')); - const a1 = [username, realm, passwd]; - const a1hash = hashHexArray(a1); - const a2 = [method, uri]; - const a2hash = hashHexArray(a2); - const a3 = [a1hash, nonce, nc, cnonce, qop, a2hash]; - const response = hashHexArray(a3); - const dh: {[s: string]: string} = { - realm, - nonce, - uri, - username, - cnonce, - nc, - qop, - algorithm, - response, - opaque, - }; - - const auth = `Digest ${Object.keys(dh).map((v) => `${v}="${dh[v]}"`).join(', ')}`; - - if (config === undefined) { - return { headers: { Authorization: auth } }; - } - - if (config.headers === undefined) { - // eslint-disable-next-line no-param-reassign - config.headers = {}; - } - // eslint-disable-next-line no-param-reassign - config.headers.Authorization = auth; - return config; - } + private readonly axios: AxiosInstance | AxiosStatic; + + private username: string; + + private passwd: string; + + constructor(username: string, passwd: string, customAxios?: AxiosInstance | AxiosStatic) { + this.axios = customAxios !== undefined ? customAxios : axios; + this.username = username; + this.passwd = passwd; + } + + set info(d: { username: string; passwd: string }) { + this.username = d.username; + this.passwd = d.passwd; + } + + get info() { + return { username: this.username, passwd: '***' }; + } + + public async get(path: string, config?: AxiosRequestConfig) { + try { + return await this.axios.get(path, config); + } catch (v) { + const c = this.getAuthHeader(this.getWwwAuth(v), 'GET', path, config); + return this.axios.get(path, c); + } + } + + public async post(path: string, data?: any, config?: AxiosRequestConfig) { + try { + return await this.axios.post(path, data, config); + } catch (v) { + const c = this.getAuthHeader(this.getWwwAuth(v), 'POST', path, config); + return this.axios.post(path, data, c); + } + } + + public async put(path: string, data?: any, config?: AxiosRequestConfig) { + try { + return await this.axios.put(path, data, config); + } catch (v) { + const c = this.getAuthHeader(this.getWwwAuth(v), 'PUT', path, config); + return this.axios.put(path, data, c); + } + } + + public async delete(path: string, config?: AxiosRequestConfig) { + try { + return await this.axios.delete(path, config); + } catch (v) { + const c = this.getAuthHeader(this.getWwwAuth(v), 'DELETE', path, config); + return this.axios.delete(path, c); + } + } + + public head(path: string, config?: AxiosRequestConfig) { + return this.axios + .head(path, config) + .catch(this.getWwwAuth) + .then((wwwAuth) => { + const c = this.getAuthHeader(wwwAuth, 'HEAD', path, config); + return this.axios.head(path, c); + }); + } + + public patch(path: string, data?: any, config?: AxiosRequestConfig) { + return this.axios + .patch(path, data, config) + .catch(this.getWwwAuth) + .then((wwwAuth) => { + const c = this.getAuthHeader(wwwAuth, 'PATCH', path, config); + return this.axios.patch(path, data, c); + }); + } + + // eslint-disable-next-line class-methods-use-this + private getWwwAuth(r: any) { + if (r.response) { + const { status } = r.response; + if (status === 401) { + return r.response.headers['www-authenticate']; + } + } + throw r; + } + + private getAuthHeader(authHeader: string, method: string, url: string, config?: AxiosRequestConfig) { + const paramsString: string[] = authHeader.split(/\s*,?\s*Digest\s*/).filter((v) => v !== ''); + const paramsArray: string[][] = paramsString.map((v) => v.split(/\s*,(?=(?:[^"]*"[^"]*")*)\s*/)); + const paramsKvArray: [string, string][][] = paramsArray.map((v) => + v.map((value) => { + const ret = value + .split(/\s*=(?:(?=[^"]*"[^"]*")|(?!"))\s*/, 2) + .map((v2) => v2.replace(/^"/, '').replace(/"$/, '')); + return [ret[0], ret[1]]; + }), + ); + const paramsMapArray: { [s: string]: string }[] = paramsKvArray.map((v) => { + const t: { [s: string]: string } = {}; + v.forEach((w) => { + // eslint-disable-next-line prefer-destructuring + t[w[0]] = w[1]; + }); + return t; + }); + const calams = ['realm', 'nonce', 'qop']; + const paramsCalamsOk = paramsMapArray + .map((v) => { + if (!('algorithm' in v)) { + // eslint-disable-next-line no-param-reassign + v.algorithm = 'MD5'; + } + return v; + }) + .filter((v) => ['MD5', 'SHA-256', 'SHA-512-256', 'SHA-512'].findIndex((i) => i === v.algorithm) >= 0) + .filter((v) => calams.filter((value) => !(value in v)).length === 0) + .filter((v) => v.qop.split(/\s*,\s*/).filter((v2) => v2 === 'auth').length !== 0); + + if (paramsCalamsOk.length === 0) { + throw new Error('Auth params error.'); + } + paramsCalamsOk.sort((a, b) => { + const [aEval, bEval] = [a.algorithm, b.algorithm].map((v) => { + if (v === 'MD5') return 0; + if (v === 'SHA-256') return 1; + if (v === 'SHA-512-256') return 2; + return 3; + }); + return bEval - aEval; + }); + const params: { [s: string]: string } = paramsCalamsOk[0]; + const { username } = this; + const { passwd } = this; + const { realm, nonce, opaque, algorithm } = params; + const uri: string = url.split(/^https?:\/\/[^/]+/).filter((v) => v !== '')[0]; + const cnonce: string = Math.random().toString(36).substring(2, 10); + const nc: string = '00000001'; + const qop: string = 'auth'; + + // eslint-disable-next-line no-unused-vars + const hashHex = ((): ((str: string) => string) => { + if (algorithm === 'MD5') return md5; + if (algorithm === 'SHA-256') return sha256; + if (algorithm === 'SHA-512-256') return sha512256; + return sha512; + })(); + + const hashHexArray = (data: string[]) => hashHex(data.join(':')); + const a1 = [username, realm, passwd]; + const a1hash = hashHexArray(a1); + const a2 = [method, uri]; + const a2hash = hashHexArray(a2); + const a3 = [a1hash, nonce, nc, cnonce, qop, a2hash]; + const response = hashHexArray(a3); + const dh: { [s: string]: string } = { + realm, + nonce, + uri, + username, + cnonce, + nc, + qop, + algorithm, + response, + opaque, + }; + + const auth = `Digest ${Object.keys(dh) + .map((v) => `${v}="${dh[v]}"`) + .join(', ')}`; + + if (config === undefined) { + return { headers: { Authorization: auth } }; + } + + if (config.headers === undefined) { + // eslint-disable-next-line no-param-reassign + config.headers = {}; + } + // eslint-disable-next-line no-param-reassign + config.headers.Authorization = auth; + return config; + } } diff --git a/package-lock.json b/package-lock.json index 3178934..7c045a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "axios-digest", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "axios-digest", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "dependencies": { - "axios": "^0.24.0", + "axios": "^0.27.0", "js-md5": "^0.7.3", "js-sha256": "^0.9.0", "js-sha512": "^0.8.0" @@ -1797,15 +1797,29 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "node_modules/axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.0.tgz", + "integrity": "sha512-XV/WrPxXfzgZ8j4lcB5i6LyaXmi90yetmV/Fem0kmglGx+mpY06CiweL3YxU6wOTNLmqLUePW4G8h45nGZ/+pA==", + "deprecated": "Formdata complete broken, incorrect build size", "dependencies": { - "follow-redirects": "^1.14.4" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" } }, "node_modules/babel-jest": { @@ -2136,7 +2150,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -2269,7 +2282,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -3065,9 +3077,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "funding": [ { "type": "individual", @@ -4835,7 +4847,6 @@ "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", - "dev": true, "engines": { "node": ">= 0.6" } @@ -4844,7 +4855,6 @@ "version": "2.1.34", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "dev": true, "dependencies": { "mime-db": "1.51.0" }, @@ -7515,15 +7525,27 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "axios": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", - "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.0.tgz", + "integrity": "sha512-XV/WrPxXfzgZ8j4lcB5i6LyaXmi90yetmV/Fem0kmglGx+mpY06CiweL3YxU6wOTNLmqLUePW4G8h45nGZ/+pA==", "requires": { - "follow-redirects": "^1.14.4" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } } }, "babel-jest": { @@ -7784,7 +7806,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -7900,8 +7921,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "detect-newline": { "version": "3.1.0", @@ -8517,9 +8537,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.5.tgz", - "integrity": "sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA==" + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" }, "form-data": { "version": "3.0.1", @@ -9836,14 +9856,12 @@ "mime-db": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", - "dev": true + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" }, "mime-types": { "version": "2.1.34", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", - "dev": true, "requires": { "mime-db": "1.51.0" } diff --git a/package.json b/package.json index 9eb783c..74ac394 100644 --- a/package.json +++ b/package.json @@ -1,61 +1,61 @@ { - "name": "axios-digest", - "version": "0.3.1", - "description": "", - "main": "index.js", - "scripts": { - "build": "tsc", - "test": "jest", - "lint": "eslint 'index.ts'" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/rearn/axios-digest.git" - }, - "author": "minamibashi rearn (https://github.com/rearn)", - "license": "MIT", - "bugs": { - "url": "https://github.com/rearn/axios-digest/issues" - }, - "homepage": "https://github.com/rearn/axios-digest#readme", - "devDependencies": { - "@types/jest": "^27.0.3", - "@types/js-md5": "^0.4.3", - "@typescript-eslint/eslint-plugin": "^5.6.0", - "@typescript-eslint/parser": "^5.6.0", - "eslint": "^8.4.1", - "eslint-config-airbnb-base": "^15.0.0", - "eslint-plugin-import": "^2.25.3", - "jest": "^27.4.3", - "ts-jest": "^27.1.1", - "typescript": "^4.5.2" - }, - "dependencies": { - "axios": "^0.24.0", - "js-md5": "^0.7.3", - "js-sha256": "^0.9.0", - "js-sha512": "^0.8.0" - }, - "keywords": [ - "axios", - "digest" - ], - "jest": { - "moduleFileExtensions": [ - "ts", - "js" - ], - "transform": { - "^.+\\.ts$": "ts-jest" + "name": "axios-digest", + "version": "0.3.2", + "description": "", + "main": "index.js", + "scripts": { + "build": "tsc", + "test": "jest", + "lint": "eslint 'index.ts'" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rearn/axios-digest.git" + }, + "author": "minamibashi rearn (https://github.com/rearn)", + "license": "MIT", + "bugs": { + "url": "https://github.com/rearn/axios-digest/issues" + }, + "homepage": "https://github.com/rearn/axios-digest#readme", + "devDependencies": { + "@types/jest": "^27.0.3", + "@types/js-md5": "^0.4.3", + "@typescript-eslint/eslint-plugin": "^5.6.0", + "@typescript-eslint/parser": "^5.6.0", + "eslint": "^8.4.1", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-plugin-import": "^2.25.3", + "jest": "^27.4.3", + "ts-jest": "^27.1.1", + "typescript": "^4.5.2" }, - "globals": { - "ts-jest": { - "tsConfig": "tsconfig.json" - } + "dependencies": { + "axios": "^0.27.0", + "js-md5": "^0.7.3", + "js-sha256": "^0.9.0", + "js-sha512": "^0.8.0" }, - "testMatch": [ - "**/*.test.ts" + "keywords": [ + "axios", + "digest" ], - "testEnvironment": "node" - } + "jest": { + "moduleFileExtensions": [ + "ts", + "js" + ], + "transform": { + "^.+\\.ts$": "ts-jest" + }, + "globals": { + "ts-jest": { + "tsConfig": "tsconfig.json" + } + }, + "testMatch": [ + "**/*.test.ts" + ], + "testEnvironment": "node" + } } diff --git a/tsconfig.json b/tsconfig.json index f619974..9e752ae 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,23 +1,17 @@ { - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "lib": ["es6"], - "noImplicitAny": true, - "removeComments": true, - "preserveConstEnums": true, - "sourceMap": true, - "strictNullChecks": true, - "declaration": true - }, - "rules": { - "indent": [ - true, - "spaces", - 2 - ] - }, - "files": [ - "index.ts" - ] + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "removeComments": true, + "preserveConstEnums": true, + "sourceMap": true, + "strictNullChecks": true, + "declaration": true + }, + "rules": { + "indent": [true, "tabs", 4] + }, + "files": ["index.ts"] }