@proxy-checkout/server-js 0.0.5-prx-93.47.1 → 0.0.6-prx-93.48.1
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/errors.d.cts +1 -1
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/version.d.cts +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/webhook-handler.d.cts +3 -2
- package/dist/cjs/webhook-handler.d.ts +3 -2
- package/dist/cjs/webhook-handler.js +11 -2
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +1 -1
- package/dist/esm/webhook-handler.d.ts +3 -2
- package/dist/esm/webhook-handler.js +11 -2
- package/package.json +1 -1
package/dist/cjs/errors.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ProxyCheckoutApiErrorDetails {
|
|
|
4
4
|
readonly responseBody: unknown;
|
|
5
5
|
readonly statusCode: number;
|
|
6
6
|
}
|
|
7
|
-
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch";
|
|
7
|
+
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch" | "webhook_sessions_resource_missing";
|
|
8
8
|
/**
|
|
9
9
|
* Raised when the SDK receives Proxy data it cannot safely normalize, for
|
|
10
10
|
* example an invalid date string, a cart snapshot that fails the merchant
|
package/dist/cjs/errors.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ProxyCheckoutApiErrorDetails {
|
|
|
4
4
|
readonly responseBody: unknown;
|
|
5
5
|
readonly statusCode: number;
|
|
6
6
|
}
|
|
7
|
-
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch";
|
|
7
|
+
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch" | "webhook_sessions_resource_missing";
|
|
8
8
|
/**
|
|
9
9
|
* Raised when the SDK receives Proxy data it cannot safely normalize, for
|
|
10
10
|
* example an invalid date string, a cart snapshot that fails the merchant
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export declare const proxyCheckoutServerSdkVersion = "0.0.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.0.6-prx-93.48.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.6-prx-93.48.1";
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export declare const proxyCheckoutServerSdkVersion = "0.0.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.0.6-prx-93.48.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.6-prx-93.48.1";
|
package/dist/cjs/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.proxyCheckoutServerSdkUserAgent = exports.proxyCheckoutServerSdkVersion = exports.proxyCheckoutServerSdkName = void 0;
|
|
4
4
|
exports.proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
5
|
-
exports.proxyCheckoutServerSdkVersion = "0.0.
|
|
5
|
+
exports.proxyCheckoutServerSdkVersion = "0.0.6-prx-93.48.1";
|
|
6
6
|
exports.proxyCheckoutServerSdkUserAgent = `${exports.proxyCheckoutServerSdkName}/${exports.proxyCheckoutServerSdkVersion}`;
|
|
@@ -76,8 +76,8 @@ export interface ProxyWebhookProcessResult {
|
|
|
76
76
|
}
|
|
77
77
|
export declare class ProxyWebhooksResource {
|
|
78
78
|
private readonly events;
|
|
79
|
-
private readonly sessions
|
|
80
|
-
constructor(events: ProxyEventsResource, sessions
|
|
79
|
+
private readonly sessions?;
|
|
80
|
+
constructor(events: ProxyEventsResource, sessions?: Pick<ProxySessionsResource, "markProvisioned" | "markProvisioningFailed"> | undefined);
|
|
81
81
|
/** Low-level: verify + construct the event without resolving lifecycle. */
|
|
82
82
|
constructEvent(input: {
|
|
83
83
|
body: Buffer | string;
|
|
@@ -100,4 +100,5 @@ export declare class ProxyWebhooksResource {
|
|
|
100
100
|
*/
|
|
101
101
|
handle(input: ProxyWebhookRequestInput, options: ProxyWebhookHandlerOptions): Promise<Response>;
|
|
102
102
|
private runResolvedHandler;
|
|
103
|
+
private requireSessionsResource;
|
|
103
104
|
}
|
|
@@ -76,8 +76,8 @@ export interface ProxyWebhookProcessResult {
|
|
|
76
76
|
}
|
|
77
77
|
export declare class ProxyWebhooksResource {
|
|
78
78
|
private readonly events;
|
|
79
|
-
private readonly sessions
|
|
80
|
-
constructor(events: ProxyEventsResource, sessions
|
|
79
|
+
private readonly sessions?;
|
|
80
|
+
constructor(events: ProxyEventsResource, sessions?: Pick<ProxySessionsResource, "markProvisioned" | "markProvisioningFailed"> | undefined);
|
|
81
81
|
/** Low-level: verify + construct the event without resolving lifecycle. */
|
|
82
82
|
constructEvent(input: {
|
|
83
83
|
body: Buffer | string;
|
|
@@ -100,4 +100,5 @@ export declare class ProxyWebhooksResource {
|
|
|
100
100
|
*/
|
|
101
101
|
handle(input: ProxyWebhookRequestInput, options: ProxyWebhookHandlerOptions): Promise<Response>;
|
|
102
102
|
private runResolvedHandler;
|
|
103
|
+
private requireSessionsResource;
|
|
103
104
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ProxyWebhooksResource = exports.PROXY_WEBHOOK_RETRY_AFTER_SECONDS = void 0;
|
|
13
|
+
const errors_js_1 = require("./errors.js");
|
|
13
14
|
const webhooks_js_1 = require("./webhooks.js");
|
|
14
15
|
/** Seconds advertised in `Retry-After` when an event is already in flight. */
|
|
15
16
|
exports.PROXY_WEBHOOK_RETRY_AFTER_SECONDS = 30;
|
|
@@ -65,7 +66,7 @@ class ProxyWebhooksResource {
|
|
|
65
66
|
resolved = await this.events.resolveCurrentState(event, { requestId: options.requestId });
|
|
66
67
|
const provisioningFailed = await this.runResolvedHandler(resolved, options);
|
|
67
68
|
if (!provisioningFailed && resolved.kind === "initial_provision") {
|
|
68
|
-
await this.
|
|
69
|
+
await this.requireSessionsResource("mark provisioned").markProvisioned(resolved.session.id, {
|
|
69
70
|
requestId: options.requestId,
|
|
70
71
|
});
|
|
71
72
|
}
|
|
@@ -140,7 +141,7 @@ class ProxyWebhooksResource {
|
|
|
140
141
|
if (!failure) {
|
|
141
142
|
throw error;
|
|
142
143
|
}
|
|
143
|
-
await this.
|
|
144
|
+
await this.requireSessionsResource("mark provisioning failed").markProvisioningFailed(resolved.session.id, {
|
|
144
145
|
errorCode: failure.errorCode,
|
|
145
146
|
errorMessage: failure.errorMessage,
|
|
146
147
|
metadata: failure.metadata,
|
|
@@ -149,6 +150,14 @@ class ProxyWebhooksResource {
|
|
|
149
150
|
return true;
|
|
150
151
|
}
|
|
151
152
|
}
|
|
153
|
+
requireSessionsResource(operation) {
|
|
154
|
+
if (this.sessions) {
|
|
155
|
+
return this.sessions;
|
|
156
|
+
}
|
|
157
|
+
throw new errors_js_1.ProxyCheckoutValidationError(`ProxyWebhooksResource cannot ${operation} without a ProxySessionsResource. Construct webhooks via createProxyCheckoutServerClient or pass the sessions resource to new ProxyWebhooksResource(events, sessions).`, {
|
|
158
|
+
code: "webhook_sessions_resource_missing",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
152
161
|
}
|
|
153
162
|
exports.ProxyWebhooksResource = ProxyWebhooksResource;
|
|
154
163
|
function toWebhookResponse(result) {
|
package/dist/esm/errors.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ProxyCheckoutApiErrorDetails {
|
|
|
4
4
|
readonly responseBody: unknown;
|
|
5
5
|
readonly statusCode: number;
|
|
6
6
|
}
|
|
7
|
-
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch";
|
|
7
|
+
export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch" | "webhook_sessions_resource_missing";
|
|
8
8
|
/**
|
|
9
9
|
* Raised when the SDK receives Proxy data it cannot safely normalize, for
|
|
10
10
|
* example an invalid date string, a cart snapshot that fails the merchant
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export declare const proxyCheckoutServerSdkVersion = "0.0.
|
|
3
|
-
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.
|
|
2
|
+
export declare const proxyCheckoutServerSdkVersion = "0.0.6-prx-93.48.1";
|
|
3
|
+
export declare const proxyCheckoutServerSdkUserAgent = "@proxy-checkout/server-js/0.0.6-prx-93.48.1";
|
package/dist/esm/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export const proxyCheckoutServerSdkName = "@proxy-checkout/server-js";
|
|
2
|
-
export const proxyCheckoutServerSdkVersion = "0.0.
|
|
2
|
+
export const proxyCheckoutServerSdkVersion = "0.0.6-prx-93.48.1";
|
|
3
3
|
export const proxyCheckoutServerSdkUserAgent = `${proxyCheckoutServerSdkName}/${proxyCheckoutServerSdkVersion}`;
|
|
@@ -76,8 +76,8 @@ export interface ProxyWebhookProcessResult {
|
|
|
76
76
|
}
|
|
77
77
|
export declare class ProxyWebhooksResource {
|
|
78
78
|
private readonly events;
|
|
79
|
-
private readonly sessions
|
|
80
|
-
constructor(events: ProxyEventsResource, sessions
|
|
79
|
+
private readonly sessions?;
|
|
80
|
+
constructor(events: ProxyEventsResource, sessions?: Pick<ProxySessionsResource, "markProvisioned" | "markProvisioningFailed"> | undefined);
|
|
81
81
|
/** Low-level: verify + construct the event without resolving lifecycle. */
|
|
82
82
|
constructEvent(input: {
|
|
83
83
|
body: Buffer | string;
|
|
@@ -100,4 +100,5 @@ export declare class ProxyWebhooksResource {
|
|
|
100
100
|
*/
|
|
101
101
|
handle(input: ProxyWebhookRequestInput, options: ProxyWebhookHandlerOptions): Promise<Response>;
|
|
102
102
|
private runResolvedHandler;
|
|
103
|
+
private requireSessionsResource;
|
|
103
104
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* verification, duplicate/in-flight handling, retryable responses, and
|
|
8
8
|
* current-state retrieval so customer webhook routes stay tiny.
|
|
9
9
|
*/
|
|
10
|
+
import { ProxyCheckoutValidationError } from "./errors.js";
|
|
10
11
|
import { constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookSignatureVerificationError, } from "./webhooks.js";
|
|
11
12
|
/** Seconds advertised in `Retry-After` when an event is already in flight. */
|
|
12
13
|
export const PROXY_WEBHOOK_RETRY_AFTER_SECONDS = 30;
|
|
@@ -62,7 +63,7 @@ export class ProxyWebhooksResource {
|
|
|
62
63
|
resolved = await this.events.resolveCurrentState(event, { requestId: options.requestId });
|
|
63
64
|
const provisioningFailed = await this.runResolvedHandler(resolved, options);
|
|
64
65
|
if (!provisioningFailed && resolved.kind === "initial_provision") {
|
|
65
|
-
await this.
|
|
66
|
+
await this.requireSessionsResource("mark provisioned").markProvisioned(resolved.session.id, {
|
|
66
67
|
requestId: options.requestId,
|
|
67
68
|
});
|
|
68
69
|
}
|
|
@@ -137,7 +138,7 @@ export class ProxyWebhooksResource {
|
|
|
137
138
|
if (!failure) {
|
|
138
139
|
throw error;
|
|
139
140
|
}
|
|
140
|
-
await this.
|
|
141
|
+
await this.requireSessionsResource("mark provisioning failed").markProvisioningFailed(resolved.session.id, {
|
|
141
142
|
errorCode: failure.errorCode,
|
|
142
143
|
errorMessage: failure.errorMessage,
|
|
143
144
|
metadata: failure.metadata,
|
|
@@ -146,6 +147,14 @@ export class ProxyWebhooksResource {
|
|
|
146
147
|
return true;
|
|
147
148
|
}
|
|
148
149
|
}
|
|
150
|
+
requireSessionsResource(operation) {
|
|
151
|
+
if (this.sessions) {
|
|
152
|
+
return this.sessions;
|
|
153
|
+
}
|
|
154
|
+
throw new ProxyCheckoutValidationError(`ProxyWebhooksResource cannot ${operation} without a ProxySessionsResource. Construct webhooks via createProxyCheckoutServerClient or pass the sessions resource to new ProxyWebhooksResource(events, sessions).`, {
|
|
155
|
+
code: "webhook_sessions_resource_missing",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
149
158
|
}
|
|
150
159
|
function toWebhookResponse(result) {
|
|
151
160
|
const headers = { "content-type": "application/json" };
|
package/package.json
CHANGED