noah-avalanche-sdk 0.1.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/README.md +892 -0
- package/dist/core/APIClient.d.ts +71 -0
- package/dist/core/APIClient.d.ts.map +1 -0
- package/dist/core/APIClient.js +92 -0
- package/dist/core/APIClient.js.map +1 -0
- package/dist/core/ContractClient.d.ts +38 -0
- package/dist/core/ContractClient.d.ts.map +1 -0
- package/dist/core/ContractClient.js +209 -0
- package/dist/core/ContractClient.js.map +1 -0
- package/dist/core/NoahSDK.d.ts +43 -0
- package/dist/core/NoahSDK.d.ts.map +1 -0
- package/dist/core/NoahSDK.js +93 -0
- package/dist/core/NoahSDK.js.map +1 -0
- package/dist/core/WalletAdapter.d.ts +188 -0
- package/dist/core/WalletAdapter.d.ts.map +1 -0
- package/dist/core/WalletAdapter.js +425 -0
- package/dist/core/WalletAdapter.js.map +1 -0
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +15 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useCredentials.d.ts +136 -0
- package/dist/hooks/useCredentials.d.ts.map +1 -0
- package/dist/hooks/useCredentials.js +217 -0
- package/dist/hooks/useCredentials.js.map +1 -0
- package/dist/hooks/useProtocol.d.ts +117 -0
- package/dist/hooks/useProtocol.d.ts.map +1 -0
- package/dist/hooks/useProtocol.js +165 -0
- package/dist/hooks/useProtocol.js.map +1 -0
- package/dist/hooks/useUser.d.ts +159 -0
- package/dist/hooks/useUser.d.ts.map +1 -0
- package/dist/hooks/useUser.js +188 -0
- package/dist/hooks/useUser.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/issuer/IssuerClient.d.ts +98 -0
- package/dist/issuer/IssuerClient.d.ts.map +1 -0
- package/dist/issuer/IssuerClient.js +159 -0
- package/dist/issuer/IssuerClient.js.map +1 -0
- package/dist/protocol/ProtocolClient.d.ts +124 -0
- package/dist/protocol/ProtocolClient.d.ts.map +1 -0
- package/dist/protocol/ProtocolClient.js +265 -0
- package/dist/protocol/ProtocolClient.js.map +1 -0
- package/dist/protocol/RequirementsManager.d.ts +9 -0
- package/dist/protocol/RequirementsManager.d.ts.map +1 -0
- package/dist/protocol/RequirementsManager.js +9 -0
- package/dist/protocol/RequirementsManager.js.map +1 -0
- package/dist/user/ProofGenerator.d.ts +49 -0
- package/dist/user/ProofGenerator.d.ts.map +1 -0
- package/dist/user/ProofGenerator.js +80 -0
- package/dist/user/ProofGenerator.js.map +1 -0
- package/dist/user/UserClient.d.ts +191 -0
- package/dist/user/UserClient.d.ts.map +1 -0
- package/dist/user/UserClient.js +338 -0
- package/dist/user/UserClient.js.map +1 -0
- package/dist/utils/credentials.d.ts +47 -0
- package/dist/utils/credentials.d.ts.map +1 -0
- package/dist/utils/credentials.js +99 -0
- package/dist/utils/credentials.js.map +1 -0
- package/dist/utils/identity.d.ts +22 -0
- package/dist/utils/identity.d.ts.map +1 -0
- package/dist/utils/identity.js +35 -0
- package/dist/utils/identity.js.map +1 -0
- package/dist/utils/jurisdiction.d.ts +21 -0
- package/dist/utils/jurisdiction.d.ts.map +1 -0
- package/dist/utils/jurisdiction.js +64 -0
- package/dist/utils/jurisdiction.js.map +1 -0
- package/dist/utils/mrz.d.ts +16 -0
- package/dist/utils/mrz.d.ts.map +1 -0
- package/dist/utils/mrz.js +91 -0
- package/dist/utils/mrz.js.map +1 -0
- package/dist/utils/ocr.d.ts +31 -0
- package/dist/utils/ocr.d.ts.map +1 -0
- package/dist/utils/ocr.js +69 -0
- package/dist/utils/ocr.js.map +1 -0
- package/dist/utils/types.d.ts +122 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +53 -0
- package/src/core/APIClient.ts +165 -0
- package/src/core/ContractClient.ts +266 -0
- package/src/core/NoahSDK.ts +123 -0
- package/src/core/WalletAdapter.ts +546 -0
- package/src/hooks/index.ts +31 -0
- package/src/hooks/types.d.ts +18 -0
- package/src/hooks/useCredentials.ts +359 -0
- package/src/hooks/useProtocol.ts +284 -0
- package/src/hooks/useUser.ts +331 -0
- package/src/index.ts +80 -0
- package/src/issuer/IssuerClient.ts +209 -0
- package/src/protocol/ProtocolClient.ts +330 -0
- package/src/protocol/RequirementsManager.ts +16 -0
- package/src/user/ProofGenerator.ts +113 -0
- package/src/user/UserClient.ts +440 -0
- package/src/utils/credentials.ts +122 -0
- package/src/utils/identity.ts +46 -0
- package/src/utils/jurisdiction.ts +83 -0
- package/src/utils/mrz.ts +113 -0
- package/src/utils/ocr.ts +84 -0
- package/src/utils/types.ts +144 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Proof, Requirements, TransactionResult } from '../utils/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* APIClient configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface APIClientConfig {
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
authToken?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Proof generation data
|
|
12
|
+
*/
|
|
13
|
+
export interface ProofGenerationData {
|
|
14
|
+
credential: {
|
|
15
|
+
age: number;
|
|
16
|
+
jurisdiction: string | number;
|
|
17
|
+
accredited: number;
|
|
18
|
+
credentialHash: string;
|
|
19
|
+
userAddress?: string;
|
|
20
|
+
};
|
|
21
|
+
requirements: Requirements;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Proof generation result
|
|
25
|
+
*/
|
|
26
|
+
export interface ProofGenerationResult {
|
|
27
|
+
proof: Proof;
|
|
28
|
+
publicSignals: string[];
|
|
29
|
+
credentialHash: string;
|
|
30
|
+
success: boolean;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Access status information
|
|
35
|
+
*/
|
|
36
|
+
export interface AccessStatus {
|
|
37
|
+
hasAccess: boolean;
|
|
38
|
+
protocolAddress: string;
|
|
39
|
+
userAddress: string;
|
|
40
|
+
credentialHash?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Credential status information
|
|
44
|
+
*/
|
|
45
|
+
export interface CredentialStatus {
|
|
46
|
+
isValid: boolean;
|
|
47
|
+
credentialHash: string;
|
|
48
|
+
isRevoked: boolean;
|
|
49
|
+
issuer?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* APIClient - Handles backend API interactions
|
|
53
|
+
*/
|
|
54
|
+
export declare class APIClient {
|
|
55
|
+
private client;
|
|
56
|
+
private authToken;
|
|
57
|
+
constructor(config?: APIClientConfig);
|
|
58
|
+
setAuthToken(token: string): void;
|
|
59
|
+
generateProof(proofData: ProofGenerationData): Promise<ProofGenerationResult>;
|
|
60
|
+
generateAgeProof(data: {
|
|
61
|
+
mrzData: any;
|
|
62
|
+
minAge: number;
|
|
63
|
+
recipientAddress: string;
|
|
64
|
+
}): Promise<ProofGenerationResult>;
|
|
65
|
+
getProtocolRequirements(protocolAddress: string): Promise<Requirements>;
|
|
66
|
+
checkAccess(protocolAddress: string, userAddress: string): Promise<AccessStatus>;
|
|
67
|
+
registerCredential(credentialHash: string, userAddress: string): Promise<TransactionResult>;
|
|
68
|
+
revokeCredential(credentialHash: string): Promise<TransactionResult>;
|
|
69
|
+
checkCredential(credentialHash: string): Promise<CredentialStatus>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=APIClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIClient.d.ts","sourceRoot":"","sources":["../../src/core/APIClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC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,EAAE,MAAM,CAAC;QACf,gBAAgB,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAiB5B,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAUvE,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAUhF,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAK3F,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKpE,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CASzE"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* APIClient - Handles backend API interactions
|
|
4
|
+
*/
|
|
5
|
+
export class APIClient {
|
|
6
|
+
constructor(config = {}) {
|
|
7
|
+
this.authToken = null;
|
|
8
|
+
this.client = axios.create({
|
|
9
|
+
baseURL: config.baseURL || 'http://localhost:3000/api/v1',
|
|
10
|
+
headers: {
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
},
|
|
13
|
+
timeout: config.timeout || 30000,
|
|
14
|
+
});
|
|
15
|
+
if (config.authToken) {
|
|
16
|
+
this.setAuthToken(config.authToken);
|
|
17
|
+
}
|
|
18
|
+
this.client.interceptors.response.use((response) => response.data, (error) => {
|
|
19
|
+
const errorMessage = error.response?.data?.error?.message || error.message || 'An error occurred';
|
|
20
|
+
return Promise.reject(new Error(errorMessage));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
setAuthToken(token) {
|
|
24
|
+
this.authToken = token;
|
|
25
|
+
}
|
|
26
|
+
async generateProof(proofData) {
|
|
27
|
+
try {
|
|
28
|
+
const response = await this.client.post('/proof/generate', proofData);
|
|
29
|
+
return {
|
|
30
|
+
proof: response.proof,
|
|
31
|
+
publicSignals: response.publicSignals || response.publicInputs || [],
|
|
32
|
+
credentialHash: response.credentialHash || proofData.credential.credentialHash,
|
|
33
|
+
success: response.success !== false,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new Error(`Failed to generate proof: ${error}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async generateAgeProof(data) {
|
|
41
|
+
return this.generateProof({
|
|
42
|
+
credential: {
|
|
43
|
+
age: 0,
|
|
44
|
+
jurisdiction: "",
|
|
45
|
+
accredited: 0,
|
|
46
|
+
credentialHash: "",
|
|
47
|
+
userAddress: data.recipientAddress
|
|
48
|
+
},
|
|
49
|
+
requirements: {
|
|
50
|
+
minAge: data.minAge,
|
|
51
|
+
allowedJurisdictions: [],
|
|
52
|
+
requireAccredited: false
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async getProtocolRequirements(protocolAddress) {
|
|
57
|
+
const response = await this.client.get(`/user/protocol/${protocolAddress}/requirements`);
|
|
58
|
+
return {
|
|
59
|
+
minAge: Number(response.minAge),
|
|
60
|
+
allowedJurisdictions: response.allowedJurisdictions || [],
|
|
61
|
+
requireAccredited: response.requireAccredited || false,
|
|
62
|
+
isSet: response.isSet !== false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
async checkAccess(protocolAddress, userAddress) {
|
|
66
|
+
const response = await this.client.get(`/user/access/${protocolAddress}/${userAddress}`);
|
|
67
|
+
return {
|
|
68
|
+
hasAccess: response.hasAccess || false,
|
|
69
|
+
protocolAddress,
|
|
70
|
+
userAddress,
|
|
71
|
+
credentialHash: response.credentialHash,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async registerCredential(credentialHash, userAddress) {
|
|
75
|
+
const response = await this.client.post('/issuer/credential/register', { credentialHash, userAddress });
|
|
76
|
+
return { transactionHash: response.transactionHash, receipt: response.receipt || null };
|
|
77
|
+
}
|
|
78
|
+
async revokeCredential(credentialHash) {
|
|
79
|
+
const response = await this.client.post('/issuer/credential/revoke', { credentialHash });
|
|
80
|
+
return { transactionHash: response.transactionHash, receipt: response.receipt || null };
|
|
81
|
+
}
|
|
82
|
+
async checkCredential(credentialHash) {
|
|
83
|
+
const response = await this.client.get(`/issuer/credential/check/${credentialHash}`);
|
|
84
|
+
return {
|
|
85
|
+
isValid: response.isValid || false,
|
|
86
|
+
credentialHash,
|
|
87
|
+
isRevoked: response.isRevoked || false,
|
|
88
|
+
issuer: response.issuer,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=APIClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIClient.js","sourceRoot":"","sources":["../../src/core/APIClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAyDlD;;GAEG;AACH,MAAM,OAAO,SAAS;IAIpB,YAAY,SAA0B,EAAE;QAFhC,cAAS,GAAkB,IAAI,CAAC;QAGtC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,8BAA8B;YACzD,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;SACjC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CACnC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAW,EAClC,CAAC,KAAK,EAAE,EAAE;YACR,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KA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AAe,CAAC,cAAsB;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,cAAc,EAAE,CAAQ,CAAC;QAC5F,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,KAAK;YAClC,cAAc;YACd,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,KAAK;YACtC,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Provider, type Signer } from 'ethers';
|
|
2
|
+
import type { Requirements, Proof, ZKProof, TransactionResult, ContractClientConfig } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Contract Client Service
|
|
5
|
+
* Handles direct smart contract interactions for read and write operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class ContractClient {
|
|
8
|
+
private provider;
|
|
9
|
+
private credentialRegistry;
|
|
10
|
+
private protocolAccessControl;
|
|
11
|
+
private contractAddresses;
|
|
12
|
+
private rpcUrl;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new ContractClient instance
|
|
15
|
+
* @param config - Configuration options including provider, contract addresses, and RPC URL
|
|
16
|
+
*/
|
|
17
|
+
constructor(config?: ContractClientConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Initialize provider and contracts with robust support for various provider types
|
|
20
|
+
* @param inputProvider - EIP-1193 provider (window.ethereum), Ethers Provider, or custom
|
|
21
|
+
*/
|
|
22
|
+
initialize(inputProvider?: any): void;
|
|
23
|
+
/**
|
|
24
|
+
* Pre-flight validation for proof inputs
|
|
25
|
+
*/
|
|
26
|
+
validateProofInput(publicSignals: (string | number)[]): void;
|
|
27
|
+
isCredentialValid(credentialHash: string): Promise<boolean>;
|
|
28
|
+
isNullifierUsed(nullifier: string): Promise<boolean>;
|
|
29
|
+
getCredentialByUser(userAddress: string): Promise<string>;
|
|
30
|
+
hasAccess(protocolAddress: string, userAddress: string): Promise<boolean>;
|
|
31
|
+
getRequirements(protocolAddress: string): Promise<Requirements>;
|
|
32
|
+
getUserCredential(protocolAddress: string, userAddress: string): Promise<string>;
|
|
33
|
+
registerCredential(signer: Signer, credentialHash: string, userAddress: string): Promise<TransactionResult>;
|
|
34
|
+
revokeCredential(signer: Signer, credentialHash: string): Promise<TransactionResult>;
|
|
35
|
+
verifyAndGrantAccess(signer: Signer, proof: Proof | ZKProof, publicSignals: (string | number)[], credentialHash: string, userAddress: string): Promise<TransactionResult>;
|
|
36
|
+
getProvider(): Provider | null;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ContractClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractClient.d.ts","sourceRoot":"","sources":["../../src/core/ContractClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,MAAM,EAIZ,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAEV,YAAY,EAEZ,KAAK,EACL,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EAErB,MAAM,mBAAmB,CAAC;AAmC3B;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,MAAM,CAAS;IAEvB;;;OAGG;gBACS,MAAM,CAAC,EAAE,oBAAoB;IAczC;;;OAGG;IACH,UAAU,CAAC,aAAa,CAAC,EAAE,GAAG,GAAG,IAAI;IAuBrC;;OAEG;IACH,kBAAkB,CAAC,aAAa,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI;IAUtD,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3D,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAUpD,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASzD,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASzE,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAiB/D,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAShF,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC;IAYvB,gBAAgB,CACpB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,iBAAiB,CAAC;IAYvB,oBAAoB,CACxB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,OAAO,EACtB,aAAa,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAClC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC;IAyC7B,WAAW,IAAI,QAAQ,GAAG,IAAI;CAC/B"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ethers, BrowserProvider, JsonRpcProvider } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Contract ABIs (synchronized with production contracts)
|
|
4
|
+
*/
|
|
5
|
+
const CREDENTIAL_REGISTRY_ABI = [
|
|
6
|
+
'function isCredentialValid(bytes32 credentialHash) view returns (bool)',
|
|
7
|
+
'function credentials(bytes32) view returns (bool)',
|
|
8
|
+
'function revokedCredentials(bytes32) view returns (bool)',
|
|
9
|
+
'function trustedIssuers(address) view returns (bool)',
|
|
10
|
+
'function issuerNames(address) view returns (string)',
|
|
11
|
+
'function credentialIssuers(bytes32) view returns (address)',
|
|
12
|
+
'function nullifierOwners(bytes32) view returns (address)',
|
|
13
|
+
'function userToCredential(address) view returns (bytes32)',
|
|
14
|
+
'function registerCredential(bytes32 credentialHash, address user)',
|
|
15
|
+
'function registerNullifier(bytes32 nullifier, bytes32 credentialHash, address user)',
|
|
16
|
+
'function revokeCredential(bytes32 credentialHash)',
|
|
17
|
+
'function hasRole(bytes32 role, address account) view returns (bool)',
|
|
18
|
+
'event CredentialIssued(address indexed user, bytes32 indexed credentialHash, address indexed issuer, uint256 timestamp)',
|
|
19
|
+
'event CredentialRevoked(bytes32 indexed credentialHash, address indexed issuer, uint256 timestamp)',
|
|
20
|
+
'event NullifierRegistered(bytes32 indexed nullifier, bytes32 indexed credentialHash, address indexed user)',
|
|
21
|
+
];
|
|
22
|
+
const PROTOCOL_ACCESS_CONTROL_ABI = [
|
|
23
|
+
'function hasAccess(address protocol, address user) view returns (bool)',
|
|
24
|
+
'function checkAccess(address user) view returns (bool)',
|
|
25
|
+
'function protocolRequirements(address) view returns (uint256 minAge, bool requireAccredited, bool isSet)',
|
|
26
|
+
'function userCredentials(address protocol, address user) view returns (bytes32)',
|
|
27
|
+
'function setRequirements(uint256 minAge, uint256[] memory allowedJurisdictions, bool requireAccredited)',
|
|
28
|
+
'function verifyAndGrantAccess(uint[2] a, uint[2][2] b, uint[2] c, uint[28] publicSignals, bytes32 credentialHash, address user)',
|
|
29
|
+
'event AccessGranted(address indexed user, address indexed protocol, bytes32 indexed credentialHash, uint256 timestamp)',
|
|
30
|
+
'event AccessRevoked(address indexed user, address indexed protocol, uint256 timestamp)',
|
|
31
|
+
'event RequirementsSet(address indexed protocol, uint256 minAge, uint256[] allowedJurisdictions, bool requireAccredited)',
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Contract Client Service
|
|
35
|
+
* Handles direct smart contract interactions for read and write operations
|
|
36
|
+
*/
|
|
37
|
+
export class ContractClient {
|
|
38
|
+
/**
|
|
39
|
+
* Create a new ContractClient instance
|
|
40
|
+
* @param config - Configuration options including provider, contract addresses, and RPC URL
|
|
41
|
+
*/
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.provider = null;
|
|
44
|
+
this.credentialRegistry = null;
|
|
45
|
+
this.protocolAccessControl = null;
|
|
46
|
+
this.contractAddresses = config?.contractAddresses || {
|
|
47
|
+
CredentialRegistry: '0x8E4B7e3f9F3C55DA50aB587168f1d8A011FC8e95',
|
|
48
|
+
ZKVerifier: '0x48392A1bE10b5687c06be11152675215dff14512',
|
|
49
|
+
ProtocolAccessControl: '0xb92f19431617F5B34bFDCb06E3a80533939DD71b',
|
|
50
|
+
};
|
|
51
|
+
this.rpcUrl = config?.rpcUrl || 'https://avax-fuji.g.alchemy.com/v2/gu3D3rKyivv6bhmb3UbyUSYxThLz7C_c';
|
|
52
|
+
if (config?.provider) {
|
|
53
|
+
this.initialize(config.provider);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Initialize provider and contracts with robust support for various provider types
|
|
58
|
+
* @param inputProvider - EIP-1193 provider (window.ethereum), Ethers Provider, or custom
|
|
59
|
+
*/
|
|
60
|
+
initialize(inputProvider) {
|
|
61
|
+
if (!inputProvider) {
|
|
62
|
+
this.provider = new JsonRpcProvider(this.rpcUrl);
|
|
63
|
+
}
|
|
64
|
+
else if (inputProvider.request) {
|
|
65
|
+
// It's an EIP-1193 provider (MetaMask, etc.)
|
|
66
|
+
this.provider = new BrowserProvider(inputProvider);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Assume it's already an ethers-compatible provider
|
|
70
|
+
this.provider = inputProvider;
|
|
71
|
+
}
|
|
72
|
+
this.credentialRegistry = new ethers.Contract(this.contractAddresses.CredentialRegistry, CREDENTIAL_REGISTRY_ABI, this.provider);
|
|
73
|
+
this.protocolAccessControl = new ethers.Contract(this.contractAddresses.ProtocolAccessControl, PROTOCOL_ACCESS_CONTROL_ABI, this.provider);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Pre-flight validation for proof inputs
|
|
77
|
+
*/
|
|
78
|
+
validateProofInput(publicSignals) {
|
|
79
|
+
if (!publicSignals || publicSignals.length < 28) {
|
|
80
|
+
throw new Error(`Invalid public signals length: expected 28, got ${publicSignals?.length || 0}`);
|
|
81
|
+
}
|
|
82
|
+
// Check isValid bit
|
|
83
|
+
if (publicSignals[25] != "1" && publicSignals[25] != 1) {
|
|
84
|
+
throw new Error("ZK Proof internal validation failed (isValid signal is not 1)");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async isCredentialValid(credentialHash) {
|
|
88
|
+
if (!this.credentialRegistry)
|
|
89
|
+
this.initialize();
|
|
90
|
+
try {
|
|
91
|
+
return await this.credentialRegistry.isCredentialValid(credentialHash);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw new Error(`Failed to check credential validity: ${error}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async isNullifierUsed(nullifier) {
|
|
98
|
+
if (!this.credentialRegistry)
|
|
99
|
+
this.initialize();
|
|
100
|
+
try {
|
|
101
|
+
const owner = await this.credentialRegistry.nullifierOwners(nullifier);
|
|
102
|
+
return owner !== ethers.ZeroAddress;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw new Error(`Failed to check nullifier status: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async getCredentialByUser(userAddress) {
|
|
109
|
+
if (!this.credentialRegistry)
|
|
110
|
+
this.initialize();
|
|
111
|
+
try {
|
|
112
|
+
return await this.credentialRegistry.userToCredential(userAddress);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new Error(`Failed to get credential by user: ${error}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async hasAccess(protocolAddress, userAddress) {
|
|
119
|
+
if (!this.protocolAccessControl)
|
|
120
|
+
this.initialize();
|
|
121
|
+
try {
|
|
122
|
+
return await this.protocolAccessControl.hasAccess(protocolAddress, userAddress);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Failed to check access: ${error}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async getRequirements(protocolAddress) {
|
|
129
|
+
if (!this.protocolAccessControl)
|
|
130
|
+
this.initialize();
|
|
131
|
+
try {
|
|
132
|
+
const [minAge, requireAccredited, isSet] = await this.protocolAccessControl.protocolRequirements(protocolAddress);
|
|
133
|
+
return {
|
|
134
|
+
minAge: Number(minAge),
|
|
135
|
+
allowedJurisdictions: [],
|
|
136
|
+
requireAccredited,
|
|
137
|
+
isSet,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw new Error(`Failed to get protocol requirements: ${error}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async getUserCredential(protocolAddress, userAddress) {
|
|
145
|
+
if (!this.protocolAccessControl)
|
|
146
|
+
this.initialize();
|
|
147
|
+
try {
|
|
148
|
+
return await this.protocolAccessControl.userCredentials(protocolAddress, userAddress);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
throw new Error(`Failed to get user credential: ${error}`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async registerCredential(signer, credentialHash, userAddress) {
|
|
155
|
+
if (!signer)
|
|
156
|
+
throw new Error('Signer is required');
|
|
157
|
+
const contract = new ethers.Contract(this.contractAddresses.CredentialRegistry, CREDENTIAL_REGISTRY_ABI, signer);
|
|
158
|
+
try {
|
|
159
|
+
const tx = await contract.registerCredential(credentialHash, userAddress);
|
|
160
|
+
const receipt = await tx.wait();
|
|
161
|
+
return { transactionHash: tx.hash, receipt };
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
throw new Error(`Failed to register credential: ${error}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async revokeCredential(signer, credentialHash) {
|
|
168
|
+
if (!signer)
|
|
169
|
+
throw new Error('Signer is required');
|
|
170
|
+
const contract = new ethers.Contract(this.contractAddresses.CredentialRegistry, CREDENTIAL_REGISTRY_ABI, signer);
|
|
171
|
+
try {
|
|
172
|
+
const tx = await contract.revokeCredential(credentialHash);
|
|
173
|
+
const receipt = await tx.wait();
|
|
174
|
+
return { transactionHash: tx.hash, receipt };
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw new Error(`Failed to revoke credential: ${error}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async verifyAndGrantAccess(signer, proof, publicSignals, credentialHash, userAddress) {
|
|
181
|
+
if (!signer)
|
|
182
|
+
throw new Error('Signer is required to verify and grant access');
|
|
183
|
+
// Pre-flight check
|
|
184
|
+
this.validateProofInput(publicSignals);
|
|
185
|
+
const accessControl = new ethers.Contract(this.contractAddresses.ProtocolAccessControl, PROTOCOL_ACCESS_CONTROL_ABI, signer);
|
|
186
|
+
const a = [BigInt(proof.a[0]), BigInt(proof.a[1])];
|
|
187
|
+
const b = [
|
|
188
|
+
[BigInt(proof.b[0][0]), BigInt(proof.b[0][1])],
|
|
189
|
+
[BigInt(proof.b[1][0]), BigInt(proof.b[1][1])]
|
|
190
|
+
];
|
|
191
|
+
const c = [BigInt(proof.c[0]), BigInt(proof.c[1])];
|
|
192
|
+
const publicSignalsArray = publicSignals.slice(0, 28).map(s => BigInt(s));
|
|
193
|
+
try {
|
|
194
|
+
const tx = await accessControl.verifyAndGrantAccess(a, b, c, publicSignalsArray, credentialHash, userAddress);
|
|
195
|
+
const receipt = await tx.wait();
|
|
196
|
+
if (!receipt)
|
|
197
|
+
throw new Error('Transaction failed: No receipt returned');
|
|
198
|
+
return {
|
|
199
|
+
transactionHash: tx.hash,
|
|
200
|
+
receipt,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
throw new Error(`Contract verification failed: ${error}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
getProvider() { return this.provider; }
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=ContractClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractClient.js","sourceRoot":"","sources":["../../src/core/ContractClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,eAAe,EACf,eAAe,EAMhB,MAAM,QAAQ,CAAC;AAYhB;;GAEG;AACH,MAAM,uBAAuB,GAAG;IAC9B,wEAAwE;IACxE,mDAAmD;IACnD,0DAA0D;IAC1D,sDAAsD;IACtD,qDAAqD;IACrD,4DAA4D;IAC5D,0DAA0D;IAC1D,2DAA2D;IAC3D,mEAAmE;IACnE,qFAAqF;IACrF,mDAAmD;IACnD,qEAAqE;IACrE,yHAAyH;IACzH,oGAAoG;IACpG,4GAA4G;CACpG,CAAC;AAEX,MAAM,2BAA2B,GAAG;IAClC,wEAAwE;IACxE,wDAAwD;IACxD,0GAA0G;IAC1G,iFAAiF;IACjF,yGAAyG;IACzG,iIAAiI;IACjI,wHAAwH;IACxH,wFAAwF;IACxF,yHAAyH;CACjH,CAAC;AAEX;;;GAGG;AACH,MAAM,OAAO,cAAc;IAOzB;;;OAGG;IACH,YAAY,MAA6B;QAVjC,aAAQ,GAAoB,IAAI,CAAC;QACjC,uBAAkB,GAAoB,IAAI,CAAC;QAC3C,0BAAqB,GAAoB,IAAI,CAAC;QASpD,IAAI,CAAC,iBAAiB,GAAG,MAAM,EAAE,iBAAiB,IAAI;YACpD,kBAAkB,EAAE,4CAA4C;YAChE,UAAU,EAAE,4CAA4C;YACxD,qBAAqB,EAAE,4CAA4C;SACpE,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,qEAAqE,CAAC;QAEtG,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,UAAU,CAA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AC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,WAAW,KAAsB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;CACzD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ContractClient } from './ContractClient.js';
|
|
2
|
+
import { APIClient, type APIClientConfig } from './APIClient.js';
|
|
3
|
+
import { type MRZData } from '../utils/mrz.js';
|
|
4
|
+
import type { ContractClientConfig, TransactionResult, Requirements } from '../utils/types.js';
|
|
5
|
+
import type { Signer } from 'ethers';
|
|
6
|
+
export declare class NoahError extends Error {
|
|
7
|
+
message: string;
|
|
8
|
+
code: string;
|
|
9
|
+
constructor(message: string, code: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class NoahValidationError extends NoahError {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
export declare class NoahProverError extends NoahError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* NoahSDK - Main entry point for the Noah Protocol
|
|
19
|
+
*/
|
|
20
|
+
export declare class NoahSDK {
|
|
21
|
+
contracts: ContractClient;
|
|
22
|
+
api: APIClient;
|
|
23
|
+
private ocrExtractor;
|
|
24
|
+
constructor(config?: ContractClientConfig & APIClientConfig);
|
|
25
|
+
/**
|
|
26
|
+
* Extract identity data from a document image
|
|
27
|
+
* @param image - File or URL of the passport image
|
|
28
|
+
*/
|
|
29
|
+
extractPassportData(image: File | string | Blob): Promise<MRZData>;
|
|
30
|
+
/**
|
|
31
|
+
* Initialize the SDK with a provider
|
|
32
|
+
*/
|
|
33
|
+
init(provider: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* High-level method to prove age and grant access in one go
|
|
36
|
+
*/
|
|
37
|
+
proveAndGrant(signer: Signer, protocolAddress: string, mrzData: any, targetAge: number): Promise<TransactionResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Get protocol requirements via contract client
|
|
40
|
+
*/
|
|
41
|
+
getProtocolRequirements(protocolAddress: string): Promise<Requirements>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=NoahSDK.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoahSDK.d.ts","sourceRoot":"","sources":["../../src/core/NoahSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EACR,oBAAoB,EAEpB,iBAAiB,EACjB,YAAY,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,qBAAa,SAAU,SAAQ,KAAK;IACb,OAAO,EAAE,MAAM;IAAS,IAAI,EAAE,MAAM;gBAApC,OAAO,EAAE,MAAM,EAAS,IAAI,EAAE,MAAM;CAI1D;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBAClC,OAAO,EAAE,MAAM;CAG9B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBAC9B,OAAO,EAAE,MAAM;CAG9B;AAED;;GAEG;AACH,qBAAa,OAAO;IACT,SAAS,EAAE,cAAc,CAAC;IAC1B,GAAG,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,YAAY,CAAe;gBAEvB,MAAM,CAAC,EAAE,oBAAoB,GAAG,eAAe;IAM3D;;;OAGG;IACU,mBAAmB,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB/E;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;IAIhC;;OAEG;IACU,aAAa,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,GAAG,EACZ,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC;IAkC7B;;OAEG;IACU,uBAAuB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAGvF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ContractClient } from './ContractClient.js';
|
|
2
|
+
import { APIClient } from './APIClient.js';
|
|
3
|
+
import { OCRExtractor } from '../utils/ocr.js';
|
|
4
|
+
import { parseTD3 } from '../utils/mrz.js';
|
|
5
|
+
export class NoahError extends Error {
|
|
6
|
+
constructor(message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = 'NoahError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class NoahValidationError extends NoahError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message, 'VALIDATION_ERROR');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class NoahProverError extends NoahError {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message, 'PROVER_ERROR');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* NoahSDK - Main entry point for the Noah Protocol
|
|
25
|
+
*/
|
|
26
|
+
export class NoahSDK {
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.contracts = new ContractClient(config);
|
|
29
|
+
this.api = new APIClient(config);
|
|
30
|
+
this.ocrExtractor = new OCRExtractor();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Extract identity data from a document image
|
|
34
|
+
* @param image - File or URL of the passport image
|
|
35
|
+
*/
|
|
36
|
+
async extractPassportData(image) {
|
|
37
|
+
const { mrzLines } = await this.ocrExtractor.extractMRZ(image);
|
|
38
|
+
if (mrzLines.length < 2) {
|
|
39
|
+
throw new NoahValidationError('Could not detect MRZ lines in the image. Please ensure the bottom part of the passport is clearly visible.');
|
|
40
|
+
}
|
|
41
|
+
// We assume the last two lines are the TD3 MRZ lines
|
|
42
|
+
const line1 = mrzLines[mrzLines.length - 2];
|
|
43
|
+
const line2 = mrzLines[mrzLines.length - 1];
|
|
44
|
+
try {
|
|
45
|
+
return parseTD3(line1, line2);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new NoahValidationError(`Failed to parse MRZ: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Initialize the SDK with a provider
|
|
53
|
+
*/
|
|
54
|
+
init(provider) {
|
|
55
|
+
this.contracts.initialize(provider);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* High-level method to prove age and grant access in one go
|
|
59
|
+
*/
|
|
60
|
+
async proveAndGrant(signer, protocolAddress, mrzData, targetAge) {
|
|
61
|
+
try {
|
|
62
|
+
// 1. Pre-flight check requirements
|
|
63
|
+
const requirements = await this.contracts.getRequirements(protocolAddress);
|
|
64
|
+
if (requirements.minAge > targetAge) {
|
|
65
|
+
throw new NoahValidationError(`Protocol requires age ${requirements.minAge}, but target age is ${targetAge}`);
|
|
66
|
+
}
|
|
67
|
+
// 2. Generate Proof via API/Prover
|
|
68
|
+
const userAddress = await signer.getAddress();
|
|
69
|
+
const proofResult = await this.api.generateAgeProof({
|
|
70
|
+
mrzData,
|
|
71
|
+
minAge: targetAge,
|
|
72
|
+
recipientAddress: userAddress
|
|
73
|
+
});
|
|
74
|
+
if (!proofResult.success) {
|
|
75
|
+
throw new NoahProverError(proofResult.error || 'Unknown prover error');
|
|
76
|
+
}
|
|
77
|
+
// 3. Submit to Chain
|
|
78
|
+
return await this.contracts.verifyAndGrantAccess(signer, proofResult.proof, proofResult.publicSignals, proofResult.credentialHash, userAddress);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof NoahError)
|
|
82
|
+
throw error;
|
|
83
|
+
throw new NoahError(error instanceof Error ? error.message : 'Unknown error', 'INTERNAL_ERROR');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get protocol requirements via contract client
|
|
88
|
+
*/
|
|
89
|
+
async getProtocolRequirements(protocolAddress) {
|
|
90
|
+
return this.contracts.getRequirements(protocolAddress);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=NoahSDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoahSDK.js","sourceRoot":"","sources":["../../src/core/NoahSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAgB,MAAM,iBAAiB,CAAC;AASzD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAChC,YAAmB,OAAe,EAAS,IAAY;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QADA,YAAO,GAAP,OAAO,CAAQ;QAAS,SAAI,GAAJ,IAAI,CAAQ;QAEnD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;CACJ;AAED,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAC9C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC1C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACnC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,OAAO;IAKhB,YAAY,MAA+C;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAM,CA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