Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
uploadTask(path, file, meta, uploadType) {
const nameHash = Md5.hashStr(file.name + new Date().getTime());
const fileExt = file.type.split('/')[1];
const name = `${nameHash}.${fileExt}`;
const newMeta = {
...meta,
someMoreData: 'Moooore data'
};
const ref = this.storage.ref(`${path}/${name}`);
const task = ref.put(file, { customMetadata: newMeta });
// add the following lines
task.snapshotChanges().pipe(
finalize(() => {
this.downloadURL = ref.getDownloadURL();
console.log('Image Uploaded!');
case AuthScheme.BEARER:
const token = CommonUtil.getCookie(AuthHelper.TOKEN_ID);
if (!CommonUtil.isEmpty(token)) {
headers.set('Authorization', 'Bearer ' + token);
}
break;
case AuthScheme.DIGEST:
if (!CommonUtil.isEmpty(user)) {
// TODO check from where arrive this fields
const nonce = 'dcd98b7102dd2f0e8b11d0f600bfb0c093';
const nc = '00000001';
const cnonce = '0a4f113b';
const opaque = '5ccc069c403ebaf9f0171e9517f40e41';
const qop = 'auth';
const HA1 = Md5.hashStr(user.username + ':' + user.email + ':' + user.password);
const HA2 = Md5.hashStr(method + ':' + uri);
const response = Md5.hashStr(HA1 + ':' + nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + HA2);
headers.set('Authorization', 'Digest ' +
' username="' + user.username + '",' +
' realm="' + user.email + '",' +
' nonce="' + nonce + '",' +
' uri="' + uri + '",' +
' qop=auth,' +
' nc=' + nc + ',' +
' cnonce="' + cnonce + '",' +
' response="' + response + '",' +
' opaque="' + opaque + '"');
}
break;
case AuthScheme.HOBA:
protected addMessage(message: any, keep: boolean = true): void {
/* Create a hash to identify the message. The text of online messages isn't reliable because it can have random data
like VideoJS ID. Try to use id and fallback to text for offline messages. */
message.hash = Md5.hashAsciiStr(String(message.id || message.text || '')) + '#' + message.timecreated + '#' +
message.useridfrom;
if (typeof this.keepMessageMap[message.hash] === 'undefined') {
// Message not added to the list. Add it now.
this.messages.push(message);
}
// Message needs to be kept in the list.
this.keepMessageMap[message.hash] = keep;
}
loginMyUser(username: string, password: string, server: string) {
// Log user in
const salt = this.generateSalt();
const token = new Md5().appendStr(password).appendStr(salt).end().toString();
const myUser: MyUser = {
name: username,
salt: salt,
token: token,
server: server
};
localStorage.setItem(USER_INFO, JSON.stringify(myUser));
localStorage.setItem(SERVER_URL, server);
this.loadMyRoles(username);
this.loadMyFolders(username);
}
private convertCommit(projectName: string, commit: any): GitCommit {
const emailMD5 = Md5.hashStr(commit.author_email);
const avatarURL = `https://secure.gravatar.com/avatar/${emailMD5}?s=120&d=identicon`;
return {
html_url: this.getCommitURL(projectName, commit.id),
author: {
id: null,
login: null,
avatar_url: avatarURL,
html_url: null
},
commit: {
author: {
date: commit.created_at,
name: commit.author_name,
email: commit.author_email
},
resetPassword(email, password, nav) {
let url = this.BASE_URL + 'auth/reset';
let body = JSON.stringify({'email': email, 'password': Md5.hashStr(password)});
let headers = new Headers({'Content-Type': 'application/json'});
return new Promise(resolve => {
this.http.patch(url, body, {headers: headers})
.map(res => res.json())
.subscribe(data => {
console.log(data.msg);
if (data.status == 200) {
resolve();
} else {
this.showToast('修改失败...', 2000, nav);
}
}, error => {
this.showToast('无法连接到服务器...', 2000, nav);
});
});
}
public exists(key: string): boolean {
var encryptedKeyString = Md5.hashStr(key).toString();
var valueExists = this.cacheMap.has(encryptedKeyString);
if (valueExists) {
return true;
}
return false;
}
public objectExists(key: any): boolean {
get md5password(): string {
return Md5.hashStr(this.password) as string;
}
userEmailHash(email) {
return Md5.hashStr(email);
}
private persistReportFor({ value }: SceneFinished) {
const filename = `${ Md5.hashStr(value.subject.id) }.json`;
this.stage.manager.informOfWorkInProgress(
RehearsalReport.from(this.stage.manager.readNewJournalEntriesAs('SerenityBDDReporter'))
.exportedUsing(new SerenityBDDReportExporter())
.then((fullReport: FullReport) => Promise.all(
fullReport.scenes.map(
(scene: SceneReport) => this.fs.store(filename, JSON.stringify(scene)),
),
)),
);
}
}