This package has been deprecated

    Author message:

    couchdb-generate-session-id is now couchdb-calculate-session-id

    couchdb-generate-session-id

    2.0.0 • Public • Published

    couchdb-generate-session-id

    generates valid CouchDB session IDs using username, salt, secret & timestamp

    Build Status Coverage Status Dependency Status devDependency Status

    Example

    var generateSessionId = require('couchdb-generate-session-id')
     
    var sessionId = generateSessionId(
      'pat',
      '24eb90e9e1343977b8323857287ffca4',
      '78875068a1979fb910d5d8f37d316aa4',
      1449689785
    )

    Arguments

    Argument Type Description
    username String name property of \_users doc
    usersalt String salt property of \_users doc
    serversecret String couch_httpd_auth.secret of CouchDB configuration
    timestamp Number Number of seconds elapsed since 1 January 1970 00:00:00 UTC

    How CouchDB does it using Erlang

    make_cookie_hash(UserNameSecretTimeStamp) ->
        SessionData = UserName ++ ":" ++ erlang:integer_to_list(TimeStamp, 16),
        Hash = crypto:sha_mac(Secret, SessionData),
        couch_util:encodeBase64Url(SessionData ++ ":" ++ ?b2l(Hash)).

    Credits

    All credits due to @christophwitzko, @indutny & @janl: https://gist.github.com/janl/4583f5eb4c0d8216cc5f

    License

    Apache-2.0

    Install

    npm i couchdb-generate-session-id

    DownloadsWeekly Downloads

    0

    Version

    2.0.0

    License

    Apache-2.0

    Last publish

    Collaborators

    • hoodie