@passly/passly-sdk 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/index.js +68 -6
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passly/passly-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "Official SDK for Passly identity protocol - social identity verification for Web3",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"ethers": "^5.7.2"
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
"keywords": [
|
|
11
11
|
"web3",
|
|
12
12
|
"identity",
|
|
13
13
|
"verification",
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"oauth",
|
|
21
21
|
"passport"
|
|
22
22
|
],
|
|
23
|
-
|
|
23
|
+
"author": {
|
|
24
24
|
"name": "0xRetroDev",
|
|
25
25
|
"email": "hello@0xRetro.dev",
|
|
26
26
|
"url": "https://github.com/0xRetroDev"
|
|
27
27
|
},
|
|
28
|
-
|
|
28
|
+
"homepage": "https://passly.xyz",
|
|
29
29
|
"license": "MIT",
|
|
30
|
-
|
|
30
|
+
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// index.js (or passly-sdk.js)
|
|
2
1
|
import { ethers } from 'ethers';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -49,11 +48,11 @@ class PasslySDK {
|
|
|
49
48
|
|
|
50
49
|
// Default contract addresses
|
|
51
50
|
const addresses = {
|
|
52
|
-
passly: config.contractAddress || '
|
|
53
|
-
platforms: config.platformsAddress || '
|
|
54
|
-
archives: config.archivesAddress || '
|
|
55
|
-
rewards: config.rewardsAddress || '
|
|
56
|
-
leaderboard: config.leaderboardAddress ||
|
|
51
|
+
passly: config.contractAddress || '0x8EEFC0840Bc24e269A2F77B787E9b3e212c4F316',
|
|
52
|
+
platforms: config.platformsAddress || '0xd2FEEa5775c171D85648198AeB77377fD9AdFe98',
|
|
53
|
+
archives: config.archivesAddress || '0xbC57EA3ff9BDE13087b907Dc02e86f08C57574E7',
|
|
54
|
+
rewards: config.rewardsAddress || '0xEc34ad267a9AACE045Ef4644047BCFeB0f53b0C0',
|
|
55
|
+
leaderboard: config.leaderboardAddress || '0x7f9c4841346d0ef7970daF02aE3663f8AC5bE540'
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
// Contract ABIs
|
|
@@ -332,6 +331,31 @@ class PasslySDK {
|
|
|
332
331
|
};
|
|
333
332
|
}
|
|
334
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Get a user's identifier on a specific platform
|
|
336
|
+
* @param {string} address - The wallet address
|
|
337
|
+
* @param {string} platform - The platform name (e.g., "twitter")
|
|
338
|
+
* @returns {Promise<string|null>} - The platform identifier (username/handle) or null if not verified
|
|
339
|
+
*/
|
|
340
|
+
async getPlatformIdentifier(address, platform) {
|
|
341
|
+
this._ensureConnected();
|
|
342
|
+
|
|
343
|
+
try {
|
|
344
|
+
const passportId = await this.getPassportId(address);
|
|
345
|
+
if (!passportId) return null;
|
|
346
|
+
|
|
347
|
+
const [identifier, , , active] = await this.contracts.passly.getVerification(
|
|
348
|
+
passportId,
|
|
349
|
+
platform.toLowerCase()
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
// Only return identifier if verification is active
|
|
353
|
+
return active ? identifier : null;
|
|
354
|
+
} catch (error) {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
335
359
|
// =============================================================================
|
|
336
360
|
// REWARDS & POINTS FUNCTIONS
|
|
337
361
|
// =============================================================================
|
|
@@ -1020,6 +1044,44 @@ class PasslySDK {
|
|
|
1020
1044
|
|
|
1021
1045
|
return verification.proofHash;
|
|
1022
1046
|
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Get all proof hashes for all verified platforms for a user
|
|
1050
|
+
* @param {string} address - The wallet address
|
|
1051
|
+
* @returns {Promise<{[platform: string]: string}|null>} - Object mapping platforms to proof hashes, or null if no passport
|
|
1052
|
+
*/
|
|
1053
|
+
async getAllProofHashes(address) {
|
|
1054
|
+
this._ensureConnected();
|
|
1055
|
+
|
|
1056
|
+
try {
|
|
1057
|
+
const passportId = await this.getPassportId(address);
|
|
1058
|
+
if (!passportId) return null;
|
|
1059
|
+
|
|
1060
|
+
const platforms = await this.contracts.passly.getVerifiedPlatforms(passportId);
|
|
1061
|
+
const proofHashes = {};
|
|
1062
|
+
|
|
1063
|
+
for (const platform of platforms) {
|
|
1064
|
+
try {
|
|
1065
|
+
const [, , proofHash, active] = await this.contracts.passly.getVerification(
|
|
1066
|
+
passportId,
|
|
1067
|
+
platform
|
|
1068
|
+
);
|
|
1069
|
+
|
|
1070
|
+
// Only include active verifications
|
|
1071
|
+
if (active) {
|
|
1072
|
+
proofHashes[platform] = proofHash;
|
|
1073
|
+
}
|
|
1074
|
+
} catch (error) {
|
|
1075
|
+
// Skip platforms that fail to load
|
|
1076
|
+
console.warn(`Failed to load proof hash for platform ${platform}:`, error.message);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
return Object.keys(proofHashes).length > 0 ? proofHashes : null;
|
|
1081
|
+
} catch (error) {
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1023
1085
|
}
|
|
1024
1086
|
|
|
1025
1087
|
export default PasslySDK;
|