Inspect your first key
Install one package and inspect a public key in memory. This example needs no key file, credentials or server. The sample is a public Ed25519 key; it contains no private key material.
Install
sh
npm install @jalsoedesign/dockline-keysSave the example
Choose a tab and save its filename. TypeScript is the default. Download: TypeScript · JavaScript · MJS · CommonJS.
ts
// inspect-key.ts
import {inspectKey, type KeyInfo} from '@jalsoedesign/dockline-keys';
const keyContents = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICHSfk0iVuoJjZcokMlnUBsZMppVQ/KGDxV8Jb7lF8qo documentation@example';
const info: KeyInfo = await inspectKey(keyContents);
console.log('Kind:', info.kind);
console.log('Format:', info.format);
console.log('Algorithm:', info.algorithm);
console.log('Encrypted:', info.encrypted);js
// inspect-key.js
import {inspectKey} from '@jalsoedesign/dockline-keys';
const keyContents = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICHSfk0iVuoJjZcokMlnUBsZMppVQ/KGDxV8Jb7lF8qo documentation@example';
const info = await inspectKey(keyContents);
console.log('Kind:', info.kind);
console.log('Format:', info.format);
console.log('Algorithm:', info.algorithm);
console.log('Encrypted:', info.encrypted);js
// inspect-key.mjs
import {inspectKey} from '@jalsoedesign/dockline-keys';
const keyContents = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICHSfk0iVuoJjZcokMlnUBsZMppVQ/KGDxV8Jb7lF8qo documentation@example';
const info = await inspectKey(keyContents);
console.log('Kind:', info.kind);
console.log('Format:', info.format);
console.log('Algorithm:', info.algorithm);
console.log('Encrypted:', info.encrypted);js
// inspect-key.cjs
const {inspectKey} = require('@jalsoedesign/dockline-keys');
async function main() {
const keyContents = 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICHSfk0iVuoJjZcokMlnUBsZMppVQ/KGDxV8Jb7lF8qo documentation@example';
const info = await inspectKey(keyContents);
console.log('Kind:', info.kind);
console.log('Format:', info.format);
console.log('Algorithm:', info.algorithm);
console.log('Encrypted:', info.encrypted);
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});Run
sh
npm install --save-dev typescript tsx @types/node
npm pkg set type=module
npx tsx inspect-key.tssh
npm pkg set type=module
node inspect-key.jssh
node inspect-key.mjssh
node inspect-key.cjsOutput
text
Kind: public
Format: openssh
Algorithm: ed25519
Encrypted: falseinspectKey returns metadata; the example prints these four fields. A public key is not encrypted private input. The same API can inspect a private key, including supported encrypted input when you supply its passphrase.
Next: fingerprints and inspection, try encrypted conversion, or read a file.