build/authorify.js
function() {
      var cert;
      try {
        cert = this.keychain.getCertPem();
      } catch (e) {
        throw new CError({
          body: {
            code: 'ImATeapot',
            message: 'missing certificate',
            cause: e
          }
        }).log('body');
      }
      if (!cert) {
        throw new CError('missing certificate').log();
      }
      if (!this.getDate()) {
        throw new CError('missing date').log();
      }
      if (!this.getSid()) {
        throw new CError('missing session identifier').log();
      }
      if (!this.getId()) {
        throw new CError('missing id').log();
      }
      if (!this.getApp()) {
        throw new CError('missing app').log();
      }
      var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::';
      if (this._reply) {
        // NOTE: username is not mandatory in non browser environment
        // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module
        var username = this.getUsername();
        if (!username) {
          username = 'anonymous';
        }
        var password = this.getPassword();
        if (!password) {
          password = forge.util.encode64(forge.random.getBytesSync(16));
        }
        tmp += username + '::' + password + '::' + SECRET_SERVER;
      } else {
        tmp += SECRET_CLIENT;
      }
      var hmac = forge.hmac.create();
      hmac.start('sha256', SECRET);
      hmac.update(tmp);
      return hmac.digest().toHex();
    }
function() {
      var cert;
      try {
        cert = this.keychain.getCertPem();
      } catch (e) {
        throw new CError({
          body: {
            code: 'ImATeapot',
            message: 'missing certificate',
            cause: e
          }
        }).log('body');
      }
      if (!cert) {
        throw new CError('missing certificate').log();
      }
      if (!this.getDate()) {
        throw new CError('missing date').log();
      }
      if (!this.getSid()) {
        throw new CError('missing session identifier').log();
      }
      if (!this.getId()) {
        throw new CError('missing id').log();
      }
      if (!this.getApp()) {
        throw new CError('missing app').log();
      }
      var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::';
      if (this._reply) {
        // NOTE: username is not mandatory in non browser environment
        // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module
        var username = this.getUsername();
        if (!username) {
          username = 'anonymous';
        }
        var password = this.getPassword();
        if (!password) {
          password = forge.util.encode64(forge.random.getBytesSync(16));
        }
        tmp += username + '::' + password + '::' + SECRET_SERVER;
      } else {
        tmp += SECRET_CLIENT;
      }
      var hmac = forge.hmac.create();
      hmac.start('sha256', SECRET);
      hmac.update(tmp);
      return hmac.digest().toHex();
    }
function ( ) { var cert ; try { cert = this . keychain . getCertPem ( ) ; } catch ( e ) { throw new CError ( { body : { code : 'ImATeapot' , message : 'missing certificate' , cause : e } } ) . log ( 'body' ) ; } if ( ! cert ) { throw new CError ( 'missing certificate' ) . log ( ) ; } if ( ! this . getDate ( ) ) { throw new CError ( 'missing date' ) . log ( ) ; } if ( ! this . getSid ( ) ) { throw new CError ( 'missing session identifier' ) . log ( ) ; } if ( ! this . getId ( ) ) { throw new CError ( 'missing id' ) . log ( ) ; } if ( ! this . getApp ( ) ) { throw new CError ( 'missing app' ) . log ( ) ; } var tmp = this . getDate ( ) + '::' + cert + '::' + this . getSid ( ) + '::' + this . getId ( ) + '::' + this . getApp ( ) + '::' ; if ( this . _reply ) { // NOTE: username is not mandatory in non browser environment // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module var username = this . getUsername ( ) ; if ( ! username ) { username = 'anonymous' ; } var password = this . getPassword ( ) ; if ( ! password ) { password = forge . util . encode64 ( forge . random . getBytesSync ( 16 ) ) ; } tmp += username + '::' + password + '::' + SECRET_SERVER ; } else { tmp += SECRET_CLIENT ; } var hmac = forge . hmac . create ( ) ; hmac . start ( 'sha256' , SECRET ) ; hmac . update ( tmp ) ; return hmac . digest ( ) . toHex ( ) ; }
Generate a new token

@returns {String} The generated token
Generate a new token