Socket
Socket
Sign inDemoInstall

couchdb-calculate-session-id

Package Overview
Dependencies
3
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    couchdb-calculate-session-id

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


Version published
Weekly downloads
961
decreased by-28.18%
Maintainers
1
Install size
73.9 kB
Created
Weekly downloads
 

Readme

Source

couchdb-calculate-session-id

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

Build Status Coverage Status Dependency Status devDependency Status

Example

var calculateSessionId = require('couchdb-calculate-session-id')

var sessionId = calculateSessionId(
  '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 15 May 2018

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