0.8.4-alpha.9653 • Published 3 years ago

@castframework/chain-auth v0.8.4-alpha.9653

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
3 years ago

LICENSE

https://www.societegenerale.com/fr/mentions-legales

Code

Making request with a signed claim

import { generateNewJws, signJws } from '@castframework/chain-auth';

const privateKey = getMyPrivateKey(); const ethAddress = ethAddrFromPrivateKey(privateKey); const claim = generateNewJws(ethAddress, 'myservice.com'); const signedClaim = signJws(claim, privateKey);

http.get('myservice.com/goblin', { header: { authorization: Bearer ${signedClaim} } })

Verifying a signed claim

import { authenticate } from '@castframework/chain-auth';

const auth = getAuthFieldFromRequest(request); // get something like 'Bearer 0x40935789042SDFE750984375ASF893475098109345'

const token = auth.dropBearer();

const isClaimTrue = authenticate(token);