How to use the uid-safe.sync function in uid-safe

To help you get started, we’ve selected a few uid-safe 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 pillarjs / multiparty / index.js View on Github external
function uploadPath(baseDir, filename) {
  var ext = path.extname(filename).replace(FILE_EXT_RE, '$1');
  var name = uid.sync(18) + ext
  return path.join(baseDir, name);
}
github longztian / koa-session-minimal / src / session.js View on Github external
const regenerateId = () => {
      sid = uid.sync(24)
    }
github onehilltech / blueprint / packages / blueprint-gatekeeper / data / seeds / oauth2 / dev.js View on Github external
mongoose.connect (CONNECTION_STRING);

var accounts = [
  {_id: new mongoose.Types.ObjectId, username: 'gatekeeper_d@gatekeeper.com', password: 'gatekeeper_d'},
]

var clients = [
  {_id: new mongoose.Types.ObjectId, name: 'Gatekeeper Portal', secret: '0987654321', redirect_uri: 'http://localhost:5000/redirect' },
  {_id: new mongoose.Types.ObjectId, name: 'Test Client 1', secret: 'abc123', redirect_uri: 'http://localhost:5000/client1/redirect' },
  {_id: new mongoose.Types.ObjectId, name: 'Test Client 2', secret: 'xyz890', redirect_uri: 'http://localhost:5000/client2/redirect' },
  {_id: new mongoose.Types.ObjectId, name: 'Test Client 3 (disabled)', secret: 'xyz890', redirect_uri: 'http://localhost:5000/client3/redirect', disabled: true},
  {_id: new mongoose.Types.ObjectId, name: 'Test Client 4 (direct login)', secret: '12xdft', redirect_uri: 'http://localhost:5000/client4/redirect'}
];

var tokens = [
  { token : uid.sync (TOKEN_LENGTH), refresh_token : uid.sync (TOKEN_LENGTH), account : accounts[0]._id, client : clients[0]._id}
];

async.series(
  [
    function (callback) { models.Account.remove ({}, callback); },
    function (callback) { models.Account.create (accounts, callback);},

    function (callback) { oauth2.Client.remove ({}, callback); },
    function (callback) { oauth2.Client.create (clients, callback); },

    function (callback) { oauth2.AccessToken.remove ({}, callback); },
    function (callback) { oauth2.AccessToken.create (tokens, callback); }
  ],
  function (err, result) {
    process.exit (err ? 0 : 1);
  }
github hammer-io / yggdrasil / endor / src / services / auth.service.js View on Github external
async createCode(redirectUri, user) {
    this.log.info(`AuthService: create new access code and redirect to ${redirectUri}`);

    let errors = await this.validateId(this.USER, user);
    errors = errors.concat(await this.exists(this.REDIRECT_URI, redirectUri));
    if (errors.length !== 0) {
      return Promise.reject(new InvalidRequestException(errors));
    }

    const code = {
      value: uid.sync(this.CODE_LENGTH),
      redirectURI: redirectUri,
      userId: user
    };
    try {
      const createdCode = await this.codeRepository.create(code);
      return createdCode;
    } catch (err) {
      if (err instanceof sequelize.ForeignKeyConstraintError) {
        return Promise.reject(new InvalidRequestException([err]));
      }

      return Promise.reject(err);
    }
  }
github akanass / rx-otp / lib / components / GoogleAuthenticator.js View on Github external
value: function()
            {
                return self.encode(uid.sync(7).toUpperCase());
            },
            enumerable: true
github trendmicro / SecureCodingDojo / trainingportal / auth.js View on Github external
exports.getSession = function () {
    var ses = session(
    { 
        proxy:true,
        secret: uid.sync(64), 
        resave:false, 
        saveUninitialized:false,
        maxAge: Date.now() + 1000 * 60 * 60 * 2, //2 hours session timeout
        cookie: {secure:config.dojoUrl.startsWith("https")} 
    });

    return ses;

}
github quorrajs / NodeSession / lib / store / Store.js View on Github external
Store.prototype.__generateSessionId = function () {
    return uid(30);
};

uid-safe

URL and cookie safe UIDs

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular uid-safe functions