pinata 2.5.2 → 2.5.3
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.d.mts +99 -1
- package/dist/index.d.ts +99 -1
- package/dist/index.js +639 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +632 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +69 -69
package/dist/index.js
CHANGED
|
@@ -3352,6 +3352,600 @@ var uploadCid = async (config, cid, options) => {
|
|
|
3352
3352
|
}
|
|
3353
3353
|
};
|
|
3354
3354
|
|
|
3355
|
+
// src/core/functions/x402/listPaymentInstructions.ts
|
|
3356
|
+
var listPaymentInstructions = async (config, options) => {
|
|
3357
|
+
if (!config) {
|
|
3358
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3359
|
+
}
|
|
3360
|
+
let headers;
|
|
3361
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3362
|
+
headers = {
|
|
3363
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3364
|
+
"Content-Type": "application/json",
|
|
3365
|
+
...config.customHeaders
|
|
3366
|
+
};
|
|
3367
|
+
} else {
|
|
3368
|
+
headers = {
|
|
3369
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3370
|
+
"Content-Type": "application/json",
|
|
3371
|
+
Source: "sdk/listPaymentInstructions"
|
|
3372
|
+
};
|
|
3373
|
+
}
|
|
3374
|
+
const params = new URLSearchParams();
|
|
3375
|
+
if (options) {
|
|
3376
|
+
const { pageToken, limit, cid, name, id } = options;
|
|
3377
|
+
if (pageToken) params.append("pageToken", pageToken);
|
|
3378
|
+
if (limit !== void 0) params.append("limit", limit.toString());
|
|
3379
|
+
if (cid) params.append("cid", cid);
|
|
3380
|
+
if (name) params.append("name", name);
|
|
3381
|
+
if (id) params.append("id", id);
|
|
3382
|
+
}
|
|
3383
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3384
|
+
if (config.endpointUrl) {
|
|
3385
|
+
endpoint = config.endpointUrl;
|
|
3386
|
+
}
|
|
3387
|
+
try {
|
|
3388
|
+
const request = await fetch(
|
|
3389
|
+
`${endpoint}/x402/payment_instructions?${params.toString()}`,
|
|
3390
|
+
{
|
|
3391
|
+
method: "GET",
|
|
3392
|
+
headers
|
|
3393
|
+
}
|
|
3394
|
+
);
|
|
3395
|
+
if (!request.ok) {
|
|
3396
|
+
const errorData = await request.text();
|
|
3397
|
+
if (request.status === 401 || request.status === 403) {
|
|
3398
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3399
|
+
`Authentication failed: ${errorData}`,
|
|
3400
|
+
request.status,
|
|
3401
|
+
{
|
|
3402
|
+
error: errorData,
|
|
3403
|
+
code: "AUTH_ERROR",
|
|
3404
|
+
metadata: {
|
|
3405
|
+
requestUrl: request.url
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
);
|
|
3409
|
+
}
|
|
3410
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3411
|
+
error: errorData,
|
|
3412
|
+
code: "HTTP_ERROR",
|
|
3413
|
+
metadata: {
|
|
3414
|
+
requestUrl: request.url
|
|
3415
|
+
}
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
const res = await request.json();
|
|
3419
|
+
return res;
|
|
3420
|
+
} catch (error) {
|
|
3421
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3422
|
+
throw error;
|
|
3423
|
+
}
|
|
3424
|
+
if (error instanceof Error) {
|
|
3425
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3426
|
+
`Error processing listPaymentInstructions: ${error.message}`
|
|
3427
|
+
);
|
|
3428
|
+
}
|
|
3429
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3430
|
+
"An unknown error occurred while listing payment instructions"
|
|
3431
|
+
);
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
|
|
3435
|
+
// src/core/functions/x402/createPaymentInstruction.ts
|
|
3436
|
+
var createPaymentInstruction = async (config, request) => {
|
|
3437
|
+
if (!config) {
|
|
3438
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3439
|
+
}
|
|
3440
|
+
if (!request.name) {
|
|
3441
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction name is required");
|
|
3442
|
+
}
|
|
3443
|
+
if (!request.payment_requirements || request.payment_requirements.length === 0) {
|
|
3444
|
+
throw new chunkBK3CLF3Z_js.ValidationError("At least one payment requirement is required");
|
|
3445
|
+
}
|
|
3446
|
+
let headers;
|
|
3447
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3448
|
+
headers = {
|
|
3449
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3450
|
+
"Content-Type": "application/json",
|
|
3451
|
+
...config.customHeaders
|
|
3452
|
+
};
|
|
3453
|
+
} else {
|
|
3454
|
+
headers = {
|
|
3455
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3456
|
+
"Content-Type": "application/json",
|
|
3457
|
+
Source: "sdk/createPaymentInstruction"
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3461
|
+
if (config.endpointUrl) {
|
|
3462
|
+
endpoint = config.endpointUrl;
|
|
3463
|
+
}
|
|
3464
|
+
try {
|
|
3465
|
+
const requestObj = await fetch(`${endpoint}/x402/payment_instructions`, {
|
|
3466
|
+
method: "POST",
|
|
3467
|
+
headers,
|
|
3468
|
+
body: JSON.stringify(request)
|
|
3469
|
+
});
|
|
3470
|
+
if (!requestObj.ok) {
|
|
3471
|
+
const errorData = await requestObj.text();
|
|
3472
|
+
if (requestObj.status === 401 || requestObj.status === 403) {
|
|
3473
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3474
|
+
`Authentication failed: ${errorData}`,
|
|
3475
|
+
requestObj.status,
|
|
3476
|
+
{
|
|
3477
|
+
error: errorData,
|
|
3478
|
+
code: "AUTH_ERROR",
|
|
3479
|
+
metadata: {
|
|
3480
|
+
requestUrl: requestObj.url
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
);
|
|
3484
|
+
}
|
|
3485
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, requestObj.status, {
|
|
3486
|
+
error: errorData,
|
|
3487
|
+
code: "HTTP_ERROR",
|
|
3488
|
+
metadata: {
|
|
3489
|
+
requestUrl: requestObj.url
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
const res = await requestObj.json();
|
|
3494
|
+
return res;
|
|
3495
|
+
} catch (error) {
|
|
3496
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3497
|
+
throw error;
|
|
3498
|
+
}
|
|
3499
|
+
if (error instanceof Error) {
|
|
3500
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3501
|
+
`Error processing createPaymentInstruction: ${error.message}`
|
|
3502
|
+
);
|
|
3503
|
+
}
|
|
3504
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3505
|
+
"An unknown error occurred while creating payment instruction"
|
|
3506
|
+
);
|
|
3507
|
+
}
|
|
3508
|
+
};
|
|
3509
|
+
|
|
3510
|
+
// src/core/functions/x402/getPaymentInstruction.ts
|
|
3511
|
+
var getPaymentInstruction = async (config, id) => {
|
|
3512
|
+
if (!config) {
|
|
3513
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3514
|
+
}
|
|
3515
|
+
if (!id) {
|
|
3516
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3517
|
+
}
|
|
3518
|
+
let headers;
|
|
3519
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3520
|
+
headers = {
|
|
3521
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3522
|
+
"Content-Type": "application/json",
|
|
3523
|
+
...config.customHeaders
|
|
3524
|
+
};
|
|
3525
|
+
} else {
|
|
3526
|
+
headers = {
|
|
3527
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3528
|
+
"Content-Type": "application/json",
|
|
3529
|
+
Source: "sdk/getPaymentInstruction"
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3533
|
+
if (config.endpointUrl) {
|
|
3534
|
+
endpoint = config.endpointUrl;
|
|
3535
|
+
}
|
|
3536
|
+
try {
|
|
3537
|
+
const request = await fetch(`${endpoint}/x402/payment_instructions/${id}`, {
|
|
3538
|
+
method: "GET",
|
|
3539
|
+
headers
|
|
3540
|
+
});
|
|
3541
|
+
if (!request.ok) {
|
|
3542
|
+
const errorData = await request.text();
|
|
3543
|
+
if (request.status === 401 || request.status === 403) {
|
|
3544
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3545
|
+
`Authentication failed: ${errorData}`,
|
|
3546
|
+
request.status,
|
|
3547
|
+
{
|
|
3548
|
+
error: errorData,
|
|
3549
|
+
code: "AUTH_ERROR",
|
|
3550
|
+
metadata: {
|
|
3551
|
+
requestUrl: request.url
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
);
|
|
3555
|
+
}
|
|
3556
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3557
|
+
error: errorData,
|
|
3558
|
+
code: "HTTP_ERROR",
|
|
3559
|
+
metadata: {
|
|
3560
|
+
requestUrl: request.url
|
|
3561
|
+
}
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
const res = await request.json();
|
|
3565
|
+
return res;
|
|
3566
|
+
} catch (error) {
|
|
3567
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3568
|
+
throw error;
|
|
3569
|
+
}
|
|
3570
|
+
if (error instanceof Error) {
|
|
3571
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3572
|
+
`Error processing getPaymentInstruction: ${error.message}`
|
|
3573
|
+
);
|
|
3574
|
+
}
|
|
3575
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3576
|
+
"An unknown error occurred while getting payment instruction"
|
|
3577
|
+
);
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
|
|
3581
|
+
// src/core/functions/x402/updatePaymentInstruction.ts
|
|
3582
|
+
var updatePaymentInstruction = async (config, id, request) => {
|
|
3583
|
+
if (!config) {
|
|
3584
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3585
|
+
}
|
|
3586
|
+
if (!id) {
|
|
3587
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3588
|
+
}
|
|
3589
|
+
let headers;
|
|
3590
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3591
|
+
headers = {
|
|
3592
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3593
|
+
"Content-Type": "application/json",
|
|
3594
|
+
...config.customHeaders
|
|
3595
|
+
};
|
|
3596
|
+
} else {
|
|
3597
|
+
headers = {
|
|
3598
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3599
|
+
"Content-Type": "application/json",
|
|
3600
|
+
Source: "sdk/updatePaymentInstruction"
|
|
3601
|
+
};
|
|
3602
|
+
}
|
|
3603
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3604
|
+
if (config.endpointUrl) {
|
|
3605
|
+
endpoint = config.endpointUrl;
|
|
3606
|
+
}
|
|
3607
|
+
try {
|
|
3608
|
+
const requestObj = await fetch(
|
|
3609
|
+
`${endpoint}/x402/payment_instructions/${id}`,
|
|
3610
|
+
{
|
|
3611
|
+
method: "PATCH",
|
|
3612
|
+
headers,
|
|
3613
|
+
body: JSON.stringify(request)
|
|
3614
|
+
}
|
|
3615
|
+
);
|
|
3616
|
+
if (!requestObj.ok) {
|
|
3617
|
+
const errorData = await requestObj.text();
|
|
3618
|
+
if (requestObj.status === 401 || requestObj.status === 403) {
|
|
3619
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3620
|
+
`Authentication failed: ${errorData}`,
|
|
3621
|
+
requestObj.status,
|
|
3622
|
+
{
|
|
3623
|
+
error: errorData,
|
|
3624
|
+
code: "AUTH_ERROR",
|
|
3625
|
+
metadata: {
|
|
3626
|
+
requestUrl: requestObj.url
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
);
|
|
3630
|
+
}
|
|
3631
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, requestObj.status, {
|
|
3632
|
+
error: errorData,
|
|
3633
|
+
code: "HTTP_ERROR",
|
|
3634
|
+
metadata: {
|
|
3635
|
+
requestUrl: requestObj.url
|
|
3636
|
+
}
|
|
3637
|
+
});
|
|
3638
|
+
}
|
|
3639
|
+
const res = await requestObj.json();
|
|
3640
|
+
return res;
|
|
3641
|
+
} catch (error) {
|
|
3642
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3643
|
+
throw error;
|
|
3644
|
+
}
|
|
3645
|
+
if (error instanceof Error) {
|
|
3646
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3647
|
+
`Error processing updatePaymentInstruction: ${error.message}`
|
|
3648
|
+
);
|
|
3649
|
+
}
|
|
3650
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3651
|
+
"An unknown error occurred while updating payment instruction"
|
|
3652
|
+
);
|
|
3653
|
+
}
|
|
3654
|
+
};
|
|
3655
|
+
|
|
3656
|
+
// src/core/functions/x402/deletePaymentInstruction.ts
|
|
3657
|
+
var deletePaymentInstruction = async (config, id) => {
|
|
3658
|
+
if (!config) {
|
|
3659
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3660
|
+
}
|
|
3661
|
+
if (!id) {
|
|
3662
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3663
|
+
}
|
|
3664
|
+
let headers;
|
|
3665
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3666
|
+
headers = {
|
|
3667
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3668
|
+
"Content-Type": "application/json",
|
|
3669
|
+
...config.customHeaders
|
|
3670
|
+
};
|
|
3671
|
+
} else {
|
|
3672
|
+
headers = {
|
|
3673
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3674
|
+
"Content-Type": "application/json",
|
|
3675
|
+
Source: "sdk/deletePaymentInstruction"
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3679
|
+
if (config.endpointUrl) {
|
|
3680
|
+
endpoint = config.endpointUrl;
|
|
3681
|
+
}
|
|
3682
|
+
try {
|
|
3683
|
+
const request = await fetch(`${endpoint}/x402/payment_instructions/${id}`, {
|
|
3684
|
+
method: "DELETE",
|
|
3685
|
+
headers
|
|
3686
|
+
});
|
|
3687
|
+
if (!request.ok) {
|
|
3688
|
+
const errorData = await request.text();
|
|
3689
|
+
if (request.status === 401 || request.status === 403) {
|
|
3690
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3691
|
+
`Authentication failed: ${errorData}`,
|
|
3692
|
+
request.status,
|
|
3693
|
+
{
|
|
3694
|
+
error: errorData,
|
|
3695
|
+
code: "AUTH_ERROR",
|
|
3696
|
+
metadata: {
|
|
3697
|
+
requestUrl: request.url
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
);
|
|
3701
|
+
}
|
|
3702
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3703
|
+
error: errorData,
|
|
3704
|
+
code: "HTTP_ERROR",
|
|
3705
|
+
metadata: {
|
|
3706
|
+
requestUrl: request.url
|
|
3707
|
+
}
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
const res = await request.json();
|
|
3711
|
+
return res;
|
|
3712
|
+
} catch (error) {
|
|
3713
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3714
|
+
throw error;
|
|
3715
|
+
}
|
|
3716
|
+
if (error instanceof Error) {
|
|
3717
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3718
|
+
`Error processing deletePaymentInstruction: ${error.message}`
|
|
3719
|
+
);
|
|
3720
|
+
}
|
|
3721
|
+
throw new chunkBK3CLF3Z_js.PinataError(
|
|
3722
|
+
"An unknown error occurred while deleting payment instruction"
|
|
3723
|
+
);
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
|
|
3727
|
+
// src/core/functions/x402/listCids.ts
|
|
3728
|
+
var listCids = async (config, paymentInstructionId, options) => {
|
|
3729
|
+
if (!config) {
|
|
3730
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3731
|
+
}
|
|
3732
|
+
if (!paymentInstructionId) {
|
|
3733
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3734
|
+
}
|
|
3735
|
+
let headers;
|
|
3736
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3737
|
+
headers = {
|
|
3738
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3739
|
+
"Content-Type": "application/json",
|
|
3740
|
+
...config.customHeaders
|
|
3741
|
+
};
|
|
3742
|
+
} else {
|
|
3743
|
+
headers = {
|
|
3744
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3745
|
+
"Content-Type": "application/json",
|
|
3746
|
+
Source: "sdk/listCids"
|
|
3747
|
+
};
|
|
3748
|
+
}
|
|
3749
|
+
const params = new URLSearchParams();
|
|
3750
|
+
if (options) {
|
|
3751
|
+
const { pageToken, limit } = options;
|
|
3752
|
+
if (pageToken) params.append("pageToken", pageToken);
|
|
3753
|
+
if (limit !== void 0) params.append("limit", limit.toString());
|
|
3754
|
+
}
|
|
3755
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3756
|
+
if (config.endpointUrl) {
|
|
3757
|
+
endpoint = config.endpointUrl;
|
|
3758
|
+
}
|
|
3759
|
+
try {
|
|
3760
|
+
const request = await fetch(
|
|
3761
|
+
`${endpoint}/x402/payment_instructions/${paymentInstructionId}/cids?${params.toString()}`,
|
|
3762
|
+
{
|
|
3763
|
+
method: "GET",
|
|
3764
|
+
headers
|
|
3765
|
+
}
|
|
3766
|
+
);
|
|
3767
|
+
if (!request.ok) {
|
|
3768
|
+
const errorData = await request.text();
|
|
3769
|
+
if (request.status === 401 || request.status === 403) {
|
|
3770
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3771
|
+
`Authentication failed: ${errorData}`,
|
|
3772
|
+
request.status,
|
|
3773
|
+
{
|
|
3774
|
+
error: errorData,
|
|
3775
|
+
code: "AUTH_ERROR",
|
|
3776
|
+
metadata: {
|
|
3777
|
+
requestUrl: request.url
|
|
3778
|
+
}
|
|
3779
|
+
}
|
|
3780
|
+
);
|
|
3781
|
+
}
|
|
3782
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3783
|
+
error: errorData,
|
|
3784
|
+
code: "HTTP_ERROR",
|
|
3785
|
+
metadata: {
|
|
3786
|
+
requestUrl: request.url
|
|
3787
|
+
}
|
|
3788
|
+
});
|
|
3789
|
+
}
|
|
3790
|
+
const res = await request.json();
|
|
3791
|
+
return res;
|
|
3792
|
+
} catch (error) {
|
|
3793
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3794
|
+
throw error;
|
|
3795
|
+
}
|
|
3796
|
+
if (error instanceof Error) {
|
|
3797
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing listCids: ${error.message}`);
|
|
3798
|
+
}
|
|
3799
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while listing CIDs");
|
|
3800
|
+
}
|
|
3801
|
+
};
|
|
3802
|
+
|
|
3803
|
+
// src/core/functions/x402/addCid.ts
|
|
3804
|
+
var addCid = async (config, paymentInstructionId, cid) => {
|
|
3805
|
+
if (!config) {
|
|
3806
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3807
|
+
}
|
|
3808
|
+
if (!paymentInstructionId) {
|
|
3809
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3810
|
+
}
|
|
3811
|
+
if (!cid) {
|
|
3812
|
+
throw new chunkBK3CLF3Z_js.ValidationError("CID is required");
|
|
3813
|
+
}
|
|
3814
|
+
let headers;
|
|
3815
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3816
|
+
headers = {
|
|
3817
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3818
|
+
"Content-Type": "application/json",
|
|
3819
|
+
...config.customHeaders
|
|
3820
|
+
};
|
|
3821
|
+
} else {
|
|
3822
|
+
headers = {
|
|
3823
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3824
|
+
"Content-Type": "application/json",
|
|
3825
|
+
Source: "sdk/addCid"
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3828
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3829
|
+
if (config.endpointUrl) {
|
|
3830
|
+
endpoint = config.endpointUrl;
|
|
3831
|
+
}
|
|
3832
|
+
try {
|
|
3833
|
+
const request = await fetch(
|
|
3834
|
+
`${endpoint}/x402/payment_instructions/${paymentInstructionId}/cids/${cid}`,
|
|
3835
|
+
{
|
|
3836
|
+
method: "PUT",
|
|
3837
|
+
headers
|
|
3838
|
+
}
|
|
3839
|
+
);
|
|
3840
|
+
if (!request.ok) {
|
|
3841
|
+
const errorData = await request.text();
|
|
3842
|
+
if (request.status === 401 || request.status === 403) {
|
|
3843
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3844
|
+
`Authentication failed: ${errorData}`,
|
|
3845
|
+
request.status,
|
|
3846
|
+
{
|
|
3847
|
+
error: errorData,
|
|
3848
|
+
code: "AUTH_ERROR",
|
|
3849
|
+
metadata: {
|
|
3850
|
+
requestUrl: request.url
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
);
|
|
3854
|
+
}
|
|
3855
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3856
|
+
error: errorData,
|
|
3857
|
+
code: "HTTP_ERROR",
|
|
3858
|
+
metadata: {
|
|
3859
|
+
requestUrl: request.url
|
|
3860
|
+
}
|
|
3861
|
+
});
|
|
3862
|
+
}
|
|
3863
|
+
const res = await request.json();
|
|
3864
|
+
return res;
|
|
3865
|
+
} catch (error) {
|
|
3866
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3867
|
+
throw error;
|
|
3868
|
+
}
|
|
3869
|
+
if (error instanceof Error) {
|
|
3870
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing addCid: ${error.message}`);
|
|
3871
|
+
}
|
|
3872
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while adding CID");
|
|
3873
|
+
}
|
|
3874
|
+
};
|
|
3875
|
+
|
|
3876
|
+
// src/core/functions/x402/removeCid.ts
|
|
3877
|
+
var removeCid = async (config, paymentInstructionId, cid) => {
|
|
3878
|
+
if (!config) {
|
|
3879
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Pinata configuration is missing");
|
|
3880
|
+
}
|
|
3881
|
+
if (!paymentInstructionId) {
|
|
3882
|
+
throw new chunkBK3CLF3Z_js.ValidationError("Payment instruction ID is required");
|
|
3883
|
+
}
|
|
3884
|
+
if (!cid) {
|
|
3885
|
+
throw new chunkBK3CLF3Z_js.ValidationError("CID is required");
|
|
3886
|
+
}
|
|
3887
|
+
let headers;
|
|
3888
|
+
if (config.customHeaders && Object.keys(config.customHeaders).length > 0) {
|
|
3889
|
+
headers = {
|
|
3890
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3891
|
+
"Content-Type": "application/json",
|
|
3892
|
+
...config.customHeaders
|
|
3893
|
+
};
|
|
3894
|
+
} else {
|
|
3895
|
+
headers = {
|
|
3896
|
+
Authorization: `Bearer ${config.pinataJwt}`,
|
|
3897
|
+
"Content-Type": "application/json",
|
|
3898
|
+
Source: "sdk/removeCid"
|
|
3899
|
+
};
|
|
3900
|
+
}
|
|
3901
|
+
let endpoint = "https://api.pinata.cloud/v3";
|
|
3902
|
+
if (config.endpointUrl) {
|
|
3903
|
+
endpoint = config.endpointUrl;
|
|
3904
|
+
}
|
|
3905
|
+
try {
|
|
3906
|
+
const request = await fetch(
|
|
3907
|
+
`${endpoint}/x402/payment_instructions/${paymentInstructionId}/cids/${cid}`,
|
|
3908
|
+
{
|
|
3909
|
+
method: "DELETE",
|
|
3910
|
+
headers
|
|
3911
|
+
}
|
|
3912
|
+
);
|
|
3913
|
+
if (!request.ok) {
|
|
3914
|
+
const errorData = await request.text();
|
|
3915
|
+
if (request.status === 401 || request.status === 403) {
|
|
3916
|
+
throw new chunkBK3CLF3Z_js.AuthenticationError(
|
|
3917
|
+
`Authentication failed: ${errorData}`,
|
|
3918
|
+
request.status,
|
|
3919
|
+
{
|
|
3920
|
+
error: errorData,
|
|
3921
|
+
code: "AUTH_ERROR",
|
|
3922
|
+
metadata: {
|
|
3923
|
+
requestUrl: request.url
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
);
|
|
3927
|
+
}
|
|
3928
|
+
throw new chunkBK3CLF3Z_js.NetworkError(`HTTP error: ${errorData}`, request.status, {
|
|
3929
|
+
error: errorData,
|
|
3930
|
+
code: "HTTP_ERROR",
|
|
3931
|
+
metadata: {
|
|
3932
|
+
requestUrl: request.url
|
|
3933
|
+
}
|
|
3934
|
+
});
|
|
3935
|
+
}
|
|
3936
|
+
const res = await request.json();
|
|
3937
|
+
return res;
|
|
3938
|
+
} catch (error) {
|
|
3939
|
+
if (error instanceof chunkBK3CLF3Z_js.PinataError) {
|
|
3940
|
+
throw error;
|
|
3941
|
+
}
|
|
3942
|
+
if (error instanceof Error) {
|
|
3943
|
+
throw new chunkBK3CLF3Z_js.PinataError(`Error processing removeCid: ${error.message}`);
|
|
3944
|
+
}
|
|
3945
|
+
throw new chunkBK3CLF3Z_js.PinataError("An unknown error occurred while removing CID");
|
|
3946
|
+
}
|
|
3947
|
+
};
|
|
3948
|
+
|
|
3355
3949
|
// src/core/classes/analytics/Analytics.ts
|
|
3356
3950
|
var Analytics = class {
|
|
3357
3951
|
constructor(config) {
|
|
@@ -4689,6 +5283,40 @@ var Signatures = class {
|
|
|
4689
5283
|
}
|
|
4690
5284
|
};
|
|
4691
5285
|
|
|
5286
|
+
// src/core/classes/x402/X402.ts
|
|
5287
|
+
var X402 = class {
|
|
5288
|
+
constructor(config) {
|
|
5289
|
+
this.config = chunkBK3CLF3Z_js.formatConfig(config);
|
|
5290
|
+
}
|
|
5291
|
+
updateConfig(newConfig) {
|
|
5292
|
+
this.config = newConfig;
|
|
5293
|
+
}
|
|
5294
|
+
listPaymentInstructions(options) {
|
|
5295
|
+
return listPaymentInstructions(this.config, options);
|
|
5296
|
+
}
|
|
5297
|
+
createPaymentInstruction(request) {
|
|
5298
|
+
return createPaymentInstruction(this.config, request);
|
|
5299
|
+
}
|
|
5300
|
+
getPaymentInstruction(id) {
|
|
5301
|
+
return getPaymentInstruction(this.config, id);
|
|
5302
|
+
}
|
|
5303
|
+
updatePaymentInstruction(id, request) {
|
|
5304
|
+
return updatePaymentInstruction(this.config, id, request);
|
|
5305
|
+
}
|
|
5306
|
+
deletePaymentInstruction(id) {
|
|
5307
|
+
return deletePaymentInstruction(this.config, id);
|
|
5308
|
+
}
|
|
5309
|
+
listCids(paymentInstructionId, options) {
|
|
5310
|
+
return listCids(this.config, paymentInstructionId, options);
|
|
5311
|
+
}
|
|
5312
|
+
addCid(paymentInstructionId, cid) {
|
|
5313
|
+
return addCid(this.config, paymentInstructionId, cid);
|
|
5314
|
+
}
|
|
5315
|
+
removeCid(paymentInstructionId, cid) {
|
|
5316
|
+
return removeCid(this.config, paymentInstructionId, cid);
|
|
5317
|
+
}
|
|
5318
|
+
};
|
|
5319
|
+
|
|
4692
5320
|
// src/core/pinataSDK.ts
|
|
4693
5321
|
var PinataSDK = class {
|
|
4694
5322
|
constructor(config) {
|
|
@@ -4700,6 +5328,7 @@ var PinataSDK = class {
|
|
|
4700
5328
|
this.groups = new Groups(this.config);
|
|
4701
5329
|
this.analytics = new Analytics(this.config);
|
|
4702
5330
|
this.signatures = new Signatures(this.config);
|
|
5331
|
+
this.x402 = new X402(this.config);
|
|
4703
5332
|
}
|
|
4704
5333
|
setNewHeaders(headers) {
|
|
4705
5334
|
if (!this.config) {
|
|
@@ -4713,6 +5342,7 @@ var PinataSDK = class {
|
|
|
4713
5342
|
this.groups.updateConfig(this.config);
|
|
4714
5343
|
this.analytics.updateConfig(this.config);
|
|
4715
5344
|
this.signatures.updateConfig(this.config);
|
|
5345
|
+
this.x402.updateConfig(this.config);
|
|
4716
5346
|
}
|
|
4717
5347
|
setNewJwt(jwt) {
|
|
4718
5348
|
if (!this.config) {
|
|
@@ -4726,6 +5356,7 @@ var PinataSDK = class {
|
|
|
4726
5356
|
this.groups.updateConfig(this.config);
|
|
4727
5357
|
this.analytics.updateConfig(this.config);
|
|
4728
5358
|
this.signatures.updateConfig(this.config);
|
|
5359
|
+
this.x402.updateConfig(this.config);
|
|
4729
5360
|
}
|
|
4730
5361
|
testAuthentication() {
|
|
4731
5362
|
return testAuthentication(this.config);
|
|
@@ -4765,6 +5396,7 @@ Object.defineProperty(exports, "getFileIdFromUrl", {
|
|
|
4765
5396
|
get: function () { return chunkBK3CLF3Z_js.getFileIdFromUrl; }
|
|
4766
5397
|
});
|
|
4767
5398
|
exports.PinataSDK = PinataSDK;
|
|
5399
|
+
exports.addCid = addCid;
|
|
4768
5400
|
exports.addToGroup = addToGroup;
|
|
4769
5401
|
exports.analyticsDateInterval = analyticsDateInterval;
|
|
4770
5402
|
exports.analyticsTopUsage = analyticsTopUsage;
|
|
@@ -4772,19 +5404,25 @@ exports.convertIPFSUrl = convertIPFSUrl;
|
|
|
4772
5404
|
exports.createAccessLink = createAccessLink;
|
|
4773
5405
|
exports.createGroup = createGroup;
|
|
4774
5406
|
exports.createKey = createKey;
|
|
5407
|
+
exports.createPaymentInstruction = createPaymentInstruction;
|
|
4775
5408
|
exports.createSignedUploadURL = createSignedUploadURL;
|
|
4776
5409
|
exports.deleteFile = deleteFile;
|
|
4777
5410
|
exports.deleteFileVectors = deleteFileVectors;
|
|
4778
5411
|
exports.deleteGroup = deleteGroup;
|
|
5412
|
+
exports.deletePaymentInstruction = deletePaymentInstruction;
|
|
4779
5413
|
exports.deletePinRequest = deletePinRequest;
|
|
4780
5414
|
exports.deleteSwap = deleteSwap;
|
|
4781
5415
|
exports.getCid = getCid;
|
|
4782
5416
|
exports.getGroup = getGroup;
|
|
5417
|
+
exports.getPaymentInstruction = getPaymentInstruction;
|
|
5418
|
+
exports.listCids = listCids;
|
|
4783
5419
|
exports.listFiles = listFiles;
|
|
4784
5420
|
exports.listGroups = listGroups;
|
|
4785
5421
|
exports.listKeys = listKeys;
|
|
5422
|
+
exports.listPaymentInstructions = listPaymentInstructions;
|
|
4786
5423
|
exports.pinnedFileCount = pinnedFileCount;
|
|
4787
5424
|
exports.queue = queue;
|
|
5425
|
+
exports.removeCid = removeCid;
|
|
4788
5426
|
exports.removeFromGroup = removeFromGroup;
|
|
4789
5427
|
exports.revokeKeys = revokeKeys;
|
|
4790
5428
|
exports.swapCid = swapCid;
|
|
@@ -4793,6 +5431,7 @@ exports.testAuthentication = testAuthentication;
|
|
|
4793
5431
|
exports.totalStorageUsage = totalStorageUsage;
|
|
4794
5432
|
exports.updateFile = updateFile;
|
|
4795
5433
|
exports.updateGroup = updateGroup;
|
|
5434
|
+
exports.updatePaymentInstruction = updatePaymentInstruction;
|
|
4796
5435
|
exports.uploadBase64 = uploadBase64;
|
|
4797
5436
|
exports.uploadCid = uploadCid;
|
|
4798
5437
|
exports.uploadFile = uploadFile;
|