@zkp2p/sdk 0.4.2 → 0.5.0
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 +49 -35
- package/dist/index.cjs +128 -224
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +53 -31
- package/dist/index.d.ts +53 -31
- package/dist/index.mjs +127 -225
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/{vaultUtils-Bi2uldoa.d.mts → vaultUtils-BL8tzsmH.d.mts} +59 -13
- package/dist/{vaultUtils-Bi2uldoa.d.ts → vaultUtils-BL8tzsmH.d.ts} +59 -13
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -423,7 +423,7 @@ function normalizeOptionalString(value) {
|
|
|
423
423
|
function normalizeBaseUrl(value, label) {
|
|
424
424
|
const normalized = normalizeOptionalString(value)?.replace(/\/+$/u, "");
|
|
425
425
|
if (!normalized) {
|
|
426
|
-
throw new Error(`${label} is required
|
|
426
|
+
throw new Error(`${label} is required.`);
|
|
427
427
|
}
|
|
428
428
|
return normalized;
|
|
429
429
|
}
|
|
@@ -516,6 +516,35 @@ async function apiVerifyBuyerTeePayment(payload, attestationServiceUrl, platform
|
|
|
516
516
|
return res.json();
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
|
+
async function apiRequestIdentityAttestation(payload, attestationServiceUrl, platform, actionType) {
|
|
520
|
+
return withRetry(async () => {
|
|
521
|
+
let res;
|
|
522
|
+
try {
|
|
523
|
+
const endpoint = "/identity";
|
|
524
|
+
const baseUrl = normalizeBaseUrl(attestationServiceUrl, "Attestation Service URL");
|
|
525
|
+
res = await fetch(`${baseUrl}${endpoint}`, {
|
|
526
|
+
method: "POST",
|
|
527
|
+
headers: headers(),
|
|
528
|
+
body: JSON.stringify({
|
|
529
|
+
platform,
|
|
530
|
+
actionType,
|
|
531
|
+
encryptedSessionMaterial: payload.encryptedSessionMaterial,
|
|
532
|
+
params: payload.params
|
|
533
|
+
})
|
|
534
|
+
});
|
|
535
|
+
} catch (error) {
|
|
536
|
+
throw new NetworkError("Failed to connect to Attestation Service", {
|
|
537
|
+
endpoint: "/identity",
|
|
538
|
+
error
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
if (!res.ok) {
|
|
542
|
+
const errorText = await res.text();
|
|
543
|
+
throw parseAPIError(res, errorText);
|
|
544
|
+
}
|
|
545
|
+
return res.json();
|
|
546
|
+
});
|
|
547
|
+
}
|
|
519
548
|
async function createEncryptedBuyerTeeSessionMaterial({
|
|
520
549
|
actionType,
|
|
521
550
|
attestationRuntime,
|
|
@@ -1352,6 +1381,7 @@ var IntentOperations = class {
|
|
|
1352
1381
|
paymentProof,
|
|
1353
1382
|
data: encodeAddressAsBytes(attestation.responseObject.signer)
|
|
1354
1383
|
});
|
|
1384
|
+
params.callbacks?.onAttestationComplete?.(attestation);
|
|
1355
1385
|
}
|
|
1356
1386
|
const args = [
|
|
1357
1387
|
{
|
|
@@ -3317,6 +3347,7 @@ var INTENT_FULFILLMENTS_QUERY = (
|
|
|
3317
3347
|
query GetFulfilledIntents($intentHashes: [String!]) {
|
|
3318
3348
|
Orchestrator_V21_IntentFulfilled(where: { intentHash: { _in: $intentHashes } }) {
|
|
3319
3349
|
intentHash
|
|
3350
|
+
amount
|
|
3320
3351
|
isManualRelease
|
|
3321
3352
|
fundsTransferredTo
|
|
3322
3353
|
}
|
|
@@ -5352,6 +5383,58 @@ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey)
|
|
|
5352
5383
|
});
|
|
5353
5384
|
return response.responseObject;
|
|
5354
5385
|
}
|
|
5386
|
+
|
|
5387
|
+
// src/sellerCredentials.ts
|
|
5388
|
+
function normalizeBaseApiUrl(value) {
|
|
5389
|
+
return (value?.trim().replace(/\/+$/u, "") || DEFAULT_BASE_API_URL).replace(/\/v1$/u, "");
|
|
5390
|
+
}
|
|
5391
|
+
function assertBundlePlatformMatches(params) {
|
|
5392
|
+
if (params.bundle.platform.toLowerCase() !== params.platform) {
|
|
5393
|
+
throw new Error("Seller credential bundle platform does not match upload platform");
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
5396
|
+
async function apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs) {
|
|
5397
|
+
assertBundlePlatformMatches(params);
|
|
5398
|
+
const normalizedBaseApiUrl = normalizeBaseApiUrl(baseApiUrl);
|
|
5399
|
+
if (params.platform === "wise") {
|
|
5400
|
+
return apiUploadSellerCredential(
|
|
5401
|
+
params.platform,
|
|
5402
|
+
params.bundle.payeeIdHash,
|
|
5403
|
+
params.bundle,
|
|
5404
|
+
normalizedBaseApiUrl,
|
|
5405
|
+
timeoutMs
|
|
5406
|
+
);
|
|
5407
|
+
}
|
|
5408
|
+
const registeredPayeePayload = {
|
|
5409
|
+
offchainId: params.offchainId,
|
|
5410
|
+
processorName: params.platform
|
|
5411
|
+
};
|
|
5412
|
+
if (params.telegramUsername !== void 0) {
|
|
5413
|
+
registeredPayeePayload.telegramUsername = params.telegramUsername;
|
|
5414
|
+
}
|
|
5415
|
+
if (params.metadata !== void 0) {
|
|
5416
|
+
registeredPayeePayload.metadata = params.metadata;
|
|
5417
|
+
}
|
|
5418
|
+
const registeredPayeeResponse = await apiPostDepositDetails(
|
|
5419
|
+
registeredPayeePayload,
|
|
5420
|
+
normalizedBaseApiUrl,
|
|
5421
|
+
timeoutMs
|
|
5422
|
+
);
|
|
5423
|
+
if (!registeredPayeeResponse.success || !registeredPayeeResponse.responseObject) {
|
|
5424
|
+
throw new Error(registeredPayeeResponse.message || "Failed to register seller payee details");
|
|
5425
|
+
}
|
|
5426
|
+
const registeredPayee = registeredPayeeResponse.responseObject;
|
|
5427
|
+
if (registeredPayee.hashedOnchainId.toLowerCase() !== params.bundle.payeeIdHash.toLowerCase()) {
|
|
5428
|
+
throw new Error("Seller credential payee hash does not match registered payee details");
|
|
5429
|
+
}
|
|
5430
|
+
return apiUploadSellerCredential(
|
|
5431
|
+
params.platform,
|
|
5432
|
+
registeredPayee.hashedOnchainId,
|
|
5433
|
+
params.bundle,
|
|
5434
|
+
normalizedBaseApiUrl,
|
|
5435
|
+
timeoutMs
|
|
5436
|
+
);
|
|
5437
|
+
}
|
|
5355
5438
|
var formatTokenAmountForDisplay = (amount, decimals) => {
|
|
5356
5439
|
const formatted = formatUnits(amount, decimals);
|
|
5357
5440
|
if (!formatted.includes(".")) {
|
|
@@ -5496,11 +5579,11 @@ var ERC20_ABI = [
|
|
|
5496
5579
|
];
|
|
5497
5580
|
|
|
5498
5581
|
// src/client/Zkp2pClient.ts
|
|
5499
|
-
function
|
|
5582
|
+
function isObjectRecord(value) {
|
|
5500
5583
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
5501
5584
|
return false;
|
|
5502
5585
|
}
|
|
5503
|
-
return
|
|
5586
|
+
return true;
|
|
5504
5587
|
}
|
|
5505
5588
|
function normalizeTelegramUsername(value) {
|
|
5506
5589
|
if (typeof value !== "string") {
|
|
@@ -5537,7 +5620,7 @@ function normalizeQuotePayeeData(maker) {
|
|
|
5537
5620
|
return {
|
|
5538
5621
|
offchainId,
|
|
5539
5622
|
telegramUsername: normalizeTelegramUsername(maker?.telegramUsername) ?? legacy?.telegramUsername ?? null,
|
|
5540
|
-
metadata:
|
|
5623
|
+
metadata: isObjectRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
|
|
5541
5624
|
};
|
|
5542
5625
|
}
|
|
5543
5626
|
function normalizePayeeDataInputItem(raw) {
|
|
@@ -7239,7 +7322,9 @@ var Zkp2pClient = class {
|
|
|
7239
7322
|
* { limit: 50, orderBy: 'remainingDeposits', orderDirection: 'desc' }
|
|
7240
7323
|
* );
|
|
7241
7324
|
*
|
|
7242
|
-
* // Get historical fulfillment data
|
|
7325
|
+
* // Get historical fulfillment event data. Use `amount` for net USDC
|
|
7326
|
+
* // transferred to the taker; use getIntentFulfillmentAmounts() when you
|
|
7327
|
+
* // also need gross released USDC.
|
|
7243
7328
|
* const fulfillments = await client.indexer.getFulfilledIntentEvents(['0x...']);
|
|
7244
7329
|
* ```
|
|
7245
7330
|
*/
|
|
@@ -7301,13 +7386,15 @@ var Zkp2pClient = class {
|
|
|
7301
7386
|
return service.fetchExpiredIntents(params);
|
|
7302
7387
|
},
|
|
7303
7388
|
/**
|
|
7304
|
-
* Fetches fulfillment events for completed intents.
|
|
7389
|
+
* Fetches fulfillment events for completed intents. `amount` is the net
|
|
7390
|
+
* USDC transferred to the taker after protocol/referrer fees.
|
|
7305
7391
|
*/
|
|
7306
7392
|
getFulfilledIntentEvents: (intentHashes) => {
|
|
7307
7393
|
return service.fetchFulfilledIntentEvents(intentHashes);
|
|
7308
7394
|
},
|
|
7309
7395
|
/**
|
|
7310
|
-
* Fetches gross and net fulfillment amounts for an intent.
|
|
7396
|
+
* Fetches gross and net fulfillment amounts for an intent. Use
|
|
7397
|
+
* `takerAmountNetFees` as the buyer/taker received USDC amount.
|
|
7311
7398
|
*/
|
|
7312
7399
|
getIntentFulfillmentAmounts: (intentHash) => {
|
|
7313
7400
|
return service.fetchIntentFulfillmentAmounts(intentHash);
|
|
@@ -7925,14 +8012,14 @@ var Zkp2pClient = class {
|
|
|
7925
8012
|
const attestationServiceUrl = this.stripTrailingSlash(
|
|
7926
8013
|
opts?.attestationServiceUrl ?? this.defaultAttestationServiceForBaseApiUrl(baseApiUrl)
|
|
7927
8014
|
);
|
|
7928
|
-
const createBundle = (
|
|
7929
|
-
|
|
8015
|
+
const createBundle = (uploadPayload) => opts?.attestationRuntime ? apiCreateSellerCredentialBundle(
|
|
8016
|
+
uploadPayload,
|
|
7930
8017
|
attestationServiceUrl,
|
|
7931
8018
|
params.platform,
|
|
7932
8019
|
timeoutMs,
|
|
7933
8020
|
opts.attestationRuntime
|
|
7934
8021
|
) : apiCreateSellerCredentialBundle(
|
|
7935
|
-
|
|
8022
|
+
uploadPayload,
|
|
7936
8023
|
attestationServiceUrl,
|
|
7937
8024
|
params.platform,
|
|
7938
8025
|
timeoutMs
|
|
@@ -7944,51 +8031,42 @@ var Zkp2pClient = class {
|
|
|
7944
8031
|
if (!bundleResponse2.success || !bundleResponse2.responseObject) {
|
|
7945
8032
|
throw new Error(bundleResponse2.message || "Failed to create seller credential bundle");
|
|
7946
8033
|
}
|
|
7947
|
-
return
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
timeoutMs
|
|
8034
|
+
return this.uploadSellerCredentialBundle(
|
|
8035
|
+
{
|
|
8036
|
+
bundle: bundleResponse2.responseObject,
|
|
8037
|
+
platform: params.platform
|
|
8038
|
+
},
|
|
8039
|
+
{ baseApiUrl, timeoutMs }
|
|
7953
8040
|
);
|
|
7954
8041
|
}
|
|
7955
|
-
const
|
|
7956
|
-
offchainId: params.offchainId,
|
|
7957
|
-
processorName: params.platform
|
|
7958
|
-
};
|
|
7959
|
-
if (params.telegramUsername !== void 0) {
|
|
7960
|
-
registeredPayeePayload.telegramUsername = params.telegramUsername;
|
|
7961
|
-
}
|
|
7962
|
-
if (params.metadata !== void 0) {
|
|
7963
|
-
registeredPayeePayload.metadata = params.metadata;
|
|
7964
|
-
}
|
|
7965
|
-
const registeredPayeeResponse = await apiPostDepositDetails(
|
|
7966
|
-
registeredPayeePayload,
|
|
7967
|
-
baseApiUrl,
|
|
7968
|
-
timeoutMs
|
|
7969
|
-
);
|
|
7970
|
-
if (!registeredPayeeResponse.success || !registeredPayeeResponse.responseObject) {
|
|
7971
|
-
throw new Error(registeredPayeeResponse.message || "Failed to register seller payee details");
|
|
7972
|
-
}
|
|
7973
|
-
const uploadPayload = {
|
|
8042
|
+
const bundlePayload = {
|
|
7974
8043
|
payeeId: params.payeeId,
|
|
7975
8044
|
sessionMaterial: params.sessionMaterial
|
|
7976
8045
|
};
|
|
7977
|
-
const bundleResponse = await createBundle(
|
|
8046
|
+
const bundleResponse = await createBundle(bundlePayload);
|
|
7978
8047
|
if (!bundleResponse.success || !bundleResponse.responseObject) {
|
|
7979
8048
|
throw new Error(bundleResponse.message || "Failed to create seller credential bundle");
|
|
7980
8049
|
}
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
baseApiUrl,
|
|
7990
|
-
|
|
8050
|
+
return this.uploadSellerCredentialBundle(
|
|
8051
|
+
{
|
|
8052
|
+
bundle: bundleResponse.responseObject,
|
|
8053
|
+
offchainId: params.offchainId,
|
|
8054
|
+
platform: params.platform,
|
|
8055
|
+
...params.telegramUsername !== void 0 ? { telegramUsername: params.telegramUsername } : {},
|
|
8056
|
+
...params.metadata !== void 0 ? { metadata: params.metadata } : {}
|
|
8057
|
+
},
|
|
8058
|
+
{ baseApiUrl, timeoutMs }
|
|
8059
|
+
);
|
|
8060
|
+
}
|
|
8061
|
+
/**
|
|
8062
|
+
* Store an already-encrypted seller credential bundle with curator.
|
|
8063
|
+
*/
|
|
8064
|
+
async uploadSellerCredentialBundle(params, opts) {
|
|
8065
|
+
const baseApiUrl = this.stripTrailingSlash(
|
|
8066
|
+
opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
|
|
7991
8067
|
);
|
|
8068
|
+
const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
|
|
8069
|
+
return apiUploadSellerCredentialBundle(params, baseApiUrl, timeoutMs);
|
|
7992
8070
|
}
|
|
7993
8071
|
/**
|
|
7994
8072
|
* Confirms the PayPal Gmail-forwarding setup for an existing maker payee hash.
|
|
@@ -8287,189 +8365,13 @@ var getPeerExtensionState = async (options) => {
|
|
|
8287
8365
|
return "needs_connection";
|
|
8288
8366
|
}
|
|
8289
8367
|
};
|
|
8290
|
-
var fiatAmountRegex = /^-?\d*(\.\d{0,6})?$/;
|
|
8291
|
-
var usdcAmountRegex = /^\d+$/;
|
|
8292
|
-
var assertObjectInput = (params) => {
|
|
8293
|
-
if (params === void 0) {
|
|
8294
|
-
throw new Error("Peer extension onramp requires query params with intentHash.");
|
|
8295
|
-
}
|
|
8296
|
-
if (params === null || typeof params !== "object" || Array.isArray(params)) {
|
|
8297
|
-
throw new Error("Peer extension onramp expects an object of query params.");
|
|
8298
|
-
}
|
|
8299
|
-
return params;
|
|
8300
|
-
};
|
|
8301
|
-
var normalizeOptionalString2 = (value, label) => {
|
|
8302
|
-
if (value === void 0) {
|
|
8303
|
-
return void 0;
|
|
8304
|
-
}
|
|
8305
|
-
if (typeof value !== "string") {
|
|
8306
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
8307
|
-
}
|
|
8308
|
-
const trimmed = value.trim();
|
|
8309
|
-
if (!trimmed) {
|
|
8310
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty string.`);
|
|
8311
|
-
}
|
|
8312
|
-
return trimmed;
|
|
8313
|
-
};
|
|
8314
|
-
var normalizeOptionalUrl = (value, label) => {
|
|
8315
|
-
const trimmed = normalizeOptionalString2(value, label);
|
|
8316
|
-
if (trimmed === void 0) {
|
|
8317
|
-
return void 0;
|
|
8318
|
-
}
|
|
8319
|
-
let parsed;
|
|
8320
|
-
try {
|
|
8321
|
-
parsed = new URL(trimmed);
|
|
8322
|
-
} catch (error) {
|
|
8323
|
-
throw new Error(`Peer extension onramp ${label} must be a valid URL.`);
|
|
8324
|
-
}
|
|
8325
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
8326
|
-
throw new Error(`Peer extension onramp ${label} must use http or https.`);
|
|
8327
|
-
}
|
|
8328
|
-
return trimmed;
|
|
8329
|
-
};
|
|
8330
|
-
var normalizeFiatAmount = (value) => {
|
|
8331
|
-
if (value === void 0) {
|
|
8332
|
-
return void 0;
|
|
8333
|
-
}
|
|
8334
|
-
const normalized = typeof value === "number" ? String(value) : value;
|
|
8335
|
-
if (typeof normalized !== "string") {
|
|
8336
|
-
throw new Error("Peer extension onramp inputAmount must be a string or number.");
|
|
8337
|
-
}
|
|
8338
|
-
const trimmed = normalized.trim();
|
|
8339
|
-
if (!trimmed) {
|
|
8340
|
-
throw new Error("Peer extension onramp inputAmount must be a non-empty value.");
|
|
8341
|
-
}
|
|
8342
|
-
if (!fiatAmountRegex.test(trimmed)) {
|
|
8343
|
-
throw new Error(
|
|
8344
|
-
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
8345
|
-
);
|
|
8346
|
-
}
|
|
8347
|
-
if (Number.isNaN(Number(trimmed)) || Number(trimmed) < 0) {
|
|
8348
|
-
throw new Error(
|
|
8349
|
-
"Peer extension onramp inputAmount must be a non-negative number with up to 6 decimals."
|
|
8350
|
-
);
|
|
8351
|
-
}
|
|
8352
|
-
return trimmed;
|
|
8353
|
-
};
|
|
8354
|
-
var normalizeUsdcAmount = (value) => {
|
|
8355
|
-
if (value === void 0) {
|
|
8356
|
-
return void 0;
|
|
8357
|
-
}
|
|
8358
|
-
if (typeof value === "bigint") {
|
|
8359
|
-
if (value < 0n) {
|
|
8360
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
8361
|
-
}
|
|
8362
|
-
return value.toString();
|
|
8363
|
-
}
|
|
8364
|
-
if (typeof value === "number") {
|
|
8365
|
-
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
8366
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
8367
|
-
}
|
|
8368
|
-
return String(value);
|
|
8369
|
-
}
|
|
8370
|
-
if (typeof value !== "string") {
|
|
8371
|
-
throw new Error("Peer extension onramp amountUsdc must be a string, number, or bigint.");
|
|
8372
|
-
}
|
|
8373
|
-
const trimmed = value.trim();
|
|
8374
|
-
if (!trimmed) {
|
|
8375
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-empty value.");
|
|
8376
|
-
}
|
|
8377
|
-
if (!usdcAmountRegex.test(trimmed)) {
|
|
8378
|
-
throw new Error("Peer extension onramp amountUsdc must be a non-negative integer.");
|
|
8379
|
-
}
|
|
8380
|
-
return trimmed;
|
|
8381
|
-
};
|
|
8382
|
-
var normalizeIntegerParam = (value, label) => {
|
|
8383
|
-
if (value === void 0) {
|
|
8384
|
-
return void 0;
|
|
8385
|
-
}
|
|
8386
|
-
if (typeof value === "bigint") {
|
|
8387
|
-
if (value < 0n) {
|
|
8388
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
8389
|
-
}
|
|
8390
|
-
return value.toString();
|
|
8391
|
-
}
|
|
8392
|
-
if (typeof value === "number") {
|
|
8393
|
-
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
8394
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
8395
|
-
}
|
|
8396
|
-
if (!Number.isSafeInteger(value)) {
|
|
8397
|
-
throw new Error(
|
|
8398
|
-
`Peer extension onramp ${label} number input must be a safe integer; pass a string or bigint for larger values.`
|
|
8399
|
-
);
|
|
8400
|
-
}
|
|
8401
|
-
return String(value);
|
|
8402
|
-
}
|
|
8403
|
-
if (typeof value !== "string") {
|
|
8404
|
-
throw new Error(`Peer extension onramp ${label} must be a string, number, or bigint.`);
|
|
8405
|
-
}
|
|
8406
|
-
const trimmed = value.trim();
|
|
8407
|
-
if (!trimmed) {
|
|
8408
|
-
throw new Error(`Peer extension onramp ${label} must be a non-empty value.`);
|
|
8409
|
-
}
|
|
8410
|
-
if (!/^\d+$/.test(trimmed)) {
|
|
8411
|
-
throw new Error(`Peer extension onramp ${label} must be a non-negative integer.`);
|
|
8412
|
-
}
|
|
8413
|
-
return trimmed;
|
|
8414
|
-
};
|
|
8415
|
-
var intentHashRegex = /^0x[a-fA-F0-9]{64}$/;
|
|
8416
|
-
var normalizeIntentHash = (value) => {
|
|
8417
|
-
if (value === void 0) {
|
|
8418
|
-
throw new Error("Peer extension onramp intentHash is required.");
|
|
8419
|
-
}
|
|
8420
|
-
if (typeof value !== "string") {
|
|
8421
|
-
throw new Error("Peer extension onramp intentHash must be a string.");
|
|
8422
|
-
}
|
|
8423
|
-
const trimmed = value.trim();
|
|
8424
|
-
if (!trimmed) {
|
|
8425
|
-
throw new Error("Peer extension onramp intentHash must be a non-empty string.");
|
|
8426
|
-
}
|
|
8427
|
-
if (!intentHashRegex.test(trimmed)) {
|
|
8428
|
-
throw new Error(
|
|
8429
|
-
"Peer extension onramp intentHash must be a valid bytes32 hex string (0x + 64 hex characters)."
|
|
8430
|
-
);
|
|
8431
|
-
}
|
|
8432
|
-
return trimmed.toLowerCase();
|
|
8433
|
-
};
|
|
8434
|
-
var buildOnrampQueryString = (params) => {
|
|
8435
|
-
const validated = assertObjectInput(params);
|
|
8436
|
-
const searchParams = new URLSearchParams();
|
|
8437
|
-
const setParam = (key, value) => {
|
|
8438
|
-
if (value !== void 0) {
|
|
8439
|
-
searchParams.set(key, value);
|
|
8440
|
-
}
|
|
8441
|
-
};
|
|
8442
|
-
setParam("referrer", normalizeOptionalString2(validated.referrer, "referrer"));
|
|
8443
|
-
setParam("referrerLogo", normalizeOptionalUrl(validated.referrerLogo, "referrerLogo"));
|
|
8444
|
-
setParam("inputCurrency", normalizeOptionalString2(validated.inputCurrency, "inputCurrency"));
|
|
8445
|
-
setParam("inputAmount", normalizeFiatAmount(validated.inputAmount));
|
|
8446
|
-
setParam(
|
|
8447
|
-
"paymentPlatform",
|
|
8448
|
-
normalizeOptionalString2(validated.paymentPlatform, "paymentPlatform")
|
|
8449
|
-
);
|
|
8450
|
-
setParam("depositId", normalizeIntegerParam(validated.depositId, "depositId"));
|
|
8451
|
-
setParam("toToken", normalizeOptionalString2(validated.toToken, "toToken"));
|
|
8452
|
-
setParam("amountUsdc", normalizeUsdcAmount(validated.amountUsdc));
|
|
8453
|
-
setParam(
|
|
8454
|
-
"recipientAddress",
|
|
8455
|
-
normalizeOptionalString2(validated.recipientAddress, "recipientAddress")
|
|
8456
|
-
);
|
|
8457
|
-
setParam("intentHash", normalizeIntentHash(validated.intentHash));
|
|
8458
|
-
return searchParams.toString();
|
|
8459
|
-
};
|
|
8460
8368
|
var createPeerExtensionSdk = (options = {}) => ({
|
|
8461
8369
|
isAvailable: () => isPeerExtensionAvailable(options),
|
|
8462
8370
|
requestConnection: () => requirePeer(options).requestConnection(),
|
|
8463
8371
|
checkConnectionStatus: () => requirePeer(options).checkConnectionStatus(),
|
|
8464
|
-
openSidebar: (route) => requirePeer(options).openSidebar(route),
|
|
8465
|
-
onramp: (params, callback) => {
|
|
8466
|
-
if (typeof callback !== "function") {
|
|
8467
|
-
throw new Error("Peer extension onramp callback is required.");
|
|
8468
|
-
}
|
|
8469
|
-
requirePeer(options).onramp(buildOnrampQueryString(params), callback);
|
|
8470
|
-
},
|
|
8471
|
-
getOnrampTransaction: (intentHash) => requirePeer(options).getOnrampTransaction(normalizeIntentHash(intentHash)),
|
|
8472
8372
|
getVersion: () => requirePeer(options).getVersion(),
|
|
8373
|
+
authenticate: (params) => requirePeer(options).authenticate(params),
|
|
8374
|
+
onMetadataMessage: (callback) => requirePeer(options).onMetadataMessage(callback),
|
|
8473
8375
|
openInstallPage: () => openPeerExtensionInstallPage(options),
|
|
8474
8376
|
getState: () => getPeerExtensionState(options)
|
|
8475
8377
|
});
|
|
@@ -8513,6 +8415,6 @@ var logger = {
|
|
|
8513
8415
|
}
|
|
8514
8416
|
};
|
|
8515
8417
|
|
|
8516
|
-
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiConfirmPayPalForwarding, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiUploadGoogleOAuthSellerCredential, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
8418
|
+
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiConfirmPayPalForwarding, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiRequestIdentityAttestation, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
8517
8419
|
//# sourceMappingURL=index.mjs.map
|
|
8518
8420
|
//# sourceMappingURL=index.mjs.map
|