Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couchdb-calculate-session-id

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
increased by96.48%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 15 May 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc