Cryptosign-based Authentication
Field
Type
Required
Description
'use strict';
import { Wampy } from 'wampy';
import * as wampyCS from 'wampy-cryptosign';
// or you can import only sign method
//import { sign } from 'wampy-cryptosign';
/**
* Manual authentication using signed message
*/
wampy = new Wampy('wss://wamp.router.url', {
realm: 'realm1',
authid: 'joe',
authmethods: ['cryptosign'],
authextra: {
pubkey: '545efb0a2192db8d43f118e9bf9aee081466e1ef36c708b96ee6f62dddad9122'
},
onChallenge: (method, info) => {
console.log('Requested challenge with ', method, info);
return wampyCS.sign('joe secret (private) key')(method, info);
}
});
/**
* Promise-based manual authentication using signed message
*/
wampy = new Wampy('wss://wamp.router.url', {
realm: 'realm1',
authid: 'micky',
authmethods: ['cryptosign'],
authextra: {
pubkey: '545efb0a2192db8d43f118e9bf9aee081466e1ef36c708b96ee6f62dddad9122'
},
onChallenge: (method, info) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('Requested challenge with ', method, info);
resolve(wampyCS.sign('micky secret (private) key')(method, info));
}, 2000);
});
}
});
/**
* Automatic CryptoSign authentication
*/
wampy = new Wampy('wss://wamp.router.url', {
realm: 'realm1',
authid: 'patrik',
authmethods: ['cryptosign'],
authextra: {
pubkey: '545efb0a2192db8d43f118e9bf9aee081466e1ef36c708b96ee6f62dddad9122'
},
onChallenge: wampyCS.sign('patrik secret (private) key')
});Last updated