@mesub/node 0.1.0 → 0.1.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/README.md +10 -5
- package/dist/{chunk-ELK7IBLO.js → chunk-35MOUS4W.js} +2 -2
- package/dist/{chunk-XDLLXY7Y.js → chunk-6HGYY2KN.js} +2 -2
- package/dist/{chunk-SGSYQJYT.cjs → chunk-BP5D5I66.cjs} +31 -22
- package/dist/chunk-BP5D5I66.cjs.map +1 -0
- package/dist/{chunk-KMPBFNJE.js → chunk-JCDJZDEJ.js} +16 -7
- package/dist/chunk-JCDJZDEJ.js.map +1 -0
- package/dist/{chunk-PCDZI7B4.cjs → chunk-RSN2QQUR.cjs} +7 -7
- package/dist/{chunk-PCDZI7B4.cjs.map → chunk-RSN2QQUR.cjs.map} +1 -1
- package/dist/{chunk-VMKI4VVA.cjs → chunk-WNHLTJ6F.cjs} +4 -4
- package/dist/{chunk-VMKI4VVA.cjs.map → chunk-WNHLTJ6F.cjs.map} +1 -1
- package/dist/{client-Dm1jamju.d.cts → client-BZB6KIGd.d.cts} +10 -3
- package/dist/{client-BQuRYSdB.d.ts → client-Q5QhXphp.d.ts} +10 -3
- package/dist/{errors-DqW3DMBS.d.ts → errors-BN4ZWUfM.d.ts} +1 -1
- package/dist/{errors-CtPucyOh.d.cts → errors-DcLfunS-.d.cts} +1 -1
- package/dist/express.cjs +21 -21
- package/dist/express.d.cts +7 -7
- package/dist/express.d.ts +7 -7
- package/dist/express.js +3 -3
- package/dist/{guard-DKb6iU1z.d.ts → guard-CaXiHMVF.d.ts} +1 -1
- package/dist/{guard-Dhy4fI6n.d.cts → guard-D4AB5HtN.d.cts} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/nest.cjs +13 -13
- package/dist/nest.d.cts +5 -5
- package/dist/nest.d.ts +5 -5
- package/dist/nest.js +2 -2
- package/dist/next.cjs +20 -20
- package/dist/next.d.cts +7 -7
- package/dist/next.d.ts +7 -7
- package/dist/next.js +3 -3
- package/dist/{routes-DWkRFOP0.d.cts → routes-DT8EFWSl.d.cts} +2 -2
- package/dist/{routes-CLtZnUzl.d.ts → routes-KoaD1Xsk.d.ts} +2 -2
- package/dist/situations.d.cts +1 -1
- package/dist/situations.d.ts +1 -1
- package/dist/{subscriptions-D1hE7MUc.d.ts → subscriptions-B6Lin6i_.d.cts} +7 -0
- package/dist/{subscriptions-D1hE7MUc.d.cts → subscriptions-B6Lin6i_.d.ts} +7 -0
- package/dist/testing.cjs +20 -18
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +8 -6
- package/dist/testing.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-KMPBFNJE.js.map +0 -1
- package/dist/chunk-SGSYQJYT.cjs.map +0 -1
- /package/dist/{chunk-ELK7IBLO.js.map → chunk-35MOUS4W.js.map} +0 -0
- /package/dist/{chunk-XDLLXY7Y.js.map → chunk-6HGYY2KN.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as CacheStore, a as CacheEntry } from './client-
|
|
2
|
-
export { A as AccessCache, b as AccessCacheOptions, c as AccessChangedDetail, d as CachedAnswer, e as CreatedDetail, D as DEFAULT_MAX_STALE_MS, f as Decision, E as EndedDetail, g as EventList, h as EventListParams, i as EventNetwork, j as EventType, k as Events, F as FirstPayment, H as HeaderSource, M as Mesub, l as MesubEvent, m as MesubOptions, N as NoDetail, P as PaymentFailedDetail, n as Plan, o as PlanStatus, p as PlanToken, q as Plans, R as RenewalIssue, r as RenewalUpcomingDetail, s as RenewedDetail, t as Revalidating, S as StoppedDetail, u as SubscriptionAccessGrantedEvent, v as SubscriptionAccessRevokedEvent, w as SubscriptionCancelledEvent, x as SubscriptionCreatedEvent, y as SubscriptionEndedEvent, z as SubscriptionExpiredEvent, B as SubscriptionPausedEvent, G as SubscriptionPaymentFailedEvent, I as SubscriptionRenewalUpcomingEvent, J as SubscriptionRenewedEvent, K as SubscriptionResumedEvent, L as SubscriptionStoppedEvent, O as SubscriptionUnpausedEvent, T as TestEvent, V as VerifyWebhookOptions, W as WebhookBody, Q as WebhookEvent, U as WebhookEventType, X as Webhooks, Y as verifyWebhook } from './client-
|
|
3
|
-
export { M as MesubError, a as MesubErrorCode, b as MesubErrorOptions, c as MesubSubmitError, d as MesubSubmitErrorOptions } from './errors-
|
|
4
|
-
export { A as AccessAnswer, a as AccessList, b as AccessOptions, c as AttemptsParams, B as BlockedReason, d as ConfirmOptions, e as ConfirmParams, f as ConfirmReasonCode, g as ConfirmResult, C as Customer, E as EndReason, L as LateReason, h as ListParams, P as PaymentStatus, i as PullOutcome, R as RequestOptions, S as ServedAttempt, j as ServerSubscription, k as ServerSubscriptionList, l as ServerSubscriptionStatus, m as StopReason, n as SubmitOptions, o as SubmitParams, p as SubmitResult, q as SubscribeCosts, r as SubscribeParams, s as SubscribeTransaction, t as SubscriptionAttempt, u as SubscriptionAttemptList, v as SubscriptionStatus, w as Subscriptions, W as WalletTransaction } from './subscriptions-
|
|
1
|
+
import { C as CacheStore, a as CacheEntry } from './client-Q5QhXphp.js';
|
|
2
|
+
export { A as AccessCache, b as AccessCacheOptions, c as AccessChangedDetail, d as CachedAnswer, e as CreatedDetail, D as DEFAULT_MAX_STALE_MS, f as Decision, E as EndedDetail, g as EventList, h as EventListParams, i as EventNetwork, j as EventType, k as Events, F as FirstPayment, H as HeaderSource, M as Mesub, l as MesubEvent, m as MesubOptions, N as NoDetail, P as PaymentFailedDetail, n as Plan, o as PlanStatus, p as PlanToken, q as Plans, R as RenewalIssue, r as RenewalUpcomingDetail, s as RenewedDetail, t as Revalidating, S as StoppedDetail, u as SubscriptionAccessGrantedEvent, v as SubscriptionAccessRevokedEvent, w as SubscriptionCancelledEvent, x as SubscriptionCreatedEvent, y as SubscriptionEndedEvent, z as SubscriptionExpiredEvent, B as SubscriptionPausedEvent, G as SubscriptionPaymentFailedEvent, I as SubscriptionRenewalUpcomingEvent, J as SubscriptionRenewedEvent, K as SubscriptionResumedEvent, L as SubscriptionStoppedEvent, O as SubscriptionUnpausedEvent, T as TestEvent, V as VerifyWebhookOptions, W as WebhookBody, Q as WebhookEvent, U as WebhookEventType, X as Webhooks, Y as verifyWebhook } from './client-Q5QhXphp.js';
|
|
3
|
+
export { M as MesubError, a as MesubErrorCode, b as MesubErrorOptions, c as MesubSubmitError, d as MesubSubmitErrorOptions } from './errors-BN4ZWUfM.js';
|
|
4
|
+
export { A as AccessAnswer, a as AccessList, b as AccessOptions, c as AttemptsParams, B as BlockedReason, d as ConfirmOptions, e as ConfirmParams, f as ConfirmReasonCode, g as ConfirmResult, C as Customer, E as EndReason, L as LateReason, h as ListParams, P as PaymentStatus, i as PullOutcome, R as RequestOptions, S as ServedAttempt, j as ServerSubscription, k as ServerSubscriptionList, l as ServerSubscriptionStatus, m as StopReason, n as SubmitOptions, o as SubmitParams, p as SubmitResult, q as SubscribeCosts, r as SubscribeParams, s as SubscribeTransaction, t as SubscriptionAttempt, u as SubscriptionAttemptList, v as SubscriptionStatus, w as Subscriptions, W as WalletTransaction } from './subscriptions-B6Lin6i_.js';
|
|
5
5
|
export { ACCESS_LINE, CONFIRMATIONS, ConfirmationKey, ExplainOptions, Explainable, ExplainedAction, Explanation, SITUATIONS, Situation, SituationActionId, SituationActionTemplate, SituationActor, SituationKey, SituationText, explain, situationOf } from './situations.js';
|
|
6
6
|
|
|
7
7
|
/** Kept in step with package.json by `test/version.spec.ts`. */
|
|
8
|
-
declare const VERSION = "0.1.
|
|
8
|
+
declare const VERSION = "0.1.3";
|
|
9
9
|
/**
|
|
10
10
|
* The version of the Mesub API this release was written against, sent in
|
|
11
11
|
* the `Mesub-Version` header of every call, so the API can change its
|
package/dist/index.js
CHANGED
package/dist/nest.cjs
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkWNHLTJ6Fcjs = require('./chunk-WNHLTJ6F.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkBP5D5I66cjs = require('./chunk-BP5D5I66.cjs');
|
|
16
16
|
|
|
17
17
|
// src/nest.ts
|
|
18
18
|
|
|
@@ -25,28 +25,28 @@ function setHeader(response, name, value) {
|
|
|
25
25
|
else if (typeof response.header === "function") response.header(name, value);
|
|
26
26
|
}
|
|
27
27
|
function RequirePlan(plan, options) {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
_chunkWNHLTJ6Fcjs.checkPlan.call(void 0, plan);
|
|
29
|
+
_chunkWNHLTJ6Fcjs.checkCustomer.call(void 0, options);
|
|
30
30
|
class MesubPlanGuard {
|
|
31
31
|
async canActivate(context) {
|
|
32
32
|
const http = context.switchToHttp();
|
|
33
33
|
const request = http.getRequest();
|
|
34
|
-
const client = _nullishCoalesce(options.client, () => (
|
|
35
|
-
const outcome = await
|
|
34
|
+
const client = _nullishCoalesce(options.client, () => ( _chunkWNHLTJ6Fcjs.defaultClient.call(void 0, )));
|
|
35
|
+
const outcome = await _chunkWNHLTJ6Fcjs.guard.call(void 0,
|
|
36
36
|
client,
|
|
37
|
-
await
|
|
38
|
-
() =>
|
|
37
|
+
await _chunkWNHLTJ6Fcjs.askerOf.call(void 0, request, options.customer),
|
|
38
|
+
() => _chunkWNHLTJ6Fcjs.plansOf.call(void 0, plan, request)
|
|
39
39
|
);
|
|
40
40
|
if (outcome.allowed) {
|
|
41
|
-
request.mesub =
|
|
41
|
+
request.mesub = _chunkWNHLTJ6Fcjs.accessOf.call(void 0, outcome);
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
|
-
const denial =
|
|
44
|
+
const denial = _chunkWNHLTJ6Fcjs.denialOf.call(void 0, outcome);
|
|
45
45
|
await _optionalChain([options, 'access', _ => _.onDenied, 'optionalCall', _2 => _2(denial, request)]);
|
|
46
46
|
if (outcome.reason === "unavailable") {
|
|
47
|
-
setHeader(http.getResponse(), "Retry-After",
|
|
47
|
+
setHeader(http.getResponse(), "Retry-After", _chunkWNHLTJ6Fcjs.retryAfterOf.call(void 0, outcome));
|
|
48
48
|
}
|
|
49
|
-
throw new (0, _common.HttpException)(
|
|
49
|
+
throw new (0, _common.HttpException)(_chunkWNHLTJ6Fcjs.denialBody.call(void 0, outcome), denial.status);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
return _common.mixin.call(void 0, MesubPlanGuard);
|
|
@@ -58,5 +58,5 @@ var MesubAccess = _common.createParamDecorator.call(void 0,
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
exports.MesubAccess = MesubAccess; exports.MesubError =
|
|
61
|
+
exports.MesubAccess = MesubAccess; exports.MesubError = _chunkBP5D5I66cjs.MesubError; exports.RequirePlan = RequirePlan;
|
|
62
62
|
//# sourceMappingURL=nest.cjs.map
|
package/dist/nest.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Type, CanActivate } from '@nestjs/common';
|
|
2
|
-
import { H as HeaderSource, M as Mesub } from './client-
|
|
3
|
-
import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-
|
|
4
|
-
export { A as Asked, a as DenialReason } from './guard-
|
|
5
|
-
export { M as MesubError } from './errors-
|
|
6
|
-
export { C as Customer } from './subscriptions-
|
|
2
|
+
import { H as HeaderSource, M as Mesub } from './client-BZB6KIGd.cjs';
|
|
3
|
+
import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-D4AB5HtN.cjs';
|
|
4
|
+
export { A as Asked, a as DenialReason } from './guard-D4AB5HtN.cjs';
|
|
5
|
+
export { M as MesubError } from './errors-DcLfunS-.cjs';
|
|
6
|
+
export { C as Customer } from './subscriptions-B6Lin6i_.cjs';
|
|
7
7
|
|
|
8
8
|
/** `@mesub/node/nest`: `RequirePlan()` and `@MesubAccess()`. */
|
|
9
9
|
|
package/dist/nest.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Type, CanActivate } from '@nestjs/common';
|
|
2
|
-
import { H as HeaderSource, M as Mesub } from './client-
|
|
3
|
-
import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-
|
|
4
|
-
export { A as Asked, a as DenialReason } from './guard-
|
|
5
|
-
export { M as MesubError } from './errors-
|
|
6
|
-
export { C as Customer } from './subscriptions-
|
|
2
|
+
import { H as HeaderSource, M as Mesub } from './client-Q5QhXphp.js';
|
|
3
|
+
import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CaXiHMVF.js';
|
|
4
|
+
export { A as Asked, a as DenialReason } from './guard-CaXiHMVF.js';
|
|
5
|
+
export { M as MesubError } from './errors-BN4ZWUfM.js';
|
|
6
|
+
export { C as Customer } from './subscriptions-B6Lin6i_.js';
|
|
7
7
|
|
|
8
8
|
/** `@mesub/node/nest`: `RequirePlan()` and `@MesubAccess()`. */
|
|
9
9
|
|
package/dist/nest.js
CHANGED
package/dist/next.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkRSN2QQURcjs = require('./chunk-RSN2QQUR.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -15,27 +15,27 @@ var _chunkPCDZI7B4cjs = require('./chunk-PCDZI7B4.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkWNHLTJ6Fcjs = require('./chunk-WNHLTJ6F.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkBP5D5I66cjs = require('./chunk-BP5D5I66.cjs');
|
|
22
22
|
|
|
23
23
|
// src/next.ts
|
|
24
24
|
function withMesub(handler, options) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
_chunkWNHLTJ6Fcjs.checkPlan.call(void 0, options.plan);
|
|
26
|
+
_chunkWNHLTJ6Fcjs.checkCustomer.call(void 0, options);
|
|
27
27
|
return async (request, context) => {
|
|
28
|
-
const client = _nullishCoalesce(options.client, () => (
|
|
29
|
-
const outcome = await
|
|
28
|
+
const client = _nullishCoalesce(options.client, () => ( _chunkWNHLTJ6Fcjs.defaultClient.call(void 0, )));
|
|
29
|
+
const outcome = await _chunkWNHLTJ6Fcjs.guard.call(void 0,
|
|
30
30
|
client,
|
|
31
|
-
await
|
|
32
|
-
() =>
|
|
31
|
+
await _chunkWNHLTJ6Fcjs.askerOf.call(void 0, request, options.customer),
|
|
32
|
+
() => _chunkWNHLTJ6Fcjs.plansOf.call(void 0, options.plan, request)
|
|
33
33
|
);
|
|
34
|
-
if (outcome.allowed) return handler(request,
|
|
35
|
-
const denial =
|
|
34
|
+
if (outcome.allowed) return handler(request, _chunkWNHLTJ6Fcjs.accessOf.call(void 0, outcome), context);
|
|
35
|
+
const denial = _chunkWNHLTJ6Fcjs.denialOf.call(void 0, outcome);
|
|
36
36
|
if (options.onDenied) return await options.onDenied(denial, request);
|
|
37
|
-
const headers = outcome.reason === "unavailable" ? { "Retry-After":
|
|
38
|
-
return Response.json(
|
|
37
|
+
const headers = outcome.reason === "unavailable" ? { "Retry-After": _chunkWNHLTJ6Fcjs.retryAfterOf.call(void 0, outcome) } : {};
|
|
38
|
+
return Response.json(_chunkWNHLTJ6Fcjs.denialBody.call(void 0, outcome), { status: denial.status, headers });
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
async function pathOf(context) {
|
|
@@ -44,7 +44,7 @@ async function pathOf(context) {
|
|
|
44
44
|
return `/${(_nullishCoalesce(segments, () => ( []))).map((segment) => encodeURIComponent(String(segment))).join("/")}`;
|
|
45
45
|
}
|
|
46
46
|
async function textOf(request) {
|
|
47
|
-
if (Number(request.headers.get("content-length")) >
|
|
47
|
+
if (Number(request.headers.get("content-length")) > _chunkRSN2QQURcjs.MAX_BODY_BYTES) return null;
|
|
48
48
|
if (request.body === null) return "";
|
|
49
49
|
const reader = request.body.getReader();
|
|
50
50
|
const decoder = new TextDecoder();
|
|
@@ -54,7 +54,7 @@ async function textOf(request) {
|
|
|
54
54
|
const { done, value } = await reader.read();
|
|
55
55
|
if (done) return text + decoder.decode();
|
|
56
56
|
size += value.byteLength;
|
|
57
|
-
if (size >
|
|
57
|
+
if (size > _chunkRSN2QQURcjs.MAX_BODY_BYTES) {
|
|
58
58
|
await reader.cancel();
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
@@ -62,7 +62,7 @@ async function textOf(request) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function mesubRouteHandlers(options) {
|
|
65
|
-
|
|
65
|
+
_chunkRSN2QQURcjs.checkWidgetOptions.call(void 0, options);
|
|
66
66
|
const handle = async (request, context) => {
|
|
67
67
|
const path = await pathOf(context);
|
|
68
68
|
let body;
|
|
@@ -84,10 +84,10 @@ function mesubRouteHandlers(options) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
const publicRead = request.method === "GET" && path.startsWith("/plans/");
|
|
87
|
-
const asked = publicRead ? null : await
|
|
87
|
+
const asked = publicRead ? null : await _chunkRSN2QQURcjs.widgetCustomer.call(void 0, request, options.customer);
|
|
88
88
|
const email = asked && options.email ? await options.email(request) : void 0;
|
|
89
|
-
const answer = await
|
|
90
|
-
_nullishCoalesce(options.client, () => (
|
|
89
|
+
const answer = await _chunkRSN2QQURcjs.handleWidget.call(void 0,
|
|
90
|
+
_nullishCoalesce(options.client, () => ( _chunkWNHLTJ6Fcjs.defaultClient.call(void 0, ))),
|
|
91
91
|
{
|
|
92
92
|
method: request.method,
|
|
93
93
|
path,
|
|
@@ -109,5 +109,5 @@ function mesubRouteHandlers(options) {
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
exports.MesubError =
|
|
112
|
+
exports.MesubError = _chunkBP5D5I66cjs.MesubError; exports.mesubRouteHandlers = mesubRouteHandlers; exports.withMesub = withMesub;
|
|
113
113
|
//# sourceMappingURL=next.cjs.map
|
package/dist/next.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as Mesub } from './client-
|
|
2
|
-
import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-
|
|
3
|
-
export { A as Asked, a as DenialReason } from './guard-
|
|
4
|
-
import { W as WidgetRoutesOptions } from './routes-
|
|
5
|
-
export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-
|
|
6
|
-
export { M as MesubError } from './errors-
|
|
7
|
-
export { C as Customer } from './subscriptions-
|
|
1
|
+
import { M as Mesub } from './client-BZB6KIGd.cjs';
|
|
2
|
+
import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-D4AB5HtN.cjs';
|
|
3
|
+
export { A as Asked, a as DenialReason } from './guard-D4AB5HtN.cjs';
|
|
4
|
+
import { W as WidgetRoutesOptions } from './routes-DT8EFWSl.cjs';
|
|
5
|
+
export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-DT8EFWSl.cjs';
|
|
6
|
+
export { M as MesubError } from './errors-DcLfunS-.cjs';
|
|
7
|
+
export { C as Customer } from './subscriptions-B6Lin6i_.cjs';
|
|
8
8
|
|
|
9
9
|
/** `@mesub/node/next`: `withMesub()`. Web `Request`/`Response` only, nothing imported from `next`. */
|
|
10
10
|
|
package/dist/next.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as Mesub } from './client-
|
|
2
|
-
import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-
|
|
3
|
-
export { A as Asked, a as DenialReason } from './guard-
|
|
4
|
-
import { W as WidgetRoutesOptions } from './routes-
|
|
5
|
-
export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-
|
|
6
|
-
export { M as MesubError } from './errors-
|
|
7
|
-
export { C as Customer } from './subscriptions-
|
|
1
|
+
import { M as Mesub } from './client-Q5QhXphp.js';
|
|
2
|
+
import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CaXiHMVF.js';
|
|
3
|
+
export { A as Asked, a as DenialReason } from './guard-CaXiHMVF.js';
|
|
4
|
+
import { W as WidgetRoutesOptions } from './routes-KoaD1Xsk.js';
|
|
5
|
+
export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-KoaD1Xsk.js';
|
|
6
|
+
export { M as MesubError } from './errors-BN4ZWUfM.js';
|
|
7
|
+
export { C as Customer } from './subscriptions-B6Lin6i_.js';
|
|
8
8
|
|
|
9
9
|
/** `@mesub/node/next`: `withMesub()`. Web `Request`/`Response` only, nothing imported from `next`. */
|
|
10
10
|
|
package/dist/next.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
checkWidgetOptions,
|
|
4
4
|
handleWidget,
|
|
5
5
|
widgetCustomer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-35MOUS4W.js";
|
|
7
7
|
import {
|
|
8
8
|
accessOf,
|
|
9
9
|
askerOf,
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
guard,
|
|
16
16
|
plansOf,
|
|
17
17
|
retryAfterOf
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6HGYY2KN.js";
|
|
19
19
|
import {
|
|
20
20
|
MesubError
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-JCDJZDEJ.js";
|
|
22
22
|
|
|
23
23
|
// src/next.ts
|
|
24
24
|
function withMesub(handler, options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Customer, j as ServerSubscription } from './subscriptions-
|
|
2
|
-
import { M as Mesub } from './client-
|
|
1
|
+
import { C as Customer, j as ServerSubscription } from './subscriptions-B6Lin6i_.cjs';
|
|
2
|
+
import { M as Mesub } from './client-BZB6KIGd.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The routes `@mesub/react` calls on your own server, so the browser never
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Customer, j as ServerSubscription } from './subscriptions-
|
|
2
|
-
import { M as Mesub } from './client-
|
|
1
|
+
import { C as Customer, j as ServerSubscription } from './subscriptions-B6Lin6i_.js';
|
|
2
|
+
import { M as Mesub } from './client-Q5QhXphp.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The routes `@mesub/react` calls on your own server, so the browser never
|
package/dist/situations.d.cts
CHANGED
package/dist/situations.d.ts
CHANGED
|
@@ -484,6 +484,13 @@ interface SubscriptionAttempt {
|
|
|
484
484
|
* knows no price, and from a Mesub that predates it.
|
|
485
485
|
*/
|
|
486
486
|
amount_usd: string | null;
|
|
487
|
+
/**
|
|
488
|
+
* What the receiver's account got of a `paid` one, in the mint's smallest
|
|
489
|
+
* unit: `amount` less the fee a Token-2022 mint withholds on transfers.
|
|
490
|
+
* Null when not known (an attempt not paid, one recorded before Mesub
|
|
491
|
+
* kept it) and from a Mesub that predates it.
|
|
492
|
+
*/
|
|
493
|
+
amount_received: string | null;
|
|
487
494
|
/** The transaction that paid. Null on every outcome but `paid`, a refused one included. */
|
|
488
495
|
signature: string | null;
|
|
489
496
|
/** The subscription had already failed on this period. */
|
|
@@ -484,6 +484,13 @@ interface SubscriptionAttempt {
|
|
|
484
484
|
* knows no price, and from a Mesub that predates it.
|
|
485
485
|
*/
|
|
486
486
|
amount_usd: string | null;
|
|
487
|
+
/**
|
|
488
|
+
* What the receiver's account got of a `paid` one, in the mint's smallest
|
|
489
|
+
* unit: `amount` less the fee a Token-2022 mint withholds on transfers.
|
|
490
|
+
* Null when not known (an attempt not paid, one recorded before Mesub
|
|
491
|
+
* kept it) and from a Mesub that predates it.
|
|
492
|
+
*/
|
|
493
|
+
amount_received: string | null;
|
|
487
494
|
/** The transaction that paid. Null on every outcome but `paid`, a refused one included. */
|
|
488
495
|
signature: string | null;
|
|
489
496
|
/** The subscription had already failed on this period. */
|
package/dist/testing.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkBP5D5I66cjs = require('./chunk-BP5D5I66.cjs');
|
|
8
8
|
|
|
9
9
|
// src/testing.ts
|
|
10
10
|
var ACCESS_ATTEMPTS = 5;
|
|
@@ -166,7 +166,7 @@ var FakeMesub = (_class = class {
|
|
|
166
166
|
* unless asked, so a failure shows at once. Any other option is passed on.
|
|
167
167
|
*/
|
|
168
168
|
client(options = {}) {
|
|
169
|
-
return new (0,
|
|
169
|
+
return new (0, _chunkBP5D5I66cjs.Mesub)({
|
|
170
170
|
maxRetries: 0,
|
|
171
171
|
...options,
|
|
172
172
|
apiKey: this.apiKey,
|
|
@@ -262,7 +262,7 @@ var FakeMesub = (_class = class {
|
|
|
262
262
|
* asked about, and to null for an external id or an email.
|
|
263
263
|
*/
|
|
264
264
|
setAccess(customer, plan, fields) {
|
|
265
|
-
const asked =
|
|
265
|
+
const asked = _chunkBP5D5I66cjs.customerOf.call(void 0, customer);
|
|
266
266
|
const answer = { ...nothing(asked, plan), ...fields, plan };
|
|
267
267
|
this.#answers.set(keyOf(asked, plan), answer);
|
|
268
268
|
return this.#fresh(answer);
|
|
@@ -307,6 +307,8 @@ var FakeMesub = (_class = class {
|
|
|
307
307
|
amount: "9990000",
|
|
308
308
|
// The default amount's worth only: no price is guessed for another.
|
|
309
309
|
amount_usd: attempt.amount === void 0 ? "9.99" : null,
|
|
310
|
+
// A mint that withholds nothing: the receiver got it all.
|
|
311
|
+
amount_received: _nullishCoalesce(attempt.amount, () => ( "9990000")),
|
|
310
312
|
signature: "fake_signature",
|
|
311
313
|
retry: false,
|
|
312
314
|
retry_number: null,
|
|
@@ -347,8 +349,8 @@ var FakeMesub = (_class = class {
|
|
|
347
349
|
object: "event",
|
|
348
350
|
type,
|
|
349
351
|
created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
|
|
350
|
-
network: "
|
|
351
|
-
api_version:
|
|
352
|
+
network: "mainnet-beta",
|
|
353
|
+
api_version: _chunkBP5D5I66cjs.API_VERSION,
|
|
352
354
|
...sequence !== null && { sequence },
|
|
353
355
|
data,
|
|
354
356
|
detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data))),
|
|
@@ -390,8 +392,8 @@ var FakeMesub = (_class = class {
|
|
|
390
392
|
object: "event",
|
|
391
393
|
type,
|
|
392
394
|
created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
|
|
393
|
-
network: "
|
|
394
|
-
api_version:
|
|
395
|
+
network: "mainnet-beta",
|
|
396
|
+
api_version: _chunkBP5D5I66cjs.API_VERSION,
|
|
395
397
|
...sequence !== null && { sequence },
|
|
396
398
|
data,
|
|
397
399
|
detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data)))
|
|
@@ -496,8 +498,8 @@ var FakeMesub = (_class = class {
|
|
|
496
498
|
object: "event",
|
|
497
499
|
type: each,
|
|
498
500
|
created_at,
|
|
499
|
-
network: "
|
|
500
|
-
api_version:
|
|
501
|
+
network: "mainnet-beta",
|
|
502
|
+
api_version: _chunkBP5D5I66cjs.API_VERSION,
|
|
501
503
|
sequence: this.#nextSequence(subscription.id),
|
|
502
504
|
data: structuredClone(data),
|
|
503
505
|
detail: eachDetail
|
|
@@ -561,12 +563,12 @@ var FakeMesub = (_class = class {
|
|
|
561
563
|
if (key !== this.apiKey) {
|
|
562
564
|
return error(401, "invalid_api_key", "That API key is not valid.");
|
|
563
565
|
}
|
|
564
|
-
const version = headers.get(
|
|
565
|
-
if (version !== null && version !==
|
|
566
|
+
const version = headers.get(_chunkBP5D5I66cjs.API_VERSION_HEADER);
|
|
567
|
+
if (version !== null && version !== _chunkBP5D5I66cjs.API_VERSION) {
|
|
566
568
|
return error(
|
|
567
569
|
400,
|
|
568
570
|
"unsupported_version",
|
|
569
|
-
`${
|
|
571
|
+
`${_chunkBP5D5I66cjs.API_VERSION_HEADER} must be one of the versions this API serves: ${_chunkBP5D5I66cjs.API_VERSION}.`
|
|
570
572
|
);
|
|
571
573
|
}
|
|
572
574
|
if (this.#failure) {
|
|
@@ -1016,7 +1018,7 @@ var FakeMesub = (_class = class {
|
|
|
1016
1018
|
if (subscription.external_id) customers.push({ external_id: subscription.external_id });
|
|
1017
1019
|
if (subscription.email) customers.push({ email: subscription.email });
|
|
1018
1020
|
for (const customer of customers) {
|
|
1019
|
-
const before = this.#answers.get(keyOf(
|
|
1021
|
+
const before = this.#answers.get(keyOf(_chunkBP5D5I66cjs.customerOf.call(void 0, customer), plan));
|
|
1020
1022
|
this.setAccess(customer, plan, {
|
|
1021
1023
|
wallet: subscription.wallet,
|
|
1022
1024
|
access: subscription.access,
|
|
@@ -1286,7 +1288,7 @@ async function signWebhook(payload, options) {
|
|
|
1286
1288
|
const body = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
1287
1289
|
const id = _nullishCoalesce(options.id, () => ( `msg_signed_${signedIds += 1}`));
|
|
1288
1290
|
const timestamp = _nullishCoalesce(options.timestamp, () => ( Math.floor(Date.now() / 1e3)));
|
|
1289
|
-
return { body, headers: await
|
|
1291
|
+
return { body, headers: await _chunkBP5D5I66cjs.signedHeaders.call(void 0, options.secret, id, timestamp, body) };
|
|
1290
1292
|
}
|
|
1291
1293
|
function detailOf(type, now, data) {
|
|
1292
1294
|
const start = now.toISOString();
|
|
@@ -1389,7 +1391,7 @@ function invalidSubmit(body) {
|
|
|
1389
1391
|
}
|
|
1390
1392
|
function askedIn(query) {
|
|
1391
1393
|
try {
|
|
1392
|
-
return
|
|
1394
|
+
return _chunkBP5D5I66cjs.customerOf.call(void 0, {
|
|
1393
1395
|
wallet: query["wallet"],
|
|
1394
1396
|
external_id: query["external_id"],
|
|
1395
1397
|
email: query["email"]
|
|
@@ -1425,9 +1427,9 @@ function fakePlan(slug, { token, ...over } = {}) {
|
|
|
1425
1427
|
verified: vouched,
|
|
1426
1428
|
...token
|
|
1427
1429
|
},
|
|
1428
|
-
mint: "
|
|
1430
|
+
mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
1429
1431
|
period_hours: 720,
|
|
1430
|
-
network: "
|
|
1432
|
+
network: "mainnet-beta",
|
|
1431
1433
|
status: "active",
|
|
1432
1434
|
available: true,
|
|
1433
1435
|
ends_at: null,
|
|
@@ -1474,7 +1476,7 @@ function error(status, code, message, { retryable, retryAfter } = {}) {
|
|
|
1474
1476
|
async function stamped(response, id) {
|
|
1475
1477
|
const headers = new Headers(response.headers);
|
|
1476
1478
|
headers.set(REQUEST_ID_HEADER, id);
|
|
1477
|
-
headers.set(
|
|
1479
|
+
headers.set(_chunkBP5D5I66cjs.API_VERSION_HEADER, _chunkBP5D5I66cjs.API_VERSION);
|
|
1478
1480
|
if (response.ok) return new Response(response.body, { status: response.status, headers });
|
|
1479
1481
|
const body = await response.json();
|
|
1480
1482
|
return Response.json({ ...body, request_id: id }, { status: response.status, headers });
|