couchdb-calculate-session-id
v1.1.3
Published
calculates valid CouchDB session IDs using username, salt, secret & timestamp
Downloads
9,681
Readme
couchdb-calculate-session-id
calculates valid CouchDB session IDs using username, salt, secret & timestamp
Example
var calculateSessionId = require('couchdb-calculate-session-id')
var sessionId = calculateSessionId(
'pat',
'24eb90e9e1343977b8323857287ffca4',
'78875068a1979fb910d5d8f37d316aa4',
1449689785
)
Arguments
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