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.
Files changed (103) hide show
  1. package/README.md +892 -0
  2. package/dist/core/APIClient.d.ts +71 -0
  3. package/dist/core/APIClient.d.ts.map +1 -0
  4. package/dist/core/APIClient.js +92 -0
  5. package/dist/core/APIClient.js.map +1 -0
  6. package/dist/core/ContractClient.d.ts +38 -0
  7. package/dist/core/ContractClient.d.ts.map +1 -0
  8. package/dist/core/ContractClient.js +209 -0
  9. package/dist/core/ContractClient.js.map +1 -0
  10. package/dist/core/NoahSDK.d.ts +43 -0
  11. package/dist/core/NoahSDK.d.ts.map +1 -0
  12. package/dist/core/NoahSDK.js +93 -0
  13. package/dist/core/NoahSDK.js.map +1 -0
  14. package/dist/core/WalletAdapter.d.ts +188 -0
  15. package/dist/core/WalletAdapter.d.ts.map +1 -0
  16. package/dist/core/WalletAdapter.js +425 -0
  17. package/dist/core/WalletAdapter.js.map +1 -0
  18. package/dist/hooks/index.d.ts +18 -0
  19. package/dist/hooks/index.d.ts.map +1 -0
  20. package/dist/hooks/index.js +15 -0
  21. package/dist/hooks/index.js.map +1 -0
  22. package/dist/hooks/useCredentials.d.ts +136 -0
  23. package/dist/hooks/useCredentials.d.ts.map +1 -0
  24. package/dist/hooks/useCredentials.js +217 -0
  25. package/dist/hooks/useCredentials.js.map +1 -0
  26. package/dist/hooks/useProtocol.d.ts +117 -0
  27. package/dist/hooks/useProtocol.d.ts.map +1 -0
  28. package/dist/hooks/useProtocol.js +165 -0
  29. package/dist/hooks/useProtocol.js.map +1 -0
  30. package/dist/hooks/useUser.d.ts +159 -0
  31. package/dist/hooks/useUser.d.ts.map +1 -0
  32. package/dist/hooks/useUser.js +188 -0
  33. package/dist/hooks/useUser.js.map +1 -0
  34. package/dist/index.d.ts +28 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +26 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/issuer/IssuerClient.d.ts +98 -0
  39. package/dist/issuer/IssuerClient.d.ts.map +1 -0
  40. package/dist/issuer/IssuerClient.js +159 -0
  41. package/dist/issuer/IssuerClient.js.map +1 -0
  42. package/dist/protocol/ProtocolClient.d.ts +124 -0
  43. package/dist/protocol/ProtocolClient.d.ts.map +1 -0
  44. package/dist/protocol/ProtocolClient.js +265 -0
  45. package/dist/protocol/ProtocolClient.js.map +1 -0
  46. package/dist/protocol/RequirementsManager.d.ts +9 -0
  47. package/dist/protocol/RequirementsManager.d.ts.map +1 -0
  48. package/dist/protocol/RequirementsManager.js +9 -0
  49. package/dist/protocol/RequirementsManager.js.map +1 -0
  50. package/dist/user/ProofGenerator.d.ts +49 -0
  51. package/dist/user/ProofGenerator.d.ts.map +1 -0
  52. package/dist/user/ProofGenerator.js +80 -0
  53. package/dist/user/ProofGenerator.js.map +1 -0
  54. package/dist/user/UserClient.d.ts +191 -0
  55. package/dist/user/UserClient.d.ts.map +1 -0
  56. package/dist/user/UserClient.js +338 -0
  57. package/dist/user/UserClient.js.map +1 -0
  58. package/dist/utils/credentials.d.ts +47 -0
  59. package/dist/utils/credentials.d.ts.map +1 -0
  60. package/dist/utils/credentials.js +99 -0
  61. package/dist/utils/credentials.js.map +1 -0
  62. package/dist/utils/identity.d.ts +22 -0
  63. package/dist/utils/identity.d.ts.map +1 -0
  64. package/dist/utils/identity.js +35 -0
  65. package/dist/utils/identity.js.map +1 -0
  66. package/dist/utils/jurisdiction.d.ts +21 -0
  67. package/dist/utils/jurisdiction.d.ts.map +1 -0
  68. package/dist/utils/jurisdiction.js +64 -0
  69. package/dist/utils/jurisdiction.js.map +1 -0
  70. package/dist/utils/mrz.d.ts +16 -0
  71. package/dist/utils/mrz.d.ts.map +1 -0
  72. package/dist/utils/mrz.js +91 -0
  73. package/dist/utils/mrz.js.map +1 -0
  74. package/dist/utils/ocr.d.ts +31 -0
  75. package/dist/utils/ocr.d.ts.map +1 -0
  76. package/dist/utils/ocr.js +69 -0
  77. package/dist/utils/ocr.js.map +1 -0
  78. package/dist/utils/types.d.ts +122 -0
  79. package/dist/utils/types.d.ts.map +1 -0
  80. package/dist/utils/types.js +2 -0
  81. package/dist/utils/types.js.map +1 -0
  82. package/package.json +53 -0
  83. package/src/core/APIClient.ts +165 -0
  84. package/src/core/ContractClient.ts +266 -0
  85. package/src/core/NoahSDK.ts +123 -0
  86. package/src/core/WalletAdapter.ts +546 -0
  87. package/src/hooks/index.ts +31 -0
  88. package/src/hooks/types.d.ts +18 -0
  89. package/src/hooks/useCredentials.ts +359 -0
  90. package/src/hooks/useProtocol.ts +284 -0
  91. package/src/hooks/useUser.ts +331 -0
  92. package/src/index.ts +80 -0
  93. package/src/issuer/IssuerClient.ts +209 -0
  94. package/src/protocol/ProtocolClient.ts +330 -0
  95. package/src/protocol/RequirementsManager.ts +16 -0
  96. package/src/user/ProofGenerator.ts +113 -0
  97. package/src/user/UserClient.ts +440 -0
  98. package/src/utils/credentials.ts +122 -0
  99. package/src/utils/identity.ts +46 -0
  100. package/src/utils/jurisdiction.ts +83 -0
  101. package/src/utils/mrz.ts +113 -0
  102. package/src/utils/ocr.ts +84 -0
  103. package/src/utils/types.ts +144 -0
