@notabene/verify-proof 1.0.0-preview.2 → 1.0.0-preview.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var r=require("@notabene/javascript-sdk/src/types"),e=require("viem");function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},t.apply(null,arguments)}exports.verifyProof=function(s){try{switch(s.type){case r.ProofTypes.SelfDeclaration:return Promise.resolve(t({},s,{status:s.confirmed?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED}));case r.ProofTypes.Screenshot:return Promise.resolve(t({},s,{status:s.url?r.ProofStatus.FLAGGED:r.ProofStatus.FAILED}));case r.ProofTypes.PersonalSignEIP191:return function(s){try{return Promise.resolve(e.verifyMessage({address:s.address,message:s.attestation,signature:s.proof})).then(function(e){return t({},s,{status:e?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED})})}catch(r){return Promise.reject(r)}}(s)}return Promise.resolve(s)}catch(r){return Promise.reject(r)}};
1
+ var r=require("@notabene/javascript-sdk/src/types"),e=require("viem");function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},t.apply(null,arguments)}exports.verifyProof=function(s){try{switch(s.type){case r.ProofTypes.SelfDeclaration:return Promise.resolve(t({},s,{status:s.confirmed?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED}));case r.ProofTypes.Screenshot:return Promise.resolve(t({},s,{status:s.url?r.ProofStatus.FLAGGED:r.ProofStatus.FAILED}));case r.ProofTypes.PersonalSignEIP191:return function(s){try{var o=s.address.split(/:/),a=o[2];return"eip155"!==o[0]?Promise.resolve(t({},s,{status:r.ProofStatus.FAILED})):Promise.resolve(e.verifyMessage({address:a,message:s.attestation,signature:s.proof})).then(function(e){return t({},s,{status:e?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED})})}catch(r){return Promise.reject(r)}}(s)}return Promise.resolve(s)}catch(r){return Promise.reject(r)}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const verified = await verifyMessage({\n address: proof.address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","verifyMessage","address","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"kTAUsB,SACpBA,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAUA,WAACC,gBACd,OAAAC,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,GACHO,OAASP,EAA2BQ,UAChCC,cAAYC,SACZD,EAAAA,YAAYE,UAEpB,KAAKT,EAAUA,WAACU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAAA,YAAYK,QACZL,EAAWA,YAACE,UAEpB,KAAKT,EAAAA,WAAWa,mBACd,gBAUJf,GAAqB,IAAAI,OAAAA,QAAAC,QAEEW,EAAAA,cAAc,CACnCC,QAASjB,EAAMiB,QACfC,QAASlB,EAAMmB,YACfC,UAAWpB,EAAMA,SACjBqB,KAAA,SAJIC,GAKN,OAAAhB,EACKN,CAAAA,EAAAA,GACHO,OAAQe,EAAWb,EAAAA,YAAYC,SAAWD,EAAWA,YAACE,QACtD,EACJ,CAAC,MAAAY,GAAA,OAAAnB,QAAAoB,OAAAD,IArBYE,CAAyBzB,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAuB,UAAAnB,QAAAoB,OAAAD,EAAA,CAAA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const [ns, _, address] = proof.address.split(/:/);\n if (ns !== \"eip155\") return { ...proof, status: ProofStatus.FAILED };\n\n const verified = await verifyMessage({\n address: address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"kTAUiC,SAC/BA,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAAA,WAAWC,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKN,EAAK,CACRO,OAASP,EAA2BQ,UAChCC,EAAAA,YAAYC,SACZD,EAAAA,YAAYE,UAEpB,KAAKT,EAAUA,WAACU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAWA,YAACK,QACZL,EAAWA,YAACE,UAEpB,KAAKT,EAAAA,WAAWa,mBACd,OASiC,SACrCf,GAAqB,IAErB,IAAAgB,EAAyBhB,EAAMiB,QAAQC,MAAM,KAA/BD,EAAOD,EAAA,GACrB,MAAW,WADFA,EAAA,GACYZ,QAAAC,QAAAC,EAAA,GAAYN,EAAK,CAAEO,OAAQE,EAAWA,YAACE,UAASP,QAAAC,QAE9Cc,EAAAA,cAAc,CACnCF,QAASA,EACTG,QAASpB,EAAMqB,YACfC,UAAWtB,EAAMA,SACjBuB,KAJIC,SAAAA,GAKN,OAAAlB,EAAA,CAAA,EACKN,EAAK,CACRO,OAAQiB,EAAWf,EAAWA,YAACC,SAAWD,EAAAA,YAAYE,QACtD,EACJ,CAAC,MAAAc,GAAArB,OAAAA,QAAAsB,OAAAD,EA3CD,CAAA,CAmBaE,CAAyB3B,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAyB,GAAA,OAAArB,QAAAsB,OAAAD,EAAA,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{ProofTypes as r,ProofStatus as e}from"@notabene/javascript-sdk/src/types";import{verifyMessage as t}from"viem";function s(){return s=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},s.apply(null,arguments)}var n=function(n){try{switch(n.type){case r.SelfDeclaration:return Promise.resolve(s({},n,{status:n.confirmed?e.VERIFIED:e.FAILED}));case r.Screenshot:return Promise.resolve(s({},n,{status:n.url?e.FLAGGED:e.FAILED}));case r.PersonalSignEIP191:return function(r){try{return Promise.resolve(t({address:r.address,message:r.attestation,signature:r.proof})).then(function(t){return s({},r,{status:t?e.VERIFIED:e.FAILED})})}catch(r){return Promise.reject(r)}}(n)}return Promise.resolve(n)}catch(r){return Promise.reject(r)}};export{n as verifyProof};
1
+ import{ProofTypes as r,ProofStatus as e}from"@notabene/javascript-sdk/src/types";import{verifyMessage as t}from"viem";function s(){return s=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(r[s]=t[s])}return r},s.apply(null,arguments)}var n=function(n){try{switch(n.type){case r.SelfDeclaration:return Promise.resolve(s({},n,{status:n.confirmed?e.VERIFIED:e.FAILED}));case r.Screenshot:return Promise.resolve(s({},n,{status:n.url?e.FLAGGED:e.FAILED}));case r.PersonalSignEIP191:return function(r){try{var n=r.address.split(/:/),o=n[2];return"eip155"!==n[0]?Promise.resolve(s({},r,{status:e.FAILED})):Promise.resolve(t({address:o,message:r.attestation,signature:r.proof})).then(function(t){return s({},r,{status:t?e.VERIFIED:e.FAILED})})}catch(r){return Promise.reject(r)}}(n)}return Promise.resolve(n)}catch(r){return Promise.reject(r)}};export{n as verifyProof};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const verified = await verifyMessage({\n address: proof.address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["verifyProof","proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","verifyMessage","address","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"8UAQqC,IAEfA,EAAA,SACpBC,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAWC,gBACd,OAAAC,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,GACHO,OAASP,EAA2BQ,UAChCC,EAAYC,SACZD,EAAYE,UAEpB,KAAKT,EAAWU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAYK,QACZL,EAAYE,UAEpB,KAAKT,EAAWa,mBACd,gBAUJf,GAAqB,IAAAI,OAAAA,QAAAC,QAEEW,EAAc,CACnCC,QAASjB,EAAMiB,QACfC,QAASlB,EAAMmB,YACfC,UAAWpB,EAAMA,SACjBqB,KAAA,SAJIC,GAKN,OAAAhB,EACKN,CAAAA,EAAAA,GACHO,OAAQe,EAAWb,EAAYC,SAAWD,EAAYE,QACtD,EACJ,CAAC,MAAAY,GAAA,OAAAnB,QAAAoB,OAAAD,IArBYE,CAAyBzB,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAuB,UAAAnB,QAAAoB,OAAAD,EAAA,CAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const [ns, _, address] = proof.address.split(/:/);\n if (ns !== \"eip155\") return { ...proof, status: ProofStatus.FAILED };\n\n const verified = await verifyMessage({\n address: address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["verifyProof","proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"8UAQqC,IAEfA,EAAW,SAC/BC,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAWC,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKN,EAAK,CACRO,OAASP,EAA2BQ,UAChCC,EAAYC,SACZD,EAAYE,UAEpB,KAAKT,EAAWU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAYK,QACZL,EAAYE,UAEpB,KAAKT,EAAWa,mBACd,OASiC,SACrCf,GAAqB,IAErB,IAAAgB,EAAyBhB,EAAMiB,QAAQC,MAAM,KAA/BD,EAAOD,EAAA,GACrB,MAAW,WADFA,EAAA,GACYZ,QAAAC,QAAAC,EAAA,GAAYN,EAAK,CAAEO,OAAQE,EAAYE,UAASP,QAAAC,QAE9Cc,EAAc,CACnCF,QAASA,EACTG,QAASpB,EAAMqB,YACfC,UAAWtB,EAAMA,SACjBuB,KAJIC,SAAAA,GAKN,OAAAlB,EAAA,CAAA,EACKN,EAAK,CACRO,OAAQiB,EAAWf,EAAYC,SAAWD,EAAYE,QACtD,EACJ,CAAC,MAAAc,GAAArB,OAAAA,QAAAsB,OAAAD,EA3CD,CAAA,CAmBaE,CAAyB3B,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAyB,GAAA,OAAArB,QAAAsB,OAAAD,EAAA,CAAA"}
@@ -1,2 +1,2 @@
1
- import{ProofTypes as r,ProofStatus as t}from"@notabene/javascript-sdk/src/types";import{verifyMessage as n}from"viem";function e(){return e=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var e in n)({}).hasOwnProperty.call(n,e)&&(r[e]=n[e])}return r},e.apply(null,arguments)}async function s(s){switch(s.type){case r.SelfDeclaration:return e({},s,{status:s.confirmed?t.VERIFIED:t.FAILED});case r.Screenshot:return e({},s,{status:s.url?t.FLAGGED:t.FAILED});case r.PersonalSignEIP191:return async function(r){return e({},r,{status:await n({address:r.address,message:r.attestation,signature:r.proof})?t.VERIFIED:t.FAILED})}(s)}return s}export{s as verifyProof};
1
+ import{ProofTypes as t,ProofStatus as r}from"@notabene/javascript-sdk/src/types";import{verifyMessage as s}from"viem";function n(){return n=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var n in s)({}).hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},n.apply(null,arguments)}async function e(e){switch(e.type){case t.SelfDeclaration:return n({},e,{status:e.confirmed?r.VERIFIED:r.FAILED});case t.Screenshot:return n({},e,{status:e.url?r.FLAGGED:r.FAILED});case t.PersonalSignEIP191:return async function(t){const[e,a,i]=t.address.split(/:/);return n({},t,"eip155"!==e?{status:r.FAILED}:{status:await s({address:i,message:t.attestation,signature:t.proof})?r.VERIFIED:r.FAILED})}(e)}return e}export{e as verifyProof};
2
2
  //# sourceMappingURL=index.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const verified = await verifyMessage({\n address: proof.address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["async","verifyProof","proof","type","ProofTypes","SelfDeclaration","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","verifyMessage","address","message","attestation","signature","verifyPersonalSignEIP191"],"mappings":"8UAUOA,eAAeC,EACpBC,GAEA,OAAQA,EAAMC,MACZ,KAAKC,EAAWC,gBACd,OAAAC,KACKJ,EAAK,CACRK,OAASL,EAA2BM,UAChCC,EAAYC,SACZD,EAAYE,SAEpB,KAAKP,EAAWQ,WACd,OAAAN,EACKJ,GAAAA,GACHK,OAASL,EAA0BW,IAC/BJ,EAAYK,QACZL,EAAYE,SAEpB,KAAKP,EAAWW,mBACd,OASNf,eACEE,GAOA,OAAAI,EACKJ,CAAAA,EAAAA,GACHK,aAPqBS,EAAc,CACnCC,QAASf,EAAMe,QACfC,QAAShB,EAAMiB,YACfC,UAAWlB,EAAMA,QAIEO,EAAYC,SAAWD,EAAYE,QAE1D,CArBaU,CAAyBnB,GAMpC,OAAOA,CACT"}
