id-kit / dist / selftest.js
1
2
3
4
5
6
7
8
import { $APP, shadow$provide } from "./shared.js";
import "./index.js";
import "./xkey.js";
var Z=function(a,b){if(!$APP.n(a))throw Error("id-kit self-test FAILED: "+$APP.u(b));},eb=function(){var a=$APP.A($APP.w(32));Z($APP.N.test(a),"seed shape");return $APP.F(a).then(function(b){return $APP.F(a).then(function(c){Z(b.publicKeyB64===c.publicKeyB64,"identity deterministic from seed");return $APP.D(b.publicKeyB64).then(function(d){Z(64===d.hex.length&&d.emoji.length>0,"fingerprint shape");return b.assert("selftest/v1","room","peer").then(function(e){return $APP.ra("selftest/v1","room","peer",
b.publicKeyB64,e).then(function(f){Z(f!=null,"assertion verifies");return $APP.ra("selftest/v1","room","other",b.publicKeyB64,e).then(function(g){Z(g==null,"bound to peerId");return $APP.ra("selftest/v2","room","peer",b.publicKeyB64,e).then(function(k){Z(k==null,"bound to salt");return{seed:a,id1:b}})})})})})})})},fb=function(a,b){return $APP.Za(a).then(function(c){return $APP.Za(a).then(function(d){Z(c.pubB64===d.pubB64,"x25519 deterministic from seed");return $APP.Ya(a,"someapp/v1").then(function(e){Z(e.pubB64!==
c.pubB64,"x25519 salt-separated");return $APP.$a(b,"ardegazu.ro/id/v1",c.pubB64).then(function(f){return $APP.ab("ardegazu.ro/id/v1",b.publicKeyB64,c.pubB64,f).then(function(g){Z(g,"x cert verifies");return $APP.ab("someapp/v1",b.publicKeyB64,c.pubB64,f).then(function(k){Z($APP.G(k),"x cert bound to salt");k=$APP.v("hello friend");return $APP.cb("ardegazu.ro/id/v1","ctx-1",b.publicKeyB64,c.pubB64,k).then(function(h){return $APP.db("ardegazu.ro/id/v1","ctx-1",h,c).then(function(q){Z(q!=null&&(new TextDecoder).decode(q)===
"hello friend","wrap roundtrip");return $APP.db("ardegazu.ro/id/v1","ctx-2",h,c).then(function(p){Z(p==null,"wrap bound to ctx");return $APP.Za($APP.A($APP.w(32))).then(function(m){return $APP.db("ardegazu.ro/id/v1","ctx-1",h,m).then(function(r){Z(r==null,"wrap sealed to recipient");return null})})})})})})})})})})})};export const runIdKitSelfTest=function(){return eb().then(function(a){var b=a.seed,c=a.id1;return fb(b,c).then(function(){Z($APP.ua(c.publicKeyB64)===$APP.ua(c.publicKeyB64),"hue deterministic");var d=Object.assign(Object.create({evil:1}),{name:"x".repeat(99),hue:720.5,glyph:"\ud83e\udd8a\ud83e\udd8a"});d=$APP.K(d);Z(32===d.name.length&&d.hue==null&&d.glyph==="\ud83e\udd8a","profile clamped");Z($APP.G("evil"in d),"no prototype pollution");Z($APP.V({seed:"short"})==null,"bad seed rejected");d=$APP.V({seed:b,
name:42,hue:"red",createdAt:-5});Z(d!=null&&d.name===""&&d.hue==null&&d.createdAt>0,"record normalized");console.info("✅ id-kit self-test passed")})})};

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/id-kit.git