
@windingtree/org.id-auth
ORGiD authentication library
Setup
npm install @windingtree/org.id-auth
Usage
VC signed with private key
const privateKey = '<PRIVATE_KEY_KEYLIKE_OR_JWK>';
const issuer = 'did:orgid:4:0x7b15197de62b0bc73da908b215666c48e1e49ed38e4486f5f6f094458786412d#key-1';
const holder = 'did:orgid:4:0xcfdb769eafae259e58028ba25ab70ce539731b593c08b780e5275c723132d206';
const subject = {
test: '123'
};
const vc = await createVC(
issuer,
'VerifiableCredential'
)
.setHolder(holder)
.setExpirationDate(new Date('2031-06-29').toISOString())
.setValidFrom(new Date('2031-05-30').toISOString())
.setValidUntil(new Date('2031-06-28').toISOString())
.setCredentialSubject(subject)
.sign(privateKey);
const payload = await verifyVC(vc, publicKey);
VC signed with blockchain account
Currently, supported Ethereum account type (eip155) only.
const web3Provider = '<WEB3_PROVIDER>';
const account = '<ETH_ACCOUNT>';
const issuerBlockchainAccountId = `${account}@eip155:1`;
const vc = await createVC(
issuer,
'TestCredential'
)
.setHolder(holder)
.setExpirationDate(new Date('2031-06-29').toISOString())
.setValidFrom(new Date('2031-05-30').toISOString())
.setValidUntil(new Date('2031-06-28').toISOString())
.setCredentialSubject(subject)
.signWithBlockchainAccount(
issuerBlockchainAccountId,
{
web3Provider
}
);
const payload = await verifyVC(vc, issuerBlockchainAccountId);
Documentation
Generated docs
Manual keys generation
secp256k1 ECPrivateKey format
openssl ecparam -name secp256k1 -genkey -out ./key.pem
openssl ec -in ./key.pem -pubout > ./key.pub
secp256k1 PKCS#8 format (unencrypted)
openssl ecparam -name secp256k1 -genkey -out ./key.pem
openssl pkcs8 -in ./key.pem -topk8 -nocrypt -out ./pkcs8.pem
openssl ec -in ./pkcs8.pem -pubout > ./key.pub