Initial AS213905 SDK release

This commit is contained in:
AS213905 Engineering
2026-08-14 11:06:03 +00:00
commit ff4aa1b64e
29 changed files with 3313 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {AS213905, APIError} from '../src/index.js';
test('sets bearer authentication and parses organization', async () => {
const client = new AS213905({apiKey:'secret',fetch:async (url,init)=>{assert.equal(init.headers.Authorization,'Bearer secret');return new Response(JSON.stringify({organization:{asn:213905}}),{status:200,headers:{'content-type':'application/json'}})}});
assert.equal((await client.organization()).asn,213905);
});
test('throws a structured APIError', async () => {
const client = new AS213905({apiKey:'secret',fetch:async()=>new Response(JSON.stringify({error:'scope_required',message:'need traffic:read'}),{status:403})});
await assert.rejects(client.traffic(),error=>error instanceof APIError&&error.status===403&&error.code==='scope_required');
});