@windrun-huaiin/backend-core 13.0.0 → 14.1.0

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 (110) hide show
  1. package/dist/_virtual/index.js +7 -3
  2. package/dist/_virtual/index.mjs +5 -3
  3. package/dist/_virtual/index2.js +2 -6
  4. package/dist/_virtual/index2.mjs +2 -6
  5. package/dist/index.js +3 -1
  6. package/dist/index.mjs +2 -2
  7. package/dist/lib/index.js +3 -1
  8. package/dist/lib/index.mjs +2 -2
  9. package/dist/lib/stripe-config.d.ts +1 -1
  10. package/dist/lib/stripe-config.d.ts.map +1 -1
  11. package/dist/lib/stripe-config.js +25 -16
  12. package/dist/lib/stripe-config.mjs +25 -16
  13. package/dist/lib/upstash/qstash.d.ts.map +1 -1
  14. package/dist/lib/upstash/qstash.js +66 -62
  15. package/dist/lib/upstash/qstash.mjs +67 -63
  16. package/dist/lib/upstash/redis-counter.d.ts.map +1 -1
  17. package/dist/lib/upstash/redis-counter.js +9 -24
  18. package/dist/lib/upstash/redis-counter.mjs +10 -25
  19. package/dist/lib/upstash/redis-favorite.d.ts.map +1 -1
  20. package/dist/lib/upstash/redis-favorite.js +22 -36
  21. package/dist/lib/upstash/redis-favorite.mjs +23 -37
  22. package/dist/lib/upstash/redis-like.d.ts.map +1 -1
  23. package/dist/lib/upstash/redis-like.js +22 -36
  24. package/dist/lib/upstash/redis-like.mjs +23 -37
  25. package/dist/lib/upstash/redis-lock.d.ts.map +1 -1
  26. package/dist/lib/upstash/redis-lock.js +22 -38
  27. package/dist/lib/upstash/redis-lock.mjs +23 -39
  28. package/dist/lib/upstash/redis-structures.d.ts.map +1 -1
  29. package/dist/lib/upstash/redis-structures.js +77 -113
  30. package/dist/lib/upstash/redis-structures.mjs +78 -114
  31. package/dist/lib/upstash-config.d.ts +9 -1
  32. package/dist/lib/upstash-config.d.ts.map +1 -1
  33. package/dist/lib/upstash-config.js +221 -27
  34. package/dist/lib/upstash-config.mjs +220 -28
  35. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.js → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.js} +897 -468
  36. package/dist/node_modules/.pnpm/{@upstash_qstash@2.8.4/node_modules/@upstash/qstash/chunk-RQPZUJXG.mjs → @upstash_qstash@2.10.1/node_modules/@upstash/qstash/chunk-35B33QW3.mjs} +895 -468
  37. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.js → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.js} +657 -40
  38. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1/node_modules/@upstash/redis/chunk-LLI2WIYN.mjs → @upstash_redis@1.37.0/node_modules/@upstash/redis/chunk-IH7W44G6.mjs} +657 -41
  39. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.js +6 -5
  40. package/dist/node_modules/.pnpm/{@upstash_redis@1.36.1 → @upstash_redis@1.37.0}/node_modules/@upstash/redis/nodejs.mjs +2 -2
  41. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.js +1 -1
  42. package/dist/node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/index.mjs +1 -1
  43. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jws/flattened/verify.js +6 -6
  44. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/jwt/verify.js +1 -1
  45. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/key/import.js +2 -2
  46. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/epoch.js +3 -1
  47. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_disjoint.js +3 -1
  48. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_jwk.js +1 -1
  49. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/is_object.js +3 -1
  50. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/jwt_claims_set.js +7 -5
  51. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/secs.js +3 -1
  52. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_algorithms.js +3 -1
  53. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/lib/validate_crit.js +3 -1
  54. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js +3 -1
  55. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js +3 -1
  56. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js +4 -2
  57. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js +3 -1
  58. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js +3 -1
  59. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_like.js +1 -1
  60. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/is_key_object.js +3 -1
  61. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/jwk_to_key.js +3 -1
  62. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/node_key.js +6 -4
  63. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/sign.js +6 -4
  64. package/dist/node_modules/.pnpm/jose@5.10.0/node_modules/jose/dist/node/esm/runtime/verify.js +7 -5
  65. package/dist/services/stripe/webhook-handler.js +4 -2
  66. package/dist/services/stripe/webhook-handler.mjs +3 -1
  67. package/package.json +5 -5
  68. package/src/lib/stripe-config.ts +27 -15
  69. package/src/lib/upstash/qstash.ts +64 -62
  70. package/src/lib/upstash/redis-counter.ts +10 -26
  71. package/src/lib/upstash/redis-favorite.ts +23 -42
  72. package/src/lib/upstash/redis-like.ts +23 -42
  73. package/src/lib/upstash/redis-lock.ts +23 -49
  74. package/src/lib/upstash/redis-structures.ts +82 -131
  75. package/src/lib/upstash-config.ts +231 -24
  76. package/src/services/stripe/webhook-handler.ts +3 -1
  77. package/dist/_virtual/index3.js +0 -5
  78. package/dist/_virtual/index3.mjs +0 -3
  79. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.js +0 -191
  80. package/dist/node_modules/.pnpm/@upstash_lock@0.2.1_typescript@5.9.3/node_modules/@upstash/lock/dist/index.mjs +0 -189
  81. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.js +0 -54
  82. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/errors.mjs +0 -51
  83. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.js +0 -44
  84. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/iso.mjs +0 -35
  85. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.js +0 -31
  86. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/parse.mjs +0 -18
  87. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.js +0 -587
  88. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/classic/schemas.mjs +0 -527
  89. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.js +0 -447
  90. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/api.mjs +0 -399
  91. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.js +0 -245
  92. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/checks.mjs +0 -232
  93. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.js +0 -68
  94. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/core.mjs +0 -62
  95. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.js +0 -39
  96. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/doc.mjs +0 -37
  97. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.js +0 -80
  98. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/errors.mjs +0 -75
  99. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.js +0 -101
  100. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/parse.mjs +0 -86
  101. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.js +0 -102
  102. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/regexes.mjs +0 -76
  103. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.js +0 -56
  104. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/registries.mjs +0 -52
  105. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.js +0 -1205
  106. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/schemas.mjs +0 -1157
  107. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.js +0 -407
  108. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/util.mjs +0 -374
  109. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.js +0 -9
  110. package/dist/node_modules/.pnpm/zod@4.1.12/node_modules/zod/v4/core/versions.mjs +0 -7
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkLLI2WIYN = require('./chunk-LLI2WIYN.js');
3
+ var chunkIH7W44G6 = require('./chunk-IH7W44G6.js');
4
4
 