@@ -0,0 +1,159 @@
1
+ import { ContractClient } from '../core/ContractClient';
2
+ import { APIClient } from '../core/APIClient';
3
+ /**
4
+ * IssuerClient - High-level API for credential issuers
5
+ *
6
+ * Provides a simple interface for issuers to:
7
+ * - Register credentials on-chain
8
+ * - Revoke credentials
9
+ * - Check credential status
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { IssuerClient } from '@noah-protocol/sdk';
14
+ * import { ethers } from 'ethers';
15
+ *
16
+ * const provider = new ethers.BrowserProvider(window.ethereum);
17
+ * const signer = await provider.getSigner();
18
+ * const issuer = new IssuerClient(signer, { apiBaseUrl: 'https://api.noah.xyz' });
19
+ *
20
+ * // Register credential
21
+ * await issuer.registerCredential(credentialHash, userAddress);
22
+ *
23
+ * // Revoke credential
24
+ * await issuer.revokeCredential(credentialHash);
25
+ * ```
26
+ */
27
+ export class IssuerClient {
28
+ /**
29
+ * Create a new IssuerClient instance
30
+ * @param signer - Ethers.js signer from issuer's wallet
31
+ * @param config - Optional configuration
32
+ */
33
+ constructor(signer, config = {}) {
34
+ if (!signer) {
35
+ throw new Error('Signer is required');
36
+ }
37
+ this.signer = signer;
38
+ // Initialize ContractClient
39
+ this.contractClient = new ContractClient({
40
+ provider: signer.provider || undefined,
41
+ contractAddresses: config.contractAddresses,
42
+ rpcUrl: config.rpcUrl,
43
+ });
44
+ // Initialize APIClient
45
+ this.apiClient = new APIClient({
46
+ baseURL: config.apiBaseUrl,
47
+ });
48
+ }
49
+ /**
50
+ * Register a credential on-chain
51
+ *
52
+ * @param credentialHash - The credential hash to register (bytes32)
53
+ * @param userAddress - The user's wallet address
54
+ * @param useAPI - If true, use backend API (gasless). If false, use direct contract call.
55
+ * @returns Promise resolving to transaction result
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const tx = await issuer.registerCredential('0x1234...', '0x5678...');
60
+ * console.log('Transaction hash:', tx.transactionHash);
61
+ * ```
62
+ */
63
+ async registerCredential(credentialHash, userAddress, useAPI = false) {
64
+ if (!credentialHash) {
65
+ throw new Error('Credential hash is required');
66
+ }
67
+ if (!userAddress) {
68
+ throw new Error('User address is required');
69
+ }
70
+ try {
71
+ if (useAPI) {
72
+ // Use backend API for gasless transactions
73
+ return await this.apiClient.registerCredential(credentialHash, userAddress);
74
+ }
75
+ else {
76
+ // Use direct contract call
77
+ return await this.contractClient.registerCredential(this.signer, credentialHash, userAddress);
78
+ }
79
+ }
80
+ catch (error) {
81
+ throw new Error(`Failed to register credential: ${error.message || 'Unknown error'}`);
82
+ }
83
+ }
84
+ /**
85
+ * Revoke a credential
86
+ *
87
+ * @param credentialHash - The credential hash to revoke (bytes32)
88
+ * @param useAPI - If true, use backend API (gasless). If false, use direct contract call.
89
+ * @returns Promise resolving to transaction result
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const tx = await issuer.revokeCredential('0x1234...');
94
+ * console.log('Transaction hash:', tx.transactionHash);
95
+ * ```
96
+ */
97
+ async revokeCredential(credentialHash, useAPI = false) {
98
+ if (!credentialHash) {
99
+ throw new Error('Credential hash is required');
100
+ }
101
+ try {
102
+ if (useAPI) {
103
+ // Use backend API for gasless transactions
104
+ return await this.apiClient.revokeCredential(credentialHash);
105
+ }
106
+ else {
107
+ // Use direct contract call
108
+ return await this.contractClient.revokeCredential(this.signer, credentialHash);
109
+ }
110
+ }
111
+ catch (error) {
112
+ throw new Error(`Failed to revoke credential: ${error.message || 'Unknown error'}`);
113
+ }
114
+ }
115
+ /**
116
+ * Check credential status
117
+ *
118
+ * @param credentialHash - The credential hash to check (bytes32)
119
+ * @returns Promise resolving to credential status information
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const status = await issuer.checkCredential('0x1234...');
124
+ * console.log('Is valid:', status.isValid);
125
+ * console.log('Is revoked:', status.isRevoked);
126
+ * ```
127
+ */
128
+ async checkCredential(credentialHash) {
129
+ if (!credentialHash) {
130
+ throw new Error('Credential hash is required');
131
+ }
132
+ try {
133
+ // Check on-chain validity
134
+ const isValid = await this.contractClient.isCredentialValid(credentialHash);
135
+ // Get additional info from API if available
136
+ try {
137
+ const apiStatus = await this.apiClient.checkCredential(credentialHash);
138
+ return {
139
+ isValid: apiStatus.isValid && isValid,
140
+ credentialHash,
141
+ isRevoked: apiStatus.isRevoked,
142
+ issuer: apiStatus.issuer,
143
+ };
144
+ }
145
+ catch {
146
+ // If API fails, return on-chain status
147
+ return {
148
+ isValid,
149
+ credentialHash,
150
+ isRevoked: !isValid,
151
+ };
152
+ }
153
+ }
154
+ catch (error) {
155
+ throw new Error(`Failed to check credential: ${error.message || 'Unknown error'}`);
156
+ }
157
+ }
158
+ }
159
+ //# sourceMappingURL=IssuerClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IssuerClient.js","sourceRoot":"","sources":["../../src/issuer/IssuerClient.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e,CAAC,cAAc,CAAC,CAAC;gBACvE,OAAO;oBACL,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,OAAO;oBACrC,cAAc;oBACd,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;iBACzB,CAAC;YACJ,CAAC;YAAC,MAAM,CAAC;gBACP,uCAAuC;gBACvC,OAAO;oBACL,OAAO;oBACP,cAAc;oBACd,SAAS,EAAE,CAAC,OAAO;iBACpB,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,+BAA+B,KAAK,CAAC,OAAO,IAAI,eAAe,EAAE,CAClE,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,124 @@
1
+ import type { Signer } from 'ethers';
2
+ import { Requirements, TransactionResult, ProtocolClientConfig, SetRequirementsParams, VerifyUserAccessParams } from '../utils/types';
3
+ /**
4
+ * ProtocolClient - High-level API for DeFi protocol integration
5
+ *
6
+ * Provides a simple interface for protocols to:
7
+ * - Set KYC requirements (minAge, jurisdictions, accredited status)
8
+ * - Check if users have access
9
+ * - Verify ZK proofs and grant access to users
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { ProtocolClient } from '@noah-protocol/sdk';
14
+ * import { ethers } from 'ethers';
15
+ *
16
+ * const provider = new ethers.BrowserProvider(window.ethereum);
17
+ * const signer = await provider.getSigner();
18
+ * const protocol = new ProtocolClient(signer);
19
+ *
20
+ * // Set requirements
21
+ * await protocol.setRequirements({
22
+ * minAge: 21,
23
+ * jurisdictions: ['US', 'UK', 'CA'],
24
+ * requireAccredited: true
25
+ * });
26
+ *
27
+ * // Check user access
28
+ * const hasAccess = await protocol.checkUserAccess(protocolAddress, userAddress);
29
+ * ```
30
+ */
31
+ export declare class ProtocolClient {
32
+ private signer;
33
+ private provider;
34
+ private protocolAccessControlAddress;
35
+ private contract;
36
+ /**
37
+ * Create a new ProtocolClient instance
38
+ *
39
+ * @param signer - Ethers signer (from wallet connection)
40
+ * @param config - Optional configuration (contract address, provider)
41
+ */
42
+ constructor(signer: Signer, config?: ProtocolClientConfig);
43
+ /**
44
+ * Get or create the ProtocolAccessControl contract instance
45
+ * Uses signer for write operations, provider for read operations
46
+ */
47
+ private getContract;
48
+ /**
49
+ * Get read-only contract instance (for queries)
50
+ */
51
+ private getReadOnlyContract;
52
+ /**
53
+ * Set protocol requirements for KYC verification
54
+ *
55
+ * @param params - Requirements parameters
56
+ * @param params.minAge - Minimum age required (must be positive integer)
57
+ * @param params.jurisdictions - Array of allowed jurisdiction hashes (strings or numbers)
58
+ * @param params.requireAccredited - Whether accredited investor status is required
59
+ * @returns Promise resolving to transaction result
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const tx = await protocol.setRequirements({
64
+ * minAge: 21,
65
+ * jurisdictions: ['1234567890', '1111111111'],
66
+ * requireAccredited: true
67
+ * });
68
+ * console.log('Transaction hash:', tx.transactionHash);
69
+ * ```
70
+ */
71
+ setRequirements(params: SetRequirementsParams): Promise<TransactionResult>;
72
+ /**
73
+ * Get protocol requirements
74
+ *
75
+ * @param protocolAddress - The protocol contract address (defaults to signer's address)
76
+ * @returns Promise resolving to requirements object
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const requirements = await protocol.getRequirements(protocolAddress);
81
+ * console.log('Min age:', requirements.minAge);
82
+ * console.log('Jurisdictions:', requirements.allowedJurisdictions);
83
+ * ```
84
+ */
85
+ getRequirements(protocolAddress?: string): Promise<Requirements>;
86
+ /**
87
+ * Verify ZK proof and grant access to a user
88
+ *
89
+ * @param params - Verification parameters
90
+ * @param params.userAddress - The user's wallet address
91
+ * @param params.proof - ZK proof object (Groth16 format)
92
+ * @param params.publicSignals - Public signals array (13 elements)
93
+ * @param params.credentialHash - The credential hash (bytes32)
94
+ * @returns Promise resolving to transaction result
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const tx = await protocol.verifyUserAccess({
99
+ * userAddress: '0x...',
100
+ * proof: { a: [...], b: [...], c: [...] },
101
+ * publicSignals: ['21', '1234567890', ...],
102
+ * credentialHash: '0x...'
103
+ * });
104
+ * ```
105
+ */
106
+ verifyUserAccess(params: VerifyUserAccessParams): Promise<TransactionResult>;
107
+ /**
108
+ * Check if a user has access to a protocol
109
+ *
110
+ * @param protocolAddress - The protocol contract address (defaults to signer's address)
111
+ * @param userAddress - The user's wallet address
112
+ * @returns Promise resolving to boolean indicating access status
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const hasAccess = await protocol.checkUserAccess(protocolAddress, userAddress);
117
+ * if (hasAccess) {
118
+ * console.log('User has access');
119
+ * }
120
+ * ```
121
+ */
122
+ checkUserAccess(protocolAddress: string, userAddress: string): Promise<boolean>;
123
+ }
124
+ //# sourceMappingURL=ProtocolClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtocolClient.d.ts","sourceRoot":"","sources":["../../src/protocol/ProtocolClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAwC,MAAM,QAAQ,CAAC;AAC3E,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAqBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,4BAA4B,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAiBzD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;;;;;;;;;;;;;OAkBG;IACG,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAgEhF;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBtE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAqDlF;;;;;;;;;;;;;;OAcG;IACG,eAAe,CACnB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC;CASpB"}
@@ -0,0 +1,265 @@
1
+ import { Contract } from 'ethers';
2
+ import { jurisdictionStringsToHashes } from '../utils/jurisdiction';
3
+ /**
4
+ * Protocol Access Control ABI (minimal for required operations)
5
+ */
6
+ const PROTOCOL_ACCESS_CONTROL_ABI = [
7
+ 'function hasAccess(address protocol, address user) view returns (bool)',
8
+ 'function protocolRequirements(address) view returns (uint256 minAge, bool requireAccredited, bool isSet)',
9
+ 'function setRequirements(uint256 minAge, uint256[] memory allowedJurisdictions, bool requireAccredited)',
10
+ 'function verifyAndGrantAccess(uint[2] a, uint[2][2] b, uint[2] c, uint[13] publicSignals, bytes32 credentialHash, address user)',
11
+ 'event AccessGranted(address indexed user, address indexed protocol, bytes32 credentialHash, uint256 timestamp)',
12
+ 'event RequirementsSet(address indexed protocol, uint256 minAge, uint256[] allowedJurisdictions, bool requireAccredited)',
13
+ ];
14
+ /**
15
+ * Default Protocol Access Control contract address (Mantle Sepolia)
16
+ * Can be overridden via config
17
+ */
18
+ const DEFAULT_PROTOCOL_ACCESS_CONTROL_ADDRESS = '0xF599F186aC6fD2a9bECd9eDEE91fd58D3Dc3dB0A';
19
+ /**
20
+ * ProtocolClient - High-level API for DeFi protocol integration
21
+ *
22
+ * Provides a simple interface for protocols to:
23
+ * - Set KYC requirements (minAge, jurisdictions, accredited status)
24
+ * - Check if users have access
25
+ * - Verify ZK proofs and grant access to users
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * import { ProtocolClient } from '@noah-protocol/sdk';
30
+ * import { ethers } from 'ethers';
31
+ *
32
+ * const provider = new ethers.BrowserProvider(window.ethereum);
33
+ * const signer = await provider.getSigner();
34
+ * const protocol = new ProtocolClient(signer);
35
+ *
36
+ * // Set requirements
37
+ * await protocol.setRequirements({
38
+ * minAge: 21,
39
+ * jurisdictions: ['US', 'UK', 'CA'],
40
+ * requireAccredited: true
41
+ * });
42
+ *
43
+ * // Check user access
44
+ * const hasAccess = await protocol.checkUserAccess(protocolAddress, userAddress);
45
+ * ```
46
+ */
47
+ export class ProtocolClient {
48
+ /**
49
+ * Create a new ProtocolClient instance
50
+ *
51
+ * @param signer - Ethers signer (from wallet connection)
52
+ * @param config - Optional configuration (contract address, provider)
53
+ */
54
+ constructor(signer, config) {
55
+ this.contract = null;
56
+ if (!signer) {
57
+ throw new Error('Signer is required');
58
+ }
59
+ this.signer = signer;
60
+ this.provider = config?.provider || signer.provider;
61
+ if (!this.provider) {
62
+ throw new Error('Provider is required. Pass it via config or ensure signer has a provider.');
63
+ }
64
+ this.protocolAccessControlAddress =
65
+ config?.protocolAccessControlAddress ||
66
+ DEFAULT_PROTOCOL_ACCESS_CONTROL_ADDRESS;
67
+ }
68
+ /**
69
+ * Get or create the ProtocolAccessControl contract instance
70
+ * Uses signer for write operations, provider for read operations
71
+ */
72
+ getContract() {
73
+ if (!this.contract) {
74
+ this.contract = new Contract(this.protocolAccessControlAddress, PROTOCOL_ACCESS_CONTROL_ABI, this.signer);
75
+ }
76
+ return this.contract;
77
+ }
78
+ /**
79
+ * Get read-only contract instance (for queries)
80
+ */
81
+ getReadOnlyContract() {
82
+ return new Contract(this.protocolAccessControlAddress, PROTOCOL_ACCESS_CONTROL_ABI, this.provider);
83
+ }
84
+ /**
85
+ * Set protocol requirements for KYC verification
86
+ *
87
+ * @param params - Requirements parameters
88
+ * @param params.minAge - Minimum age required (must be positive integer)
89
+ * @param params.jurisdictions - Array of allowed jurisdiction hashes (strings or numbers)
90
+ * @param params.requireAccredited - Whether accredited investor status is required
91
+ * @returns Promise resolving to transaction result
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const tx = await protocol.setRequirements({
96
+ * minAge: 21,
97
+ * jurisdictions: ['1234567890', '1111111111'],
98
+ * requireAccredited: true
99
+ * });
100
+ * console.log('Transaction hash:', tx.transactionHash);
101
+ * ```
102
+ */
103
+ async setRequirements(params) {
104
+ const { minAge, jurisdictions, requireAccredited } = params;
105
+ if (minAge < 0 || !Number.isInteger(minAge)) {
106
+ throw new Error('minAge must be a non-negative integer');
107
+ }
108
+ if (!Array.isArray(jurisdictions)) {
109
+ throw new Error('jurisdictions must be an array');
110
+ }
111
+ if (jurisdictions.length > 10) {
112
+ throw new Error('Maximum 10 jurisdictions allowed');
113
+ }
114
+ // Convert jurisdictions to BigInt array
115
+ // First, check if they're jurisdiction strings (like "US", "UK") or already hashes
116
+ let jurisdictionsToProcess;
117
+ // Check if any jurisdiction is a string that's not numeric (like "US", "UK")
118
+ const hasStringJurisdictions = jurisdictions.some(j => typeof j === 'string' && !j.startsWith('0x') && !/^\d+$/.test(j));
119
+ if (hasStringJurisdictions) {
120
+ // Convert jurisdiction strings to hashes
121
+ const jurisdictionStrings = jurisdictions.map(j => String(j));
122
+ const hashes = jurisdictionStringsToHashes(jurisdictionStrings);
123
+ jurisdictionsToProcess = hashes;
124
+ }
125
+ else {
126
+ jurisdictionsToProcess = jurisdictions;
127
+ }
128
+ // Convert to BigInt array
129
+ const jurisdictionsArray = jurisdictionsToProcess.map(j => {
130
+ if (typeof j === 'string') {
131
+ if (j.startsWith('0x')) {
132
+ return BigInt(j);
133
+ }
134
+ return BigInt(j);
135
+ }
136
+ return BigInt(j);
137
+ });
138
+ try {
139
+ const contract = this.getContract();
140
+ const tx = await contract.setRequirements(BigInt(minAge), jurisdictionsArray, requireAccredited);
141
+ const receipt = await tx.wait();
142
+ return {
143
+ transactionHash: tx.hash,
144
+ receipt: receipt,
145
+ };
146
+ }
147
+ catch (error) {
148
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
149
+ throw new Error(`Failed to set requirements: ${errorMessage}`);
150
+ }
151
+ }
152
+ /**
153
+ * Get protocol requirements
154
+ *
155
+ * @param protocolAddress - The protocol contract address (defaults to signer's address)
156
+ * @returns Promise resolving to requirements object
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const requirements = await protocol.getRequirements(protocolAddress);
161
+ * console.log('Min age:', requirements.minAge);
162
+ * console.log('Jurisdictions:', requirements.allowedJurisdictions);
163
+ * ```
164
+ */
165
+ async getRequirements(protocolAddress) {
166
+ const address = protocolAddress || (await this.signer.getAddress());
167
+ try {
168
+ const contract = this.getReadOnlyContract();
169
+ const [minAge, requireAccredited, isSet] = await contract.protocolRequirements(address);
170
+ return {
171
+ minAge: Number(minAge),
172
+ allowedJurisdictions: [], // Public mapping getter does not return arrays
173
+ requireAccredited,
174
+ isSet,
175
+ };
176
+ }
177
+ catch (error) {
178
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
179
+ throw new Error(`Failed to get requirements: ${errorMessage}`);
180
+ }
181
+ }
182
+ /**
183
+ * Verify ZK proof and grant access to a user
184
+ *
185
+ * @param params - Verification parameters
186
+ * @param params.userAddress - The user's wallet address
187
+ * @param params.proof - ZK proof object (Groth16 format)
188
+ * @param params.publicSignals - Public signals array (13 elements)
189
+ * @param params.credentialHash - The credential hash (bytes32)
190
+ * @returns Promise resolving to transaction result
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * const tx = await protocol.verifyUserAccess({
195
+ * userAddress: '0x...',
196
+ * proof: { a: [...], b: [...], c: [...] },
197
+ * publicSignals: ['21', '1234567890', ...],
198
+ * credentialHash: '0x...'
199
+ * });
200
+ * ```
201
+ */
202
+ async verifyUserAccess(params) {
203
+ const { userAddress, proof, publicSignals, credentialHash } = params;
204
+ if (!proof.a || !Array.isArray(proof.a) || proof.a.length !== 2) {
205
+ throw new Error('Proof.a must be an array of 2 elements');
206
+ }
207
+ if (!proof.b || !Array.isArray(proof.b) || proof.b.length !== 2) {
208
+ throw new Error('Proof.b must be an array of 2 arrays');
209
+ }
210
+ if (!proof.c || !Array.isArray(proof.c) || proof.c.length !== 2) {
211
+ throw new Error('Proof.c must be an array of 2 elements');
212
+ }
213
+ if (!Array.isArray(publicSignals) || publicSignals.length < 13) {
214
+ throw new Error('publicSignals must be an array of at least 13 elements');
215
+ }
216
+ // Convert proof arrays to BigInt arrays
217
+ const a = [BigInt(proof.a[0]), BigInt(proof.a[1])];
218
+ const b = [
219
+ [BigInt(proof.b[0][0]), BigInt(proof.b[0][1])],
220
+ [BigInt(proof.b[1][0]), BigInt(proof.b[1][1])],
221
+ ];
222
+ const c = [BigInt(proof.c[0]), BigInt(proof.c[1])];
223
+ // Convert public signals to BigInt array (13 elements)
224
+ const publicSignalsArray = publicSignals.slice(0, 13).map(s => BigInt(s));
225
+ try {
226
+ const contract = this.getContract();
227
+ const tx = await contract.verifyAndGrantAccess(a, b, c, publicSignalsArray, credentialHash, userAddress);
228
+ const receipt = await tx.wait();
229
+ return {
230
+ transactionHash: tx.hash,
231
+ receipt: receipt,
232
+ };
233
+ }
234
+ catch (error) {
235
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
236
+ throw new Error(`Failed to verify and grant access: ${errorMessage}`);
237
+ }
238
+ }
239
+ /**
240
+ * Check if a user has access to a protocol
241
+ *
242
+ * @param protocolAddress - The protocol contract address (defaults to signer's address)
243
+ * @param userAddress - The user's wallet address
244
+ * @returns Promise resolving to boolean indicating access status
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const hasAccess = await protocol.checkUserAccess(protocolAddress, userAddress);
249
+ * if (hasAccess) {
250
+ * console.log('User has access');
251
+ * }
252
+ * ```
253
+ */
254
+ async checkUserAccess(protocolAddress, userAddress) {
255
+ try {
256
+ const contract = this.getReadOnlyContract();
257
+ return await contract.hasAccess(protocolAddress, userAddress);
258
+ }
259
+ catch (error) {
260
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
261
+ throw new Error(`Failed to check user access: ${errorMessage}`);
262
+ }
263
+ }
264
+ }
265
+ //# sourceMappingURL=ProtocolClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProtocolClient.js","sourceRoot":"","sources":["../../src/protocol/ProtocolClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,2BAA2B,GAAG;IAClC,wEAAwE;IACxE,0GAA0G;IAC1G,yGAAyG;IACzG,iIAAiI;IACjI,gHAAgH;IAChH,yHAAyH;CACjH,CAAC;AAEX;;;GAGG;AACH,MAAM,uCAAuC,GAAG,4CAA4C,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,cAAc;IAMzB;;;;;OAKG;IACH,YAAY,MAAc,EAAE,MAA6B;QARjD,aAAQ,GAAoB,IAAI,CAAC;QASvC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,MAAM,CAAC,QAAS,CAAC;QAErD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,CAAC;QAED,IAAI,CAAC,4BAA4B;YAC/B,MAAM,EAAE,4BAA4B;gBACpC,uCAAuC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACK,WAAW;QACjB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAC1B,IAAI,CAAC,4BAA4B,EACjC,2BAA2B,EAC3B,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AAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACpC,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,oBAAoB,CAC5C,CAAC,EACD,CAAC,EACD,CAAC,EACD,kBAAkB,EAClB,cAAc,EACd,WAAW,CACZ,CAAC;YAEF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;YAEhC,OAAO;gBACL,eAAe,EAAE,EAAE,CAAC,IAAI;gBACxB,OAAO,EAAE,OAAqC;aAC/C,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,sCAAsC,YAAY,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,eAAe,CACnB,eAAuB,EACvB,WAAmB;QAEnB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC5C,OAAO,MAAM,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAChE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * RequirementsManager
3
+ *
4
+ * Helper utilities for managing protocol requirements.
5
+ * This is a placeholder - implementation will be added in Phase 3.
6
+ */
7
+ export declare class RequirementsManager {
8
+ }
9
+ //# sourceMappingURL=RequirementsManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequirementsManager.d.ts","sourceRoot":"","sources":["../../src/protocol/RequirementsManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,mBAAmB;CAE/B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * RequirementsManager
3
+ *
4
+ * Helper utilities for managing protocol requirements.
5
+ * This is a placeholder - implementation will be added in Phase 3.
6
+ */
7
+ export class RequirementsManager {
8
+ }
9
+ //# sourceMappingURL=RequirementsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequirementsManager.js","sourceRoot":"","sources":["../../src/protocol/RequirementsManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,OAAO,mBAAmB;CAE/B"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ProofGenerator - Browser-side ZK Proof Generation
3
+ *
4
+ * This class manages the lifecycle of the ZK prover:
5
+ * 1. Loading the WASM module
6
+ * 2. Caching artifacts in IndexedDB
7
+ * 3. Executing proofs in a Web Worker (optional but recommended)
8
+ */
9
+ import type { ZKProof } from '../utils/types';
10
+ export interface ProverInput {
11
+ actualAge: number;
12
+ actualJurisdiction: number;
13
+ actualAccredited: number;
14
+ credentialHash: string;
15
+ passportNumber: string;
16
+ expiryDate: number;
17
+ minAge: number;
18
+ recipientAddress: string;
19
+ currentDate: number;
20
+ allowedJurisdictions: number[];
21
+ sanctionedCountries: number[];
22
+ requireAccredited: number;
23
+ credentialHashPublic: string;
24
+ }
25
+ export interface ProofGenerationResult {
26
+ proof: ZKProof;
27
+ publicSignals: string[];
28
+ success: boolean;
29
+ nullifier: string;
30
+ packedFlags: number;
31
+ }
32
+ export declare class ProofGenerator {
33
+ private wasmLoaded;
34
+ private wasmBinary;
35
+ constructor();
36
+ /**
37
+ * Load the ZK prover artifacts
38
+ * @param wasmUrl - URL to the noah_prover.wasm file
39
+ */
40
+ loadProver(wasmUrl?: string): Promise<void>;
41
+ /**
42
+ * Generate a ZK proof locally
43
+ * @param input - Circuit assignment data
44
+ */
45
+ generateProof(input: ProverInput): Promise<ProofGenerationResult>;
46
+ private getCachedWasm;
47
+ private cacheWasm;
48
+ }
49
+ //# sourceMappingURL=ProofGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofGenerator.d.ts","sourceRoot":"","sources":["../../src/user/ProofGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,UAAU,CAA4B;;IAI9C;;;OAGG;IACG,UAAU,CAAC,OAAO,GAAE,MAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBtE;;;OAGG;IACG,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;YA8BzD,aAAa;YAKb,SAAS;CAIxB"}