Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public urlBase64Decode(str: string): string {
let output = str.replace(/-/g, '+').replace(/_/g, '/');
switch (output.length % 4) {
case 0: { break; }
case 2: { output += '=='; break; }
case 3: { output += '='; break; }
default: {
throw 'Illegal base64url string!';
}
}
// This does not use btoa because it does not support unicode and the various fixes were... wonky.
return Base64.decode(output);
}
processIdToken(idToken, accessToken) {
var tokenParts = idToken.split(".");
var claimsBase64 = this.padBase64(tokenParts[1]);
var claimsJson = Base64.decode(claimsBase64);
var claims = JSON.parse(claimsJson);
var savedNonce = this._storage.getItem("nonce");
if (Array.isArray(claims.aud)) {
if (claims.aud.every(v => v !== this.clientId)) {
console.warn("Wrong audience: " + claims.aud.join(","));
return false;
}
} else {
if (claims.aud !== this.clientId) {
console.warn("Wrong audience: " + claims.aud);
return false;
}
}
if (this.issuer && claims.iss !== this.issuer) {
export function parseToken (token) {
const parts = token.split('.')
if (parts.length !== 3) {
throw new Error('token malformed')
}
const data = JSON.parse(Base64.decode(parts[1]))
if (Math.round(new Date().getTime() / 1000) > data.exp) {
throw new Error('token expired')
}
localStorage.setItem('jwt', token)
store.commit('setJWT', token)
store.commit('setUser', data.user)
}
if (!param || !param.git || !param.path) {
return route('/start')
}
const data = await fetch(param.git)
.then(response => {
if (response.ok) {
return response.json()
}
return null
})
if (data) {
const { git, path, comments } = param
const lines = Base64.decode(data.content).split('\n')
return {
git,
path,
lines,
comments,
networkError: false,
urlError: false
}
}
route('/start')
}
ContextCarrier.prototype.deserialize = function(traceContext) {
if (!traceContext) {
return this;
}
let traceContextSegment = traceContext.split("-");
if (traceContextSegment.length != 9) {
return this;
}
this._primaryDistributedTraceId = Base64.decode(traceContextSegment[1]);
this._traceSegmentId = Base64.decode(traceContextSegment[2]);
this._spanId = traceContextSegment[3];
this._parentServiceInstanceId = traceContextSegment[4];
this._entryServiceInstanceId = traceContextSegment[5];
this._peerHost = Base64.decode(traceContextSegment[6]);
this._entryEndpointName = Base64.decode(traceContextSegment[7]);
this._parentEndpointName = Base64.decode(traceContextSegment[8]);
};
.done(function (data) {
if ('content' in data) {
cb(null, base64.decode(data.content))
} else {
cb('Content not received')
}
})
.fail(function (xhr, text, err) {
result.map(async n => {
const notification: INotification = {
id: n.ggid,
content: decodeHTML(Base64.decode(n.ggnr)),
title: decodeHTML(n.bt),
url: URL.LEARN_NOTIFICATION_DETAIL(courseID, n.ggid),
publisher: n.fbrxm,
hasRead: n.sfyd === '是',
markedImportant: n.sfqd === '1',
publishTime: new Date(n.fbsjStr),
};
let detail: INotificationDetail = {};
if (n.fjmc !== null) {
notification.attachmentName = n.fjmc;
detail = await this.parseNotificationDetail(courseID, notification.id);
}
notifications.push({ ...notification, ...detail });
}),
);
decode(payload) {
super.decode(payload);
this.callId = payload.content;
let json = Base64.decode(payload.binaryContent);
let obj = JSON.parse(json);
this.connectTime = obj.c;
this.endTime = obj.e;
this.status = obj.s;
this.audioOnly = (obj.a === 1);
this.targetId = obj.t;
}
}
function decodeWidgetDataObject(data) {
return JSON.parse(base64.decode(data));
}
unbase64: function(str) {
return Base64.decode(str);
},