Get Certificates
Get Certificates via the SDK
import * as KeetaNet from '@keetanetwork/keetanet-client';
async function main() {
// Target address
const publicKeyString = 'keeta_aabg2lkwuy4gvzr44cniihdmwzinfuunqv4qgsuhbq7jpt4qms622tldjbdexwy';
const account = await KeetaNet.lib.Account.fromPublicKeyString(publicKeyString);
// Read-only client bound to target account
const client = KeetaNet.UserClient.fromNetwork(
'test',
null,
{ account }
);
try {
// Fetch and sort certificates by issuance date (newest first)
const response = await client.getCertificates();
const sorted = response.sort(
(a, b) => b.certificate.notBefore.valueOf() - a.certificate.notBefore.valueOf()
);
console.log(`Found ${sorted.length} certificates for ${account}`);
// Display basic info for each certificate
sorted.forEach(({ certificate }) => {
console.log('Issuer:', certificate.issuerDN);
console.log('Subject:', certificate.subjectDN);
console.log('Valid until:', certificate.notAfter.toISOString());
console.log('—');
});
} finally {
await client.destroy();
}
}
main().catch(console.error);
Last updated