Skip to content
WSSE Username Token generator for Node.js
Branch: master
Clone or download
Latest commit fdafc7a Jun 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix encoding bugs Jan 22, 2019
test add some tests Jan 23, 2019
.gitignore ignore nyc output Jan 22, 2019
.travis.yml
LICENSE update license Jan 22, 2019
README.md update readme Jan 22, 2019
package-lock.json 4.0.0 Jun 6, 2019
package.json 4.0.0 Jun 6, 2019
tsconfig.json coffee -> ts Jan 22, 2019
tslint.json coffee -> ts Jan 22, 2019

README.md

WSSE

WSSE Username Token generator for Node.js

See: http://www.xml.com/pub/a/2003/12/17/dive.html

Installation

npm install wsse

Usage

import wsse from 'wsse';

const token = wsse({ username: 'bob', password: 'taadtaadpstcsm' });

// 'bob'
console.log(token.getUsername());

// 'taadtaadpstcsm'
console.log(token.getPassword());

// e.g. '2003-12-15T14:43:07Z'
console.log(token.getCreated());

// e.g. 'd36e316282959a9ed4c89851497a717f'
console.log(token.getNonce());

// e.g. 'quR/EWLAV4xLf9Zqyw4pDmfV9OY='
console.log(token.getPasswordDigest());

// e.g. 'UsernameToken Username="bob", PasswordDigest="quR/EWLAV4xLf9Zqyw4pDmfV9OY=", Nonce="d36e316282959a9ed4c89851497a717f", Created="2003-12-15T14:43:07Z"'
console.log(token.getWSSEHeader());
console.log(token.toString());
console.log(token + '');

// ----- advanced -----

// you can use `UsernameToken` class.
const token2 = new wsse.UsernameToken({
  username: 'bob',                           // (required)
  password: 'taadtaadpstcsm',                // (required)
  created: '2003-12-15T14:43:07Z',           // (optional) you can specify `craeted`.
  nonce: 'd36e316282959a9ed4c89851497a717f', // (optional) you can specify `nonce`.
  sha1encoding: 'hex'                        // (optional) you can specify `sha1encoding` for wrong WSSE Username Token implementation.
});

// you can use `nonceBase64` option. it encodes the nonce to base64 in header.
// 'UsernameToken Username="bob", PasswordDigest="quR/EWLAV4xLf9Zqyw4pDmfV9OY=", Nonce="ZDM2ZTMxNjI4Mjk1OWE5ZWQ0Yzg5ODUxNDk3YTcxN2Y=", Created="2003-12-15T14:43:07Z"'
// e.g. Hatena API http://developer.hatena.ne.jp/ja/documents/auth/apis/wsse
console.log(token2.getWSSEHeader({ nonceBase64: true }));
console.log(token2.toString({ nonceBase64: true }));

Badges

npm version Travis CI Coveralls

License

>=2.0.0

MIT

<1.0.0

ISC

Author

bouzuya <m@bouzuya.net> (http://bouzuya.net)

You can’t perform that action at this time.