@mesub/node 0.1.4 → 0.1.5

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/express.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkK6U6FPTAcjs = require('./chunk-K6U6FPTA.cjs');
6
+ var _chunkD3MM42ZLcjs = require('./chunk-D3MM42ZL.cjs');
7
7
 
8
8
 
9
9
 
@@ -15,16 +15,16 @@ var _chunkK6U6FPTAcjs = require('./chunk-K6U6FPTA.cjs');
15
15
 
16
16
 
17
17
 
18
- var _chunkYCPYBU3Rcjs = require('./chunk-YCPYBU3R.cjs');
18
+ var _chunk6XJWKRCNcjs = require('./chunk-6XJWKRCN.cjs');
19
19
 
20
20
 
21
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
21
+ var _chunkSFK52JDWcjs = require('./chunk-SFK52JDW.cjs');
22
22
 
23
23
  // src/express.ts
24
24
  function forNext(error) {
25
- if (!(error instanceof _chunkIAYUXSDDcjs.MesubError) || error.status === null) return error;
25
+ if (!(error instanceof _chunkSFK52JDWcjs.MesubError) || error.status === null) return error;
26
26
  if (error.status < 400 || error.status >= 500) return error;
27
- return new (0, _chunkIAYUXSDDcjs.MesubError)(error.message, {
27
+ return new (0, _chunkSFK52JDWcjs.MesubError)(error.message, {
28
28
  status: 500,
29
29
  code: error.code,
30
30
  apiCode: error.apiCode,
@@ -36,30 +36,30 @@ function forNext(error) {
36
36
  });
37
37
  }
38
38
  function requirePlan(plan, options) {
39
- _chunkYCPYBU3Rcjs.checkPlan.call(void 0, plan);
40
- _chunkYCPYBU3Rcjs.checkCustomer.call(void 0, options);
39
+ _chunk6XJWKRCNcjs.checkPlan.call(void 0, plan);
40
+ _chunk6XJWKRCNcjs.checkCustomer.call(void 0, options);
41
41
  return async (req, res, next) => {
42
42
  try {
43
- const client = _nullishCoalesce(options.client, () => ( _chunkYCPYBU3Rcjs.defaultClient.call(void 0, )));
44
- const outcome = await _chunkYCPYBU3Rcjs.guard.call(void 0,
43
+ const client = _nullishCoalesce(options.client, () => ( _chunk6XJWKRCNcjs.defaultClient.call(void 0, )));
44
+ const outcome = await _chunk6XJWKRCNcjs.guard.call(void 0,
45
45
  client,
46
- await _chunkYCPYBU3Rcjs.askerOf.call(void 0, req, options.customer),
47
- () => _chunkYCPYBU3Rcjs.plansOf.call(void 0, plan, req)
46
+ await _chunk6XJWKRCNcjs.askerOf.call(void 0, req, options.customer),
47
+ () => _chunk6XJWKRCNcjs.plansOf.call(void 0, plan, req)
48
48
  );
49
49
  if (outcome.allowed) {
50
- const locals = _chunkYCPYBU3Rcjs.accessOf.call(void 0, outcome);
50
+ const locals = _chunk6XJWKRCNcjs.accessOf.call(void 0, outcome);
51
51
  res.locals["mesub"] = locals;
52
52
  return next();
53
53
  }
54
- const denial = _chunkYCPYBU3Rcjs.denialOf.call(void 0, outcome);
54
+ const denial = _chunk6XJWKRCNcjs.denialOf.call(void 0, outcome);
55
55
  if (options.onDenied) {
56
56
  await options.onDenied(denial, req, res, next);
57
57
  return;
58
58
  }
59
59
  if (outcome.reason === "unavailable") {
60
- res.setHeader("Retry-After", _chunkYCPYBU3Rcjs.retryAfterOf.call(void 0, outcome));
60
+ res.setHeader("Retry-After", _chunk6XJWKRCNcjs.retryAfterOf.call(void 0, outcome));
61
61
  }
62
- res.status(denial.status).json(_chunkYCPYBU3Rcjs.denialBody.call(void 0, outcome));
62
+ res.status(denial.status).json(_chunk6XJWKRCNcjs.denialBody.call(void 0, outcome));
63
63
  } catch (error) {
64
64
  next(forNext(error));
65
65
  }
@@ -74,14 +74,14 @@ async function jsonBody(req) {
74
74
  for await (const chunk of req) {
75
75
  const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
76
76
  size += bytes.length;
77
- if (size > _chunkK6U6FPTAcjs.MAX_BODY_BYTES) throw new RangeError("The body is too large.");
77
+ if (size > _chunkD3MM42ZLcjs.MAX_BODY_BYTES) throw new RangeError("The body is too large.");
78
78
  chunks.push(bytes);
79
79
  }
80
80
  if (size === 0) return void 0;
81
81
  return JSON.parse(Buffer.concat(chunks).toString("utf8"));
82
82
  }
83
83
  function mesubRoutes(options) {
84
- _chunkK6U6FPTAcjs.checkWidgetOptions.call(void 0, options);
84
+ _chunkD3MM42ZLcjs.checkWidgetOptions.call(void 0, options);
85
85
  return async (req, res, next) => {
86
86
  try {
87
87
  let body;
@@ -98,10 +98,10 @@ function mesubRoutes(options) {
98
98
  return;
99
99
  }
100
100
  const publicRead = req.method === "GET" && req.path.startsWith("/plans/");
101
- const asked = publicRead ? null : await _chunkK6U6FPTAcjs.widgetCustomer.call(void 0, req, options.customer);
101
+ const asked = publicRead ? null : await _chunkD3MM42ZLcjs.widgetCustomer.call(void 0, req, options.customer);
102
102
  const email = asked && options.email ? await options.email(req) : void 0;
103
- const answer = await _chunkK6U6FPTAcjs.handleWidget.call(void 0,
104
- _nullishCoalesce(options.client, () => ( _chunkYCPYBU3Rcjs.defaultClient.call(void 0, ))),
103
+ const answer = await _chunkD3MM42ZLcjs.handleWidget.call(void 0,
104
+ _nullishCoalesce(options.client, () => ( _chunk6XJWKRCNcjs.defaultClient.call(void 0, ))),
105
105
  {
106
106
  method: req.method,
107
107
  path: req.path,
@@ -125,5 +125,5 @@ function mesubRoutes(options) {
125
125
 
126
126
 
127
127
 
128
- exports.MesubError = _chunkIAYUXSDDcjs.MesubError; exports.mesubRoutes = mesubRoutes; exports.requirePlan = requirePlan;
128
+ exports.MesubError = _chunkSFK52JDWcjs.MesubError; exports.mesubRoutes = mesubRoutes; exports.requirePlan = requirePlan;
129
129
  //# sourceMappingURL=express.cjs.map
package/dist/express.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  checkWidgetOptions,
4
4
  handleWidget,
5
5
  widgetCustomer
6
- } from "./chunk-PFI3Y32I.js";
6
+ } from "./chunk-ELS6KPJQ.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-PH5LR5WA.js";
19
19
  import {
20
20
  MesubError
21
- } from "./chunk-IG4QRQSJ.js";
21
+ } from "./chunk-IHGJN3QZ.js";
22
22
 
23
23
  // src/express.ts
24
24
  function forNext(error) {
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
13
+ var _chunkSFK52JDWcjs = require('./chunk-SFK52JDW.cjs');
14
14
 
15
15
 
16
16
 
@@ -35,5 +35,5 @@ var _chunk43Q4PNF7cjs = require('./chunk-43Q4PNF7.cjs');
35
35
 
36
36
 
37
37
 
38
- exports.ACCESS_LINE = _chunk43Q4PNF7cjs.ACCESS_LINE; exports.API_VERSION = _chunkIAYUXSDDcjs.API_VERSION; exports.API_VERSION_HEADER = _chunkIAYUXSDDcjs.API_VERSION_HEADER; exports.AccessCache = _chunkIAYUXSDDcjs.AccessCache; exports.CONFIRMATIONS = _chunk43Q4PNF7cjs.CONFIRMATIONS; exports.DEFAULT_MAX_ENTRIES = _chunkIAYUXSDDcjs.DEFAULT_MAX_ENTRIES; exports.DEFAULT_MAX_STALE_MS = _chunkIAYUXSDDcjs.DEFAULT_MAX_STALE_MS; exports.MemoryStore = _chunkIAYUXSDDcjs.MemoryStore; exports.Mesub = _chunkIAYUXSDDcjs.Mesub; exports.MesubError = _chunkIAYUXSDDcjs.MesubError; exports.MesubSubmitError = _chunkIAYUXSDDcjs.MesubSubmitError; exports.SITUATIONS = _chunk43Q4PNF7cjs.SITUATIONS; exports.VERSION = _chunkIAYUXSDDcjs.VERSION; exports.explain = _chunk43Q4PNF7cjs.explain; exports.situationOf = _chunk43Q4PNF7cjs.situationOf; exports.verifyWebhook = _chunkIAYUXSDDcjs.verifyWebhook;
38
+ exports.ACCESS_LINE = _chunk43Q4PNF7cjs.ACCESS_LINE; exports.API_VERSION = _chunkSFK52JDWcjs.API_VERSION; exports.API_VERSION_HEADER = _chunkSFK52JDWcjs.API_VERSION_HEADER; exports.AccessCache = _chunkSFK52JDWcjs.AccessCache; exports.CONFIRMATIONS = _chunk43Q4PNF7cjs.CONFIRMATIONS; exports.DEFAULT_MAX_ENTRIES = _chunkSFK52JDWcjs.DEFAULT_MAX_ENTRIES; exports.DEFAULT_MAX_STALE_MS = _chunkSFK52JDWcjs.DEFAULT_MAX_STALE_MS; exports.MemoryStore = _chunkSFK52JDWcjs.MemoryStore; exports.Mesub = _chunkSFK52JDWcjs.Mesub; exports.MesubError = _chunkSFK52JDWcjs.MesubError; exports.MesubSubmitError = _chunkSFK52JDWcjs.MesubSubmitError; exports.SITUATIONS = _chunk43Q4PNF7cjs.SITUATIONS; exports.VERSION = _chunkSFK52JDWcjs.VERSION; exports.explain = _chunk43Q4PNF7cjs.explain; exports.situationOf = _chunk43Q4PNF7cjs.situationOf; exports.verifyWebhook = _chunkSFK52JDWcjs.verifyWebhook;
39
39
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -5,7 +5,7 @@ export { A as AccessAnswer, a as AccessList, b as AccessOptions, c as AttemptsPa
5
5
  export { ACCESS_LINE, CONFIRMATIONS, ConfirmationKey, ExplainOptions, Explainable, ExplainedAction, Explanation, SITUATIONS, Situation, SituationActionId, SituationActionTemplate, SituationActor, SituationKey, SituationText, explain, situationOf } from './situations.cjs';
6
6
 
7
7
  /** Kept in step with package.json by `test/version.spec.ts`. */
8
- declare const VERSION = "0.1.4";
8
+ declare const VERSION = "0.1.5";
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.d.ts CHANGED
@@ -5,7 +5,7 @@ export { A as AccessAnswer, a as AccessList, b as AccessOptions, c as AttemptsPa
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.4";
8
+ declare const VERSION = "0.1.5";
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
@@ -10,7 +10,7 @@ import {
10
10
  MesubSubmitError,
11
11
  VERSION,
12
12
  verifyWebhook
13
- } from "./chunk-IG4QRQSJ.js";
13
+ } from "./chunk-IHGJN3QZ.js";
14
14
  import {
15
15
  ACCESS_LINE,
16
16
  CONFIRMATIONS,
package/dist/nest.cjs CHANGED
@@ -9,10 +9,10 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkYCPYBU3Rcjs = require('./chunk-YCPYBU3R.cjs');
12
+ var _chunk6XJWKRCNcjs = require('./chunk-6XJWKRCN.cjs');
13
13
 
14
14
 
15
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
15
+ var _chunkSFK52JDWcjs = require('./chunk-SFK52JDW.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
+ _chunk6XJWKRCNcjs.checkPlan.call(void 0, plan);
29
+ _chunk6XJWKRCNcjs.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, () => ( _chunk6XJWKRCNcjs.defaultClient.call(void 0, )));
35
+ const outcome = await _chunk6XJWKRCNcjs.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 _chunk6XJWKRCNcjs.askerOf.call(void 0, request, options.customer),
38
+ () => _chunk6XJWKRCNcjs.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 = _chunk6XJWKRCNcjs.accessOf.call(void 0, outcome);
42
42
  return true;
43
43
  }
44
- const denial = _chunkYCPYBU3Rcjs.denialOf.call(void 0, outcome);
44
+ const denial = _chunk6XJWKRCNcjs.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", _chunk6XJWKRCNcjs.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)(_chunk6XJWKRCNcjs.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 = _chunkSFK52JDWcjs.MesubError; exports.RequirePlan = RequirePlan;
62
62
  //# sourceMappingURL=nest.cjs.map
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-PH5LR5WA.js";
13
13
  import {
14
14
  MesubError
15
- } from "./chunk-IG4QRQSJ.js";
15
+ } from "./chunk-IHGJN3QZ.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 _chunkD3MM42ZLcjs = require('./chunk-D3MM42ZL.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 _chunk6XJWKRCNcjs = require('./chunk-6XJWKRCN.cjs');
19
19
 
20
20
 
21
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
21
+ var _chunkSFK52JDWcjs = require('./chunk-SFK52JDW.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
+ _chunk6XJWKRCNcjs.checkPlan.call(void 0, options.plan);
26
+ _chunk6XJWKRCNcjs.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, () => ( _chunk6XJWKRCNcjs.defaultClient.call(void 0, )));
29
+ const outcome = await _chunk6XJWKRCNcjs.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 _chunk6XJWKRCNcjs.askerOf.call(void 0, request, options.customer),
32
+ () => _chunk6XJWKRCNcjs.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, _chunk6XJWKRCNcjs.accessOf.call(void 0, outcome), context);
35
+ const denial = _chunk6XJWKRCNcjs.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": _chunk6XJWKRCNcjs.retryAfterOf.call(void 0, outcome) } : {};
38
+ return Response.json(_chunk6XJWKRCNcjs.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")) > _chunkD3MM42ZLcjs.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 > _chunkD3MM42ZLcjs.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
+ _chunkD3MM42ZLcjs.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 _chunkD3MM42ZLcjs.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 _chunkD3MM42ZLcjs.handleWidget.call(void 0,
90
+ _nullishCoalesce(options.client, () => ( _chunk6XJWKRCNcjs.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 = _chunkSFK52JDWcjs.MesubError; exports.mesubRouteHandlers = mesubRouteHandlers; exports.withMesub = withMesub;
113
113
  //# sourceMappingURL=next.cjs.map
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-ELS6KPJQ.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-PH5LR5WA.js";
19
19
  import {
20
20
  MesubError
21
- } from "./chunk-IG4QRQSJ.js";
21
+ } from "./chunk-IHGJN3QZ.js";
22
22
 
23
23
  // src/next.ts
24
24
  function withMesub(handler, options) {
package/dist/testing.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkIAYUXSDDcjs = require('./chunk-IAYUXSDD.cjs');
7
+ var _chunkSFK52JDWcjs = require('./chunk-SFK52JDW.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, _chunkIAYUXSDDcjs.Mesub)({
169
+ return new (0, _chunkSFK52JDWcjs.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 = _chunkIAYUXSDDcjs.customerOf.call(void 0, customer);
265
+ const asked = _chunkSFK52JDWcjs.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);
@@ -350,7 +350,7 @@ var FakeMesub = (_class = class {
350
350
  type,
351
351
  created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
352
352
  network: "mainnet-beta",
353
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
353
+ api_version: _chunkSFK52JDWcjs.API_VERSION,
354
354
  ...sequence !== null && { sequence },
355
355
  data,
356
356
  detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data))),
@@ -393,7 +393,7 @@ var FakeMesub = (_class = class {
393
393
  type,
394
394
  created_at: _nullishCoalesce(fields.created_at, () => ( now.toISOString())),
395
395
  network: "mainnet-beta",
396
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
396
+ api_version: _chunkSFK52JDWcjs.API_VERSION,
397
397
  ...sequence !== null && { sequence },
398
398
  data,
399
399
  detail: _nullishCoalesce(fields.detail, () => ( detailOf(type, now, data)))
@@ -499,7 +499,7 @@ var FakeMesub = (_class = class {
499
499
  type: each,
500
500
  created_at,
501
501
  network: "mainnet-beta",
502
- api_version: _chunkIAYUXSDDcjs.API_VERSION,
502
+ api_version: _chunkSFK52JDWcjs.API_VERSION,
503
503
  sequence: this.#nextSequence(subscription.id),
504
504
  data: structuredClone(data),
505
505
  detail: eachDetail
@@ -563,12 +563,12 @@ var FakeMesub = (_class = class {
563
563
  if (key !== this.apiKey) {
564
564
  return error(401, "invalid_api_key", "That API key is not valid.");
565
565
  }
566
- const version = headers.get(_chunkIAYUXSDDcjs.API_VERSION_HEADER);
567
- if (version !== null && version !== _chunkIAYUXSDDcjs.API_VERSION) {
566
+ const version = headers.get(_chunkSFK52JDWcjs.API_VERSION_HEADER);
567
+ if (version !== null && version !== _chunkSFK52JDWcjs.API_VERSION) {
568
568
  return error(
569
569
  400,
570
570
  "unsupported_version",
571
- `${_chunkIAYUXSDDcjs.API_VERSION_HEADER} must be one of the versions this API serves: ${_chunkIAYUXSDDcjs.API_VERSION}.`
571
+ `${_chunkSFK52JDWcjs.API_VERSION_HEADER} must be one of the versions this API serves: ${_chunkSFK52JDWcjs.API_VERSION}.`
572
572
  );
573
573
  }
574
574
  if (this.#failure) {
@@ -1018,7 +1018,7 @@ var FakeMesub = (_class = class {
1018
1018
  if (subscription.external_id) customers.push({ external_id: subscription.external_id });
1019
1019
  if (subscription.email) customers.push({ email: subscription.email });
1020
1020
  for (const customer of customers) {
1021
- const before = this.#answers.get(keyOf(_chunkIAYUXSDDcjs.customerOf.call(void 0, customer), plan));
1021
+ const before = this.#answers.get(keyOf(_chunkSFK52JDWcjs.customerOf.call(void 0, customer), plan));
1022
1022
  this.setAccess(customer, plan, {
1023
1023
  wallet: subscription.wallet,
1024
1024
  access: subscription.access,
@@ -1288,7 +1288,7 @@ async function signWebhook(payload, options) {
1288
1288
  const body = typeof payload === "string" ? payload : JSON.stringify(payload);
1289
1289
  const id = _nullishCoalesce(options.id, () => ( `msg_signed_${signedIds += 1}`));
1290
1290
  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) };
1291
+ return { body, headers: await _chunkSFK52JDWcjs.signedHeaders.call(void 0, options.secret, id, timestamp, body) };
1292
1292
  }
1293
1293
  function detailOf(type, now, data) {
1294
1294
  const start = now.toISOString();
@@ -1391,7 +1391,7 @@ function invalidSubmit(body) {
1391
1391
  }
1392
1392
  function askedIn(query) {
1393
1393
  try {
1394
- return _chunkIAYUXSDDcjs.customerOf.call(void 0, {
1394
+ return _chunkSFK52JDWcjs.customerOf.call(void 0, {
1395
1395
  wallet: query["wallet"],
1396
1396
  external_id: query["external_id"],
1397
1397
  email: query["email"]
@@ -1476,7 +1476,7 @@ function error(status, code, message, { retryable, retryAfter } = {}) {
1476
1476
  async function stamped(response, id) {
1477
1477
  const headers = new Headers(response.headers);
1478
1478
  headers.set(REQUEST_ID_HEADER, id);
1479
- headers.set(_chunkIAYUXSDDcjs.API_VERSION_HEADER, _chunkIAYUXSDDcjs.API_VERSION);
1479
+ headers.set(_chunkSFK52JDWcjs.API_VERSION_HEADER, _chunkSFK52JDWcjs.API_VERSION);
1480
1480
  if (response.ok) return new Response(response.body, { status: response.status, headers });
1481
1481
  const body = await response.json();
1482
1482
  return Response.json({ ...body, request_id: id }, { status: response.status, headers });
package/dist/testing.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  Mesub,
5
5
  customerOf,
6
6
  signedHeaders
7
- } from "./chunk-IG4QRQSJ.js";
7
+ } from "./chunk-IHGJN3QZ.js";
8
8
 
9
9
  // src/testing.ts
10
10
  var ACCESS_ATTEMPTS = 5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mesub/node",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Mesub for Node: check a customer's access, take subscriptions and verify webhooks for subscription billing on Solana.",
5
5
  "license": "MIT",
6
6
  "repository": {