@mesub/node 0.1.4 → 0.1.6

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.
Files changed (58) hide show
  1. package/README.md +20 -5
  2. package/dist/{chunk-43Q4PNF7.cjs → chunk-4M3ACBWX.cjs} +28 -2
  3. package/dist/chunk-4M3ACBWX.cjs.map +1 -0
  4. package/dist/{chunk-K6U6FPTA.cjs → chunk-5LDAYKUA.cjs} +7 -7
  5. package/dist/{chunk-K6U6FPTA.cjs.map → chunk-5LDAYKUA.cjs.map} +1 -1
  6. package/dist/{chunk-IAYUXSDD.cjs → chunk-5THDILDD.cjs} +16 -3
  7. package/dist/chunk-5THDILDD.cjs.map +1 -0
  8. package/dist/{chunk-PFI3Y32I.js → chunk-ANBU7BJU.js} +2 -2
  9. package/dist/{chunk-EPOLIEGY.js → chunk-EGGKTDHO.js} +2 -2
  10. package/dist/{chunk-IG4QRQSJ.js → chunk-QDBKSJ56.js} +16 -3
  11. package/dist/chunk-QDBKSJ56.js.map +1 -0
  12. package/dist/{chunk-JJWHMB2X.js → chunk-R4H46TSQ.js} +28 -2
  13. package/dist/chunk-R4H46TSQ.js.map +1 -0
  14. package/dist/{chunk-YCPYBU3R.cjs → chunk-TDRUSUBV.cjs} +4 -4
  15. package/dist/{chunk-YCPYBU3R.cjs.map → chunk-TDRUSUBV.cjs.map} +1 -1
  16. package/dist/{client-BZB6KIGd.d.cts → client-B2DttW-V.d.cts} +18 -2
  17. package/dist/{client-Q5QhXphp.d.ts → client-BHrc_yO3.d.ts} +18 -2
  18. package/dist/{errors-BN4ZWUfM.d.ts → errors-CTFJfJoF.d.ts} +1 -1
  19. package/dist/{errors-DcLfunS-.d.cts → errors-xk1hGCOf.d.cts} +1 -1
  20. package/dist/express.cjs +21 -21
  21. package/dist/express.d.cts +7 -7
  22. package/dist/express.d.ts +7 -7
  23. package/dist/express.js +3 -3
  24. package/dist/{guard-D4AB5HtN.d.cts → guard-CDC9mDWY.d.cts} +1 -1
  25. package/dist/{guard-CaXiHMVF.d.ts → guard-CrGTKKXV.d.ts} +1 -1
  26. package/dist/index.cjs +3 -3
  27. package/dist/index.d.cts +5 -5
  28. package/dist/index.d.ts +5 -5
  29. package/dist/index.js +2 -2
  30. package/dist/nest.cjs +13 -13
  31. package/dist/nest.d.cts +5 -5
  32. package/dist/nest.d.ts +5 -5
  33. package/dist/nest.js +2 -2
  34. package/dist/next.cjs +20 -20
  35. package/dist/next.d.cts +7 -7
  36. package/dist/next.d.ts +7 -7
  37. package/dist/next.js +3 -3
  38. package/dist/{routes-DT8EFWSl.d.cts → routes-BpOV9UAR.d.cts} +2 -2
  39. package/dist/{routes-KoaD1Xsk.d.ts → routes-DWhspa6s.d.ts} +2 -2
  40. package/dist/situations.cjs +2 -2
  41. package/dist/situations.d.cts +41 -1
  42. package/dist/situations.d.ts +41 -1
  43. package/dist/situations.js +1 -1
  44. package/dist/{subscriptions-B6Lin6i_.d.cts → subscriptions-Dy_BNyPE.d.cts} +6 -3
  45. package/dist/{subscriptions-B6Lin6i_.d.ts → subscriptions-Dy_BNyPE.d.ts} +6 -3
  46. package/dist/testing.cjs +19 -15
  47. package/dist/testing.cjs.map +1 -1
  48. package/dist/testing.d.cts +9 -6
  49. package/dist/testing.d.ts +9 -6
  50. package/dist/testing.js +5 -1
  51. package/dist/testing.js.map +1 -1
  52. package/package.json +1 -1
  53. package/dist/chunk-43Q4PNF7.cjs.map +0 -1
  54. package/dist/chunk-IAYUXSDD.cjs.map +0 -1
  55. package/dist/chunk-IG4QRQSJ.js.map +0 -1
  56. package/dist/chunk-JJWHMB2X.js.map +0 -1
  57. /package/dist/{chunk-PFI3Y32I.js.map → chunk-ANBU7BJU.js.map} +0 -0
  58. /package/dist/{chunk-EPOLIEGY.js.map → chunk-EGGKTDHO.js.map} +0 -0
