Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Do not sign the request if client has added 'Authorization' header,
// which means custom authorizer.
if (typeof params.headers['Authorization'] !== 'undefined') {
params.headers = Object.keys(params.headers).reduce((acc, k) => {
if (params.headers[k]) {
acc[k] = params.headers[k];
}
return acc;
// tslint:disable-next-line:align
}, {});
return this._request(params, isAllResponse);
}
// Signing the request in case there credentials are available
return Credentials.get()
.then(
credentials => this._signed({ ...params }, credentials, isAllResponse),
err => {
logger.debug('No credentials available, the request will be unsigned');
return this._request(params, isAllResponse);
}
);
}
// Do not sign the request if client has added 'Authorization' header,
// which means custom authorizer.
if (typeof params.headers['Authorization'] !== 'undefined') {
params.headers = Object.keys(params.headers).reduce((acc, k) => {
if (params.headers[k]) {
acc[k] = params.headers[k];
}
return acc;
// tslint:disable-next-line:align
}, {});
return this._request(params, isAllResponse);
}
// Signing the request in case there credentials are available
return Credentials.get().then(
credentials => this._signed({ ...params }, credentials, isAllResponse),
err => {
logger.debug('No credentials available, the request will be unsigned');
return this._request(params, isAllResponse);
}
);
}
_ensureCredentials() {
return Credentials.get()
.then(credentials => {
if (!credentials) return false;
const cred = Credentials.shear(credentials);
logger.debug('set credentials for storage', cred);
this._config.credentials = cred;
return true;
})
.catch(err => {
logger.warn('ensure credentials error', err);
return false;
});
}
_ensureCredentials() {
return Credentials.get()
.then(credentials => {
if (!credentials) return false;
const cred = Credentials.shear(credentials);
logger.debug('set credentials for api', cred);
return true;
})
.catch(err => {
logger.warn('ensure credentials error', err);
return false;
});
}
}
_ensureCredentials() {
return Credentials.get()
.then(credentials => {
if (!credentials) return false;
const cred = Credentials.shear(credentials);
logger.debug('set credentials for api', cred);
return true;
})
.catch(err => {
logger.warn('ensure credentials error', err);
return false;
});
}
}
_ensureCredentials() {
return Credentials.get()
.then(credentials => {
if (!credentials) return false;
const cred = Credentials.shear(credentials);
logger.debug('set credentials for api', cred);
return true;
})
.catch(err => {
logger.warn('ensure credentials error', err);
return false;
});
}
}
private async _getCredentials() {
try {
const credentials = await Credentials.get();
if (!credentials) return null;
logger.debug('set credentials for analytics', credentials);
return Credentials.shear(credentials);
} catch (err) {
logger.debug('ensure credentials error', err);
return null;
}
}
}