Add trailing commas to ESLint + Prettier

This commit is contained in:
Gregory Schier committed 2018-12-12 12:36:11 -05:00
1 parent 64a5e44528
commit 88b0bb784f
404 files changed
+2575 -2571

No files matched your search

+2 -2
View File
@@ -4,6 +4,6 @@
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"trailingComma": "all",
"printWidth": 100
}
}
+12 -5
View File
@@ -29,16 +29,23 @@
"jest/globals": true
},
"rules": {
"comma-dangle": [
"error",
"always-multiline"
],
"indent": "off",
"no-var": "error",
"no-duplicate-imports": "off",
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"filenames/match-exported": [
"error",
"kebab"
+1 -1
View File
@@ -12,7 +12,7 @@ const localStorageMock = (function() {
},
clear() {
store = {};
}
},
};
})();
@@ -14,14 +14,14 @@ const remote = {
},
getLocale() {
return 'en-US';
}
},
},
net: {
request(url) {
const req = new events.EventEmitter();
req.end = function() {};
return req;
}
},
},
BrowserWindow: {
getAllWindows() {
@@ -31,15 +31,15 @@ const remote = {
return {
getContentBounds() {
return { width: 1900, height: 1060 };
}
},
};
}
},
},
screen: {
getPrimaryDisplay() {
return { workAreaSize: { width: 1920, height: 1080 } };
}
}
},
},
};
module.exports = {
@@ -47,11 +47,11 @@ module.exports = {
remote: remote,
ipcMain: {
on() {},
once() {}
once() {},
},
ipcRenderer: {
on() {},
once() {},
send() {}
}
send() {},
},
};
@@ -81,8 +81,8 @@ class Curl extends EventEmitter {
JSON.stringify({
options: this._options,
meta: this._meta,
features: this._features
})
features: this._features,
}),
);
this.emit('data', data);
@@ -97,8 +97,8 @@ class Curl extends EventEmitter {
'HTTP/1.1 200 OK',
`Content-Length: ${data.length}`,
'Content-Type: application/json',
''
].join('\n')
'',
].join('\n'),
);
});
});
@@ -117,23 +117,23 @@ Curl.info = {
DATA_OUT: 'DATA_OUT',
SSL_DATA_IN: 'SSL_DATA_IN',
SSL_DATA_OUT: 'SSL_DATA_OUT',
TEXT: 'TEXT'
}
TEXT: 'TEXT',
},
};
Curl.auth = {
ANY: 'ANY'
ANY: 'ANY',
};
Curl.netrc = {
IGNORED: 0,
OPTIONAL: 1,
REQUIRED: 2
REQUIRED: 2,
};
Curl.feature = {
NO_HEADER_PARSING: 'NO_HEADER_PARSING',
NO_DATA_PARSING: 'NO_DATA_PARSING'
NO_DATA_PARSING: 'NO_DATA_PARSING',
};
Curl.option = {
@@ -175,9 +175,9 @@ Curl.option = {
USERNAME: 'USERNAME',
VERBOSE: 'VERBOSE',
WRITEFUNCTION: 'WRITEFUNCTION',
XFERINFOFUNCTION: 'XFERINFOFUNCTION'
XFERINFOFUNCTION: 'XFERINFOFUNCTION',
};
module.exports = {
Curl: Curl
Curl: Curl,
};
@@ -9,30 +9,30 @@ module.exports = {
jsbn: forge.jsbn,
util: forge.util,
pkcs5: {
pbkdf2() {}
pbkdf2() {},
},
md: {
sha256: {
create() {
return 'TODO';
}
}
},
},
},
rsa: {
setPublicKey() {
return {
encrypt(str) {
return str;
}
},
};
},
setPrivateKey() {
return {
decrypt(str) {
return str;
}
},
};
}
},
},
random: {
getBytesSync(n) {
@@ -41,7 +41,7 @@ module.exports = {
s += 'a';
}
return s;
}
},
},
pki: {
rsa: {
@@ -55,15 +55,15 @@ module.exports = {
n: 'a',
p: 'a',
q: 'a',
qInv: 'a'
qInv: 'a',
},
publicKey: {
e: 'a',
n: 'a'
}
n: 'a',
},
};
}
}
},
},
},
cipher: {
createCipher(alg, key) {
@@ -77,7 +77,7 @@ module.exports = {
finish() {
this.mode = { tag: 'tag' };
this.output = this._data;
}
},
};
},
createDecipher(alg, key) {
@@ -90,8 +90,8 @@ module.exports = {
},
finish() {
return true;
}
},
};
}
}
},
},
};
@@ -4,53 +4,53 @@ export const data = {
[models.workspace.type]: [
{
_id: 'wrk_1',
name: 'Wrk 1'
}
name: 'Wrk 1',
},
],
[models.requestGroup.type]: [
{
_id: 'fld_1',
parentId: 'wrk_1',
name: 'Fld 1'
name: 'Fld 1',
},
{
_id: 'fld_2',
parentId: 'wrk_1',
name: 'Fld 2'
name: 'Fld 2',
},
{
_id: 'fld_3',
parentId: 'fld_1',
name: 'Fld 3'
}
name: 'Fld 3',
},
],
[models.request.type]: [
{
_id: 'req_1',
parentId: 'fld_1',
name: 'Req 1'
name: 'Req 1',
},
{
_id: 'req_2',
parentId: 'fld_1',
name: 'Req 2'
name: 'Req 2',
},
{
_id: 'req_3',
parentId: 'wrk_1',
name: 'Req 3'
name: 'Req 3',
},
{
_id: 'req_4',
parentId: 'fld_3',
name: 'Req 4'
name: 'Req 4',
},
{
_id: 'req_5',
parentId: 'wrk_1',
name: 'Req 5'
}
]
name: 'Req 5',
},
],
};
@@ -29,7 +29,7 @@ describe('onChange()', () => {
const doc = {
type: models.request.type,
parentId: 'nothing',
name: 'foo'
name: 'foo',
};
const changesSeen = [];
@@ -44,7 +44,7 @@ describe('onChange()', () => {
expect(changesSeen).toEqual([
[[db.CHANGE_INSERT, newDoc, false]],
[[db.CHANGE_UPDATE, updatedDoc, false]]
[[db.CHANGE_UPDATE, updatedDoc, false]],
]);
db.offChange(callback);
@@ -59,7 +59,7 @@ describe('bufferChanges()', () => {
const doc = {
type: models.request.type,
parentId: 'n/a',
name: 'foo'
name: 'foo',
};
const changesSeen = [];
@@ -78,13 +78,13 @@ describe('bufferChanges()', () => {
// Assert changes seen after flush
await db.flushChanges();
expect(changesSeen).toEqual([
[[db.CHANGE_INSERT, newDoc, false], [db.CHANGE_UPDATE, updatedDoc, false]]
[[db.CHANGE_INSERT, newDoc, false], [db.CHANGE_UPDATE, updatedDoc, false]],
]);
// Assert no more changes seen after flush again
await db.flushChanges();
expect(changesSeen).toEqual([
[[db.CHANGE_INSERT, newDoc, false], [db.CHANGE_UPDATE, updatedDoc, false]]
[[db.CHANGE_INSERT, newDoc, false], [db.CHANGE_UPDATE, updatedDoc, false]],
]);
});
});
@@ -96,7 +96,7 @@ describe('requestCreate()', () => {
const patch = {
name: 'My Request',
parentId: 'wrk_123'
parentId: 'wrk_123',
};
const r = await models.request.create(patch);
@@ -167,34 +167,34 @@ describe('_fixThings()', () => {
await models.environment.create({
_id: 'b1',
parentId: 'w1',
data: { foo: 'b1', b1: true }
data: { foo: 'b1', b1: true },
});
await models.environment.create({
_id: 'b1_sub1',
parentId: 'b1',
data: { foo: '1' }
data: { foo: '1' },
});
await models.environment.create({
_id: 'b1_sub2',
parentId: 'b1',
data: { foo: '2' }
data: { foo: '2' },
});
// Create second set of sub environments
await models.environment.create({
_id: 'b2',
parentId: 'w1',
data: { foo: 'b2', b2: true }
data: { foo: 'b2', b2: true },
});
await models.environment.create({
_id: 'b2_sub1',
parentId: 'b2',
data: { foo: '3' }
data: { foo: '3' },
});
await models.environment.create({
_id: 'b2_sub2',
parentId: 'b2',
data: { foo: '4' }
data: { foo: '4' },
});
// Make sure we have everything
@@ -202,7 +202,7 @@ describe('_fixThings()', () => {
const descendants = (await db.withDescendants(workspace)).map(d => ({
_id: d._id,
parentId: d.parentId,
data: d.data || null
data: d.data || null,
}));
expect(descendants).toEqual([
{ _id: 'w1', data: null, parentId: null },
@@ -211,7 +211,7 @@ describe('_fixThings()', () => {
{ _id: 'b1_sub1', data: { foo: '1' }, parentId: 'b1' },
{ _id: 'b1_sub2', data: { foo: '2' }, parentId: 'b1' },
{ _id: 'b2_sub1', data: { foo: '3' }, parentId: 'b2' },
{ _id: 'b2_sub2', data: { foo: '4' }, parentId: 'b2' }
{ _id: 'b2_sub2', data: { foo: '4' }, parentId: 'b2' },
]);
// Run the fix algorithm
@@ -221,7 +221,7 @@ describe('_fixThings()', () => {
const descendants2 = (await db.withDescendants(workspace)).map(d => ({
_id: d._id,
parentId: d.parentId,
data: d.data || null
data: d.data || null,
}));
expect(descendants2).toEqual([
{ _id: 'w1', data: null, parentId: null },
@@ -234,7 +234,7 @@ describe('_fixThings()', () => {
{ _id: 'b1_sub1', data: { foo: '1' }, parentId: 'b1' },
{ _id: 'b1_sub2', data: { foo: '2' }, parentId: 'b1' },
{ _id: 'b2_sub1', data: { foo: '3' }, parentId: 'b1' },
{ _id: 'b2_sub2', data: { foo: '4' }, parentId: 'b1' }
{ _id: 'b2_sub2', data: { foo: '4' }, parentId: 'b1' },
]);
});
@@ -247,13 +247,13 @@ describe('_fixThings()', () => {
await models.cookieJar.create({
_id: 'j1',
parentId: 'w1',
cookies: [{ id: '1', key: 'foo', value: '1' }, { id: 'j1_1', key: 'j1', value: '1' }]
cookies: [{ id: '1', key: 'foo', value: '1' }, { id: 'j1_1', key: 'j1', value: '1' }],
});
await models.cookieJar.create({
_id: 'j2',
parentId: 'w1',
cookies: [{ id: '1', key: 'foo', value: '2' }, { id: 'j2_1', key: 'j2', value: '2' }]
cookies: [{ id: '1', key: 'foo', value: '2' }, { id: 'j2_1', key: 'j2', value: '2' }],
});
// Make sure we have everything
@@ -261,20 +261,20 @@ describe('_fixThings()', () => {
const descendants = (await db.withDescendants(workspace)).map(d => ({
_id: d._id,
cookies: d.cookies || null,
parentId: d.parentId
parentId: d.parentId,
}));
expect(descendants).toEqual([
{ _id: 'w1', cookies: null, parentId: null },
{
_id: 'j1',
parentId: 'w1',
cookies: [{ id: '1', key: 'foo', value: '1' }, { id: 'j1_1', key: 'j1', value: '1' }]
cookies: [{ id: '1', key: 'foo', value: '1' }, { id: 'j1_1', key: 'j1', value: '1' }],
},
{
_id: 'j2',
parentId: 'w1',
cookies: [{ id: '1', key: 'foo', value: '2' }, { id: 'j2_1', key: 'j2', value: '2' }]
}
cookies: [{ id: '1', key: 'foo', value: '2' }, { id: 'j2_1', key: 'j2', value: '2' }],
},
]);
// Run the fix algorithm
@@ -284,7 +284,7 @@ describe('_fixThings()', () => {
const descendants2 = (await db.withDescendants(workspace)).map(d => ({
_id: d._id,
cookies: d.cookies || null,
parentId: d.parentId
parentId: d.parentId,
}));
expect(descendants2).toEqual([
{ _id: 'w1', cookies: null, parentId: null },
@@ -294,9 +294,9 @@ describe('_fixThings()', () => {
cookies: [
{ id: '1', key: 'foo', value: '1' },
{ id: 'j1_1', key: 'j1', value: '1' },
{ id: 'j2_1', key: 'j2', value: '2' }
]
}
{ id: 'j2_1', key: 'j2', value: '2' },
],
},
]);
});
});
@@ -10,7 +10,7 @@ describe('exportHar()', () => {
it('exports single requests', async () => {
const wrk = await models.workspace.create({
_id: 'wrk_1',
name: 'Workspace'
name: 'Workspace',
});
const req1 = await models.request.create({
_id: 'req_1',
@@ -21,13 +21,13 @@ describe('exportHar()', () => {
method: 'POST',
body: {
mimeType: 'application/json',
text: '{}'
text: '{}',
},
headers: [
{ name: 'Content-Type', value: 'application/json' },
{ name: 'Accept', value: 'application/json', disabled: false },
{ name: 'X-Disabled', value: 'X-Disabled', disabled: true }
]
{ name: 'X-Disabled', value: 'X-Disabled', disabled: true },
],
});
await models.response.create({
parentId: req1._id,
@@ -38,7 +38,7 @@ describe('exportHar()', () => {
headers: [{ name: 'Content-Type', value: 'application/json' }],
contentType: 'application/json',
bodyPath: path.join(__dirname, '../__fixtures__/har/test-response.json'),
bodyCompression: null
bodyCompression: null,
});
const exportRequests = [{ requestId: req1._id, environmentId: 'n/a' }];
@@ -48,7 +48,7 @@ describe('exportHar()', () => {
log: {
version: '1.2',
creator: {
name: 'Insomnia REST Client'
name: 'Insomnia REST Client',
},
entries: [
{
@@ -61,16 +61,16 @@ describe('exportHar()', () => {
cookies: [],
headers: [
{ name: 'Content-Type', value: 'application/json' },
{ name: 'Accept', value: 'application/json' }
{ name: 'Accept', value: 'application/json' },
],
queryString: [],
postData: {
mimeType: 'application/json',
params: [],
text: '{}'
text: '{}',
},
headersSize: -1,
bodySize: -1
bodySize: -1,
},
response: {
status: 200,
@@ -81,11 +81,11 @@ describe('exportHar()', () => {
content: {
size: 15,
mimeType: 'application/json',
text: '{"key":"value"}'
text: '{"key":"value"}',
},
redirectURL: '',
headersSize: -1,
bodySize: -1
bodySize: -1,
},
cache: {},
timings: {
@@ -95,19 +95,19 @@ describe('exportHar()', () => {
send: 0,
wait: 999,
receive: 0,
ssl: -1
ssl: -1,
},
comment: req1.name
}
]
}
comment: req1.name,
},
],
},
});
});
it('exports multiple requests', async () => {
const workspace = await models.workspace.create({
_id: 'wrk_1',
name: 'Workspace'
name: 'Workspace',
});
const baseReq = await models.request.create({
@@ -119,7 +119,7 @@ describe('exportHar()', () => {
url: 'http://localhost',
method: 'GET',
body: {},
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }]
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }],
});
const req1 = await models.request.duplicate(baseReq);
req1._id = 'req_1';
@@ -140,51 +140,51 @@ describe('exportHar()', () => {
await models.response.create({
_id: 'res_1',
parentId: req1._id,
statusCode: 204
statusCode: 204,
});
await models.response.create({
_id: 'res_2',
parentId: req2._id,
statusCode: 404
statusCode: 404,
});
await models.response.create({
_id: 'res_3',
parentId: req3._id,
statusCode: 500
statusCode: 500,
});
const envBase = await models.environment.getOrCreateForWorkspace(workspace);
await models.environment.update(envBase, {
data: {
envvalue: ''
}
envvalue: '',
},
});
const envPublic = await models.environment.create({
_id: 'env_1',
name: 'Public',
parentId: envBase._id
parentId: envBase._id,
});
await models.environment.update(envPublic, {
data: {
envvalue: 'public'
}
envvalue: 'public',
},
});
const envPrivate = await models.environment.create({
_id: 'env_2',
name: 'Private',
isPrivate: true,
parentId: envBase._id
parentId: envBase._id,
});
await models.environment.update(envPrivate, {
data: {
envvalue: 'private'
}
envvalue: 'private',
},
});
const exportRequests = [
{ requestId: req1._id, environmentId: 'n/a' },
{ requestId: req2._id, environmentId: envPublic._id },
{ requestId: req3._id, environmentId: envPrivate._id }
{ requestId: req3._id, environmentId: envPrivate._id },
];
const harExport = await harUtils.exportHar(exportRequests);
@@ -192,44 +192,44 @@ describe('exportHar()', () => {
log: {
version: '1.2',
creator: {
name: 'Insomnia REST Client'
name: 'Insomnia REST Client',
},
entries: [
{
request: {
headers: [{ name: 'X-Environment', value: '' }, { name: 'X-Request', value: '1' }]
headers: [{ name: 'X-Environment', value: '' }, { name: 'X-Request', value: '1' }],
},
response: {
status: 204
status: 204,
},
comment: req1.name
comment: req1.name,
},
{
request: {
headers: [
{ name: 'X-Environment', value: 'public' },
{ name: 'X-Request', value: '2' }
]
{ name: 'X-Request', value: '2' },
],
},
response: {
status: 404
status: 404,
},
comment: req2.name
comment: req2.name,
},
{
request: {
headers: [
{ name: 'X-Environment', value: 'private' },
{ name: 'X-Request', value: '3' }
]
{ name: 'X-Request', value: '3' },
],
},
response: {
status: 500
status: 500,
},
comment: req3.name
}
]
}
comment: req3.name,
},
],
},
});
});
});
@@ -247,8 +247,8 @@ describe('exportHarResponse()', () => {
httpVersion: 'HTTP/1.1',
content: {
size: 0,
mimeType: ''
}
mimeType: '',
},
});
});
it('exports a valid har response for a non empty response', async () => {
@@ -264,10 +264,10 @@ describe('exportHarResponse()', () => {
headers: [
{ name: 'Content-Type', value: 'application/json' },
{ name: 'Content-Length', value: '2' },
{ name: 'Set-Cookie', value: 'sessionid=12345; HttpOnly; Path=/' }
{ name: 'Set-Cookie', value: 'sessionid=12345; HttpOnly; Path=/' },
],
contentType: 'application/json',
bodyPath: path.join(__dirname, '../__fixtures__/har/test-response.json')
bodyPath: path.join(__dirname, '../__fixtures__/har/test-response.json'),
});
const harResponse = await harUtils.exportHarResponse(response);
@@ -281,22 +281,22 @@ describe('exportHarResponse()', () => {
name: 'sessionid',
value: '12345',
path: '/',
httpOnly: true
}
httpOnly: true,
},
],
headers: [
{ name: 'Content-Type', value: 'application/json' },
{ name: 'Content-Length', value: '2' },
{ name: 'Set-Cookie', value: 'sessionid=12345; HttpOnly; Path=/' }
{ name: 'Set-Cookie', value: 'sessionid=12345; HttpOnly; Path=/' },
],
content: {
size: 15,
mimeType: 'application/json',
text: '{"key":"value"}'
text: '{"key":"value"}',
},
redirectURL: '',
headersSize: -1,
bodySize: -1
bodySize: -1,
});
});
});
@@ -314,14 +314,14 @@ describe('exportHarWithRequest()', () => {
domain: 'google.com',
path: '/',
hostOnly: true,
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
}
lastAccessed: new Date('2096-10-05T04:40:49.505Z'),
},
];
const cookieJar = await models.cookieJar.getOrCreateForParentId(workspace._id);
await models.cookieJar.update(cookieJar, {
parentId: workspace._id,
cookies
cookies,
});
const request = Object.assign(models.request.init(), {
@@ -331,14 +331,14 @@ describe('exportHarWithRequest()', () => {
parameters: [{ name: 'foo bar', value: 'hello&world' }],
method: 'POST',
body: {
text: 'foo bar'
text: 'foo bar',
},
url: 'http://google.com',
authentication: {
type: AUTH_BASIC,
username: 'user',
password: 'pass'
}
password: 'pass',
},
});
const renderedRequest = await render.getRenderedRequest(request);
@@ -353,12 +353,12 @@ describe('exportHarWithRequest()', () => {
expires: '2096-10-12T04:40:49.000Z',
name: 'foo',
path: '/',
value: 'barrrrr'
}
value: 'barrrrr',
},
],
headers: [
{ name: 'Content-Type', value: 'application/json' },
{ name: 'Authorization', value: 'Basic dXNlcjpwYXNz' }
{ name: 'Authorization', value: 'Basic dXNlcjpwYXNz' },
],
headersSize: -1,
httpVersion: 'HTTP/1.1',
@@ -366,11 +366,11 @@ describe('exportHarWithRequest()', () => {
postData: {
mimeType: '',
params: [],
text: 'foo bar'
text: 'foo bar',
},
queryString: [{ name: 'foo bar', value: 'hello&world' }],
url: 'http://google.com/',
settingEncodeUrl: true
settingEncodeUrl: true,
});
});
});
@@ -8,47 +8,47 @@ describe('exportHAR()', () => {
it('exports a single workspace as an HTTP Archive', async () => {
const wrk1 = await models.workspace.create({
_id: 'wrk_1',
name: 'Workspace 1'
name: 'Workspace 1',
});
const req1 = await models.request.create({
_id: 'req_1',
name: 'Request 1',
parentId: wrk1._id,
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }],
metaSortKey: 0
metaSortKey: 0,
});
const req2 = await models.request.create({
_id: 'req_2',
name: 'Request 2',
parentId: wrk1._id,
metaSortKey: 1
metaSortKey: 1,
});
let env1Base = await models.environment.getOrCreateForWorkspace(wrk1);
env1Base = await models.environment.update(env1Base, {
data: {
envvalue: 'base1'
}
envvalue: 'base1',
},
});
const env1Private = await models.environment.create({
name: 'Private',
parentId: env1Base._id,
data: {
envvalue: 'private1'
}
envvalue: 'private1',
},
});
await models.workspaceMeta.create({
parentId: wrk1._id,
activeEnvironmentId: env1Private._id
activeEnvironmentId: env1Private._id,
});
const wrk2 = await models.workspace.create({
_id: 'wrk_2',
name: 'Workspace 2'
name: 'Workspace 2',
});
await models.request.create({
_id: 'req_3',
name: 'Request 3',
parentId: wrk2._id
parentId: wrk2._id,
});
const includePrivateDocs = true;
@@ -60,75 +60,75 @@ describe('exportHAR()', () => {
entries: [
{
request: {
headers: [{ name: 'X-Environment', value: 'private1' }]
headers: [{ name: 'X-Environment', value: 'private1' }],
},
comment: req1.name
comment: req1.name,
},
{
comment: req2.name
}
]
}
comment: req2.name,
},
],
},
});
expect(data.log.entries.length).toBe(2);
});
it('exports all workspaces as an HTTP Archive', async () => {
const wrk1 = await models.workspace.create({
_id: 'wrk_1',
name: 'Workspace 1'
name: 'Workspace 1',
});
const wrk2 = await models.workspace.create({
_id: 'wrk_2',
name: 'Workspace 2'
name: 'Workspace 2',
});
await models.request.create({
_id: 'req_1',
name: 'Request 1',
parentId: wrk1._id,
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }]
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }],
});
await models.request.create({
_id: 'req_2',
name: 'Request 2',
parentId: wrk2._id,
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }]
headers: [{ name: 'X-Environment', value: '{{ envvalue }}' }],
});
let env1Base = await models.environment.getOrCreateForWorkspace(wrk1);
env1Base = await models.environment.update(env1Base, {
data: {
envvalue: 'base1'
}
envvalue: 'base1',
},
});
const env1Public = await models.environment.create({
name: 'Public',
parentId: env1Base._id,
data: {
envvalue: 'public1'
}
envvalue: 'public1',
},
});
const env2Base = await models.environment.getOrCreateForWorkspace(wrk2);
await models.environment.update(env2Base, {
data: {
envvalue: 'base2'
}
envvalue: 'base2',
},
});
const env2Private = await models.environment.create({
name: 'Private',
isPrivate: true,
parentId: env1Base._id,
data: {
envvalue: 'private2'
}
envvalue: 'private2',
},
});
await models.workspaceMeta.create({
parentId: wrk1._id,
activeEnvironmentId: env1Public._id
activeEnvironmentId: env1Public._id,
});
await models.workspaceMeta.create({
parentId: wrk2._id,
activeEnvironmentId: env2Private._id
activeEnvironmentId: env2Private._id,
});
const includePrivateDocs = false;
@@ -140,18 +140,18 @@ describe('exportHAR()', () => {
entries: [
{
request: {
headers: [{ name: 'X-Environment', value: 'public1' }]
headers: [{ name: 'X-Environment', value: 'public1' }],
},
comment: 'Request 1'
comment: 'Request 1',
},
{
request: {
headers: [{ name: 'X-Environment', value: 'base2' }]
headers: [{ name: 'X-Environment', value: 'base2' }],
},
comment: 'Request 2'
}
]
}
comment: 'Request 2',
},
],
},
});
});
});
@@ -163,17 +163,17 @@ describe('exportJSON()', () => {
const jar = await models.cookieJar.getOrCreateForParentId(w._id);
const r1 = await models.request.create({
name: 'Request',
parentId: w._id
parentId: w._id,
});
const eBase = await models.environment.getOrCreateForWorkspace(w);
const ePub = await models.environment.create({
name: 'Public',
parentId: eBase._id
parentId: eBase._id,
});
await models.environment.create({
name: 'Private',
isPrivate: true,
parentId: eBase._id
parentId: eBase._id,
});
const json = await importUtil.exportJSON();
@@ -6,7 +6,7 @@ describe('hasAuthHeader()', () => {
it('finds valid header', () => {
const yes = misc.hasAuthHeader([
{ name: 'foo', value: 'bar' },
{ name: 'authorization', value: 'foo' }
{ name: 'authorization', value: 'foo' },
]);
expect(yes).toEqual(true);
@@ -15,7 +15,7 @@ describe('hasAuthHeader()', () => {
it('finds valid header case insensitive', () => {
const yes = misc.hasAuthHeader([
{ name: 'foo', value: 'bar' },
{ name: 'AuthOrizAtiOn', value: 'foo' }
{ name: 'AuthOrizAtiOn', value: 'foo' },
]);
expect(yes).toEqual(true);
@@ -45,7 +45,7 @@ describe('filterHeaders()', () => {
expect(misc.filterHeaders(null, 'good')).toEqual([]);
expect(misc.filterHeaders([{ name: 'good', value: 'valid' }], null)).toEqual([]);
expect(misc.filterHeaders([{ name: 'good', value: 'valid' }], 'good')).toEqual([
{ name: 'good', value: 'valid' }
{ name: 'good', value: 'valid' },
]);
});
});
@@ -77,8 +77,8 @@ describe('keyedDebounce()', () => {
{
foo: ['bar3'],
baz: ['bar'],
multi: ['foo', 'bar', 'baz']
}
multi: ['foo', 'bar', 'baz'],
},
]);
});
});
@@ -116,13 +116,13 @@ describe('fuzzyMatch()', () => {
expect(misc.fuzzyMatch('test', 'testing')).toEqual({
score: -3,
indexes: [0, 1, 2, 3],
target: 'testing'
target: 'testing',
});
expect(misc.fuzzyMatch('tst', 'testing')).toEqual({
score: -2004,
indexes: [0, 2, 3],
target: 'testing'
target: 'testing',
});
});
@@ -141,27 +141,27 @@ describe('fuzzyMatchAll()', () => {
expect(misc.fuzzyMatchAll('test', ['testing', 'foo'])).toEqual({
score: -3,
indexes: [0, 1, 2, 3],
target: 'testing foo'
target: 'testing foo',
});
expect(misc.fuzzyMatchAll('test foo', ['testing', 'foo'], { splitSpace: true })).toEqual({
score: 0,
indexes: [0, 1, 2, 3, 0, 1, 2],
target: 'testing foo'
target: 'testing foo',
});
expect(misc.fuzzyMatchAll('tst', ['testing'])).toEqual({
score: -2004,
indexes: [0, 2, 3],
target: 'testing'
target: 'testing',
});
expect(
misc.fuzzyMatch('tst this ou', 'testing this out', {
splitSpace: true,
loose: true
})
loose: true,
}),
).toEqual({
score: -20,
indexes: [0, 2, 3, 8, 9, 10, 11, 13, 14],
target: 'testing this out'
target: 'testing this out',
});
});
@@ -8,7 +8,7 @@ describe('render()', () => {
beforeEach(globalBeforeEach);
it('renders hello world', async () => {
const rendered = await renderUtils.render('Hello {{ msg }}!', {
msg: 'World'
msg: 'World',
});
expect(rendered).toBe('Hello World!');
});
@@ -39,35 +39,35 @@ describe('buildRenderContext()', () => {
const ancestors = [
{
type: models.requestGroup.type,
environment: { foo: 'parent', ancestor: true }
environment: { foo: 'parent', ancestor: true },
},
{
type: models.requestGroup.type,
environment: { foo: 'grandparent', ancestor: true }
}
environment: { foo: 'grandparent', ancestor: true },
},
];
const rootEnvironment = {
type: models.environment.type,
data: { foo: 'root', root: true }
data: { foo: 'root', root: true },
};
const subEnvironment = {
type: models.environment.type,
data: { foo: 'sub', sub: true }
data: { foo: 'sub', sub: true },
};
const context = await renderUtils.buildRenderContext(
ancestors,
rootEnvironment,
subEnvironment
subEnvironment,
);
expect(context).toEqual({
foo: 'parent',
ancestor: true,
root: true,
sub: true
sub: true,
});
});
@@ -76,15 +76,15 @@ describe('buildRenderContext()', () => {
{
// Sub Environment
type: models.requestGroup.type,
environment: { recursive: '{{ recursive }}/hello' }
}
environment: { recursive: '{{ recursive }}/hello' },
},
];
const context = await renderUtils.buildRenderContext(ancestors);
// This is longer than 3 because it multiplies every time (1 -> 2 -> 4 -> 8)
expect(context).toEqual({
recursive: '{{ recursive }}/hello/hello/hello/hello/hello/hello/hello/hello'
recursive: '{{ recursive }}/hello/hello/hello/hello/hello/hello/hello/hello',
});
});
@@ -94,8 +94,8 @@ describe('buildRenderContext()', () => {
data: {
proto: 'http',
domain: 'base.com',
url: '{{ proto }}://{{ domain }}'
}
url: '{{ proto }}://{{ domain }}',
},
};
const sub = {
@@ -104,8 +104,8 @@ describe('buildRenderContext()', () => {
proto: 'https',
domain: 'sub.com',
port: 8000,
url: '{{ proto }}://{{ domain }}:{{ port }}'
}
url: '{{ proto }}://{{ domain }}:{{ port }}',
},
};
const ancestors = [
@@ -115,9 +115,9 @@ describe('buildRenderContext()', () => {
environment: {
proto: 'https',
domain: 'folder.com',
port: 7000
}
}
port: 7000,
},
},
];
const context = await renderUtils.buildRenderContext(ancestors, root, sub);
@@ -126,19 +126,19 @@ describe('buildRenderContext()', () => {
proto: 'https',
domain: 'folder.com',
port: 7000,
url: 'https://folder.com:7000'
url: 'https://folder.com:7000',
});
});
it('does the thing', async () => {
const root = {
type: models.environment.type,
data: { url: 'insomnia.rest' }
data: { url: 'insomnia.rest' },
};
const sub = {
type: models.environment.type,
data: { url: '{{ url }}/sub' }
data: { url: '{{ url }}/sub' },
};
const ancestors = [
@@ -147,16 +147,16 @@ describe('buildRenderContext()', () => {
type: models.requestGroup.type,
environment: {
url: '{{ url }}/{{ name }}',
name: 'folder'
}
}
name: 'folder',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors, root, sub);
expect(context).toEqual({
url: 'insomnia.rest/sub/folder',
name: 'folder'
name: 'folder',
});
});
@@ -170,9 +170,9 @@ describe('buildRenderContext()', () => {
c: '/c{{ d }}',
b: '/b{{ c }}',
a: '/a{{ b }}',
test: 'http://insomnia.rest{{ a }}'
}
}
test: 'http://insomnia.rest{{ a }}',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
@@ -182,7 +182,7 @@ describe('buildRenderContext()', () => {
c: '/c/d',
b: '/b/c/d',
a: '/a/b/c/d',
test: 'http://insomnia.rest/a/b/c/d'
test: 'http://insomnia.rest/a/b/c/d',
});
});
@@ -193,9 +193,9 @@ describe('buildRenderContext()', () => {
type: models.requestGroup.type,
environment: {
sibling: 'sibling',
test: '{{ sibling }}/hello'
}
}
test: '{{ sibling }}/hello',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
@@ -209,23 +209,23 @@ describe('buildRenderContext()', () => {
name: 'Parent',
type: models.requestGroup.type,
environment: {
test: '{{ grandparent }} parent'
}
test: '{{ grandparent }} parent',
},
},
{
name: 'Grandparent',
type: models.requestGroup.type,
environment: {
grandparent: 'grandparent'
}
}
grandparent: 'grandparent',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
expect(context).toEqual({
grandparent: 'grandparent',
test: 'grandparent parent'
test: 'grandparent parent',
});
});
@@ -235,16 +235,16 @@ describe('buildRenderContext()', () => {
name: 'Parent',
type: models.requestGroup.type,
environment: {
base_url: '{{ base_url }}/resource'
}
base_url: '{{ base_url }}/resource',
},
},
{
name: 'Grandparent',
type: models.requestGroup.type,
environment: {
base_url: 'https://insomnia.rest'
}
}
base_url: 'https://insomnia.rest',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
@@ -258,8 +258,8 @@ describe('buildRenderContext()', () => {
name: 'Parent',
type: models.requestGroup.type,
environment: {
host: 'parent.com'
}
host: 'parent.com',
},
},
{
name: 'Grandparent',
@@ -269,22 +269,22 @@ describe('buildRenderContext()', () => {
node: {
admin: 'admin',
test: 'test',
port: 8080
port: 8080,
},
urls: {
admin: 'https://{{ host }}/{{ node.admin }}',
test: 'https://{{ host }}/{{ node.test }}'
}
}
}
test: 'https://{{ host }}/{{ node.test }}',
},
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
expect(await renderUtils.render('{{ urls.admin }}/foo', context)).toBe(
'https://parent.com/admin/foo'
'https://parent.com/admin/foo',
);
expect(await renderUtils.render('{{ urls.test }}/foo', context)).toBe(
'https://parent.com/test/foo'
'https://parent.com/test/foo',
);
});
@@ -294,16 +294,16 @@ describe('buildRenderContext()', () => {
name: 'Parent',
type: models.requestGroup.type,
environment: {
parent: 'parent'
}
parent: 'parent',
},
},
{
name: 'Grandparent',
type: models.requestGroup.type,
environment: {
test: '{{ parent }} grandparent'
}
}
test: '{{ parent }} grandparent',
},
},
];
const context = await renderUtils.buildRenderContext(ancestors);
@@ -318,32 +318,32 @@ describe('buildRenderContext()', () => {
environment: {
url: '{{ base_url }}/resource',
ancestor: true,
winner: 'folder parent'
}
winner: 'folder parent',
},
},
{
type: models.requestGroup.type,
environment: {
ancestor: true,
winner: 'folder grandparent'
}
}
winner: 'folder grandparent',
},
},
];
const subEnvironment = {
type: models.environment.type,
data: { winner: 'sub', sub: true, base_url: 'https://insomnia.rest' }
data: { winner: 'sub', sub: true, base_url: 'https://insomnia.rest' },
};
const rootEnvironment = {
type: models.environment.type,
data: { winner: 'root', root: true, base_url: 'ignore this' }
data: { winner: 'root', root: true, base_url: 'ignore this' },
};
const context = await renderUtils.buildRenderContext(
ancestors,
rootEnvironment,
subEnvironment
subEnvironment,
);
expect(context).toEqual({
@@ -352,7 +352,7 @@ describe('buildRenderContext()', () => {
ancestor: true,
winner: 'folder parent',
root: true,
sub: true
sub: true,
});
});
@@ -365,8 +365,8 @@ describe('buildRenderContext()', () => {
orderId: 123456789012345,
password: "{% hash 'sha512', 'hex', hash_input %}",
password_expected: "{% hash 'sha512', 'hex', hash_input_expected %}",
secret: 'ThisIsATopSecretValue'
}
secret: 'ThisIsATopSecretValue',
},
};
const context = await renderUtils.buildRenderContext([], rootEnvironment);
@@ -379,7 +379,7 @@ describe('buildRenderContext()', () => {
'ea84d15f33d3f9e9098fe01659b1ea0599d345770bba20ba98bf9056676a83ffe6b5528b2451ad04badbf690cf3009a94c510121cc6897045f8bb4ba0826134c',
password_expected:
'ea84d15f33d3f9e9098fe01659b1ea0599d345770bba20ba98bf9056676a83ffe6b5528b2451ad04badbf690cf3009a94c510121cc6897045f8bb4ba0826134c',
secret: 'ThisIsATopSecretValue'
secret: 'ThisIsATopSecretValue',
});
});
@@ -391,7 +391,7 @@ describe('buildRenderContext()', () => {
const context = await renderUtils.buildRenderContext(
ancestors,
rootEnvironment,
subEnvironment
subEnvironment,
);
expect(context).toEqual({});
@@ -405,15 +405,15 @@ describe('render()', () => {
{
foo: '{{ foo }}',
bar: 'bar',
baz: '{{ bad }}'
baz: '{{ bad }}',
},
{ foo: 'bar', bad: 'hi' }
{ foo: 'bar', bad: 'hi' },
);
expect(newObj).toEqual({
foo: 'bar',
bar: 'bar',
baz: 'hi'
baz: 'hi',
});
});
@@ -428,8 +428,8 @@ describe('render()', () => {
num: 1234,
nested: {
foo: '{{ foo }}',
arr: [1, 2, '{{ foo }}']
}
arr: [1, 2, '{{ foo }}'],
},
};
const newObj = await renderUtils.render(obj, { foo: 'bar' });
@@ -443,8 +443,8 @@ describe('render()', () => {
num: 1234,
nested: {
foo: 'bar',
arr: [1, 2, 'bar']
}
arr: [1, 2, 'bar'],
},
});
// Make sure original request isn't changed
@@ -459,9 +459,9 @@ describe('render()', () => {
{
foo: '{{ foo }',
bar: 'bar',
baz: '{{ bad }}'
baz: '{{ bad }}',
},
{ foo: 'bar' }
{ foo: 'bar' },
);
fail('Render should have failed');
} catch (err) {
@@ -477,7 +477,7 @@ describe('render()', () => {
template,
context,
null,
renderUtils.KEEP_ON_ERROR
renderUtils.KEEP_ON_ERROR,
);
expect(resultOnlyVars).toBe('{{ foo }} {% invalid "hi" %}');
@@ -491,7 +491,7 @@ describe('render()', () => {
it('outputs correct error path', async () => {
const template = {
foo: [{ bar: '{% foo %}' }]
foo: [{ bar: '{% foo %}' }],
};
try {
@@ -504,7 +504,7 @@ describe('render()', () => {
it('outputs correct error path when private first node', async () => {
const template = {
_foo: { _bar: { baz: '{% foo %}' } }
_foo: { _bar: { baz: '{% foo %}' } },
};
try {
@@ -67,10 +67,7 @@ export const LARGE_RESPONSE_MB = 5;
export const HUGE_RESPONSE_MB = 100;
export const FLEXIBLE_URL_REGEX = /^(http|https):\/\/[\wàâäèéêëîïôóœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ\-_.]+[/\wàâäèéêëîïôóœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ.\-+=:\][@%^*&!#?;$]*/;
export const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 3; // 3 hours
export const PLUGIN_PATH = path.join(
getDataDirectory(),
'plugins'
);
export const PLUGIN_PATH = path.join(getDataDirectory(), 'plugins');
// Hotkeys
export const MNEMONIC_SYM = isMac() ? '' : '&';
@@ -116,7 +113,7 @@ export const HTTP_METHODS = [
METHOD_PATCH,
METHOD_DELETE,
METHOD_OPTIONS,
METHOD_HEAD
METHOD_HEAD,
];
// Preview Modes
@@ -127,7 +124,7 @@ export const PREVIEW_MODE_RAW = 'raw';
const previewModeMap = {
[PREVIEW_MODE_FRIENDLY]: ['Preview', 'Visual Preview'],
[PREVIEW_MODE_SOURCE]: ['Source', 'Source Code'],
[PREVIEW_MODE_RAW]: ['Raw', 'Raw Data']
[PREVIEW_MODE_RAW]: ['Raw', 'Raw Data'],
};
export const PREVIEW_MODES = Object.keys(previewModeMap);
@@ -150,7 +147,7 @@ const contentTypesMap = {
[CONTENT_TYPE_FILE]: ['File', 'Binary File'],
[CONTENT_TYPE_GRAPHQL]: ['GraphQL', 'GraphQL Query'],
[CONTENT_TYPE_OTHER]: ['Other', 'Other'],
[CONTENT_TYPE_EDN]: ['EDN', 'EDN']
[CONTENT_TYPE_EDN]: ['EDN', 'EDN'],
};
// Auth Types
@@ -179,7 +176,7 @@ const authTypesMap = {
[AUTH_HAWK]: ['Hawk', 'Hawk'],
[AUTH_AWS_IAM]: ['AWS', 'AWS IAM v4'],
[AUTH_ASAP]: ['ASAP', 'Atlassian ASAP'],
[AUTH_NETRC]: ['Netrc', 'Netrc File']
[AUTH_NETRC]: ['Netrc', 'Netrc File'],
};
export function getPreviewModeName(previewMode, useLong = false) {
@@ -298,5 +295,5 @@ export const RESPONSE_CODE_DESCRIPTIONS = {
507: 'The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.',
508: 'The server detected an infinite loop while processing the request.',
510: 'Further extensions to the request are required for the server to fulfill it.',
511: 'The 511 status code indicates that the client needs to authenticate to gain network access.'
511: 'The 511 status code indicates that the client needs to authenticate to gain network access.',
};
+24 -24
View File
@@ -14,7 +14,7 @@ export const CHANGE_REMOVE = 'remove';
const database = {};
const db = {
_empty: true
_empty: true,
};
// ~~~~~~~ //
@@ -63,10 +63,10 @@ export async function init(types: Array<string>, config: Object = {}, forceReset
Object.assign(
{
autoload: true,
filename: filePath
filename: filePath,
},
config
)
config,
),
);
collection.persistence.setAutocompactionInterval(DB_PERSIST_INTERVAL);
@@ -152,7 +152,7 @@ export function offChange(callback: Function): void {
}
export const bufferChanges = (database.bufferChanges = async function(
millis: number = 1000
millis: number = 1000,
): Promise<void> {
if (db._empty) return _send('bufferChanges', ...arguments);
@@ -205,7 +205,7 @@ async function notifyOfChange(event: string, doc: BaseModel, fromSync: boolean):
export const getMostRecentlyModified = (database.getMostRecentlyModified = async function(
type: string,
query: Object = {}
query: Object = {},
): Promise<BaseModel | null> {
if (db._empty) return _send('getMostRecentlyModified', ...arguments);
@@ -216,7 +216,7 @@ export const getMostRecentlyModified = (database.getMostRecentlyModified = async
export const findMostRecentlyModified = (database.findMostRecentlyModified = async function(
type: string,
query: Object = {},
limit: number | null = null
limit: number | null = null,
): Promise<Array<BaseModel>> {
if (db._empty) return _send('findMostRecentlyModified', ...arguments);
@@ -245,7 +245,7 @@ export const findMostRecentlyModified = (database.findMostRecentlyModified = asy
export const find = (database.find = async function<T: BaseModel>(
type: string,
query: Object = {},
sort: Object = { created: 1 }
sort: Object = { created: 1 },
): Promise<Array<T>> {
if (db._empty) return _send('find', ...arguments);
@@ -276,7 +276,7 @@ export const all = (database.all = async function<T: BaseModel>(type: string): P
export const getWhere = (database.getWhere = async function<T: BaseModel>(
type: string,
query: Object
query: Object,
): Promise<T | null> {
if (db._empty) return _send('getWhere', ...arguments);
@@ -286,7 +286,7 @@ export const getWhere = (database.getWhere = async function<T: BaseModel>(
export const get = (database.get = async function<T: BaseModel>(
type: string,
id: string
id: string,
): Promise<T | null> {
if (db._empty) return _send('get', ...arguments);
@@ -300,7 +300,7 @@ export const get = (database.get = async function<T: BaseModel>(
export const count = (database.count = async function(
type: string,
query: Object = {}
query: Object = {},
): Promise<number> {
if (db._empty) return _send('count', ...arguments);
@@ -317,7 +317,7 @@ export const count = (database.count = async function(
export const upsert = (database.upsert = async function(
doc: BaseModel,
fromSync: boolean = false
fromSync: boolean = false,
): Promise<BaseModel> {
if (db._empty) return _send('upsert', ...arguments);
@@ -331,7 +331,7 @@ export const upsert = (database.upsert = async function(
export const insert = (database.insert = async function<T: BaseModel>(
doc: T,
fromSync: boolean = false
fromSync: boolean = false,
): Promise<T> {
if (db._empty) return _send('insert', ...arguments);
@@ -352,7 +352,7 @@ export const insert = (database.insert = async function<T: BaseModel>(
export const update = (database.update = async function<T: BaseModel>(
doc: T,
fromSync: boolean = false
fromSync: boolean = false,
): Promise<T> {
if (db._empty) return _send('update', ...arguments);
@@ -373,7 +373,7 @@ export const update = (database.update = async function<T: BaseModel>(
export const remove = (database.remove = async function<T: BaseModel>(
doc: T,
fromSync: boolean = false
fromSync: boolean = false,
): Promise<void> {
if (db._empty) return _send('remove', ...arguments);
@@ -393,7 +393,7 @@ export const remove = (database.remove = async function<T: BaseModel>(
export const removeWhere = (database.removeWhere = async function(
type: string,
query: Object
query: Object,
): Promise<void> {
if (db._empty) return _send('removeWhere', ...arguments);
@@ -428,7 +428,7 @@ export async function docUpdate<T: BaseModel>(
// NOTE: This is before `patch` because we want `patch.modified` to win if it has it
{ modified: Date.now() },
...patches
...patches,
);
return database.update(doc);
@@ -440,7 +440,7 @@ export async function docCreate<T: BaseModel>(type: string, ...patches: Array<Ob
...patches,
// Fields that the user can't touch
{ type: type }
{ type: type },
);
return database.insert(doc);
@@ -452,7 +452,7 @@ export async function docCreate<T: BaseModel>(type: string, ...patches: Array<Ob
export const withDescendants = (database.withDescendants = async function(
doc: BaseModel | null,
stopType: string | null = null
stopType: string | null = null,
): Promise<Array<BaseModel>> {
if (db._empty) return _send('withDescendants', ...arguments);
@@ -489,7 +489,7 @@ export const withDescendants = (database.withDescendants = async function(
export const withAncestors = (database.withAncestors = async function(
doc: BaseModel | null,
types: Array<string> = allTypes()
types: Array<string> = allTypes(),
): Promise<Array<BaseModel>> {
if (db._empty) return _send('withAncestors', ...arguments);
@@ -524,7 +524,7 @@ export const withAncestors = (database.withAncestors = async function(
export const duplicate = (database.duplicate = async function<T: BaseModel>(
originalDoc: T,
patch: Object = {}
patch: Object = {},
): Promise<T> {
if (db._empty) return _send('duplicate', ...arguments);
@@ -595,7 +595,7 @@ export async function _repairDatabase() {
*/
async function _repairBaseEnvironments(workspace) {
const baseEnvironments = await find(models.environment.type, {
parentId: workspace._id
parentId: workspace._id,
});
// Nothing to do here
@@ -611,7 +611,7 @@ async function _repairBaseEnvironments(workspace) {
chosenBase.data = Object.assign(baseEnvironment.data, chosenBase.data);
const subEnvironments = await find(models.environment.type, {
parentId: baseEnvironment._id
parentId: baseEnvironment._id,
});
for (const subEnvironment of subEnvironments) {
@@ -635,7 +635,7 @@ async function _repairBaseEnvironments(workspace) {
*/
async function _fixMultipleCookieJars(workspace) {
const cookieJars = await find(models.cookieJar.type, {
parentId: workspace._id
parentId: workspace._id,
});
// Nothing to do here
+1 -1
View File
@@ -37,7 +37,7 @@ export function rawFetch(...args) {
async function _fetch(method, path, obj, sessionId = null) {
const config = {
method: method,
headers: new window.Headers()
headers: new window.Headers(),
};
// Set some client information
+44 -44
View File
@@ -26,19 +26,19 @@ export type HarCookie = {
expires?: string,
httpOnly?: boolean,
secure?: boolean,
comment?: string
comment?: string,
};
export type HarHeader = {
name: string,
value: string,
comment?: string
comment?: string,
};
export type HarQueryString = {
name: string,
value: string,
comment?: string
comment?: string,
};
export type HarPostParam = {
@@ -46,14 +46,14 @@ export type HarPostParam = {
value?: string,
fileName?: string,
contentType?: string,
comment?: string
comment?: string,
};
export type HarPostData = {
mimeType: string,
params: Array<HarPostParam>,
text: string,
comment?: string
comment?: string,
};
export type HarRequest = {
@@ -67,7 +67,7 @@ export type HarRequest = {
headersSize: number,
bodySize: number,
comment?: string,
settingEncodeUrl: boolean
settingEncodeUrl: boolean,
};
export type HarContent = {
@@ -76,7 +76,7 @@ export type HarContent = {
mimeType: string,
text?: string,
encoding?: string,
comment?: string
comment?: string,
};
export type HarResponse = {
@@ -89,7 +89,7 @@ export type HarResponse = {
redirectURL: string,
headersSize: number,
bodySize: number,
comment?: string
comment?: string,
};
export type HarRequestCache = {
@@ -97,13 +97,13 @@ export type HarRequestCache = {
lastAccess: string,
eTag: string,
hitCount: number,
comment?: string
comment?: string,
};
export type HarCache = {
beforeRequest?: HarRequestCache,
afterRequest?: HarRequestCache,
comment?: string
comment?: string,
};
export type HarEntryTimings = {
@@ -114,7 +114,7 @@ export type HarEntryTimings = {
wait: number,
receive: number,
ssl?: number,
comment?: string
comment?: string,
};
export type HarEntry = {
@@ -127,13 +127,13 @@ export type HarEntry = {
timings: HarEntryTimings,
serverIPAddress?: string,
connection?: string,
comment?: string
comment?: string,
};
export type HarPageTimings = {
onContentLoad?: number,
onLoad?: number,
comment?: string
comment?: string,
};
export type HarPage = {
@@ -141,19 +141,19 @@ export type HarPage = {
id: string,
title: string,
pageTimings: HarPageTimings,
comment?: string
comment?: string,
};
export type HarCreator = {
name: string,
version: string,
comment?: string
comment?: string,
};
export type HarBrowser = {
name: string,
version: string,
comment?: string
comment?: string,
};
export type HarLog = {
@@ -162,16 +162,16 @@ export type HarLog = {
browser?: HarBrowser,
pages?: Array<HarPage>,
entries: Array<HarEntry>,
comment?: string
comment?: string,
};
export type Har = {
log: HarLog
log: HarLog,
};
export type ExportRequest = {
requestId: string,
environmentId: string
environmentId: string,
};
export async function exportHar(exportRequests: Array<ExportRequest>): Promise<Har> {
@@ -190,7 +190,7 @@ export async function exportHar(exportRequests: Array<ExportRequest>): Promise<H
}
const response: ResponseModel | null = await models.response.getLatestForRequest(
exportRequest.requestId
exportRequest.requestId,
);
const harResponse = await exportHarResponse(response);
if (!harResponse) {
@@ -210,9 +210,9 @@ export async function exportHar(exportRequests: Array<ExportRequest>): Promise<H
send: 0,
wait: response ? response.elapsedTime : 0,
receive: 0,
ssl: -1
ssl: -1,
},
comment: request.name
comment: request.name,
};
entries.push(entry);
@@ -223,10 +223,10 @@ export async function exportHar(exportRequests: Array<ExportRequest>): Promise<H
version: '1.2',
creator: {
name: 'Insomnia REST Client',
version: `insomnia.desktop.app:v${getAppVersion()}`
version: `insomnia.desktop.app:v${getAppVersion()}`,
},
entries: entries
}
entries: entries,
},
};
}
@@ -240,11 +240,11 @@ export async function exportHarResponse(response: ResponseModel | null): Promise
headers: [],
content: {
size: 0,
mimeType: ''
mimeType: '',
},
redirectURL: '',
headersSize: -1,
bodySize: -1
bodySize: -1,
};
}
@@ -257,14 +257,14 @@ export async function exportHarResponse(response: ResponseModel | null): Promise
content: getResponseContent(response),
redirectURL: '',
headersSize: -1,
bodySize: -1
bodySize: -1,
};
}
export async function exportHarRequest(
requestId: string,
environmentId: string,
addContentLength: boolean = false
addContentLength: boolean = false,
): Promise<HarRequest | null> {
const request = await models.request.getById(requestId);
if (!request) {
@@ -277,13 +277,13 @@ export async function exportHarRequest(
export async function exportHarWithRequest(
request: Request,
environmentId: string,
addContentLength: boolean = false
addContentLength: boolean = false,
): Promise<HarRequest | null> {
try {
const renderResult = await getRenderedRequestAndContext(request, environmentId);
const renderedRequest = await _applyRequestPluginHooks(
renderResult.request,
renderResult.context
renderResult.context,
);
return exportHarWithRenderedRequest(renderedRequest, addContentLength);
} catch (err) {
@@ -297,7 +297,7 @@ export async function exportHarWithRequest(
async function _applyRequestPluginHooks(
renderedRequest: RenderedRequest,
renderedContext: Object
renderedContext: Object,
): Promise<RenderedRequest> {
let newRenderedRequest = renderedRequest;
for (const { plugin, hook } of await plugins.getRequestHooks()) {
@@ -306,7 +306,7 @@ async function _applyRequestPluginHooks(
const context = {
...pluginContexts.app.init(),
...pluginContexts.request.init(newRenderedRequest, renderedContext),
...pluginContexts.store.init(plugin)
...pluginContexts.store.init(plugin),
};
try {
@@ -322,7 +322,7 @@ async function _applyRequestPluginHooks(
export async function exportHarWithRenderedRequest(
renderedRequest: RenderedRequest,
addContentLength: boolean = false
addContentLength: boolean = false,
): Promise<HarRequest> {
const url = smartEncodeUrl(renderedRequest.url, renderedRequest.settingEncodeUrl);
@@ -343,12 +343,12 @@ export async function exportHarWithRenderedRequest(
renderedRequest._id,
url,
renderedRequest.method,
renderedRequest.authentication
renderedRequest.authentication,
);
if (header) {
renderedRequest.headers.push({
name: header.name,
value: header.value
value: header.value,
});
}
}
@@ -363,7 +363,7 @@ export async function exportHarWithRenderedRequest(
postData: getRequestPostData(renderedRequest),
headersSize: -1,
bodySize: -1,
settingEncodeUrl: renderedRequest.settingEncodeUrl
settingEncodeUrl: renderedRequest.settingEncodeUrl,
};
}
@@ -393,7 +393,7 @@ function getReponseCookies(response: ResponseModel): Array<HarCookie> {
function mapCookie(cookie: Cookie): HarCookie {
const harCookie: HarCookie = {
name: cookie.key,
value: cookie.value
value: cookie.value,
};
if (cookie.path) {
@@ -441,7 +441,7 @@ function getResponseContent(response: ResponseModel): HarContent {
return {
size: body.byteLength,
mimeType: response.contentType,
text: body.toString('utf8')
text: body.toString('utf8'),
};
}
@@ -449,7 +449,7 @@ function getResponseHeaders(response: ResponseModel): Array<HarHeader> {
return response.headers.filter(header => header.name).map(h => {
return {
name: h.name,
value: h.value
value: h.value,
};
});
}
@@ -458,7 +458,7 @@ function getRequestHeaders(renderedRequest: RenderedRequest): Array<HarHeader> {
return renderedRequest.headers.filter(header => header.name).map(header => {
return {
name: header.name,
value: header.value
value: header.value,
};
});
}
@@ -467,7 +467,7 @@ function getRequestQueryString(renderedRequest: RenderedRequest): Array<HarQuery
return renderedRequest.parameters.map(parameter => {
return {
name: parameter.name,
value: parameter.value
value: parameter.value,
};
});
}
@@ -491,7 +491,7 @@ function getRequestPostData(renderedRequest: RenderedRequest): HarPostData | voi
params = body.params.map(param => {
return {
name: param.name,
value: param.value
value: param.value,
};
});
}
@@ -499,6 +499,6 @@ function getRequestPostData(renderedRequest: RenderedRequest): HarPostData | voi
return {
mimeType: body.mimeType || '',
text: body.text || '',
params: params
params: params,
};
}
+29 -29
View File
@@ -8,7 +8,7 @@ export type Hotkey = {
alt: boolean,
shift: boolean,
keycode: number | Array<number>,
metaIsCtrl?: boolean
metaIsCtrl?: boolean,
};
export const SHOW_WORKSPACE_SETTINGS: Hotkey = {
@@ -16,7 +16,7 @@ export const SHOW_WORKSPACE_SETTINGS: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.comma
keycode: keycodes.comma,
};
export const SHOW_REQUEST_SETTINGS: Hotkey = {
@@ -24,7 +24,7 @@ export const SHOW_REQUEST_SETTINGS: Hotkey = {
meta: true,
alt: true,
shift: true,
keycode: keycodes.comma
keycode: keycodes.comma,
};
export const SHOW_KEYBOARD_SHORTCUTS: Hotkey = {
@@ -32,7 +32,7 @@ export const SHOW_KEYBOARD_SHORTCUTS: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.forwardslash
keycode: keycodes.forwardslash,
};
export const SHOW_SETTINGS: Hotkey = {
@@ -40,7 +40,7 @@ export const SHOW_SETTINGS: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.comma
keycode: keycodes.comma,
};
export const TOGGLE_MAIN_MENU: Hotkey = {
@@ -48,7 +48,7 @@ export const TOGGLE_MAIN_MENU: Hotkey = {
meta: true,
alt: true,
shift: false,
keycode: keycodes.comma
keycode: keycodes.comma,
};
export const TOGGLE_SIDEBAR: Hotkey = {
@@ -56,7 +56,7 @@ export const TOGGLE_SIDEBAR: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.backslash
keycode: keycodes.backslash,
};
export const SHOW_QUICK_SWITCHER: Hotkey = {
@@ -64,7 +64,7 @@ export const SHOW_QUICK_SWITCHER: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.p
keycode: keycodes.p,
};
export const RELOAD_PLUGINS: Hotkey = {
@@ -72,7 +72,7 @@ export const RELOAD_PLUGINS: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.r
keycode: keycodes.r,
};
export const SHOW_AUTOCOMPLETE: Hotkey = {
@@ -81,7 +81,7 @@ export const SHOW_AUTOCOMPLETE: Hotkey = {
metaIsCtrl: true,
alt: false,
shift: false,
keycode: keycodes.space
keycode: keycodes.space,
};
export const SEND_REQUEST: Hotkey = {
@@ -89,7 +89,7 @@ export const SEND_REQUEST: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: [keycodes.enter, keycodes.r]
keycode: [keycodes.enter, keycodes.r],
};
export const SEND_REQUEST_F5: Hotkey = {
@@ -97,7 +97,7 @@ export const SEND_REQUEST_F5: Hotkey = {
meta: false,
alt: false,
shift: false,
keycode: keycodes.f5
keycode: keycodes.f5,
};
export const SHOW_SEND_OPTIONS: Hotkey = {
@@ -105,7 +105,7 @@ export const SHOW_SEND_OPTIONS: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.enter
keycode: keycodes.enter,
};
export const SHOW_ENVIRONMENTS: Hotkey = {
@@ -113,7 +113,7 @@ export const SHOW_ENVIRONMENTS: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.e
keycode: keycodes.e,
};
export const TOGGLE_ENVIRONMENTS_MENU: Hotkey = {
@@ -121,7 +121,7 @@ export const TOGGLE_ENVIRONMENTS_MENU: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.e
keycode: keycodes.e,
};
export const TOGGLE_METHOD_DROPDOWN: Hotkey = {
@@ -129,7 +129,7 @@ export const TOGGLE_METHOD_DROPDOWN: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.l
keycode: keycodes.l,
};
export const TOGGLE_HISTORY_DROPDOWN: Hotkey = {
@@ -137,7 +137,7 @@ export const TOGGLE_HISTORY_DROPDOWN: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.h
keycode: keycodes.h,
};
export const FOCUS_URL: Hotkey = {
@@ -145,7 +145,7 @@ export const FOCUS_URL: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.l
keycode: keycodes.l,
};
export const GENERATE_CODE: Hotkey = {
@@ -153,7 +153,7 @@ export const GENERATE_CODE: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.g
keycode: keycodes.g,
};
export const FOCUS_FILTER: Hotkey = {
@@ -161,7 +161,7 @@ export const FOCUS_FILTER: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.f
keycode: keycodes.f,
};
export const FOCUS_RESPONSE: Hotkey = {
@@ -169,7 +169,7 @@ export const FOCUS_RESPONSE: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.singlequote
keycode: keycodes.singlequote,
};
export const SHOW_COOKIES: Hotkey = {
@@ -177,7 +177,7 @@ export const SHOW_COOKIES: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.k
keycode: keycodes.k,
};
export const CREATE_REQUEST: Hotkey = {
@@ -185,7 +185,7 @@ export const CREATE_REQUEST: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.n
keycode: keycodes.n,
};
export const DELETE_REQUEST: Hotkey = {
@@ -193,7 +193,7 @@ export const DELETE_REQUEST: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.delete
keycode: keycodes.delete,
};
export const CREATE_FOLDER: Hotkey = {
@@ -201,7 +201,7 @@ export const CREATE_FOLDER: Hotkey = {
meta: true,
alt: false,
shift: true,
keycode: keycodes.n
keycode: keycodes.n,
};
export const DUPLICATE_REQUEST: Hotkey = {
@@ -209,7 +209,7 @@ export const DUPLICATE_REQUEST: Hotkey = {
meta: true,
alt: false,
shift: false,
keycode: keycodes.d
keycode: keycodes.d,
};
export const CLOSE_DROPDOWN: Hotkey = {
@@ -217,7 +217,7 @@ export const CLOSE_DROPDOWN: Hotkey = {
meta: false,
alt: false,
shift: false,
keycode: keycodes.esc
keycode: keycodes.esc,
};
export const CLOSE_MODAL: Hotkey = {
@@ -225,7 +225,7 @@ export const CLOSE_MODAL: Hotkey = {
meta: false,
alt: false,
shift: false,
keycode: keycodes.esc
keycode: keycodes.esc,
};
export const UNCOVER_VARIABLES: Hotkey = {
@@ -233,7 +233,7 @@ export const UNCOVER_VARIABLES: Hotkey = {
meta: false,
alt: true,
shift: true,
keycode: keycodes.u
keycode: keycodes.u,
};
export function pressedHotKey(e: KeyboardEvent, definition: Hotkey): boolean {
+14 -14
View File
@@ -29,7 +29,7 @@ const MODELS = {
[EXPORT_TYPE_REQUEST_GROUP]: models.requestGroup,
[EXPORT_TYPE_WORKSPACE]: models.workspace,
[EXPORT_TYPE_COOKIE_JAR]: models.cookieJar,
[EXPORT_TYPE_ENVIRONMENT]: models.environment
[EXPORT_TYPE_ENVIRONMENT]: models.environment,
};
export async function importUri(workspaceId: string | null, uri: string): Promise<void> {
@@ -72,11 +72,11 @@ export async function importUri(workspaceId: string | null, uri: string): Promis
export async function importRaw(
workspaceId: string | null,
rawContent: string,
generateNewIds: boolean = false
generateNewIds: boolean = false,
): Promise<{
source: string,
error: string | null,
summary: { [string]: Array<BaseModel> }
summary: { [string]: Array<BaseModel> },
}> {
let results;
try {
@@ -86,7 +86,7 @@ export async function importRaw(
return {
source: 'not found',
error: 'No importers found for file',
summary: {}
summary: {},
};
}
@@ -96,7 +96,7 @@ export async function importRaw(
// Fetch the base environment in case we need it
let baseEnvironment: Environment | null = await models.environment.getOrCreateForWorkspaceId(
workspaceId || 'n/a'
workspaceId || 'n/a',
);
// Generate all the ids we may need
@@ -120,7 +120,7 @@ export async function importRaw(
if (!baseEnvironment) {
if (!workspace) {
workspace = await models.workspace.create({
name: 'Imported Workspace'
name: 'Imported Workspace',
});
}
baseEnvironment = await models.environment.getOrCreateForWorkspace(workspace);
@@ -184,13 +184,13 @@ export async function importRaw(
return {
source: results.type && typeof results.type.id === 'string' ? results.type.id : 'unknown',
summary: importedDocs,
error: null
error: null,
};
}
export async function exportHAR(
parentDoc: BaseModel | null = null,
includePrivateDocs: boolean = false
includePrivateDocs: boolean = false,
): Promise<string> {
let workspaces;
if (parentDoc) {
@@ -219,7 +219,7 @@ export async function exportHAR(
.map((request: BaseModel) => {
return {
requestId: request._id,
environmentId: workspaceEnvironmentLookup[workspace._id]
environmentId: workspaceEnvironmentLookup[workspace._id],
};
});
@@ -233,14 +233,14 @@ export async function exportHAR(
export async function exportJSON(
parentDoc: BaseModel | null = null,
includePrivateDocs: boolean = false
includePrivateDocs: boolean = false,
): Promise<string> {
const data = {
_type: 'export',
__export_format: EXPORT_FORMAT,
__export_date: new Date(),
__export_source: `insomnia.desktop.app:v${getAppVersion()}`,
resources: []
resources: [],
};
const docs: Array<BaseModel> = await getDocWithDescendants(parentDoc, includePrivateDocs);
@@ -253,7 +253,7 @@ export async function exportJSON(
d.type === models.requestGroup.type ||
d.type === models.workspace.type ||
d.type === models.cookieJar.type ||
d.type === models.environment.type
d.type === models.environment.type,
)
.map((d: Object) => {
if (d.type === models.workspace.type) {
@@ -278,12 +278,12 @@ export async function exportJSON(
async function getDocWithDescendants(
parentDoc: BaseModel | null = null,
includePrivateDocs: boolean = false
includePrivateDocs: boolean = false,
): Promise<Array<BaseModel>> {
const docs = await db.withDescendants(parentDoc);
return docs.filter(
d =>
// Don't include if private, except if we want to
!(d: any).isPrivate || includePrivateDocs
!(d: any).isPrivate || includePrivateDocs,
);
}
+1 -1
View File
@@ -97,5 +97,5 @@ export default {
openbracket: 219,
backslash: 220,
closebracket: 221,
singlequote: 222
singlequote: 222,
};
@@ -8,7 +8,7 @@ marked.setOptions({
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false
smartypants: false,
});
export function markdownToHTML(markdown) {
+4 -4
View File
@@ -11,12 +11,12 @@ const ESCAPE_REGEX_MATCH = /[-[\]/{}()*+?.\\^$|]/g;
type Header = {
name: string,
value: string
value: string,
};
type Parameter = {
name: string,
value: string
value: string,
};
export function filterParameters<T: Parameter>(parameters: Array<T>, name: string): Array<T> {
@@ -233,7 +233,7 @@ export function escapeRegex(str: string): string {
export function fuzzyMatch(
searchString: string,
text: string,
options: { splitSpace?: boolean, loose?: boolean } = {}
options: { splitSpace?: boolean, loose?: boolean } = {},
): null | { score: number, indexes: Array<number> } {
return fuzzyMatchAll(searchString, [text], options);
}
@@ -241,7 +241,7 @@ export function fuzzyMatch(
export function fuzzyMatchAll(
searchString: string,
allText: Array<string>,
options: { splitSpace?: boolean, loose?: boolean } = {}
options: { splitSpace?: boolean, loose?: boolean } = {},
): null | { score: number, indexes: Array<number> } {
if (!searchString || !searchString.trim()) {
return null;
+16 -16
View File
@@ -21,14 +21,14 @@ export const RENDER_PURPOSE_GENERAL: RenderPurpose = 'general';
export type RenderedRequest = Request & {
cookies: Array<{ name: string, value: string, disabled?: boolean }>,
cookieJar: CookieJar
cookieJar: CookieJar,
};
export async function buildRenderContext(
ancestors: Array<BaseModel> | null,
rootEnvironment: Environment | null,
subEnvironment: Environment | null,
baseContext: Object = {}
baseContext: Object = {},
): Object {
const envObjects = [];
@@ -77,7 +77,7 @@ export async function buildRenderContext(
renderContext, // Only render with key being overwritten
null,
KEEP_ON_ERROR,
'Environment'
'Environment',
);
} else {
// Otherwise it's just a regular replacement
@@ -101,7 +101,7 @@ export async function buildRenderContext(
finalRenderContext,
null,
KEEP_ON_ERROR,
'Environment'
'Environment',
);
}
}
@@ -123,7 +123,7 @@ export async function render<T>(
context: Object = {},
blacklistPathRegex: RegExp | null = null,
errorMode: string = THROW_ON_ERROR,
name: string = ''
name: string = '',
): Promise<T> {
// Make a deep copy so no one gets mad :)
const newObj = clone(obj);
@@ -193,13 +193,13 @@ export async function getRenderContext(
request: Request,
environmentId: string,
ancestors: Array<BaseModel> | null = null,
purpose: string | null = null
purpose: string | null = null,
): Promise<Object> {
if (!ancestors) {
ancestors = await db.withAncestors(request, [
models.request.type,
models.requestGroup.type,
models.workspace.type
models.workspace.type,
]);
}
@@ -209,7 +209,7 @@ export async function getRenderContext(
}
const rootEnvironment = await models.environment.getOrCreateForWorkspaceId(
workspace ? workspace._id : 'n/a'
workspace ? workspace._id : 'n/a',
);
const subEnvironment = await models.environment.getById(environmentId);
@@ -243,11 +243,11 @@ export async function getRenderContext(
const baseContext = {};
baseContext.getMeta = () => ({
requestId: request ? request._id : null,
workspaceId: workspace ? workspace._id : 'n/a'
workspaceId: workspace ? workspace._id : 'n/a',
});
baseContext.getKeysContext = () => ({
keyContext: keySource
keyContext: keySource,
});
baseContext.getPurpose = () => purpose;
@@ -259,12 +259,12 @@ export async function getRenderContext(
export async function getRenderedRequestAndContext(
request: Request,
environmentId: string,
purpose?: string
purpose?: string,
): Promise<{ request: RenderedRequest, context: Object }> {
const ancestors = await db.withAncestors(request, [
models.request.type,
models.requestGroup.type,
models.workspace.type
models.workspace.type,
]);
const workspace = ancestors.find(doc => doc.type === models.workspace.type);
const parentId = workspace ? workspace._id : 'n/a';
@@ -286,7 +286,7 @@ export async function getRenderedRequestAndContext(
const renderResult = await render(
{ _request: request, _cookieJar: cookieJar },
renderContext,
request.settingDisableRenderRequestBody ? /^body.*/ : null
request.settingDisableRenderRequestBody ? /^body.*/ : null,
);
const renderedRequest = renderResult._request;
@@ -341,15 +341,15 @@ export async function getRenderedRequestAndContext(
settingRebuildPath: renderedRequest.settingRebuildPath,
settingMaxTimelineDataSize: renderedRequest.settingMaxTimelineDataSize,
type: renderedRequest.type,
url: renderedRequest.url
}
url: renderedRequest.url,
},
};
}
export async function getRenderedRequest(
request: Request,
environmentId: string,
purpose?: string
purpose?: string,
): Promise<RenderedRequest> {
const result = await getRenderedRequestAndContext(request, environmentId, purpose);
return result.request;
@@ -12,5 +12,5 @@ export default [
'https://{{ shop }}.myshopify.com/admin/oauth/authorize',
'https://api.box.com/oauth2/token',
'https://api-ssl.bitly.com/oauth/access_token',
'https://api.imgur.com/oauth2/token'
'https://api.imgur.com/oauth2/token',
];
@@ -12,5 +12,5 @@ export default [
'https://todoist.com/oauth/authorize',
'https://account.box.com/api/oauth2/authorize',
'https://bitly.com/oauth/authorize',
'https://api.imgur.com/oauth2/authorize'
'https://api.imgur.com/oauth2/authorize',
];
@@ -117,5 +117,5 @@ export default [
'x-mac-icelandic',
'x-mac-japanese',
'x-mac-korean',
'x-mac-turkish'
'x-mac-turkish',
];
@@ -204,5 +204,5 @@ export default [
'video/x-f4v',
'video/x-fli',
'video/x-flv',
'video/x-m4v'
'video/x-m4v',
];
@@ -31,5 +31,5 @@ export default [
'User-Agent',
'Upgrade',
'Via',
'Warning'
'Warning',
];
@@ -109,7 +109,7 @@ async function _trackStats() {
lastLaunch: oldStats.currentLaunch,
currentVersion: getAppVersion(),
lastVersion: oldStats.currentVersion,
launches: oldStats.launches + 1
launches: oldStats.launches + 1,
});
// Update Stats Object
@@ -128,7 +128,7 @@ async function _trackStats() {
url: `${CHANGELOG_BASE_URL}/${currentVersion}/`,
cta: "See What's New",
message: `Updated to ${currentVersion}`,
email: 'support@insomnia.rest'
email: 'support@insomnia.rest',
};
// Wait a bit before showing the user because the app just launched.
+3 -3
View File
@@ -5,7 +5,7 @@ import {
getAppVersion,
isDevelopment,
UPDATE_URL_MAC,
UPDATE_URL_WINDOWS
UPDATE_URL_WINDOWS,
} from '../common/constants';
import * as models from '../models/index';
import { buildQueryStringFromParams, joinUrlAndQueryString } from 'insomnia-url';
@@ -28,7 +28,7 @@ async function getUpdateUrl(force: boolean): Promise<string | null> {
const params = [
{ name: 'v', value: getAppVersion() },
{ name: 'channel', value: settings.updateChannel }
{ name: 'channel', value: settings.updateChannel },
];
const qs = buildQueryStringFromParams(params);
@@ -131,7 +131,7 @@ async function _checkForUpdates(force: boolean) {
if (updateUrl === null) {
console.log(
`[updater] Updater not running platform=${process.platform} dev=${isDevelopment()}`
`[updater] Updater not running platform=${process.platform} dev=${isDevelopment()}`,
);
_sendUpdateComplete(false, 'Updates Not Supported');
return;
+40 -40
View File
@@ -10,7 +10,7 @@ import {
getAppName,
getAppVersion,
isDevelopment,
isMac
isMac,
} from '../common/constants';
import * as misc from '../common/misc';
@@ -59,8 +59,8 @@ export function createWindow() {
acceptFirstMouse: true,
icon: path.resolve(__dirname, 'static/icon.png'),
webPreferences: {
zoomFactor: zoomFactor
}
zoomFactor: zoomFactor,
},
});
// BrowserWindow doesn't have an option for this, so we have to do it manually :(
@@ -108,7 +108,7 @@ export function createWindow() {
return;
}
window.webContents.send('toggle-preferences');
}
},
},
{
label: `${MNEMONIC_SYM}Changelog`,
@@ -117,12 +117,12 @@ export function createWindow() {
return;
}
misc.clickLink(`${CHANGELOG_BASE_URL}/${getAppVersion()}/`);
}
},
},
...(isMac() ? [{ type: 'separator' }, { role: 'hide' }, { role: 'hideothers' }] : []),
{ type: 'separator' },
{ label: `${MNEMONIC_SYM}Quit`, accelerator: 'CmdOrCtrl+Q', click: () => app.quit() }
]
{ label: `${MNEMONIC_SYM}Quit`, accelerator: 'CmdOrCtrl+Q', click: () => app.quit() },
],
};
const editMenu = {
@@ -137,9 +137,9 @@ export function createWindow() {
{
label: `Select ${MNEMONIC_SYM}All`,
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:'
}
]
selector: 'selectAll:',
},
],
};
const viewMenu = {
@@ -158,7 +158,7 @@ export function createWindow() {
const zoomFactor = 1;
window.webContents.setZoomFactor(zoomFactor);
saveZoomFactor(zoomFactor);
}
},
},
{
label: `Zoom ${MNEMONIC_SYM}In`,
@@ -173,7 +173,7 @@ export function createWindow() {
window.webContents.setZoomFactor(zoomFactor);
saveZoomFactor(zoomFactor);
}
},
},
{
label: `Zoom ${MNEMONIC_SYM}Out`,
@@ -187,7 +187,7 @@ export function createWindow() {
const zoomFactor = Math.max(0.5, getZoomFactor() - 0.05);
window.webContents.setZoomFactor(zoomFactor);
saveZoomFactor(zoomFactor);
}
},
},
{
label: `Toggle ${MNEMONIC_SYM}Sidebar`,
@@ -199,13 +199,13 @@ export function createWindow() {
}
window.webContents.send('toggle-sidebar');
}
},
},
{
label: `Toggle ${MNEMONIC_SYM}DevTools`,
click: () => mainWindow.toggleDevTools()
}
]
click: () => mainWindow.toggleDevTools(),
},
],
};
const windowMenu = {
@@ -213,8 +213,8 @@ export function createWindow() {
role: 'window',
submenu: [
{ label: `${MNEMONIC_SYM}Minimize`, role: 'minimize' },
...(isMac() ? [{ label: `${MNEMONIC_SYM}Close`, role: 'close' }] : [])
]
...(isMac() ? [{ label: `${MNEMONIC_SYM}Close`, role: 'close' }] : []),
],
};
const helpMenu = {
@@ -226,7 +226,7 @@ export function createWindow() {
label: `Contact ${MNEMONIC_SYM}Support`,
click: () => {
shell.openExternal('https://insomnia.rest/support/');
}
},
},
{
label: `${MNEMONIC_SYM}Keyboard Shortcuts`,
@@ -236,23 +236,23 @@ export function createWindow() {
return;
}
window.webContents.send('toggle-preferences-shortcuts');
}
},
},
{
label: `Show App ${MNEMONIC_SYM}Data Folder`,
click: (menuItem, window, e) => {
const directory = misc.getDataDirectory();
shell.showItemInFolder(directory);
}
},
},
{
label: `Insomnia ${MNEMONIC_SYM}Help`,
accelerator: !isMac() ? 'F1' : null,
click: () => {
shell.openExternal('https://support.insomnia.rest');
}
}
]
},
},
],
};
if (!isMac()) {
@@ -270,10 +270,10 @@ export function createWindow() {
'V8 ' + process.versions.v8,
'Architecture ' + process.arch,
'', // Blank line before libcurl
Curl.getVersion()
].join('\n')
Curl.getVersion(),
].join('\n'),
});
}
},
});
}
@@ -284,12 +284,12 @@ export function createWindow() {
{
label: `${MNEMONIC_SYM}Reload`,
accelerator: 'Shift+F5',
click: () => mainWindow.reload()
click: () => mainWindow.reload(),
},
{
label: `Toggle ${MNEMONIC_SYM}DevTools`,
accelerator: 'Alt+CmdOrCtrl+I',
click: () => mainWindow.toggleDevTools()
click: () => mainWindow.toggleDevTools(),
},
{
label: `Resize to Defaul${MNEMONIC_SYM}t`,
@@ -298,8 +298,8 @@ export function createWindow() {
x: 100,
y: 100,
width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT
})
height: DEFAULT_HEIGHT,
}),
},
{
label: `Take ${MNEMONIC_SYM}Screenshot`,
@@ -309,9 +309,9 @@ export function createWindow() {
const dir = app.getPath('desktop');
fs.writeFileSync(path.join(dir, `Screenshot-${new Date()}.png`), buffer);
});
}
}
]
},
},
],
};
const toolsMenu = {
@@ -327,9 +327,9 @@ export function createWindow() {
}
window.webContents.send('reload-plugins');
}
}
]
},
},
],
};
let template = [];
@@ -358,14 +358,14 @@ function showUnresponsiveModal() {
defaultId: 1,
cancelId: 0,
title: 'Unresponsive',
message: 'Insomnia has become unresponsive. Do you want to reload?'
message: 'Insomnia has become unresponsive. Do you want to reload?',
},
id => {
if (id === 1) {
mainWindow.destroy();
createWindow();
}
}
},
);
}
@@ -11,7 +11,7 @@ const v1UUIDs = [
'f7273dba-f493-11e6-bc64-92361f002671',
'f7273eaa-f493-11e6-bc64-92361f002671',
'f7273f7c-f493-11e6-bc64-92361f002671',
'f7274300-f493-11e6-bc64-92361f002671'
'f7274300-f493-11e6-bc64-92361f002671',
];
const v4UUIDs = [
@@ -189,7 +189,7 @@ const v4UUIDs = [
'90160273-9bef-442b-aa36-393bdb3fcf38',
'4d02d9bc-d81b-41da-b1e0-2d1ffde96103',
'f8be054e-651d-4542-a3e4-681a4a2ec9d0',
'966e9995-938a-4a5e-813c-de3691dddb3a'
'966e9995-938a-4a5e-813c-de3691dddb3a',
];
function v1() {
@@ -21,7 +21,7 @@ describe('init()', () => {
settingDisableRenderRequestBody: false,
settingEncodeUrl: true,
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000
settingMaxTimelineDataSize: 1000,
});
});
});
@@ -34,7 +34,7 @@ describe('create()', async () => {
const request = await models.request.create({
name: 'Test Request',
parentId: 'fld_124',
description: 'A test Request'
description: 'A test Request',
});
const expected = {
_id: 'req_cc1dd2ca4275747aa88199e8efd42403',
@@ -57,7 +57,7 @@ describe('create()', async () => {
settingDisableRenderRequestBody: false,
settingEncodeUrl: true,
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000
settingMaxTimelineDataSize: 1000,
};
expect(request).toEqual(expected);
@@ -67,7 +67,7 @@ describe('create()', async () => {
it('fails when missing parentId', async () => {
Date.now = jest.fn().mockReturnValue(1478795580200);
expect(() => models.request.create({ name: 'Test Request' })).toThrow(
'New Requests missing `parentId`'
'New Requests missing `parentId`',
);
});
});
@@ -77,7 +77,7 @@ describe('updateMimeType()', async () => {
it('adds header when does not exist', async () => {
const request = await models.request.create({
name: 'My Request',
parentId: 'fld_1'
parentId: 'fld_1',
});
expect(request).not.toBeNull();
@@ -93,8 +93,8 @@ describe('updateMimeType()', async () => {
{ name: 'content-tYPE', value: 'application/json' },
{ name: 'foo', value: 'bar' },
{ bad: true },
null
]
null,
],
});
expect(request).not.toBeNull();
@@ -103,7 +103,7 @@ describe('updateMimeType()', async () => {
{ name: 'content-tYPE', value: 'text/html' },
{ name: 'foo', value: 'bar' },
{ bad: true },
null
null,
]);
});
@@ -111,7 +111,7 @@ describe('updateMimeType()', async () => {
const request = await models.request.create({
name: 'My Request',
parentId: 'fld_1',
headers: [{ name: 'content-tYPE', value: 'application/json' }]
headers: [{ name: 'content-tYPE', value: 'application/json' }],
});
expect(request).not.toBeNull();
@@ -123,7 +123,7 @@ describe('updateMimeType()', async () => {
const request = await models.request.create({
name: 'My Request',
parentId: 'fld_1',
headers: [{ name: 'content-tYPE', value: 'application/json' }]
headers: [{ name: 'content-tYPE', value: 'application/json' }],
});
expect(request).not.toBeNull();
@@ -137,13 +137,13 @@ describe('updateMimeType()', async () => {
name: 'My Request',
parentId: 'fld_1',
body: {
text: 'My Data'
}
text: 'My Data',
},
});
expect(request).not.toBeNull();
const newRequest = await models.request.updateMimeType(request, 'application/json', false, {
text: 'Saved Data'
text: 'Saved Data',
});
expect(newRequest.body.text).toEqual('Saved Data');
});
@@ -153,8 +153,8 @@ describe('updateMimeType()', async () => {
name: 'My Request',
parentId: 'fld_1',
body: {
text: 'My Data'
}
text: 'My Data',
},
});
expect(request).not.toBeNull();
@@ -168,13 +168,13 @@ describe('migrate()', () => {
it('migrates basic case', () => {
const original = {
headers: [],
body: 'hello world!'
body: 'hello world!',
};
const expected = {
headers: [],
body: { mimeType: '', text: 'hello world!' },
url: ''
url: '',
};
expect(models.request.migrate(original)).toEqual(expected);
@@ -183,16 +183,16 @@ describe('migrate()', () => {
it('migrates form-urlencoded', () => {
const original = {
headers: [{ name: 'content-type', value: 'application/x-www-form-urlencoded' }],
body: 'foo=bar&baz={{ hello }}'
body: 'foo=bar&baz={{ hello }}',
};
const expected = {
headers: [{ name: 'content-type', value: 'application/x-www-form-urlencoded' }],
body: {
mimeType: 'application/x-www-form-urlencoded',
params: [{ name: 'foo', value: 'bar' }, { name: 'baz', value: '{{ hello }}' }]
params: [{ name: 'foo', value: 'bar' }, { name: 'baz', value: '{{ hello }}' }],
},
url: ''
url: '',
};
expect(models.request.migrate(original)).toEqual(expected);
@@ -203,24 +203,24 @@ describe('migrate()', () => {
headers: [
{
name: 'content-type',
value: 'application/x-www-form-urlencoded; charset=utf-8'
}
value: 'application/x-www-form-urlencoded; charset=utf-8',
},
],
body: 'foo=bar&baz={{ hello }}'
body: 'foo=bar&baz={{ hello }}',
};
const expected = {
headers: [
{
name: 'content-type',
value: 'application/x-www-form-urlencoded; charset=utf-8'
}
value: 'application/x-www-form-urlencoded; charset=utf-8',
},
],
body: {
mimeType: 'application/x-www-form-urlencoded',
params: [{ name: 'foo', value: 'bar' }, { name: 'baz', value: '{{ hello }}' }]
params: [{ name: 'foo', value: 'bar' }, { name: 'baz', value: '{{ hello }}' }],
},
url: ''
url: '',
};
expect(models.request.migrate(original)).toEqual(expected);
@@ -229,16 +229,16 @@ describe('migrate()', () => {
it('migrates form-urlencoded malformed', () => {
const original = {
headers: [{ name: 'content-type', value: 'application/x-www-form-urlencoded' }],
body: '{"foo": "bar"}'
body: '{"foo": "bar"}',
};
const expected = {
headers: [{ name: 'content-type', value: 'application/x-www-form-urlencoded' }],
body: {
mimeType: 'application/x-www-form-urlencoded',
params: [{ name: '{"foo": "bar"}', value: '' }]
params: [{ name: '{"foo": "bar"}', value: '' }],
},
url: ''
url: '',
};
expect(models.request.migrate(original)).toEqual(expected);
@@ -248,19 +248,19 @@ describe('migrate()', () => {
const contentToMimeMap = {
'application/json; charset=utf-8': 'application/json',
'text/plain': 'text/plain',
malformed: 'malformed'
malformed: 'malformed',
};
for (const contentType of Object.keys(contentToMimeMap)) {
const original = {
headers: [{ name: 'content-type', value: contentType }],
body: ''
body: '',
};
const expected = {
headers: [{ name: 'content-type', value: contentType }],
body: { mimeType: contentToMimeMap[contentType], text: '' },
url: ''
url: '',
};
expect(models.request.migrate(original)).toEqual(expected);
@@ -269,7 +269,7 @@ describe('migrate()', () => {
it('skips migrate for schema 1', () => {
const original = {
body: { mimeType: 'text/plain', text: 'foo' }
body: { mimeType: 'text/plain', text: 'foo' },
};
expect(models.request.migrate(original)).toBe(original);
@@ -284,14 +284,14 @@ describe('migrate()', () => {
const expected = {
body: {
mimeType: '',
text: 'foo bar!'
text: 'foo bar!',
},
url: ''
url: '',
};
const expected2 = {
body: {},
url: ''
url: '',
};
expect(models.request.migrate(newBody)).toEqual(expected);
@@ -306,7 +306,7 @@ describe('migrate()', () => {
const original = {
_id: 'req_123',
headers: [],
body: 'hello world!'
body: 'hello world!',
};
const expected = {
@@ -330,7 +330,7 @@ describe('migrate()', () => {
settingDisableRenderRequestBody: false,
settingEncodeUrl: true,
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000
settingMaxTimelineDataSize: 1000,
};
const migrated = await models.initModel(models.request.type, original);
@@ -23,7 +23,7 @@ describe('migrate()', () => {
const newModel = await models.initModel(models.response.type, initialModel);
const expectedBodyPath = path.join(
getDataDirectory(),
`responses/fc3ff98e8c6a0d3087d515c0473f8677.zip`
`responses/fc3ff98e8c6a0d3087d515c0473f8677.zip`,
);
const storedBody = models.response.getBodyBuffer(newModel);
@@ -43,7 +43,7 @@ describe('migrate()', () => {
jest.runAllTimers();
const expectedBodyPath = path.join(
getDataDirectory(),
`responses/fc3ff98e8c6a0d3087d515c0473f8677.zip`
`responses/fc3ff98e8c6a0d3087d515c0473f8677.zip`,
);
const storedBody = models.response.getBodyBuffer(newModel);
@@ -65,7 +65,7 @@ describe('migrate()', () => {
const expectedBodyPath = path.join(
getDataDirectory(),
'responses/d41d8cd98f00b204e9800998ecf8427e.zip'
'responses/d41d8cd98f00b204e9800998ecf8427e.zip',
);
const storedBody = models.response.getBodyBuffer(newModel);
@@ -105,7 +105,7 @@ describe('migrate()', () => {
it('migrates old bodies', async () => {
const response = await models.initModel(models.response.type, {
body: 'aGVsbG8gd29ybGQh',
encoding: 'base64'
encoding: 'base64',
});
const body = await models.response.getBodyBuffer(response).toString();
@@ -117,16 +117,16 @@ describe('migrate()', () => {
expect(
(await models.initModel(models.response.type, {
bodyPath: '/foo/bar',
bodyCompression: null
})).bodyCompression
bodyCompression: null,
})).bodyCompression,
).toBe(null);
});
it('migrates sets bodyCompression to zip if does not have one yet', async () => {
expect(
(await models.initModel(models.response.type, {
bodyPath: '/foo/bar'
})).bodyCompression
bodyPath: '/foo/bar',
})).bodyCompression,
).toBe('zip');
});
@@ -134,8 +134,8 @@ describe('migrate()', () => {
expect(
(await models.initModel(models.response.type, {
bodyPath: '/foo/bar',
bodyCompression: 'zip'
})).bodyCompression
bodyCompression: 'zip',
})).bodyCompression,
).toBe('zip');
});
});
@@ -202,7 +202,7 @@ async function createModels(responsesDir, count) {
await models.workspace.create({
_id: workspaceId,
created: 111,
modified: 222
modified: 222,
});
await models.request.create({
_id: requestId,
@@ -210,7 +210,7 @@ async function createModels(responsesDir, count) {
created: 111,
modified: 222,
metaSortKey: 0,
url: 'https://insomnia.rest'
url: 'https://insomnia.rest',
});
await models.response.create({
@@ -218,7 +218,7 @@ async function createModels(responsesDir, count) {
parentId: requestId,
statusCode: 200,
body: 'foo',
bodyPath: path.join(responsesDir, responseId)
bodyPath: path.join(responsesDir, responseId),
});
responseIds.push(responseId);
}
@@ -6,7 +6,7 @@ describe('migrate()', () => {
it('migrates client certificates properly', async () => {
const workspace = await models.workspace.create({
name: 'My Workspace',
certificates: [{ key: 'key', passphrase: 'mypass' }, { disabled: true, cert: 'cert' }]
certificates: [{ key: 'key', passphrase: 'mypass' }, { disabled: true, cert: 'cert' }],
});
const migratedWorkspace = await models.workspace.migrate(workspace);
@@ -32,7 +32,7 @@ describe('migrate()', () => {
parentId: 'wrk_cc1dd2ca4275747aa88199e8efd42403',
passphrase: null,
pfx: null,
type: 'ClientCertificate'
type: 'ClientCertificate',
},
{
_id: 'crt_dd2ccc1a2745477a881a9e8ef9d42403',
@@ -44,8 +44,8 @@ describe('migrate()', () => {
parentId: 'wrk_cc1dd2ca4275747aa88199e8efd42403',
passphrase: 'mypass',
pfx: null,
type: 'ClientCertificate'
}
type: 'ClientCertificate',
},
]);
expect(migratedWorkspace.certificates).toBeUndefined();
@@ -17,7 +17,7 @@ type BaseClientCertificate = {
disabled: boolean,
// For sync control
isPrivate: boolean
isPrivate: boolean,
};
export type ClientCertificate = BaseModel & BaseClientCertificate;
@@ -31,7 +31,7 @@ export function init(): BaseClientCertificate {
cert: null,
key: null,
pfx: null,
isPrivate: false
isPrivate: false,
};
}
@@ -22,12 +22,12 @@ export type Cookie = {
creationIndex?: number,
hostOnly?: boolean,
pathIsDefault?: boolean,
lastAccessed?: Date
lastAccessed?: Date,
};
type BaseCookieJar = {
name: string,
cookies: Array<Cookie>
cookies: Array<Cookie>,
};
export type CookieJar = BaseModel & BaseCookieJar;
@@ -35,7 +35,7 @@ export type CookieJar = BaseModel & BaseCookieJar;
export function init() {
return {
name: 'Default Jar',
cookies: []
cookies: [],
};
}
@@ -15,7 +15,7 @@ type BaseEnvironment = {
metaSortKey: number,
// For sync control
isPrivate: boolean
isPrivate: boolean,
};
export type Environment = BaseModel & BaseEnvironment;
@@ -26,7 +26,7 @@ export function init() {
data: {},
color: null,
isPrivate: false,
metaSortKey: Date.now()
metaSortKey: Date.now(),
};
}
@@ -56,7 +56,7 @@ export async function getOrCreateForWorkspaceId(workspaceId: string): Promise<En
if (!environments.length) {
return create({
parentId: workspaceId,
name: 'Base Environment'
name: 'Base Environment',
});
}
+4 -4
View File
@@ -21,7 +21,7 @@ export type BaseModel = {
type: string,
parentId: string,
modified: number,
created: number
created: number,
};
// Reference to each model
@@ -57,7 +57,7 @@ export function all() {
response,
oAuth2Token,
clientCertificate,
pluginData
pluginData,
];
}
@@ -106,9 +106,9 @@ export async function initModel<T: BaseModel>(type: string, ...sources: Array<Ob
type: type,
parentId: null,
modified: Date.now(),
created: Date.now()
created: Date.now(),
},
model.init()
model.init(),
);
const fullObject = Object.assign({}, objectDefaults, ...sources);
@@ -15,7 +15,7 @@ type BaseOAuth2Token = {
// Error handling
error: string,
errorDescription: string,
errorUri: string
errorUri: string,
};
export type OAuth2Token = BaseModel & BaseOAuth2Token;
@@ -38,7 +38,7 @@ export function init(): BaseOAuth2Token {
// Error handling
error: '',
errorDescription: '',
errorUri: ''
errorUri: '',
};
}
@@ -10,7 +10,7 @@ export const canDuplicate = false;
type BasePluginData = {
plugin: string,
key: string,
value: string
value: string,
};
export type PluginData = BaseModel & BasePluginData;
@@ -19,7 +19,7 @@ export function init(): BasePluginData {
return {
plugin: '',
key: '',
value: ''
value: '',
};
}
@@ -8,7 +8,7 @@ export const canDuplicate = false;
export function init() {
return {
parentId: null,
collapsed: false
collapsed: false,
};
}
@@ -11,7 +11,7 @@ type BaseRequestGroup = {
name: string,
description: string,
environment: Object,
metaSortKey: number
metaSortKey: number,
};
export type RequestGroup = BaseModel & BaseRequestGroup;
@@ -21,7 +21,7 @@ export function init() {
name: 'New Folder',
description: '',
environment: {},
metaSortKey: -1 * Date.now()
metaSortKey: -1 * Date.now(),
};
}
@@ -13,7 +13,7 @@ export function init() {
responseFilter: '',
responseFilterHistory: [],
activeResponseId: null,
savedRequestBody: {}
savedRequestBody: {},
};
}
@@ -15,12 +15,12 @@ const FIELDS_TO_IGNORE = [
'metaSortKey',
'description',
'parentId',
'name'
'name',
];
export function init() {
return {
compressedRequest: null
compressedRequest: null,
};
}
+17 -17
View File
@@ -20,7 +20,7 @@ import {
getContentTypeFromHeaders,
HAWK_ALGORITHM_SHA256,
METHOD_GET,
METHOD_POST
METHOD_POST,
} from '../common/constants';
import * as db from '../common/database';
import { getContentTypeHeader } from '../common/misc';
@@ -38,7 +38,7 @@ export type RequestAuthentication = Object;
export type RequestHeader = {
name: string,
value: string,
disabled?: boolean
disabled?: boolean,
};
export type RequestParameter = {
@@ -46,7 +46,7 @@ export type RequestParameter = {
value: string,
disabled?: boolean,
id?: string,
fileName?: string
fileName?: string,
};
export type RequestBodyParameter = {
@@ -56,14 +56,14 @@ export type RequestBodyParameter = {
multiline?: string,
id?: string,
fileName?: string,
type?: string
type?: string,
};
export type RequestBody = {
mimeType?: string | null,
text?: string,
fileName?: string,
params?: Array<RequestBodyParameter>
params?: Array<RequestBodyParameter>,
};
type BaseRequest = {
@@ -84,7 +84,7 @@ type BaseRequest = {
settingDisableRenderRequestBody: boolean,
settingEncodeUrl: boolean,
settingRebuildPath: boolean,
settingMaxTimelineDataSize: number
settingMaxTimelineDataSize: number,
};
export type Request = BaseModel & BaseRequest;
@@ -108,7 +108,7 @@ export function init(): BaseRequest {
settingDisableRenderRequestBody: false,
settingEncodeUrl: true,
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000
settingMaxTimelineDataSize: 1000,
};
}
@@ -126,7 +126,7 @@ export function newAuth(type: string, oldAuth: RequestAuthentication = {}): Requ
type,
disabled: oldAuth.disabled || false,
username: oldAuth.username || '',
password: oldAuth.password || ''
password: oldAuth.password || '',
};
case AUTH_OAUTH_1:
@@ -142,14 +142,14 @@ export function newAuth(type: string, oldAuth: RequestAuthentication = {}): Requ
version: '1.0',
nonce: '',
timestamp: '',
callback: ''
callback: '',
};
// OAuth 2.0
case AUTH_OAUTH_2:
return {
type,
grantType: GRANT_TYPE_AUTHORIZATION_CODE
grantType: GRANT_TYPE_AUTHORIZATION_CODE,
};
// Aws IAM
@@ -159,14 +159,14 @@ export function newAuth(type: string, oldAuth: RequestAuthentication = {}): Requ
disabled: oldAuth.disabled || false,
accessKeyId: oldAuth.accessKeyId || '',
secretAccessKey: oldAuth.secretAccessKey || '',
sessionToken: oldAuth.sessionToken || ''
sessionToken: oldAuth.sessionToken || '',
};
// Hawk
case AUTH_HAWK:
return {
type,
algorithm: HAWK_ALGORITHM_SHA256
algorithm: HAWK_ALGORITHM_SHA256,
};
// Atlassian ASAP
@@ -178,7 +178,7 @@ export function newAuth(type: string, oldAuth: RequestAuthentication = {}): Requ
audience: '',
additionalClaims: '',
keyId: '',
privateKey: ''
privateKey: '',
};
// Types needing no defaults
@@ -204,21 +204,21 @@ export function newBodyRaw(rawBody: string, contentType?: string): RequestBody {
export function newBodyFormUrlEncoded(parameters: Array<RequestBodyParameter> | null): RequestBody {
return {
mimeType: CONTENT_TYPE_FORM_URLENCODED,
params: parameters || []
params: parameters || [],
};
}
export function newBodyFile(path: string): RequestBody {
return {
mimeType: CONTENT_TYPE_FILE,
fileName: path
fileName: path,
};
}
export function newBodyForm(parameters: Array<RequestBodyParameter>): RequestBody {
return {
mimeType: CONTENT_TYPE_FORM_DATA,
params: parameters || []
params: parameters || [],
};
}
@@ -253,7 +253,7 @@ export function updateMimeType(
request: Request,
mimeType: string,
doCreate: boolean = false,
savedBody: RequestBody = {}
savedBody: RequestBody = {},
): Promise<Request> {
let headers = request.headers ? [...request.headers] : [];
const contentTypeHeader = getContentTypeHeader(headers);
+7 -7
View File
@@ -19,12 +19,12 @@ export const canDuplicate = false;
export type ResponseHeader = {
name: string,
value: string
value: string,
};
export type ResponseTimelineEntry = {
name: string,
value: string
value: string,
};
type BaseResponse = {
@@ -45,7 +45,7 @@ type BaseResponse = {
// Things from the request
settingStoreCookies: boolean | null,
settingSendCookies: boolean | null
settingSendCookies: boolean | null,
};
export type Response = BaseModel & BaseResponse;
@@ -69,7 +69,7 @@ export function init(): BaseResponse {
// Things from the request
settingStoreCookies: null,
settingSendCookies: null
settingSendCookies: null,
};
}
@@ -111,7 +111,7 @@ export function remove(response: Response) {
export async function findRecentForRequest(
requestId: string,
limit: number
limit: number,
): Promise<Array<Response>> {
const responses = await db.findMostRecentlyModified(type, { parentId: requestId }, limit);
return responses;
@@ -159,7 +159,7 @@ export function getBodyBuffer<T>(response: Object, readFailureValue: ?T): Buffer
function getBodyStreamFromPath<T>(
bodyPath: string,
compression: string | null,
readFailureValue: ?T
readFailureValue: ?T,
): Readable | null | T {
// No body, so return empty Buffer
if (!bodyPath) {
@@ -184,7 +184,7 @@ function getBodyStreamFromPath<T>(
function getBodyBufferFromPath<T>(
bodyPath: string,
compression: string | null,
readFailureValue: ?T
readFailureValue: ?T,
): Buffer | T | null {
// No body, so return empty Buffer
if (!bodyPath) {
+2 -2
View File
@@ -32,7 +32,7 @@ type BaseSettings = {
fontMonospace: string | null,
fontInterface: string | null,
fontSize: number,
fontVariantLigatures: boolean
fontVariantLigatures: boolean,
};
export type Settings = BaseModel & BaseSettings;
@@ -72,7 +72,7 @@ export function init(): BaseSettings {
fontMonospace: null,
fontInterface: null,
fontSize: 13,
fontVariantLigatures: false
fontVariantLigatures: false,
};
}
+2 -2
View File
@@ -12,7 +12,7 @@ type BaseStats = {
lastLaunch: number | null,
currentVersion: string | null,
lastVersion: string | null,
launches: number
launches: number,
};
export type Stats = BaseModel & BaseStats;
@@ -23,7 +23,7 @@ export function init(): BaseStats {
lastLaunch: null,
currentVersion: null,
lastVersion: null,
launches: 0
launches: 0,
};
}
@@ -4,7 +4,7 @@ import * as db from '../common/database';
import {
DEFAULT_SIDEBAR_WIDTH,
DEFAULT_PANE_WIDTH,
DEFAULT_PANE_HEIGHT
DEFAULT_PANE_HEIGHT,
} from '../common/constants';
export const name = 'Workspace Meta';
@@ -20,7 +20,7 @@ type BaseWorkspaceMeta = {
sidebarWidth: number,
paneWidth: number,
paneHeight: number,
hasSeen: boolean
hasSeen: boolean,
};
export type WorkspaceMeta = BaseWorkspaceMeta & BaseModel;
@@ -35,7 +35,7 @@ export function init(): BaseWorkspaceMeta {
sidebarWidth: DEFAULT_SIDEBAR_WIDTH,
paneWidth: DEFAULT_PANE_WIDTH,
paneHeight: DEFAULT_PANE_HEIGHT,
hasSeen: true
hasSeen: true,
};
}
@@ -10,7 +10,7 @@ export const canDuplicate = true;
type BaseWorkspace = {
name: string,
description: string
description: string,
};
export type Workspace = BaseModel & BaseWorkspace;
@@ -18,7 +18,7 @@ export type Workspace = BaseModel & BaseWorkspace;
export function init() {
return {
name: 'New Workspace',
description: ''
description: '',
};
}
@@ -72,7 +72,7 @@ async function _migrateExtractClientCertificates(workspace: Workspace): Promise<
cert: cert.cert || null,
key: cert.key || null,
pfx: cert.pfx || null,
isPrivate: false
isPrivate: false,
});
}
@@ -12,7 +12,7 @@ describe('OAuth 1.0', () => {
tokenSecret: 'tokenSecret',
signatureMethod: 'HMAC-SHA1',
nonce: 'nonce',
timestamp: '1234567890'
timestamp: '1234567890',
});
expect(header).toEqual({
@@ -25,8 +25,8 @@ describe('OAuth 1.0', () => {
'oauth_signature_method="HMAC-SHA1"',
'oauth_timestamp="1234567890"',
'oauth_token="tokenKey"',
'oauth_version="1.0"'
].join(', ')
'oauth_version="1.0"',
].join(', '),
});
});
@@ -56,7 +56,7 @@ describe('OAuth 1.0', () => {
'F29dI2yG3Ti+28/WlSdfYGe9P9SfeYM7RQbNbUp1MHWrkg==\n' +
'-----END RSA PRIVATE KEY-----',
nonce: 'nonce',
timestamp: '1234567890'
timestamp: '1234567890',
});
expect(header).toEqual({
@@ -69,8 +69,8 @@ describe('OAuth 1.0', () => {
'oauth_signature_method="RSA-SHA1"',
'oauth_timestamp="1234567890"',
'oauth_token="tokenKey"',
'oauth_version="1.0"'
].join(', ')
'oauth_version="1.0"',
].join(', '),
});
});
@@ -79,7 +79,7 @@ describe('OAuth 1.0', () => {
type: AUTH_OAUTH_1,
consumerKey: 'consumerKey',
consumerSecret: 'consumerSecret',
signatureMethod: 'HMAC-SHA1'
signatureMethod: 'HMAC-SHA1',
});
expect(header.name).toBe('Authorization');
@@ -91,9 +91,9 @@ describe('OAuth 1.0', () => {
'oauth_signature="[\\w\\d%]*"',
'oauth_signature_method="HMAC-SHA1"',
'oauth_timestamp="\\d*"',
'oauth_version="1\\.0"'
].join(', ')
)
'oauth_version="1\\.0"',
].join(', '),
),
);
});
});
@@ -9,7 +9,7 @@ describe('buildMultipart()', () => {
it('builds a simple request', async () => {
const { filePath, boundary, contentLength } = await buildMultipart([
{ name: 'foo', value: 'bar' },
{ name: 'multi-line', value: 'Hello\nWorld!' }
{ name: 'multi-line', value: 'Hello\nWorld!' },
]);
expect(boundary).toBe(DEFAULT_BOUNDARY);
@@ -25,8 +25,8 @@ describe('buildMultipart()', () => {
'',
'Hello\nWorld!',
`--${boundary}--`,
''
].join('\r\n')
'',
].join('\r\n'),
);
});
@@ -35,7 +35,7 @@ describe('buildMultipart()', () => {
const { filePath, boundary, contentLength } = await buildMultipart([
{ name: 'foo', value: 'bar' },
{ name: 'file', type: 'file', fileName: fileName },
{ name: 'baz', value: 'qux' }
{ name: 'baz', value: 'qux' },
]);
expect(boundary).toBe(DEFAULT_BOUNDARY);
@@ -56,8 +56,8 @@ describe('buildMultipart()', () => {
'',
'qux',
`--${boundary}--`,
''
].join('\r\n')
'',
].join('\r\n'),
);
});
@@ -66,7 +66,7 @@ describe('buildMultipart()', () => {
{ value: 'bar' },
{ name: 'foo' },
{ name: '', value: '' },
{ name: '', type: 'file', fileName: '' }
{ name: '', type: 'file', fileName: '' },
]);
expect(boundary).toBe(DEFAULT_BOUNDARY);
@@ -82,8 +82,8 @@ describe('buildMultipart()', () => {
'',
'',
`--${boundary}--`,
''
].join('\r\n')
'',
].join('\r\n'),
);
});
});
@@ -10,7 +10,7 @@ import {
CONTENT_TYPE_FILE,
CONTENT_TYPE_FORM_DATA,
CONTENT_TYPE_FORM_URLENCODED,
getAppVersion
getAppVersion,
} from '../../common/constants';
import { filterHeaders } from '../../common/misc';
import { globalBeforeEach } from '../../__jest__/before-each';
@@ -32,7 +32,7 @@ describe('actuallySend()', () => {
domain: 'notlocalhost',
path: '/',
hostOnly: true,
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
lastAccessed: new Date('2096-10-05T04:40:49.505Z'),
},
{
creation: new Date('2016-10-05T04:40:49.505Z'),
@@ -42,14 +42,14 @@ describe('actuallySend()', () => {
domain: 'localhost',
path: '/',
hostOnly: true,
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
}
lastAccessed: new Date('2096-10-05T04:40:49.505Z'),
},
];
const cookieJar = await models.cookieJar.getOrCreateForParentId(workspace._id);
await models.cookieJar.update(cookieJar, {
parentId: workspace._id,
cookies
cookies,
});
const request = Object.assign(models.request.init(), {
@@ -60,14 +60,14 @@ describe('actuallySend()', () => {
method: 'POST',
body: {
mimeType: CONTENT_TYPE_FORM_URLENCODED,
params: [{ name: 'foo', value: 'bar' }]
params: [{ name: 'foo', value: 'bar' }],
},
url: 'http://localhost',
authentication: {
type: AUTH_BASIC,
username: 'user',
password: 'pass'
}
password: 'pass',
},
});
const renderedRequest = await getRenderedRequest(request);
@@ -75,7 +75,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -84,12 +84,12 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
COOKIELIST: [
'notlocalhost\tFALSE\t/\tFALSE\t4000855249\tfoo\tbarrrrr',
'localhost\tFALSE\t/\tFALSE\t4000855249\tfoo\tbar'
'localhost\tFALSE\t/\tFALSE\t4000855249\tfoo\tbar',
],
ACCEPT_ENCODING: '',
COOKIEFILE: '',
@@ -100,7 +100,7 @@ describe('actuallySend()', () => {
'Expect:',
'Transfer-Encoding:',
'Accept: */*',
'Accept-Encoding:'
'Accept-Encoding:',
],
NOPROGRESS: false,
USERNAME: 'user',
@@ -111,8 +111,8 @@ describe('actuallySend()', () => {
TIMEOUT_MS: 0,
URL: 'http://localhost/?foo%20bar=hello%26world',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -129,10 +129,10 @@ describe('actuallySend()', () => {
params: [
{ name: 'foo', value: 'bar' },
{ name: 'bar', value: '' },
{ name: '', value: 'value' }
]
{ name: '', value: 'value' },
],
},
url: 'http://localhost'
url: 'http://localhost',
});
const renderedRequest = await getRenderedRequest(request);
@@ -140,7 +140,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -149,7 +149,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
POST: 1,
@@ -161,7 +161,7 @@ describe('actuallySend()', () => {
'Expect:',
'Transfer-Encoding:',
'Accept: */*',
'Accept-Encoding:'
'Accept-Encoding:',
],
NOPROGRESS: false,
POSTFIELDS: 'foo=bar&bar=&=value',
@@ -169,8 +169,8 @@ describe('actuallySend()', () => {
TIMEOUT_MS: 0,
URL: 'http://localhost/',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -186,7 +186,7 @@ describe('actuallySend()', () => {
domain: 'notlocalhost',
path: '/',
hostOnly: true,
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
lastAccessed: new Date('2096-10-05T04:40:49.505Z'),
},
{
creation: new Date('2016-10-05T04:40:49.505Z'),
@@ -196,13 +196,13 @@ describe('actuallySend()', () => {
domain: 'localhost',
path: '/',
hostOnly: true,
lastAccessed: new Date('2096-10-05T04:40:49.505Z')
}
lastAccessed: new Date('2096-10-05T04:40:49.505Z'),
},
];
await models.cookieJar.create({
parentId: workspace._id,
cookies
cookies,
});
const request = Object.assign(models.request.init(), {
@@ -213,16 +213,16 @@ describe('actuallySend()', () => {
method: 'GET',
body: {
mimeType: CONTENT_TYPE_FORM_URLENCODED,
params: [{ name: 'foo', value: 'bar' }]
params: [{ name: 'foo', value: 'bar' }],
},
url: 'http://localhost',
authentication: {
type: AUTH_BASIC,
username: 'user',
password: 'pass'
password: 'pass',
},
settingStoreCookies: false,
settingSendCookies: false
settingSendCookies: false,
});
const renderedRequest = await getRenderedRequest(request);
@@ -230,7 +230,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -239,7 +239,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
CUSTOMREQUEST: 'GET',
@@ -250,7 +250,7 @@ describe('actuallySend()', () => {
'Expect:',
'Transfer-Encoding:',
'Accept: */*',
'Accept-Encoding:'
'Accept-Encoding:',
],
NOPROGRESS: false,
USERNAME: 'user',
@@ -260,8 +260,8 @@ describe('actuallySend()', () => {
TIMEOUT_MS: 0,
URL: 'http://localhost/?foo%20bar=hello%26world',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -277,7 +277,7 @@ describe('actuallySend()', () => {
headers: [{ name: 'Content-Type', value: 'application/octet-stream' }],
url: 'http://localhost',
method: 'POST',
body: { mimeType: CONTENT_TYPE_FILE, fileName }
body: { mimeType: CONTENT_TYPE_FILE, fileName },
});
const renderedRequest = await getRenderedRequest(request);
@@ -285,7 +285,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -295,7 +295,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
POST: 1,
@@ -308,7 +308,7 @@ describe('actuallySend()', () => {
'Expect:',
'Transfer-Encoding:',
'Accept: */*',
'Accept-Encoding:'
'Accept-Encoding:',
],
NOPROGRESS: false,
INFILESIZE_LARGE: 26,
@@ -318,8 +318,8 @@ describe('actuallySend()', () => {
UPLOAD: 1,
URL: 'http://localhost/',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -343,9 +343,9 @@ describe('actuallySend()', () => {
// Some extra params
{ name: 'a', value: 'AA' },
{ name: 'baz', value: 'qux', disabled: true }
]
}
{ name: 'baz', value: 'qux', disabled: true },
],
},
});
const renderedRequest = await getRenderedRequest(request);
@@ -353,7 +353,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
const body = JSON.parse(bodyBuffer);
@@ -361,7 +361,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
POST: 1,
@@ -374,7 +374,7 @@ describe('actuallySend()', () => {
'Expect:',
'Transfer-Encoding:',
'Accept: */*',
'Accept-Encoding:'
'Accept-Encoding:',
],
INFILESIZE_LARGE: 244,
NOPROGRESS: false,
@@ -389,15 +389,15 @@ describe('actuallySend()', () => {
'',
'AA',
`--${DEFAULT_BOUNDARY}--`,
''
'',
].join('\r\n'),
PROXY: '',
TIMEOUT_MS: 0,
URL: 'http://localhost/',
UPLOAD: 1,
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -409,7 +409,7 @@ describe('actuallySend()', () => {
_id: 'req_123',
parentId: workspace._id,
url: 'http://unix:/my/socket:/my/path',
method: 'GET'
method: 'GET',
});
const renderedRequest = await getRenderedRequest(request);
@@ -417,7 +417,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -426,7 +426,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
CUSTOMREQUEST: 'GET',
@@ -440,8 +440,8 @@ describe('actuallySend()', () => {
URL: 'http://my/path',
UNIX_SOCKET_PATH: '/my/socket',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -453,7 +453,7 @@ describe('actuallySend()', () => {
_id: 'req_123',
parentId: workspace._id,
url: 'http://localhost:3000/foo/bar',
method: 'HEAD'
method: 'HEAD',
});
const renderedRequest = await getRenderedRequest(request);
@@ -461,7 +461,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -470,7 +470,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
NOBODY: 1,
@@ -483,8 +483,8 @@ describe('actuallySend()', () => {
TIMEOUT_MS: 0,
URL: 'http://localhost:3000/foo/bar',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -496,7 +496,7 @@ describe('actuallySend()', () => {
_id: 'req_123',
parentId: workspace._id,
url: 'http://unix:3000/my/path',
method: 'GET'
method: 'GET',
});
const renderedRequest = await getRenderedRequest(request);
@@ -504,7 +504,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -513,7 +513,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
CUSTOMREQUEST: 'GET',
@@ -526,8 +526,8 @@ describe('actuallySend()', () => {
TIMEOUT_MS: 0,
URL: 'http://unix:3000/my/path',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
@@ -539,8 +539,8 @@ describe('actuallySend()', () => {
_id: 'req_123',
parentId: workspace._id,
authentication: {
type: AUTH_NETRC
}
type: AUTH_NETRC,
},
});
const renderedRequest = await getRenderedRequest(request);
@@ -548,7 +548,7 @@ describe('actuallySend()', () => {
renderedRequest,
CONTEXT,
workspace,
settings
settings,
);
const bodyBuffer = models.response.getBodyBuffer(response);
@@ -557,7 +557,7 @@ describe('actuallySend()', () => {
meta: {},
features: {
NO_HEADER_PARSING: true,
NO_DATA_PARSING: true
NO_DATA_PARSING: true,
},
options: {
CUSTOMREQUEST: 'GET',
@@ -571,8 +571,8 @@ describe('actuallySend()', () => {
NETRC: 2,
URL: '',
USERAGENT: `insomnia/${getAppVersion()}`,
VERBOSE: true
}
VERBOSE: true,
},
});
});
});
@@ -585,29 +585,29 @@ describe('_getAwsAuthHeaders', () => {
type: AUTH_AWS_IAM,
accessKeyId: 'AKIA99999999',
secretAccessKey: 'SAK9999999999999',
sessionToken: 'ST9999999999999999'
sessionToken: 'ST9999999999999999',
},
headers: [{ name: 'content-type', value: 'application/json' }],
body: { text: '{}' },
method: 'POST',
url: 'https://ec2.us-west-2.amazonaws.com/path?query=q1'
url: 'https://ec2.us-west-2.amazonaws.com/path?query=q1',
};
const credentials = {
accessKeyId: req.authentication.accessKeyId || '',
secretAccessKey: req.authentication.secretAccessKey || '',
sessionToken: req.authentication.sessionToken || ''
sessionToken: req.authentication.sessionToken || '',
};
const headers = networkUtils._getAwsAuthHeaders(
credentials,
req.headers,
req.body.text,
req.url,
req.method
req.method,
);
expect(filterHeaders(headers, 'x-amz-date')[0].value).toMatch(/^\d{8}T\d{6}Z$/);
expect(filterHeaders(headers, 'host')[0].value).toEqual('ec2.us-west-2.amazonaws.com');
expect(filterHeaders(headers, 'authorization')[0].value).toMatch(
/^AWS4-HMAC-SHA256 Credential=AKIA99999999\/\d{8}\/us-west-2\/ec2\/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-security-token, Signature=[a-z0-9]*$/
/^AWS4-HMAC-SHA256 Credential=AKIA99999999\/\d{8}\/us-west-2\/ec2\/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-security-token, Signature=[a-z0-9]*$/,
);
expect(filterHeaders(headers, 'content-type')).toEqual([]);
});
@@ -618,16 +618,16 @@ describe('_getAwsAuthHeaders', () => {
type: AUTH_AWS_IAM,
accessKeyId: 'AKIA99999999',
secretAccessKey: 'SAK9999999999999',
sessionToken: 'ST99999999999999'
sessionToken: 'ST99999999999999',
},
headers: ['Accept: */*', 'Accept-Encoding:'],
url: 'https://example.com',
method: 'GET'
method: 'GET',
};
const credentials = {
accessKeyId: req.authentication.accessKeyId || '',
secretAccessKey: req.authentication.secretAccessKey || '',
sessionToken: req.authentication.sessionToken || ''
sessionToken: req.authentication.sessionToken || '',
};
const headers = networkUtils._getAwsAuthHeaders(
credentials,
@@ -636,13 +636,13 @@ describe('_getAwsAuthHeaders', () => {
req.url,
req.method,
'us-west-2',
'ec2'
'ec2',
);
expect(filterHeaders(headers, 'x-amz-date')[0].value).toMatch(/^\d{8}T\d{6}Z$/);
expect(filterHeaders(headers, 'host')[0].value).toEqual('example.com');
expect(filterHeaders(headers, 'authorization')[0].value).toMatch(
/^AWS4-HMAC-SHA256 Credential=AKIA99999999\/\d{8}\/us-west-2\/ec2\/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=[a-z0-9]*$/
/^AWS4-HMAC-SHA256 Credential=AKIA99999999\/\d{8}\/us-west-2\/ec2\/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token, Signature=[a-z0-9]*$/,
);
expect(filterHeaders(headers, 'content-type')).toEqual([]);
});
@@ -660,7 +660,7 @@ describe('_parseHeaders', () => {
'Duplicate: bar',
'Date: Mon, 13 Nov 2017 22:06:28 GMT',
'Foo', // Invalid header
''
'',
];
const minimalHeaders = ['HTTP/1.1 301', ''];
@@ -680,9 +680,9 @@ describe('_parseHeaders', () => {
{ name: 'Duplicate', value: 'foo' },
{ name: 'Duplicate', value: 'bar' },
{ name: 'Date', value: 'Mon, 13 Nov 2017 22:06:28 GMT' },
{ name: 'Foo', value: '' }
]
}
{ name: 'Foo', value: '' },
],
},
]);
});
@@ -701,9 +701,9 @@ describe('_parseHeaders', () => {
{ name: 'Duplicate', value: 'foo' },
{ name: 'Duplicate', value: 'bar' },
{ name: 'Date', value: 'Mon, 13 Nov 2017 22:06:28 GMT' },
{ name: 'Foo', value: '' }
]
}
{ name: 'Foo', value: '' },
],
},
]);
});
@@ -723,15 +723,15 @@ describe('_parseHeaders', () => {
{ name: 'Duplicate', value: 'foo' },
{ name: 'Duplicate', value: 'bar' },
{ name: 'Date', value: 'Mon, 13 Nov 2017 22:06:28 GMT' },
{ name: 'Foo', value: '' }
]
{ name: 'Foo', value: '' },
],
},
{
code: 301,
headers: [],
reason: '',
version: 'HTTP/1.1'
}
version: 'HTTP/1.1',
},
]);
});
});
@@ -5,7 +5,7 @@ import {
AUTH_BEARER,
AUTH_HAWK,
AUTH_OAUTH_1,
AUTH_OAUTH_2
AUTH_OAUTH_2,
} from '../common/constants';
import getOAuth2Token from './o-auth-2/get-token';
import getOAuth1Token from './o-auth-1/get-token';
@@ -17,14 +17,14 @@ import { getBearerAuthHeader } from './bearer-auth/get-header';
type Header = {
name: string,
value: string
value: string,
};
export async function getAuthHeader(
requestId: string,
url: string,
method: string,
authentication: RequestAuthentication
authentication: RequestAuthentication,
): Promise<Header | null> {
if (authentication.disabled) {
return null;
@@ -61,7 +61,7 @@ export async function getAuthHeader(
if (oAuth1Token) {
return {
name: 'Authorization',
value: oAuth1Token.Authorization
value: oAuth1Token.Authorization,
};
} else {
return null;
@@ -72,11 +72,11 @@ export async function getAuthHeader(
const { id, key, algorithm, ext } = authentication;
const header = Hawk.client.header(url, method, {
credentials: { id, key, algorithm },
ext: ext
ext: ext,
});
return {
name: 'Authorization',
value: header.field
value: header.field,
};
}
@@ -97,7 +97,7 @@ export async function getAuthHeader(
if (parsedAdditionalClaims) {
if (typeof parsedAdditionalClaims !== 'object') {
throw new Error(
`additional-claims must be an object received: '${typeof parsedAdditionalClaims}' instead`
`additional-claims must be an object received: '${typeof parsedAdditionalClaims}' instead`,
);
}
@@ -106,7 +106,7 @@ export async function getAuthHeader(
const options = {
privateKey,
kid: keyId
kid: keyId,
};
return new Promise((resolve, reject) => {
@@ -116,7 +116,7 @@ export async function getAuthHeader(
} else {
resolve({
name: 'Authorization',
value: headerValue
value: headerValue,
});
}
});
@@ -7,7 +7,7 @@ describe('getBasicAuthHeader()', () => {
const header = getBasicAuthHeader('user', 'password');
expect(header).toEqual({
name: 'Authorization',
value: 'Basic dXNlcjpwYXNzd29yZA=='
value: 'Basic dXNlcjpwYXNzd29yZA==',
});
});
@@ -15,7 +15,7 @@ describe('getBasicAuthHeader()', () => {
const header = getBasicAuthHeader(null, 'password');
expect(header).toEqual({
name: 'Authorization',
value: 'Basic OnBhc3N3b3Jk'
value: 'Basic OnBhc3N3b3Jk',
});
});
@@ -23,7 +23,7 @@ describe('getBasicAuthHeader()', () => {
const header = getBasicAuthHeader('user', '');
expect(header).toEqual({
name: 'Authorization',
value: 'Basic dXNlcjo='
value: 'Basic dXNlcjo=',
});
});
@@ -31,7 +31,7 @@ describe('getBasicAuthHeader()', () => {
const header = getBasicAuthHeader('user', null);
expect(header).toEqual({
name: 'Authorization',
value: 'Basic dXNlcjo='
value: 'Basic dXNlcjo=',
});
});
});
@@ -28,7 +28,7 @@ export async function buildMultipart(params: Array<RequestBodyParameter>) {
});
stream.pipe(
writeStream,
{ end: false }
{ end: false },
);
totalSize += size;
});
@@ -58,7 +58,7 @@ export async function buildMultipart(params: Array<RequestBodyParameter>) {
addString(
'Content-Disposition: form-data; ' +
`name="${name.replace(/"/g, '\\"')}"; ` +
`filename="${path.basename(fileName).replace(/"/g, '\\"')}"`
`filename="${path.basename(fileName).replace(/"/g, '\\"')}"`,
);
addString(lineBreak);
addString(`Content-Type: ${contentType}`);
@@ -92,7 +92,7 @@ export async function buildMultipart(params: Array<RequestBodyParameter>) {
resolve({
boundary: DEFAULT_BOUNDARY,
filePath,
contentLength: totalSize
contentLength: totalSize,
});
});
+44 -44
View File
@@ -22,7 +22,7 @@ import {
CONTENT_TYPE_FORM_URLENCODED,
getAppVersion,
getTempDir,
STATUS_CODE_PLUGIN_ERROR
STATUS_CODE_PLUGIN_ERROR,
} from '../common/constants';
import {
delay,
@@ -37,13 +37,13 @@ import {
hasContentTypeHeader,
hasUserAgentHeader,
waitForStreamToFinish,
getDataDirectory
getDataDirectory,
} from '../common/misc';
import {
buildQueryStringFromParams,
joinUrlAndQueryString,
setDefaultProtocol,
smartEncodeUrl
smartEncodeUrl,
} from 'insomnia-url';
import fs from 'fs';
import * as db from '../common/database';
@@ -73,7 +73,7 @@ export type ResponsePatch = {
parentId?: string,
settingStoreCookies?: boolean,
settingSendCookies?: boolean,
timeline?: Array<ResponseTimelineEntry>
timeline?: Array<ResponseTimelineEntry>,
};
// Time since user's last keypress to wait before making the request
@@ -95,7 +95,7 @@ export async function _actuallySend(
renderedRequest: RenderedRequest,
renderContext: Object,
workspace: Workspace,
settings: Settings
settings: Settings,
): Promise<ResponsePatch> {
return new Promise(async resolve => {
let timeline: Array<ResponseTimelineEntry> = [];
@@ -115,7 +115,7 @@ export async function _actuallySend(
async function respond(
patch: ResponsePatch,
bodyPath: string | null,
noPlugins: boolean = false
noPlugins: boolean = false,
): Promise<void> {
const responsePatchBeforeHooks = Object.assign(
({
@@ -124,9 +124,9 @@ export async function _actuallySend(
timeline: timeline,
bodyPath: bodyPath || '',
settingSendCookies: renderedRequest.settingSendCookies,
settingStoreCookies: renderedRequest.settingStoreCookies
settingStoreCookies: renderedRequest.settingStoreCookies,
}: ResponsePatch),
patch
patch,
);
if (noPlugins) {
@@ -139,11 +139,11 @@ export async function _actuallySend(
responsePatch = await _applyResponsePluginHooks(
responsePatchBeforeHooks,
renderedRequest,
renderContext
renderContext,
);
} catch (err) {
handleError(
new Error(`[plugin] Response hook failed plugin=${err.plugin.name} err=${err.message}`)
new Error(`[plugin] Response hook failed plugin=${err.plugin.name} err=${err.message}`),
);
return;
}
@@ -161,10 +161,10 @@ export async function _actuallySend(
elapsedTime: 0,
statusMessage: 'Error',
settingSendCookies: renderedRequest.settingSendCookies,
settingStoreCookies: renderedRequest.settingStoreCookies
settingStoreCookies: renderedRequest.settingStoreCookies,
},
null,
true
true,
);
}
@@ -195,10 +195,10 @@ export async function _actuallySend(
bytesRead: curl.getInfo(Curl.info.SIZE_DOWNLOAD),
url: curl.getInfo(Curl.info.EFFECTIVE_URL),
statusMessage: 'Cancelled',
error: 'Request was cancelled'
error: 'Request was cancelled',
},
null,
true
true,
);
// Kill it!
@@ -297,7 +297,7 @@ export async function _actuallySend(
return 0;
},
true
true,
);
// Set the URL, including the query parameters
@@ -376,8 +376,8 @@ export async function _actuallySend(
cookie.secure ? 'TRUE' : 'FALSE',
expiresTimestamp,
cookie.key,
cookie.value
].join('\t')
cookie.value,
].join('\t'),
);
}
@@ -387,7 +387,7 @@ export async function _actuallySend(
addTimelineText(
'Enable cookie sending with jar of ' +
`${cookies.length} cookie${cookies.length !== 1 ? 's' : ''}`
`${cookies.length} cookie${cookies.length !== 1 ? 's' : ''}`,
);
} else {
addTimelineText('Disable cookie sending due to user setting');
@@ -474,7 +474,7 @@ export async function _actuallySend(
} else if (renderedRequest.body.mimeType === CONTENT_TYPE_FORM_DATA) {
const params = renderedRequest.body.params || [];
const { filePath: multipartBodyPath, boundary, contentLength } = await buildMultipart(
params
params,
);
// Extend the Content-Type header
@@ -484,7 +484,7 @@ export async function _actuallySend(
} else {
headers.push({
name: 'Content-Type',
value: `multipart/form-data; boundary=${boundary}`
value: `multipart/form-data; boundary=${boundary}`,
});
}
@@ -531,7 +531,7 @@ export async function _actuallySend(
headers.push({ name: 'Expect', value: DISABLE_HEADER_VALUE });
headers.push({
name: 'Transfer-Encoding',
value: DISABLE_HEADER_VALUE
value: DISABLE_HEADER_VALUE,
});
}
@@ -560,14 +560,14 @@ export async function _actuallySend(
} else if (renderedRequest.authentication.type === AUTH_AWS_IAM) {
if (!noBody && !requestBody) {
return handleError(
new Error('AWS authentication not supported for provided body type')
new Error('AWS authentication not supported for provided body type'),
);
}
const { authentication } = renderedRequest;
const credentials = {
accessKeyId: authentication.accessKeyId || '',
secretAccessKey: authentication.secretAccessKey || '',
sessionToken: authentication.sessionToken || ''
sessionToken: authentication.sessionToken || '',
};
const extraHeaders = _getAwsAuthHeaders(
@@ -577,7 +577,7 @@ export async function _actuallySend(
finalUrl,
renderedRequest.method,
authentication.region || '',
authentication.service || ''
authentication.service || '',
);
for (const header of extraHeaders) {
@@ -590,13 +590,13 @@ export async function _actuallySend(
renderedRequest._id,
finalUrl,
renderedRequest.method,
renderedRequest.authentication
renderedRequest.authentication,
);
if (authHeader) {
headers.push({
name: authHeader.name,
value: authHeader.value
value: authHeader.value,
});
}
}
@@ -721,7 +721,7 @@ export async function _actuallySend(
elapsedTime: curl.getInfo(Curl.info.TOTAL_TIME) * 1000,
bytesRead: curl.getInfo(Curl.info.SIZE_DOWNLOAD),
bytesContent: responseBodyBytes,
url: curl.getInfo(Curl.info.EFFECTIVE_URL)
url: curl.getInfo(Curl.info.EFFECTIVE_URL),
};
// Close the request
@@ -754,7 +754,7 @@ export async function _actuallySend(
export async function sendWithSettings(
requestId: string,
requestPatch: Object
requestPatch: Object,
): Promise<ResponsePatch> {
const request = await models.request.getById(requestId);
if (!request) {
@@ -765,7 +765,7 @@ export async function sendWithSettings(
const ancestors = await db.withAncestors(request, [
models.request.type,
models.requestGroup.type,
models.workspace.type
models.workspace.type,
]);
const workspaceDoc = ancestors.find(doc => doc.type === models.workspace.type);
@@ -780,7 +780,7 @@ export async function sendWithSettings(
const newRequest: Request = await models.initModel(models.request.type, requestPatch, {
_id: request._id + '.other',
parentId: request._id
parentId: request._id,
});
let renderResult: { request: RenderedRequest, context: Object };
@@ -814,7 +814,7 @@ export async function send(requestId: string, environmentId: string): Promise<Re
const ancestors = await db.withAncestors(request, [
models.request.type,
models.requestGroup.type,
models.workspace.type
models.workspace.type,
]);
if (!request) {
@@ -824,7 +824,7 @@ export async function send(requestId: string, environmentId: string): Promise<Re
const renderResult = await getRenderedRequestAndContext(
request,
environmentId,
RENDER_PURPOSE_SEND
RENDER_PURPOSE_SEND,
);
const renderedRequestBeforePlugins = renderResult.request;
@@ -840,7 +840,7 @@ export async function send(requestId: string, environmentId: string): Promise<Re
try {
renderedRequest = await _applyRequestPluginHooks(
renderedRequestBeforePlugins,
renderedContextBeforePlugins
renderedContextBeforePlugins,
);
} catch (err) {
return {
@@ -850,7 +850,7 @@ export async function send(requestId: string, environmentId: string): Promise<Re
statusCode: STATUS_CODE_PLUGIN_ERROR,
statusMessage: err.plugin ? `Plugin ${err.plugin.name}` : 'Plugin',
settingSendCookies: renderedRequestBeforePlugins.settingSendCookies,
settingStoreCookies: renderedRequestBeforePlugins.settingStoreCookies
settingStoreCookies: renderedRequestBeforePlugins.settingStoreCookies,
};
}
@@ -859,14 +859,14 @@ export async function send(requestId: string, environmentId: string): Promise<Re
async function _applyRequestPluginHooks(
renderedRequest: RenderedRequest,
renderedContext: Object
renderedContext: Object,
): Promise<RenderedRequest> {
const newRenderedRequest = clone(renderedRequest);
for (const { plugin, hook } of await plugins.getRequestHooks()) {
const context = {
...pluginContexts.app.init(),
...pluginContexts.store.init(plugin),
...pluginContexts.request.init(newRenderedRequest, renderedContext)
...pluginContexts.request.init(newRenderedRequest, renderedContext),
};
try {
@@ -883,7 +883,7 @@ async function _applyRequestPluginHooks(
async function _applyResponsePluginHooks(
response: ResponsePatch,
request: RenderedRequest,
renderContext: Object
renderContext: Object,
): Promise<ResponsePatch> {
const newResponse = clone(response);
const newRequest = clone(request);
@@ -893,7 +893,7 @@ async function _applyResponsePluginHooks(
...pluginContexts.app.init(),
...pluginContexts.store.init(plugin),
...pluginContexts.response.init(newResponse),
...pluginContexts.request.init(newRequest, renderContext, true)
...pluginContexts.request.init(newRequest, renderContext, true),
};
try {
@@ -908,12 +908,12 @@ async function _applyResponsePluginHooks(
}
export function _parseHeaders(
buffer: Buffer
buffer: Buffer,
): Array<{
headers: Array<ResponseHeader>,
version: string,
code: number,
reason: string
reason: string,
}> {
const results = [];
@@ -936,7 +936,7 @@ export function _parseHeaders(
version,
code: parseInt(code, 10),
reason: other.join(' '),
headers: []
headers: [],
};
} else {
const [name, value] = line.split(/:\s(.+)/);
@@ -953,14 +953,14 @@ export function _getAwsAuthHeaders(
credentials: {
accessKeyId: string,
secretAccessKey: string,
sessionToken: string
sessionToken: string,
},
headers: Array<RequestHeader>,
body: string,
url: string,
method: string,
region?: string,
service?: string
service?: string,
): Array<{ name: string, value: string, disabled?: boolean }> {
const parsedUrl = urlParse(url);
const contentTypeHeader = getContentTypeHeader(headers);
@@ -976,7 +976,7 @@ export function _getAwsAuthHeaders(
body,
method,
path: parsedUrl.path,
headers: contentTypeHeader ? { 'content-type': contentTypeHeader.value } : {}
headers: contentTypeHeader ? { 'content-type': contentTypeHeader.value } : {},
};
const signature = aws4.sign(awsSignOptions, credentials);
@@ -9,7 +9,7 @@ import {
SIGNATURE_METHOD_HMAC_SHA1,
SIGNATURE_METHOD_RSA_SHA1,
SIGNATURE_METHOD_PLAINTEXT,
SIGNATURE_METHOD_HMAC_SHA256
SIGNATURE_METHOD_HMAC_SHA256,
} from './constants';
import type { OAuth1SignatureMethod } from './constants';
import type { RequestAuthentication } from '../../models/request';
@@ -54,17 +54,17 @@ function hashFunction(signatureMethod: OAuth1SignatureMethod) {
export default async function(
url: string,
method: string,
authentication: RequestAuthentication
authentication: RequestAuthentication,
): { [string]: string } {
const oauth = new OAuth1({
consumer: {
key: authentication.consumerKey,
secret: authentication.consumerSecret
secret: authentication.consumerSecret,
},
signature_method: authentication.signatureMethod,
version: authentication.version,
hash_function: hashFunction(authentication.signatureMethod),
realm: authentication.realm || null
realm: authentication.realm || null,
});
const requestData = {
@@ -72,7 +72,7 @@ export default async function(
method: method,
data: {
// These are conditionally filled in below
}
},
};
if (authentication.callback) {
@@ -95,7 +95,7 @@ export default async function(
if (authentication.tokenKey && authentication.tokenSecret) {
token = {
key: authentication.tokenKey,
secret: authentication.tokenSecret
secret: authentication.tokenSecret,
};
} else if (authentication.tokenKey) {
token = { key: authentication.tokenKey };
@@ -26,8 +26,8 @@ describe('authorization_code', () => {
JSON.stringify({
access_token: 'token_123',
token_type: 'token_type',
scope: SCOPE
})
scope: SCOPE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -35,7 +35,7 @@ describe('authorization_code', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/json' }]
headers: [{ name: 'Content-Type', value: 'application/json' }],
}));
const result = await getToken(
@@ -47,7 +47,7 @@ describe('authorization_code', () => {
CLIENT_SECRET,
REDIRECT_URI,
SCOPE,
STATE
STATE,
);
// Check the request to fetch the token
@@ -63,25 +63,25 @@ describe('authorization_code', () => {
{ name: 'grant_type', value: 'authorization_code' },
{ name: 'code', value: 'code_123' },
{ name: 'redirect_uri', value: REDIRECT_URI },
{ name: 'state', value: STATE }
]
{ name: 'state', value: STATE },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
value: 'application/x-www-form-urlencoded, application/json',
},
{
name: 'Authorization',
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM='
}
]
}
]
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM=',
},
],
},
],
]);
// Check the expected value
@@ -94,7 +94,7 @@ describe('authorization_code', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403'
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403',
});
});
@@ -107,8 +107,8 @@ describe('authorization_code', () => {
JSON.stringify({
access_token: 'token_123',
token_type: 'token_type',
scope: SCOPE
})
scope: SCOPE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -116,7 +116,7 @@ describe('authorization_code', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }]
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }],
}));
const result = await getToken(
@@ -128,7 +128,7 @@ describe('authorization_code', () => {
CLIENT_SECRET,
REDIRECT_URI,
SCOPE,
STATE
STATE,
);
// Check the request to fetch the token
@@ -146,21 +146,21 @@ describe('authorization_code', () => {
{ name: 'redirect_uri', value: REDIRECT_URI },
{ name: 'state', value: STATE },
{ name: 'client_id', value: CLIENT_ID },
{ name: 'client_secret', value: CLIENT_SECRET }
]
{ name: 'client_secret', value: CLIENT_SECRET },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
]
}
]
value: 'application/x-www-form-urlencoded, application/json',
},
],
},
],
]);
// Check the expected value
@@ -173,7 +173,7 @@ describe('authorization_code', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d'
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d',
});
});
});
@@ -25,8 +25,8 @@ describe('client_credentials', () => {
token_type: 'token_type',
scope: SCOPE,
audience: AUDIENCE,
resource: RESOURCE
})
resource: RESOURCE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -34,7 +34,7 @@ describe('client_credentials', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/json' }]
headers: [{ name: 'Content-Type', value: 'application/json' }],
}));
const result = await getToken(
@@ -45,7 +45,7 @@ describe('client_credentials', () => {
CLIENT_SECRET,
SCOPE,
AUDIENCE,
RESOURCE
RESOURCE,
);
// Check the request to fetch the token
@@ -61,25 +61,25 @@ describe('client_credentials', () => {
{ name: 'grant_type', value: 'client_credentials' },
{ name: 'scope', value: SCOPE },
{ name: 'audience', value: AUDIENCE },
{ name: 'resource', value: RESOURCE }
]
{ name: 'resource', value: RESOURCE },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
value: 'application/x-www-form-urlencoded, application/json',
},
{
name: 'Authorization',
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM='
}
]
}
]
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM=',
},
],
},
],
]);
// Check the expected value
@@ -93,7 +93,7 @@ describe('client_credentials', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403'
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403',
});
});
@@ -107,8 +107,8 @@ describe('client_credentials', () => {
token_type: 'token_type',
scope: SCOPE,
audience: AUDIENCE,
resource: RESOURCE
})
resource: RESOURCE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -116,7 +116,7 @@ describe('client_credentials', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }]
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }],
}));
const result = await getToken(
@@ -127,7 +127,7 @@ describe('client_credentials', () => {
CLIENT_SECRET,
SCOPE,
AUDIENCE,
RESOURCE
RESOURCE,
);
// Check the request to fetch the token
@@ -145,21 +145,21 @@ describe('client_credentials', () => {
{ name: 'audience', value: AUDIENCE },
{ name: 'resource', value: RESOURCE },
{ name: 'client_id', value: CLIENT_ID },
{ name: 'client_secret', value: CLIENT_SECRET }
]
{ name: 'client_secret', value: CLIENT_SECRET },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
]
}
]
value: 'application/x-www-form-urlencoded, application/json',
},
],
},
],
]);
// Check the expected value
@@ -173,7 +173,7 @@ describe('client_credentials', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d'
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d',
});
});
});
@@ -25,7 +25,7 @@ describe('implicit', () => {
state: STATE,
error: null,
error_description: null,
error_uri: null
error_uri: null,
});
});
});
@@ -23,8 +23,8 @@ describe('password', () => {
JSON.stringify({
access_token: 'token_123',
token_type: 'token_type',
scope: SCOPE
})
scope: SCOPE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -32,7 +32,7 @@ describe('password', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/json' }]
headers: [{ name: 'Content-Type', value: 'application/json' }],
}));
const result = await getToken(
@@ -43,7 +43,7 @@ describe('password', () => {
CLIENT_SECRET,
USERNAME,
PASSWORD,
SCOPE
SCOPE,
);
// Check the request to fetch the token
@@ -59,25 +59,25 @@ describe('password', () => {
{ name: 'grant_type', value: 'password' },
{ name: 'username', value: USERNAME },
{ name: 'password', value: PASSWORD },
{ name: 'scope', value: SCOPE }
]
{ name: 'scope', value: SCOPE },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
value: 'application/x-www-form-urlencoded, application/json',
},
{
name: 'Authorization',
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM='
}
]
}
]
value: 'Basic Y2xpZW50XzEyMzpzZWNyZXRfMTIzNDU0NTY2Nzc3NTYzNDM=',
},
],
},
],
]);
// Check the expected value
@@ -90,7 +90,7 @@ describe('password', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403'
xResponseId: 'res_dd2ccc1a2745477a881a9e8ef9d42403',
});
});
@@ -102,8 +102,8 @@ describe('password', () => {
JSON.stringify({
access_token: 'token_123',
token_type: 'token_type',
scope: SCOPE
})
scope: SCOPE,
}),
);
network.sendWithSettings = jest.fn(() => ({
@@ -111,7 +111,7 @@ describe('password', () => {
bodyCompression: '',
parentId: 'req_1',
statusCode: 200,
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }]
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }],
}));
const result = await getToken(
@@ -122,7 +122,7 @@ describe('password', () => {
CLIENT_SECRET,
USERNAME,
PASSWORD,
SCOPE
SCOPE,
);
// Check the request to fetch the token
@@ -140,21 +140,21 @@ describe('password', () => {
{ name: 'password', value: PASSWORD },
{ name: 'scope', value: SCOPE },
{ name: 'client_id', value: CLIENT_ID },
{ name: 'client_secret', value: CLIENT_SECRET }
]
{ name: 'client_secret', value: CLIENT_SECRET },
],
},
headers: [
{
name: 'Content-Type',
value: 'application/x-www-form-urlencoded'
value: 'application/x-www-form-urlencoded',
},
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
]
}
]
value: 'application/x-www-form-urlencoded, application/json',
},
],
},
],
]);
// Check the expected value
@@ -167,7 +167,7 @@ describe('password', () => {
error: null,
error_uri: null,
error_description: null,
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d'
xResponseId: 'res_e3e96e5fdd6842298b66dee1f0940f3d',
});
});
});
@@ -16,7 +16,7 @@ import {
P_EXPIRES_IN,
P_REFRESH_TOKEN,
X_RESPONSE_ID,
X_ERROR
X_ERROR,
} from './constants';
import * as models from '../../models';
import type { RequestAuthentication } from '../../models/request';
@@ -26,7 +26,7 @@ import type { OAuth2Token } from '../../models/o-auth-2-token';
export default async function(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean = false
forceRefresh: boolean = false,
): Promise<OAuth2Token | null> {
switch (authentication.grantType) {
case GRANT_TYPE_AUTHORIZATION_CODE:
@@ -45,7 +45,7 @@ export default async function(
async function _getOAuth2AuthorizationCodeHeader(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean
forceRefresh: boolean,
): Promise<OAuth2Token | null> {
const oAuth2Token = await _getAccessToken(requestId, authentication, forceRefresh);
@@ -62,7 +62,7 @@ async function _getOAuth2AuthorizationCodeHeader(
authentication.clientSecret,
authentication.redirectUrl,
authentication.scope,
authentication.state
authentication.state,
);
return _updateOAuth2Token(requestId, results);
@@ -71,7 +71,7 @@ async function _getOAuth2AuthorizationCodeHeader(
async function _getOAuth2ClientCredentialsHeader(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean
forceRefresh: boolean,
): Promise<OAuth2Token | null> {
const oAuth2Token = await _getAccessToken(requestId, authentication, forceRefresh);
@@ -87,7 +87,7 @@ async function _getOAuth2ClientCredentialsHeader(
authentication.clientSecret,
authentication.scope,
authentication.audience,
authentication.resource
authentication.resource,
);
return _updateOAuth2Token(requestId, results);
@@ -96,7 +96,7 @@ async function _getOAuth2ClientCredentialsHeader(
async function _getOAuth2ImplicitHeader(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean
forceRefresh: boolean,
): Promise<OAuth2Token | null> {
const oAuth2Token = await _getAccessToken(requestId, authentication, forceRefresh);
@@ -112,7 +112,7 @@ async function _getOAuth2ImplicitHeader(
authentication.redirectUrl,
authentication.scope,
authentication.state,
authentication.audience
authentication.audience,
);
return _updateOAuth2Token(requestId, results);
@@ -121,7 +121,7 @@ async function _getOAuth2ImplicitHeader(
async function _getOAuth2PasswordHeader(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean
forceRefresh: boolean,
): Promise<OAuth2Token | null> {
const oAuth2Token = await _getAccessToken(requestId, authentication, forceRefresh);
@@ -137,7 +137,7 @@ async function _getOAuth2PasswordHeader(
authentication.clientSecret,
authentication.username,
authentication.password,
authentication.scope
authentication.scope,
);
return _updateOAuth2Token(requestId, results);
@@ -146,7 +146,7 @@ async function _getOAuth2PasswordHeader(
async function _getAccessToken(
requestId: string,
authentication: RequestAuthentication,
forceRefresh: boolean
forceRefresh: boolean,
): Promise<OAuth2Token | null> {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// See if we have a token already //
@@ -187,7 +187,7 @@ async function _getAccessToken(
authentication.clientId,
authentication.clientSecret,
token.refreshToken,
authentication.scope
authentication.scope,
);
// ~~~~~~~~~~~~~ //
@@ -214,6 +214,6 @@ async function _updateOAuth2Token(requestId: string, authResults: Object): Promi
// Special Cases
xResponseId: authResults[X_RESPONSE_ID] || null,
xError: authResults[X_ERROR] || null
xError: authResults[X_ERROR] || null,
});
}
@@ -17,7 +17,7 @@ export default async function(
clientSecret: string,
redirectUri: string = '',
scope: string = '',
state: string = ''
state: string = '',
): Promise<Object> {
if (!authorizeUrl) {
throw new Error('Invalid authorization URL');
@@ -45,14 +45,14 @@ export default async function(
clientSecret,
authorizeResults[c.P_CODE],
redirectUri,
state
state,
);
}
async function _authorize(url, clientId, redirectUri = '', scope = '', state = '') {
const params = [
{ name: c.P_RESPONSE_TYPE, value: c.RESPONSE_TYPE_CODE },
{ name: c.P_CLIENT_ID, value: clientId }
{ name: c.P_CLIENT_ID, value: clientId },
];
// Add optional params
@@ -76,7 +76,7 @@ async function _authorize(url, clientId, redirectUri = '', scope = '', state = '
c.P_STATE,
c.P_ERROR,
c.P_ERROR_DESCRIPTION,
c.P_ERROR_URI
c.P_ERROR_URI,
]);
}
@@ -88,11 +88,11 @@ async function _getToken(
clientSecret: string,
code: string,
redirectUri: string = '',
state: string = ''
state: string = '',
): Promise<Object> {
const params = [
{ name: c.P_GRANT_TYPE, value: c.GRANT_TYPE_AUTHORIZATION_CODE },
{ name: c.P_CODE, value: code }
{ name: c.P_CODE, value: code },
];
// Add optional params
@@ -103,8 +103,8 @@ async function _getToken(
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
value: 'application/x-www-form-urlencoded, application/json',
},
];
if (credentialsInBody) {
@@ -118,7 +118,7 @@ async function _getToken(
headers,
url,
method: 'POST',
body: models.request.newBodyFormUrlEncoded(params)
body: models.request.newBodyFormUrlEncoded(params),
});
const response = await models.response.create(responsePatch);
@@ -127,7 +127,7 @@ async function _getToken(
if (!bodyBuffer) {
return {
[c.X_ERROR]: `No body returned from ${url}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -135,7 +135,7 @@ async function _getToken(
if (statusCode < 200 || statusCode >= 300) {
return {
[c.X_ERROR]: `Failed to fetch token url=${url} status=${statusCode}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -147,7 +147,7 @@ async function _getToken(
c.P_SCOPE,
c.P_ERROR,
c.P_ERROR_URI,
c.P_ERROR_DESCRIPTION
c.P_ERROR_DESCRIPTION,
]);
results[c.X_RESPONSE_ID] = response._id;
@@ -14,7 +14,7 @@ export default async function(
clientSecret: string,
scope: string = '',
audience: string = '',
resource: string = ''
resource: string = '',
): Promise<Object> {
const params = [{ name: c.P_GRANT_TYPE, value: c.GRANT_TYPE_CLIENT_CREDENTIALS }];
@@ -27,8 +27,8 @@ export default async function(
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
value: 'application/x-www-form-urlencoded, application/json',
},
];
if (credentialsInBody) {
@@ -44,7 +44,7 @@ export default async function(
headers,
url,
method: 'POST',
body: models.request.newBodyFormUrlEncoded(params)
body: models.request.newBodyFormUrlEncoded(params),
});
const response = await models.response.create(responsePatch);
@@ -53,7 +53,7 @@ export default async function(
if (!bodyBuffer) {
return {
[c.X_ERROR]: `No body returned from ${url}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -61,7 +61,7 @@ export default async function(
if (statusCode < 200 || statusCode >= 300) {
return {
[c.X_ERROR]: `Failed to fetch token url=${url} status=${statusCode}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -74,7 +74,7 @@ export default async function(
c.P_RESOURCE,
c.P_ERROR,
c.P_ERROR_URI,
c.P_ERROR_DESCRIPTION
c.P_ERROR_DESCRIPTION,
]);
results[c.X_RESPONSE_ID] = response._id;
@@ -11,11 +11,11 @@ export default async function(
redirectUri: string = '',
scope: string = '',
state: string = '',
audience: string = ''
audience: string = '',
): Promise<Object> {
const params = [
{ name: c.P_RESPONSE_TYPE, value: responseType },
{ name: c.P_CLIENT_ID, value: clientId }
{ name: c.P_CLIENT_ID, value: clientId },
];
// Add optional params
@@ -48,7 +48,7 @@ export default async function(
c.P_STATE,
c.P_ERROR,
c.P_ERROR_DESCRIPTION,
c.P_ERROR_URI
c.P_ERROR_URI,
]);
} else {
// Bad redirect
@@ -14,12 +14,12 @@ export default async function(
clientSecret: string,
username: string,
password: string,
scope: string = ''
scope: string = '',
): Promise<Object> {
const params = [
{ name: c.P_GRANT_TYPE, value: c.GRANT_TYPE_PASSWORD },
{ name: c.P_USERNAME, value: username },
{ name: c.P_PASSWORD, value: password }
{ name: c.P_PASSWORD, value: password },
];
// Add optional params
@@ -29,8 +29,8 @@ export default async function(
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
value: 'application/x-www-form-urlencoded, application/json',
},
];
if (credentialsInBody) {
@@ -46,7 +46,7 @@ export default async function(
url,
headers,
method: 'POST',
body: models.request.newBodyFormUrlEncoded(params)
body: models.request.newBodyFormUrlEncoded(params),
});
const response = await models.response.create(responsePatch);
@@ -55,7 +55,7 @@ export default async function(
if (!bodyBuffer) {
return {
[c.X_ERROR]: `No body returned from ${url}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -63,7 +63,7 @@ export default async function(
if (statusCode < 200 || statusCode >= 300) {
return {
[c.X_ERROR]: `Failed to fetch token url=${url} status=${statusCode}`,
[c.X_RESPONSE_ID]: response._id
[c.X_RESPONSE_ID]: response._id,
};
}
@@ -75,7 +75,7 @@ export default async function(
c.P_SCOPE,
c.P_ERROR,
c.P_ERROR_URI,
c.P_ERROR_DESCRIPTION
c.P_ERROR_DESCRIPTION,
]);
results[c.X_RESPONSE_ID] = response._id;
@@ -27,7 +27,7 @@ export function responseToObject(body, keys) {
export function authorizeUserInWindow(
url,
urlSuccessRegex = /(code=).*/,
urlFailureRegex = /(error=).*/
urlFailureRegex = /(error=).*/,
) {
return new Promise((resolve, reject) => {
let finalUrl = null;
@@ -35,13 +35,13 @@ export function authorizeUserInWindow(
function _parseUrl(currentUrl) {
if (currentUrl.match(urlSuccessRegex)) {
console.log(
`[oauth2] Matched success redirect to "${currentUrl}" with ${urlSuccessRegex.toString()}`
`[oauth2] Matched success redirect to "${currentUrl}" with ${urlSuccessRegex.toString()}`,
);
finalUrl = currentUrl;
child.close();
} else if (currentUrl.match(urlFailureRegex)) {
console.log(
`[oauth2] Matched error redirect to "${currentUrl}" with ${urlFailureRegex.toString()}`
`[oauth2] Matched error redirect to "${currentUrl}" with ${urlFailureRegex.toString()}`,
);
finalUrl = currentUrl;
child.close();
@@ -50,7 +50,7 @@ export function authorizeUserInWindow(
console.log(`[oauth2] Loaded "${currentUrl}"`);
} else {
console.log(
`[oauth2] Ignoring URL "${currentUrl}". Didn't match ${urlSuccessRegex.toString()}`
`[oauth2] Ignoring URL "${currentUrl}". Didn't match ${urlSuccessRegex.toString()}`,
);
}
}
@@ -59,9 +59,9 @@ export function authorizeUserInWindow(
const child = new electron.remote.BrowserWindow({
webPreferences: {
nodeIntegration: false,
partition: `oauth2_${AUTH_WINDOW_SESSION_ID}`
partition: `oauth2_${AUTH_WINDOW_SESSION_ID}`,
},
show: false
show: false,
});
// Finish on close
@@ -13,11 +13,11 @@ export default async function(
clientId: string,
clientSecret: string,
refreshToken: string,
scope: string
scope: string,
): Promise<Object> {
const params = [
{ name: c.P_GRANT_TYPE, value: c.GRANT_TYPE_REFRESH },
{ name: c.P_REFRESH_TOKEN, value: refreshToken }
{ name: c.P_REFRESH_TOKEN, value: refreshToken },
];
// Add optional params
@@ -27,8 +27,8 @@ export default async function(
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
{
name: 'Accept',
value: 'application/x-www-form-urlencoded, application/json'
}
value: 'application/x-www-form-urlencoded, application/json',
},
];
if (credentialsInBody) {
@@ -44,7 +44,7 @@ export default async function(
headers,
url,
method: 'POST',
body: models.request.newBodyFormUrlEncoded(params)
body: models.request.newBodyFormUrlEncoded(params),
});
const statusCode = response.statusCode || 0;
@@ -65,7 +65,7 @@ export default async function(
c.P_SCOPE,
c.P_ERROR,
c.P_ERROR_URI,
c.P_ERROR_DESCRIPTION
c.P_ERROR_DESCRIPTION,
]);
return results;
@@ -12,7 +12,7 @@ describe('init()', () => {
'alert',
'getPath',
'prompt',
'showSaveDialog'
'showSaveDialog',
]);
});
});
@@ -40,7 +40,7 @@ describe('app.alert()', () => {
// Make sure it passes correct arguments
expect(modals.showAlert.mock.calls).toEqual([
[{ title: 'Title' }],
[{ title: 'Title', message: 'Message' }]
[{ title: 'Title', message: 'Message' }],
]);
});
});
@@ -71,17 +71,17 @@ describe('app.prompt()', () => {
{
title: 'Title',
onComplete: expect.any(Function),
onCancel: expect.any(Function)
}
onCancel: expect.any(Function),
},
],
[
{
title: 'Title',
label: 'Label',
onComplete: expect.any(Function),
onCancel: expect.any(Function)
}
]
onCancel: expect.any(Function),
},
],
]);
});
});
@@ -11,7 +11,7 @@ const PLUGIN = {
name: 'my-plugin',
version: '1.0.0',
directory: '/plugins/my-plugin',
module: {}
module: {},
};
describe('init()', () => {
@@ -30,7 +30,7 @@ describe('app.import.*', () => {
await models.workspace.create({
_id: 'wrk_1',
created: 111,
modified: 222
modified: 222,
});
});
it('uri', async () => {
@@ -53,8 +53,8 @@ describe('app.import.*', () => {
description: '',
name: 'New',
parentId: null,
type: 'Workspace'
}
type: 'Workspace',
},
]);
expect(await db.all(models.request.type)).toEqual([
{
@@ -78,8 +78,8 @@ describe('app.import.*', () => {
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000,
type: 'Request',
url: 'https://insomnia.rest'
}
url: 'https://insomnia.rest',
},
]);
});
@@ -103,8 +103,8 @@ describe('app.import.*', () => {
description: '',
name: 'New',
parentId: null,
type: 'Workspace'
}
type: 'Workspace',
},
]);
expect(await db.all(models.request.type)).toEqual([
{
@@ -128,8 +128,8 @@ describe('app.import.*', () => {
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000,
type: 'Request',
url: 'https://insomnia.rest'
}
url: 'https://insomnia.rest',
},
]);
});
});
@@ -140,7 +140,7 @@ describe('app.export.*', () => {
await models.workspace.create({
_id: 'wrk_1',
created: 111,
modified: 222
modified: 222,
});
await models.request.create({
_id: 'req_1',
@@ -148,13 +148,13 @@ describe('app.export.*', () => {
created: 111,
modified: 222,
metaSortKey: 0,
url: 'https://insomnia.rest'
url: 'https://insomnia.rest',
});
await models.response.create({
_id: 'res_1',
parentId: 'req_1',
statusCode: 200,
body: 'foo'
body: 'foo',
});
});
@@ -179,7 +179,7 @@ describe('app.export.*', () => {
description: '',
modified: 222,
name: 'New Workspace',
parentId: null
parentId: null,
},
{
_id: 'req_1',
@@ -202,9 +202,9 @@ describe('app.export.*', () => {
settingStoreCookies: true,
settingRebuildPath: true,
settingMaxTimelineDataSize: 1000,
url: 'https://insomnia.rest'
}
]
url: 'https://insomnia.rest',
},
],
});
});
@@ -219,7 +219,7 @@ describe('app.export.*', () => {
log: {
creator: {
name: 'Insomnia REST Client',
version: `insomnia.desktop.app:v${getAppVersion()}`
version: `insomnia.desktop.app:v${getAppVersion()}`,
},
entries: [
{
@@ -235,18 +235,18 @@ describe('app.export.*', () => {
postData: {
mimeType: '',
params: [],
text: ''
text: '',
},
queryString: [],
url: 'https://insomnia.rest/',
settingEncodeUrl: true
settingEncodeUrl: true,
},
response: {
bodySize: -1,
content: {
mimeType: '',
size: 3,
text: 'foo'
text: 'foo',
},
cookies: [],
headers: [],
@@ -254,7 +254,7 @@ describe('app.export.*', () => {
httpVersion: 'HTTP/1.1',
redirectURL: '',
status: 200,
statusText: ''
statusText: '',
},
startedDateTime: '2017-11-24T18:12:12.849Z',
time: 0,
@@ -265,12 +265,12 @@ describe('app.export.*', () => {
receive: 0,
send: 0,
ssl: -1,
wait: 0
}
}
wait: 0,
},
},
],
version: '1.2'
}
version: '1.2',
},
});
});
});
@@ -7,7 +7,7 @@ const CONTEXT = {
hello: 'world',
array_test: ['a', 'b'],
object_test: { a: 'A', b: 'B' },
null_test: null
null_test: null,
};
describe('init()', () => {
@@ -17,7 +17,7 @@ describe('init()', () => {
await models.request.create({
_id: 'req_1',
parentId: 'wrk_1',
name: 'My Request'
name: 'My Request',
});
});
@@ -49,7 +49,7 @@ describe('init()', () => {
'settingDisableRenderRequestBody',
'settingEncodeUrl',
'settingSendCookies',
'settingStoreCookies'
'settingStoreCookies',
]);
});
@@ -69,7 +69,7 @@ describe('init()', () => {
'getParameters',
'getUrl',
'hasHeader',
'hasParameter'
'hasParameter',
]);
});
@@ -89,9 +89,9 @@ describe('request.*', () => {
body: { text: 'body' },
headers: [
{ name: 'hello', value: 'world' },
{ name: 'Content-Type', value: 'application/json' }
{ name: 'Content-Type', value: 'application/json' },
],
parameters: [{ name: 'foo', value: 'bar' }, { name: 'message', value: 'Hello World!' }]
parameters: [{ name: 'foo', value: 'bar' }, { name: 'message', value: 'Hello World!' }],
});
});
@@ -110,7 +110,7 @@ describe('request.*', () => {
// getParameters()
expect(result.request.getParameters()).toEqual([
{ name: 'foo', value: 'bar' },
{ name: 'message', value: 'Hello World!' }
{ name: 'message', value: 'Hello World!' },
]);
// getParameter()
@@ -141,7 +141,7 @@ describe('request.*', () => {
// getHeaders()
expect(result.request.getHeaders()).toEqual([
{ name: 'hello', value: 'world' },
{ name: 'Content-Type', value: 'application/json' }
{ name: 'Content-Type', value: 'application/json' },
]);
// getHeader()
@@ -189,7 +189,7 @@ describe('request.*', () => {
hello: 'world',
array_test: ['a', 'b'],
object_test: { a: 'A', b: 'B' },
null_test: null
null_test: null,
});
// getEnvironmentVariable
@@ -198,7 +198,7 @@ describe('request.*', () => {
expect(result.request.getEnvironmentVariable('array_test')).toEqual(['a', 'b']);
expect(result.request.getEnvironmentVariable('object_test')).toEqual({
a: 'A',
b: 'B'
b: 'B',
});
expect(result.request.getEnvironmentVariable('null_test')).toBe(null);
expect(result.request.getEnvironmentVariable('bad')).toBeUndefined();
@@ -20,7 +20,7 @@ describe('init()', () => {
'getStatusMessage',
'getTime',
'hasHeader',
'setBody'
'setBody',
]);
});
@@ -42,7 +42,7 @@ describe('response.*', () => {
statusCode: 200,
statusMessage: 'OK',
bytesRead: 123,
elapsedTime: 321
elapsedTime: 321,
});
const result = plugin.init(response);
expect(result.response.getRequestId()).toBe('req_1');
@@ -66,8 +66,8 @@ describe('response.*', () => {
headers: [
{ name: 'content-type', value: 'application/json' },
{ name: 'set-cookie', value: 'foo=bar' },
{ name: 'set-cookie', value: 'baz=qux' }
]
{ name: 'set-cookie', value: 'baz=qux' },
],
};
const result = plugin.init(response);
expect(result.response.getHeader('Does-Not-Exist')).toBeNull();
@@ -5,7 +5,7 @@ const PLUGIN = {
name: 'my-plugin',
version: '1.0.0',
directory: '/plugins/my-plugin',
module: {}
module: {},
};
describe('init()', () => {
@@ -18,7 +18,7 @@ describe('init()', () => {
'getItem',
'hasItem',
'removeItem',
'setItem'
'setItem',
]);
});
});
@@ -49,7 +49,7 @@ describe('store.*', () => {
expect(all.sort((a, b) => (a.key < b.key ? -1 : 1))).toEqual([
{ key: 'a', value: 'aaa' },
{ key: 'b', value: 'bbb' },
{ key: 'c', value: 'ccc' }
{ key: 'c', value: 'ccc' },
]);
// Clear it
@@ -20,8 +20,8 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
label?: string,
defaultValue?: string,
submitName?: string,
cancelable?: boolean
}
cancelable?: boolean,
},
): Promise<string> {
options = options || {};
@@ -38,7 +38,7 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
},
onComplete(value: string) {
resolve(value);
}
},
});
});
},
@@ -59,14 +59,14 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
const saveOptions = {
title: 'Save File',
buttonLabel: 'Save',
defaultPath: options.defaultPath
defaultPath: options.defaultPath,
};
electron.remote.dialog.showSaveDialog(saveOptions, filename => {
resolve(filename || null);
});
});
}
}
},
},
};
}
@@ -9,7 +9,7 @@ export function init(): { import: Object, export: Object } {
},
async raw(text: string, options: { workspaceId?: string } = {}): Promise<void> {
await importRaw(options.workspaceId || null, text);
}
},
},
export: {
async insomnia(options: { includePrivate?: boolean } = {}): Promise<string> {
@@ -18,7 +18,7 @@ export function init(): { import: Object, export: Object } {
},
async har(options: { includePrivate?: boolean } = {}): Promise<string> {
return exportHAR(null, options.includePrivate);
}
}
},
},
};
}
@@ -5,7 +5,7 @@ import * as misc from '../../common/misc';
export function init(
renderedRequest: RenderedRequest,
renderedContext: Object,
readOnly: boolean = false
readOnly: boolean = false,
): { request: Object } {
if (!renderedRequest) {
throw new Error('contexts.request initialized without request');
@@ -69,7 +69,7 @@ export function init(
getHeaders(): Array<{ name: string, value: string }> {
return renderedRequest.headers.map(h => ({
name: h.name,
value: h.value
value: h.value,
}));
},
hasHeader(name: string): boolean {
@@ -106,7 +106,7 @@ export function init(
getParameters(): Array<{ name: string, value: string }> {
return renderedRequest.parameters.map(p => ({
name: p.name,
value: p.value
value: p.value,
}));
},
hasParameter(name: string): boolean {
@@ -129,7 +129,7 @@ export function init(
if (!parameter) {
renderedRequest.parameters.push({ name, value });
}
}
},
// NOTE: For these to make sense, we'd need to account for cookies in the jar as well
// addCookie (name: string, value: string): void {}
@@ -12,7 +12,7 @@ type MaybeResponse = {
bytesContent?: number,
bodyPath?: string,
elapsedTime?: number,
headers?: Array<ResponseHeader>
headers?: Array<ResponseHeader>,
};
export function init(response: MaybeResponse): { response: Object } {
@@ -70,7 +70,7 @@ export function init(response: MaybeResponse): { response: Object } {
},
hasHeader(name: string): boolean {
return this.getHeader(name) !== null;
}
}
},
},
};
}
@@ -26,9 +26,9 @@ export function init(plugin: Plugin) {
const docs = await models.pluginData.all(plugin.name);
return docs.map(d => ({
value: d.value,
key: d.key
key: d.key,
}));
}
}
},
},
};
}
+8 -8
View File
@@ -14,27 +14,27 @@ export type Plugin = {
description: string,
version: string,
directory: string,
module: *
module: *,
};
export type TemplateTag = {
plugin: Plugin,
templateTag: PluginTemplateTag
templateTag: PluginTemplateTag,
};
export type RequestHook = {
plugin: Plugin,
hook: Function
hook: Function,
};
export type ResponseHook = {
plugin: Plugin,
hook: Function
hook: Function,
};
export type Theme = {
plugin: Plugin,
theme: PluginTheme
theme: PluginTheme,
};
const CORE_PLUGINS = [
@@ -48,7 +48,7 @@ const CORE_PLUGINS = [
'insomnia-plugin-response',
'insomnia-plugin-jsonpath',
'insomnia-plugin-cookie-jar',
'insomnia-plugin-core-themes'
'insomnia-plugin-core-themes',
];
let plugins: ?Array<Plugin> = null;
@@ -108,7 +108,7 @@ async function _traversePluginPath(pluginMap: Object, allPaths: Array<string>) {
showError({
title: 'Plugin Error',
message: 'Failed to load plugin ' + filename,
error: err
error: err,
});
}
}
@@ -203,6 +203,6 @@ function _initPlugin(packageJSON: Object, module: any, path: ?string): Plugin {
description: packageJSON.description || meta.description || '',
version: packageJSON.version || 'unknown',
directory: path || '',
module: module
module: module,
};
}
+11 -11
View File
@@ -32,7 +32,7 @@ export default async function(lookupName: string): Promise<void> {
// Move entire module to plugins folder
fsx.moveSync(path.join(tmpDir, moduleName), pluginDir, {
overwrite: true
overwrite: true,
});
// Move each dependency into node_modules folder
@@ -66,7 +66,7 @@ async function _isInsomniaPlugin(lookupName: string): Promise<Object> {
_getYarnPath(),
'info',
lookupName,
'--json'
'--json',
],
{
timeout: 5 * 60 * 1000,
@@ -74,8 +74,8 @@ async function _isInsomniaPlugin(lookupName: string): Promise<Object> {
shell: true,
env: {
NODE_ENV: 'production',
ELECTRON_RUN_AS_NODE: 'true'
}
ELECTRON_RUN_AS_NODE: 'true',
},
},
(err, stdout, stderr) => {
if (err) {
@@ -110,10 +110,10 @@ async function _isInsomniaPlugin(lookupName: string): Promise<Object> {
version: data.version,
dist: {
shasum: data.dist.shasum,
tarball: data.dist.tarball
}
tarball: data.dist.tarball,
},
});
}
},
);
});
}
@@ -136,7 +136,7 @@ async function _installPluginToTmpDir(lookupName: string): Promise<{ tmpDir: str
tmpDir,
'--no-lockfile',
'--production',
'--no-progress'
'--no-progress',
],
{
timeout: 5 * 60 * 1000,
@@ -145,8 +145,8 @@ async function _installPluginToTmpDir(lookupName: string): Promise<{ tmpDir: str
shell: true, // Some package installs require a shell
env: {
NODE_ENV: 'production',
ELECTRON_RUN_AS_NODE: 'true'
}
ELECTRON_RUN_AS_NODE: 'true',
},
},
(err, stdout, stderr) => {
if (err) {
@@ -160,7 +160,7 @@ async function _installPluginToTmpDir(lookupName: string): Promise<{ tmpDir: str
}
resolve({ tmpDir });
}
},
);
});
}
+10 -10
View File
@@ -11,7 +11,7 @@ type ThemeBlock = {
warning?: string,
danger?: string,
surprise?: string,
info?: string
info?: string,
},
foreground?: {
default: string,
@@ -20,7 +20,7 @@ type ThemeBlock = {
warning?: string,
danger?: string,
surprise?: string,
info?: string
info?: string,
},
highlight?: {
default: string,
@@ -29,8 +29,8 @@ type ThemeBlock = {
sm?: string,
md?: string,
lg?: string,
xl?: string
}
xl?: string,
},
};
type ThemeInner = {
@@ -50,14 +50,14 @@ type ThemeInner = {
dialogHeader?: ThemeBlock,
dialogFooter?: ThemeBlock,
transparentOverlay?: ThemeBlock,
link?: ThemeBlock
}
link?: ThemeBlock,
},
};
export type PluginTheme = {
name: string,
displayName: string,
theme: ThemeInner
theme: ThemeInner,
};
export async function generateThemeCSS(theme: PluginTheme): Promise<string> {
@@ -66,7 +66,7 @@ export async function generateThemeCSS(theme: PluginTheme): Promise<string> {
theme.theme,
null,
THROW_ON_ERROR,
theme.name
theme.name,
);
const n = theme.name;
@@ -88,7 +88,7 @@ export async function generateThemeCSS(theme: PluginTheme): Promise<string> {
css += wrapStyles(
n,
'.theme--transparent-overlay',
getThemeBlockCSS(styles.transparentOverlay)
getThemeBlockCSS(styles.transparentOverlay),
);
// Dialogs
@@ -191,7 +191,7 @@ function wrapStyles(theme: string, selector: string, styles: string) {
styles,
'}',
'',
''
'',
].join('\n');
}
@@ -22,7 +22,7 @@ describe('encryptRSA', () => {
ad: '6164646974696f6e616c2064617461',
d: '48656c6c6f253230576f726c6421',
iv: '616161616161616161616161',
t: '746167'
t: '746167',
};
const expectedDecrypted = 'Hello World!';
@@ -25,12 +25,12 @@ describe('Test push/pull behaviour', () => {
await models.request.create({
_id: 'req_1',
name: 'Request 1',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await models.request.create({
_id: 'req_2',
name: 'Request 2',
parentId: 'wrk_2'
parentId: 'wrk_2',
});
// Create resources, resource groups, and configs
@@ -49,10 +49,10 @@ describe('Test push/pull behaviour', () => {
// Set up sync modes
await sync.createOrUpdateConfig(resourceRequest.resourceGroupId, {
syncMode: syncStorage.SYNC_MODE_ON
syncMode: syncStorage.SYNC_MODE_ON,
});
await sync.createOrUpdateConfig(resourceRequest2.resourceGroupId, {
syncMode: syncStorage.SYNC_MODE_UNSET
syncMode: syncStorage.SYNC_MODE_UNSET,
});
await sync.push(); // Push only active configs
@@ -75,14 +75,14 @@ describe('Test push/pull behaviour', () => {
const request = await models.request.getById('req_1');
const resourceRequest = await syncStorage.getResourceByDocId(request._id);
await sync.createOrUpdateConfig(resourceRequest.resourceGroupId, {
syncMode: syncStorage.SYNC_MODE_ON
syncMode: syncStorage.SYNC_MODE_ON,
});
session.syncPush.mockReturnValueOnce({
updated: [],
created: [{ id: request._id, version: 'new-version' }],
removed: [],
conflicts: []
conflicts: [],
});
const resourceBefore = await syncStorage.getResourceByDocId(request._id);
@@ -102,31 +102,31 @@ describe('Test push/pull behaviour', () => {
const request2 = await models.request.getById('req_2');
const requestNew = Object.assign({}, request, {
_id: 'req_new',
name: 'New Request'
name: 'New Request',
});
const resourceBefore = await syncStorage.getResourceByDocId(request._id);
const resource2Before = await syncStorage.getResourceByDocId(requestNew._id);
await sync.createOrUpdateConfig(resourceBefore.resourceGroupId, {
syncMode: syncStorage.SYNC_MODE_ON
syncMode: syncStorage.SYNC_MODE_ON,
});
const updatedRequest = Object.assign({}, request, {
name: 'Request Updated'
name: 'Request Updated',
});
const updatedResource = Object.assign({}, resourceBefore, {
version: 'ver1',
encContent: await sync.encryptDoc(resourceBefore.resourceGroupId, updatedRequest)
encContent: await sync.encryptDoc(resourceBefore.resourceGroupId, updatedRequest),
});
const createdResourceNew = Object.assign({}, resourceBefore, {
id: requestNew._id,
resourceGroupId: 'rg_1',
encContent: await sync.encryptDoc(resourceBefore.resourceGroupId, requestNew)
encContent: await sync.encryptDoc(resourceBefore.resourceGroupId, requestNew),
});
session.syncPull.mockReturnValueOnce({
updatedResources: [updatedResource],
createdResources: [createdResourceNew],
idsToPush: [],
idsToRemove: ['req_2']
idsToRemove: ['req_2'],
});
// Pull and get docs/resources
@@ -136,7 +136,7 @@ describe('Test push/pull behaviour', () => {
const requestNewAfter = await models.request.getById('req_new');
const resourceAfter = await syncStorage.getResourceByDocId(
request._id,
resourceBefore.resourceGroupId
resourceBefore.resourceGroupId,
);
const resource2After = await syncStorage.getResourceByDocId(request2._id);
const resourceNewAfter = await syncStorage.getResourceByDocId(requestNewAfter._id);
@@ -156,26 +156,26 @@ describe('Test push/pull behaviour', () => {
it('Conflict: local version wins on modified before', async () => {
const requestClient = await models.request.getById('req_1');
const requestServer = Object.assign({}, requestClient, {
name: 'Server Request'
name: 'Server Request',
});
const resourceRequest = await syncStorage.getResourceByDocId(requestClient._id);
const resourceConflict = Object.assign({}, resourceRequest, {
version: 'ver-2',
encContent: await sync.encryptDoc(resourceRequest.resourceGroupId, requestServer),
lastEdited: resourceRequest.lastEdited - 1000 // Same edited time
lastEdited: resourceRequest.lastEdited - 1000, // Same edited time
});
session.syncPush.mockReturnValueOnce({
updated: [],
created: [],
removed: [],
conflicts: [resourceConflict]
conflicts: [resourceConflict],
});
await sync.push(resourceRequest.resourceGroupId);
const resourceAfter = await syncStorage.getResourceByDocId(
requestClient._id,
resourceRequest.resourceGroupId
resourceRequest.resourceGroupId,
);
const requestAfter = await models.request.getById(requestClient._id);
@@ -193,26 +193,26 @@ describe('Test push/pull behaviour', () => {
it('Conflict: local version wins on modified tie', async () => {
const requestClient = await models.request.getById('req_1');
const requestServer = Object.assign({}, requestClient, {
name: 'Server Request'
name: 'Server Request',
});
const resourceRequest = await syncStorage.getResourceByDocId(requestClient._id);
const resourceConflict = Object.assign({}, resourceRequest, {
version: 'ver-2',
encContent: await sync.encryptDoc(resourceRequest.resourceGroupId, requestServer),
lastEdited: resourceRequest.lastEdited // Same edited time
lastEdited: resourceRequest.lastEdited, // Same edited time
});
session.syncPush.mockReturnValueOnce({
updated: [],
created: [],
removed: [],
conflicts: [resourceConflict]
conflicts: [resourceConflict],
});
await sync.push(resourceRequest.resourceGroupId);
const resourceAfter = await syncStorage.getResourceByDocId(
requestClient._id,
resourceRequest.resourceGroupId
resourceRequest.resourceGroupId,
);
const requestAfter = await models.request.getById(requestClient._id);
@@ -230,26 +230,26 @@ describe('Test push/pull behaviour', () => {
it('Conflict: server version wins if modified after', async () => {
const requestClient = await models.request.getById('req_1');
const requestServer = Object.assign({}, requestClient, {
name: 'Server Request'
name: 'Server Request',
});
const resourceRequest = await syncStorage.getResourceByDocId(requestClient._id);
const resourceConflict = Object.assign({}, resourceRequest, {
version: 'ver-2',
encContent: await sync.encryptDoc(resourceRequest.resourceGroupId, requestServer),
lastEdited: resourceRequest.lastEdited + 1000
lastEdited: resourceRequest.lastEdited + 1000,
});
session.syncPush.mockReturnValueOnce({
updated: [],
created: [],
removed: [],
conflicts: [resourceConflict]
conflicts: [resourceConflict],
});
await sync.push(resourceRequest.resourceGroupId);
const resourceAfter = await syncStorage.getResourceByDocId(
requestClient._id,
resourceRequest.resourceGroupId
resourceRequest.resourceGroupId,
);
const requestAfter = await models.request.getById(requestClient._id);
@@ -284,29 +284,29 @@ describe('Integration tests for creating Resources and pushing', () => {
// Add some data
await models.workspace.create({
_id: 'wrk_empty',
name: 'Workspace Empty'
name: 'Workspace Empty',
});
await models.workspace.create({ _id: 'wrk_1', name: 'Workspace 1' });
await models.request.create({
_id: 'req_1',
name: 'Request 1',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await models.request.create({
_id: 'req_2',
name: 'Request 2',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await models.request.create({
_id: 'req_3',
name: 'Request 3',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await models.environment.create({
_id: 'env_2',
name: 'Env Prv',
parentId: 'wrk_1',
isPrivate: true
isPrivate: true,
});
// Flush changes just to be sure they won't affect our tests
@@ -332,7 +332,7 @@ describe('Integration tests for creating Resources and pushing', () => {
const configs = await syncStorage.allConfigs();
for (const config of configs) {
await syncStorage.updateConfig(config, {
syncMode: syncStorage.SYNC_MODE_ON
syncMode: syncStorage.SYNC_MODE_ON,
});
}
@@ -349,7 +349,7 @@ describe('Integration tests for creating Resources and pushing', () => {
await models.request.create({
_id: 'req_t',
url: 'https://google.com',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await db.flushChanges();
@@ -377,7 +377,7 @@ describe('Integration tests for creating Resources and pushing', () => {
const request = await models.request.create({
_id: 'req_t',
name: 'Original Request',
parentId: 'wrk_1'
parentId: 'wrk_1',
});
await db.flushChanges();
await sync.writePendingChanges();
@@ -386,7 +386,7 @@ describe('Integration tests for creating Resources and pushing', () => {
// Mark resource as removed
const originalResource = await syncStorage.getResourceByDocId('req_t');
const updatedResource = await syncStorage.updateResource(originalResource, {
removed: true
removed: true,
});
// Update it and push it again
@@ -409,7 +409,7 @@ describe('Integration tests for creating Resources and pushing', () => {
const resource = await syncStorage.getResourceByDocId(request._id);
await db.bufferChanges();
const updatedRequest = await models.request.update(request, {
name: 'New Name'
name: 'New Name',
});
// Drain and fetch new resource
@@ -472,7 +472,7 @@ async function _setSessionData() {
ext: true,
k: '3-QU2OcQcpSyFIoL8idgclbImP3M8Y2d0oVAca3Vl4g',
key_ops: ['encrypt', 'decrypt'],
kty: 'oct'
kty: 'oct',
};
const publicKey = {
@@ -481,7 +481,7 @@ async function _setSessionData() {
ext: true,
key_ops: ['encrypt'],
kty: 'RSA',
n: 'aaaa'
n: 'aaaa',
};
const { privateKey } = await crypt.generateKeyPairJWK();
@@ -489,7 +489,7 @@ async function _setSessionData() {
ad: '',
d: Buffer.from(JSON.stringify(privateKey)).toString('hex'),
iv: '968f1d810efdaec58f9e313e',
t: '0e87a2e57a198ca79cb99585fe9c244a'
t: '0e87a2e57a198ca79cb99585fe9c244a',
};
// Setup mocks and stuff
@@ -501,7 +501,7 @@ async function _setSessionData() {
'gschier1990@gmail.com',
symmetricKey,
publicKey,
encPrivateKey
encPrivateKey,
);
}
@@ -524,8 +524,8 @@ async function _setupSessionMocks() {
{
parentResourceId: parentId,
name: name,
encSymmetricKey: encSymmetricKey
}
encSymmetricKey: encSymmetricKey,
},
);
return resourceGroups[id];
});
@@ -544,13 +544,13 @@ async function _setupSessionMocks() {
updatedResources: [],
createdResources: [],
idsToPush: [],
idsToRemove: []
idsToRemove: [],
}));
session.syncPush = jest.fn(body => ({
conflicts: [],
updated: [],
created: [],
removed: []
removed: [],
}));
}
+14 -14
View File
@@ -40,7 +40,7 @@ export function encryptRSAWithJWK(publicKeyJWK, plaintext) {
const publicKey = forge.rsa.setPublicKey(n, e);
const encrypted = publicKey.encrypt(encodedPlaintext, 'RSA-OAEP', {
md: forge.md.sha256.create()
md: forge.md.sha256.create(),
});
return forge.util.bytesToHex(encrypted);
}
@@ -58,7 +58,7 @@ export function decryptRSAWithJWK(privateJWK, encryptedBlob) {
const privateKey = forge.rsa.setPrivateKey(n, e, d, p, q, dP, dQ, qInv);
const bytes = forge.util.hexToBytes(encryptedBlob);
const decrypted = privateKey.decrypt(bytes, 'RSA-OAEP', {
md: forge.md.sha256.create()
md: forge.md.sha256.create(),
});
return decodeURIComponent(decrypted);
@@ -96,7 +96,7 @@ export function encryptAES(jwkOrKey, plaintext, additionalData = '') {
iv: forge.util.bytesToHex(iv),
t: forge.util.bytesToHex(cipher.mode.tag),
d: forge.util.bytesToHex(cipher.output),
ad: forge.util.bytesToHex(additionalData)
ad: forge.util.bytesToHex(additionalData),
};
}
@@ -121,7 +121,7 @@ export function decryptAES(jwkOrKey, message) {
iv: forge.util.hexToBytes(message.iv),
tagLength: message.t.length * 4,
tag: forge.util.hexToBytes(message.t),
additionalData: forge.util.hexToBytes(message.ad)
additionalData: forge.util.hexToBytes(message.ad),
});
decipher.update(forge.util.createBuffer(forge.util.hexToBytes(message.d)));
@@ -179,7 +179,7 @@ export async function generateAES256Key() {
console.log('[crypt] Using Native AES Key Generation');
const key = await subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, [
'encrypt',
'decrypt'
'decrypt',
]);
return subtle.exportKey('jwk', key);
} else {
@@ -190,7 +190,7 @@ export async function generateAES256Key() {
alg: 'A256GCM',
ext: true,
key_ops: ['encrypt', 'decrypt'],
k: _hexToB64Url(key)
k: _hexToB64Url(key),
};
}
}
@@ -212,15 +212,15 @@ export async function generateKeyPairJWK() {
name: 'RSA-OAEP',
publicExponent: new Uint8Array([1, 0, 1]),
modulusLength: 2048,
hash: 'SHA-256'
hash: 'SHA-256',
},
true,
['encrypt', 'decrypt']
['encrypt', 'decrypt'],
);
return {
publicKey: await subtle.exportKey('jwk', pair.publicKey),
privateKey: await subtle.exportKey('jwk', pair.privateKey)
privateKey: await subtle.exportKey('jwk', pair.privateKey),
};
} else {
console.log('[crypt] Using Forge RSA Generation');
@@ -238,7 +238,7 @@ export async function generateKeyPairJWK() {
n: _bigIntToB64Url(pair.privateKey.n),
p: _bigIntToB64Url(pair.privateKey.p),
q: _bigIntToB64Url(pair.privateKey.q),
qi: _bigIntToB64Url(pair.privateKey.qInv)
qi: _bigIntToB64Url(pair.privateKey.qInv),
};
const publicKey = {
@@ -246,7 +246,7 @@ export async function generateKeyPairJWK() {
kty: 'RSA',
key_ops: ['encrypt'],
e: _bigIntToB64Url(pair.publicKey.e),
n: _bigIntToB64Url(pair.publicKey.n)
n: _bigIntToB64Url(pair.publicKey.n),
};
return { privateKey, publicKey };
@@ -315,14 +315,14 @@ async function _pbkdf2Passphrase(passphrase, salt) {
Buffer.from(passphrase, 'utf8'),
{ name: 'PBKDF2' },
false,
['deriveBits']
['deriveBits'],
);
const algo = {
name: 'PBKDF2',
salt: Buffer.from(salt, 'hex'),
iterations: DEFAULT_PBKDF2_ITERATIONS,
hash: 'SHA-256'
hash: 'SHA-256',
};
const derivedKeyRaw = await window.crypto.subtle.deriveBits(algo, k, DEFAULT_BYTE_LENGTH * 8);
@@ -334,7 +334,7 @@ async function _pbkdf2Passphrase(passphrase, salt) {
forge.util.hexToBytes(salt),
DEFAULT_PBKDF2_ITERATIONS,
DEFAULT_BYTE_LENGTH,
forge.md.sha256.create()
forge.md.sha256.create(),
);
return forge.util.bytesToHex(derivedKeyRaw);
+11 -11
View File
@@ -19,7 +19,7 @@ const WHITE_LIST = {
// These can be overridden in sync config
[models.cookieJar.type]: true,
[models.clientCertificate.type]: true
[models.clientCertificate.type]: true,
};
export const logger = new Logger();
@@ -43,7 +43,7 @@ export async function init() {
db.onChange(async changes => {
// To help prevent bugs, put Workspaces first
const sortedChanges = changes.sort(
([event, doc, fromSync]) => (doc.type === models.workspace.type ? 1 : -1)
([event, doc, fromSync]) => (doc.type === models.workspace.type ? 1 : -1),
);
for (const [event, doc, fromSync] of sortedChanges) {
@@ -263,7 +263,7 @@ export async function push(resourceGroupId = null) {
for (const serverResource of conflicts) {
const localResource = await store.getResourceByDocId(
serverResource.id,
serverResource.resourceGroupId
serverResource.resourceGroupId,
);
// On conflict, choose last edited one
@@ -274,7 +274,7 @@ export async function push(resourceGroupId = null) {
// NOTE: using localResource as the base to make sure we have _id
await store.updateResource(localResource, winner, {
version: serverResource.version, // Act as the server resource no matter what
dirty: !serverIsNewer // It's dirty if we chose the local doc
dirty: !serverIsNewer, // It's dirty if we chose the local doc
});
// Decrypt the docs from the resources. Don't fetch the local doc from the
@@ -327,14 +327,14 @@ export async function pull(resourceGroupId = null, createMissingResources = true
id: r.id,
resourceGroupId: r.resourceGroupId,
version: r.version,
removed: r.removed
removed: r.removed,
}));
const blacklistedResourceGroupIds = blacklistedConfigs.map(c => c.resourceGroupId);
const body = {
resources,
blacklist: blacklistedResourceGroupIds
blacklist: blacklistedResourceGroupIds,
};
logger.debug(`Pulling with ${resources.length} resources`);
@@ -431,7 +431,7 @@ export async function pull(resourceGroupId = null, createMissingResources = true
// Update local resource
const resource = await store.getResourceByDocId(
serverResource.id,
serverResource.resourceGroupId
serverResource.resourceGroupId,
);
await store.updateResource(resource, serverResource, { dirty: false });
} catch (e) {
@@ -554,7 +554,7 @@ async function _handleChangeAndPush(event, doc, timestamp) {
lastEditedBy: session.getAccountId(),
encContent: await encryptDoc(resource.resourceGroupId, doc),
removed: event === db.CHANGE_REMOVE,
dirty: true
dirty: true,
});
// Debounce pushing of dirty resources
@@ -643,7 +643,7 @@ async function _getResourceGroupSymmetricKey(resourceGroupId) {
const symmetricKeyStr = crypt.decryptRSAWithJWK(
accountPrivateKey,
resourceGroup.encSymmetricKey
resourceGroup.encSymmetricKey,
);
key = JSON.parse(symmetricKeyStr);
@@ -741,7 +741,7 @@ export async function createResource(doc, resourceGroupId) {
removed: false,
type: doc.type,
encContent: await encryptDoc(resourceGroupId, doc),
dirty: true
dirty: true,
});
}
@@ -803,7 +803,7 @@ export async function getOrCreateAllActiveResources(resourceGroupId = null) {
// Make sure Workspace is first, because the loop below depends on it
const modelTypes = Object.keys(WHITE_LIST).sort(
(a, b) => (a.type === models.workspace.type ? 1 : -1)
(a, b) => (a.type === models.workspace.type ? 1 : -1),
);
let created = 0;
+11 -11
View File
@@ -23,12 +23,12 @@ export async function login(rawEmail, rawPassphrase) {
Buffer.from(saltAuth, 'hex'),
Buffer.from(email, 'utf8'),
Buffer.from(authSecret, 'hex'),
Buffer.from(secret1, 'hex')
Buffer.from(secret1, 'hex'),
);
const srpA = c.computeA().toString('hex');
const { sessionStarterId, srpB } = await util.post('/auth/login-a', {
srpA,
email
email,
});
// ~~~~~~~~~~~~~~~~~~~~~ //
@@ -39,7 +39,7 @@ export async function login(rawEmail, rawPassphrase) {
const srpM1 = c.computeM1().toString('hex');
const { srpM2 } = await util.post('/auth/login-m1', {
srpM1,
sessionStarterId
sessionStarterId,
});
// ~~~~~~~~~~~~~~~~~~~~~~~~~ //
@@ -63,7 +63,7 @@ export async function login(rawEmail, rawPassphrase) {
saltEnc,
accountId,
firstName,
lastName
lastName,
} = await whoami(sessionId);
const derivedSymmetricKey = await crypt.deriveKey(passphrase, email, saltEnc);
@@ -78,7 +78,7 @@ export async function login(rawEmail, rawPassphrase) {
email,
JSON.parse(symmetricKeyStr),
JSON.parse(publicKey),
JSON.parse(encPrivateKey)
JSON.parse(encPrivateKey),
);
}
@@ -86,7 +86,7 @@ export function syncCreateResourceGroup(parentResourceId, name, encSymmetricKey)
return util.post('/api/resource_groups', {
parentResourceId,
name,
encSymmetricKey
encSymmetricKey,
});
}
@@ -117,7 +117,7 @@ export function unshareWithAllTeams(resourceGroupId) {
export async function shareWithTeam(resourceGroupId, teamId, rawPassphrase) {
// Ask the server what we need to do to invite the member
const instructions = await util.post(`/api/resource_groups/${resourceGroupId}/share-a`, {
teamId
teamId,
});
// Compute keys necessary to invite the member
@@ -134,7 +134,7 @@ export async function shareWithTeam(resourceGroupId, teamId, rawPassphrase) {
const privateKeyJWK = JSON.parse(privateKey);
const resourceGroupSymmetricKey = crypt.decryptRSAWithJWK(
privateKeyJWK,
instructions.encSymmetricKey
instructions.encSymmetricKey,
);
// Build the invite data request
@@ -147,7 +147,7 @@ export async function shareWithTeam(resourceGroupId, teamId, rawPassphrase) {
// Actually share it with the team
await util.post(`/api/resource_groups/${resourceGroupId}/share-b`, {
teamId,
keys: newKeys
keys: newKeys,
});
}
@@ -209,7 +209,7 @@ export function setSessionData(
email,
symmetricKey,
publicKey,
encPrivateKey
encPrivateKey,
) {
const dataStr = JSON.stringify({
id: sessionId,
@@ -219,7 +219,7 @@ export function setSessionData(
encPrivateKey: encPrivateKey,
email: email,
firstName: firstName,
lastName: lastName
lastName: lastName,
});
window.localStorage.setItem(getSessionKey(sessionId), dataStr);
+6 -6
View File
@@ -112,7 +112,7 @@ export async function insertResource(resource) {
h.update(resource.resourceGroupId);
h.update(resource.id);
const newResource = Object.assign({}, resource, {
_id: `rs_${h.digest('hex')}`
_id: `rs_${h.digest('hex')}`,
});
await _execDB(TYPE_RESOURCE, 'insert', newResource);
_notifyChange();
@@ -122,7 +122,7 @@ export async function insertResource(resource) {
export async function updateResource(resource, ...patches) {
const newDoc = Object.assign({}, resource, ...patches);
await _execDB(TYPE_RESOURCE, 'update', { _id: resource._id }, newDoc, {
multi: true
multi: true,
});
_notifyChange();
return newDoc;
@@ -148,7 +148,7 @@ export function allConfigs() {
export function findInactiveConfigs(excludedResourceGroupId = null) {
if (excludedResourceGroupId) {
return findConfigs({
$not: { syncMode: SYNC_MODE_ON, excludedResourceGroupId }
$not: { syncMode: SYNC_MODE_ON, excludedResourceGroupId },
});
} else {
return findConfigs({ $not: { syncMode: SYNC_MODE_ON } });
@@ -189,9 +189,9 @@ function _initConfig(data) {
{
_id: util.generateId('scf'),
syncMode: SYNC_MODE_UNSET,
resourceGroupId: null
resourceGroupId: null,
},
data
data,
);
}
@@ -206,7 +206,7 @@ export function initDB(config, forceReset) {
// Fill in the defaults
_database['Resource'] = new NeDB(
Object.assign({ filename: resourcePath, autoload: true }, config)
Object.assign({ filename: resourcePath, autoload: true }, config),
);
_database['Config'] = new NeDB(Object.assign({ filename: configPath, autoload: true }, config));
@@ -10,7 +10,7 @@ describe('getKeys()', () => {
null: null,
undefined: undefined,
false: false,
array: ['hello', { hi: 'there' }, true, ['x', 'y', 'z']]
array: ['hello', { hi: 'there' }, true, ['x', 'y', 'z']],
};
const keys = utils.getKeys(obj).sort((a, b) => (a.name > b.name ? 1 : -1));
@@ -25,7 +25,7 @@ describe('getKeys()', () => {
{ name: 'false', value: obj.false },
{ name: 'foo', value: obj.foo },
{ name: 'null', value: obj.null },
{ name: 'undefined', value: obj.undefined }
{ name: 'undefined', value: obj.undefined },
]);
});
@@ -34,7 +34,7 @@ describe('getKeys()', () => {
foo: 'bar',
toString: function() {
// Nothing
}
},
};
const keys = utils.getKeys(obj);
@@ -52,8 +52,8 @@ describe('tokenizeTag()', () => {
args: [
{ type: 'variable', value: 'bar' },
{ type: 'string', value: 'baz "qux"', quotedBy: '"' },
{ type: 'expression', value: '1 + 5 | default("foo")' }
]
{ type: 'expression', value: '1 + 5 | default("foo")' },
],
};
expect(actual).toEqual(expected);
@@ -65,7 +65,7 @@ describe('tokenizeTag()', () => {
const expected = {
name: 'name',
args: [{ type: 'string', value: 'foo', quotedBy: "'" }, { type: 'variable', value: 'bar' }]
args: [{ type: 'string', value: 'foo', quotedBy: "'" }, { type: 'variable', value: 'bar' }],
};
expect(minimal).toEqual(expected);
@@ -77,7 +77,7 @@ describe('tokenizeTag()', () => {
const expected = {
name: 'name',
args: [{ type: 'string', value: 'foo', quotedBy: "'" }]
args: [{ type: 'string', value: 'foo', quotedBy: "'" }],
};
expect(actual).toEqual(expected);
@@ -91,8 +91,8 @@ describe('tokenizeTag()', () => {
args: [
{ type: 'number', value: '9.324' },
{ type: 'number', value: '8' },
{ type: 'number', value: '7' }
]
{ type: 'number', value: '7' },
],
};
expect(actual).toEqual(expected);
@@ -103,7 +103,7 @@ describe('tokenizeTag()', () => {
const expected = {
name: 'name',
args: [{ type: 'boolean', value: true }, { type: 'boolean', value: false }]
args: [{ type: 'boolean', value: true }, { type: 'boolean', value: false }],
};
expect(actual).toEqual(expected);
@@ -114,7 +114,7 @@ describe('tokenizeTag()', () => {
const expected = {
name: 'name',
args: [{ type: 'expression', value: `5 * 10 + 'hello' | default(2 - 3)` }]
args: [{ type: 'expression', value: `5 * 10 + 'hello' | default(2 - 3)` }],
};
expect(actual).toEqual(expected);
@@ -129,7 +129,7 @@ describe('tokenizeTag()', () => {
const expected = {
name: 'name',
args: [{ type: 'expression', value: 'foo bar baz' }]
args: [{ type: 'expression', value: 'foo bar baz' }],
};
expect(actual).toEqual(expected);
@@ -150,7 +150,7 @@ describe('unTokenizeTag()', () => {
it('fixes missing quotedBy attribute', () => {
const tagData = {
name: 'name',
args: [{ type: 'file', value: 'foo/bar/baz' }, { type: 'model', value: 'foo' }]
args: [{ type: 'file', value: 'foo/bar/baz' }, { type: 'model', value: 'foo' }],
};
const result = utils.unTokenizeTag(tagData);
@@ -83,24 +83,24 @@ export default class BaseExtension {
getAncestors: async request => {
const ancestors = await db.withAncestors(request, [
models.requestGroup.type,
models.workspace.type
models.workspace.type,
]);
return ancestors.filter(doc => doc._id !== request._id);
}
},
},
workspace: { getById: models.workspace.getById },
oAuth2Token: { getByRequestId: models.oAuth2Token.getByParentId },
cookieJar: {
getOrCreateForWorkspace: workspace => {
return models.cookieJar.getOrCreateForParentId(workspace._id);
}
},
},
response: {
getLatestForRequestId: models.response.getLatestForRequest,
getBodyBuffer: models.response.getBodyBuffer
}
}
}
getBodyBuffer: models.response.getBodyBuffer,
},
},
},
};
let result;
@@ -10,47 +10,47 @@ type PluginArgumentBase = {
displayName: DisplayName,
description?: string,
help?: string,
hide?: (args: Array<NunjucksParsedTagArg>) => boolean
hide?: (args: Array<NunjucksParsedTagArg>) => boolean,
};
export type PluginArgumentEnumOption = {
displayName: DisplayName,
value: PluginArgumentValue,
description?: string,
placeholder?: string
placeholder?: string,
};
export type PluginArgumentEnum = PluginArgumentBase & {
type: 'enum',
options: Array<PluginArgumentEnumOption>,
defaultValue?: PluginArgumentValue
defaultValue?: PluginArgumentValue,
};
export type PluginArgumentModel = PluginArgumentBase & {
type: 'model',
model: string,
defaultValue?: string
defaultValue?: string,
};
export type PluginArgumentString = PluginArgumentBase & {
type: 'string',
placeholder?: string,
defaultValue?: string
defaultValue?: string,
};
export type PluginArgumentBoolean = PluginArgumentBase & {
type: 'boolean',
defaultValue?: boolean
defaultValue?: boolean,
};
export type PluginArgumentFile = PluginArgumentBase & {
type: 'file'
type: 'file',
};
export type PluginArgumentNumber = PluginArgumentBase & {
type: 'number',
placeholder?: string,
defaultValue?: number
defaultValue?: number,
};
export type PluginArgument =
@@ -65,14 +65,14 @@ export type PluginTemplateTagContext = {
util: {
models: {
request: {
getById: (id: string) => Promise<Request | null>
getById: (id: string) => Promise<Request | null>,
},
response: {
getLatestForRequestId: (id: string) => Promise<Response | null>,
getBodyBuffer: (response: Response, fallback?: any) => Promise<Buffer | null>
}
}
}
getBodyBuffer: (response: Response, fallback?: any) => Promise<Buffer | null>,
},
},
},
};
export type PluginTemplateTag = {
@@ -83,5 +83,5 @@ export type PluginTemplateTag = {
run: (context: PluginTemplateTagContext, ...arg: Array<any>) => Promise<any> | any,
deprecated?: boolean,
validate?: (value: any) => ?string,
priority?: number
priority?: number,
};
@@ -32,7 +32,7 @@ let nunjucksAll = null;
*/
export function render(
text: string,
config: { context?: Object, path?: string, renderMode?: string } = {}
config: { context?: Object, path?: string, renderMode?: string } = {},
): Promise<string> {
const context = config.context || {};
const path = config.path || null;
@@ -93,7 +93,7 @@ export async function getTagDefinitions(): Promise<Array<NunjucksParsedTag>> {
name: ext.getTag(),
displayName: ext.getName(),
description: ext.getDescription(),
args: ext.getArgs()
args: ext.getArgs(),
}));
}
@@ -123,8 +123,8 @@ async function getNunjucks(renderMode: string) {
variableStart: '{{',
variableEnd: '}}',
commentStart: '{#',
commentEnd: '#}'
}
commentEnd: '#}',
},
};
if (renderMode === RENDER_VARS) {
@@ -10,13 +10,13 @@ export type NunjucksParsedTagArg = {
displayName?: string,
quotedBy?: '"' | "'",
validate?: (value: any) => string,
hide?: (Array<NunjucksParsedTagArg>) => boolean
hide?: (Array<NunjucksParsedTagArg>) => boolean,
};
export type NunjucksParsedTag = {
name: string,
args: Array<NunjucksParsedTagArg>,
rawValue?: string
rawValue?: string,
};
/**
@@ -44,7 +44,7 @@ Button.propTypes = {
disabled: PropTypes.bool,
tabIndex: PropTypes.number,
type: PropTypes.string,
id: PropTypes.string
id: PropTypes.string,
};
export default Button;
@@ -8,7 +8,7 @@ class CopyButton extends PureComponent {
constructor(props) {
super(props);
this.state = {
showConfirmation: false
showConfirmation: false,
};
}
@@ -67,7 +67,7 @@ CopyButton.propTypes = {
// Optional
children: PropTypes.node,
title: PropTypes.string,
confirmMessage: PropTypes.string
confirmMessage: PropTypes.string,
};
export default CopyButton;
@@ -142,7 +142,7 @@ DebouncedInput.propTypes = {
onFocus: PropTypes.func,
onBlur: PropTypes.func,
textarea: PropTypes.bool,
delay: PropTypes.number
delay: PropTypes.number,
};
export default DebouncedInput;
@@ -13,7 +13,7 @@ class DropdownButton extends PureComponent {
}
DropdownButton.propTypes = {
children: PropTypes.node
children: PropTypes.node,
};
export default DropdownButton;
@@ -7,7 +7,7 @@ class DropdownDivider extends PureComponent {
const { children } = this.props;
const classes = classnames('dropdown__divider', {
'dropdown__divider--no-name': !children
'dropdown__divider--no-name': !children,
});
return (
@@ -19,7 +19,7 @@ class DropdownDivider extends PureComponent {
}
DropdownDivider.propTypes = {
children: PropTypes.node
children: PropTypes.node,
};
export default DropdownDivider;
@@ -4,7 +4,7 @@ import type { Hotkey as HotkeyType } from '../../../../common/hotkeys';
import Hotkey from '../../hotkey';
type Props = {
hotkey: HotkeyType
hotkey: HotkeyType,
};
class DropdownHint extends React.PureComponent<Props> {
@@ -47,7 +47,7 @@ class DropdownItem extends PureComponent {
const buttonProps = {
type: 'button',
onClick: this._handleClick,
...props
...props,
};
return React.createElement(buttonClass || 'button', buttonProps, inner);
@@ -62,7 +62,7 @@ DropdownItem.propTypes = {
onClick: PropTypes.func,
children: PropTypes.node,
className: PropTypes.string,
color: PropTypes.string
color: PropTypes.string,
};
export default DropdownItem;
Loaded 100 of 404 files, more files were not shown because too many files have changed in this diff. Show more