How to use the js-base64.Base64.decode function in js-base64

To help you get started, we’ve selected a few js-base64 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github auth0 / angular2-jwt / angular2-jwt.ts View on Github external
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);
  }
github manfredsteyer / angular-oauth2-oidc / src / oauth-service.ts View on Github external
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) {
github filebrowser / filebrowser / frontend / src / utils / auth.js View on Github external
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)
}
github code-and-comment / code-and-comment / src / jsx / actions / view.jsx View on Github external
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')
}
github SkyAPM / SkyAPM-nodejs / modules / nodejs-agent / lib / trace / context-carrier.js View on Github external
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]);
};
github chriseth / browser-solidity / src / app.js View on Github external
.done(function (data) {
        if ('content' in data) {
          cb(null, base64.decode(data.content))
        } else {
          cb('Content not received')
        }
      })
      .fail(function (xhr, text, err) {
github Harry-Chen / thu-learn-lib / src / index.ts View on Github external
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 });
      }),
    );
github wildfirechat / pc-chat / src / js / wfc / av / messages / callStartMessageContent.js View on Github external
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;
  }
}
github QardsJs / qards / plugins / qards-netlify-cms-paths / gatsby-node.js View on Github external
function decodeWidgetDataObject(data) {
		return JSON.parse(base64.decode(data));
	}
github YMFE / yapi / common / power-string.js View on Github external
unbase64: function(str) {
    return Base64.decode(str);
  },