bsv-bap 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/MemberID.d.ts
CHANGED
@@ -12,7 +12,7 @@ export declare class MemberID extends BaseClass {
|
|
12
12
|
address: string;
|
13
13
|
signature: string;
|
14
14
|
};
|
15
|
-
signOpReturnWithAIP(opReturn: number[][]
|
15
|
+
signOpReturnWithAIP(opReturn: number[][]): number[][];
|
16
16
|
getPublicKey(): string;
|
17
17
|
import(identity: MemberIdentity): void;
|
18
18
|
static fromMemberIdentity(identity: MemberIdentity): MemberID;
|
package/dist/index.modern.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
// @bun
|
2
|
-
import{BSM as D,BigNumber as Lj,ECIES as wj,HD as Yj,OP as I,Signature as Gj}from"@bsv/sdk";import{Utils as Fj}from"@bsv/sdk";var s=async(j,$,J,q)=>{let z=`${J}${j}`;return(await fetch(z,{method:"post",headers:{"Content-type":"application/json; charset=utf-8",token:q,format:"json"},body:JSON.stringify($)})).json()},R=(j,$)=>async(J,q)=>{return s(J,q,j,$)};import{Utils as r}from"@bsv/sdk";var{toHex:K,toArray:g}=r,X="1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT",m=K(g(X)),M="15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva",
|
2
|
+
import{BSM as D,BigNumber as Lj,ECIES as wj,HD as Yj,OP as I,Signature as Gj}from"@bsv/sdk";import{Utils as Fj}from"@bsv/sdk";var s=async(j,$,J,q)=>{let z=`${J}${j}`;return(await fetch(z,{method:"post",headers:{"Content-type":"application/json; charset=utf-8",token:q,format:"json"},body:JSON.stringify($)})).json()},R=(j,$)=>async(J,q)=>{return s(J,q,j,$)};import{Utils as r}from"@bsv/sdk";var{toHex:K,toArray:g}=r,X="1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT",m=K(g(X)),M="15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva",kj=K(g(M)),T="https://api.sigmaidentity.com/v1",G=2147483647,O="m/424150'/0'/0'",w=`m/424150'/${G}'/${G}'`;import{BSM as x,Utils as Qj,ECIES as Wj,Hash as U,PublicKey as N,BigNumber as l}from"@bsv/sdk";import{randomBytes as i}from"crypto";var Y={getRandomString(j=32){return i(j).toString("hex")},getSigningPathFromHex(j,$=!0){let J="m",q=j.match(/.{1,8}/g);if(!q)throw new Error("Invalid hex string");let z=2147483647;for(let Q of q){let Z=Number(`0x${Q}`);if(Z>z)Z-=z;J+=`/${Z}${$?"'":""}`}return J},getNextIdentityPath(j){let $=j.split("/"),J=$[$.length-2],q=!1;if(J.match("'"))q=!0;let z=(Number(J.replace(/[^0-9]/g,""))+1).toString();return $[$.length-2]=z+(q?"'":""),$[$.length-1]=`0${q?"'":""}`,$.join("/")},getNextPath(j){let $=j.split("/"),J=$[$.length-1],q=!1;if(J.match("'"))q=!0;let z=(Number(J.replace(/[^0-9]/g,""))+1).toString();return $[$.length-1]=z+(q?"'":""),$.join("/")}};import{BSM as H,Utils as vj,PrivateKey as S,BigNumber as qj}from"@bsv/sdk";import{ECIES as a,Utils as e,OP as A,PublicKey as c}from"@bsv/sdk";var{toArray:C,toUTF8:t,toBase64:jj}=e,{electrumDecrypt:$j,electrumEncrypt:Jj}=a;class V{identityAttributes={};encrypt(j,$){let{privKey:J,pubKey:q}=this.getEncryptionKey(),z=$?c.fromString($):q;return jj(Jj(C(j),z,J))}decrypt(j,$){let{privKey:J}=this.getEncryptionKey(),q=void 0;if($)q=c.fromString($);return t($j(C(j,"base64"),J,q))}signOpReturnWithAIP(j,$){let J=this.getAIPMessageBuffer(j),{address:q,signature:z}=this.signMessage(J.flat(),$);return this.formatAIPOutput(J,q,z)}getAttributes(){return this.identityAttributes}getAttribute(j){if(this.identityAttributes[j])return this.identityAttributes[j];return null}setAttribute(j,$){if(!$)return;if(this.identityAttributes[j])this.updateExistingAttribute(j,$);else this.createNewAttribute(j,$)}unsetAttribute(j){delete this.identityAttributes[j]}addAttribute(j,$,J=""){let q=J;if(!J)q=Y.getRandomString();this.identityAttributes[j]={value:$,nonce:q}}getAttributeUrns(){let j="";for(let $ in this.identityAttributes){let J=this.getAttributeUrn($);if(J)j+=`${J}
|
3
3
|
`}return j}getAttributeUrn(j){let $=this.identityAttributes[j];if($)return`urn:bap:id:${j}:${$.value}:${$.nonce}`;return null}parseStringUrns(j){let $={},J=j.replace(/^\s+/g,"").replace(/\r/gm,"").split(`
|
4
|
-
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}updateExistingAttribute(j,$){if(typeof $==="string"){this.identityAttributes[j].value=$;return}if(this.identityAttributes[j].value=$.value||"",$.nonce)this.identityAttributes[j].nonce=$.nonce}createNewAttribute(j,$){if(typeof $==="string"){this.addAttribute(j,$);return}this.addAttribute(j,$.value||"",$.nonce)}getAIPMessageBuffer(j,$){let J=j.findIndex((z)=>z[0]===A.OP_RETURN),q=[];if(J===-1)q.push([A.OP_RETURN]),J=0;if($)for(let z of $)q.push(j[J+z]);else for(let z of j)q.push(z);
|
5
|
-
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}getIdentityKey(){return this.identityKey}set rootPath(j){if(this.#j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error(`invalid signing path given ${$}`);this.#$=$;let J=this.#j.derive($);this.rootAddress=J.pubKey.toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress),this.#q=$,this.#z=$}}get rootPath(){return this.#$}getRootPath(){return this.#$}set currentPath(j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error("invalid signing path given");this.#q=this.#z,this.#z=$}get currentPath(){return this.#z}get previousPath(){return this.#q}get idSeed(){return this.#W}incrementPath(){this.currentPath=Y.getNextPath(this.currentPath)}validatePath(j){if(j.match(/\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?/)){let $=j.split("/");if($.length===7&&Number($[1].replace("'",""))<=G&&Number($[2].replace("'",""))<=G&&Number($[3].replace("'",""))<=G&&Number($[4].replace("'",""))<=G&&Number($[5].replace("'",""))<=G&&Number($[6].replace("'",""))<=G)return!0}return!1}getInitialIdTransaction(){return this.getIdTransaction(this.#$)}getIdTransaction(j=""){if(this.#z===this.#$)throw new Error("Current path equals rootPath. ID was probably not initialized properly");let $=[F(X),F("ID"),F(this.identityKey),F(this.getCurrentAddress())];return this.signOpReturnWithAIP($,j||this.#q)}getAddress(j){return this.#j.derive(j).privKey.toPublicKey().toAddress()}getCurrentAddress(){return this.getAddress(this.#z)}getEncryptionKey(){let $=this.#j.derive(this.#$).derive(w).privKey;return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionKeyType42(){let j=this.#j.derive(this.#$),$=j.privKey.deriveChild(j.toPublic().pubKey,w);return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}getEncryptionPublicKeyWithSeed(j){return this.getEncryptionPrivateKeyWithSeed(j).toPublicKey().toString()}encrypt(j,$){let z=this.#j.derive(this.#$).derive(w).privKey.toPublicKey(),Q=$?N.fromString($):z;return b(P(F(j),Q,null))}decrypt(j,$){let q=this.#j.derive(this.#$).derive(w).privKey,z=void 0;if($)z=N.fromString($);return p(h(F(j,"base64"),q,z))}encryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=q.toPublicKey(),Q=J?N.fromString(J):z;return b(P(F(j),Q,q))}decryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=void 0;if(J)z=N.fromString(J);return p(h(F(j,"base64"),q,z))}getEncryptionPrivateKeyWithSeed(j){let $=
|
6
|
-
`,J),this.importOldIds(J);return}if(typeof J!=="object")throw new Error("decrypted, but found unrecognized identities format");this.importIds(J,!1)}importOldIds(j){for(let $ of j){let J=new _(this.#j,{},$.idSeed??"");J.BAP_SERVER=this.#Q,J.BAP_TOKEN=this.#$,J.import($),this.checkIdBelongs(J),this.#J[J.getIdentityKey()]=J,this.#q=J.currentPath}}exportIds(j,$=!0){let J={lastIdPath:this.#q,ids:[]},q=j||Object.keys(this.#J);for(let z of q){if(!this.#J[z])throw new Error(`Identity ${z} not found`);J.ids.push(this.#J[z].export())}if($)return this.encrypt(JSON.stringify(J));return J}exportId(j,$=!0){let J={lastIdPath:this.#q,ids:[]};if(J.ids.push(this.#J[j].export()),$)return this.encrypt(JSON.stringify(J));return J}encrypt(j){let $=this.#j.derive(w);return y(Xj(W(j),$.pubKey,null))}decrypt(j){let $=this.#j.derive(w);return E(Cj(W(j,"base64"),$.privKey))}signAttestationWithAIP(j,$,J=0,q=""){let z=this.getId($);if(!z)throw new Error("Could not find identity to attest with");let Q=this.getAttestationBuffer(j,J,q),{address:Z,signature:L}=z.signMessage(Q);return this.createAttestationTransaction(j,J,Z,L,q)}verifyAttestationWithAIP(j){if(!j.every((q)=>Array.isArray(q))||j[0][0]!==I.OP_RETURN||v(j[1])!==m)throw new Error("Not a valid BAP transaction");let $=v(j[7])==="44415441"?5:0,J={type:E(j[2]),hash:v(j[3]),sequence:E(j[4]),signingProtocol:E(j[7+$]),signingAddress:E(j[8+$]),signature:y(j[9+$])};if($&&j[3]===j[8])J.data=v(j[9]);console.log({attestation:J});try{let q=[];for(let z=0;z<6+$;z++)q.push(j[z]);J.verified=this.verifySignature(q.flat(),J.signingAddress,J.signature)}catch(q){J.verified=!1}return J}createAttestationTransaction(j,$,J,q,z=""){let Q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(z)Q.push(W(X),W("DATA"),W(j),W(z),W("|"));return Q.push(W(M),W("BITCOIN_ECDSA"),W(J),W(q,"base64")),console.log({elements:Q}),Q}getAttestationBuffer(j,$=0,J=""){let q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(J)q.push(W(X),W("DATA"),W(j),W(J),W("|"));return q.flat()}verifySignature(j,$,J){let q;if(Array.isArray(j))q=j;else if(Buffer.isBuffer(j))q=[...j];else q=W(j,"utf8");let z=Gj.fromCompact(J,"base64"),Q;for(let Z=0;Z<4;Z++)try{if(Q=z.RecoverPublicKey(Z,new Lj(D.magicHash(q))),D.verify(q,z,Q)&&Q.toAddress()===$)return!0}catch(L){}return!1}async verifyChallengeSignature(j,$,J,q){if(!this.verifySignature(J,$,q))return!1;try{let Q=await this.getApiData("/attestation/valid",{idKey:j,address:$,challenge:J,signature:q});if(Q?.status==="success"&&Q?.result?.valid===!0)return!0;return!1}catch(Q){return console.error("API call failed:",Q),!1}}async isValidAttestationTransaction(j){if(this.verifyAttestationWithAIP(j))return this.getApiData("/attestation/valid",{tx:j});return!1}async getIdentityFromAddress(j){return this.getApiData("/identity/from-address",{address:j})}async getIdentity(j){return this.getApiData("/identity/get",{idKey:j})}async getAttestationsForHash(j){return this.getApiData("/attestations",{hash:j})}}export{
|
4
|
+
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}updateExistingAttribute(j,$){if(typeof $==="string"){this.identityAttributes[j].value=$;return}if(this.identityAttributes[j].value=$.value||"",$.nonce)this.identityAttributes[j].nonce=$.nonce}createNewAttribute(j,$){if(typeof $==="string"){this.addAttribute(j,$);return}this.addAttribute(j,$.value||"",$.nonce)}getAIPMessageBuffer(j,$){let J=j.findIndex((z)=>z[0]===A.OP_RETURN),q=[];if(J===-1)q.push([A.OP_RETURN]),J=0;if($)for(let z of $)q.push(j[J+z]);else for(let z of j)q.push(z);return q}formatAIPOutput(j,$,J){let q=[C("|"),C(M),C("BITCOIN_ECDSA"),C($),C(J,"base64")];return[...j,...q]}}var{magicHash:zj}=H;class f extends V{key;idName;description;address;identityKey;constructor(j,$={}){super();this.key=j,this.address=j.toAddress(),this.idName="Member ID 1",this.description="",this.identityKey="",this.identityAttributes=this.parseAttributes($)}signMessage(j,$){let J=this.key,q=J.toAddress(),z=H.sign(j,J,"raw"),Q=new qj(zj(j)),Z=z.CalculateRecoveryFactor(J.toPublicKey(),Q),L=H.sign(j,J,"raw").toCompact(Z,!0,"base64");return{address:q,signature:L}}signOpReturnWithAIP(j){let $=this.getAIPMessageBuffer(j),{address:J,signature:q}=this.signMessage($.flat());return this.formatAIPOutput($,J,q)}getPublicKey(){return this.key.toPublicKey().toString()}import(j){this.idName=j.name,this.description=j.description,this.key=S.fromWif(j.derivedPrivateKey),this.address=this.key.toAddress(),this.identityAttributes=j.identityAttributes||{},this.identityKey=j.identityKey}static fromMemberIdentity(j){let $=new f(S.fromWif(j.derivedPrivateKey));return $.import(j),$}static fromBackup(j){let $=new f(S.fromWif(j.wif)),J=JSON.parse($.decrypt(j.id));return $.import(J),$}export(){return{name:this.idName,description:this.description,derivedPrivateKey:this.key.toWif(),address:this.address,identityAttributes:this.getAttributes(),identityKey:this.identityKey}}getEncryptionKey(){return{privKey:this.key.deriveChild(this.key.toPublicKey(),w),pubKey:this.key.deriveChild(this.key.toPublicKey(),w).toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}}var{toArray:F,toHex:k,toBase58:Zj,toUTF8:p,toBase64:b}=Qj,{electrumDecrypt:h,electrumEncrypt:P}=Wj,{magicHash:o}=x;class _ extends V{#j;#J=T;#Q="";#$;#q;#z;#W;idName;description;rootAddress;identityKey;identityAttributes;getApiData;constructor(j,$={},J=""){super();if(J){let Q=k(U.sha256(J,"utf8")),Z=Y.getSigningPathFromHex(Q);this.#j=j.derive(Z)}else this.#j=j;this.#W=J,this.idName="ID 1",this.description="",this.#$=`${O}/0/0/0`,this.#q=`${O}/0/0/0`,this.#z=`${O}/0/0/1`;let q=this.#j.derive(this.#$);this.rootAddress=q.privKey.toPublicKey().toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress);let z={...$};this.identityAttributes=this.parseAttributes(z),this.getApiData=R(this.#J,this.#Q)}set BAP_SERVER(j){this.#J=j}get BAP_SERVER(){return this.#J}set BAP_TOKEN(j){this.#Q=j}get BAP_TOKEN(){return this.#Q}deriveIdentityKey(j){let $=k(U.sha256(j,"utf8"));return Zj(U.ripemd160($,"hex"))}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}parseStringUrns(j){let $={},J=j.replace(/^\s+/g,"").replace(/\r/gm,"").split(`
|
5
|
+
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}getIdentityKey(){return this.identityKey}set rootPath(j){if(this.#j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error(`invalid signing path given ${$}`);this.#$=$;let J=this.#j.derive($);this.rootAddress=J.pubKey.toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress),this.#q=$,this.#z=$}}get rootPath(){return this.#$}getRootPath(){return this.#$}set currentPath(j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error("invalid signing path given");this.#q=this.#z,this.#z=$}get currentPath(){return this.#z}get previousPath(){return this.#q}get idSeed(){return this.#W}incrementPath(){this.currentPath=Y.getNextPath(this.currentPath)}validatePath(j){if(j.match(/\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?/)){let $=j.split("/");if($.length===7&&Number($[1].replace("'",""))<=G&&Number($[2].replace("'",""))<=G&&Number($[3].replace("'",""))<=G&&Number($[4].replace("'",""))<=G&&Number($[5].replace("'",""))<=G&&Number($[6].replace("'",""))<=G)return!0}return!1}getInitialIdTransaction(){return this.getIdTransaction(this.#$)}getIdTransaction(j=""){if(this.#z===this.#$)throw new Error("Current path equals rootPath. ID was probably not initialized properly");let $=[F(X),F("ID"),F(this.identityKey),F(this.getCurrentAddress())];return this.signOpReturnWithAIP($,j||this.#q)}getAddress(j){return this.#j.derive(j).privKey.toPublicKey().toAddress()}getCurrentAddress(){return this.getAddress(this.#z)}getEncryptionKey(){let $=this.#j.derive(this.#$).derive(w).privKey;return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionKeyType42(){let j=this.#j.derive(this.#$),$=j.privKey.deriveChild(j.toPublic().pubKey,w);return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}getEncryptionPublicKeyWithSeed(j){return this.getEncryptionPrivateKeyWithSeed(j).toPublicKey().toString()}encrypt(j,$){let z=this.#j.derive(this.#$).derive(w).privKey.toPublicKey(),Q=$?N.fromString($):z;return b(P(F(j),Q,null))}decrypt(j,$){let q=this.#j.derive(this.#$).derive(w).privKey,z=void 0;if($)z=N.fromString($);return p(h(F(j,"base64"),q,z))}encryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=q.toPublicKey(),Q=J?N.fromString(J):z;return b(P(F(j),Q,q))}decryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=void 0;if(J)z=N.fromString(J);return p(h(F(j,"base64"),q,z))}getEncryptionPrivateKeyWithSeed(j){let $=k(U.sha256(j,"utf8")),J=Y.getSigningPathFromHex($);return this.#j.derive(this.#$).derive(J).privKey}getAttestation(j){let $=U.sha256(j,"utf8");return`bap:attest:${k($)}:${this.getIdentityKey()}`}getAttestationHash(j){let $=this.getAttributeUrn(j);if(!$)return null;let J=this.getAttestation($),q=U.sha256(J,"utf8");return k(q)}signMessage(j,$){let J=$||this.#z,q=this.#j.derive(J).privKey,z=q.toAddress(),Q=x.sign(j,q,"raw"),Z=new l(o(j)),L=Q.CalculateRecoveryFactor(q.toPublicKey(),Z),B=x.sign(j,q,"raw").toCompact(L,!0,"base64");return{address:z,signature:B}}signMessageWithSeed(j,$){let J=k(U.sha256($,"utf8")),q=Y.getSigningPathFromHex(J),Q=this.#j.derive(this.#$).derive(q),Z=Q.privKey.toPublicKey().toAddress(),L=F(j,"utf8"),B=x.sign(L,Q.privKey,"raw"),u=new l(o(L)),n=B.CalculateRecoveryFactor(Q.privKey.toPublicKey(),u),d=x.sign(L,Q.privKey,"raw").toCompact(n,!0,"base64");return{address:Z,signature:d}}signOpReturnWithAIP(j,$=""){let J=this.getAIPMessageBuffer(j),{address:q,signature:z}=this.signMessage(J.flat(),$);return this.formatAIPOutput(j,q,z)}async getIdSigningKeys(){let j=await this.getApiData("/signing-keys",{idKey:this.identityKey});return console.log("getIdSigningKeys",j),j}async getAttributeAttestations(j){let $=this.getAttestationHash(j),J=await this.getApiData("/attestation/get",{hash:$});return console.log("getAttestations",j,$,J),J}import(j){this.idName=j.name,this.description=j.description||"",this.identityKey=j.identityKey,this.#$=j.rootPath,this.rootAddress=j.rootAddress,this.#q=j.previousPath,this.#z=j.currentPath,this.#W=("idSeed"in j?j.idSeed:"")||"",this.identityAttributes=this.parseAttributes(j.identityAttributes)}export(){return{name:this.idName,description:this.description,identityKey:this.identityKey,rootPath:this.#$,rootAddress:this.rootAddress,previousPath:this.#q,currentPath:this.#z,idSeed:this.#W,identityAttributes:this.getAttributes(),lastIdPath:""}}exportMemberBackup(){let j=this.#j.derive(this.#z).privKey;return{name:this.idName,description:this.description,derivedPrivateKey:j.toWif(),address:j.toPublicKey().toAddress(),identityAttributes:this.getAttributes(),identityKey:this.identityKey}}newId(){this.incrementPath();let j=this.#j.derive(this.#z).privKey;return new f(j)}}var{toArray:W,toUTF8:E,toBase64:y,toHex:v}=Fj,{electrumEncrypt:Xj,electrumDecrypt:Cj}=wj;class Uj{#j;#J={};#Q=T;#$="";#q="";getApiData;constructor(j,$="",J=""){if(!j)throw new Error("No HDPrivateKey given");if(this.#j=Yj.fromString(j),$)this.#$=$;if(J)this.#Q=J;this.getApiData=R(this.#Q,this.#$)}get lastIdPath(){return this.#q}getPublicKey(j=""){if(j)return this.#j.derive(j).pubKey.toString();return this.#j.pubKey.toString()}getHdPublicKey(j=""){if(j)return this.#j.derive(j).toPublic().toString();return this.#j.toPublic().toString()}set BAP_SERVER(j){this.#Q=j;for(let $ in this.#J)this.#J[$].BAP_SERVER=j}get BAP_SERVER(){return this.#Q}set BAP_TOKEN(j){this.#$=j;for(let $ in this.#J)this.#J[$].BAP_TOKEN=j}get BAP_TOKEN(){return this.#$}checkIdBelongs(j){if(this.#j.derive(j.rootPath).pubKey.toAddress()!==j.rootAddress)throw new Error("ID does not belong to this private key");return!0}listIds(){return Object.keys(this.#J)}newId(j,$={},J=""){let q;if(!j)q=this.getNextValidPath();else q=j;let z=new _(this.#j,$,J);z.BAP_SERVER=this.#Q,z.BAP_TOKEN=this.#$,z.rootPath=q,z.currentPath=Y.getNextPath(q);let Q=z.getIdentityKey();return this.#J[Q]=z,this.#q=q,this.#J[Q]}removeId(j){delete this.#J[j]}getNextValidPath(){if(this.#q)return Y.getNextIdentityPath(this.#q);return`/0'/${Object.keys(this.#J).length}'/0'`}getId(j){return this.#J[j]||null}setId(j){this.checkIdBelongs(j),this.#J[j.getIdentityKey()]=j}importIds(j,$=!0){if($&&typeof j==="string"){this.importEncryptedIds(j);return}let J=j;if(!J.lastIdPath)throw new Error("ID cannot be imported as it is not complete");if(!J.ids)throw new Error(`ID data is not in the correct format: ${j}`);let q=j.lastIdPath;for(let z of J.ids){if(!z.identityKey||!z.identityAttributes||!z.rootAddress)throw new Error("ID cannot be imported as it is not complete");let Q=new _(this.#j,{},z.idSeed);if(Q.BAP_SERVER=this.#Q,Q.BAP_TOKEN=this.#$,Q.import(z),q==="")q=Q.currentPath;this.checkIdBelongs(Q),this.#J[Q.getIdentityKey()]=Q}this.#q=q}importEncryptedIds(j){let $=this.decrypt(j),J=JSON.parse($);if(Array.isArray(J)){console.log(`Importing old format:
|
6
|
+
`,J),this.importOldIds(J);return}if(typeof J!=="object")throw new Error("decrypted, but found unrecognized identities format");this.importIds(J,!1)}importOldIds(j){for(let $ of j){let J=new _(this.#j,{},$.idSeed??"");J.BAP_SERVER=this.#Q,J.BAP_TOKEN=this.#$,J.import($),this.checkIdBelongs(J),this.#J[J.getIdentityKey()]=J,this.#q=J.currentPath}}exportIds(j,$=!0){let J={lastIdPath:this.#q,ids:[]},q=j||Object.keys(this.#J);for(let z of q){if(!this.#J[z])throw new Error(`Identity ${z} not found`);J.ids.push(this.#J[z].export())}if($)return this.encrypt(JSON.stringify(J));return J}exportId(j,$=!0){let J={lastIdPath:this.#q,ids:[]};if(J.ids.push(this.#J[j].export()),$)return this.encrypt(JSON.stringify(J));return J}encrypt(j){let $=this.#j.derive(w);return y(Xj(W(j),$.pubKey,null))}decrypt(j){let $=this.#j.derive(w);return E(Cj(W(j,"base64"),$.privKey))}signAttestationWithAIP(j,$,J=0,q=""){let z=this.getId($);if(!z)throw new Error("Could not find identity to attest with");let Q=this.getAttestationBuffer(j,J,q),{address:Z,signature:L}=z.signMessage(Q);return this.createAttestationTransaction(j,J,Z,L,q)}verifyAttestationWithAIP(j){if(!j.every((q)=>Array.isArray(q))||j[0][0]!==I.OP_RETURN||v(j[1])!==m)throw new Error("Not a valid BAP transaction");let $=v(j[7])==="44415441"?5:0,J={type:E(j[2]),hash:v(j[3]),sequence:E(j[4]),signingProtocol:E(j[7+$]),signingAddress:E(j[8+$]),signature:y(j[9+$])};if($&&j[3]===j[8])J.data=v(j[9]);console.log({attestation:J});try{let q=[];for(let z=0;z<6+$;z++)q.push(j[z]);J.verified=this.verifySignature(q.flat(),J.signingAddress,J.signature)}catch(q){J.verified=!1}return J}createAttestationTransaction(j,$,J,q,z=""){let Q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(z)Q.push(W(X),W("DATA"),W(j),W(z),W("|"));return Q.push(W(M),W("BITCOIN_ECDSA"),W(J),W(q,"base64")),console.log({elements:Q}),Q}getAttestationBuffer(j,$=0,J=""){let q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(J)q.push(W(X),W("DATA"),W(j),W(J),W("|"));return q.flat()}verifySignature(j,$,J){let q;if(Array.isArray(j))q=j;else if(Buffer.isBuffer(j))q=[...j];else q=W(j,"utf8");let z=Gj.fromCompact(J,"base64"),Q;for(let Z=0;Z<4;Z++)try{if(Q=z.RecoverPublicKey(Z,new Lj(D.magicHash(q))),D.verify(q,z,Q)&&Q.toAddress()===$)return!0}catch(L){}return!1}async verifyChallengeSignature(j,$,J,q){if(!this.verifySignature(J,$,q))return!1;try{let Q=await this.getApiData("/attestation/valid",{idKey:j,address:$,challenge:J,signature:q});if(Q?.status==="success"&&Q?.result?.valid===!0)return!0;return!1}catch(Q){return console.error("API call failed:",Q),!1}}async isValidAttestationTransaction(j){if(this.verifyAttestationWithAIP(j))return this.getApiData("/attestation/valid",{tx:j});return!1}async getIdentityFromAddress(j){return this.getApiData("/identity/from-address",{address:j})}async getIdentity(j){return this.getApiData("/identity/get",{idKey:j})}async getAttestationsForHash(j){return this.getApiData("/attestations",{hash:j})}}export{f as MemberID,_ as MasterID,Uj as BAP};
|
7
7
|
|
8
|
-
//# debugId=
|
8
|
+
//# debugId=122786430EC8BDEA64756E2164756E21
|
package/dist/index.modern.js.map
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
"import { Utils } from \"@bsv/sdk\";\nconst { toHex, toArray } = Utils;\n\nexport const BAP_BITCOM_ADDRESS = '1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT';\nexport const BAP_BITCOM_ADDRESS_HEX = toHex(toArray(BAP_BITCOM_ADDRESS));\nexport const AIP_BITCOM_ADDRESS = '15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva';\nexport const AIP_BITCOM_ADDRESS_HEX = toHex(toArray(AIP_BITCOM_ADDRESS));\nexport const BAP_SERVER = 'https://api.sigmaidentity.com/v1';\nexport const MAX_INT = 2147483648 - 1; // 0x80000000\n\n// This is just a choice for this library and could be anything else if so needed/wanted\n// but it is advisable to use the same derivation between libraries for compatibility\nexport const SIGNING_PATH_PREFIX = 'm/424150\\'/0\\'/0\\''; // BAP in hex\nexport const ENCRYPTION_PATH = `m/424150'/${MAX_INT}'/${MAX_INT}'`;\n",
|
8
8
|
"import { BSM, Utils as BSVUtils, ECIES, Hash, PublicKey, type PrivateKey, BigNumber } from \"@bsv/sdk\";\nimport type { HD, Signature } from \"@bsv/sdk\";\n\nimport { type APIFetcher, apiFetcher } from \"./api\";\nimport type { GetAttestationResponse, GetSigningKeysResponse } from \"./apiTypes\";\nimport {\n AIP_BITCOM_ADDRESS,\n BAP_BITCOM_ADDRESS,\n BAP_SERVER,\n ENCRYPTION_PATH,\n MAX_INT,\n SIGNING_PATH_PREFIX,\n} from \"./constants\";\nimport type {\n Identity,\n IdentityAttribute,\n IdentityAttributes,\n OldIdentity,\n MemberIdentity,\n} from \"./interface\";\nimport { Utils } from \"./utils\";\nimport { MemberID } from './MemberID';\nimport { BaseClass } from \"./BaseClass\";\nconst { toArray, toHex, toBase58, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\nconst { magicHash } = BSM;\n/**\n * MasterID class\n *\n * This class should be used in conjunction with the BAP class\n *\n * @type {MasterID}\n */\nclass MasterID extends BaseClass {\n #HDPrivateKey: HD;\n #BAP_SERVER: string = BAP_SERVER;\n #BAP_TOKEN = \"\";\n #rootPath: string;\n #previousPath: string;\n #currentPath: string;\n #idSeed: string;\n\n idName: string;\n description: string;\n\n rootAddress: string;\n identityKey: string;\n identityAttributes: IdentityAttributes;\n\n getApiData: APIFetcher\n\n constructor(\n HDPrivateKey: HD,\n identityAttributes: IdentityAttributes = {},\n idSeed = \"\",\n ) {\n super();\n \n if (idSeed) {\n // create a new HDPrivateKey based on the seed\n const seedHex = toHex(Hash.sha256(idSeed, \"utf8\"));\n const seedPath = Utils.getSigningPathFromHex(seedHex);\n this.#HDPrivateKey = HDPrivateKey.derive(seedPath);\n } else {\n this.#HDPrivateKey = HDPrivateKey;\n }\n\n this.#idSeed = idSeed;\n this.idName = \"ID 1\";\n this.description = \"\";\n\n this.#rootPath = `${SIGNING_PATH_PREFIX}/0/0/0`;\n this.#previousPath = `${SIGNING_PATH_PREFIX}/0/0/0`;\n this.#currentPath = `${SIGNING_PATH_PREFIX}/0/0/1`;\n\n const rootChild = this.#HDPrivateKey.derive(this.#rootPath);\n this.rootAddress = rootChild.privKey.toPublicKey().toAddress();\n this.identityKey = this.deriveIdentityKey(this.rootAddress);\n\n // unlink the object\n const attributes = { ...identityAttributes };\n this.identityAttributes = this.parseAttributes(attributes);\n\n this.getApiData = apiFetcher(this.#BAP_SERVER, this.#BAP_TOKEN);\n }\n\n set BAP_SERVER(bapServer) {\n this.#BAP_SERVER = bapServer;\n }\n\n get BAP_SERVER(): string {\n return this.#BAP_SERVER;\n }\n\n set BAP_TOKEN(token) {\n this.#BAP_TOKEN = token;\n }\n\n get BAP_TOKEN(): string {\n return this.#BAP_TOKEN;\n }\n\n deriveIdentityKey(address: string): string {\n // base58( ripemd160 ( sha256 ( rootAddress ) ) )\n const rootAddressHash = toHex(Hash.sha256(address, \"utf8\"));\n return toBase58(Hash.ripemd160(rootAddressHash, \"hex\"));\n }\n\n /**\n * Helper function to parse identity attributes\n *\n * @param identityAttributes\n * @returns {{}}\n */\n parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Parse a text of urn string into identity attributes\n *\n * urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa\n * urn:bap:id:birthday:1990-05-22:e61f23cbbb2284842d77965e2b0e32f0ca890b1894ca4ce652831347ee3596d9\n * urn:bap:id:over18:1:480ca17ccaacd671b28dc811332525f2f2cd594d8e8e7825de515ce5d52d30e8\n *\n * @param urnIdentityAttributes\n */\n parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n // avoid forEach\n\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n // remove any whitespace from the string (trim)\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Returns the identity key\n *\n * @returns {*|string}\n */\n getIdentityKey(): string {\n return this.identityKey;\n }\n\n /**\n * This should be called with the last part of the signing path (/.../.../...)\n * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file\n *\n * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}\n */\n set rootPath(path: string) {\n if (this.#HDPrivateKey) {\n let pathToUse = path;\n if (path.split(\"/\").length < 5) {\n pathToUse = `${SIGNING_PATH_PREFIX}${path}`;\n }\n\n if (!this.validatePath(pathToUse)) {\n throw new Error(`invalid signing path given ${pathToUse}`);\n }\n\n this.#rootPath = pathToUse;\n\n const derivedChild = this.#HDPrivateKey.derive(pathToUse);\n this.rootAddress = derivedChild.pubKey.toAddress();\n // Identity keys should be derivatives of the root address - this allows checking\n // of the creation transaction\n this.identityKey = this.deriveIdentityKey(this.rootAddress);\n\n // we also set this previousPath / currentPath to the root as we seem to be (re)setting this ID\n this.#previousPath = pathToUse;\n this.#currentPath = pathToUse;\n }\n }\n\n get rootPath(): string {\n return this.#rootPath;\n }\n\n getRootPath(): string {\n return this.#rootPath;\n }\n\n /**\n * This should be called with the last part of the signing path (/.../.../...)\n * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file\n *\n * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}\n */\n set currentPath(path) {\n let pathToUse = path;\n if (path.split(\"/\").length < 5) {\n pathToUse = `${SIGNING_PATH_PREFIX}${path}`;\n }\n\n if (!this.validatePath(pathToUse)) {\n throw new Error(\"invalid signing path given\");\n }\n\n this.#previousPath = this.#currentPath;\n this.#currentPath = pathToUse;\n }\n\n get currentPath(): string {\n return this.#currentPath;\n }\n\n get previousPath(): string {\n return this.#previousPath;\n }\n\n /**\n * This can be used to break the deterministic way child keys are created to make it harder for\n * an attacker to steal the identites when the root key is compromised. This does however require\n * the seeds to be stored at all times. If the seed is lost, the identity will not be recoverable.\n */\n get idSeed(): string {\n return this.#idSeed;\n }\n\n /**\n * Increment current path to a new path\n *\n * @returns {*}\n */\n incrementPath(): void {\n this.currentPath = Utils.getNextPath(this.currentPath);\n }\n\n /**\n * Check whether the given path is a valid path for use with this class\n * The signing paths used here always have a length of 3\n *\n * @param path The last part of the signing path (example \"/0/0/1\")\n * @returns {boolean}\n */\n validatePath(path: string) {\n /* eslint-disable max-len */\n if (\n path.match(\n /\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?/,\n )\n ) {\n const pathValues = path.split(\"/\");\n if (\n pathValues.length === 7 &&\n Number(pathValues[1].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[2].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[3].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[4].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[5].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[6].replace(\"'\", \"\")) <= MAX_INT\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Get the OP_RETURN for the initial ID transaction (signed with root address)\n *\n * @returns {[]}\n */\n getInitialIdTransaction() {\n return this.getIdTransaction(this.#rootPath);\n }\n\n /**\n * Get the OP_RETURN for the ID transaction of the current address / path\n *\n * @returns {[]}\n */\n getIdTransaction(previousPath = \"\") {\n if (this.#currentPath === this.#rootPath) {\n throw new Error(\n \"Current path equals rootPath. ID was probably not initialized properly\",\n );\n }\n\n const opReturn = [\n toArray(BAP_BITCOM_ADDRESS),\n toArray(\"ID\"),\n toArray(this.identityKey),\n toArray(this.getCurrentAddress()),\n ];\n\n return this.signOpReturnWithAIP(\n opReturn,\n previousPath || this.#previousPath,\n );\n }\n\n /**\n * Get address for given path\n *\n * @param path\n * @returns {*}\n */\n getAddress(path: string): string {\n const derivedChild = this.#HDPrivateKey.derive(path);\n return derivedChild.privKey.toPublicKey().toAddress();\n }\n\n /**\n * Get current signing address\n *\n * @returns {*}\n */\n getCurrentAddress(): string {\n return this.getAddress(this.#currentPath);\n }\n\n /**\n * Get the encryption key pair for this identity\n */\n getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey } {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n return {\n privKey: encryptionKey,\n pubKey: encryptionKey.toPublicKey()\n };\n }\n\n /**\n * Get the encryption key using type 42 (different key / incompatible with above)\n */\n getEncryptionKeyType42(): { privKey: PrivateKey, pubKey: PublicKey } {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.privKey.deriveChild(HDPrivateKey.toPublic().pubKey, ENCRYPTION_PATH);\n return {\n privKey: encryptionKey,\n pubKey: encryptionKey.toPublicKey()\n };\n }\n /**\n * Get the public key for encrypting data for this identity\n */\n getEncryptionPublicKey(): string {\n const { pubKey } = this.getEncryptionKey();\n return pubKey.toString();\n }\n\n /**\n * Get the public key for encrypting data for this identity, using a seed for the encryption\n */\n getEncryptionPublicKeyWithSeed(seed: string): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n return encryptionKey.toPublicKey().toString();\n }\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n const publicKey = encryptionKey.toPublicKey();\n const pubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : publicKey;\n // @ts-ignore - remove this when SDK is updated\n return toBase64(electrumEncrypt(toArray(stringData), pubKey, null));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n let pubKey = undefined\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), encryptionKey, pubKey));\n }\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param seed String seed\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encryptWithSeed(\n stringData: string,\n seed: string,\n counterPartyPublicKey?: string,\n ): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n const publicKey = encryptionKey.toPublicKey();\n const pubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : publicKey;\n return toBase64(electrumEncrypt(toArray(stringData), pubKey, encryptionKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param seed String seed\n // * @param counterPartyPublicKey Public key of the counterparty\n */\n decryptWithSeed(ciphertext: string, seed: string, counterPartyPublicKey?: string): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n let pubKey = undefined\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), encryptionKey, pubKey));\n }\n\n private getEncryptionPrivateKeyWithSeed(seed: string) {\n const pathHex = toHex(Hash.sha256(seed, \"utf8\"));\n const path = Utils.getSigningPathFromHex(pathHex);\n\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n return HDPrivateKey.derive(path).privKey;\n }\n\n /**\n * Get an attestation string for the given urn for this identity\n *\n * @param urn\n * @returns {string}\n */\n getAttestation(urn: string) {\n const urnHash = Hash.sha256(urn, \"utf8\");\n return `bap:attest:${toHex(urnHash)}:${this.getIdentityKey()}`;\n }\n\n /**\n * Generate and return the attestation hash for the given attribute of this identity\n *\n * @param attribute Attribute name (name, email etc.)\n * @returns {string}\n */\n getAttestationHash(attribute: string) {\n const urn = this.getAttributeUrn(attribute);\n if (!urn) return null;\n\n const attestation = this.getAttestation(urn);\n const attestationHash = Hash.sha256(attestation, \"utf8\");\n\n return toHex(attestationHash);\n }\n\n /**\n * Sign a message with the current signing address of this identity\n *\n * @param message\n * @param signingPath\n * @returns {{address: string, signature: string}}\n */\n signMessage(message: number[], signingPath?: string): { address: string; signature: string } {\n const pathToUse = signingPath || this.#currentPath;\n const childPk = this.#HDPrivateKey.derive(pathToUse).privKey;\n const address = childPk.toAddress();\n\n // Needed to calculate the recovery factor\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(\n childPk.toPublicKey(),\n h,\n );\n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n\n return { address, signature };\n }\n\n /**\n * Sign a message using a key based on the given string seed\n *\n * This works by creating a private key from the root key of this identity. It will always\n * work with the rootPath / rootKey, to be deterministic. It will not change even if the keys\n * are rotated for this ID.\n *\n * This is used in for instance deterministic login systems, that do not support BAP.\n *\n * @param message\n * @param seed {string} String seed that will be used to generate a path\n */\n signMessageWithSeed(\n message: string,\n seed: string,\n ): { address: string; signature: string } {\n const pathHex = toHex(Hash.sha256(seed, \"utf8\"));\n const path = Utils.getSigningPathFromHex(pathHex);\n\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const derivedChild = HDPrivateKey.derive(path);\n const address = derivedChild.privKey.toPublicKey().toAddress();\n\n const messageArray = toArray(message, \"utf8\");\n const dummySig = BSM.sign(messageArray, derivedChild.privKey, 'raw') as Signature;\n\n const h = new BigNumber(magicHash(messageArray));\n const r = dummySig.CalculateRecoveryFactor(\n derivedChild.privKey.toPublicKey(),\n h,\n );\n\n const signature = (BSM.sign(messageArray, derivedChild.privKey, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n\n return { address, signature };\n }\n\n /**\n * Sign an op_return hex array with AIP\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath = \"\",\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(opReturn, address, signature);\n }\n\n /**\n * Get all signing keys for this identity\n */\n async getIdSigningKeys(): Promise<GetSigningKeysResponse> {\n const signingKeys = await this.getApiData<GetSigningKeysResponse>(\"/signing-keys\", {\n idKey: this.identityKey,\n });\n console.log(\"getIdSigningKeys\", signingKeys);\n\n return signingKeys;\n }\n\n /**\n * Get all attestations for the given attribute\n *\n * @param attribute\n */\n async getAttributeAttestations(attribute: string): Promise<GetAttestationResponse> {\n // This function needs to make a call to a BAP server to get all the attestations for this\n // identity for the given attribute\n const attestationHash = this.getAttestationHash(attribute);\n\n // get all BAP ATTEST records for the given attestationHash\n const attestations = await this.getApiData<GetAttestationResponse>(\"/attestation/get\", {\n hash: attestationHash,\n });\n console.log(\"getAttestations\", attribute, attestationHash, attestations);\n\n return attestations;\n }\n\n /**\n * Import an identity from a JSON object\n *\n * @param identity{{}}\n */\n import(identity: Identity | OldIdentity): void {\n this.idName = identity.name;\n this.description = identity.description || \"\";\n this.identityKey = identity.identityKey;\n this.#rootPath = identity.rootPath;\n this.rootAddress = identity.rootAddress;\n this.#previousPath = identity.previousPath;\n this.#currentPath = identity.currentPath;\n this.#idSeed = ('idSeed' in identity ? identity.idSeed : \"\") || \"\";\n this.identityAttributes = this.parseAttributes(identity.identityAttributes);\n }\n\n /**\n * Export this identity to a JSON object\n * @returns {{}}\n */\n export(): Identity {\n return {\n name: this.idName,\n description: this.description,\n identityKey: this.identityKey,\n rootPath: this.#rootPath,\n rootAddress: this.rootAddress,\n previousPath: this.#previousPath,\n currentPath: this.#currentPath,\n idSeed: this.#idSeed,\n identityAttributes: this.getAttributes(),\n lastIdPath: \"\",\n };\n }\n\n // New method to export a member-friendly backup, containing only the derived signing key\n exportMemberBackup(): MemberIdentity {\n const derivedKey = this.#HDPrivateKey.derive(this.#currentPath).privKey;\n return {\n name: this.idName,\n description: this.description,\n derivedPrivateKey: derivedKey.toWif(),\n address: derivedKey.toPublicKey().toAddress(),\n identityAttributes: this.getAttributes(),\n identityKey: this.identityKey,\n };\n }\n\n // New method to derive a new member ID from the master HD key\n public newId(): MemberID {\n // Assuming incrementPath updates the internal current path\n this.incrementPath();\n const derivedKey = this.#HDPrivateKey.derive(this.#currentPath).privKey;\n return new MemberID(derivedKey);\n }\n}\nexport { MasterID };\n\n",
|
9
9
|
"import { randomBytes } from 'node:crypto';\nimport type { PathPrefix } from \"./interface.js\";\n\nexport const Utils = {\n /**\n * Helper function to generate a random nonce\n *\n * @returns {string}\n */\n getRandomString(length = 32) {\n return randomBytes(length).toString('hex');\n },\n\n /**\n * Get a signing path from a hex number\n *\n * @param hexString {string}\n * @param hardened {boolean} Whether to return a hardened path\n * @returns {string}\n */\n getSigningPathFromHex(hexString: string, hardened = true) {\n // \"m/0/0/1\"\n let signingPath = 'm';\n const signingHex = hexString.match(/.{1,8}/g);\n if (!signingHex) {\n throw new Error('Invalid hex string');\n }\n const maxNumber = 2147483648 - 1; // 0x80000000\n for (const hexNumber of signingHex) {\n let number = Number(`0x${hexNumber}`);\n if (number > maxNumber) number -= maxNumber;\n signingPath += `/${number}${(hardened ? \"'\" : '')}`;\n }\n\n return signingPath;\n },\n\n /**\n * Increment that second to last part from the given part, set the last part to 0\n *\n * @param path string\n * @returns {*}\n */\n getNextIdentityPath(path: string): PathPrefix {\n const pathValues = path.split('/');\n const secondToLastPart = pathValues[pathValues.length - 2];\n\n let hardened = false;\n if (secondToLastPart.match('\\'')) {\n hardened = true;\n }\n\n const nextPath = (Number(secondToLastPart.replace(/[^0-9]/g, '')) + 1).toString();\n pathValues[pathValues.length - 2] = nextPath + (hardened ? '\\'' : '');\n pathValues[pathValues.length - 1] = `0${hardened ? '\\'' : ''}`;\n\n return pathValues.join('/') as PathPrefix;\n },\n\n /**\n * Increment that last part of the given path\n *\n * @param path string\n * @returns {*}\n */\n getNextPath(path: string) {\n const pathValues = path.split('/');\n const lastPart = pathValues[pathValues.length - 1];\n let hardened = false;\n if (lastPart.match('\\'')) {\n hardened = true;\n }\n const nextPath = (Number(lastPart.replace(/[^0-9]/g, '')) + 1).toString();\n pathValues[pathValues.length - 1] = nextPath + (hardened ? '\\'' : '');\n return pathValues.join('/');\n },\n};\n",
|
10
|
-
"import { BSM, Utils as BSVUtils, type PublicKey, PrivateKey, BigNumber, Hash } from \"@bsv/sdk\";\nimport type { Signature } from \"@bsv/sdk\";\nimport { BaseClass } from \"./BaseClass\";\nimport type { IdentityAttributes, MemberIdentity } from \"./interface\";\nimport { ENCRYPTION_PATH } from \"./constants\";\nconst { toHex, toBase58, toArray } = BSVUtils;\nconst { magicHash } = BSM;\n\nexport class MemberID extends BaseClass {\n private key: PrivateKey;\n public idName: string;\n public description: string;\n public address: string;\n public identityKey: string\n\n constructor(key: PrivateKey, identityAttributes: IdentityAttributes = {}) {\n super();\n this.key = key;\n this.address = key.toAddress();\n this.idName = \"Member ID 1\";\n this.description = \"\";\n this.identityKey = \"\";\n this.identityAttributes = this.parseAttributes(identityAttributes);\n }\n\n // Implement the abstract signMessage method from BaseClass\n public signMessage(message: number[], _signingPath?: string): { address: string; signature: string } {\n const childPk = this.key;\n const address = childPk.toAddress();\n \n // Sign using the raw message buffer directly\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(childPk.toPublicKey(), h);\n \n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n \n return { address, signature };\n }\n\n // Implement signOpReturnWithAIP - MemberID ignores signing path\n public signOpReturnWithAIP(\n opReturn: number[][]
|
11
|
-
"import { ECIES, Utils as BSVUtils, OP, PublicKey } from \"@bsv/sdk\";\nimport type { PrivateKey } from \"@bsv/sdk\";\nimport { AIP_BITCOM_ADDRESS } from \"./constants\";\nimport type { IdentityAttribute, IdentityAttributes } from \"./interface\";\nimport { Utils } from \"./utils\";\nconst { toArray, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\n\nabstract class BaseClass {\n protected identityAttributes: IdentityAttributes = {};\n\n /**\n * Abstract method that must be implemented by derived classes to sign messages\n * @param message - The message to sign\n * @param signingPath - Optional signing path for HD wallets\n * @returns Object containing address and signature\n */\n abstract signMessage(message: number[], signingPath?: string): { address: string; signature: string };\n\n /**\n * Abstract method that must be implemented by derived classes to get encryption key\n */\n abstract getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey };\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const { privKey, pubKey } = this.getEncryptionKey();\n const targetPubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : pubKey;\n return toBase64(electrumEncrypt(toArray(stringData), targetPubKey, privKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param counterPartyPublicKey Optional public key of the counterparty\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const { privKey } = this.getEncryptionKey();\n let pubKey = undefined;\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), privKey, pubKey));\n }\n\n /**\n * Sign an op_return hex array with AIP\n * Each implementation must handle its own signing path logic\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath?: string,\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n /**\n * Returns all the attributes in the identity\n * @returns {IdentityAttributes}\n */\n getAttributes(): IdentityAttributes {\n return this.identityAttributes;\n }\n\n /**\n * Get the value of the given attribute\n * @param attributeName\n * @returns {IdentityAttribute | null}\n */\n getAttribute(attributeName: string): IdentityAttribute | null {\n if (this.identityAttributes[attributeName]) {\n return this.identityAttributes[attributeName];\n }\n return null;\n }\n\n /**\n * Set the value of the given attribute\n * If an empty value ('' || null || false) is given, the attribute is removed from the ID\n * @param attributeName string\n * @param attributeValue any\n */\n setAttribute(attributeName: string, attributeValue: string | Record<string, string>): void {\n if (!attributeValue) {\n return;\n }\n\n if (this.identityAttributes[attributeName]) {\n this.updateExistingAttribute(attributeName, attributeValue);\n } else {\n this.createNewAttribute(attributeName, attributeValue);\n }\n }\n\n /**\n * Unset the given attribute from the ID\n * @param attributeName\n */\n unsetAttribute(attributeName: string): void {\n delete this.identityAttributes[attributeName];\n }\n\n /**\n * Add an attribute to this identity\n * @param attributeName\n * @param value\n * @param nonce\n */\n addAttribute(attributeName: string, value: string, nonce = \"\"): void {\n let nonceToUse = nonce;\n if (!nonce) {\n nonceToUse = Utils.getRandomString();\n }\n\n this.identityAttributes[attributeName] = {\n value,\n nonce: nonceToUse,\n };\n }\n\n /**\n * Get all attribute URNs for this ID\n * @returns {string}\n */\n getAttributeUrns(): string {\n let urns = \"\";\n for (const key in this.identityAttributes) {\n const urn = this.getAttributeUrn(key);\n if (urn) {\n urns += `${urn}\\n`;\n }\n }\n return urns;\n }\n\n /**\n * Create and return the attribute URN for the given attribute\n * @param attributeName\n * @returns {string|null}\n */\n getAttributeUrn(attributeName: string): string | null {\n const attribute = this.identityAttributes[attributeName];\n if (attribute) {\n return `urn:bap:id:${attributeName}:${attribute.value}:${attribute.nonce}`;\n }\n return null;\n }\n\n /**\n * Parse a text of URN string into identity attributes\n * @param urnIdentityAttributes\n */\n protected parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Helper function to parse identity attributes\n * @param identityAttributes\n * @returns {IdentityAttributes}\n */\n protected parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Helper method to update an existing attribute\n */\n protected updateExistingAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.identityAttributes[attributeName].value = attributeValue;\n return;\n }\n\n this.identityAttributes[attributeName].value = attributeValue.value || '';\n if (attributeValue.nonce) {\n this.identityAttributes[attributeName].nonce = attributeValue.nonce;\n }\n }\n\n /**\n * Helper method to create a new attribute\n */\n protected createNewAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.addAttribute(attributeName, attributeValue);\n return;\n }\n\n this.addAttribute(\n attributeName,\n attributeValue.value || '',\n attributeValue.nonce\n );\n }\n\n /**\n * Construct an AIP buffer from the op return data\n * @param opReturn\n * @returns {number[]} Array of numbers representing the buffer\n */\n protected getAIPMessageBuffer(opReturn: number[][], indicies?: number[]): number[][] {\n\n // locate the position of OP_RETURN in the opReturn array\n let opReturnIndex = opReturn.findIndex(op => op[0] === OP.OP_RETURN);\n const buffers: number[][] = [];\n\n // include OP_RETURN in constructing the signature buffer\n if (opReturnIndex === -1) {\n buffers.push([OP.OP_RETURN]);\n opReturnIndex = 0;\n }\n\n // if indicies is specified, only include the specified indicies in the buffer\n // relative to the position of OP_RETURN as \"0\"\n if (indicies) {\n for (const index of indicies) {\n buffers.push(opReturn[opReturnIndex + index]);\n }\n } else {\n for (const op of opReturn) {\n buffers.push(op);\n }\n }\n\n
|
10
|
+
"import { BSM, Utils as BSVUtils, type PublicKey, PrivateKey, BigNumber, Hash } from \"@bsv/sdk\";\nimport type { Signature } from \"@bsv/sdk\";\nimport { BaseClass } from \"./BaseClass\";\nimport type { IdentityAttributes, MemberIdentity } from \"./interface\";\nimport { ENCRYPTION_PATH } from \"./constants\";\nconst { toHex, toBase58, toArray } = BSVUtils;\nconst { magicHash } = BSM;\n\nexport class MemberID extends BaseClass {\n private key: PrivateKey;\n public idName: string;\n public description: string;\n public address: string;\n public identityKey: string\n\n constructor(key: PrivateKey, identityAttributes: IdentityAttributes = {}) {\n super();\n this.key = key;\n this.address = key.toAddress();\n this.idName = \"Member ID 1\";\n this.description = \"\";\n this.identityKey = \"\";\n this.identityAttributes = this.parseAttributes(identityAttributes);\n }\n\n // Implement the abstract signMessage method from BaseClass\n public signMessage(message: number[], _signingPath?: string): { address: string; signature: string } {\n const childPk = this.key;\n const address = childPk.toAddress();\n \n // Sign using the raw message buffer directly\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(childPk.toPublicKey(), h);\n \n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n \n return { address, signature };\n }\n\n // Implement signOpReturnWithAIP - MemberID ignores signing path\n public signOpReturnWithAIP(\n opReturn: number[][]\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat());\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n // Return the member's public key\n public getPublicKey(): string {\n return this.key.toPublicKey().toString();\n }\n\n // Import the member identity from an object containing the derived private key and identity data\n public import(identity: MemberIdentity): void {\n this.idName = identity.name;\n this.description = identity.description;\n this.key = PrivateKey.fromWif(identity.derivedPrivateKey);\n this.address = this.key.toAddress();\n this.identityAttributes = identity.identityAttributes || {};\n this.identityKey = identity.identityKey;\n }\n\n static fromMemberIdentity(identity: MemberIdentity): MemberID {\n const member = new MemberID(PrivateKey.fromWif(identity.derivedPrivateKey));\n member.import(identity);\n return member;\n }\n\n static fromBackup(singleBackup: {wif:string, id: string}): MemberID {\n // decrypt the id and set the details\n const member = new MemberID(PrivateKey.fromWif(singleBackup.wif));\n const id = JSON.parse(member.decrypt(singleBackup.id));\n member.import(id);\n return member;\n }\n\n // Export the member identity as an object containing the derived private key and identity data\n public export(): MemberIdentity {\n return {\n name: this.idName,\n description: this.description,\n derivedPrivateKey: this.key.toWif(),\n address: this.address,\n identityAttributes: this.getAttributes(),\n identityKey: this.identityKey,\n };\n }\n\n /**\n * Get the encryption key pair for this identity\n * We use the same key for both signing and encryption for simplicity\n */\n getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey } {\n // Derive the encryption key from the private key using the ENCRYPTION_PATH\n // Since member keys are not HD keys, we use the path as the invoice number, \n // and use our own public key as the other party's public key\n return {\n privKey: this.key.deriveChild(this.key.toPublicKey(), ENCRYPTION_PATH),\n pubKey: this.key.deriveChild(this.key.toPublicKey(), ENCRYPTION_PATH).toPublicKey()\n };\n }\n\n /**\n * Get the public key for encrypting data for this identity\n */\n getEncryptionPublicKey(): string {\n const { pubKey } = this.getEncryptionKey();\n return pubKey.toString();\n }\n}",
|
11
|
+
"import { ECIES, Utils as BSVUtils, OP, PublicKey } from \"@bsv/sdk\";\nimport type { PrivateKey } from \"@bsv/sdk\";\nimport { AIP_BITCOM_ADDRESS } from \"./constants\";\nimport type { IdentityAttribute, IdentityAttributes } from \"./interface\";\nimport { Utils } from \"./utils\";\nconst { toArray, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\n\nabstract class BaseClass {\n protected identityAttributes: IdentityAttributes = {};\n\n /**\n * Abstract method that must be implemented by derived classes to sign messages\n * @param message - The message to sign\n * @param signingPath - Optional signing path for HD wallets\n * @returns Object containing address and signature\n */\n abstract signMessage(message: number[], signingPath?: string): { address: string; signature: string };\n\n /**\n * Abstract method that must be implemented by derived classes to get encryption key\n */\n abstract getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey };\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const { privKey, pubKey } = this.getEncryptionKey();\n const targetPubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : pubKey;\n return toBase64(electrumEncrypt(toArray(stringData), targetPubKey, privKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param counterPartyPublicKey Optional public key of the counterparty\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const { privKey } = this.getEncryptionKey();\n let pubKey = undefined;\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), privKey, pubKey));\n }\n\n /**\n * Sign an op_return hex array with AIP\n * Each implementation must handle its own signing path logic\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath?: string,\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n /**\n * Returns all the attributes in the identity\n * @returns {IdentityAttributes}\n */\n getAttributes(): IdentityAttributes {\n return this.identityAttributes;\n }\n\n /**\n * Get the value of the given attribute\n * @param attributeName\n * @returns {IdentityAttribute | null}\n */\n getAttribute(attributeName: string): IdentityAttribute | null {\n if (this.identityAttributes[attributeName]) {\n return this.identityAttributes[attributeName];\n }\n return null;\n }\n\n /**\n * Set the value of the given attribute\n * If an empty value ('' || null || false) is given, the attribute is removed from the ID\n * @param attributeName string\n * @param attributeValue any\n */\n setAttribute(attributeName: string, attributeValue: string | Record<string, string>): void {\n if (!attributeValue) {\n return;\n }\n\n if (this.identityAttributes[attributeName]) {\n this.updateExistingAttribute(attributeName, attributeValue);\n } else {\n this.createNewAttribute(attributeName, attributeValue);\n }\n }\n\n /**\n * Unset the given attribute from the ID\n * @param attributeName\n */\n unsetAttribute(attributeName: string): void {\n delete this.identityAttributes[attributeName];\n }\n\n /**\n * Add an attribute to this identity\n * @param attributeName\n * @param value\n * @param nonce\n */\n addAttribute(attributeName: string, value: string, nonce = \"\"): void {\n let nonceToUse = nonce;\n if (!nonce) {\n nonceToUse = Utils.getRandomString();\n }\n\n this.identityAttributes[attributeName] = {\n value,\n nonce: nonceToUse,\n };\n }\n\n /**\n * Get all attribute URNs for this ID\n * @returns {string}\n */\n getAttributeUrns(): string {\n let urns = \"\";\n for (const key in this.identityAttributes) {\n const urn = this.getAttributeUrn(key);\n if (urn) {\n urns += `${urn}\\n`;\n }\n }\n return urns;\n }\n\n /**\n * Create and return the attribute URN for the given attribute\n * @param attributeName\n * @returns {string|null}\n */\n getAttributeUrn(attributeName: string): string | null {\n const attribute = this.identityAttributes[attributeName];\n if (attribute) {\n return `urn:bap:id:${attributeName}:${attribute.value}:${attribute.nonce}`;\n }\n return null;\n }\n\n /**\n * Parse a text of URN string into identity attributes\n * @param urnIdentityAttributes\n */\n protected parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Helper function to parse identity attributes\n * @param identityAttributes\n * @returns {IdentityAttributes}\n */\n protected parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Helper method to update an existing attribute\n */\n protected updateExistingAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.identityAttributes[attributeName].value = attributeValue;\n return;\n }\n\n this.identityAttributes[attributeName].value = attributeValue.value || '';\n if (attributeValue.nonce) {\n this.identityAttributes[attributeName].nonce = attributeValue.nonce;\n }\n }\n\n /**\n * Helper method to create a new attribute\n */\n protected createNewAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.addAttribute(attributeName, attributeValue);\n return;\n }\n\n this.addAttribute(\n attributeName,\n attributeValue.value || '',\n attributeValue.nonce\n );\n }\n\n /**\n * Construct an AIP buffer from the op return data\n * @param opReturn\n * @returns {number[]} Array of numbers representing the buffer\n */\n protected getAIPMessageBuffer(opReturn: number[][], indicies?: number[]): number[][] {\n\n // locate the position of OP_RETURN in the opReturn array\n let opReturnIndex = opReturn.findIndex(op => op[0] === OP.OP_RETURN);\n const buffers: number[][] = [];\n\n // include OP_RETURN in constructing the signature buffer\n if (opReturnIndex === -1) {\n buffers.push([OP.OP_RETURN]);\n opReturnIndex = 0;\n }\n\n // if indicies is specified, only include the specified indicies in the buffer\n // relative to the position of OP_RETURN as \"0\"\n if (indicies) {\n for (const index of indicies) {\n buffers.push(opReturn[opReturnIndex + index]);\n }\n } else {\n for (const op of opReturn) {\n buffers.push(op);\n }\n }\n\n return buffers;\n }\n\n /**\n * Helper method to format AIP output\n * @param opReturn Original OP_RETURN data\n * @param address Signing address\n * @param signature Base64 signature\n * @returns Formatted AIP output as number[]\n */\n protected formatAIPOutput(\n opReturnBuffers: number[][],\n address: string,\n signature: string,\n ): number[][] {\n // Add AIP protocol elements\n const aipElements = [\n toArray(\"|\"),\n toArray(AIP_BITCOM_ADDRESS),\n toArray(\"BITCOIN_ECDSA\"),\n toArray(address),\n toArray(signature, \"base64\"),\n ];\n\n // Concatenate all buffers\n return [\n ...opReturnBuffers,\n ...aipElements\n ];\n }\n}\n\nexport { BaseClass };"
|
12
12
|
],
|
13
|
-
"mappings": ";AAAA,cAAS,eAAK,YAAW,SAAO,SAAI,eAAoB,kBAExD,gBAAS,kBCMF,IAAM,EAAa,MAAU,EAAgB,EAAkB,EAAgB,IAA8B,CAClH,IAAM,EAAM,GAAG,IAAS,IAWxB,OAViB,MAAM,MAAM,EAAK,CAChC,OAAQ,OACR,QAAS,CACP,eAAgB,kCAChB,QACA,OAAQ,MACV,EACA,KAAM,KAAK,UAAU,CAAO,CAC9B,CAAC,GAEe,KAAK,GAKV,EAAa,CAAC,EAAc,IAA8B,MAAU,EAAa,IAA8B,CAC1H,OAAO,EAAc,EAAK,EAAM,EAAM,CAAK,GC1B7C,gBAAS,iBACT,IAAQ,QAAO,WAAY,EAEd,EAAqB,qCACrB,EAAyB,EAAM,EAAQ,CAAkB,CAAC,EAC1D,EAAqB,qCACrB,GAAyB,EAAM,EAAQ,CAAkB,CAAC,EAC1D,EAAa,mCACb,EAAU,WAIV,EAAsB,kBACtB,EAAkB,aAAa,MAAY,KCbxD,cAAS,WAAK,YAAmB,WAAO,eAAM,eAA4B,iBCA1E,sBAAS,eAGF,IAAM,EAAQ,CAMnB,eAAe,CAAC,EAAS,GAAI,CAC3B,OAAO,EAAY,CA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-1,8 +1,8 @@
|
|
1
1
|
// @bun
|
2
|
-
import{BSM as D,BigNumber as Lj,ECIES as wj,HD as Yj,OP as I,Signature as Gj}from"@bsv/sdk";import{Utils as Fj}from"@bsv/sdk";var s=async(j,$,J,q)=>{let z=`${J}${j}`;return(await fetch(z,{method:"post",headers:{"Content-type":"application/json; charset=utf-8",token:q,format:"json"},body:JSON.stringify($)})).json()},R=(j,$)=>async(J,q)=>{return s(J,q,j,$)};import{Utils as r}from"@bsv/sdk";var{toHex:K,toArray:g}=r,X="1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT",m=K(g(X)),M="15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva",
|
2
|
+
import{BSM as D,BigNumber as Lj,ECIES as wj,HD as Yj,OP as I,Signature as Gj}from"@bsv/sdk";import{Utils as Fj}from"@bsv/sdk";var s=async(j,$,J,q)=>{let z=`${J}${j}`;return(await fetch(z,{method:"post",headers:{"Content-type":"application/json; charset=utf-8",token:q,format:"json"},body:JSON.stringify($)})).json()},R=(j,$)=>async(J,q)=>{return s(J,q,j,$)};import{Utils as r}from"@bsv/sdk";var{toHex:K,toArray:g}=r,X="1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT",m=K(g(X)),M="15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva",kj=K(g(M)),T="https://api.sigmaidentity.com/v1",G=2147483647,O="m/424150'/0'/0'",w=`m/424150'/${G}'/${G}'`;import{BSM as x,Utils as Qj,ECIES as Wj,Hash as U,PublicKey as N,BigNumber as l}from"@bsv/sdk";import{randomBytes as i}from"crypto";var Y={getRandomString(j=32){return i(j).toString("hex")},getSigningPathFromHex(j,$=!0){let J="m",q=j.match(/.{1,8}/g);if(!q)throw new Error("Invalid hex string");let z=2147483647;for(let Q of q){let Z=Number(`0x${Q}`);if(Z>z)Z-=z;J+=`/${Z}${$?"'":""}`}return J},getNextIdentityPath(j){let $=j.split("/"),J=$[$.length-2],q=!1;if(J.match("'"))q=!0;let z=(Number(J.replace(/[^0-9]/g,""))+1).toString();return $[$.length-2]=z+(q?"'":""),$[$.length-1]=`0${q?"'":""}`,$.join("/")},getNextPath(j){let $=j.split("/"),J=$[$.length-1],q=!1;if(J.match("'"))q=!0;let z=(Number(J.replace(/[^0-9]/g,""))+1).toString();return $[$.length-1]=z+(q?"'":""),$.join("/")}};import{BSM as H,Utils as vj,PrivateKey as S,BigNumber as qj}from"@bsv/sdk";import{ECIES as a,Utils as e,OP as A,PublicKey as c}from"@bsv/sdk";var{toArray:C,toUTF8:t,toBase64:jj}=e,{electrumDecrypt:$j,electrumEncrypt:Jj}=a;class V{identityAttributes={};encrypt(j,$){let{privKey:J,pubKey:q}=this.getEncryptionKey(),z=$?c.fromString($):q;return jj(Jj(C(j),z,J))}decrypt(j,$){let{privKey:J}=this.getEncryptionKey(),q=void 0;if($)q=c.fromString($);return t($j(C(j,"base64"),J,q))}signOpReturnWithAIP(j,$){let J=this.getAIPMessageBuffer(j),{address:q,signature:z}=this.signMessage(J.flat(),$);return this.formatAIPOutput(J,q,z)}getAttributes(){return this.identityAttributes}getAttribute(j){if(this.identityAttributes[j])return this.identityAttributes[j];return null}setAttribute(j,$){if(!$)return;if(this.identityAttributes[j])this.updateExistingAttribute(j,$);else this.createNewAttribute(j,$)}unsetAttribute(j){delete this.identityAttributes[j]}addAttribute(j,$,J=""){let q=J;if(!J)q=Y.getRandomString();this.identityAttributes[j]={value:$,nonce:q}}getAttributeUrns(){let j="";for(let $ in this.identityAttributes){let J=this.getAttributeUrn($);if(J)j+=`${J}
|
3
3
|
`}return j}getAttributeUrn(j){let $=this.identityAttributes[j];if($)return`urn:bap:id:${j}:${$.value}:${$.nonce}`;return null}parseStringUrns(j){let $={},J=j.replace(/^\s+/g,"").replace(/\r/gm,"").split(`
|
4
|
-
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}updateExistingAttribute(j,$){if(typeof $==="string"){this.identityAttributes[j].value=$;return}if(this.identityAttributes[j].value=$.value||"",$.nonce)this.identityAttributes[j].nonce=$.nonce}createNewAttribute(j,$){if(typeof $==="string"){this.addAttribute(j,$);return}this.addAttribute(j,$.value||"",$.nonce)}getAIPMessageBuffer(j,$){let J=j.findIndex((z)=>z[0]===A.OP_RETURN),q=[];if(J===-1)q.push([A.OP_RETURN]),J=0;if($)for(let z of $)q.push(j[J+z]);else for(let z of j)q.push(z);
|
5
|
-
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}getIdentityKey(){return this.identityKey}set rootPath(j){if(this.#j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error(`invalid signing path given ${$}`);this.#$=$;let J=this.#j.derive($);this.rootAddress=J.pubKey.toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress),this.#q=$,this.#z=$}}get rootPath(){return this.#$}getRootPath(){return this.#$}set currentPath(j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error("invalid signing path given");this.#q=this.#z,this.#z=$}get currentPath(){return this.#z}get previousPath(){return this.#q}get idSeed(){return this.#W}incrementPath(){this.currentPath=Y.getNextPath(this.currentPath)}validatePath(j){if(j.match(/\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?/)){let $=j.split("/");if($.length===7&&Number($[1].replace("'",""))<=G&&Number($[2].replace("'",""))<=G&&Number($[3].replace("'",""))<=G&&Number($[4].replace("'",""))<=G&&Number($[5].replace("'",""))<=G&&Number($[6].replace("'",""))<=G)return!0}return!1}getInitialIdTransaction(){return this.getIdTransaction(this.#$)}getIdTransaction(j=""){if(this.#z===this.#$)throw new Error("Current path equals rootPath. ID was probably not initialized properly");let $=[F(X),F("ID"),F(this.identityKey),F(this.getCurrentAddress())];return this.signOpReturnWithAIP($,j||this.#q)}getAddress(j){return this.#j.derive(j).privKey.toPublicKey().toAddress()}getCurrentAddress(){return this.getAddress(this.#z)}getEncryptionKey(){let $=this.#j.derive(this.#$).derive(w).privKey;return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionKeyType42(){let j=this.#j.derive(this.#$),$=j.privKey.deriveChild(j.toPublic().pubKey,w);return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}getEncryptionPublicKeyWithSeed(j){return this.getEncryptionPrivateKeyWithSeed(j).toPublicKey().toString()}encrypt(j,$){let z=this.#j.derive(this.#$).derive(w).privKey.toPublicKey(),Q=$?N.fromString($):z;return b(P(F(j),Q,null))}decrypt(j,$){let q=this.#j.derive(this.#$).derive(w).privKey,z=void 0;if($)z=N.fromString($);return p(h(F(j,"base64"),q,z))}encryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=q.toPublicKey(),Q=J?N.fromString(J):z;return b(P(F(j),Q,q))}decryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=void 0;if(J)z=N.fromString(J);return p(h(F(j,"base64"),q,z))}getEncryptionPrivateKeyWithSeed(j){let $=
|
6
|
-
`,J),this.importOldIds(J);return}if(typeof J!=="object")throw new Error("decrypted, but found unrecognized identities format");this.importIds(J,!1)}importOldIds(j){for(let $ of j){let J=new _(this.#j,{},$.idSeed??"");J.BAP_SERVER=this.#Q,J.BAP_TOKEN=this.#$,J.import($),this.checkIdBelongs(J),this.#J[J.getIdentityKey()]=J,this.#q=J.currentPath}}exportIds(j,$=!0){let J={lastIdPath:this.#q,ids:[]},q=j||Object.keys(this.#J);for(let z of q){if(!this.#J[z])throw new Error(`Identity ${z} not found`);J.ids.push(this.#J[z].export())}if($)return this.encrypt(JSON.stringify(J));return J}exportId(j,$=!0){let J={lastIdPath:this.#q,ids:[]};if(J.ids.push(this.#J[j].export()),$)return this.encrypt(JSON.stringify(J));return J}encrypt(j){let $=this.#j.derive(w);return y(Xj(W(j),$.pubKey,null))}decrypt(j){let $=this.#j.derive(w);return E(Cj(W(j,"base64"),$.privKey))}signAttestationWithAIP(j,$,J=0,q=""){let z=this.getId($);if(!z)throw new Error("Could not find identity to attest with");let Q=this.getAttestationBuffer(j,J,q),{address:Z,signature:L}=z.signMessage(Q);return this.createAttestationTransaction(j,J,Z,L,q)}verifyAttestationWithAIP(j){if(!j.every((q)=>Array.isArray(q))||j[0][0]!==I.OP_RETURN||v(j[1])!==m)throw new Error("Not a valid BAP transaction");let $=v(j[7])==="44415441"?5:0,J={type:E(j[2]),hash:v(j[3]),sequence:E(j[4]),signingProtocol:E(j[7+$]),signingAddress:E(j[8+$]),signature:y(j[9+$])};if($&&j[3]===j[8])J.data=v(j[9]);console.log({attestation:J});try{let q=[];for(let z=0;z<6+$;z++)q.push(j[z]);J.verified=this.verifySignature(q.flat(),J.signingAddress,J.signature)}catch(q){J.verified=!1}return J}createAttestationTransaction(j,$,J,q,z=""){let Q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(z)Q.push(W(X),W("DATA"),W(j),W(z),W("|"));return Q.push(W(M),W("BITCOIN_ECDSA"),W(J),W(q,"base64")),console.log({elements:Q}),Q}getAttestationBuffer(j,$=0,J=""){let q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(J)q.push(W(X),W("DATA"),W(j),W(J),W("|"));return q.flat()}verifySignature(j,$,J){let q;if(Array.isArray(j))q=j;else if(Buffer.isBuffer(j))q=[...j];else q=W(j,"utf8");let z=Gj.fromCompact(J,"base64"),Q;for(let Z=0;Z<4;Z++)try{if(Q=z.RecoverPublicKey(Z,new Lj(D.magicHash(q))),D.verify(q,z,Q)&&Q.toAddress()===$)return!0}catch(L){}return!1}async verifyChallengeSignature(j,$,J,q){if(!this.verifySignature(J,$,q))return!1;try{let Q=await this.getApiData("/attestation/valid",{idKey:j,address:$,challenge:J,signature:q});if(Q?.status==="success"&&Q?.result?.valid===!0)return!0;return!1}catch(Q){return console.error("API call failed:",Q),!1}}async isValidAttestationTransaction(j){if(this.verifyAttestationWithAIP(j))return this.getApiData("/attestation/valid",{tx:j});return!1}async getIdentityFromAddress(j){return this.getApiData("/identity/from-address",{address:j})}async getIdentity(j){return this.getApiData("/identity/get",{idKey:j})}async getAttestationsForHash(j){return this.getApiData("/attestations",{hash:j})}}export{
|
4
|
+
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}updateExistingAttribute(j,$){if(typeof $==="string"){this.identityAttributes[j].value=$;return}if(this.identityAttributes[j].value=$.value||"",$.nonce)this.identityAttributes[j].nonce=$.nonce}createNewAttribute(j,$){if(typeof $==="string"){this.addAttribute(j,$);return}this.addAttribute(j,$.value||"",$.nonce)}getAIPMessageBuffer(j,$){let J=j.findIndex((z)=>z[0]===A.OP_RETURN),q=[];if(J===-1)q.push([A.OP_RETURN]),J=0;if($)for(let z of $)q.push(j[J+z]);else for(let z of j)q.push(z);return q}formatAIPOutput(j,$,J){let q=[C("|"),C(M),C("BITCOIN_ECDSA"),C($),C(J,"base64")];return[...j,...q]}}var{magicHash:zj}=H;class f extends V{key;idName;description;address;identityKey;constructor(j,$={}){super();this.key=j,this.address=j.toAddress(),this.idName="Member ID 1",this.description="",this.identityKey="",this.identityAttributes=this.parseAttributes($)}signMessage(j,$){let J=this.key,q=J.toAddress(),z=H.sign(j,J,"raw"),Q=new qj(zj(j)),Z=z.CalculateRecoveryFactor(J.toPublicKey(),Q),L=H.sign(j,J,"raw").toCompact(Z,!0,"base64");return{address:q,signature:L}}signOpReturnWithAIP(j){let $=this.getAIPMessageBuffer(j),{address:J,signature:q}=this.signMessage($.flat());return this.formatAIPOutput($,J,q)}getPublicKey(){return this.key.toPublicKey().toString()}import(j){this.idName=j.name,this.description=j.description,this.key=S.fromWif(j.derivedPrivateKey),this.address=this.key.toAddress(),this.identityAttributes=j.identityAttributes||{},this.identityKey=j.identityKey}static fromMemberIdentity(j){let $=new f(S.fromWif(j.derivedPrivateKey));return $.import(j),$}static fromBackup(j){let $=new f(S.fromWif(j.wif)),J=JSON.parse($.decrypt(j.id));return $.import(J),$}export(){return{name:this.idName,description:this.description,derivedPrivateKey:this.key.toWif(),address:this.address,identityAttributes:this.getAttributes(),identityKey:this.identityKey}}getEncryptionKey(){return{privKey:this.key.deriveChild(this.key.toPublicKey(),w),pubKey:this.key.deriveChild(this.key.toPublicKey(),w).toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}}var{toArray:F,toHex:k,toBase58:Zj,toUTF8:p,toBase64:b}=Qj,{electrumDecrypt:h,electrumEncrypt:P}=Wj,{magicHash:o}=x;class _ extends V{#j;#J=T;#Q="";#$;#q;#z;#W;idName;description;rootAddress;identityKey;identityAttributes;getApiData;constructor(j,$={},J=""){super();if(J){let Q=k(U.sha256(J,"utf8")),Z=Y.getSigningPathFromHex(Q);this.#j=j.derive(Z)}else this.#j=j;this.#W=J,this.idName="ID 1",this.description="",this.#$=`${O}/0/0/0`,this.#q=`${O}/0/0/0`,this.#z=`${O}/0/0/1`;let q=this.#j.derive(this.#$);this.rootAddress=q.privKey.toPublicKey().toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress);let z={...$};this.identityAttributes=this.parseAttributes(z),this.getApiData=R(this.#J,this.#Q)}set BAP_SERVER(j){this.#J=j}get BAP_SERVER(){return this.#J}set BAP_TOKEN(j){this.#Q=j}get BAP_TOKEN(){return this.#Q}deriveIdentityKey(j){let $=k(U.sha256(j,"utf8"));return Zj(U.ripemd160($,"hex"))}parseAttributes(j){if(typeof j==="string")return this.parseStringUrns(j);for(let $ in j)if(!j[$].value||!j[$].nonce)throw new Error("Invalid identity attribute");return j||{}}parseStringUrns(j){let $={},J=j.replace(/^\s+/g,"").replace(/\r/gm,"").split(`
|
5
|
+
`);for(let q of J){let Q=q.replace(/^\s+/g,"").replace(/\s+$/g,"").split(":");if(Q[0]==="urn"&&Q[1]==="bap"&&Q[2]==="id"&&Q[3]&&Q[4]&&Q[5])$[Q[3]]={value:Q[4],nonce:Q[5]}}return $}getIdentityKey(){return this.identityKey}set rootPath(j){if(this.#j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error(`invalid signing path given ${$}`);this.#$=$;let J=this.#j.derive($);this.rootAddress=J.pubKey.toAddress(),this.identityKey=this.deriveIdentityKey(this.rootAddress),this.#q=$,this.#z=$}}get rootPath(){return this.#$}getRootPath(){return this.#$}set currentPath(j){let $=j;if(j.split("/").length<5)$=`${O}${j}`;if(!this.validatePath($))throw new Error("invalid signing path given");this.#q=this.#z,this.#z=$}get currentPath(){return this.#z}get previousPath(){return this.#q}get idSeed(){return this.#W}incrementPath(){this.currentPath=Y.getNextPath(this.currentPath)}validatePath(j){if(j.match(/\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?\/[0-9]{1,10}'?/)){let $=j.split("/");if($.length===7&&Number($[1].replace("'",""))<=G&&Number($[2].replace("'",""))<=G&&Number($[3].replace("'",""))<=G&&Number($[4].replace("'",""))<=G&&Number($[5].replace("'",""))<=G&&Number($[6].replace("'",""))<=G)return!0}return!1}getInitialIdTransaction(){return this.getIdTransaction(this.#$)}getIdTransaction(j=""){if(this.#z===this.#$)throw new Error("Current path equals rootPath. ID was probably not initialized properly");let $=[F(X),F("ID"),F(this.identityKey),F(this.getCurrentAddress())];return this.signOpReturnWithAIP($,j||this.#q)}getAddress(j){return this.#j.derive(j).privKey.toPublicKey().toAddress()}getCurrentAddress(){return this.getAddress(this.#z)}getEncryptionKey(){let $=this.#j.derive(this.#$).derive(w).privKey;return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionKeyType42(){let j=this.#j.derive(this.#$),$=j.privKey.deriveChild(j.toPublic().pubKey,w);return{privKey:$,pubKey:$.toPublicKey()}}getEncryptionPublicKey(){let{pubKey:j}=this.getEncryptionKey();return j.toString()}getEncryptionPublicKeyWithSeed(j){return this.getEncryptionPrivateKeyWithSeed(j).toPublicKey().toString()}encrypt(j,$){let z=this.#j.derive(this.#$).derive(w).privKey.toPublicKey(),Q=$?N.fromString($):z;return b(P(F(j),Q,null))}decrypt(j,$){let q=this.#j.derive(this.#$).derive(w).privKey,z=void 0;if($)z=N.fromString($);return p(h(F(j,"base64"),q,z))}encryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=q.toPublicKey(),Q=J?N.fromString(J):z;return b(P(F(j),Q,q))}decryptWithSeed(j,$,J){let q=this.getEncryptionPrivateKeyWithSeed($),z=void 0;if(J)z=N.fromString(J);return p(h(F(j,"base64"),q,z))}getEncryptionPrivateKeyWithSeed(j){let $=k(U.sha256(j,"utf8")),J=Y.getSigningPathFromHex($);return this.#j.derive(this.#$).derive(J).privKey}getAttestation(j){let $=U.sha256(j,"utf8");return`bap:attest:${k($)}:${this.getIdentityKey()}`}getAttestationHash(j){let $=this.getAttributeUrn(j);if(!$)return null;let J=this.getAttestation($),q=U.sha256(J,"utf8");return k(q)}signMessage(j,$){let J=$||this.#z,q=this.#j.derive(J).privKey,z=q.toAddress(),Q=x.sign(j,q,"raw"),Z=new l(o(j)),L=Q.CalculateRecoveryFactor(q.toPublicKey(),Z),B=x.sign(j,q,"raw").toCompact(L,!0,"base64");return{address:z,signature:B}}signMessageWithSeed(j,$){let J=k(U.sha256($,"utf8")),q=Y.getSigningPathFromHex(J),Q=this.#j.derive(this.#$).derive(q),Z=Q.privKey.toPublicKey().toAddress(),L=F(j,"utf8"),B=x.sign(L,Q.privKey,"raw"),u=new l(o(L)),n=B.CalculateRecoveryFactor(Q.privKey.toPublicKey(),u),d=x.sign(L,Q.privKey,"raw").toCompact(n,!0,"base64");return{address:Z,signature:d}}signOpReturnWithAIP(j,$=""){let J=this.getAIPMessageBuffer(j),{address:q,signature:z}=this.signMessage(J.flat(),$);return this.formatAIPOutput(j,q,z)}async getIdSigningKeys(){let j=await this.getApiData("/signing-keys",{idKey:this.identityKey});return console.log("getIdSigningKeys",j),j}async getAttributeAttestations(j){let $=this.getAttestationHash(j),J=await this.getApiData("/attestation/get",{hash:$});return console.log("getAttestations",j,$,J),J}import(j){this.idName=j.name,this.description=j.description||"",this.identityKey=j.identityKey,this.#$=j.rootPath,this.rootAddress=j.rootAddress,this.#q=j.previousPath,this.#z=j.currentPath,this.#W=("idSeed"in j?j.idSeed:"")||"",this.identityAttributes=this.parseAttributes(j.identityAttributes)}export(){return{name:this.idName,description:this.description,identityKey:this.identityKey,rootPath:this.#$,rootAddress:this.rootAddress,previousPath:this.#q,currentPath:this.#z,idSeed:this.#W,identityAttributes:this.getAttributes(),lastIdPath:""}}exportMemberBackup(){let j=this.#j.derive(this.#z).privKey;return{name:this.idName,description:this.description,derivedPrivateKey:j.toWif(),address:j.toPublicKey().toAddress(),identityAttributes:this.getAttributes(),identityKey:this.identityKey}}newId(){this.incrementPath();let j=this.#j.derive(this.#z).privKey;return new f(j)}}var{toArray:W,toUTF8:E,toBase64:y,toHex:v}=Fj,{electrumEncrypt:Xj,electrumDecrypt:Cj}=wj;class Uj{#j;#J={};#Q=T;#$="";#q="";getApiData;constructor(j,$="",J=""){if(!j)throw new Error("No HDPrivateKey given");if(this.#j=Yj.fromString(j),$)this.#$=$;if(J)this.#Q=J;this.getApiData=R(this.#Q,this.#$)}get lastIdPath(){return this.#q}getPublicKey(j=""){if(j)return this.#j.derive(j).pubKey.toString();return this.#j.pubKey.toString()}getHdPublicKey(j=""){if(j)return this.#j.derive(j).toPublic().toString();return this.#j.toPublic().toString()}set BAP_SERVER(j){this.#Q=j;for(let $ in this.#J)this.#J[$].BAP_SERVER=j}get BAP_SERVER(){return this.#Q}set BAP_TOKEN(j){this.#$=j;for(let $ in this.#J)this.#J[$].BAP_TOKEN=j}get BAP_TOKEN(){return this.#$}checkIdBelongs(j){if(this.#j.derive(j.rootPath).pubKey.toAddress()!==j.rootAddress)throw new Error("ID does not belong to this private key");return!0}listIds(){return Object.keys(this.#J)}newId(j,$={},J=""){let q;if(!j)q=this.getNextValidPath();else q=j;let z=new _(this.#j,$,J);z.BAP_SERVER=this.#Q,z.BAP_TOKEN=this.#$,z.rootPath=q,z.currentPath=Y.getNextPath(q);let Q=z.getIdentityKey();return this.#J[Q]=z,this.#q=q,this.#J[Q]}removeId(j){delete this.#J[j]}getNextValidPath(){if(this.#q)return Y.getNextIdentityPath(this.#q);return`/0'/${Object.keys(this.#J).length}'/0'`}getId(j){return this.#J[j]||null}setId(j){this.checkIdBelongs(j),this.#J[j.getIdentityKey()]=j}importIds(j,$=!0){if($&&typeof j==="string"){this.importEncryptedIds(j);return}let J=j;if(!J.lastIdPath)throw new Error("ID cannot be imported as it is not complete");if(!J.ids)throw new Error(`ID data is not in the correct format: ${j}`);let q=j.lastIdPath;for(let z of J.ids){if(!z.identityKey||!z.identityAttributes||!z.rootAddress)throw new Error("ID cannot be imported as it is not complete");let Q=new _(this.#j,{},z.idSeed);if(Q.BAP_SERVER=this.#Q,Q.BAP_TOKEN=this.#$,Q.import(z),q==="")q=Q.currentPath;this.checkIdBelongs(Q),this.#J[Q.getIdentityKey()]=Q}this.#q=q}importEncryptedIds(j){let $=this.decrypt(j),J=JSON.parse($);if(Array.isArray(J)){console.log(`Importing old format:
|
6
|
+
`,J),this.importOldIds(J);return}if(typeof J!=="object")throw new Error("decrypted, but found unrecognized identities format");this.importIds(J,!1)}importOldIds(j){for(let $ of j){let J=new _(this.#j,{},$.idSeed??"");J.BAP_SERVER=this.#Q,J.BAP_TOKEN=this.#$,J.import($),this.checkIdBelongs(J),this.#J[J.getIdentityKey()]=J,this.#q=J.currentPath}}exportIds(j,$=!0){let J={lastIdPath:this.#q,ids:[]},q=j||Object.keys(this.#J);for(let z of q){if(!this.#J[z])throw new Error(`Identity ${z} not found`);J.ids.push(this.#J[z].export())}if($)return this.encrypt(JSON.stringify(J));return J}exportId(j,$=!0){let J={lastIdPath:this.#q,ids:[]};if(J.ids.push(this.#J[j].export()),$)return this.encrypt(JSON.stringify(J));return J}encrypt(j){let $=this.#j.derive(w);return y(Xj(W(j),$.pubKey,null))}decrypt(j){let $=this.#j.derive(w);return E(Cj(W(j,"base64"),$.privKey))}signAttestationWithAIP(j,$,J=0,q=""){let z=this.getId($);if(!z)throw new Error("Could not find identity to attest with");let Q=this.getAttestationBuffer(j,J,q),{address:Z,signature:L}=z.signMessage(Q);return this.createAttestationTransaction(j,J,Z,L,q)}verifyAttestationWithAIP(j){if(!j.every((q)=>Array.isArray(q))||j[0][0]!==I.OP_RETURN||v(j[1])!==m)throw new Error("Not a valid BAP transaction");let $=v(j[7])==="44415441"?5:0,J={type:E(j[2]),hash:v(j[3]),sequence:E(j[4]),signingProtocol:E(j[7+$]),signingAddress:E(j[8+$]),signature:y(j[9+$])};if($&&j[3]===j[8])J.data=v(j[9]);console.log({attestation:J});try{let q=[];for(let z=0;z<6+$;z++)q.push(j[z]);J.verified=this.verifySignature(q.flat(),J.signingAddress,J.signature)}catch(q){J.verified=!1}return J}createAttestationTransaction(j,$,J,q,z=""){let Q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(z)Q.push(W(X),W("DATA"),W(j),W(z),W("|"));return Q.push(W(M),W("BITCOIN_ECDSA"),W(J),W(q,"base64")),console.log({elements:Q}),Q}getAttestationBuffer(j,$=0,J=""){let q=[[I.OP_RETURN],W(X),W("ATTEST"),W(j),W(`${$}`),W("|")];if(J)q.push(W(X),W("DATA"),W(j),W(J),W("|"));return q.flat()}verifySignature(j,$,J){let q;if(Array.isArray(j))q=j;else if(Buffer.isBuffer(j))q=[...j];else q=W(j,"utf8");let z=Gj.fromCompact(J,"base64"),Q;for(let Z=0;Z<4;Z++)try{if(Q=z.RecoverPublicKey(Z,new Lj(D.magicHash(q))),D.verify(q,z,Q)&&Q.toAddress()===$)return!0}catch(L){}return!1}async verifyChallengeSignature(j,$,J,q){if(!this.verifySignature(J,$,q))return!1;try{let Q=await this.getApiData("/attestation/valid",{idKey:j,address:$,challenge:J,signature:q});if(Q?.status==="success"&&Q?.result?.valid===!0)return!0;return!1}catch(Q){return console.error("API call failed:",Q),!1}}async isValidAttestationTransaction(j){if(this.verifyAttestationWithAIP(j))return this.getApiData("/attestation/valid",{tx:j});return!1}async getIdentityFromAddress(j){return this.getApiData("/identity/from-address",{address:j})}async getIdentity(j){return this.getApiData("/identity/get",{idKey:j})}async getAttestationsForHash(j){return this.getApiData("/attestations",{hash:j})}}export{f as MemberID,_ as MasterID,Uj as BAP};
|
7
7
|
|
8
|
-
//# debugId=
|
8
|
+
//# debugId=BC682187893BF30D64756E2164756E21
|
package/dist/index.module.js.map
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
"import { Utils } from \"@bsv/sdk\";\nconst { toHex, toArray } = Utils;\n\nexport const BAP_BITCOM_ADDRESS = '1BAPSuaPnfGnSBM3GLV9yhxUdYe4vGbdMT';\nexport const BAP_BITCOM_ADDRESS_HEX = toHex(toArray(BAP_BITCOM_ADDRESS));\nexport const AIP_BITCOM_ADDRESS = '15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva';\nexport const AIP_BITCOM_ADDRESS_HEX = toHex(toArray(AIP_BITCOM_ADDRESS));\nexport const BAP_SERVER = 'https://api.sigmaidentity.com/v1';\nexport const MAX_INT = 2147483648 - 1; // 0x80000000\n\n// This is just a choice for this library and could be anything else if so needed/wanted\n// but it is advisable to use the same derivation between libraries for compatibility\nexport const SIGNING_PATH_PREFIX = 'm/424150\\'/0\\'/0\\''; // BAP in hex\nexport const ENCRYPTION_PATH = `m/424150'/${MAX_INT}'/${MAX_INT}'`;\n",
|
8
8
|
"import { BSM, Utils as BSVUtils, ECIES, Hash, PublicKey, type PrivateKey, BigNumber } from \"@bsv/sdk\";\nimport type { HD, Signature } from \"@bsv/sdk\";\n\nimport { type APIFetcher, apiFetcher } from \"./api\";\nimport type { GetAttestationResponse, GetSigningKeysResponse } from \"./apiTypes\";\nimport {\n AIP_BITCOM_ADDRESS,\n BAP_BITCOM_ADDRESS,\n BAP_SERVER,\n ENCRYPTION_PATH,\n MAX_INT,\n SIGNING_PATH_PREFIX,\n} from \"./constants\";\nimport type {\n Identity,\n IdentityAttribute,\n IdentityAttributes,\n OldIdentity,\n MemberIdentity,\n} from \"./interface\";\nimport { Utils } from \"./utils\";\nimport { MemberID } from './MemberID';\nimport { BaseClass } from \"./BaseClass\";\nconst { toArray, toHex, toBase58, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\nconst { magicHash } = BSM;\n/**\n * MasterID class\n *\n * This class should be used in conjunction with the BAP class\n *\n * @type {MasterID}\n */\nclass MasterID extends BaseClass {\n #HDPrivateKey: HD;\n #BAP_SERVER: string = BAP_SERVER;\n #BAP_TOKEN = \"\";\n #rootPath: string;\n #previousPath: string;\n #currentPath: string;\n #idSeed: string;\n\n idName: string;\n description: string;\n\n rootAddress: string;\n identityKey: string;\n identityAttributes: IdentityAttributes;\n\n getApiData: APIFetcher\n\n constructor(\n HDPrivateKey: HD,\n identityAttributes: IdentityAttributes = {},\n idSeed = \"\",\n ) {\n super();\n \n if (idSeed) {\n // create a new HDPrivateKey based on the seed\n const seedHex = toHex(Hash.sha256(idSeed, \"utf8\"));\n const seedPath = Utils.getSigningPathFromHex(seedHex);\n this.#HDPrivateKey = HDPrivateKey.derive(seedPath);\n } else {\n this.#HDPrivateKey = HDPrivateKey;\n }\n\n this.#idSeed = idSeed;\n this.idName = \"ID 1\";\n this.description = \"\";\n\n this.#rootPath = `${SIGNING_PATH_PREFIX}/0/0/0`;\n this.#previousPath = `${SIGNING_PATH_PREFIX}/0/0/0`;\n this.#currentPath = `${SIGNING_PATH_PREFIX}/0/0/1`;\n\n const rootChild = this.#HDPrivateKey.derive(this.#rootPath);\n this.rootAddress = rootChild.privKey.toPublicKey().toAddress();\n this.identityKey = this.deriveIdentityKey(this.rootAddress);\n\n // unlink the object\n const attributes = { ...identityAttributes };\n this.identityAttributes = this.parseAttributes(attributes);\n\n this.getApiData = apiFetcher(this.#BAP_SERVER, this.#BAP_TOKEN);\n }\n\n set BAP_SERVER(bapServer) {\n this.#BAP_SERVER = bapServer;\n }\n\n get BAP_SERVER(): string {\n return this.#BAP_SERVER;\n }\n\n set BAP_TOKEN(token) {\n this.#BAP_TOKEN = token;\n }\n\n get BAP_TOKEN(): string {\n return this.#BAP_TOKEN;\n }\n\n deriveIdentityKey(address: string): string {\n // base58( ripemd160 ( sha256 ( rootAddress ) ) )\n const rootAddressHash = toHex(Hash.sha256(address, \"utf8\"));\n return toBase58(Hash.ripemd160(rootAddressHash, \"hex\"));\n }\n\n /**\n * Helper function to parse identity attributes\n *\n * @param identityAttributes\n * @returns {{}}\n */\n parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Parse a text of urn string into identity attributes\n *\n * urn:bap:id:name:John Doe:e2c6fb4063cc04af58935737eaffc938011dff546d47b7fbb18ed346f8c4d4fa\n * urn:bap:id:birthday:1990-05-22:e61f23cbbb2284842d77965e2b0e32f0ca890b1894ca4ce652831347ee3596d9\n * urn:bap:id:over18:1:480ca17ccaacd671b28dc811332525f2f2cd594d8e8e7825de515ce5d52d30e8\n *\n * @param urnIdentityAttributes\n */\n parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n // avoid forEach\n\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n // remove any whitespace from the string (trim)\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Returns the identity key\n *\n * @returns {*|string}\n */\n getIdentityKey(): string {\n return this.identityKey;\n }\n\n /**\n * This should be called with the last part of the signing path (/.../.../...)\n * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file\n *\n * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}\n */\n set rootPath(path: string) {\n if (this.#HDPrivateKey) {\n let pathToUse = path;\n if (path.split(\"/\").length < 5) {\n pathToUse = `${SIGNING_PATH_PREFIX}${path}`;\n }\n\n if (!this.validatePath(pathToUse)) {\n throw new Error(`invalid signing path given ${pathToUse}`);\n }\n\n this.#rootPath = pathToUse;\n\n const derivedChild = this.#HDPrivateKey.derive(pathToUse);\n this.rootAddress = derivedChild.pubKey.toAddress();\n // Identity keys should be derivatives of the root address - this allows checking\n // of the creation transaction\n this.identityKey = this.deriveIdentityKey(this.rootAddress);\n\n // we also set this previousPath / currentPath to the root as we seem to be (re)setting this ID\n this.#previousPath = pathToUse;\n this.#currentPath = pathToUse;\n }\n }\n\n get rootPath(): string {\n return this.#rootPath;\n }\n\n getRootPath(): string {\n return this.#rootPath;\n }\n\n /**\n * This should be called with the last part of the signing path (/.../.../...)\n * This library assumes the first part is m/424150'/0'/0' as defined at the top of this file\n *\n * @param path The second path of the signing path in the format [0-9]{0,9}/[0-9]{0,9}/[0-9]{0,9}\n */\n set currentPath(path) {\n let pathToUse = path;\n if (path.split(\"/\").length < 5) {\n pathToUse = `${SIGNING_PATH_PREFIX}${path}`;\n }\n\n if (!this.validatePath(pathToUse)) {\n throw new Error(\"invalid signing path given\");\n }\n\n this.#previousPath = this.#currentPath;\n this.#currentPath = pathToUse;\n }\n\n get currentPath(): string {\n return this.#currentPath;\n }\n\n get previousPath(): string {\n return this.#previousPath;\n }\n\n /**\n * This can be used to break the deterministic way child keys are created to make it harder for\n * an attacker to steal the identites when the root key is compromised. This does however require\n * the seeds to be stored at all times. If the seed is lost, the identity will not be recoverable.\n */\n get idSeed(): string {\n return this.#idSeed;\n }\n\n /**\n * Increment current path to a new path\n *\n * @returns {*}\n */\n incrementPath(): void {\n this.currentPath = Utils.getNextPath(this.currentPath);\n }\n\n /**\n * Check whether the given path is a valid path for use with this class\n * The signing paths used here always have a length of 3\n *\n * @param path The last part of the signing path (example \"/0/0/1\")\n * @returns {boolean}\n */\n validatePath(path: string) {\n /* eslint-disable max-len */\n if (\n path.match(\n /\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?\\/[0-9]{1,10}'?/,\n )\n ) {\n const pathValues = path.split(\"/\");\n if (\n pathValues.length === 7 &&\n Number(pathValues[1].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[2].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[3].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[4].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[5].replace(\"'\", \"\")) <= MAX_INT &&\n Number(pathValues[6].replace(\"'\", \"\")) <= MAX_INT\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Get the OP_RETURN for the initial ID transaction (signed with root address)\n *\n * @returns {[]}\n */\n getInitialIdTransaction() {\n return this.getIdTransaction(this.#rootPath);\n }\n\n /**\n * Get the OP_RETURN for the ID transaction of the current address / path\n *\n * @returns {[]}\n */\n getIdTransaction(previousPath = \"\") {\n if (this.#currentPath === this.#rootPath) {\n throw new Error(\n \"Current path equals rootPath. ID was probably not initialized properly\",\n );\n }\n\n const opReturn = [\n toArray(BAP_BITCOM_ADDRESS),\n toArray(\"ID\"),\n toArray(this.identityKey),\n toArray(this.getCurrentAddress()),\n ];\n\n return this.signOpReturnWithAIP(\n opReturn,\n previousPath || this.#previousPath,\n );\n }\n\n /**\n * Get address for given path\n *\n * @param path\n * @returns {*}\n */\n getAddress(path: string): string {\n const derivedChild = this.#HDPrivateKey.derive(path);\n return derivedChild.privKey.toPublicKey().toAddress();\n }\n\n /**\n * Get current signing address\n *\n * @returns {*}\n */\n getCurrentAddress(): string {\n return this.getAddress(this.#currentPath);\n }\n\n /**\n * Get the encryption key pair for this identity\n */\n getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey } {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n return {\n privKey: encryptionKey,\n pubKey: encryptionKey.toPublicKey()\n };\n }\n\n /**\n * Get the encryption key using type 42 (different key / incompatible with above)\n */\n getEncryptionKeyType42(): { privKey: PrivateKey, pubKey: PublicKey } {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.privKey.deriveChild(HDPrivateKey.toPublic().pubKey, ENCRYPTION_PATH);\n return {\n privKey: encryptionKey,\n pubKey: encryptionKey.toPublicKey()\n };\n }\n /**\n * Get the public key for encrypting data for this identity\n */\n getEncryptionPublicKey(): string {\n const { pubKey } = this.getEncryptionKey();\n return pubKey.toString();\n }\n\n /**\n * Get the public key for encrypting data for this identity, using a seed for the encryption\n */\n getEncryptionPublicKeyWithSeed(seed: string): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n return encryptionKey.toPublicKey().toString();\n }\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n const publicKey = encryptionKey.toPublicKey();\n const pubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : publicKey;\n // @ts-ignore - remove this when SDK is updated\n return toBase64(electrumEncrypt(toArray(stringData), pubKey, null));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const encryptionKey = HDPrivateKey.derive(ENCRYPTION_PATH).privKey;\n let pubKey = undefined\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), encryptionKey, pubKey));\n }\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param seed String seed\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encryptWithSeed(\n stringData: string,\n seed: string,\n counterPartyPublicKey?: string,\n ): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n const publicKey = encryptionKey.toPublicKey();\n const pubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : publicKey;\n return toBase64(electrumEncrypt(toArray(stringData), pubKey, encryptionKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param seed String seed\n // * @param counterPartyPublicKey Public key of the counterparty\n */\n decryptWithSeed(ciphertext: string, seed: string, counterPartyPublicKey?: string): string {\n const encryptionKey = this.getEncryptionPrivateKeyWithSeed(seed);\n let pubKey = undefined\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), encryptionKey, pubKey));\n }\n\n private getEncryptionPrivateKeyWithSeed(seed: string) {\n const pathHex = toHex(Hash.sha256(seed, \"utf8\"));\n const path = Utils.getSigningPathFromHex(pathHex);\n\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n return HDPrivateKey.derive(path).privKey;\n }\n\n /**\n * Get an attestation string for the given urn for this identity\n *\n * @param urn\n * @returns {string}\n */\n getAttestation(urn: string) {\n const urnHash = Hash.sha256(urn, \"utf8\");\n return `bap:attest:${toHex(urnHash)}:${this.getIdentityKey()}`;\n }\n\n /**\n * Generate and return the attestation hash for the given attribute of this identity\n *\n * @param attribute Attribute name (name, email etc.)\n * @returns {string}\n */\n getAttestationHash(attribute: string) {\n const urn = this.getAttributeUrn(attribute);\n if (!urn) return null;\n\n const attestation = this.getAttestation(urn);\n const attestationHash = Hash.sha256(attestation, \"utf8\");\n\n return toHex(attestationHash);\n }\n\n /**\n * Sign a message with the current signing address of this identity\n *\n * @param message\n * @param signingPath\n * @returns {{address: string, signature: string}}\n */\n signMessage(message: number[], signingPath?: string): { address: string; signature: string } {\n const pathToUse = signingPath || this.#currentPath;\n const childPk = this.#HDPrivateKey.derive(pathToUse).privKey;\n const address = childPk.toAddress();\n\n // Needed to calculate the recovery factor\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(\n childPk.toPublicKey(),\n h,\n );\n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n\n return { address, signature };\n }\n\n /**\n * Sign a message using a key based on the given string seed\n *\n * This works by creating a private key from the root key of this identity. It will always\n * work with the rootPath / rootKey, to be deterministic. It will not change even if the keys\n * are rotated for this ID.\n *\n * This is used in for instance deterministic login systems, that do not support BAP.\n *\n * @param message\n * @param seed {string} String seed that will be used to generate a path\n */\n signMessageWithSeed(\n message: string,\n seed: string,\n ): { address: string; signature: string } {\n const pathHex = toHex(Hash.sha256(seed, \"utf8\"));\n const path = Utils.getSigningPathFromHex(pathHex);\n\n const HDPrivateKey = this.#HDPrivateKey.derive(this.#rootPath);\n const derivedChild = HDPrivateKey.derive(path);\n const address = derivedChild.privKey.toPublicKey().toAddress();\n\n const messageArray = toArray(message, \"utf8\");\n const dummySig = BSM.sign(messageArray, derivedChild.privKey, 'raw') as Signature;\n\n const h = new BigNumber(magicHash(messageArray));\n const r = dummySig.CalculateRecoveryFactor(\n derivedChild.privKey.toPublicKey(),\n h,\n );\n\n const signature = (BSM.sign(messageArray, derivedChild.privKey, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n\n return { address, signature };\n }\n\n /**\n * Sign an op_return hex array with AIP\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath = \"\",\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(opReturn, address, signature);\n }\n\n /**\n * Get all signing keys for this identity\n */\n async getIdSigningKeys(): Promise<GetSigningKeysResponse> {\n const signingKeys = await this.getApiData<GetSigningKeysResponse>(\"/signing-keys\", {\n idKey: this.identityKey,\n });\n console.log(\"getIdSigningKeys\", signingKeys);\n\n return signingKeys;\n }\n\n /**\n * Get all attestations for the given attribute\n *\n * @param attribute\n */\n async getAttributeAttestations(attribute: string): Promise<GetAttestationResponse> {\n // This function needs to make a call to a BAP server to get all the attestations for this\n // identity for the given attribute\n const attestationHash = this.getAttestationHash(attribute);\n\n // get all BAP ATTEST records for the given attestationHash\n const attestations = await this.getApiData<GetAttestationResponse>(\"/attestation/get\", {\n hash: attestationHash,\n });\n console.log(\"getAttestations\", attribute, attestationHash, attestations);\n\n return attestations;\n }\n\n /**\n * Import an identity from a JSON object\n *\n * @param identity{{}}\n */\n import(identity: Identity | OldIdentity): void {\n this.idName = identity.name;\n this.description = identity.description || \"\";\n this.identityKey = identity.identityKey;\n this.#rootPath = identity.rootPath;\n this.rootAddress = identity.rootAddress;\n this.#previousPath = identity.previousPath;\n this.#currentPath = identity.currentPath;\n this.#idSeed = ('idSeed' in identity ? identity.idSeed : \"\") || \"\";\n this.identityAttributes = this.parseAttributes(identity.identityAttributes);\n }\n\n /**\n * Export this identity to a JSON object\n * @returns {{}}\n */\n export(): Identity {\n return {\n name: this.idName,\n description: this.description,\n identityKey: this.identityKey,\n rootPath: this.#rootPath,\n rootAddress: this.rootAddress,\n previousPath: this.#previousPath,\n currentPath: this.#currentPath,\n idSeed: this.#idSeed,\n identityAttributes: this.getAttributes(),\n lastIdPath: \"\",\n };\n }\n\n // New method to export a member-friendly backup, containing only the derived signing key\n exportMemberBackup(): MemberIdentity {\n const derivedKey = this.#HDPrivateKey.derive(this.#currentPath).privKey;\n return {\n name: this.idName,\n description: this.description,\n derivedPrivateKey: derivedKey.toWif(),\n address: derivedKey.toPublicKey().toAddress(),\n identityAttributes: this.getAttributes(),\n identityKey: this.identityKey,\n };\n }\n\n // New method to derive a new member ID from the master HD key\n public newId(): MemberID {\n // Assuming incrementPath updates the internal current path\n this.incrementPath();\n const derivedKey = this.#HDPrivateKey.derive(this.#currentPath).privKey;\n return new MemberID(derivedKey);\n }\n}\nexport { MasterID };\n\n",
|
9
9
|
"import { randomBytes } from 'node:crypto';\nimport type { PathPrefix } from \"./interface.js\";\n\nexport const Utils = {\n /**\n * Helper function to generate a random nonce\n *\n * @returns {string}\n */\n getRandomString(length = 32) {\n return randomBytes(length).toString('hex');\n },\n\n /**\n * Get a signing path from a hex number\n *\n * @param hexString {string}\n * @param hardened {boolean} Whether to return a hardened path\n * @returns {string}\n */\n getSigningPathFromHex(hexString: string, hardened = true) {\n // \"m/0/0/1\"\n let signingPath = 'm';\n const signingHex = hexString.match(/.{1,8}/g);\n if (!signingHex) {\n throw new Error('Invalid hex string');\n }\n const maxNumber = 2147483648 - 1; // 0x80000000\n for (const hexNumber of signingHex) {\n let number = Number(`0x${hexNumber}`);\n if (number > maxNumber) number -= maxNumber;\n signingPath += `/${number}${(hardened ? \"'\" : '')}`;\n }\n\n return signingPath;\n },\n\n /**\n * Increment that second to last part from the given part, set the last part to 0\n *\n * @param path string\n * @returns {*}\n */\n getNextIdentityPath(path: string): PathPrefix {\n const pathValues = path.split('/');\n const secondToLastPart = pathValues[pathValues.length - 2];\n\n let hardened = false;\n if (secondToLastPart.match('\\'')) {\n hardened = true;\n }\n\n const nextPath = (Number(secondToLastPart.replace(/[^0-9]/g, '')) + 1).toString();\n pathValues[pathValues.length - 2] = nextPath + (hardened ? '\\'' : '');\n pathValues[pathValues.length - 1] = `0${hardened ? '\\'' : ''}`;\n\n return pathValues.join('/') as PathPrefix;\n },\n\n /**\n * Increment that last part of the given path\n *\n * @param path string\n * @returns {*}\n */\n getNextPath(path: string) {\n const pathValues = path.split('/');\n const lastPart = pathValues[pathValues.length - 1];\n let hardened = false;\n if (lastPart.match('\\'')) {\n hardened = true;\n }\n const nextPath = (Number(lastPart.replace(/[^0-9]/g, '')) + 1).toString();\n pathValues[pathValues.length - 1] = nextPath + (hardened ? '\\'' : '');\n return pathValues.join('/');\n },\n};\n",
|
10
|
-
"import { BSM, Utils as BSVUtils, type PublicKey, PrivateKey, BigNumber, Hash } from \"@bsv/sdk\";\nimport type { Signature } from \"@bsv/sdk\";\nimport { BaseClass } from \"./BaseClass\";\nimport type { IdentityAttributes, MemberIdentity } from \"./interface\";\nimport { ENCRYPTION_PATH } from \"./constants\";\nconst { toHex, toBase58, toArray } = BSVUtils;\nconst { magicHash } = BSM;\n\nexport class MemberID extends BaseClass {\n private key: PrivateKey;\n public idName: string;\n public description: string;\n public address: string;\n public identityKey: string\n\n constructor(key: PrivateKey, identityAttributes: IdentityAttributes = {}) {\n super();\n this.key = key;\n this.address = key.toAddress();\n this.idName = \"Member ID 1\";\n this.description = \"\";\n this.identityKey = \"\";\n this.identityAttributes = this.parseAttributes(identityAttributes);\n }\n\n // Implement the abstract signMessage method from BaseClass\n public signMessage(message: number[], _signingPath?: string): { address: string; signature: string } {\n const childPk = this.key;\n const address = childPk.toAddress();\n \n // Sign using the raw message buffer directly\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(childPk.toPublicKey(), h);\n \n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n \n return { address, signature };\n }\n\n // Implement signOpReturnWithAIP - MemberID ignores signing path\n public signOpReturnWithAIP(\n opReturn: number[][]
|
11
|
-
"import { ECIES, Utils as BSVUtils, OP, PublicKey } from \"@bsv/sdk\";\nimport type { PrivateKey } from \"@bsv/sdk\";\nimport { AIP_BITCOM_ADDRESS } from \"./constants\";\nimport type { IdentityAttribute, IdentityAttributes } from \"./interface\";\nimport { Utils } from \"./utils\";\nconst { toArray, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\n\nabstract class BaseClass {\n protected identityAttributes: IdentityAttributes = {};\n\n /**\n * Abstract method that must be implemented by derived classes to sign messages\n * @param message - The message to sign\n * @param signingPath - Optional signing path for HD wallets\n * @returns Object containing address and signature\n */\n abstract signMessage(message: number[], signingPath?: string): { address: string; signature: string };\n\n /**\n * Abstract method that must be implemented by derived classes to get encryption key\n */\n abstract getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey };\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const { privKey, pubKey } = this.getEncryptionKey();\n const targetPubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : pubKey;\n return toBase64(electrumEncrypt(toArray(stringData), targetPubKey, privKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param counterPartyPublicKey Optional public key of the counterparty\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const { privKey } = this.getEncryptionKey();\n let pubKey = undefined;\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), privKey, pubKey));\n }\n\n /**\n * Sign an op_return hex array with AIP\n * Each implementation must handle its own signing path logic\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath?: string,\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n /**\n * Returns all the attributes in the identity\n * @returns {IdentityAttributes}\n */\n getAttributes(): IdentityAttributes {\n return this.identityAttributes;\n }\n\n /**\n * Get the value of the given attribute\n * @param attributeName\n * @returns {IdentityAttribute | null}\n */\n getAttribute(attributeName: string): IdentityAttribute | null {\n if (this.identityAttributes[attributeName]) {\n return this.identityAttributes[attributeName];\n }\n return null;\n }\n\n /**\n * Set the value of the given attribute\n * If an empty value ('' || null || false) is given, the attribute is removed from the ID\n * @param attributeName string\n * @param attributeValue any\n */\n setAttribute(attributeName: string, attributeValue: string | Record<string, string>): void {\n if (!attributeValue) {\n return;\n }\n\n if (this.identityAttributes[attributeName]) {\n this.updateExistingAttribute(attributeName, attributeValue);\n } else {\n this.createNewAttribute(attributeName, attributeValue);\n }\n }\n\n /**\n * Unset the given attribute from the ID\n * @param attributeName\n */\n unsetAttribute(attributeName: string): void {\n delete this.identityAttributes[attributeName];\n }\n\n /**\n * Add an attribute to this identity\n * @param attributeName\n * @param value\n * @param nonce\n */\n addAttribute(attributeName: string, value: string, nonce = \"\"): void {\n let nonceToUse = nonce;\n if (!nonce) {\n nonceToUse = Utils.getRandomString();\n }\n\n this.identityAttributes[attributeName] = {\n value,\n nonce: nonceToUse,\n };\n }\n\n /**\n * Get all attribute URNs for this ID\n * @returns {string}\n */\n getAttributeUrns(): string {\n let urns = \"\";\n for (const key in this.identityAttributes) {\n const urn = this.getAttributeUrn(key);\n if (urn) {\n urns += `${urn}\\n`;\n }\n }\n return urns;\n }\n\n /**\n * Create and return the attribute URN for the given attribute\n * @param attributeName\n * @returns {string|null}\n */\n getAttributeUrn(attributeName: string): string | null {\n const attribute = this.identityAttributes[attributeName];\n if (attribute) {\n return `urn:bap:id:${attributeName}:${attribute.value}:${attribute.nonce}`;\n }\n return null;\n }\n\n /**\n * Parse a text of URN string into identity attributes\n * @param urnIdentityAttributes\n */\n protected parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Helper function to parse identity attributes\n * @param identityAttributes\n * @returns {IdentityAttributes}\n */\n protected parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Helper method to update an existing attribute\n */\n protected updateExistingAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.identityAttributes[attributeName].value = attributeValue;\n return;\n }\n\n this.identityAttributes[attributeName].value = attributeValue.value || '';\n if (attributeValue.nonce) {\n this.identityAttributes[attributeName].nonce = attributeValue.nonce;\n }\n }\n\n /**\n * Helper method to create a new attribute\n */\n protected createNewAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.addAttribute(attributeName, attributeValue);\n return;\n }\n\n this.addAttribute(\n attributeName,\n attributeValue.value || '',\n attributeValue.nonce\n );\n }\n\n /**\n * Construct an AIP buffer from the op return data\n * @param opReturn\n * @returns {number[]} Array of numbers representing the buffer\n */\n protected getAIPMessageBuffer(opReturn: number[][], indicies?: number[]): number[][] {\n\n // locate the position of OP_RETURN in the opReturn array\n let opReturnIndex = opReturn.findIndex(op => op[0] === OP.OP_RETURN);\n const buffers: number[][] = [];\n\n // include OP_RETURN in constructing the signature buffer\n if (opReturnIndex === -1) {\n buffers.push([OP.OP_RETURN]);\n opReturnIndex = 0;\n }\n\n // if indicies is specified, only include the specified indicies in the buffer\n // relative to the position of OP_RETURN as \"0\"\n if (indicies) {\n for (const index of indicies) {\n buffers.push(opReturn[opReturnIndex + index]);\n }\n } else {\n for (const op of opReturn) {\n buffers.push(op);\n }\n }\n\n
|
10
|
+
"import { BSM, Utils as BSVUtils, type PublicKey, PrivateKey, BigNumber, Hash } from \"@bsv/sdk\";\nimport type { Signature } from \"@bsv/sdk\";\nimport { BaseClass } from \"./BaseClass\";\nimport type { IdentityAttributes, MemberIdentity } from \"./interface\";\nimport { ENCRYPTION_PATH } from \"./constants\";\nconst { toHex, toBase58, toArray } = BSVUtils;\nconst { magicHash } = BSM;\n\nexport class MemberID extends BaseClass {\n private key: PrivateKey;\n public idName: string;\n public description: string;\n public address: string;\n public identityKey: string\n\n constructor(key: PrivateKey, identityAttributes: IdentityAttributes = {}) {\n super();\n this.key = key;\n this.address = key.toAddress();\n this.idName = \"Member ID 1\";\n this.description = \"\";\n this.identityKey = \"\";\n this.identityAttributes = this.parseAttributes(identityAttributes);\n }\n\n // Implement the abstract signMessage method from BaseClass\n public signMessage(message: number[], _signingPath?: string): { address: string; signature: string } {\n const childPk = this.key;\n const address = childPk.toAddress();\n \n // Sign using the raw message buffer directly\n const dummySig = BSM.sign(message, childPk, 'raw') as Signature;\n const h = new BigNumber(magicHash(message));\n const r = dummySig.CalculateRecoveryFactor(childPk.toPublicKey(), h);\n \n const signature = (BSM.sign(message, childPk, 'raw') as Signature).toCompact(\n r,\n true,\n \"base64\"\n ) as string;\n \n return { address, signature };\n }\n\n // Implement signOpReturnWithAIP - MemberID ignores signing path\n public signOpReturnWithAIP(\n opReturn: number[][]\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat());\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n // Return the member's public key\n public getPublicKey(): string {\n return this.key.toPublicKey().toString();\n }\n\n // Import the member identity from an object containing the derived private key and identity data\n public import(identity: MemberIdentity): void {\n this.idName = identity.name;\n this.description = identity.description;\n this.key = PrivateKey.fromWif(identity.derivedPrivateKey);\n this.address = this.key.toAddress();\n this.identityAttributes = identity.identityAttributes || {};\n this.identityKey = identity.identityKey;\n }\n\n static fromMemberIdentity(identity: MemberIdentity): MemberID {\n const member = new MemberID(PrivateKey.fromWif(identity.derivedPrivateKey));\n member.import(identity);\n return member;\n }\n\n static fromBackup(singleBackup: {wif:string, id: string}): MemberID {\n // decrypt the id and set the details\n const member = new MemberID(PrivateKey.fromWif(singleBackup.wif));\n const id = JSON.parse(member.decrypt(singleBackup.id));\n member.import(id);\n return member;\n }\n\n // Export the member identity as an object containing the derived private key and identity data\n public export(): MemberIdentity {\n return {\n name: this.idName,\n description: this.description,\n derivedPrivateKey: this.key.toWif(),\n address: this.address,\n identityAttributes: this.getAttributes(),\n identityKey: this.identityKey,\n };\n }\n\n /**\n * Get the encryption key pair for this identity\n * We use the same key for both signing and encryption for simplicity\n */\n getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey } {\n // Derive the encryption key from the private key using the ENCRYPTION_PATH\n // Since member keys are not HD keys, we use the path as the invoice number, \n // and use our own public key as the other party's public key\n return {\n privKey: this.key.deriveChild(this.key.toPublicKey(), ENCRYPTION_PATH),\n pubKey: this.key.deriveChild(this.key.toPublicKey(), ENCRYPTION_PATH).toPublicKey()\n };\n }\n\n /**\n * Get the public key for encrypting data for this identity\n */\n getEncryptionPublicKey(): string {\n const { pubKey } = this.getEncryptionKey();\n return pubKey.toString();\n }\n}",
|
11
|
+
"import { ECIES, Utils as BSVUtils, OP, PublicKey } from \"@bsv/sdk\";\nimport type { PrivateKey } from \"@bsv/sdk\";\nimport { AIP_BITCOM_ADDRESS } from \"./constants\";\nimport type { IdentityAttribute, IdentityAttributes } from \"./interface\";\nimport { Utils } from \"./utils\";\nconst { toArray, toUTF8, toBase64 } = BSVUtils;\nconst { electrumDecrypt, electrumEncrypt } = ECIES;\n\nabstract class BaseClass {\n protected identityAttributes: IdentityAttributes = {};\n\n /**\n * Abstract method that must be implemented by derived classes to sign messages\n * @param message - The message to sign\n * @param signingPath - Optional signing path for HD wallets\n * @returns Object containing address and signature\n */\n abstract signMessage(message: number[], signingPath?: string): { address: string; signature: string };\n\n /**\n * Abstract method that must be implemented by derived classes to get encryption key\n */\n abstract getEncryptionKey(): { privKey: PrivateKey, pubKey: PublicKey };\n\n /**\n * Encrypt the given string data with the identity encryption key\n * @param stringData\n * @param counterPartyPublicKey Optional public key of the counterparty\n * @return string Base64\n */\n encrypt(stringData: string, counterPartyPublicKey?: string): string {\n const { privKey, pubKey } = this.getEncryptionKey();\n const targetPubKey = counterPartyPublicKey\n ? PublicKey.fromString(counterPartyPublicKey)\n : pubKey;\n return toBase64(electrumEncrypt(toArray(stringData), targetPubKey, privKey));\n }\n\n /**\n * Decrypt the given ciphertext with the identity encryption key\n * @param ciphertext\n * @param counterPartyPublicKey Optional public key of the counterparty\n */\n decrypt(ciphertext: string, counterPartyPublicKey?: string): string {\n const { privKey } = this.getEncryptionKey();\n let pubKey = undefined;\n if (counterPartyPublicKey) {\n pubKey = PublicKey.fromString(counterPartyPublicKey);\n }\n return toUTF8(electrumDecrypt(toArray(ciphertext, \"base64\"), privKey, pubKey));\n }\n\n /**\n * Sign an op_return hex array with AIP\n * Each implementation must handle its own signing path logic\n * @param opReturn {array}\n * @param signingPath {string}\n * @return {number[]}\n */\n signOpReturnWithAIP(\n opReturn: number[][],\n signingPath?: string,\n ): number[][] {\n const aipMessageBuffer = this.getAIPMessageBuffer(opReturn);\n const { address, signature } = this.signMessage(aipMessageBuffer.flat(), signingPath);\n return this.formatAIPOutput(aipMessageBuffer, address, signature);\n }\n\n /**\n * Returns all the attributes in the identity\n * @returns {IdentityAttributes}\n */\n getAttributes(): IdentityAttributes {\n return this.identityAttributes;\n }\n\n /**\n * Get the value of the given attribute\n * @param attributeName\n * @returns {IdentityAttribute | null}\n */\n getAttribute(attributeName: string): IdentityAttribute | null {\n if (this.identityAttributes[attributeName]) {\n return this.identityAttributes[attributeName];\n }\n return null;\n }\n\n /**\n * Set the value of the given attribute\n * If an empty value ('' || null || false) is given, the attribute is removed from the ID\n * @param attributeName string\n * @param attributeValue any\n */\n setAttribute(attributeName: string, attributeValue: string | Record<string, string>): void {\n if (!attributeValue) {\n return;\n }\n\n if (this.identityAttributes[attributeName]) {\n this.updateExistingAttribute(attributeName, attributeValue);\n } else {\n this.createNewAttribute(attributeName, attributeValue);\n }\n }\n\n /**\n * Unset the given attribute from the ID\n * @param attributeName\n */\n unsetAttribute(attributeName: string): void {\n delete this.identityAttributes[attributeName];\n }\n\n /**\n * Add an attribute to this identity\n * @param attributeName\n * @param value\n * @param nonce\n */\n addAttribute(attributeName: string, value: string, nonce = \"\"): void {\n let nonceToUse = nonce;\n if (!nonce) {\n nonceToUse = Utils.getRandomString();\n }\n\n this.identityAttributes[attributeName] = {\n value,\n nonce: nonceToUse,\n };\n }\n\n /**\n * Get all attribute URNs for this ID\n * @returns {string}\n */\n getAttributeUrns(): string {\n let urns = \"\";\n for (const key in this.identityAttributes) {\n const urn = this.getAttributeUrn(key);\n if (urn) {\n urns += `${urn}\\n`;\n }\n }\n return urns;\n }\n\n /**\n * Create and return the attribute URN for the given attribute\n * @param attributeName\n * @returns {string|null}\n */\n getAttributeUrn(attributeName: string): string | null {\n const attribute = this.identityAttributes[attributeName];\n if (attribute) {\n return `urn:bap:id:${attributeName}:${attribute.value}:${attribute.nonce}`;\n }\n return null;\n }\n\n /**\n * Parse a text of URN string into identity attributes\n * @param urnIdentityAttributes\n */\n protected parseStringUrns(urnIdentityAttributes: string): IdentityAttributes {\n const identityAttributes: IdentityAttributes = {};\n const attributesRaw = urnIdentityAttributes\n .replace(/^\\s+/g, \"\")\n .replace(/\\r/gm, \"\")\n .split(\"\\n\");\n\n for (const line of attributesRaw) {\n const attribute = line.replace(/^\\s+/g, \"\").replace(/\\s+$/g, \"\");\n const urn = attribute.split(\":\");\n if (\n urn[0] === \"urn\" &&\n urn[1] === \"bap\" &&\n urn[2] === \"id\" &&\n urn[3] &&\n urn[4] &&\n urn[5]\n ) {\n identityAttributes[urn[3]] = {\n value: urn[4],\n nonce: urn[5],\n };\n }\n }\n\n return identityAttributes;\n }\n\n /**\n * Helper function to parse identity attributes\n * @param identityAttributes\n * @returns {IdentityAttributes}\n */\n protected parseAttributes(\n identityAttributes: IdentityAttributes | string,\n ): IdentityAttributes {\n if (typeof identityAttributes === \"string\") {\n return this.parseStringUrns(identityAttributes);\n }\n\n for (const key in identityAttributes) {\n if (!identityAttributes[key].value || !identityAttributes[key].nonce) {\n throw new Error(\"Invalid identity attribute\");\n }\n }\n\n return identityAttributes || {};\n }\n\n /**\n * Helper method to update an existing attribute\n */\n protected updateExistingAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.identityAttributes[attributeName].value = attributeValue;\n return;\n }\n\n this.identityAttributes[attributeName].value = attributeValue.value || '';\n if (attributeValue.nonce) {\n this.identityAttributes[attributeName].nonce = attributeValue.nonce;\n }\n }\n\n /**\n * Helper method to create a new attribute\n */\n protected createNewAttribute(\n attributeName: string,\n attributeValue: string | Record<string, string>\n ): void {\n if (typeof attributeValue === 'string') {\n this.addAttribute(attributeName, attributeValue);\n return;\n }\n\n this.addAttribute(\n attributeName,\n attributeValue.value || '',\n attributeValue.nonce\n );\n }\n\n /**\n * Construct an AIP buffer from the op return data\n * @param opReturn\n * @returns {number[]} Array of numbers representing the buffer\n */\n protected getAIPMessageBuffer(opReturn: number[][], indicies?: number[]): number[][] {\n\n // locate the position of OP_RETURN in the opReturn array\n let opReturnIndex = opReturn.findIndex(op => op[0] === OP.OP_RETURN);\n const buffers: number[][] = [];\n\n // include OP_RETURN in constructing the signature buffer\n if (opReturnIndex === -1) {\n buffers.push([OP.OP_RETURN]);\n opReturnIndex = 0;\n }\n\n // if indicies is specified, only include the specified indicies in the buffer\n // relative to the position of OP_RETURN as \"0\"\n if (indicies) {\n for (const index of indicies) {\n buffers.push(opReturn[opReturnIndex + index]);\n }\n } else {\n for (const op of opReturn) {\n buffers.push(op);\n }\n }\n\n return buffers;\n }\n\n /**\n * Helper method to format AIP output\n * @param opReturn Original OP_RETURN data\n * @param address Signing address\n * @param signature Base64 signature\n * @returns Formatted AIP output as number[]\n */\n protected formatAIPOutput(\n opReturnBuffers: number[][],\n address: string,\n signature: string,\n ): number[][] {\n // Add AIP protocol elements\n const aipElements = [\n toArray(\"|\"),\n toArray(AIP_BITCOM_ADDRESS),\n toArray(\"BITCOIN_ECDSA\"),\n toArray(address),\n toArray(signature, \"base64\"),\n ];\n\n // Concatenate all buffers\n return [\n ...opRe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EAAG,EAId,MAAO,QAcH,yBAAwB,CAC5B,EACA,EACA,EACA,EACkB,CAIlB,IAF0B,KAAK,gBAAgB,EAAW,EAAS,CAAS,EAG1E,MAAO,GAGT,GAAI,CACF,IAAM,EAAW,MAAM,KAAK,WAAqC,qBAAsB,CACrF,QACA,UACA,YACA,WACF,CAAC,EAGD,GAAI,GAAU,SAAW,WAAa,GAAU,QAAQ,QAAU,GAChE,MAAO,GAGT,MAAO,GACP,MAAO,EAAO,CAEd,OADA,QAAQ,MAAM,mBAAoB,CAAK,EAChC,SAWL,8BAA6B,CAAC,EAA2D,CAC7F,GAAI,KAAK,yBAAyB,CAAE,EAClC,OAAO,KAAK,WAAqC,qBAAsB,CACrE,IACF,CAAC,EAEH,MAAO,QASH,uBAAsB,CAAC,EAAwD,CACnF,OAAO,KAAK,WAAyC,yBAA0B,CAC7E,SACF,CAAC,OASG,YAAW,CAAC,EAA6C,CAC7D,OAAO,KAAK,WAAgC,gBAAiB,CAC3D,OACF,CAAC,OAQG,uBAAsB,CAAC,EAA0D,CAErF,OAAO,KAAK,WAAmC,gBAAiB,CAC9D,KAAM,CACR,CAAC,EAIL",
|
14
|
+
"debugId": "BC682187893BF30D64756E2164756E21",
|
15
15
|
"names": []
|
16
16
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "bsv-bap",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.8",
|
4
4
|
"description": "BAP npm module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -39,15 +39,15 @@
|
|
39
39
|
},
|
40
40
|
"devDependencies": {
|
41
41
|
"@biomejs/biome": "1.9.4",
|
42
|
-
"@types/bun": "^1.2.
|
43
|
-
"@types/node": "^22.
|
42
|
+
"@types/bun": "^1.2.12",
|
43
|
+
"@types/node": "^22.15.12",
|
44
44
|
"rimraf": "^6.0.1",
|
45
|
-
"typescript": "^5.
|
45
|
+
"typescript": "^5.8.3"
|
46
46
|
},
|
47
47
|
"dependencies": {
|
48
|
-
"schema-dts": "^1.1.
|
48
|
+
"schema-dts": "^1.1.5"
|
49
49
|
},
|
50
50
|
"peerDependencies": {
|
51
|
-
"@bsv/sdk": "^1.
|
51
|
+
"@bsv/sdk": "^1.4.24"
|
52
52
|
}
|
53
53
|
}
|