Skip to content

Commit

Permalink
@davidkhala/crypto 0.0.2
Browse files Browse the repository at this point in the history
prune forge part in release.
add aki and serial getter
  • Loading branch information
davidkhala committed Jan 9, 2024
1 parent 1eacb55 commit ea7fa85
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crypto/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
test
forge
16 changes: 16 additions & 0 deletions crypto/X509Certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ export default class X509Certificate {
}
return result;
}

// authorityKeyIdentifier (AKI)
get authorityKeyIdentifier() {
const authorityKeyIdentifier = this.x509.getExtAuthorityKeyIdentifier();
// it is possible that certificate does not contain Authority Key Identifier
if (!authorityKeyIdentifier) {
return undefined;
}
return authorityKeyIdentifier.kid.hex;
}

// serial number
get serial() {
return this.x509.getSerialNumberHex();
}

}
6 changes: 3 additions & 3 deletions crypto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@davidkhala/crypto",
"version": "0.0.2-alpha.1",
"version": "0.0.2",
"engines": {
"node": ">=17"
},
Expand All @@ -12,10 +12,10 @@
],
"dependencies": {
"jsrsasign": "latest",
"@davidkhala/light": "latest",
"node-forge": "latest"
"@davidkhala/light": "latest"
},
"devDependencies": {
"node-forge": "latest",
"@davidkhala/logger": "latest",
"mocha": "latest",
"@davidkhala/milagro-crypto-js": "latest"
Expand Down
7 changes: 7 additions & 0 deletions crypto/test/X509Cert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import X509Certificate from '../X509Certificate.js';
import assert from 'assert';

describe('X509Certificate', () => {
const pem = `-----BEGIN CERTIFICATE-----
MIIBsDCCAVagAwIBAgIK4I7KBQLVmJNP1zAKBggqhkjOPQQDAjBTMREwDwYDVQQG
Expand All @@ -24,4 +25,10 @@ uh/bNA==
assert.strictEqual(subject.OU, 'blockchain');
assert.strictEqual(subject.CN, 'davidkhala');
});
it('aki', () => {
assert.ifError(x509.authorityKeyIdentifier);
});
it('serial', () => {
assert.strictEqual(x509.serial, 'e08eca0502d598934fd7');
});
});

0 comments on commit ea7fa85

Please sign in to comment.