// @bun
var{defineProperty:E,getOwnPropertyNames:V,getOwnPropertyDescriptor:W}=Object,X=Object.prototype.hasOwnProperty;function Y(q){return this[q]}var w=(q)=>{var x=(H??=new WeakMap).get(q),A;if(x)return x;if(x=E({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var B of V(q))if(!X.call(x,B))E(x,B,{get:Y.bind(q,B),enumerable:!(A=W(q,B))||A.enumerable})}return H.set(q,x),x},H;var Z=(q)=>q;function _(q,x){this[q]=Z.bind(null,x)}var z=(q,x)=>{for(var A in x)E(q,A,{get:x[A],enumerable:!0,configurable:!0,set:_.bind(x,A)})};var C=(q,x)=>()=>(q&&(x=q(q=0)),x);import{constants as Q,createPrivateKey as $,createPublicKey as R,sign as J,verify as L}from"crypto";function j(q,x,A={}){let B=A.algorithm??"ed25519",D=typeof x==="string"||Buffer.isBuffer(x)?$(x):x,G=Buffer.from(T(q),"utf8"),U=B==="ed25519"?J(null,G,D):J("sha256",G,{key:D,padding:Q.RSA_PKCS1_PSS_PADDING,saltLength:32});return{...q,signature:{algorithm:B,signature:U.toString("base64"),publicKey:A.publicKey??R(D).export({format:"pem",type:"spki"}).toString(),keyId:A.keyId,issuedAt:N(A.issuedAt)??new Date().toISOString(),expiresAt:N(A.expiresAt),metadata:A.metadata}}}function O(q){if(!q.signature?.signature)throw Error("Skill manifest is missing signature metadata.");let x=Buffer.from(T(q),"utf8"),A=Buffer.from(q.signature.signature,"base64"),B=R(q.signature.publicKey);if(q.signature.algorithm==="ed25519")return L(null,x,B,A);return L("sha256",x,{key:B,padding:Q.RSA_PKCS1_PSS_PADDING,saltLength:32},A)}function T(q){let x=F({...q,signature:void 0});return JSON.stringify(x)}function F(q){if(Array.isArray(q))return q.map((x)=>F(x));if(!q||typeof q!=="object")return q;return Object.fromEntries(Object.entries(q).filter(([,x])=>x!==void 0).sort(([x],[A])=>x.localeCompare(A)).map(([x,A])=>[x,F(A)]))}function N(q){if(!q)return;return typeof q==="string"?new Date(q).toISOString():q.toISOString()}export{O as verifyControlPlaneSkillSignature,j as signControlPlaneSkillManifest,T as canonicalizeControlPlaneSkillManifest};
