@zkp2p/sdk 0.0.12 → 0.0.13
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 +8 -4
- package/dist/{Zkp2pClient-D-5XTy87.d.mts → Zkp2pClient-B0l_kPQB.d.mts} +6 -2
- package/dist/{Zkp2pClient-D-5XTy87.d.ts → Zkp2pClient-B0l_kPQB.d.ts} +6 -2
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -136,7 +136,8 @@ const walletClient = createWalletClient({
|
|
|
136
136
|
const client = new OfframpClient({
|
|
137
137
|
walletClient,
|
|
138
138
|
chainId: base.id,
|
|
139
|
-
apiKey: '
|
|
139
|
+
apiKey: 'YOUR_CURATOR_API_KEY', // For curator API (createDeposit, signalIntent, etc.)
|
|
140
|
+
indexerApiKey: 'YOUR_INDEXER_KEY', // For indexer proxy (x-api-key header)
|
|
140
141
|
});
|
|
141
142
|
|
|
142
143
|
// Optional: keep indexer auth fresh in long-lived clients
|
|
@@ -147,16 +148,19 @@ const getFreshAuthToken = async () => {
|
|
|
147
148
|
const clientWithTokenProvider = new OfframpClient({
|
|
148
149
|
walletClient,
|
|
149
150
|
chainId: base.id,
|
|
150
|
-
getAuthorizationToken: getFreshAuthToken,
|
|
151
|
+
getAuthorizationToken: getFreshAuthToken, // Bearer token per indexer request
|
|
151
152
|
});
|
|
152
153
|
```
|
|
153
154
|
|
|
154
155
|
### Authentication Behavior
|
|
155
156
|
|
|
156
157
|
- Indexer authentication is optional. `client.indexer.*` works without auth unless your backend policy requires it.
|
|
157
|
-
-
|
|
158
|
+
- The indexer accepts two auth methods:
|
|
159
|
+
- **Bearer token** — set via `authorizationToken` (static) or `getAuthorizationToken` (per-request). Sent as `Authorization: Bearer <token>`.
|
|
160
|
+
- **Indexer API key** — set via `indexerApiKey`. Sent as `x-api-key: <key>`. Separate from the curator `apiKey`.
|
|
161
|
+
- `authorizationToken` is also used by API adapter methods like `getQuote()`, `getTakerTier()`, and API-backed deposit flows.
|
|
158
162
|
- `getAuthorizationToken` is used by indexer requests (`client.indexer.*`) and is called per request.
|
|
159
|
-
- If both
|
|
163
|
+
- If both bearer and indexer API key are provided, both headers are sent.
|
|
160
164
|
- If `getAuthorizationToken` throws, indexer requests continue without an `Authorization` header.
|
|
161
165
|
- Authenticated requests may receive different limits or entitlements depending on backend policy.
|
|
162
166
|
|
|
@@ -344,6 +344,7 @@ type IndexerClientOptions = {
|
|
|
344
344
|
authorizationToken?: string;
|
|
345
345
|
getAuthorizationToken?: IndexerAuthTokenProvider;
|
|
346
346
|
onAuthorizationTokenError?: (error: unknown) => void;
|
|
347
|
+
apiKey?: string;
|
|
347
348
|
};
|
|
348
349
|
declare class IndexerClient {
|
|
349
350
|
private endpoint;
|
|
@@ -1107,7 +1108,8 @@ type PaymentPlatformType = (typeof PAYMENT_PLATFORMS)[number];
|
|
|
1107
1108
|
* walletClient,
|
|
1108
1109
|
* chainId: 8453, // Base mainnet
|
|
1109
1110
|
* runtimeEnv: 'production',
|
|
1110
|
-
* apiKey: 'your-api-key',
|
|
1111
|
+
* apiKey: 'your-curator-api-key',
|
|
1112
|
+
* indexerApiKey: 'your-indexer-key',
|
|
1111
1113
|
* };
|
|
1112
1114
|
* ```
|
|
1113
1115
|
*/
|
|
@@ -1124,12 +1126,14 @@ type Zkp2pNextOptions = {
|
|
|
1124
1126
|
indexerUrl?: string;
|
|
1125
1127
|
/** Base API URL for ZKP2P services (defaults to https://api.zkp2p.xyz) */
|
|
1126
1128
|
baseApiUrl?: string;
|
|
1127
|
-
/** API key for authenticated endpoints
|
|
1129
|
+
/** Curator API key for authenticated endpoints like createDeposit, signalIntent (sent as x-api-key to curator) */
|
|
1128
1130
|
apiKey?: string;
|
|
1129
1131
|
/** Optional bearer token for hybrid authentication */
|
|
1130
1132
|
authorizationToken?: string;
|
|
1131
1133
|
/** Optional async token provider for indexer auth in long-lived clients */
|
|
1132
1134
|
getAuthorizationToken?: IndexerAuthTokenProvider;
|
|
1135
|
+
/** Optional API key for indexer proxy authentication (sent as x-api-key header) */
|
|
1136
|
+
indexerApiKey?: string;
|
|
1133
1137
|
/** Timeout configuration */
|
|
1134
1138
|
timeouts?: {
|
|
1135
1139
|
/** API call timeout in milliseconds (default: 15000) */
|
|
@@ -344,6 +344,7 @@ type IndexerClientOptions = {
|
|
|
344
344
|
authorizationToken?: string;
|
|
345
345
|
getAuthorizationToken?: IndexerAuthTokenProvider;
|
|
346
346
|
onAuthorizationTokenError?: (error: unknown) => void;
|
|
347
|
+
apiKey?: string;
|
|
347
348
|
};
|
|
348
349
|
declare class IndexerClient {
|
|
349
350
|
private endpoint;
|
|
@@ -1107,7 +1108,8 @@ type PaymentPlatformType = (typeof PAYMENT_PLATFORMS)[number];
|
|
|
1107
1108
|
* walletClient,
|
|
1108
1109
|
* chainId: 8453, // Base mainnet
|
|
1109
1110
|
* runtimeEnv: 'production',
|
|
1110
|
-
* apiKey: 'your-api-key',
|
|
1111
|
+
* apiKey: 'your-curator-api-key',
|
|
1112
|
+
* indexerApiKey: 'your-indexer-key',
|
|
1111
1113
|
* };
|
|
1112
1114
|
* ```
|
|
1113
1115
|
*/
|
|
@@ -1124,12 +1126,14 @@ type Zkp2pNextOptions = {
|
|
|
1124
1126
|
indexerUrl?: string;
|
|
1125
1127
|
/** Base API URL for ZKP2P services (defaults to https://api.zkp2p.xyz) */
|
|
1126
1128
|
baseApiUrl?: string;
|
|
1127
|
-
/** API key for authenticated endpoints
|
|
1129
|
+
/** Curator API key for authenticated endpoints like createDeposit, signalIntent (sent as x-api-key to curator) */
|
|
1128
1130
|
apiKey?: string;
|
|
1129
1131
|
/** Optional bearer token for hybrid authentication */
|
|
1130
1132
|
authorizationToken?: string;
|
|
1131
1133
|
/** Optional async token provider for indexer auth in long-lived clients */
|
|
1132
1134
|
getAuthorizationToken?: IndexerAuthTokenProvider;
|
|
1135
|
+
/** Optional API key for indexer proxy authentication (sent as x-api-key header) */
|
|
1136
|
+
indexerApiKey?: string;
|
|
1133
1137
|
/** Timeout configuration */
|
|
1134
1138
|
timeouts?: {
|
|
1135
1139
|
/** API call timeout in milliseconds (default: 15000) */
|
package/dist/index.cjs
CHANGED
|
@@ -3263,6 +3263,9 @@ var IndexerClient = class {
|
|
|
3263
3263
|
if (token && !headers2.has("Authorization")) {
|
|
3264
3264
|
headers2.set("Authorization", token.startsWith("Bearer ") ? token : `Bearer ${token}`);
|
|
3265
3265
|
}
|
|
3266
|
+
if (this.options.apiKey && !headers2.has("x-api-key")) {
|
|
3267
|
+
headers2.set("x-api-key", this.options.apiKey);
|
|
3268
|
+
}
|
|
3266
3269
|
const res = await fetch(this.endpoint, {
|
|
3267
3270
|
method: "POST",
|
|
3268
3271
|
headers: headers2,
|
|
@@ -4702,7 +4705,8 @@ var Zkp2pClient = class {
|
|
|
4702
4705
|
const indexerEndpoint = opts.indexerUrl ?? defaultIndexerEndpoint(this.runtimeEnv === "staging" ? "STAGING" : "PRODUCTION");
|
|
4703
4706
|
this._indexerClient = new IndexerClient(indexerEndpoint, {
|
|
4704
4707
|
authorizationToken: opts.authorizationToken,
|
|
4705
|
-
getAuthorizationToken: opts.getAuthorizationToken
|
|
4708
|
+
getAuthorizationToken: opts.getAuthorizationToken,
|
|
4709
|
+
apiKey: opts.indexerApiKey
|
|
4706
4710
|
});
|
|
4707
4711
|
this._indexerService = new IndexerDepositService(this._indexerClient);
|
|
4708
4712
|
this.baseApiUrl = opts.baseApiUrl;
|