Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
authToken() {
if (!this.options_.username() || !this.options_.password()) return null;
try {
// Note: Non-ASCII passwords will throw an error about Latin1 characters - https://github.com/laurent22/joplin/issues/246
// Tried various things like the below, but it didn't work on React Native:
// return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
return base64.encode(`${this.options_.username()}:${this.options_.password()}`);
} catch (error) {
error.message = `Cannot encode username/password: ${error.message}`;
throw error;
}
}
function getAuth(): Bluebird {
//
const keys = `${config.get("spotify.clientId")}:${config.get("spotify.clientSecret")}`;
const encodedKeys = base64.encode(utf8.encode(keys));
return request({
method: "POST",
uri: "https://accounts.spotify.com/api/token",
form: {
grant_type: "client_credentials"
},
headers: {
"Authorization": `Basic ${encodedKeys}`,
"Content-Type": "application/x-www-form-urlencoded"
},
json: true
}).then((response: SpotifyAuthResponse) => {
token = response.access_token;
const oneMinute = 60;
const msInMin = 1000;
const reAuthDelay = response.expires_in - oneMinute;
res.setHeader(header, responseFixture.headers[header]);
}
let decodedData = base64.decode(responseFixture.data);
let publishInfo = responseFixture.metadata ? responseFixture.metadata.publishInfo : null;
decodedData = await _rewriteManifestAsync(
publishInfo,
req,
decodedData,
DEBUGGER_HOST_PLACEHOLDER,
packagerServerUrl,
MANIFEST_URL_PLACEHOLDER,
manifestServerUrl
);
res.write(new Buffer(base64.encode(decodedData), 'base64'));
res.end();
console.log(`[${fixtureResponseId}] Responded to ${req.url}...`);
};
this.params = params;
this.page = page;
this.translate = translate;
this.fonticon = fonticon;
this.util = util;
this.language = Platform.device.language;
this.translate.setDefaultLang("en");
this.translate.use(Platform.device.language.split("-")[0]);
this.host = Settings.getString("host");
this.username = Settings.getString("username");
this.password = Settings.getString("password");
this.rootdir = Settings.getString("rootdir");
this.rootdir = (this.rootdir == null) ? "" : this.rootdir;
this.headers = {
"OCS-APIREQUEST": "true",
"Authorization": "Basic " + Base64.encode(this.username + ':' + this.password)
};
this.item = params.context.item;
this.loader = params.context.loader;
}
ImageModalComponent.prototype.ngOnInit = function () {
message["collationId"] = uuidv4();
const protocol = (this.ssl) ? 'https' : 'http';
const url = `${protocol}://${this.host}:${this.port}${path}`
if (this.verbose && window.console) {
console.log("AuthenticateRequest: %s, %o", url, message);
}
var verbose = this.verbose;
return fetch(url, {
"method": "POST",
"body": JSON.stringify(message),
"headers": {
"Accept-Language": this.lang,
"Authorization": 'Basic ' + base64.encode(this.serverKey + ':'),
"Content-Type": 'application/json',
"Accept": 'application/json',
"User-Agent": `nakama/${VERSION}`
}
}).then(function(response) {
if (verbose && window.console) {
console.log("AuthenticateResponse: %o", response);
}
return response.json();
}).then(function(response) {
if (verbose && window.console) {
console.log("AuthenticateResponse (body): %o", response);
}
if (response.error) {
this.translate.use(Platform.device.language.split("-")[0]).subscribe(()=> {
this.host = Settings.getString("host");
this.username = Settings.getString("username");
this.password = Settings.getString("password");
this.rootdir = Settings.getString("rootdir");
this.rootdir = (this.rootdir==null)? "":this.rootdir;
this.headers = {
"OCS-APIREQUEST": "true",
"Authorization": "Basic "+Base64.encode(this.username+':'+this.password)
}
this.cache.images = new Array();
this.home();
});
}
componentWillMount() {
this.props.fetchAllChats(base64.encode(this.props.email_logged_in));
this.createDataSource(this.props.chatsList);
}
checkCredentials(username, password) {
return json(Helpers.getServerUrl('/'), 'GET', {
credentials: 'omit',
headers: {
'Authorization':'Basic ' + base64.encode(username + ':' + password)
}
});
}
const callbacks = queuedItems.map(item => item.callback);
callbacks.push(flushCallback);
const data = {
batch: queuedItems.map(item => item.message),
timestamp: new Date(),
sentAt: new Date(),
};
axios(
`${this.host}/v1/batch`,
{
data,
method: 'post',
headers: {
Authorization: `Basic ${base64.encode(this.writeKey)}`,
'Content-Type': 'application/json; charset=utf-8',
'X-Requested-With': 'XMLHttpRequest',
},
},
)
.then(() => {
callbacks.forEach((callback) => {
callback(undefined, data);
});
})
.catch((error) => {
callbacks.forEach((callback) => {
callback(error);
});
});
export default (path, filename) => `http://${config.ReportServiceHost}/screenshots/${base64.encode(encodeURIComponent(path))}/${base64.encode(encodeURIComponent(filename))}`