package/dist/index.js CHANGED
@@ -10,14 +10,14 @@ import {
10
10
  MesubSubmitError,
11
11
  VERSION,
12
12
  verifyWebhook
13
- } from "./chunk-IG4QRQSJ.js";
13
+ } from "./chunk-QDBKSJ56.js";
14
14
  import {
15
15
  ACCESS_LINE,
16
16
  CONFIRMATIONS,
17
17
  SITUATIONS,
18
18
  explain,
19
19
  situationOf
20
- } from "./chunk-JJWHMB2X.js";
20
+ } from "./chunk-R4H46TSQ.js";
21
21
  export {
22
22
  ACCESS_LINE,
23
23
  API_VERSION,
package/dist/nest.cjs CHANGED
@@ -9,10 +9,10 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkYCPYBU3Rcjs = require('./chunk-YCPYBU3R.cjs');
12
+ var _chunkTDRUSUBVcjs = require('./chunk-TDRUSUBV.cjs');
13
13
 
14
14
 
15
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
15
+ var _chunk5THDILDDcjs = require('./chunk-5THDILDD.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
- _chunkYCPYBU3Rcjs.checkPlan.call(void 0, plan);
29
- _chunkYCPYBU3Rcjs.checkCustomer.call(void 0, options);
28
+ _chunkTDRUSUBVcjs.checkPlan.call(void 0, plan);
29
+ _chunkTDRUSUBVcjs.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, () => ( _chunkYCPYBU3Rcjs.defaultClient.call(void 0, )));
35
- const outcome = await _chunkYCPYBU3Rcjs.guard.call(void 0,
34
+ const client = _nullishCoalesce(options.client, () => ( _chunkTDRUSUBVcjs.defaultClient.call(void 0, )));
35
+ const outcome = await _chunkTDRUSUBVcjs.guard.call(void 0,
36
36
  client,
37
- await _chunkYCPYBU3Rcjs.askerOf.call(void 0, request, options.customer),
38
- () => _chunkYCPYBU3Rcjs.plansOf.call(void 0, plan, request)
37
+ await _chunkTDRUSUBVcjs.askerOf.call(void 0, request, options.customer),
38
+ () => _chunkTDRUSUBVcjs.plansOf.call(void 0, plan, request)
39
39
  );
40
40
  if (outcome.allowed) {
41
- request.mesub = _chunkYCPYBU3Rcjs.accessOf.call(void 0, outcome);
41
+ request.mesub = _chunkTDRUSUBVcjs.accessOf.call(void 0, outcome);
42
42
  return true;
43
43
  }
44
- const denial = _chunkYCPYBU3Rcjs.denialOf.call(void 0, outcome);
44
+ const denial = _chunkTDRUSUBVcjs.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", _chunkYCPYBU3Rcjs.retryAfterOf.call(void 0, outcome));
47
+ setHeader(http.getResponse(), "Retry-After", _chunkTDRUSUBVcjs.retryAfterOf.call(void 0, outcome));
48
48
  }
49
- throw new (0, _common.HttpException)(_chunkYCPYBU3Rcjs.denialBody.call(void 0, outcome), denial.status);
49
+ throw new (0, _common.HttpException)(_chunkTDRUSUBVcjs.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 = _chunkIAYUXSDDcjs.MesubError; exports.RequirePlan = RequirePlan;
61
+ exports.MesubAccess = MesubAccess; exports.MesubError = _chunk5THDILDDcjs.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-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';
2
+ import { H as HeaderSource, M as Mesub } from './client-B2DttW-V.cjs';
3
+ import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CDC9mDWY.cjs';
4
+ export { A as Asked, a as DenialReason } from './guard-CDC9mDWY.cjs';
5
+ export { M as MesubError } from './errors-xk1hGCOf.cjs';
6
+ export { C as Customer } from './subscriptions-Dy_BNyPE.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-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';
2
+ import { H as HeaderSource, M as Mesub } from './client-BHrc_yO3.js';
3
+ import { M as MesubAccess$1, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CrGTKKXV.js';
4
+ export { A as Asked, a as DenialReason } from './guard-CrGTKKXV.js';
5
+ export { M as MesubError } from './errors-CTFJfJoF.js';
6
+ export { C as Customer } from './subscriptions-Dy_BNyPE.js';
7
7
 
8
8
  /** `@mesub/node/nest`: `RequirePlan()` and `@MesubAccess()`. */
9
9
 
package/dist/nest.js CHANGED
@@ -9,10 +9,10 @@ import {
9
9
  guard,
10
10
  plansOf,
11
11
  retryAfterOf
12
- } from "./chunk-EPOLIEGY.js";
12
+ } from "./chunk-EGGKTDHO.js";
13
13
  import {
14
14
  MesubError
15
- } from "./chunk-IG4QRQSJ.js";
15
+ } from "./chunk-QDBKSJ56.js";
16
16
 
17
17
  // src/nest.ts
18
18
  import {
package/dist/next.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkK6U6FPTAcjs = require('./chunk-K6U6FPTA.cjs');
6
+ var _chunk5LDAYKUAcjs = require('./chunk-5LDAYKUA.cjs');
7
7
 
8
8
 
9
9
 
@@ -15,27 +15,27 @@ var _chunkK6U6FPTAcjs = require('./chunk-K6U6FPTA.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkYCPYBU3Rcjs = require('./chunk-YCPYBU3R.cjs');
18
+ var _chunkTDRUSUBVcjs = require('./chunk-TDRUSUBV.cjs');
19
19
 
20
20
 
21
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
21
+ var _chunk5THDILDDcjs = require('./chunk-5THDILDD.cjs');
22
22
 
23
23
  // src/next.ts
24
24
  function withMesub(handler, options) {
25
- _chunkYCPYBU3Rcjs.checkPlan.call(void 0, options.plan);
26
- _chunkYCPYBU3Rcjs.checkCustomer.call(void 0, options);
25
+ _chunkTDRUSUBVcjs.checkPlan.call(void 0, options.plan);
26
+ _chunkTDRUSUBVcjs.checkCustomer.call(void 0, options);
27
27
  return async (request, context) => {
28
- const client = _nullishCoalesce(options.client, () => ( _chunkYCPYBU3Rcjs.defaultClient.call(void 0, )));
29
- const outcome = await _chunkYCPYBU3Rcjs.guard.call(void 0,
28
+ const client = _nullishCoalesce(options.client, () => ( _chunkTDRUSUBVcjs.defaultClient.call(void 0, )));
29
+ const outcome = await _chunkTDRUSUBVcjs.guard.call(void 0,
30
30
  client,
31
- await _chunkYCPYBU3Rcjs.askerOf.call(void 0, request, options.customer),
32
- () => _chunkYCPYBU3Rcjs.plansOf.call(void 0, options.plan, request)
31
+ await _chunkTDRUSUBVcjs.askerOf.call(void 0, request, options.customer),
32
+ () => _chunkTDRUSUBVcjs.plansOf.call(void 0, options.plan, request)
33
33
  );
34
- if (outcome.allowed) return handler(request, _chunkYCPYBU3Rcjs.accessOf.call(void 0, outcome), context);
35
- const denial = _chunkYCPYBU3Rcjs.denialOf.call(void 0, outcome);
34
+ if (outcome.allowed) return handler(request, _chunkTDRUSUBVcjs.accessOf.call(void 0, outcome), context);
35
+ const denial = _chunkTDRUSUBVcjs.denialOf.call(void 0, outcome);
36
36
  if (options.onDenied) return await options.onDenied(denial, request);
37
- const headers = outcome.reason === "unavailable" ? { "Retry-After": _chunkYCPYBU3Rcjs.retryAfterOf.call(void 0, outcome) } : {};
38
- return Response.json(_chunkYCPYBU3Rcjs.denialBody.call(void 0, outcome), { status: denial.status, headers });
37
+ const headers = outcome.reason === "unavailable" ? { "Retry-After": _chunkTDRUSUBVcjs.retryAfterOf.call(void 0, outcome) } : {};
38
+ return Response.json(_chunkTDRUSUBVcjs.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")) > _chunkK6U6FPTAcjs.MAX_BODY_BYTES) return null;
47
+ if (Number(request.headers.get("content-length")) > _chunk5LDAYKUAcjs.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 > _chunkK6U6FPTAcjs.MAX_BODY_BYTES) {
57
+ if (size > _chunk5LDAYKUAcjs.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
- _chunkK6U6FPTAcjs.checkWidgetOptions.call(void 0, options);
65
+ _chunk5LDAYKUAcjs.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 _chunkK6U6FPTAcjs.widgetCustomer.call(void 0, request, options.customer);
87
+ const asked = publicRead ? null : await _chunk5LDAYKUAcjs.widgetCustomer.call(void 0, request, options.customer);
88
88
  const email = asked && options.email ? await options.email(request) : void 0;
89
- const answer = await _chunkK6U6FPTAcjs.handleWidget.call(void 0,
90
- _nullishCoalesce(options.client, () => ( _chunkYCPYBU3Rcjs.defaultClient.call(void 0, ))),
89
+ const answer = await _chunk5LDAYKUAcjs.handleWidget.call(void 0,
90
+ _nullishCoalesce(options.client, () => ( _chunkTDRUSUBVcjs.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 = _chunkIAYUXSDDcjs.MesubError; exports.mesubRouteHandlers = mesubRouteHandlers; exports.withMesub = withMesub;
112
+ exports.MesubError = _chunk5THDILDDcjs.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-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';
1
+ import { M as Mesub } from './client-B2DttW-V.cjs';
2
+ import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CDC9mDWY.cjs';
3
+ export { A as Asked, a as DenialReason } from './guard-CDC9mDWY.cjs';
4
+ import { W as WidgetRoutesOptions } from './routes-BpOV9UAR.cjs';
5
+ export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-BpOV9UAR.cjs';
6
+ export { M as MesubError } from './errors-xk1hGCOf.cjs';
7
+ export { C as Customer } from './subscriptions-Dy_BNyPE.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-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';
1
+ import { M as Mesub } from './client-BHrc_yO3.js';
2
+ import { M as MesubAccess, P as PlanOption, C as CustomerOption, D as Denial } from './guard-CrGTKKXV.js';
3
+ export { A as Asked, a as DenialReason } from './guard-CrGTKKXV.js';
4
+ import { W as WidgetRoutesOptions } from './routes-DWhspa6s.js';
5
+ export { a as WidgetPayment, b as WidgetSubscriptionDetail, c as WidgetSubscriptionList } from './routes-DWhspa6s.js';
6
+ export { M as MesubError } from './errors-CTFJfJoF.js';
7
+ export { C as Customer } from './subscriptions-Dy_BNyPE.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-PFI3Y32I.js";
6
+ } from "./chunk-ANBU7BJU.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-EPOLIEGY.js";
18
+ } from "./chunk-EGGKTDHO.js";
19
19
  import {
20
20
  MesubError
21
- } from "./chunk-IG4QRQSJ.js";
21
+ } from "./chunk-QDBKSJ56.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-B6Lin6i_.cjs';
2
- import { M as Mesub } from './client-BZB6KIGd.cjs';
1
+ import { C as Customer, j as ServerSubscription } from './subscriptions-Dy_BNyPE.cjs';
2
+ import { M as Mesub } from './client-B2DttW-V.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-B6Lin6i_.js';
2
- import { M as Mesub } from './client-Q5QhXphp.js';
1
+ import { C as Customer, j as ServerSubscription } from './subscriptions-Dy_BNyPE.js';
2
+ import { M as Mesub } from './client-BHrc_yO3.js';
3
3
 
4
4
  /**
5
5
  * The routes `@mesub/react` calls on your own server, so the browser never
@@ -4,12 +4,12 @@
4
4
 
5
5
 
6
6
 
7
- var _chunk43Q4PNF7cjs = require('./chunk-43Q4PNF7.cjs');
7
+ var _chunk4M3ACBWXcjs = require('./chunk-4M3ACBWX.cjs');
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
13
 
14
- exports.ACCESS_LINE = _chunk43Q4PNF7cjs.ACCESS_LINE; exports.CONFIRMATIONS = _chunk43Q4PNF7cjs.CONFIRMATIONS; exports.SITUATIONS = _chunk43Q4PNF7cjs.SITUATIONS; exports.explain = _chunk43Q4PNF7cjs.explain; exports.situationOf = _chunk43Q4PNF7cjs.situationOf;
14
+ exports.ACCESS_LINE = _chunk4M3ACBWXcjs.ACCESS_LINE; exports.CONFIRMATIONS = _chunk4M3ACBWXcjs.CONFIRMATIONS; exports.SITUATIONS = _chunk4M3ACBWXcjs.SITUATIONS; exports.explain = _chunk4M3ACBWXcjs.explain; exports.situationOf = _chunk4M3ACBWXcjs.situationOf;
15
15
  //# sourceMappingURL=situations.cjs.map
@@ -1,4 +1,4 @@
1
- import { A as AccessAnswer, j as ServerSubscription } from './subscriptions-B6Lin6i_.cjs';
1
+ import { A as AccessAnswer, j as ServerSubscription } from './subscriptions-Dy_BNyPE.cjs';
2
2
 
3
3
  /**
4
4
  * One sentence per subscription situation, for the subscriber and for the
@@ -274,6 +274,46 @@ declare const SITUATIONS: {
274
274
  readonly route: "POST /v1/subscriptions/:id/cancel";
275
275
  }];
276
276
  };
277
+ readonly blocked_receiver_account_needs_memo: {
278
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
279
+ readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the token account of the wallet that receives its payments requires a memo on every payment in, which Mesub's charges do not carry. Turn that requirement off for the account, or choose another receiving wallet; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
280
+ readonly actions: readonly [{
281
+ readonly by: "subscriber";
282
+ readonly action: "cancel";
283
+ readonly sdk: "subscriptions.cancel";
284
+ readonly route: "POST /v1/subscriptions/:id/cancel";
285
+ }];
286
+ };
287
+ readonly blocked_receiver_account_confidential_only: {
288
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
289
+ readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the token account of the wallet that receives its payments takes confidential transfers only, and Mesub's charges are plain ones. Allow plain transfers into the account, or choose another receiving wallet; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
290
+ readonly actions: readonly [{
291
+ readonly by: "subscriber";
292
+ readonly action: "cancel";
293
+ readonly sdk: "subscriptions.cancel";
294
+ readonly route: "POST /v1/subscriptions/:id/cancel";
295
+ }];
296
+ };
297
+ readonly blocked_mint_paused: {
298
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of the token it is paid in, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
299
+ readonly merchant: "Payments blocked[ since {blocked_since}] by the plan's token: its issuer paused it, so no payment in it can move. Only the issuer can lift the pause, and Mesub charges again once they do.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
300
+ readonly actions: readonly [{
301
+ readonly by: "subscriber";
302
+ readonly action: "cancel";
303
+ readonly sdk: "subscriptions.cancel";
304
+ readonly route: "POST /v1/subscriptions/:id/cancel";
305
+ }];
306
+ };
307
+ readonly blocked_mint_transfer_hook: {
308
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of the token it is paid in, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
309
+ readonly merchant: "Payments blocked[ since {blocked_since}] by the plan's token: its issuer made every transfer of it run their own program, which Mesub does not support yet. Mesub charges again if the issuer removes it; otherwise, create a new plan with another token.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
310
+ readonly actions: readonly [{
311
+ readonly by: "subscriber";
312
+ readonly action: "cancel";
313
+ readonly sdk: "subscriptions.cancel";
314
+ readonly route: "POST /v1/subscriptions/:id/cancel";
315
+ }];
316
+ };
277
317
  readonly blocked_mint_gone: {
278
318
  readonly subscriber: "Mesub can no longer take your payments for {plan_name}: the token it is paid in no longer exists. This is not because of anything you did, and there is nothing for you to do or sign.[ You keep access until {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
279
319
  readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the plan's token no longer exists on chain, so nothing can be collected on it. Create a new plan with another token.[ Access ends on {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
@@ -1,4 +1,4 @@
1
- import { A as AccessAnswer, j as ServerSubscription } from './subscriptions-B6Lin6i_.js';
1
+ import { A as AccessAnswer, j as ServerSubscription } from './subscriptions-Dy_BNyPE.js';
2
2
 
3
3
  /**
4
4
  * One sentence per subscription situation, for the subscriber and for the
@@ -274,6 +274,46 @@ declare const SITUATIONS: {
274
274
  readonly route: "POST /v1/subscriptions/:id/cancel";
275
275
  }];
276
276
  };
277
+ readonly blocked_receiver_account_needs_memo: {
278
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
279
+ readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the token account of the wallet that receives its payments requires a memo on every payment in, which Mesub's charges do not carry. Turn that requirement off for the account, or choose another receiving wallet; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
280
+ readonly actions: readonly [{
281
+ readonly by: "subscriber";
282
+ readonly action: "cancel";
283
+ readonly sdk: "subscriptions.cancel";
284
+ readonly route: "POST /v1/subscriptions/:id/cancel";
285
+ }];
286
+ };
287
+ readonly blocked_receiver_account_confidential_only: {
288
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of how the plan is set up, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
289
+ readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the token account of the wallet that receives its payments takes confidential transfers only, and Mesub's charges are plain ones. Allow plain transfers into the account, or choose another receiving wallet; Mesub keeps trying.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
290
+ readonly actions: readonly [{
291
+ readonly by: "subscriber";
292
+ readonly action: "cancel";
293
+ readonly sdk: "subscriptions.cancel";
294
+ readonly route: "POST /v1/subscriptions/:id/cancel";
295
+ }];
296
+ };
297
+ readonly blocked_mint_paused: {
298
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of the token it is paid in, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
299
+ readonly merchant: "Payments blocked[ since {blocked_since}] by the plan's token: its issuer paused it, so no payment in it can move. Only the issuer can lift the pause, and Mesub charges again once they do.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
300
+ readonly actions: readonly [{
301
+ readonly by: "subscriber";
302
+ readonly action: "cancel";
303
+ readonly sdk: "subscriptions.cancel";
304
+ readonly route: "POST /v1/subscriptions/:id/cancel";
305
+ }];
306
+ };
307
+ readonly blocked_mint_transfer_hook: {
308
+ readonly subscriber: "Mesub cannot take your payments for {plan_name} for now, because of the token it is paid in, not because of anything you did: there is nothing for you to do or sign, and Mesub keeps trying.[ You keep access until {access_until} if no payment goes through by then.] Access comes back on its own with the first payment that goes through.";
309
+ readonly merchant: "Payments blocked[ since {blocked_since}] by the plan's token: its issuer made every transfer of it run their own program, which Mesub does not support yet. Mesub charges again if the issuer removes it; otherwise, create a new plan with another token.[ Access ends on {access_until} if nothing is collected by then.] Access comes back with the first payment that goes through, with nothing for the subscriber to sign.";
310
+ readonly actions: readonly [{
311
+ readonly by: "subscriber";
312
+ readonly action: "cancel";
313
+ readonly sdk: "subscriptions.cancel";
314
+ readonly route: "POST /v1/subscriptions/:id/cancel";
315
+ }];
316
+ };
277
317
  readonly blocked_mint_gone: {
278
318
  readonly subscriber: "Mesub can no longer take your payments for {plan_name}: the token it is paid in no longer exists. This is not because of anything you did, and there is nothing for you to do or sign.[ You keep access until {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
279
319
  readonly merchant: "Payments blocked[ since {blocked_since}] by your plan's setup: the plan's token no longer exists on chain, so nothing can be collected on it. Create a new plan with another token.[ Access ends on {access_until}.] No payment can go through on this plan again, so once access ends it does not come back.";
@@ -4,7 +4,7 @@ import {
4
4
  SITUATIONS,
5
5
  explain,
6
6
  situationOf
7
- } from "./chunk-JJWHMB2X.js";
7
+ } from "./chunk-R4H46TSQ.js";
8
8
  export {
9
9
  ACCESS_LINE,
10
10
  CONFIRMATIONS,
@@ -48,10 +48,13 @@ type StopReason = 'out_of_retries' | 'retry_deadline_passed' | 'authority_closed
48
48
  * doing (Mesub-io/backend#398). The merchant's own setup, theirs to fix, by
49
49
  * name: Mesub's puller taken off the plan on chain, a receiving wallet that
50
50
  * is not in the plan's destinations, has no token account for the plan's
51
- * token or whose token account is frozen (Mesub-io/backend#395), a token
52
- * that no longer exists. `mesub` for every cause of Mesub's.
51
+ * token, whose token account is frozen (Mesub-io/backend#395) or refuses a
52
+ * plain transfer in (a memo required, or confidential transfers only), a
53
+ * token that no longer exists. Two are the token issuer's to lift, not the
54
+ * merchant's: a token its issuer paused, or gave a transfer hook program
55
+ * (Mesub-io/backend#396). `mesub` for every cause of Mesub's.
53
56
  */
54
- type BlockedReason = 'puller_not_allowed' | 'receiver_not_allowed' | 'receiver_account_missing' | 'receiver_account_frozen' | 'mint_gone' | 'mesub';
57
+ type BlockedReason = 'puller_not_allowed' | 'receiver_not_allowed' | 'receiver_account_missing' | 'receiver_account_frozen' | 'receiver_account_needs_memo' | 'receiver_account_confidential_only' | 'mint_gone' | 'mint_paused' | 'mint_transfer_hook' | 'mesub';
55
58
  /**
56
59
  * `blocked` is a pull nothing was tried for, none of it the subscriber's
57
60
  * doing (Mesub's fee payer, the network): it never counts against them.
@@ -48,10 +48,13 @@ type StopReason = 'out_of_retries' | 'retry_deadline_passed' | 'authority_closed
48
48
  * doing (Mesub-io/backend#398). The merchant's own setup, theirs to fix, by
49
49
  * name: Mesub's puller taken off the plan on chain, a receiving wallet that
50
50
  * is not in the plan's destinations, has no token account for the plan's
51
- * token or whose token account is frozen (Mesub-io/backend#395), a token
52
- * that no longer exists. `mesub` for every cause of Mesub's.
51
+ * token, whose token account is frozen (Mesub-io/backend#395) or refuses a
52
+ * plain transfer in (a memo required, or confidential transfers only), a
53
+ * token that no longer exists. Two are the token issuer's to lift, not the
54
+ * merchant's: a token its issuer paused, or gave a transfer hook program
55
+ * (Mesub-io/backend#396). `mesub` for every cause of Mesub's.
53
56
  */
54
- type BlockedReason = 'puller_not_allowed' | 'receiver_not_allowed' | 'receiver_account_missing' | 'receiver_account_frozen' | 'mint_gone' | 'mesub';
57
+ type BlockedReason = 'puller_not_allowed' | 'receiver_not_allowed' | 'receiver_account_missing' | 'receiver_account_frozen' | 'receiver_account_needs_memo' | 'receiver_account_confidential_only' | 'mint_gone' | 'mint_paused' | 'mint_transfer_hook' | 'mesub';
55
58
  /**
56
59
  * `blocked` is a pull nothing was tried for, none of it the subscriber's
57
60
  * doing (Mesub's fee payer, the network): it never counts against them.
package/dist/testing.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
7
+ var _chunk5THDILDDcjs = require('./chunk-5THDILDD.cjs');
8
8
 
9
9
  // src/testing.ts
10
10
  var ACCESS_ATTEMPTS = 5;
@@ -108,8 +108,10 @@ var FakeMesub = (_class = class {
108
108
 
109
109
 
110
110
 
111
+ /** What `project()` answers: the id of the project the key belongs to. */
112
+ __init() {this.projectId = "proj_fake"}
111
113
  /** Every call received, oldest first. */
112
- __init() {this.requests = []}
114
+ __init2() {this.requests = []}
113
115
  /** Hand it to `new Mesub({ fetch })`, or use `client()`. */
114
116
 
115
117
  #plans;
@@ -143,7 +145,7 @@ var FakeMesub = (_class = class {
143
145
  #tier;
144
146
  /** The hand retries fired on each late subscription, and when the last one was, by id. */
145
147
  #handRetries = /* @__PURE__ */ new Map();
146
- constructor(options = {}) {;_class.prototype.__init.call(this);
148
+ constructor(options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
147
149
  this.baseUrl = (_nullishCoalesce(options.baseUrl, () => ( "https://api.mesub.test"))).replace(/\/+$/, "");
148
150
  this.apiKey = _nullishCoalesce(options.apiKey, () => ( "SUB_test_fake"));
149
151
  const plans = _optionalChain([options, 'access', _ => _.plans, 'optionalAccess', _2 => _2.map, 'call', _3 => _3(
@@ -166,7 +168,7 @@ var FakeMesub = (_class = class {
166
168
  * unless asked, so a failure shows at once. Any other option is passed on.
167
169
  */
168
170
  client(options = {}) {
169
- return new (0, _chunkIAYUXSDDcjs.Mesub)({
171
+ return new (0, _chunk5THDILDDcjs.Mesub)({
170
172
  maxRetries: 0,
171
173
  ...options,
172
174
  apiKey: this.apiKey,
@@ -262,7 +264,7 @@ var FakeMesub = (_class = class {
262
264
  * asked about, and to null for an external id or an email.
263
265
  */
264
266
  setAccess(customer, plan, fields) {
265
- const asked = _chunkIAYUXSDDcjs.customerOf.call(void 0, customer);
267
+ const asked = _chunk5THDILDDcjs.customerOf.call(void 0, customer);
266
268
  const answer = { ...nothing(asked, plan), ...fields, plan };
267
269
  this.#answers.set(keyOf(asked, plan), answer);
268
270
  return this.#fresh(answer);
@@ -350,7 +352,7 @@ var FakeMesub = (_class = class {
350
352
  type,
351
353
  created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
352
354
  network: "mainnet-beta",
353
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
355
+ api_version: _chunk5THDILDDcjs.API_VERSION,
354
356
  ...sequence !== null && { sequence },
355
357
  data,
356
358
  detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data))),
@@ -393,7 +395,7 @@ var FakeMesub = (_class = class {
393
395
  type,
394
396
  created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
395
397
  network: "mainnet-beta",
396
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
398
+ api_version: _chunk5THDILDDcjs.API_VERSION,
397
399
  ...sequence !== null && { sequence },
398
400
  data,
399
401
  detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data)))
@@ -499,7 +501,7 @@ var FakeMesub = (_class = class {
499
501
  type: each,
500
502
  created_at,
501
503
  network: "mainnet-beta",
502
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
504
+ api_version: _chunk5THDILDDcjs.API_VERSION,
503
505
  sequence: this.#nextSequence(subscription.id),
504
506
  data: structuredClone(data),
505
507
  detail: eachDetail
@@ -563,12 +565,12 @@ var FakeMesub = (_class = class {
563
565
  if (key !== this.apiKey) {
564
566
  return error(401, "invalid_api_key", "That API key is not valid.");
565
567
  }
566
- const version = headers.get(_chunkIAYUXSDDcjs.API_VERSION_HEADER);
567
- if (version !== null && version !== _chunkIAYUXSDDcjs.API_VERSION) {
568
+ const version = headers.get(_chunk5THDILDDcjs.API_VERSION_HEADER);
569
+ if (version !== null && version !== _chunk5THDILDDcjs.API_VERSION) {
568
570
  return error(
569
571
  400,
570
572
  "unsupported_version",
571
- `${_chunkIAYUXSDDcjs.API_VERSION_HEADER} must be one of the versions this API serves: ${_chunkIAYUXSDDcjs.API_VERSION}.`
573
+ `${_chunk5THDILDDcjs.API_VERSION_HEADER} must be one of the versions this API serves: ${_chunk5THDILDDcjs.API_VERSION}.`
572
574
  );
573
575
  }
574
576
  if (this.#failure) {
@@ -579,6 +581,8 @@ var FakeMesub = (_class = class {
579
581
  ...retryAfter !== void 0 && { retryAfter }
580
582
  });
581
583
  }
584
+ if (method === "GET" && path === "/v1/project")
585
+ return Response.json({ id: this.projectId });
582
586
  if (method === "GET" && path === "/v1/plans") {
583
587
  return Response.json({ plans: this.#planList.map((plan) => this.#served(plan)) });
584
588
  }
@@ -1018,7 +1022,7 @@ var FakeMesub = (_class = class {
1018
1022
  if (subscription.external_id) customers.push({ external_id: subscription.external_id });
1019
1023
  if (subscription.email) customers.push({ email: subscription.email });
1020
1024
  for (const customer of customers) {
1021
- const before = this.#answers.get(keyOf(_chunkIAYUXSDDcjs.customerOf.call(void 0, customer), plan));
1025
+ const before = this.#answers.get(keyOf(_chunk5THDILDDcjs.customerOf.call(void 0, customer), plan));
1022
1026
  this.setAccess(customer, plan, {
1023
1027
  wallet: subscription.wallet,
1024
1028
  access: subscription.access,
@@ -1288,7 +1292,7 @@ async function signWebhook(payload, options) {
1288
1292
  const body = typeof payload === "string" ? payload : JSON.stringify(payload);
1289
1293
  const id = _nullishCoalesce(options.id, () => ( `msg_signed_${signedIds += 1}`));
1290
1294
  const timestamp = _nullishCoalesce(options.timestamp, () => ( Math.floor(Date.now() / 1e3)));
1291
- return { body, headers: await _chunkIAYUXSDDcjs.signedHeaders.call(void 0, options.secret, id, timestamp, body) };
1295
+ return { body, headers: await _chunk5THDILDDcjs.signedHeaders.call(void 0, options.secret, id, timestamp, body) };
1292
1296
  }
1293
1297
  function detailOf(type, now, data) {
1294
1298
  const start = now.toISOString();
@@ -1391,7 +1395,7 @@ function invalidSubmit(body) {
1391
1395
  }
1392
1396
  function askedIn(query) {
1393
1397
  try {
1394
- return _chunkIAYUXSDDcjs.customerOf.call(void 0, {
1398
+ return _chunk5THDILDDcjs.customerOf.call(void 0, {
1395
1399
  wallet: query["wallet"],
1396
1400
  external_id: query["external_id"],
1397
1401
  email: query["email"]
@@ -1476,7 +1480,7 @@ function error(status, code, message, { retryable, retryAfter } = {}) {
1476
1480
  async function stamped(response, id) {
1477
1481
  const headers = new Headers(response.headers);
1478
1482
  headers.set(REQUEST_ID_HEADER, id);
1479
- headers.set(_chunkIAYUXSDDcjs.API_VERSION_HEADER, _chunkIAYUXSDDcjs.API_VERSION);
1483
+ headers.set(_chunk5THDILDDcjs.API_VERSION_HEADER, _chunk5THDILDDcjs.API_VERSION);
1480
1484
  if (response.ok) return new Response(response.body, { status: response.status, headers });
1481
1485
  const body = await response.json();
1482
1486
  return Response.json({ ...body, request_id: id }, { status: response.status, headers });