@kynesyslabs/demosdk 2.11.0 → 2.11.2
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/build/abstraction/Identities.d.ts +102 -9
- package/build/abstraction/Identities.js +254 -0
- package/build/abstraction/Identities.js.map +1 -1
- package/build/abstraction/index.d.ts +2 -2
- package/build/abstraction/index.js.map +1 -1
- package/build/abstraction/types/HumanPassportTypes.d.ts +123 -0
- package/build/abstraction/types/HumanPassportTypes.js +32 -0
- package/build/abstraction/types/HumanPassportTypes.js.map +1 -0
- package/build/identity/humanpassport/HumanPassportClient.d.ts +86 -0
- package/build/identity/humanpassport/HumanPassportClient.js +186 -0
- package/build/identity/humanpassport/HumanPassportClient.js.map +1 -0
- package/build/identity/humanpassport/HumanPassportOnchain.d.ts +107 -0
- package/build/identity/humanpassport/HumanPassportOnchain.js +245 -0
- package/build/identity/humanpassport/HumanPassportOnchain.js.map +1 -0
- package/build/identity/humanpassport/index.d.ts +13 -0
- package/build/identity/humanpassport/index.js +17 -0
- package/build/identity/humanpassport/index.js.map +1 -0
- package/build/types/abstraction/index.d.ts +76 -1
- package/build/types/blockchain/GCREdit.d.ts +5 -3
- package/build/types/blockchain/TransactionSubtypes/TokenTransaction.d.ts +93 -3
- package/build/types/blockchain/TransactionSubtypes/TokenTransaction.js +58 -0
- package/build/types/blockchain/TransactionSubtypes/TokenTransaction.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.js.map +1 -1
- package/build/types/token/TokenTypes.d.ts +47 -0
- package/build/types/token/index.d.ts +1 -1
- package/build/types/token/index.js.map +1 -1
- package/build/websdk/GCRGeneration.js +11 -0
- package/build/websdk/GCRGeneration.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human Passport (formerly Gitcoin Passport) Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Human Passport provides Proof of Personhood through verified "Stamps" -
|
|
5
|
+
* credentials from various web2/web3 providers that prove unique humanity.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Error codes for Human Passport operations
|
|
9
|
+
*/
|
|
10
|
+
export var HumanPassportError;
|
|
11
|
+
(function (HumanPassportError) {
|
|
12
|
+
HumanPassportError["INVALID_ADDRESS"] = "INVALID_ADDRESS";
|
|
13
|
+
HumanPassportError["NO_PASSPORT"] = "NO_PASSPORT";
|
|
14
|
+
HumanPassportError["SCORE_BELOW_THRESHOLD"] = "SCORE_BELOW_THRESHOLD";
|
|
15
|
+
HumanPassportError["API_RATE_LIMITED"] = "API_RATE_LIMITED";
|
|
16
|
+
HumanPassportError["API_UNAVAILABLE"] = "API_UNAVAILABLE";
|
|
17
|
+
HumanPassportError["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
|
|
18
|
+
HumanPassportError["EXPIRED_SCORE"] = "EXPIRED_SCORE";
|
|
19
|
+
HumanPassportError["UNSUPPORTED_CHAIN"] = "UNSUPPORTED_CHAIN";
|
|
20
|
+
})(HumanPassportError || (HumanPassportError = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Custom exception for Human Passport errors
|
|
23
|
+
*/
|
|
24
|
+
export class HumanPassportException extends Error {
|
|
25
|
+
constructor(code, message, details) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.details = details;
|
|
29
|
+
this.name = 'HumanPassportException';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=HumanPassportTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumanPassportTypes.js","sourceRoot":"","sources":["../../../../src/abstraction/types/HumanPassportTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuGH;;GAEG;AACH,MAAM,CAAN,IAAY,kBASX;AATD,WAAY,kBAAkB;IAC1B,yDAAmC,CAAA;IACnC,iDAA2B,CAAA;IAC3B,qEAA+C,CAAA;IAC/C,2DAAqC,CAAA;IACrC,yDAAmC,CAAA;IACnC,6DAAuC,CAAA;IACvC,qDAA+B,CAAA;IAC/B,6DAAuC,CAAA;AAC3C,CAAC,EATW,kBAAkB,KAAlB,kBAAkB,QAS7B;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7C,YACW,IAAwB,EAC/B,OAAe,EACR,OAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJP,SAAI,GAAJ,IAAI,CAAoB;QAExB,YAAO,GAAP,OAAO,CAAU;QAGxB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human Passport API Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods to interact with the Human Passport Stamps API v2
|
|
5
|
+
* for retrieving user scores and stamp data.
|
|
6
|
+
*/
|
|
7
|
+
import { HumanPassportConfig, HumanPassportScore, HumanPassportStamp } from '../../abstraction/types/HumanPassportTypes';
|
|
8
|
+
/**
|
|
9
|
+
* Human Passport API Client
|
|
10
|
+
*
|
|
11
|
+
* Singleton client for interacting with the Human Passport Stamps API.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* // Initialize once
|
|
16
|
+
* const client = HumanPassportClient.initialize({
|
|
17
|
+
* apiKey: 'your-api-key',
|
|
18
|
+
* scorerId: 'your-scorer-id'
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* // Use anywhere
|
|
22
|
+
* const score = await HumanPassportClient.getInstance().getScore('0x...')
|
|
23
|
+
* const isHuman = await HumanPassportClient.getInstance().isHuman('0x...')
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class HumanPassportClient {
|
|
27
|
+
private config;
|
|
28
|
+
private axiosInstance;
|
|
29
|
+
private static instance;
|
|
30
|
+
private constructor();
|
|
31
|
+
/**
|
|
32
|
+
* Initialize the Human Passport client (call once at startup)
|
|
33
|
+
*/
|
|
34
|
+
static initialize(config: HumanPassportConfig): HumanPassportClient;
|
|
35
|
+
/**
|
|
36
|
+
* Get the singleton instance
|
|
37
|
+
* @throws Error if not initialized
|
|
38
|
+
*/
|
|
39
|
+
static getInstance(): HumanPassportClient;
|
|
40
|
+
/**
|
|
41
|
+
* Check if client is initialized
|
|
42
|
+
*/
|
|
43
|
+
static isInitialized(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new instance without singleton (for testing or multiple scorers)
|
|
46
|
+
*/
|
|
47
|
+
static create(config: HumanPassportConfig): HumanPassportClient;
|
|
48
|
+
/**
|
|
49
|
+
* Get user's score and stamp data from Human Passport API
|
|
50
|
+
*
|
|
51
|
+
* @param address - Ethereum address to check
|
|
52
|
+
* @returns Score data including stamps and passing status
|
|
53
|
+
* @throws HumanPassportException on API errors
|
|
54
|
+
*/
|
|
55
|
+
getScore(address: string): Promise<HumanPassportScore>;
|
|
56
|
+
/**
|
|
57
|
+
* Get user's stamps with optional metadata
|
|
58
|
+
*
|
|
59
|
+
* @param address - Ethereum address to check
|
|
60
|
+
* @param includeMetadata - Include stamp metadata (default: true)
|
|
61
|
+
* @returns Array of stamps
|
|
62
|
+
* @throws HumanPassportException on API errors
|
|
63
|
+
*/
|
|
64
|
+
getStamps<T = HumanPassportStamp>(address: string, includeMetadata?: boolean): Promise<T[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Check if address passes humanity threshold
|
|
67
|
+
*
|
|
68
|
+
* @param address - Ethereum address to check
|
|
69
|
+
* @param threshold - Custom threshold (default: uses scorer's threshold)
|
|
70
|
+
* @returns true if address is considered human
|
|
71
|
+
*/
|
|
72
|
+
isHuman(address: string, threshold?: number): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the configured scorer ID
|
|
75
|
+
*/
|
|
76
|
+
getScorerId(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Transform raw API response to typed score object
|
|
79
|
+
*/
|
|
80
|
+
private transformScoreResponse;
|
|
81
|
+
/**
|
|
82
|
+
* Handle API errors and convert to HumanPassportException
|
|
83
|
+
*/
|
|
84
|
+
private handleApiError;
|
|
85
|
+
}
|
|
86
|
+
export default HumanPassportClient;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human Passport API Client
|
|
3
|
+
*
|
|
4
|
+
* Provides methods to interact with the Human Passport Stamps API v2
|
|
5
|
+
* for retrieving user scores and stamp data.
|
|
6
|
+
*/
|
|
7
|
+
import axios from 'axios';
|
|
8
|
+
import { HumanPassportError, HumanPassportException } from '../../abstraction/types/HumanPassportTypes.js';
|
|
9
|
+
/**
|
|
10
|
+
* Human Passport API Client
|
|
11
|
+
*
|
|
12
|
+
* Singleton client for interacting with the Human Passport Stamps API.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Initialize once
|
|
17
|
+
* const client = HumanPassportClient.initialize({
|
|
18
|
+
* apiKey: 'your-api-key',
|
|
19
|
+
* scorerId: 'your-scorer-id'
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* // Use anywhere
|
|
23
|
+
* const score = await HumanPassportClient.getInstance().getScore('0x...')
|
|
24
|
+
* const isHuman = await HumanPassportClient.getInstance().isHuman('0x...')
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class HumanPassportClient {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this.config = {
|
|
30
|
+
apiKey: config.apiKey,
|
|
31
|
+
scorerId: config.scorerId,
|
|
32
|
+
baseUrl: config.baseUrl || 'https://api.passport.xyz'
|
|
33
|
+
};
|
|
34
|
+
this.axiosInstance = axios.create({
|
|
35
|
+
baseURL: this.config.baseUrl,
|
|
36
|
+
timeout: 30000,
|
|
37
|
+
headers: {
|
|
38
|
+
'X-API-KEY': this.config.apiKey,
|
|
39
|
+
'Content-Type': 'application/json'
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initialize the Human Passport client (call once at startup)
|
|
45
|
+
*/
|
|
46
|
+
static initialize(config) {
|
|
47
|
+
HumanPassportClient.instance = new HumanPassportClient(config);
|
|
48
|
+
return HumanPassportClient.instance;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the singleton instance
|
|
52
|
+
* @throws Error if not initialized
|
|
53
|
+
*/
|
|
54
|
+
static getInstance() {
|
|
55
|
+
if (!HumanPassportClient.instance) {
|
|
56
|
+
throw new Error('HumanPassportClient not initialized. Call initialize() first.');
|
|
57
|
+
}
|
|
58
|
+
return HumanPassportClient.instance;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if client is initialized
|
|
62
|
+
*/
|
|
63
|
+
static isInitialized() {
|
|
64
|
+
return HumanPassportClient.instance !== null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a new instance without singleton (for testing or multiple scorers)
|
|
68
|
+
*/
|
|
69
|
+
static create(config) {
|
|
70
|
+
return new HumanPassportClient(config);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get user's score and stamp data from Human Passport API
|
|
74
|
+
*
|
|
75
|
+
* @param address - Ethereum address to check
|
|
76
|
+
* @returns Score data including stamps and passing status
|
|
77
|
+
* @throws HumanPassportException on API errors
|
|
78
|
+
*/
|
|
79
|
+
async getScore(address) {
|
|
80
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {
|
|
81
|
+
throw new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid Ethereum address format: ${address}`);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const response = await this.axiosInstance.get(`/v2/stamps/${this.config.scorerId}/score/${address}`);
|
|
85
|
+
return this.transformScoreResponse(response.data);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw this.handleApiError(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get user's stamps with optional metadata
|
|
93
|
+
*
|
|
94
|
+
* @param address - Ethereum address to check
|
|
95
|
+
* @param includeMetadata - Include stamp metadata (default: true)
|
|
96
|
+
* @returns Array of stamps
|
|
97
|
+
* @throws HumanPassportException on API errors
|
|
98
|
+
*/
|
|
99
|
+
async getStamps(address, includeMetadata = true) {
|
|
100
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {
|
|
101
|
+
throw new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid Ethereum address format: ${address}`);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const response = await this.axiosInstance.get(`/v2/stamps/${address}`, {
|
|
105
|
+
params: { include_metadata: includeMetadata }
|
|
106
|
+
});
|
|
107
|
+
return response.data.items || [];
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
throw this.handleApiError(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Check if address passes humanity threshold
|
|
115
|
+
*
|
|
116
|
+
* @param address - Ethereum address to check
|
|
117
|
+
* @param threshold - Custom threshold (default: uses scorer's threshold)
|
|
118
|
+
* @returns true if address is considered human
|
|
119
|
+
*/
|
|
120
|
+
async isHuman(address, threshold) {
|
|
121
|
+
const score = await this.getScore(address);
|
|
122
|
+
if (threshold !== undefined) {
|
|
123
|
+
return score.score >= threshold;
|
|
124
|
+
}
|
|
125
|
+
return score.passingScore;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the configured scorer ID
|
|
129
|
+
*/
|
|
130
|
+
getScorerId() {
|
|
131
|
+
return this.config.scorerId;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Transform raw API response to typed score object
|
|
135
|
+
*/
|
|
136
|
+
transformScoreResponse(data) {
|
|
137
|
+
return {
|
|
138
|
+
address: data.address,
|
|
139
|
+
score: Number(data.score) || 0,
|
|
140
|
+
passingScore: data.passing_score,
|
|
141
|
+
lastScoreTimestamp: data.last_score_timestamp,
|
|
142
|
+
expirationTimestamp: data.expiration_timestamp,
|
|
143
|
+
threshold: Number(data.threshold) || 20,
|
|
144
|
+
stamps: data.stamps ?? {},
|
|
145
|
+
error: data.error
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Handle API errors and convert to HumanPassportException
|
|
150
|
+
*/
|
|
151
|
+
handleApiError(error) {
|
|
152
|
+
// Type narrowing for axios errors
|
|
153
|
+
if (typeof error === 'object' && error !== null && 'response' in error) {
|
|
154
|
+
const axiosError = error;
|
|
155
|
+
if (axiosError.response) {
|
|
156
|
+
const status = axiosError.response.status;
|
|
157
|
+
const responseData = axiosError.response.data;
|
|
158
|
+
const message = responseData?.detail || axiosError.message || 'Unknown error';
|
|
159
|
+
switch (status) {
|
|
160
|
+
case 400:
|
|
161
|
+
return new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid address: ${message}`, axiosError.response.data);
|
|
162
|
+
case 404:
|
|
163
|
+
return new HumanPassportException(HumanPassportError.NO_PASSPORT, 'User has not created a Human Passport. Direct them to https://app.passport.xyz/', axiosError.response.data);
|
|
164
|
+
case 429:
|
|
165
|
+
return new HumanPassportException(HumanPassportError.API_RATE_LIMITED, 'API rate limit exceeded. Try again later.', axiosError.response.data);
|
|
166
|
+
case 500:
|
|
167
|
+
case 502:
|
|
168
|
+
case 503:
|
|
169
|
+
return new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `Human Passport API unavailable: ${message}`, axiosError.response.data);
|
|
170
|
+
default:
|
|
171
|
+
return new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `API error (${status}): ${message}`, axiosError.response.data);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Check for timeout errors
|
|
175
|
+
if (axiosError.code === 'ECONNABORTED') {
|
|
176
|
+
return new HumanPassportException(HumanPassportError.API_UNAVAILABLE, 'Request timeout - Human Passport API did not respond', { timeout: true });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Fallback for unknown errors
|
|
180
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
181
|
+
return new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `Network error: ${errorMessage}`, { originalError: errorMessage });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
HumanPassportClient.instance = null;
|
|
185
|
+
export default HumanPassportClient;
|
|
186
|
+
//# sourceMappingURL=HumanPassportClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumanPassportClient.js","sourceRoot":"","sources":["../../../../src/identity/humanpassport/HumanPassportClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAwB,MAAM,OAAO,CAAA;AAC5C,OAAO,EAIH,kBAAkB,EAClB,sBAAsB,EACzB,MAAM,wCAAwC,CAAA;AAwB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,mBAAmB;IAK5B,YAAoB,MAA2B;QAC3C,IAAI,CAAC,MAAM,GAAG;YACV,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,0BAA0B;SACxD,CAAA;QAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE,KAAK;YACd,OAAO,EAAE;gBACL,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC/B,cAAc,EAAE,kBAAkB;aACrC;SACJ,CAAC,CAAA;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,MAA2B;QACzC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAC9D,OAAO,mBAAmB,CAAC,QAAQ,CAAA;IACvC,CAAC;IAED;;;OAG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UAAU,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBACrC,OAAO,IAAI,sBAAsB,CAC7B,kBAAkB,CAAC,eAAe,EAClC,sDAAsD,EACtD,EAAE,OAAO,EAAE,IAAI,EAAE,CACpB,CAAA;YACL,CAAC;QACL,CAAC;QAED,8BAA8B;QAC9B,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC3E,OAAO,IAAI,sBAAsB,CAC7B,kBAAkB,CAAC,eAAe,EAClC,kBAAkB,YAAY,EAAE,EAChC,EAAE,aAAa,EAAE,YAAY,EAAE,CAClC,CAAA;IACL,CAAC;;AAtNc,4BAAQ,GAA+B,IAAI,CAAA;AAyN9D,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human Passport Onchain Verifier
|
|
3
|
+
*
|
|
4
|
+
* Provides methods to verify Human Passport scores directly from
|
|
5
|
+
* the blockchain using the GitcoinPassportDecoder contracts.
|
|
6
|
+
*/
|
|
7
|
+
import { ethers } from 'ethers';
|
|
8
|
+
/**
|
|
9
|
+
* Stamp data from onchain passport
|
|
10
|
+
*/
|
|
11
|
+
export interface OnchainStamp {
|
|
12
|
+
provider: string;
|
|
13
|
+
score: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Onchain score result
|
|
17
|
+
*/
|
|
18
|
+
export interface OnchainScoreResult {
|
|
19
|
+
address: string;
|
|
20
|
+
score: number;
|
|
21
|
+
isHuman: boolean;
|
|
22
|
+
chainId: number;
|
|
23
|
+
chainName: string;
|
|
24
|
+
stamps: OnchainStamp[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Human Passport Onchain Verifier
|
|
28
|
+
*
|
|
29
|
+
* Verifies Human Passport scores directly from blockchain using
|
|
30
|
+
* the GitcoinPassportDecoder smart contracts.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Using ethers provider
|
|
35
|
+
* const provider = new ethers.JsonRpcProvider('https://mainnet.base.org')
|
|
36
|
+
* const verifier = new HumanPassportOnchain(provider, 8453) // Base
|
|
37
|
+
*
|
|
38
|
+
* const score = await verifier.getScore('0x...')
|
|
39
|
+
* const isHuman = await verifier.isHuman('0x...')
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare class HumanPassportOnchain {
|
|
43
|
+
private provider;
|
|
44
|
+
private decoder;
|
|
45
|
+
private chainId;
|
|
46
|
+
/**
|
|
47
|
+
* Create onchain verifier instance
|
|
48
|
+
*
|
|
49
|
+
* @param provider - ethers Provider instance
|
|
50
|
+
* @param chainId - Chain ID (must be supported)
|
|
51
|
+
* @throws HumanPassportException if chain not supported
|
|
52
|
+
*/
|
|
53
|
+
constructor(provider: ethers.Provider, chainId: number);
|
|
54
|
+
/**
|
|
55
|
+
* Get list of supported chain IDs
|
|
56
|
+
*/
|
|
57
|
+
static getSupportedChains(): number[];
|
|
58
|
+
/**
|
|
59
|
+
* Check if a chain is supported
|
|
60
|
+
*/
|
|
61
|
+
static isChainSupported(chainId: number): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get chain name by ID
|
|
64
|
+
*/
|
|
65
|
+
static getChainName(chainId: number): string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Get decoder contract address for a chain
|
|
68
|
+
*/
|
|
69
|
+
static getDecoderAddress(chainId: number): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Get user's humanity score from onchain
|
|
72
|
+
*
|
|
73
|
+
* @param address - Ethereum address to check
|
|
74
|
+
* @returns Score (divide by 10000 for actual value)
|
|
75
|
+
*/
|
|
76
|
+
getScore(address: string): Promise<number>;
|
|
77
|
+
/**
|
|
78
|
+
* Check if address is considered human (score >= 20)
|
|
79
|
+
*
|
|
80
|
+
* @param address - Ethereum address to check
|
|
81
|
+
* @returns true if address passes humanity threshold
|
|
82
|
+
*/
|
|
83
|
+
isHuman(address: string): Promise<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Get user's passport stamps from onchain
|
|
86
|
+
*
|
|
87
|
+
* @param address - Ethereum address to check
|
|
88
|
+
* @returns Array of stamps with provider and score
|
|
89
|
+
*/
|
|
90
|
+
getPassport(address: string): Promise<OnchainStamp[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Get complete onchain score result
|
|
93
|
+
*
|
|
94
|
+
* @param address - Ethereum address to check
|
|
95
|
+
* @returns Complete score data including stamps
|
|
96
|
+
*/
|
|
97
|
+
getFullScore(address: string): Promise<OnchainScoreResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Get the chain ID this verifier is configured for
|
|
100
|
+
*/
|
|
101
|
+
getChainId(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Get the decoder contract address
|
|
104
|
+
*/
|
|
105
|
+
getDecoderAddress(): string;
|
|
106
|
+
}
|
|
107
|
+
export default HumanPassportOnchain;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human Passport Onchain Verifier
|
|
3
|
+
*
|
|
4
|
+
* Provides methods to verify Human Passport scores directly from
|
|
5
|
+
* the blockchain using the GitcoinPassportDecoder contracts.
|
|
6
|
+
*/
|
|
7
|
+
import { ethers } from 'ethers';
|
|
8
|
+
import { HumanPassportError, HumanPassportException } from '../../abstraction/types/HumanPassportTypes.js';
|
|
9
|
+
/**
|
|
10
|
+
* Decoder contract addresses on supported chains
|
|
11
|
+
* Source: https://docs.passport.xyz/building-with-passport/smart-contracts/contract-reference
|
|
12
|
+
*/
|
|
13
|
+
const DECODER_ADDRESSES = {
|
|
14
|
+
42161: '0x2050256A91cbABD7C42465aA0d5325115C1dEB43', // Arbitrum One
|
|
15
|
+
8453: '0xaa24a127d10C68C8F9Ac06199AA606953cD82eE7', // Base
|
|
16
|
+
59144: '0x423cd60ab053F1b63D6F78c8c0c63e20F009d669', // Linea
|
|
17
|
+
10: '0x5558D441779Eca04A329BcD6b47830D2C6607769', // Optimism
|
|
18
|
+
534352: '0x8A5820030188346cC9532a1dD9FD2EF8d8F464de', // Scroll
|
|
19
|
+
324: '0x1166FCDCA3B04311Ba9E2eD5ad2c660E730e1386', // ZkSync Era
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Chain names for display
|
|
23
|
+
*/
|
|
24
|
+
const CHAIN_NAMES = {
|
|
25
|
+
42161: 'Arbitrum One',
|
|
26
|
+
8453: 'Base',
|
|
27
|
+
59144: 'Linea',
|
|
28
|
+
10: 'Optimism',
|
|
29
|
+
534352: 'Scroll',
|
|
30
|
+
324: 'ZkSync Era'
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* ABI for GitcoinPassportDecoder contract
|
|
34
|
+
*/
|
|
35
|
+
const DECODER_ABI = [
|
|
36
|
+
'function getScore(address user) view returns (uint256)',
|
|
37
|
+
'function isHuman(address user) view returns (bool)',
|
|
38
|
+
'function getPassport(address user) view returns (tuple(string provider, uint256 score)[])'
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Type guard to check if error is an ethers error with message
|
|
42
|
+
*/
|
|
43
|
+
function isEthersError(error) {
|
|
44
|
+
return (typeof error === 'object' &&
|
|
45
|
+
error !== null &&
|
|
46
|
+
'message' in error &&
|
|
47
|
+
typeof error.message === 'string');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Human Passport Onchain Verifier
|
|
51
|
+
*
|
|
52
|
+
* Verifies Human Passport scores directly from blockchain using
|
|
53
|
+
* the GitcoinPassportDecoder smart contracts.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Using ethers provider
|
|
58
|
+
* const provider = new ethers.JsonRpcProvider('https://mainnet.base.org')
|
|
59
|
+
* const verifier = new HumanPassportOnchain(provider, 8453) // Base
|
|
60
|
+
*
|
|
61
|
+
* const score = await verifier.getScore('0x...')
|
|
62
|
+
* const isHuman = await verifier.isHuman('0x...')
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export class HumanPassportOnchain {
|
|
66
|
+
/**
|
|
67
|
+
* Create onchain verifier instance
|
|
68
|
+
*
|
|
69
|
+
* @param provider - ethers Provider instance
|
|
70
|
+
* @param chainId - Chain ID (must be supported)
|
|
71
|
+
* @throws HumanPassportException if chain not supported
|
|
72
|
+
*/
|
|
73
|
+
constructor(provider, chainId) {
|
|
74
|
+
const decoderAddress = DECODER_ADDRESSES[chainId];
|
|
75
|
+
if (!decoderAddress) {
|
|
76
|
+
throw new HumanPassportException(HumanPassportError.UNSUPPORTED_CHAIN, `Human Passport onchain verification not supported on chain ${chainId}. ` +
|
|
77
|
+
`Supported chains: ${Object.keys(DECODER_ADDRESSES).join(', ')}`, { chainId, supportedChains: Object.keys(DECODER_ADDRESSES).map(Number) });
|
|
78
|
+
}
|
|
79
|
+
this.provider = provider;
|
|
80
|
+
this.chainId = chainId;
|
|
81
|
+
this.decoder = new ethers.Contract(decoderAddress, DECODER_ABI, provider);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get list of supported chain IDs
|
|
85
|
+
*/
|
|
86
|
+
static getSupportedChains() {
|
|
87
|
+
return Object.keys(DECODER_ADDRESSES).map(Number);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a chain is supported
|
|
91
|
+
*/
|
|
92
|
+
static isChainSupported(chainId) {
|
|
93
|
+
return chainId in DECODER_ADDRESSES;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get chain name by ID
|
|
97
|
+
*/
|
|
98
|
+
static getChainName(chainId) {
|
|
99
|
+
return CHAIN_NAMES[chainId];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get decoder contract address for a chain
|
|
103
|
+
*/
|
|
104
|
+
static getDecoderAddress(chainId) {
|
|
105
|
+
return DECODER_ADDRESSES[chainId];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get user's humanity score from onchain
|
|
109
|
+
*
|
|
110
|
+
* @param address - Ethereum address to check
|
|
111
|
+
* @returns Score (divide by 10000 for actual value)
|
|
112
|
+
*/
|
|
113
|
+
async getScore(address) {
|
|
114
|
+
if (!ethers.isAddress(address)) {
|
|
115
|
+
throw new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid Ethereum address format: ${address}`, { address, chainId: this.chainId });
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const rawScore = await this.decoder.getScore(address);
|
|
119
|
+
// Score is returned as uint256, divide by 10000 per docs
|
|
120
|
+
return Number(rawScore) / 10000;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (isEthersError(error)) {
|
|
124
|
+
if (error.reason?.includes('revert') || error.message.includes('revert')) {
|
|
125
|
+
throw new HumanPassportException(HumanPassportError.NO_PASSPORT, 'No passport score found onchain for this address', { address, chainId: this.chainId });
|
|
126
|
+
}
|
|
127
|
+
throw new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `Onchain verification failed: ${error.message}`, { address, chainId: this.chainId, originalError: error.message });
|
|
128
|
+
}
|
|
129
|
+
throw new HumanPassportException(HumanPassportError.API_UNAVAILABLE, 'Onchain verification failed with unknown error', { address, chainId: this.chainId });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Check if address is considered human (score >= 20)
|
|
134
|
+
*
|
|
135
|
+
* @param address - Ethereum address to check
|
|
136
|
+
* @returns true if address passes humanity threshold
|
|
137
|
+
*/
|
|
138
|
+
async isHuman(address) {
|
|
139
|
+
if (!ethers.isAddress(address)) {
|
|
140
|
+
throw new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid Ethereum address format: ${address}`, { address, chainId: this.chainId });
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
return await this.decoder.isHuman(address);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (isEthersError(error)) {
|
|
147
|
+
if (error.reason?.includes('revert') || error.message.includes('revert')) {
|
|
148
|
+
return false; // No passport = not human
|
|
149
|
+
}
|
|
150
|
+
throw new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `Onchain verification failed: ${error.message}`, { address, chainId: this.chainId, originalError: error.message });
|
|
151
|
+
}
|
|
152
|
+
return false; // Unknown error = treat as not human
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get user's passport stamps from onchain
|
|
157
|
+
*
|
|
158
|
+
* @param address - Ethereum address to check
|
|
159
|
+
* @returns Array of stamps with provider and score
|
|
160
|
+
*/
|
|
161
|
+
async getPassport(address) {
|
|
162
|
+
if (!ethers.isAddress(address)) {
|
|
163
|
+
throw new HumanPassportException(HumanPassportError.INVALID_ADDRESS, `Invalid Ethereum address format: ${address}`, { address, chainId: this.chainId });
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const stamps = await this.decoder.getPassport(address);
|
|
167
|
+
return stamps.map((s) => {
|
|
168
|
+
// Handle both object and tuple formats
|
|
169
|
+
if (Array.isArray(s)) {
|
|
170
|
+
return {
|
|
171
|
+
provider: s[0],
|
|
172
|
+
score: Number(s[1])
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
provider: s.provider,
|
|
177
|
+
score: Number(s.score)
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (isEthersError(error)) {
|
|
183
|
+
if (error.reason?.includes('revert') || error.message.includes('revert')) {
|
|
184
|
+
return []; // No passport = no stamps
|
|
185
|
+
}
|
|
186
|
+
throw new HumanPassportException(HumanPassportError.API_UNAVAILABLE, `Failed to get onchain passport: ${error.message}`, { address, chainId: this.chainId, originalError: error.message });
|
|
187
|
+
}
|
|
188
|
+
return []; // Unknown error = no stamps
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get complete onchain score result
|
|
193
|
+
*
|
|
194
|
+
* @param address - Ethereum address to check
|
|
195
|
+
* @returns Complete score data including stamps
|
|
196
|
+
*/
|
|
197
|
+
async getFullScore(address) {
|
|
198
|
+
const [scoreResult, isHumanResult, stampsResult] = await Promise.allSettled([
|
|
199
|
+
this.getScore(address),
|
|
200
|
+
this.isHuman(address),
|
|
201
|
+
this.getPassport(address)
|
|
202
|
+
]);
|
|
203
|
+
// Handle NO_PASSPORT error from getScore - return 0 instead of rejecting
|
|
204
|
+
let score = 0;
|
|
205
|
+
if (scoreResult.status === 'fulfilled') {
|
|
206
|
+
score = scoreResult.value;
|
|
207
|
+
}
|
|
208
|
+
else if (scoreResult.reason instanceof HumanPassportException) {
|
|
209
|
+
if (scoreResult.reason.code === HumanPassportError.NO_PASSPORT) {
|
|
210
|
+
score = 0; // No passport = score 0
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
throw scoreResult.reason; // Re-throw other errors
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
throw scoreResult.reason; // Re-throw non-HumanPassportException errors
|
|
218
|
+
}
|
|
219
|
+
// isHuman and getPassport already handle NO_PASSPORT gracefully (return false/[])
|
|
220
|
+
const isHuman = isHumanResult.status === 'fulfilled' ? isHumanResult.value : false;
|
|
221
|
+
const stamps = stampsResult.status === 'fulfilled' ? stampsResult.value : [];
|
|
222
|
+
return {
|
|
223
|
+
address: address.toLowerCase(),
|
|
224
|
+
score,
|
|
225
|
+
isHuman,
|
|
226
|
+
chainId: this.chainId,
|
|
227
|
+
chainName: CHAIN_NAMES[this.chainId] || `Chain ${this.chainId}`,
|
|
228
|
+
stamps
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the chain ID this verifier is configured for
|
|
233
|
+
*/
|
|
234
|
+
getChainId() {
|
|
235
|
+
return this.chainId;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get the decoder contract address
|
|
239
|
+
*/
|
|
240
|
+
getDecoderAddress() {
|
|
241
|
+
return DECODER_ADDRESSES[this.chainId];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export default HumanPassportOnchain;
|
|
245
|
+
//# sourceMappingURL=HumanPassportOnchain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumanPassportOnchain.js","sourceRoot":"","sources":["../../../../src/identity/humanpassport/HumanPassportOnchain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EACH,kBAAkB,EAClB,sBAAsB,EACzB,MAAM,wCAAwC,CAAA;AAE/C;;;GAGG;AACH,MAAM,iBAAiB,GAA2B;IAC9C,KAAK,EAAE,4CAA4C,EAAG,eAAe;IACrE,IAAI,EAAE,4CAA4C,EAAI,OAAO;IAC7D,KAAK,EAAE,4CAA4C,EAAG,QAAQ;IAC9D,EAAE,EAAE,4CAA4C,EAAM,WAAW;IACjE,MAAM,EAAE,4CAA4C,EAAE,SAAS;IAC/D,GAAG,EAAE,4CAA4C,EAAK,aAAa;CACtE,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,GAA2B;IACxC,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,UAAU;IACd,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,YAAY;CACpB,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,GAAG;IAChB,wDAAwD;IACxD,oDAAoD;IACpD,2FAA2F;CAC9F,CAAA;AAUD;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACjC,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAQ,KAA8B,CAAC,OAAO,KAAK,QAAQ,CAC9D,CAAA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