@notabene/verify-proof 1.0.0-preview.3 → 1.0.0-preview.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +92 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -3
- package/src/index.ts +108 -8
package/dist/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var r
|
1
|
+
var e,r,o=require("viem");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var s in o)({}).hasOwnProperty.call(o,s)&&(e[s]=o[s])}return e},s.apply(null,arguments)}exports.ProofStatus=void 0,(e=exports.ProofStatus||(exports.ProofStatus={})).PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified",exports.ProofTypes=void 0,(r=exports.ProofTypes||(exports.ProofTypes={})).SelfDeclaration="self-declaration",r.PersonalSignEIP191="eip-191",r.PersonalSignEIP712="eip-712",r.PersonalSignBIP137="bip-137",r.PersonalSignXPUB="xpub",r.MicroTransfer="microtransfer",r.Screenshot="screenshot",exports.verifyProof=function(e){try{switch(e.type){case exports.ProofTypes.SelfDeclaration:return Promise.resolve(s({},e,{status:e.confirmed?exports.ProofStatus.VERIFIED:exports.ProofStatus.FAILED}));case exports.ProofTypes.Screenshot:return Promise.resolve(s({},e,{status:e.url?exports.ProofStatus.FLAGGED:exports.ProofStatus.FAILED}));case exports.ProofTypes.PersonalSignEIP191:return function(e){try{var r=e.address.split(/:/),t=r[2];return"eip155"!==r[0]?Promise.resolve(s({},e,{status:exports.ProofStatus.FAILED})):Promise.resolve(o.verifyMessage({address:t,message:e.attestation,signature:e.proof})).then(function(r){return s({},e,{status:r?exports.ProofStatus.VERIFIED:exports.ProofStatus.FAILED})})}catch(e){return Promise.reject(e)}}(e);case exports.ProofTypes.PersonalSignEIP712:case exports.ProofTypes.PersonalSignBIP137:case exports.ProofTypes.PersonalSignXPUB:case exports.ProofTypes.MicroTransfer:}return Promise.resolve(e)}catch(e){return Promise.reject(e)}};
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {\n
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { verifyMessage } from \"viem\";\n\nexport type CAIP2 = `${string}:${string}`;\nexport type CAIP10 = `${CAIP2}:${string}`;\nexport type CAIP19 = `${CAIP2}/${string}:${string}`;\nexport type CAIP220 = string;\n\nexport type DTI = string;\nexport type NotabeneAsset = string;\n\n/**\n * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.\n *\n * @public\n */\n\nexport type TransactionAsset = NotabeneAsset | CAIP19 | DTI;\n\nexport type BlockchainAddress = string;\nexport type TravelAddress = string;\n\n/**\n * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.\n * @public\n */\nexport type Destination = BlockchainAddress | CAIP10 | TravelAddress;\nexport type Source = BlockchainAddress | CAIP10;\nexport type URI = string;\nexport type DID = `did:${string}:${string}`;\n\n/**\n * Status of the proof\n * @public\n */\nexport enum ProofStatus {\n PENDING = \"pending\", // Verification is pending\n FAILED = \"rejected\", // Rejected\n FLAGGED = \"flagged\", // Flagged for manual review\n VERIFIED = \"verified\", // Verified\n}\n\n/**\n * The type of Proofs supported\n * @public\n **/\nexport enum ProofTypes {\n SelfDeclaration = \"self-declaration\",\n PersonalSignEIP191 = \"eip-191\",\n PersonalSignEIP712 = \"eip-712\",\n PersonalSignBIP137 = \"bip-137\",\n PersonalSignXPUB = \"xpub\",\n MicroTransfer = \"microtransfer\",\n Screenshot = \"screenshot\",\n}\n/**\n * Ownership Proof\n * @public\n */\nexport interface OwnershipProof {\n type: ProofTypes;\n status: ProofStatus;\n did: DID;\n address: CAIP10;\n}\n\n/**\n * Ownership Proof using Message Signature\n * @public\n */\nexport interface SignatureProof extends OwnershipProof {\n type:\n | ProofTypes.PersonalSignEIP191\n | ProofTypes.PersonalSignEIP712\n | ProofTypes.PersonalSignBIP137\n | ProofTypes.PersonalSignXPUB;\n proof: string;\n attestation: string;\n wallet_provider: string;\n}\n\n/**\n * Ownership Proof using Self Declaration\n * @public\n */\nexport interface DeclarationProof extends OwnershipProof {\n type: ProofTypes.SelfDeclaration;\n attestation: string;\n confirmed: boolean;\n}\n\n/**\n * Ownership Proof using Micro Transfer\n * @public\n */\nexport interface MicroTransferProof extends OwnershipProof {\n type: ProofTypes.MicroTransfer;\n txhash: string;\n chain: CAIP2;\n amount: number;\n}\n\n/**\n * Ownership Proof using Screenshot\n * @public\n */\nexport interface ScreenshotProof extends OwnershipProof {\n type: ProofTypes.Screenshot;\n url: string;\n}\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":["ProofStatus","ProofTypes","proof","type","SelfDeclaration","Promise","resolve","_extends","status","confirmed","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","_","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191","PersonalSignEIP712","PersonalSignBIP137","PersonalSignXPUB","MicroTransfer"],"mappings":"IAkCYA,EAWAC,4OAXAD,QAAAA,iBAAAA,GAAAA,EAAAA,QAAWA,cAAXA,oBAKX,CAAA,IAJC,QAAA,UACAA,EAAA,OAAA,WACAA,EAAA,QAAA,UACAA,EAAA,SAAA,WAOUC,2BAAAA,EAAAA,QAAAA,aAAAA,QAAUA,WAQrB,CAAA,IAPC,gBAAA,mBACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,iBAAA,OACAA,EAAA,cAAA,gBACAA,EAAA,WAAA,iCA0DoB,SACpBC,OAEA,OAAQA,EAAMC,MACZ,KAAKF,mBAAWG,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA2BO,UAChCT,QAAWA,YAACU,SACZV,QAAAA,YAAYW,UAEpB,KAAKV,mBAAWW,WACd,OAAAP,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA0BW,IAC/Bb,QAAWA,YAACc,QACZd,QAAAA,YAAYW,UAEpB,KAAKV,QAAUA,WAACc,mBACd,OASS,SACbb,GAAqB,IAErB,IAAAc,EAAyBd,EAAMe,QAAQC,MAAM,KAA/BD,EAAOD,KACrB,MAAW,WADFA,EAAEG,GACUd,QAAAC,QAAAC,EAAYL,GAAAA,GAAOM,OAAQR,QAAWA,YAACW,UAASN,QAAAC,QAE9Cc,EAAaA,cAAC,CACnCH,QAASA,EACTI,QAASnB,EAAMoB,YACfC,UAAWrB,EAAMA,SACjBsB,cAJIC,GAKN,OAAAlB,KACKL,EAAK,CACRM,OAAQiB,EAAWzB,QAAAA,YAAYU,SAAWV,oBAAYW,QACtD,EACJ,CAAC,MAAAe,GAAA,OAAArB,QAAAsB,OAAAD,IAxBYE,CAAyB1B,GAClC,KAAKD,mBAAW4B,mBAChB,KAAK5B,QAAAA,WAAW6B,mBAChB,KAAK7B,QAAUA,WAAC8B,iBAChB,KAAK9B,mBAAW+B,eAElB,OAAA3B,QAAAC,QAAOJ,EACT,CAAC,MAAAwB,GAAA,OAAArB,QAAAsB,OAAAD,EAAA,CAAA"}
|
package/dist/index.d.ts
CHANGED
@@ -1,2 +1,93 @@
|
|
1
|
-
|
1
|
+
export type CAIP2 = `${string}:${string}`;
|
2
|
+
export type CAIP10 = `${CAIP2}:${string}`;
|
3
|
+
export type CAIP19 = `${CAIP2}/${string}:${string}`;
|
4
|
+
export type CAIP220 = string;
|
5
|
+
export type DTI = string;
|
6
|
+
export type NotabeneAsset = string;
|
7
|
+
/**
|
8
|
+
* The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.
|
9
|
+
*
|
10
|
+
* @public
|
11
|
+
*/
|
12
|
+
export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
|
13
|
+
export type BlockchainAddress = string;
|
14
|
+
export type TravelAddress = string;
|
15
|
+
/**
|
16
|
+
* The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
|
17
|
+
* @public
|
18
|
+
*/
|
19
|
+
export type Destination = BlockchainAddress | CAIP10 | TravelAddress;
|
20
|
+
export type Source = BlockchainAddress | CAIP10;
|
21
|
+
export type URI = string;
|
22
|
+
export type DID = `did:${string}:${string}`;
|
23
|
+
/**
|
24
|
+
* Status of the proof
|
25
|
+
* @public
|
26
|
+
*/
|
27
|
+
export declare enum ProofStatus {
|
28
|
+
PENDING = "pending",// Verification is pending
|
29
|
+
FAILED = "rejected",// Rejected
|
30
|
+
FLAGGED = "flagged",// Flagged for manual review
|
31
|
+
VERIFIED = "verified"
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* The type of Proofs supported
|
35
|
+
* @public
|
36
|
+
**/
|
37
|
+
export declare enum ProofTypes {
|
38
|
+
SelfDeclaration = "self-declaration",
|
39
|
+
PersonalSignEIP191 = "eip-191",
|
40
|
+
PersonalSignEIP712 = "eip-712",
|
41
|
+
PersonalSignBIP137 = "bip-137",
|
42
|
+
PersonalSignXPUB = "xpub",
|
43
|
+
MicroTransfer = "microtransfer",
|
44
|
+
Screenshot = "screenshot"
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Ownership Proof
|
48
|
+
* @public
|
49
|
+
*/
|
50
|
+
export interface OwnershipProof {
|
51
|
+
type: ProofTypes;
|
52
|
+
status: ProofStatus;
|
53
|
+
did: DID;
|
54
|
+
address: CAIP10;
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Ownership Proof using Message Signature
|
58
|
+
* @public
|
59
|
+
*/
|
60
|
+
export interface SignatureProof extends OwnershipProof {
|
61
|
+
type: ProofTypes.PersonalSignEIP191 | ProofTypes.PersonalSignEIP712 | ProofTypes.PersonalSignBIP137 | ProofTypes.PersonalSignXPUB;
|
62
|
+
proof: string;
|
63
|
+
attestation: string;
|
64
|
+
wallet_provider: string;
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Ownership Proof using Self Declaration
|
68
|
+
* @public
|
69
|
+
*/
|
70
|
+
export interface DeclarationProof extends OwnershipProof {
|
71
|
+
type: ProofTypes.SelfDeclaration;
|
72
|
+
attestation: string;
|
73
|
+
confirmed: boolean;
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Ownership Proof using Micro Transfer
|
77
|
+
* @public
|
78
|
+
*/
|
79
|
+
export interface MicroTransferProof extends OwnershipProof {
|
80
|
+
type: ProofTypes.MicroTransfer;
|
81
|
+
txhash: string;
|
82
|
+
chain: CAIP2;
|
83
|
+
amount: number;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Ownership Proof using Screenshot
|
87
|
+
* @public
|
88
|
+
*/
|
89
|
+
export interface ScreenshotProof extends OwnershipProof {
|
90
|
+
type: ProofTypes.Screenshot;
|
91
|
+
url: string;
|
92
|
+
}
|
2
93
|
export declare function verifyProof(proof: OwnershipProof): Promise<OwnershipProof>;
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{
|
1
|
+
import{verifyMessage as e}from"viem";function r(){return r=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},r.apply(null,arguments)}var n,t,s=function(s){try{switch(s.type){case t.SelfDeclaration:return Promise.resolve(r({},s,{status:s.confirmed?n.VERIFIED:n.FAILED}));case t.Screenshot:return Promise.resolve(r({},s,{status:s.url?n.FLAGGED:n.FAILED}));case t.PersonalSignEIP191:return function(t){try{var s=t.address.split(/:/),i=s[2];return"eip155"!==s[0]?Promise.resolve(r({},t,{status:n.FAILED})):Promise.resolve(e({address:i,message:t.attestation,signature:t.proof})).then(function(e){return r({},t,{status:e?n.VERIFIED:n.FAILED})})}catch(e){return Promise.reject(e)}}(s)}return Promise.resolve(s)}catch(e){return Promise.reject(e)}};!function(e){e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified"}(n||(n={})),function(e){e.SelfDeclaration="self-declaration",e.PersonalSignEIP191="eip-191",e.PersonalSignEIP712="eip-712",e.PersonalSignBIP137="bip-137",e.PersonalSignXPUB="xpub",e.MicroTransfer="microtransfer",e.Screenshot="screenshot"}(t||(t={}));export{n as ProofStatus,t as ProofTypes,s 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
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { verifyMessage } from \"viem\";\n\nexport type CAIP2 = `${string}:${string}`;\nexport type CAIP10 = `${CAIP2}:${string}`;\nexport type CAIP19 = `${CAIP2}/${string}:${string}`;\nexport type CAIP220 = string;\n\nexport type DTI = string;\nexport type NotabeneAsset = string;\n\n/**\n * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.\n *\n * @public\n */\n\nexport type TransactionAsset = NotabeneAsset | CAIP19 | DTI;\n\nexport type BlockchainAddress = string;\nexport type TravelAddress = string;\n\n/**\n * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.\n * @public\n */\nexport type Destination = BlockchainAddress | CAIP10 | TravelAddress;\nexport type Source = BlockchainAddress | CAIP10;\nexport type URI = string;\nexport type DID = `did:${string}:${string}`;\n\n/**\n * Status of the proof\n * @public\n */\nexport enum ProofStatus {\n PENDING = \"pending\", // Verification is pending\n FAILED = \"rejected\", // Rejected\n FLAGGED = \"flagged\", // Flagged for manual review\n VERIFIED = \"verified\", // Verified\n}\n\n/**\n * The type of Proofs supported\n * @public\n **/\nexport enum ProofTypes {\n SelfDeclaration = \"self-declaration\",\n PersonalSignEIP191 = \"eip-191\",\n PersonalSignEIP712 = \"eip-712\",\n PersonalSignBIP137 = \"bip-137\",\n PersonalSignXPUB = \"xpub\",\n MicroTransfer = \"microtransfer\",\n Screenshot = \"screenshot\",\n}\n/**\n * Ownership Proof\n * @public\n */\nexport interface OwnershipProof {\n type: ProofTypes;\n status: ProofStatus;\n did: DID;\n address: CAIP10;\n}\n\n/**\n * Ownership Proof using Message Signature\n * @public\n */\nexport interface SignatureProof extends OwnershipProof {\n type:\n | ProofTypes.PersonalSignEIP191\n | ProofTypes.PersonalSignEIP712\n | ProofTypes.PersonalSignBIP137\n | ProofTypes.PersonalSignXPUB;\n proof: string;\n attestation: string;\n wallet_provider: string;\n}\n\n/**\n * Ownership Proof using Self Declaration\n * @public\n */\nexport interface DeclarationProof extends OwnershipProof {\n type: ProofTypes.SelfDeclaration;\n attestation: string;\n confirmed: boolean;\n}\n\n/**\n * Ownership Proof using Micro Transfer\n * @public\n */\nexport interface MicroTransferProof extends OwnershipProof {\n type: ProofTypes.MicroTransfer;\n txhash: string;\n chain: CAIP2;\n amount: number;\n}\n\n/**\n * Ownership Proof using Screenshot\n * @public\n */\nexport interface ScreenshotProof extends OwnershipProof {\n type: ProofTypes.Screenshot;\n url: string;\n}\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":["ProofStatus","ProofTypes","verifyProof","proof","type","SelfDeclaration","Promise","resolve","_extends","status","confirmed","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","_","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"6PAAqC,IAkCzBA,EAWAC,EAiEUC,EAAA,SACpBC,OAEA,OAAQA,EAAMC,MACZ,KAAKH,EAAWI,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA2BO,UAChCV,EAAYW,SACZX,EAAYY,UAEpB,KAAKX,EAAWY,WACd,OAAAP,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA0BW,IAC/Bd,EAAYe,QACZf,EAAYY,UAEpB,KAAKX,EAAWe,mBACd,OASS,SACbb,GAAqB,IAErB,IAAAc,EAAyBd,EAAMe,QAAQC,MAAM,KAA/BD,EAAOD,KACrB,MAAW,WADFA,EAAEG,GACUd,QAAAC,QAAAC,EAAYL,GAAAA,GAAOM,OAAQT,EAAYY,UAASN,QAAAC,QAE9Cc,EAAc,CACnCH,QAASA,EACTI,QAASnB,EAAMoB,YACfC,UAAWrB,EAAMA,SACjBsB,cAJIC,GAKN,OAAAlB,KACKL,EAAK,CACRM,OAAQiB,EAAW1B,EAAYW,SAAWX,EAAYY,QACtD,EACJ,CAAC,MAAAe,GAAA,OAAArB,QAAAsB,OAAAD,IAxBYE,CAAyB1B,GAMpC,OAAAG,QAAAC,QAAOJ,EACT,CAAC,MAAAwB,GAAA,OAAArB,QAAAsB,OAAAD,EAAA,CAAA,GAtGD,SAAY3B,GACVA,EAAA,QAAA,UACAA,EAAA,OAAA,WACAA,EAAA,QAAA,UACAA,EAAA,SAAA,UACD,CALD,CAAYA,IAAAA,EAKX,CAAA,IAMD,SAAYC,GACVA,EAAA,gBAAA,mBACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,iBAAA,OACAA,EAAA,cAAA,gBACAA,EAAA,WAAA,YACD,CARD,CAAYA,IAAAA,EAQX,CAAA"}
|
package/dist/index.modern.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{
|
1
|
+
import{verifyMessage as e}from"viem";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},n.apply(null,arguments)}var r,t;async function s(s){switch(s.type){case t.SelfDeclaration:return n({},s,{status:s.confirmed?r.VERIFIED:r.FAILED});case t.Screenshot:return n({},s,{status:s.url?r.FLAGGED:r.FAILED});case t.PersonalSignEIP191:return async function(t){const[s,a,i]=t.address.split(/:/);return n({},t,"eip155"!==s?{status:r.FAILED}:{status:await e({address:i,message:t.attestation,signature:t.proof})?r.VERIFIED:r.FAILED})}(s)}return s}!function(e){e.PENDING="pending",e.FAILED="rejected",e.FLAGGED="flagged",e.VERIFIED="verified"}(r||(r={})),function(e){e.SelfDeclaration="self-declaration",e.PersonalSignEIP191="eip-191",e.PersonalSignEIP712="eip-712",e.PersonalSignBIP137="bip-137",e.PersonalSignXPUB="xpub",e.MicroTransfer="microtransfer",e.Screenshot="screenshot"}(t||(t={}));export{r as ProofStatus,t as ProofTypes,s as verifyProof};
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|
package/dist/index.modern.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["import {\n
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.ts"],"sourcesContent":["import { verifyMessage } from \"viem\";\n\nexport type CAIP2 = `${string}:${string}`;\nexport type CAIP10 = `${CAIP2}:${string}`;\nexport type CAIP19 = `${CAIP2}/${string}:${string}`;\nexport type CAIP220 = string;\n\nexport type DTI = string;\nexport type NotabeneAsset = string;\n\n/**\n * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.\n *\n * @public\n */\n\nexport type TransactionAsset = NotabeneAsset | CAIP19 | DTI;\n\nexport type BlockchainAddress = string;\nexport type TravelAddress = string;\n\n/**\n * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.\n * @public\n */\nexport type Destination = BlockchainAddress | CAIP10 | TravelAddress;\nexport type Source = BlockchainAddress | CAIP10;\nexport type URI = string;\nexport type DID = `did:${string}:${string}`;\n\n/**\n * Status of the proof\n * @public\n */\nexport enum ProofStatus {\n PENDING = \"pending\", // Verification is pending\n FAILED = \"rejected\", // Rejected\n FLAGGED = \"flagged\", // Flagged for manual review\n VERIFIED = \"verified\", // Verified\n}\n\n/**\n * The type of Proofs supported\n * @public\n **/\nexport enum ProofTypes {\n SelfDeclaration = \"self-declaration\",\n PersonalSignEIP191 = \"eip-191\",\n PersonalSignEIP712 = \"eip-712\",\n PersonalSignBIP137 = \"bip-137\",\n PersonalSignXPUB = \"xpub\",\n MicroTransfer = \"microtransfer\",\n Screenshot = \"screenshot\",\n}\n/**\n * Ownership Proof\n * @public\n */\nexport interface OwnershipProof {\n type: ProofTypes;\n status: ProofStatus;\n did: DID;\n address: CAIP10;\n}\n\n/**\n * Ownership Proof using Message Signature\n * @public\n */\nexport interface SignatureProof extends OwnershipProof {\n type:\n | ProofTypes.PersonalSignEIP191\n | ProofTypes.PersonalSignEIP712\n | ProofTypes.PersonalSignBIP137\n | ProofTypes.PersonalSignXPUB;\n proof: string;\n attestation: string;\n wallet_provider: string;\n}\n\n/**\n * Ownership Proof using Self Declaration\n * @public\n */\nexport interface DeclarationProof extends OwnershipProof {\n type: ProofTypes.SelfDeclaration;\n attestation: string;\n confirmed: boolean;\n}\n\n/**\n * Ownership Proof using Micro Transfer\n * @public\n */\nexport interface MicroTransferProof extends OwnershipProof {\n type: ProofTypes.MicroTransfer;\n txhash: string;\n chain: CAIP2;\n amount: number;\n}\n\n/**\n * Ownership Proof using Screenshot\n * @public\n */\nexport interface ScreenshotProof extends OwnershipProof {\n type: ProofTypes.Screenshot;\n url: string;\n}\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":["ProofStatus","ProofTypes","verifyProof","proof","type","SelfDeclaration","_extends","status","confirmed","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","async","ns","_","address","split","verifyMessage","message","attestation","signature","verifyPersonalSignEIP191"],"mappings":"6PAkCY,IAAAA,EAWAC,iBAiEUC,EACpBC,GAEA,OAAQA,EAAMC,MACZ,KAAKH,EAAWI,gBACd,OAAAC,KACKH,EAAK,CACRI,OAASJ,EAA2BK,UAChCR,EAAYS,SACZT,EAAYU,SAEpB,KAAKT,EAAWU,WACd,OAAAL,EACKH,CAAAA,EAAAA,EACHI,CAAAA,OAASJ,EAA0BS,IAC/BZ,EAAYa,QACZb,EAAYU,SAEpB,KAAKT,EAAWa,mBACd,OASNC,eACEZ,GAEA,MAAOa,EAAIC,EAAGC,GAAWf,EAAMe,QAAQC,MAAM,KAC7C,OAAqBb,EAAA,CAAA,EAAYH,EAAtB,WAAPa,EAAoCT,CAAAA,OAAQP,EAAYU,QAQlD,CACRH,aAPqBa,EAAc,CACnCF,QAASA,EACTG,QAASlB,EAAMmB,YACfC,UAAWpB,EAAMA,QAIEH,EAAYS,SAAWT,EAAYU,QAE1D,CAxBac,CAAyBrB,GAMpC,OAAOA,CACT,EAtGA,SAAYH,GACVA,EAAA,QAAA,UACAA,EAAA,OAAA,WACAA,EAAA,QAAA,UACAA,EAAA,SAAA,UACD,CALD,CAAYA,IAAAA,EAKX,KAMD,SAAYC,GACVA,EAAA,gBAAA,mBACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,iBAAA,OACAA,EAAA,cAAA,gBACAA,EAAA,WAAA,YACD,CARD,CAAYA,IAAAA,EAQX,CAAA"}
|
package/dist/index.umd.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("viem")):"function"==typeof define&&define.amd?define(["exports","viem"],r):r((e||self).verifyProof={},e.viem)}(this,function(e,r){function o(){return o=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var o=arguments[r];for(var t in o)({}).hasOwnProperty.call(o,t)&&(e[t]=o[t])}return e},o.apply(null,arguments)}var t,s;e.ProofStatus=void 0,(t=e.ProofStatus||(e.ProofStatus={})).PENDING="pending",t.FAILED="rejected",t.FLAGGED="flagged",t.VERIFIED="verified",e.ProofTypes=void 0,(s=e.ProofTypes||(e.ProofTypes={})).SelfDeclaration="self-declaration",s.PersonalSignEIP191="eip-191",s.PersonalSignEIP712="eip-712",s.PersonalSignBIP137="bip-137",s.PersonalSignXPUB="xpub",s.MicroTransfer="microtransfer",s.Screenshot="screenshot",e.verifyProof=function(t){try{switch(t.type){case e.ProofTypes.SelfDeclaration:return Promise.resolve(o({},t,{status:t.confirmed?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED}));case e.ProofTypes.Screenshot:return Promise.resolve(o({},t,{status:t.url?e.ProofStatus.FLAGGED:e.ProofStatus.FAILED}));case e.ProofTypes.PersonalSignEIP191:return function(t){try{var s=t.address.split(/:/),n=s[2];return"eip155"!==s[0]?Promise.resolve(o({},t,{status:e.ProofStatus.FAILED})):Promise.resolve(r.verifyMessage({address:n,message:t.attestation,signature:t.proof})).then(function(r){return o({},t,{status:r?e.ProofStatus.VERIFIED:e.ProofStatus.FAILED})})}catch(e){return Promise.reject(e)}}(t)}return Promise.resolve(t)}catch(e){return Promise.reject(e)}}});
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import {\n
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import { verifyMessage } from \"viem\";\n\nexport type CAIP2 = `${string}:${string}`;\nexport type CAIP10 = `${CAIP2}:${string}`;\nexport type CAIP19 = `${CAIP2}/${string}:${string}`;\nexport type CAIP220 = string;\n\nexport type DTI = string;\nexport type NotabeneAsset = string;\n\n/**\n * The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.\n *\n * @public\n */\n\nexport type TransactionAsset = NotabeneAsset | CAIP19 | DTI;\n\nexport type BlockchainAddress = string;\nexport type TravelAddress = string;\n\n/**\n * The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.\n * @public\n */\nexport type Destination = BlockchainAddress | CAIP10 | TravelAddress;\nexport type Source = BlockchainAddress | CAIP10;\nexport type URI = string;\nexport type DID = `did:${string}:${string}`;\n\n/**\n * Status of the proof\n * @public\n */\nexport enum ProofStatus {\n PENDING = \"pending\", // Verification is pending\n FAILED = \"rejected\", // Rejected\n FLAGGED = \"flagged\", // Flagged for manual review\n VERIFIED = \"verified\", // Verified\n}\n\n/**\n * The type of Proofs supported\n * @public\n **/\nexport enum ProofTypes {\n SelfDeclaration = \"self-declaration\",\n PersonalSignEIP191 = \"eip-191\",\n PersonalSignEIP712 = \"eip-712\",\n PersonalSignBIP137 = \"bip-137\",\n PersonalSignXPUB = \"xpub\",\n MicroTransfer = \"microtransfer\",\n Screenshot = \"screenshot\",\n}\n/**\n * Ownership Proof\n * @public\n */\nexport interface OwnershipProof {\n type: ProofTypes;\n status: ProofStatus;\n did: DID;\n address: CAIP10;\n}\n\n/**\n * Ownership Proof using Message Signature\n * @public\n */\nexport interface SignatureProof extends OwnershipProof {\n type:\n | ProofTypes.PersonalSignEIP191\n | ProofTypes.PersonalSignEIP712\n | ProofTypes.PersonalSignBIP137\n | ProofTypes.PersonalSignXPUB;\n proof: string;\n attestation: string;\n wallet_provider: string;\n}\n\n/**\n * Ownership Proof using Self Declaration\n * @public\n */\nexport interface DeclarationProof extends OwnershipProof {\n type: ProofTypes.SelfDeclaration;\n attestation: string;\n confirmed: boolean;\n}\n\n/**\n * Ownership Proof using Micro Transfer\n * @public\n */\nexport interface MicroTransferProof extends OwnershipProof {\n type: ProofTypes.MicroTransfer;\n txhash: string;\n chain: CAIP2;\n amount: number;\n}\n\n/**\n * Ownership Proof using Screenshot\n * @public\n */\nexport interface ScreenshotProof extends OwnershipProof {\n type: ProofTypes.Screenshot;\n url: string;\n}\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":["ProofStatus","ProofTypes","proof","type","SelfDeclaration","Promise","resolve","_extends","status","confirmed","VERIFIED","FAILED","Screenshot","url","FLAGGED","PersonalSignEIP191","_proof$address$split","address","split","_","verifyMessage","message","attestation","signature","then","verified","e","reject","verifyPersonalSignEIP191"],"mappings":"6dAAqC,IAkCzBA,EAWAC,EAXAD,EAAAA,iBAAAA,GAAAA,EAAAA,EAAWA,cAAXA,cAKX,CAAA,IAJC,QAAA,UACAA,EAAA,OAAA,WACAA,EAAA,QAAA,UACAA,EAAA,SAAA,WAOUC,qBAAAA,EAAAA,EAAAA,aAAAA,EAAUA,WAQrB,CAAA,IAPC,gBAAA,mBACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,mBAAA,UACAA,EAAA,iBAAA,OACAA,EAAA,cAAA,gBACAA,EAAA,WAAA,2BA0DoB,SACpBC,OAEA,OAAQA,EAAMC,MACZ,KAAKF,aAAWG,gBACd,OAAAC,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA2BO,UAChCT,EAAWA,YAACU,SACZV,EAAAA,YAAYW,UAEpB,KAAKV,aAAWW,WACd,OAAAP,QAAAC,QAAAC,EAAA,CAAA,EACKL,EACHM,CAAAA,OAASN,EAA0BW,IAC/Bb,EAAWA,YAACc,QACZd,EAAAA,YAAYW,UAEpB,KAAKV,EAAUA,WAACc,mBACd,OASS,SACbb,GAAqB,IAErB,IAAAc,EAAyBd,EAAMe,QAAQC,MAAM,KAA/BD,EAAOD,KACrB,MAAW,WADFA,EAAEG,GACUd,QAAAC,QAAAC,EAAYL,GAAAA,GAAOM,OAAQR,EAAWA,YAACW,UAASN,QAAAC,QAE9Cc,EAAaA,cAAC,CACnCH,QAASA,EACTI,QAASnB,EAAMoB,YACfC,UAAWrB,EAAMA,SACjBsB,cAJIC,GAKN,OAAAlB,KACKL,EAAK,CACRM,OAAQiB,EAAWzB,EAAAA,YAAYU,SAAWV,cAAYW,QACtD,EACJ,CAAC,MAAAe,GAAA,OAAArB,QAAAsB,OAAAD,IAxBYE,CAAyB1B,GAMpC,OAAAG,QAAAC,QAAOJ,EACT,CAAC,MAAAwB,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.
|
3
|
+
"version": "1.0.0-preview.4",
|
4
4
|
"description": "Verify ownership proofs",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"type": "module",
|
@@ -16,7 +16,7 @@
|
|
16
16
|
],
|
17
17
|
"scripts": {
|
18
18
|
"build:dev": "yarn build && yarn dev",
|
19
|
-
"build:clean": "
|
19
|
+
"build:clean": "rm -rf dist",
|
20
20
|
"build": "microbundle",
|
21
21
|
"lint": "eslint .",
|
22
22
|
"test": "vitest"
|
@@ -28,7 +28,6 @@
|
|
28
28
|
"vitest": "^2.0.5"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
|
-
"@notabene/javascript-sdk": "^2.0.0-next.5",
|
32
31
|
"bitcoinjs-message": "^2.2.0",
|
33
32
|
"viem": "^2.19.8"
|
34
33
|
}
|
package/src/index.ts
CHANGED
@@ -1,13 +1,113 @@
|
|
1
|
-
import {
|
2
|
-
DeclarationProof,
|
3
|
-
ProofStatus,
|
4
|
-
ProofTypes,
|
5
|
-
ScreenshotProof,
|
6
|
-
SignatureProof,
|
7
|
-
type OwnershipProof,
|
8
|
-
} from "@notabene/javascript-sdk/src/types";
|
9
1
|
import { verifyMessage } from "viem";
|
10
2
|
|
3
|
+
export type CAIP2 = `${string}:${string}`;
|
4
|
+
export type CAIP10 = `${CAIP2}:${string}`;
|
5
|
+
export type CAIP19 = `${CAIP2}/${string}:${string}`;
|
6
|
+
export type CAIP220 = string;
|
7
|
+
|
8
|
+
export type DTI = string;
|
9
|
+
export type NotabeneAsset = string;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The asset of a transaction either a Notabene asset, a CAIP-19 asset, or a DTI.
|
13
|
+
*
|
14
|
+
* @public
|
15
|
+
*/
|
16
|
+
|
17
|
+
export type TransactionAsset = NotabeneAsset | CAIP19 | DTI;
|
18
|
+
|
19
|
+
export type BlockchainAddress = string;
|
20
|
+
export type TravelAddress = string;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The destination of a transaction either a blockchain address, a CAIP-19 address, or a travel address.
|
24
|
+
* @public
|
25
|
+
*/
|
26
|
+
export type Destination = BlockchainAddress | CAIP10 | TravelAddress;
|
27
|
+
export type Source = BlockchainAddress | CAIP10;
|
28
|
+
export type URI = string;
|
29
|
+
export type DID = `did:${string}:${string}`;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Status of the proof
|
33
|
+
* @public
|
34
|
+
*/
|
35
|
+
export enum ProofStatus {
|
36
|
+
PENDING = "pending", // Verification is pending
|
37
|
+
FAILED = "rejected", // Rejected
|
38
|
+
FLAGGED = "flagged", // Flagged for manual review
|
39
|
+
VERIFIED = "verified", // Verified
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* The type of Proofs supported
|
44
|
+
* @public
|
45
|
+
**/
|
46
|
+
export enum ProofTypes {
|
47
|
+
SelfDeclaration = "self-declaration",
|
48
|
+
PersonalSignEIP191 = "eip-191",
|
49
|
+
PersonalSignEIP712 = "eip-712",
|
50
|
+
PersonalSignBIP137 = "bip-137",
|
51
|
+
PersonalSignXPUB = "xpub",
|
52
|
+
MicroTransfer = "microtransfer",
|
53
|
+
Screenshot = "screenshot",
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* Ownership Proof
|
57
|
+
* @public
|
58
|
+
*/
|
59
|
+
export interface OwnershipProof {
|
60
|
+
type: ProofTypes;
|
61
|
+
status: ProofStatus;
|
62
|
+
did: DID;
|
63
|
+
address: CAIP10;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Ownership Proof using Message Signature
|
68
|
+
* @public
|
69
|
+
*/
|
70
|
+
export interface SignatureProof extends OwnershipProof {
|
71
|
+
type:
|
72
|
+
| ProofTypes.PersonalSignEIP191
|
73
|
+
| ProofTypes.PersonalSignEIP712
|
74
|
+
| ProofTypes.PersonalSignBIP137
|
75
|
+
| ProofTypes.PersonalSignXPUB;
|
76
|
+
proof: string;
|
77
|
+
attestation: string;
|
78
|
+
wallet_provider: string;
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Ownership Proof using Self Declaration
|
83
|
+
* @public
|
84
|
+
*/
|
85
|
+
export interface DeclarationProof extends OwnershipProof {
|
86
|
+
type: ProofTypes.SelfDeclaration;
|
87
|
+
attestation: string;
|
88
|
+
confirmed: boolean;
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Ownership Proof using Micro Transfer
|
93
|
+
* @public
|
94
|
+
*/
|
95
|
+
export interface MicroTransferProof extends OwnershipProof {
|
96
|
+
type: ProofTypes.MicroTransfer;
|
97
|
+
txhash: string;
|
98
|
+
chain: CAIP2;
|
99
|
+
amount: number;
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Ownership Proof using Screenshot
|
104
|
+
* @public
|
105
|
+
*/
|
106
|
+
export interface ScreenshotProof extends OwnershipProof {
|
107
|
+
type: ProofTypes.Screenshot;
|
108
|
+
url: string;
|
109
|
+
}
|
110
|
+
|
11
111
|
export async function verifyProof(
|
12
112
|
proof: OwnershipProof,
|
13
113
|
): Promise<OwnershipProof> {
|