Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_authorization(url, method) {
let authorization = 'Digest'
if (method == undefined)
method = 'GET'
url = this.url_rewrite_func(url)
this.cnonce_counter++;
let cnonce_counter = (''+this.cnonce_counter).padStart(8, '0')
let A2 = method.toUpperCase() + ':' + url
let HA2 = md5.default(A2)
let resp = this.HA1 + ':' + this.auth.nonce + ':' + cnonce_counter + ':' + this.cnonce + ':' + this.auth.qop + ':' + HA2
let response = md5.default(resp)
authorization += ' username="' + this.username + '"'
authorization += ', realm="' + this.auth.realm + '"'
authorization += ', nonce="' + this.auth.nonce + '"'
authorization += ', uri="' + url + '"'
authorization += ', qop=' + this.auth.qop
authorization += ', nc=' + cnonce_counter
authorization += ', cnonce="' + this.cnonce + '"'
authorization += ', response="' + response + '"'
return authorization;
}
_authorization(url, method) {
let authorization = 'Digest'
if (method == undefined)
method = 'GET'
url = this.url_rewrite_func(url)
this.cnonce_counter++;
let cnonce_counter = (''+this.cnonce_counter).padStart(8, '0')
let A2 = method.toUpperCase() + ':' + url
let HA2 = md5.default(A2)
let resp = this.HA1 + ':' + this.auth.nonce + ':' + cnonce_counter + ':' + this.cnonce + ':' + this.auth.qop + ':' + HA2
let response = md5.default(resp)
authorization += ' username="' + this.username + '"'
authorization += ', realm="' + this.auth.realm + '"'
authorization += ', nonce="' + this.auth.nonce + '"'
authorization += ', uri="' + url + '"'
authorization += ', qop=' + this.auth.qop
authorization += ', nc=' + cnonce_counter
authorization += ', cnonce="' + this.cnonce + '"'
authorization += ', response="' + response + '"'
return authorization;
}
}
let challenge = response.headers.get('www-authenticate')
if (challenge.slice(0,6).toLowerCase() != 'digest') {
reject('unexpected www-authenticate: ' + auth_header)
}
let digest_challenge = challenge.slice(6)
let auth = this._name_value_string_to_object(digest_challenge)
if (auth.qop != 'auth') {
reject('expected qop "auth" got ' + auth.qop)
}
let A1 = this.username + ":" + auth.realm + ':' + this.password;
this.HA1 = md5.default(A1)
this.auth = auth
this.cnonce = 'deadbeef'
this.have_challenge = true;
return resolve()
}).catch((err) => {
return reject(err)
export function createTreeId({contentId, parentId}: { contentId: id, parentId: id }): id {
const objectToStringify = {
contentId,
parentId
};
const stringified = stringify(objectToStringify);
const treeId = md5(stringified);
return treeId;
}