import test from 'node:test'; import assert from 'node:assert/strict'; import {KEY_TYPES} from '../node/organisation-key-policy.mjs'; import {generateOrganisationKey,hashOrganisationKey} from '../node/organisation-keys.mjs'; import {formatOrganisationCode,parseOrganisationCode} from '../control-panel/public/codex-code-format.mjs'; for(const [type,{prefix}] of Object.entries(KEY_TYPES))test(type+' survives generation, editions, parsing and hashing',()=>{ const code=generateOrganisationKey(type),digest=hashOrganisationKey(code,type); for(const stage of ['alpha','beta','live'])for(const season of ['S01','S9999']){ const formatted=formatOrganisationCode(code,{stage,version:'1.0.1.2',season}); assert.equal(parseOrganisationCode(formatted).canonical,code); assert.equal(parseOrganisationCode(formatted).prefix,prefix); assert.equal(hashOrganisationKey(formatted,type),digest); assert.equal(hashOrganisationKey(formatted.toLowerCase(),type),digest); } });