@fire-spark/core 0.13.2 → 0.14.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 (2) hide show
  1. package/dist/index.js +16 -4
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -4150,13 +4150,20 @@ const withUserTimeout = (promise, ms) => {
4150
4150
  });
4151
4151
  });
4152
4152
  };
4153
- var PaymentUserTimeout = class extends Error {};
4153
+ /** `name` survives minification: adapters tell a timeout from a cancel. */
4154
+ var PaymentUserTimeout = class extends Error {
4155
+ name = "PaymentUserTimeout";
4156
+ };
4157
+ /** A bank challenge (OTP page, app approval) takes longer than a prompt. */
4158
+ const CHALLENGE_TIMEOUT_MS = 6e5;
4154
4159
  const timedUI = (ui, deadline, interactionMs) => {
4155
- const wrap = (call) => {
4160
+ const wrap = (call, ms = interactionMs) => {
4156
4161
  deadline.pause();
4157
- return withUserTimeout(call(), interactionMs).finally(() => deadline.resume());
4162
+ return withUserTimeout(call(), ms).finally(() => deadline.resume());
4158
4163
  };
4159
- return {
4164
+ const challenge = ui.challenge?.bind(ui);
4165
+ const challengeMs = Math.max(interactionMs, CHALLENGE_TIMEOUT_MS);
4166
+ const timed = {
4160
4167
  message: (input) => ui.message(input),
4161
4168
  action: (input) => ui.action(input),
4162
4169
  select: (input) => {
@@ -4165,6 +4172,11 @@ const timedUI = (ui, deadline, interactionMs) => {
4165
4172
  input: (input) => wrap(() => ui.input(input)),
4166
4173
  confirm: (input) => wrap(() => ui.confirm(input))
4167
4174
  };
4175
+ if (!challenge) return timed;
4176
+ return {
4177
+ ...timed,
4178
+ challenge: (input) => wrap(() => challenge(input), challengeMs)
4179
+ };
4168
4180
  };
4169
4181
  /** Runs one adapter call with the provider timeout and the user clock. */
4170
4182
  const runTimed = async (ctx, call) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fire-spark/core",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "Fire Spark headless SDK",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -20,8 +20,8 @@
20
20
  "big.js": "6.2.1",
21
21
  "dayjs": "1.11.9",
22
22
  "@types/big.js": "6.2.2",
23
- "@fire-spark/payments": "^0.13.2",
24
- "@fire-spark/types": "^0.13.2"
23
+ "@fire-spark/payments": "^0.14.0",
24
+ "@fire-spark/types": "^0.14.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsdown": "^0.22.14",