1
+ {"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const [ns, _, address] = proof.address.split(/:/);\n if (ns !== \"eip155\") return { ...proof, status: ProofStatus.FAILED };\n\n const verified = await verifyMessage({\n address: address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["async","verifyProof","proof","type","ProofTypes","SelfDeclaration","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","ns","_","address","split","verifyMessage","message","attestation","signature","verifyPersonalSignEIP191"],"mappings":"8UAUOA,eAAeC,EACpBC,GAEA,OAAQA,EAAMC,MACZ,KAAKC,EAAWC,gBACd,OAAAC,EACKJ,CAAAA,EAAAA,EACHK,CAAAA,OAASL,EAA2BM,UAChCC,EAAYC,SACZD,EAAYE,SAEpB,KAAKP,EAAWQ,WACd,OAAAN,EAAA,GACKJ,EACHK,CAAAA,OAASL,EAA0BW,IAC/BJ,EAAYK,QACZL,EAAYE,SAEpB,KAAKP,EAAWW,mBACd,OASNf,eACEE,GAEA,MAAOc,EAAIC,EAAGC,GAAWhB,EAAMgB,QAAQC,MAAM,KAC7C,OAAqBb,EAAA,CAAA,EAAYJ,EAAtB,WAAPc,EAAkC,CAAET,OAAQE,EAAYE,QAQlD,CACRJ,aAPqBa,EAAc,CACnCF,QAASA,EACTG,QAASnB,EAAMoB,YACfC,UAAWrB,EAAMA,QAIEO,EAAYC,SAAWD,EAAYE,QAE1D,CAxBaa,CAAyBtB,GAMpC,OAAOA,CACT"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@notabene/javascript-sdk/src/types"),require("viem")):"function"==typeof define&&define.amd?define(["exports","@notabene/javascript-sdk/src/types","viem"],r):r((e||self).verifyProof={},e.types,e.viem)}(this,function(e,r,t){function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)({}).hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},o.apply(null,arguments)}e.verifyProof=function(e){try{switch(e.type){case r.ProofTypes.SelfDeclaration:return Promise.resolve(o({},e,{status:e.confirmed?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED}));case r.ProofTypes.Screenshot:return Promise.resolve(o({},e,{status:e.url?r.ProofStatus.FLAGGED:r.ProofStatus.FAILED}));case r.ProofTypes.PersonalSignEIP191:return function(e){try{return Promise.resolve(t.verifyMessage({address:e.address,message:e.attestation,signature:e.proof})).then(function(t){return o({},e,{status:t?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED})})}catch(e){return Promise.reject(e)}}(e)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}}});
1
+ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@notabene/javascript-sdk/src/types"),require("viem")):"function"==typeof define&&define.amd?define(["exports","@notabene/javascript-sdk/src/types","viem"],r):r((e||self).verifyProof={},e.types,e.viem)}(this,function(e,r,t){function s(){return s=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var s in t)({}).hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},s.apply(null,arguments)}e.verifyProof=function(e){try{switch(e.type){case r.ProofTypes.SelfDeclaration:return Promise.resolve(s({},e,{status:e.confirmed?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED}));case r.ProofTypes.Screenshot:return Promise.resolve(s({},e,{status:e.url?r.ProofStatus.FLAGGED:r.ProofStatus.FAILED}));case r.ProofTypes.PersonalSignEIP191:return function(e){try{var o=e.address.split(/:/),n=o[2];return"eip155"!==o[0]?Promise.resolve(s({},e,{status:r.ProofStatus.FAILED})):Promise.resolve(t.verifyMessage({address:n,message:e.attestation,signature:e.proof})).then(function(t){return s({},e,{status:t?r.ProofStatus.VERIFIED:r.ProofStatus.FAILED})})}catch(e){return Promise.reject(e)}}(e)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}}});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const verified = await verifyMessage({\n address: proof.address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","verifyMessage","address","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"wkBAUsB,SACpBA,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAUA,WAACC,gBACd,OAAAC,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,GACHO,OAASP,EAA2BQ,UAChCC,cAAYC,SACZD,EAAAA,YAAYE,UAEpB,KAAKT,EAAUA,WAACU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAAA,YAAYK,QACZL,EAAWA,YAACE,UAEpB,KAAKT,EAAAA,WAAWa,mBACd,gBAUJf,GAAqB,IAAAI,OAAAA,QAAAC,QAEEW,EAAAA,cAAc,CACnCC,QAASjB,EAAMiB,QACfC,QAASlB,EAAMmB,YACfC,UAAWpB,EAAMA,SACjBqB,KAAA,SAJIC,GAKN,OAAAhB,EACKN,CAAAA,EAAAA,GACHO,OAAQe,EAAWb,EAAAA,YAAYC,SAAWD,EAAWA,YAACE,QACtD,EACJ,CAAC,MAAAY,GAAA,OAAAnB,QAAAoB,OAAAD,IArBYE,CAAyBzB,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAuB,UAAAnB,QAAAoB,OAAAD,EAAA,CAAA"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import {\n DeclarationProof,\n ProofStatus,\n ProofTypes,\n ScreenshotProof,\n SignatureProof,\n type OwnershipProof,\n} from \"@notabene/javascript-sdk/src/types\";\nimport { verifyMessage } from \"viem\";\n\nexport async function verifyProof(\n proof: OwnershipProof,\n): Promise<OwnershipProof> {\n switch (proof.type) {\n case ProofTypes.SelfDeclaration:\n return {\n ...proof,\n status: (proof as DeclarationProof).confirmed\n ? ProofStatus.VERIFIED\n : ProofStatus.FAILED,\n };\n case ProofTypes.Screenshot:\n return {\n ...proof,\n status: (proof as ScreenshotProof).url\n ? ProofStatus.FLAGGED\n : ProofStatus.FAILED,\n };\n case ProofTypes.PersonalSignEIP191:\n return verifyPersonalSignEIP191(proof as SignatureProof);\n case ProofTypes.PersonalSignEIP712:\n case ProofTypes.PersonalSignBIP137:\n case ProofTypes.PersonalSignXPUB:\n case ProofTypes.MicroTransfer:\n }\n return proof;\n}\n\nasync function verifyPersonalSignEIP191(\n proof: SignatureProof,\n): Promise<SignatureProof> {\n const [ns, _, address] = proof.address.split(/:/);\n if (ns !== \"eip155\") return { ...proof, status: ProofStatus.FAILED };\n\n const verified = await verifyMessage({\n address: address as `0x${string}`,\n message: proof.attestation,\n signature: proof.proof as `0x${string}`,\n });\n return {\n ...proof,\n status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED,\n };\n}\n"],"names":["proof","type","ProofTypes","SelfDeclaration","Promise","resolve","_extends","status","confirmed","ProofStatus","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"wkBAUiC,SAC/BA,GAAqB,IAErB,OAAQA,EAAMC,MACZ,KAAKC,EAAAA,WAAWC,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKN,EAAK,CACRO,OAASP,EAA2BQ,UAChCC,EAAAA,YAAYC,SACZD,EAAAA,YAAYE,UAEpB,KAAKT,EAAUA,WAACU,WACd,OAAAR,QAAAC,QAAAC,EACKN,CAAAA,EAAAA,EACHO,CAAAA,OAASP,EAA0Ba,IAC/BJ,EAAWA,YAACK,QACZL,EAAWA,YAACE,UAEpB,KAAKT,EAAAA,WAAWa,mBACd,OASiC,SACrCf,GAAqB,IAErB,IAAAgB,EAAyBhB,EAAMiB,QAAQC,MAAM,KAA/BD,EAAOD,EAAA,GACrB,MAAW,WADFA,EAAA,GACYZ,QAAAC,QAAAC,EAAA,GAAYN,EAAK,CAAEO,OAAQE,EAAWA,YAACE,UAASP,QAAAC,QAE9Cc,EAAAA,cAAc,CACnCF,QAASA,EACTG,QAASpB,EAAMqB,YACfC,UAAWtB,EAAMA,SACjBuB,KAJIC,SAAAA,GAKN,OAAAlB,EAAA,CAAA,EACKN,EAAK,CACRO,OAAQiB,EAAWf,EAAWA,YAACC,SAAWD,EAAAA,YAAYE,QACtD,EACJ,CAAC,MAAAc,GAAArB,OAAAA,QAAAsB,OAAAD,EA3CD,CAAA,CAmBaE,CAAyB3B,GAMpC,OAAAI,QAAAC,QAAOL,EACT,CAAC,MAAAyB,GAAA,OAAArB,QAAAsB,OAAAD,EAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notabene/verify-proof",
3
- "version": "1.0.0-preview.2",
3
+ "version": "1.0.0-preview.3",
4
4
  "description": "Verify ownership proofs",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
@@ -8,6 +8,12 @@
8
8
  "main": "dist/index.cjs",
9
9
  "author": "Pelle Braendgaard",
10
10
  "license": "Apache-2.0",
11
+ "files": [
12
+ "dist",
13
+ "src",
14
+ "package.json",
15
+ "README.md"
16
+ ],
11
17
  "scripts": {
12
18
  "build:dev": "yarn build && yarn dev",
13
19
  "build:clean": "rimraf dist/ ts-out",
@@ -22,7 +28,7 @@
22
28
  "vitest": "^2.0.5"
23
29
  },
24
30
  "dependencies": {
25
- "@notabene/javascript-sdk": "^2.0.0-next.4",
31
+ "@notabene/javascript-sdk": "^2.0.0-next.5",
26
32
  "bitcoinjs-message": "^2.2.0",
27
33
  "viem": "^2.19.8"
28
34
  }
package/src/index.ts CHANGED
@@ -39,7 +39,7 @@ export async function verifyProof(
39
39
  async function verifyPersonalSignEIP191(
40
40
  proof: SignatureProof,
41
41
  ): Promise<SignatureProof> {
42
- const [ns, chainId, address] = proof.address.split(/:/);
42
+ const [ns, _, address] = proof.address.split(/:/);
43
43
  if (ns !== "eip155") return { ...proof, status: ProofStatus.FAILED };
44
44
 
45
45
  const verified = await verifyMessage({
package/.node-version DELETED
@@ -1 +0,0 @@
1
- v20.17.0
package/tsconfig.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "resolveJsonModule": true,
12
- "isolatedModules": true,
13
- "noEmit": true,
14
-
15
- /* Linting */
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "noFallthroughCasesInSwitch": true,
20
-
21
- /* Path aliases */
22
- "baseUrl": ".",
23
- "paths": {
24
- "@/*": ["src/*"]
25
- },
26
-
27
- /* Additional settings */
28
- "esModuleInterop": true,
29
- "forceConsistentCasingInFileNames": true
30
- },
31
- "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
32
- }