-
-
Save christiansmith/2d0a54bc7266a28fd62410d31fe6c044 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"payload": { | |
"type": [ | |
"1005 ProofOfEmployment" | |
], | |
"issuer": "https://www.adp.com", | |
"issued": "2017-06-21T11:34:30.951Z", | |
"attr": { | |
"payload": { | |
"sub": "john.smith@acme.com", | |
"employer": { | |
"name": "ACME Company, Inc.", | |
"address": "123 Main Street, Inc." | |
}, | |
"employee": "john@acme.com", | |
"hired": "2017-06-21T11:34:30.946Z", | |
"terminated": "2017-06-21T11:34:30.946Z", | |
"issued": "2017-06-21T11:34:30.946Z" | |
}, | |
"signatures": [ | |
{ | |
"protected": { | |
"alg": "KS256" | |
}, | |
"signature": "MEQCIAci3ySC4X2JMBcgFnUv9VIGMO7UVHPJ_NWuoOTg88imAiBS779V_reT1bvGKa6-sAIZTEJwknSyfUtmXfnkjxr3mg" | |
} | |
] | |
} | |
}, | |
"signatures": [ | |
{ | |
"protected": { | |
"alg": "KS256" | |
}, | |
"signature": "MEUCIQC36AUvBSp0TGjfR_4NFAi-fFSurX6VBG_VtBsIhtIjNwIgW_qFjgUxg4lqlLzHW2vZH1Af07V9l2lFpVBkNlE88vo" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Dependencies | |
*/ | |
const Keychain = require('@trust/keychain') | |
const crypto = require('@trust/webcrypto') | |
const { JWT, JWD } = require('@trust/jose') | |
/** | |
* Generate Keypairs | |
*/ | |
let keys | |
Keychain.generate({ | |
user: { alg: 'KS256' }, | |
provider: { alg: 'KS256' } | |
}) | |
.then(keychain => keys = keychain) | |
/** | |
* User Signature | |
*/ | |
.then(() => { | |
return JWD.sign({ | |
payload: { | |
sub: 'john.smith@acme.com', | |
employer: { | |
name: 'ACME Company, Inc.', | |
address: '123 Main Street, Inc.', | |
}, | |
employee: 'john@acme.com', | |
hired: new Date(), | |
terminated: new Date(), | |
issued: new Date() | |
}, | |
signatures: [ | |
{ | |
'protected': { alg: 'KS256' }, | |
cryptoKey: keys.user.privateKey | |
} | |
] | |
}) | |
}) | |
.then(attr => JSON.parse(attr)) | |
/** | |
* Third Party Attestation | |
*/ | |
.then(attr => { | |
return JWD.sign({ | |
payload: { | |
type: ['1005 ProofOfEmployment'], | |
issuer: 'https://www.adp.com', | |
issued: new Date(), | |
attr | |
}, | |
signatures: [ | |
{ | |
'protected': { alg: 'KS256' }, | |
cryptoKey: keys.provider.privateKey | |
} | |
] | |
}) | |
}) | |
.then(console.log) | |
.catch(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment