Socket
Socket
Sign inDemoInstall

couchdb-generate-session-id

Package Overview
Dependencies
19
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    couchdb-generate-session-id

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


Version published
Weekly downloads
4
increased by300%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

ArgumentTypeDescription
usernameStringname property of \_users doc
usersaltStringsalt property of \_users doc
serversecretStringcouch_httpd_auth.secret of CouchDB configuration
timestampNumberNumber of seconds elapsed since 1 January 1970 00:00:00 UTC

How CouchDB does it using Erlang

make_cookie_hash(UserName, Secret, TimeStamp) ->
    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

Keywords

FAQs

Last updated on 11 Dec 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc