@peable.to/sdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WEBHOOK_SIGNATURE_HEADER = exports.PeableSignatureVerificationError = exports.PeableApiError = exports.PeablePermissionError = exports.PeableInvalidRequestError = exports.PeableAuthenticationError = exports.PeableError = exports.DEFAULT_OXY_API_URL = exports.DEFAULT_GATEWAY_BASE_URL = exports.Peable = void 0;
|
|
3
|
+
exports.WebhooksResource = exports.WEBHOOK_SIGNATURE_HEADER = exports.PeableSignatureVerificationError = exports.PeableApiError = exports.PeablePermissionError = exports.PeableInvalidRequestError = exports.PeableAuthenticationError = exports.PeableError = exports.DEFAULT_OXY_API_URL = exports.DEFAULT_GATEWAY_BASE_URL = exports.Peable = void 0;
|
|
4
4
|
const billing_1 = require("./resources/billing");
|
|
5
5
|
// Server entry (`@peable.to/sdk`) — the merchant-authed SDK. Configured with a
|
|
6
6
|
// confidential `ApplicationCredential` (`{publicKey, secret}`); mints and
|
|
@@ -66,3 +66,4 @@ Object.defineProperty(exports, "PeableApiError", { enumerable: true, get: functi
|
|
|
66
66
|
Object.defineProperty(exports, "PeableSignatureVerificationError", { enumerable: true, get: function () { return errors_1.PeableSignatureVerificationError; } });
|
|
67
67
|
var webhooks_2 = require("./resources/webhooks");
|
|
68
68
|
Object.defineProperty(exports, "WEBHOOK_SIGNATURE_HEADER", { enumerable: true, get: function () { return webhooks_2.WEBHOOK_SIGNATURE_HEADER; } });
|
|
69
|
+
Object.defineProperty(exports, "WebhooksResource", { enumerable: true, get: function () { return webhooks_2.WebhooksResource; } });
|
|
@@ -7,13 +7,21 @@ const errors_1 = require("../core/errors");
|
|
|
7
7
|
exports.WEBHOOK_SIGNATURE_HEADER = 'Peable-Signature';
|
|
8
8
|
/** Default replay-tolerance window, matching the backend's own tests/usage. */
|
|
9
9
|
const DEFAULT_TOLERANCE_SEC = 300;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'payment_intent.
|
|
15
|
-
'payment_intent.
|
|
16
|
-
|
|
10
|
+
// Exhaustive against the published union: adding a backend event makes this
|
|
11
|
+
// fail compilation until the SDK accepts it. Own-key lookup excludes prototype
|
|
12
|
+
// names supplied by an untrusted, even correctly signed, payload.
|
|
13
|
+
const WEBHOOK_EVENT_TYPES = {
|
|
14
|
+
'payment_intent.confirming': true,
|
|
15
|
+
'payment_intent.settled': true,
|
|
16
|
+
'payment_intent.failed': true,
|
|
17
|
+
'payment_intent.rejected': true,
|
|
18
|
+
'payment_intent.expired': true,
|
|
19
|
+
'payment_intent.refunded': true,
|
|
20
|
+
'payment_intent.partially_refunded': true,
|
|
21
|
+
'payment_intent.disputed': true,
|
|
22
|
+
'payment_intent.dispute_closed': true,
|
|
23
|
+
'connected_account.updated': true,
|
|
24
|
+
};
|
|
17
25
|
/**
|
|
18
26
|
* Structural guard for the parsed payload — the signature already proves the
|
|
19
27
|
* bytes were produced by `signWebhook` on the SAME secret, but a caller could
|
|
@@ -27,7 +35,7 @@ function isWebhookEventShape(value) {
|
|
|
27
35
|
return (typeof candidate.id === 'string' &&
|
|
28
36
|
candidate.object === 'event' &&
|
|
29
37
|
typeof candidate.type === 'string' &&
|
|
30
|
-
|
|
38
|
+
Object.prototype.hasOwnProperty.call(WEBHOOK_EVENT_TYPES, candidate.type) &&
|
|
31
39
|
typeof candidate.created === 'string' &&
|
|
32
40
|
typeof candidate.data === 'object' &&
|
|
33
41
|
candidate.data !== null &&
|
package/dist/esm/index.js
CHANGED
|
@@ -52,4 +52,4 @@ export class Peable {
|
|
|
52
52
|
}
|
|
53
53
|
export { DEFAULT_GATEWAY_BASE_URL, DEFAULT_OXY_API_URL } from './core/config.js';
|
|
54
54
|
export { PeableError, PeableAuthenticationError, PeableInvalidRequestError, PeablePermissionError, PeableApiError, PeableSignatureVerificationError, } from './core/errors.js';
|
|
55
|
-
export { WEBHOOK_SIGNATURE_HEADER } from './resources/webhooks.js';
|
|
55
|
+
export { WEBHOOK_SIGNATURE_HEADER, WebhooksResource } from './resources/webhooks.js';
|
|
@@ -4,13 +4,21 @@ import { PeableSignatureVerificationError } from '../core/errors.js';
|
|
|
4
4
|
export const WEBHOOK_SIGNATURE_HEADER = 'Peable-Signature';
|
|
5
5
|
/** Default replay-tolerance window, matching the backend's own tests/usage. */
|
|
6
6
|
const DEFAULT_TOLERANCE_SEC = 300;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'payment_intent.
|
|
12
|
-
'payment_intent.
|
|
13
|
-
|
|
7
|
+
// Exhaustive against the published union: adding a backend event makes this
|
|
8
|
+
// fail compilation until the SDK accepts it. Own-key lookup excludes prototype
|
|
9
|
+
// names supplied by an untrusted, even correctly signed, payload.
|
|
10
|
+
const WEBHOOK_EVENT_TYPES = {
|
|
11
|
+
'payment_intent.confirming': true,
|
|
12
|
+
'payment_intent.settled': true,
|
|
13
|
+
'payment_intent.failed': true,
|
|
14
|
+
'payment_intent.rejected': true,
|
|
15
|
+
'payment_intent.expired': true,
|
|
16
|
+
'payment_intent.refunded': true,
|
|
17
|
+
'payment_intent.partially_refunded': true,
|
|
18
|
+
'payment_intent.disputed': true,
|
|
19
|
+
'payment_intent.dispute_closed': true,
|
|
20
|
+
'connected_account.updated': true,
|
|
21
|
+
};
|
|
14
22
|
/**
|
|
15
23
|
* Structural guard for the parsed payload — the signature already proves the
|
|
16
24
|
* bytes were produced by `signWebhook` on the SAME secret, but a caller could
|
|
@@ -24,7 +32,7 @@ function isWebhookEventShape(value) {
|
|
|
24
32
|
return (typeof candidate.id === 'string' &&
|
|
25
33
|
candidate.object === 'event' &&
|
|
26
34
|
typeof candidate.type === 'string' &&
|
|
27
|
-
|
|
35
|
+
Object.prototype.hasOwnProperty.call(WEBHOOK_EVENT_TYPES, candidate.type) &&
|
|
28
36
|
typeof candidate.created === 'string' &&
|
|
29
37
|
typeof candidate.data === 'object' &&
|
|
30
38
|
candidate.data !== null &&
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,5 +57,5 @@ export type { DisputeEvidenceParams, DisputeList, RegisterMerchantParams, Update
|
|
|
57
57
|
export type { CreateRefundParams, RefundList } from './resources/refunds';
|
|
58
58
|
export type { CreateTransferParams, ReverseTransferParams, TransferList, } from './resources/transfers';
|
|
59
59
|
export type { PaymentLinkListParams, PaymentLinkList, UpdatePaymentLinkParams, } from './resources/paymentLinks';
|
|
60
|
-
export { WEBHOOK_SIGNATURE_HEADER } from './resources/webhooks';
|
|
60
|
+
export { WEBHOOK_SIGNATURE_HEADER, WebhooksResource } from './resources/webhooks';
|
|
61
61
|
export type { ConstructEventOptions } from './resources/webhooks';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peable.to/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Peable SDK — a Stripe-ergonomics TypeScript client over the Peable Gateway REST + realtime contract. Server entry (`@peable.to/sdk`) mints Oxy service tokens from an ApplicationCredential and exposes paymentIntents/paymentLinks/checkout.sessions/webhooks; browser entry (`@peable.to/sdk/checkout`) is the anonymous payer-side client core.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|