5
5
  // platforms/nodejs.ts
6
6
  if (typeof atob === "undefined") {
7
7
  global.atob = (b64) => Buffer.from(b64, "base64").toString("utf8");
8
8
  }
9
- var Redis2 = class _Redis extends chunkLLI2WIYN.Redis {
9
+ var Redis2 = class _Redis extends chunkIH7W44G6.Redis {
10
10
  /**
11
11
  * Create a new redis client by providing a custom `Requester` implementation
12
12
  *
@@ -47,7 +47,7 @@ var Redis2 = class _Redis extends chunkLLI2WIYN.Redis {
47
47
  "[Upstash Redis] The redis token contains whitespace or newline, which can cause errors!"
48
48
  );
49
49
  }
50
- const client = new chunkLLI2WIYN.HttpClient({
50
+ const client = new chunkIH7W44G6.HttpClient({
51
51
  baseUrl: configOrRequester.url,
52
52
  retry: configOrRequester.retry,
53
53
  headers: { authorization: `Bearer ${configOrRequester.token}` },
@@ -72,7 +72,7 @@ var Redis2 = class _Redis extends chunkLLI2WIYN.Redis {
72
72
  typeof EdgeRuntime === "string" ? "edge-light" : nodeVersion ? `node@${nodeVersion}` : "unknown"
73
73
  ),
74
74
  platform: safeEnv.UPSTASH_CONSOLE ? "console" : safeEnv.VERCEL ? "vercel" : safeEnv.AWS_REGION ? "aws" : "unknown",
75
- sdk: `@upstash/redis@${chunkLLI2WIYN.VERSION}`
75
+ sdk: `@upstash/redis@${chunkIH7W44G6.VERSION}`
76
76
  });
77
77
  if (this.enableAutoPipelining) {
78
78
  return this.autoPipeline();
@@ -111,5 +111,6 @@ var Redis2 = class _Redis extends chunkLLI2WIYN.Redis {
111
111
  }
112
112
  };
113
113
 
114
- exports.errors = chunkLLI2WIYN.error_exports;
114
+ exports.SearchIndex = chunkIH7W44G6.SearchIndex;
115
+ exports.errors = chunkIH7W44G6.error_exports;
115
116
  exports.Redis = Redis2;
@@ -1,5 +1,5 @@
1
- import { Redis, HttpClient, VERSION } from './chunk-LLI2WIYN.mjs';
2
- export { error_exports as errors } from './chunk-LLI2WIYN.mjs';
1
+ import { Redis, HttpClient, VERSION } from './chunk-IH7W44G6.mjs';
2
+ export { SearchIndex, error_exports as errors } from './chunk-IH7W44G6.mjs';
3
3
 
4
4
  // platforms/nodejs.ts
5
5
  if (typeof atob === "undefined") {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('../../../../../_virtual/index3.js');
3
+ var index = require('../../../../../_virtual/index2.js');
4
4
  var core = require('./core.js');
5
5
  var x64Core = require('./x64-core.js');
6
6
  var libTypedarrays = require('./lib-typedarrays.js');
@@ -1,4 +1,4 @@
1
- import { __module as cryptoJs$1 } from '../../../../../_virtual/index3.mjs';
1
+ import { __module as cryptoJs$1 } from '../../../../../_virtual/index2.mjs';
2
2
  import { __require as requireCore } from './core.mjs';
3
3
  import { __require as requireX64Core } from './x64-core.mjs';
4
4
  import { __require as requireLibTypedarrays } from './lib-typedarrays.mjs';
@@ -13,7 +13,7 @@ var is_jwk = require('../../lib/is_jwk.js');
13
13
  var _import = require('../../key/import.js');
14
14
 
15
15
  async function flattenedVerify(jws, key, options) {
16
- if (!is_object(jws)) {
16
+ if (!is_object.default(jws)) {
17
17
  throw new errors.JWSInvalid('Flattened JWS must be an object');
18
18
  }
19
19
  if (jws.protected === undefined && jws.header === undefined) {
@@ -28,7 +28,7 @@ async function flattenedVerify(jws, key, options) {
28
28
  if (typeof jws.signature !== 'string') {
29
29
  throw new errors.JWSInvalid('JWS Signature missing or incorrect type');
30
30
  }
31
- if (jws.header !== undefined && !is_object(jws.header)) {
31
+ if (jws.header !== undefined && !is_object.default(jws.header)) {
32
32
  throw new errors.JWSInvalid('JWS Unprotected Header incorrect type');
33
33
  }
34
34
  let parsedProt = {};
@@ -41,14 +41,14 @@ async function flattenedVerify(jws, key, options) {
41
41
  throw new errors.JWSInvalid('JWS Protected Header is invalid');
42
42
  }
43
43
  }
44
- if (!is_disjoint(parsedProt, jws.header)) {
44
+ if (!is_disjoint.default(parsedProt, jws.header)) {
45
45
  throw new errors.JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');
46
46
  }
47
47
  const joseHeader = {
48
48
  ...parsedProt,
49
49
  ...jws.header,
50
50
  };
51
- const extensions = validate_crit(errors.JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);
51
+ const extensions = validate_crit.default(errors.JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);
52
52
  let b64 = true;
53
53
  if (extensions.has('b64')) {
54
54
  b64 = parsedProt.b64;
@@ -60,7 +60,7 @@ async function flattenedVerify(jws, key, options) {
60
60
  if (typeof alg !== 'string' || !alg) {
61
61
  throw new errors.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
62
62
  }
63
- const algorithms = options && validate_algorithms('algorithms', options.algorithms);
63
+ const algorithms = options && validate_algorithms.default('algorithms', options.algorithms);
64
64
  if (algorithms && !algorithms.has(alg)) {
65
65
  throw new errors.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
66
66
  }
@@ -92,7 +92,7 @@ async function flattenedVerify(jws, key, options) {
92
92
  catch {
93
93
  throw new errors.JWSInvalid('Failed to base64url decode the signature');
94
94
  }
95
- const verified = await verify(alg, key, signature, data);
95
+ const verified = await verify.default(alg, key, signature, data);
96
96
  if (!verified) {
97
97
  throw new errors.JWSSignatureVerificationFailed();
98
98
  }
@@ -9,7 +9,7 @@ async function jwtVerify(jwt, key, options) {
9
9
  if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) {
10
10
  throw new errors.JWTInvalid('JWTs MUST NOT use unencoded payload');
11
11
  }
12
- const payload = jwt_claims_set(verified.protectedHeader, verified.payload, options);
12
+ const payload = jwt_claims_set.default(verified.protectedHeader, verified.payload, options);
13
13
  const result = { payload, protectedHeader: verified.protectedHeader };
14
14
  if (typeof key === 'function') {
15
15
  return { ...result, key: verified.key };
@@ -6,7 +6,7 @@ var errors = require('../util/errors.js');
6
6
  var is_object = require('../lib/is_object.js');
7
7
 
8
8
  async function importJWK(jwk, alg) {
9
- if (!is_object(jwk)) {
9
+ if (!is_object.default(jwk)) {
10
10
  throw new TypeError('JWK must be an object');
11
11
  }
12
12
  alg ||= jwk.alg;
@@ -22,7 +22,7 @@ async function importJWK(jwk, alg) {
22
22
  }
23
23
  case 'EC':
24
24
  case 'OKP':
25
- return jwk_to_key({ ...jwk, alg });
25
+ return jwk_to_key.default({ ...jwk, alg });
26
26
  default:
27
27
  throw new errors.JOSENotSupported('Unsupported "kty" (Key Type) Parameter value');
28
28
  }
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var epoch = (date) => Math.floor(date.getTime() / 1000);
4
6
 
5
- module.exports = epoch;
7
+ exports.default = epoch;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const isDisjoint = (...headers) => {
4
6
  const sources = headers.filter(Boolean);
5
7
  if (sources.length === 0 || sources.length === 1) {
@@ -22,4 +24,4 @@ const isDisjoint = (...headers) => {
22
24
  return true;
23
25
  };
24
26
 
25
- module.exports = isDisjoint;
27
+ exports.default = isDisjoint;
@@ -3,7 +3,7 @@
3
3
  var is_object = require('./is_object.js');
4
4
 
5
5
  function isJWK(key) {
6
- return is_object(key) && typeof key.kty === 'string';
6
+ return is_object.default(key) && typeof key.kty === 'string';
7
7
  }
8
8
  function isPrivateJWK(key) {
9
9
  return key.kty !== 'oct' && typeof key.d === 'string';
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  function isObjectLike(value) {
4
6
  return typeof value === 'object' && value !== null;
5
7
  }
@@ -17,4 +19,4 @@ function isObject(input) {
17
19
  return Object.getPrototypeOf(input) === proto;
18
20
  }
19
21
 
20
- module.exports = isObject;
22
+ exports.default = isObject;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var errors = require('../util/errors.js');
4
6
  var buffer_utils = require('./buffer_utils.js');
5
7
  var epoch = require('./epoch.js');
@@ -23,7 +25,7 @@ var jwtPayload = (protectedHeader, encodedPayload, options = {}) => {
23
25
  }
24
26
  catch {
25
27
  }
26
- if (!is_object(payload)) {
28
+ if (!is_object.default(payload)) {
27
29
  throw new errors.JWTInvalid('JWT Claims Set must be a top-level JSON object');
28
30
  }
29
31
  const { typ } = options;
@@ -61,7 +63,7 @@ var jwtPayload = (protectedHeader, encodedPayload, options = {}) => {
61
63
  let tolerance;
62
64
  switch (typeof options.clockTolerance) {
63
65
  case 'string':
64
- tolerance = secs(options.clockTolerance);
66
+ tolerance = secs.default(options.clockTolerance);
65
67
  break;
66
68
  case 'number':
67
69
  tolerance = options.clockTolerance;
@@ -73,7 +75,7 @@ var jwtPayload = (protectedHeader, encodedPayload, options = {}) => {
73
75
  throw new TypeError('Invalid clockTolerance option type');
74
76
  }
75
77
  const { currentDate } = options;
76
- const now = epoch(currentDate || new Date());
78
+ const now = epoch.default(currentDate || new Date());
77
79
  if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {
78
80
  throw new errors.JWTClaimValidationFailed('"iat" claim must be a number', payload, 'iat', 'invalid');
79
81
  }
@@ -95,7 +97,7 @@ var jwtPayload = (protectedHeader, encodedPayload, options = {}) => {
95
97
  }
96
98
  if (maxTokenAge) {
97
99
  const age = now - payload.iat;
98
- const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);
100
+ const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs.default(maxTokenAge);
99
101
  if (age - tolerance > max) {
100
102
  throw new errors.JWTExpired('"iat" claim timestamp check failed (too far in the past)', payload, 'iat', 'check_failed');
101
103
  }
@@ -106,4 +108,4 @@ var jwtPayload = (protectedHeader, encodedPayload, options = {}) => {
106
108
  return payload;
107
109
  };
108
110
 
109
- module.exports = jwtPayload;
111
+ exports.default = jwtPayload;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const minute = 60;
4
6
  const hour = minute * 60;
5
7
  const day = hour * 24;
@@ -56,4 +58,4 @@ var secs = (str) => {
56
58
  return numericDate;
57
59
  };
58
60
 
59
- module.exports = secs;
61
+ exports.default = secs;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const validateAlgorithms = (option, algorithms) => {
4
6
  if (algorithms !== undefined &&
5
7
  (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {
@@ -11,4 +13,4 @@ const validateAlgorithms = (option, algorithms) => {
11
13
  return new Set(algorithms);
12
14
  };
13
15
 
14
- module.exports = validateAlgorithms;
16
+ exports.default = validateAlgorithms;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var errors = require('../util/errors.js');
4
6
 
5
7
  function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
@@ -35,4 +37,4 @@ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader,
35
37
  return new Set(protectedHeader.crit);
36
38
  }
37
39
 
38
- module.exports = validateCrit;
40
+ exports.default = validateCrit;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
 
5
7
  var checkKeyLength = (key, alg) => {
@@ -18,4 +20,4 @@ var checkKeyLength = (key, alg) => {
18
20
  }
19
21
  };
20
22
 
21
- module.exports = checkKeyLength;
23
+ exports.default = checkKeyLength;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var errors = require('../util/errors.js');
4
6
 
5
7
  function dsaDigest(alg) {
@@ -25,4 +27,4 @@ function dsaDigest(alg) {
25
27
  }
26
28
  }
27
29
 
28
- module.exports = dsaDigest;
30
+ exports.default = dsaDigest;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
  var errors = require('../util/errors.js');
5
7
  var webcrypto = require('./webcrypto.js');
@@ -27,7 +29,7 @@ const getNamedCurve = (kee, raw) => {
27
29
  if (webcrypto.isCryptoKey(kee)) {
28
30
  key = crypto.KeyObject.from(kee);
29
31
  }
30
- else if (is_key_object(kee)) {
32
+ else if (is_key_object.default(kee)) {
31
33
  key = kee;
32
34
  }
33
35
  else if (is_jwk.isJWK(kee)) {
@@ -55,4 +57,4 @@ const getNamedCurve = (kee, raw) => {
55
57
  }
56
58
  };
57
59
 
58
- module.exports = getNamedCurve;
60
+ exports.default = getNamedCurve;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
  var webcrypto = require('./webcrypto.js');
5
7
  var crypto_key = require('../lib/crypto_key.js');
@@ -30,4 +32,4 @@ function getSignVerifyKey(alg, key, usage) {
30
32
  throw new TypeError(invalid_key_input.default(key, ...is_key_like.types, 'Uint8Array', 'JSON Web Key'));
31
33
  }
32
34
 
33
- module.exports = getSignVerifyKey;
35
+ exports.default = getSignVerifyKey;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var errors = require('../util/errors.js');
4
6
 
5
7
  function hmacDigest(alg) {
@@ -15,4 +17,4 @@ function hmacDigest(alg) {
15
17
  }
16
18
  }
17
19
 
18
- module.exports = hmacDigest;
20
+ exports.default = hmacDigest;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var webcrypto = require('./webcrypto.js');
6
6
  var is_key_object = require('./is_key_object.js');
7
7
 
8
- var isKeyLike = (key) => is_key_object(key) || webcrypto.isCryptoKey(key);
8
+ var isKeyLike = (key) => is_key_object.default(key) || webcrypto.isCryptoKey(key);
9
9
  const types = ['KeyObject'];
10
10
  if (globalThis.CryptoKey || webcrypto.default?.CryptoKey) {
11
11
  types.push('CryptoKey');
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var util = require('node:util');
4
6
 
5
7
  function _interopNamespaceDefault(e) {
@@ -23,4 +25,4 @@ var util__namespace = /*#__PURE__*/_interopNamespaceDefault(util);
23
25
 
24
26
  var isKeyObject = (obj) => util__namespace.types.isKeyObject(obj);
25
27
 
26
- module.exports = isKeyObject;
28
+ exports.default = isKeyObject;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
 
5
7
  const parse = (key) => {
@@ -9,4 +11,4 @@ const parse = (key) => {
9
11
  return crypto.createPublicKey({ format: 'jwk', key });
10
12
  };
11
13
 
12
- module.exports = parse;
14
+ exports.default = parse;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
  var get_named_curve = require('./get_named_curve.js');
5
7
  var errors = require('../util/errors.js');
@@ -61,7 +63,7 @@ function keyForCrypto(alg, key) {
61
63
  if (asymmetricKeyType !== 'rsa') {
62
64
  throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');
63
65
  }
64
- check_key_length(key, alg);
66
+ check_key_length.default(key, alg);
65
67
  break;
66
68
  case 'PS256':
67
69
  case 'PS384':
@@ -80,7 +82,7 @@ function keyForCrypto(alg, key) {
80
82
  else if (asymmetricKeyType !== 'rsa') {
81
83
  throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss');
82
84
  }
83
- check_key_length(key, alg);
85
+ check_key_length.default(key, alg);
84
86
  options = {
85
87
  padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
86
88
  saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST,
@@ -93,7 +95,7 @@ function keyForCrypto(alg, key) {
93
95
  if (asymmetricKeyType !== 'ec') {
94
96
  throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be ec');
95
97
  }
96
- const actual = get_named_curve(key);
98
+ const actual = get_named_curve.default(key);
97
99
  const expected = ecCurveAlgMap.get(alg);
98
100
  if (actual !== expected) {
99
101
  throw new TypeError(`Invalid key curve for the algorithm, its curve must be ${expected}, got ${actual}`);
@@ -110,4 +112,4 @@ function keyForCrypto(alg, key) {
110
112
  return options ? { ...options, key } : key;
111
113
  }
112
114
 
113
- module.exports = keyForCrypto;
115
+ exports.default = keyForCrypto;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
  var util = require('node:util');
5
7
  var dsa_digest = require('./dsa_digest.js');
@@ -28,13 +30,13 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
28
30
 
29
31
  const oneShotSign = util.promisify(crypto__namespace.sign);
30
32
  const sign = async (alg, key, data) => {
31
- const k = get_sign_verify_key(alg, key, 'sign');
33
+ const k = get_sign_verify_key.default(alg, key, 'sign');
32
34
  if (alg.startsWith('HS')) {
33
- const hmac = crypto__namespace.createHmac(hmac_digest(alg), k);
35
+ const hmac = crypto__namespace.createHmac(hmac_digest.default(alg), k);
34
36
  hmac.update(data);
35
37
  return hmac.digest();
36
38
  }
37
- return oneShotSign(dsa_digest(alg), data, node_key(alg, k));
39
+ return oneShotSign(dsa_digest.default(alg), data, node_key.default(alg, k));
38
40
  };
39
41
 
40
- module.exports = sign;
42
+ exports.default = sign;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var crypto = require('node:crypto');
4
6
  var util = require('node:util');
5
7
  var dsa_digest = require('./dsa_digest.js');
@@ -28,9 +30,9 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
28
30
 
29
31
  const oneShotVerify = util.promisify(crypto__namespace.verify);
30
32
  const verify = async (alg, key, signature, data) => {
31
- const k = get_sign_verify_key(alg, key, 'verify');
33
+ const k = get_sign_verify_key.default(alg, key, 'verify');
32
34
  if (alg.startsWith('HS')) {
33
- const expected = await sign(alg, k, data);
35
+ const expected = await sign.default(alg, k, data);
34
36
  const actual = signature;
35
37
  try {
36
38
  return crypto__namespace.timingSafeEqual(actual, expected);
@@ -39,8 +41,8 @@ const verify = async (alg, key, signature, data) => {
39
41
  return false;
40
42
  }
41
43
  }
42
- const algorithm = dsa_digest(alg);
43
- const keyInput = node_key(alg, k);
44
+ const algorithm = dsa_digest.default(alg);
45
+ const keyInput = node_key.default(alg, k);
44
46
  try {
45
47
  return await oneShotVerify(algorithm, data, keyInput, signature);
46
48
  }
@@ -49,4 +51,4 @@ const verify = async (alg, key, signature, data) => {
49
51
  }
50
52
  };
51
53
 
52
- module.exports = verify;
54
+ exports.default = verify;
@@ -122,9 +122,10 @@ function handleSubscriptionCheckoutInit(session, transaction) {
122
122
  throw new Error('No subscription ID in checkout session');
123
123
  }
124
124
  const subscriptionId = session.subscription;
125
+ const stripe = stripeConfig.getStripe();
125
126
  // ===== STEP 1: FETCH EXTERNAL API DATA (BEFORE TRANSACTION) =====
126
127
  // 2. Get COMPLETE Stripe subscription details including billing period
127
- const stripeSubscription = yield stripeConfig.stripe.subscriptions.retrieve(subscriptionId);
128
+ const stripeSubscription = yield stripe.subscriptions.retrieve(subscriptionId);
128
129
  // Extract billing period from subscription items (NOT from top-level subscription object)
129
130
  // The current_period_start/end are on SubscriptionItem, not on Subscription
130
131
  const subscriptionItem = (_b = (_a = stripeSubscription.items) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b[0];
@@ -343,8 +344,9 @@ function handleSubscriptionDeleted(stripeSubscription) {
343
344
  function handleAsyncPaymentSucceeded(session) {
344
345
  return tslib_es6.__awaiter(this, void 0, void 0, function* () {
345
346
  console.log(`Async payment succeeded: ${session.id}`);
347
+ const stripe = stripeConfig.getStripe();
346
348
  // Retrieve the latest session state to ensure payment_status is up to date
347
- const latestSession = yield stripeConfig.stripe.checkout.sessions.retrieve(session.id);
349
+ const latestSession = yield stripe.checkout.sessions.retrieve(session.id);
348
350
  return yield handleCheckoutCompleted(latestSession);
349
351
  });
350
352
  }
@@ -9,7 +9,7 @@ import '@prisma/client';
9
9
  import { Apilogger } from '../database/apilog.service.mjs';
10
10
  import { oneTimeExpiredDays } from '../../lib/credit-init.mjs';
11
11
  import { getCreditsFromPriceId } from '../../lib/money-price-config.mjs';
12
- import { stripe, fetchPaymentId } from '../../lib/stripe-config.mjs';
12
+ import { getStripe, fetchPaymentId } from '../../lib/stripe-config.mjs';
13
13
  import { viewLocalTime } from '@windrun-huaiin/lib/utils';
14
14
 
15
15
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -120,6 +120,7 @@ function handleSubscriptionCheckoutInit(session, transaction) {
120
120
  throw new Error('No subscription ID in checkout session');
121
121
  }
122
122
  const subscriptionId = session.subscription;
123
+ const stripe = getStripe();
123
124
  // ===== STEP 1: FETCH EXTERNAL API DATA (BEFORE TRANSACTION) =====
124
125
  // 2. Get COMPLETE Stripe subscription details including billing period
125
126
  const stripeSubscription = yield stripe.subscriptions.retrieve(subscriptionId);
@@ -341,6 +342,7 @@ function handleSubscriptionDeleted(stripeSubscription) {
341
342
  function handleAsyncPaymentSucceeded(session) {
342
343
  return __awaiter(this, void 0, void 0, function* () {
343
344
  console.log(`Async payment succeeded: ${session.id}`);
345
+ const stripe = getStripe();
344
346
  // Retrieve the latest session state to ensure payment_status is up to date
345
347
  const latestSession = yield stripe.checkout.sessions.retrieve(session.id);
346
348
  return yield handleCheckoutCompleted(latestSession);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/backend-core",
3
- "version": "13.0.0",
3
+ "version": "14.1.0",
4
4
  "description": "Shared backend primitives: Prisma schema/client, database services, routing helpers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "LICENSE"
85
85
  ],
86
86
  "dependencies": {
87
- "@clerk/nextjs": "^6.39.0",
87
+ "@clerk/nextjs": "^7.0.5",
88
88
  "@prisma/client": "^6.17.1",
89
89
  "@upstash/redis": "^1.34.0",
90
90
  "@upstash/qstash": "^2.7.0",
@@ -94,8 +94,8 @@
94
94
  "stripe": "20.0.0",
95
95
  "svix": "^1.86.0",
96
96
  "zod": "^4.3.6",
97
- "@windrun-huaiin/lib": "^13.0.0",
98
- "@windrun-huaiin/third-ui": "^13.0.0"
97
+ "@windrun-huaiin/lib": "^14.0.0",
98
+ "@windrun-huaiin/third-ui": "^14.0.0"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@rollup/plugin-alias": "^5.1.1",
@@ -107,7 +107,7 @@
107
107
  "typescript": "^5.8.3"
108
108
  },
109
109
  "peerDependencies": {
110
- "@clerk/nextjs": "^6.39.0",
110
+ "@clerk/nextjs": "^7.0.5",
111
111
  "@prisma/client": "^6.17.1",
112
112
  "next": "16.1.6",
113
113
  "prisma": "^6.17.1",