@stripe/link-cli 0.3.0 → 0.4.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.
- package/dist/cli.js +490 -488
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11358,7 +11358,7 @@ var Login = ({
|
|
|
11358
11358
|
] });
|
|
11359
11359
|
}
|
|
11360
11360
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingY: 1, children: [
|
|
11361
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "
|
|
11361
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "Authentication" }) }),
|
|
11362
11362
|
/* @__PURE__ */ jsxs(
|
|
11363
11363
|
Box,
|
|
11364
11364
|
{
|
|
@@ -11432,8 +11432,62 @@ var statusOptions = z.object({
|
|
|
11432
11432
|
timeout: z.coerce.number().default(300).describe("Polling timeout in seconds.")
|
|
11433
11433
|
});
|
|
11434
11434
|
|
|
11435
|
+
// src/commands/auth/status.tsx
|
|
11436
|
+
import { Box as Box3, Text as Text3 } from "ink";
|
|
11437
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
11438
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
11439
|
+
var AuthStatus = ({ onComplete }) => {
|
|
11440
|
+
const [checked, setChecked] = useState3(false);
|
|
11441
|
+
const [authenticated, setAuthenticated] = useState3(false);
|
|
11442
|
+
const [tokenPreview, setTokenPreview] = useState3("");
|
|
11443
|
+
const [tokenType, setTokenType] = useState3("");
|
|
11444
|
+
const [credentialsPath, setCredentialsPath] = useState3("");
|
|
11445
|
+
useEffect3(() => {
|
|
11446
|
+
const auth = storage.getAuth();
|
|
11447
|
+
const credentialsPath2 = storage.getPath();
|
|
11448
|
+
if (auth) {
|
|
11449
|
+
setAuthenticated(true);
|
|
11450
|
+
setTokenPreview(`${auth.access_token.substring(0, 20)}...`);
|
|
11451
|
+
setTokenType(auth.token_type);
|
|
11452
|
+
}
|
|
11453
|
+
setCredentialsPath(credentialsPath2);
|
|
11454
|
+
setChecked(true);
|
|
11455
|
+
setTimeout(onComplete, 1e3);
|
|
11456
|
+
}, [onComplete]);
|
|
11457
|
+
if (!checked) {
|
|
11458
|
+
return null;
|
|
11459
|
+
}
|
|
11460
|
+
if (authenticated) {
|
|
11461
|
+
return /* @__PURE__ */ jsxs2(Box3, { flexDirection: "column", children: [
|
|
11462
|
+
/* @__PURE__ */ jsx3(Text3, { color: "green", children: "\u2713 Authenticated" }),
|
|
11463
|
+
/* @__PURE__ */ jsxs2(Box3, { flexDirection: "column", marginTop: 1, paddingX: 2, children: [
|
|
11464
|
+
/* @__PURE__ */ jsxs2(Text3, { children: [
|
|
11465
|
+
"Access token: ",
|
|
11466
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: tokenPreview })
|
|
11467
|
+
] }),
|
|
11468
|
+
/* @__PURE__ */ jsxs2(Text3, { children: [
|
|
11469
|
+
"Token type: ",
|
|
11470
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: tokenType })
|
|
11471
|
+
] }),
|
|
11472
|
+
/* @__PURE__ */ jsxs2(Text3, { children: [
|
|
11473
|
+
"Credentials: ",
|
|
11474
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: credentialsPath })
|
|
11475
|
+
] })
|
|
11476
|
+
] })
|
|
11477
|
+
] });
|
|
11478
|
+
}
|
|
11479
|
+
return /* @__PURE__ */ jsxs2(Box3, { flexDirection: "column", children: [
|
|
11480
|
+
/* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "\u2717 Not authenticated" }),
|
|
11481
|
+
/* @__PURE__ */ jsx3(Text3, { dimColor: true, children: 'Run "link-cli auth login" to authenticate' }),
|
|
11482
|
+
/* @__PURE__ */ jsx3(Box3, { marginTop: 1, paddingX: 2, children: /* @__PURE__ */ jsxs2(Text3, { children: [
|
|
11483
|
+
"Credentials: ",
|
|
11484
|
+
/* @__PURE__ */ jsx3(Text3, { bold: true, children: credentialsPath })
|
|
11485
|
+
] }) })
|
|
11486
|
+
] });
|
|
11487
|
+
};
|
|
11488
|
+
|
|
11435
11489
|
// src/commands/auth/index.tsx
|
|
11436
|
-
import { jsx as
|
|
11490
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
11437
11491
|
function createAuthCli(authResource, updateInfo) {
|
|
11438
11492
|
const cli2 = Cli.create("auth", {
|
|
11439
11493
|
description: "Authentication commands"
|
|
@@ -11453,7 +11507,7 @@ function createAuthCli(authResource, updateInfo) {
|
|
|
11453
11507
|
if (!c.agent && !c.formatExplicit) {
|
|
11454
11508
|
return new Promise((resolve) => {
|
|
11455
11509
|
const { waitUntilExit } = render(
|
|
11456
|
-
/* @__PURE__ */
|
|
11510
|
+
/* @__PURE__ */ jsx4(
|
|
11457
11511
|
Login,
|
|
11458
11512
|
{
|
|
11459
11513
|
authResource,
|
|
@@ -11506,7 +11560,7 @@ function createAuthCli(authResource, updateInfo) {
|
|
|
11506
11560
|
if (!c.agent && !c.formatExplicit) {
|
|
11507
11561
|
return new Promise((resolve) => {
|
|
11508
11562
|
const { waitUntilExit } = render(
|
|
11509
|
-
/* @__PURE__ */
|
|
11563
|
+
/* @__PURE__ */ jsx4(Logout, { authResource, onComplete: () => {
|
|
11510
11564
|
} })
|
|
11511
11565
|
);
|
|
11512
11566
|
waitUntilExit().then(() => resolve(result));
|
|
@@ -11520,6 +11574,25 @@ function createAuthCli(authResource, updateInfo) {
|
|
|
11520
11574
|
options: statusOptions,
|
|
11521
11575
|
outputPolicy: "agent-only",
|
|
11522
11576
|
async *run(c) {
|
|
11577
|
+
if (!c.agent && !c.formatExplicit) {
|
|
11578
|
+
return new Promise((resolve) => {
|
|
11579
|
+
const { waitUntilExit } = render(
|
|
11580
|
+
/* @__PURE__ */ jsx4(AuthStatus, { onComplete: () => {
|
|
11581
|
+
} })
|
|
11582
|
+
);
|
|
11583
|
+
waitUntilExit().then(() => {
|
|
11584
|
+
const auth = storage.getAuth();
|
|
11585
|
+
resolve({
|
|
11586
|
+
authenticated: !!auth,
|
|
11587
|
+
...auth ? {
|
|
11588
|
+
access_token: `${auth.access_token.substring(0, 20)}...`,
|
|
11589
|
+
token_type: auth.token_type
|
|
11590
|
+
} : {},
|
|
11591
|
+
credentials_path: storage.getPath()
|
|
11592
|
+
});
|
|
11593
|
+
});
|
|
11594
|
+
});
|
|
11595
|
+
}
|
|
11523
11596
|
const opts = c.options;
|
|
11524
11597
|
const interval = opts.interval;
|
|
11525
11598
|
const maxAttempts = opts.maxAttempts;
|
|
@@ -11586,24 +11659,24 @@ import { render as render2 } from "ink";
|
|
|
11586
11659
|
|
|
11587
11660
|
// src/commands/demo/demo-runner.tsx
|
|
11588
11661
|
import { Box as Box8, Text as Text9, useInput as useInput4 } from "ink";
|
|
11589
|
-
import { useCallback, useState as
|
|
11662
|
+
import { useCallback, useState as useState7 } from "react";
|
|
11590
11663
|
|
|
11591
11664
|
// src/utils/markdown-text.tsx
|
|
11592
|
-
import { Text as
|
|
11593
|
-
import { jsx as
|
|
11665
|
+
import { Text as Text4 } from "ink";
|
|
11666
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
11594
11667
|
var MarkdownText = ({
|
|
11595
11668
|
children,
|
|
11596
11669
|
dimColor
|
|
11597
11670
|
}) => {
|
|
11598
11671
|
const parts = tokenize(children);
|
|
11599
|
-
return /* @__PURE__ */
|
|
11672
|
+
return /* @__PURE__ */ jsx5(Text4, { dimColor, children: parts.map((part) => {
|
|
11600
11673
|
if (part.type === "bold") {
|
|
11601
|
-
return /* @__PURE__ */
|
|
11674
|
+
return /* @__PURE__ */ jsx5(Text4, { bold: true, children: part.text }, part.key);
|
|
11602
11675
|
}
|
|
11603
11676
|
if (part.type === "code") {
|
|
11604
|
-
return /* @__PURE__ */
|
|
11677
|
+
return /* @__PURE__ */ jsx5(Text4, { color: "yellow", children: part.text }, part.key);
|
|
11605
11678
|
}
|
|
11606
|
-
return /* @__PURE__ */
|
|
11679
|
+
return /* @__PURE__ */ jsx5(Text4, { children: part.text }, part.key);
|
|
11607
11680
|
}) });
|
|
11608
11681
|
};
|
|
11609
11682
|
function tokenize(input) {
|
|
@@ -11638,7 +11711,7 @@ function tokenize(input) {
|
|
|
11638
11711
|
}
|
|
11639
11712
|
|
|
11640
11713
|
// src/commands/spend-request/app-download-qr-codes.tsx
|
|
11641
|
-
import { Box as
|
|
11714
|
+
import { Box as Box4, Text as Text5 } from "ink";
|
|
11642
11715
|
import { useMemo } from "react";
|
|
11643
11716
|
|
|
11644
11717
|
// src/utils/render-qr-matrix.ts
|
|
@@ -11675,25 +11748,25 @@ function renderQrMatrix(url) {
|
|
|
11675
11748
|
}
|
|
11676
11749
|
|
|
11677
11750
|
// src/commands/spend-request/app-download-qr-codes.tsx
|
|
11678
|
-
import { jsx as
|
|
11751
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
11679
11752
|
var DOWNLOAD_URL = "https://link.com/download";
|
|
11680
11753
|
var AppDownloadQrCodes = () => {
|
|
11681
11754
|
const qrLines = useMemo(() => renderQrMatrix(DOWNLOAD_URL), []);
|
|
11682
|
-
return /* @__PURE__ */
|
|
11683
|
-
/* @__PURE__ */
|
|
11684
|
-
/* @__PURE__ */
|
|
11755
|
+
return /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", marginTop: 1, children: [
|
|
11756
|
+
/* @__PURE__ */ jsx6(Text5, { dimColor: true, children: "Get the Link app to approve spend requests from your phone" }),
|
|
11757
|
+
/* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", alignItems: "flex-start", marginTop: 1, children: [
|
|
11685
11758
|
qrLines.map((line, i) => (
|
|
11686
11759
|
// biome-ignore lint/suspicious/noArrayIndexKey: stable static array
|
|
11687
|
-
/* @__PURE__ */
|
|
11760
|
+
/* @__PURE__ */ jsx6(Text5, { children: line }, i)
|
|
11688
11761
|
)),
|
|
11689
|
-
/* @__PURE__ */
|
|
11762
|
+
/* @__PURE__ */ jsx6(Text5, { dimColor: true, children: DOWNLOAD_URL })
|
|
11690
11763
|
] })
|
|
11691
11764
|
] });
|
|
11692
11765
|
};
|
|
11693
11766
|
|
|
11694
11767
|
// src/commands/demo/card-flow.tsx
|
|
11695
11768
|
import { Box as Box5, Text as Text6, useInput as useInput2 } from "ink";
|
|
11696
|
-
import { useEffect as
|
|
11769
|
+
import { useEffect as useEffect4, useRef, useState as useState4 } from "react";
|
|
11697
11770
|
|
|
11698
11771
|
// src/utils/poll-until-approved.ts
|
|
11699
11772
|
function pollUntilApproved(repository, id, options = {}) {
|
|
@@ -11721,12 +11794,12 @@ function pollUntilApproved(repository, id, options = {}) {
|
|
|
11721
11794
|
|
|
11722
11795
|
// src/commands/demo/constants.ts
|
|
11723
11796
|
var DEMO_MERCHANT_NAME = "Galtee Outdoor";
|
|
11724
|
-
var DEMO_MERCHANT_URL = "https://galtee.stripedemos.com/";
|
|
11797
|
+
var DEMO_MERCHANT_URL = "https://galtee.stripedemos.com/en/products/prod_RtAl1kmlzvL8oj";
|
|
11725
11798
|
var DEMO_MPP_DEV_URL = "https://mpp.dev";
|
|
11726
11799
|
var DEMO_CLIMATE_API_URL = "https://climate.stripe.dev/api/test/contribute";
|
|
11727
11800
|
var DEMO_CARD_AMOUNT = 12900;
|
|
11728
11801
|
var DEMO_SPT_AMOUNT = 100;
|
|
11729
|
-
var DEMO_CARD_CONTEXT = "Link CLI onboarding demo:
|
|
11802
|
+
var DEMO_CARD_CONTEXT = "Link CLI onboarding demo: Errigal Puffer Jacket from Galtee Outdoor. Agent completing checkout using a virtual card credential.";
|
|
11730
11803
|
var DEMO_SPT_CONTEXT = "Demo purchase: Testing the Link CLI machine payment flow by making an automated HTTP 402 payment to Stripe Climate. This demonstrates the shared payment token credential and machine payment protocol.";
|
|
11731
11804
|
|
|
11732
11805
|
// src/commands/demo/content.ts
|
|
@@ -11735,100 +11808,103 @@ var sptAmount = `$${(DEMO_SPT_AMOUNT / 100).toFixed(2)}`;
|
|
|
11735
11808
|
var CARD_FLOW = {
|
|
11736
11809
|
title: "Flow 1: Virtual Card",
|
|
11737
11810
|
intro: {
|
|
11738
|
-
description: `
|
|
11811
|
+
description: `Agent buys a Errigal Puffer Jacket (${cardAmount}) with a one-time virtual card from your Link wallet. Your real card is never shared.`,
|
|
11739
11812
|
steps: [
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
"
|
|
11743
|
-
"
|
|
11813
|
+
"Select payment method",
|
|
11814
|
+
`Create spend request for ${cardAmount}`,
|
|
11815
|
+
"Approve in Link",
|
|
11816
|
+
"Get virtual card and open checkout"
|
|
11744
11817
|
],
|
|
11745
11818
|
prompt: "Press [Enter] to start"
|
|
11746
11819
|
},
|
|
11820
|
+
explainPm: {
|
|
11821
|
+
prompt: "Press [Enter] to create a spend request"
|
|
11822
|
+
},
|
|
11747
11823
|
createSpend: {
|
|
11748
|
-
description:
|
|
11824
|
+
description: `Requests ${cardAmount} from your wallet. No credentials issued until you approve.`,
|
|
11749
11825
|
loading: "Creating spend request..."
|
|
11750
11826
|
},
|
|
11751
11827
|
approval: {
|
|
11752
|
-
description: "Open the URL to approve
|
|
11828
|
+
description: "Open the URL to approve. CLI continues once approved.",
|
|
11753
11829
|
loading: "Waiting for approval...",
|
|
11754
11830
|
browserHint: "Press [Enter] to open in browser"
|
|
11755
11831
|
},
|
|
11756
11832
|
showCard: {
|
|
11757
|
-
description: "
|
|
11758
|
-
openUrl: "Open Galtee Outdoor and enter these details at checkout.",
|
|
11833
|
+
description: "One-time virtual card issued. Enter these at Galtee Outdoor checkout:",
|
|
11759
11834
|
prompt: "Press [Enter] to open Galtee Outdoor"
|
|
11760
11835
|
},
|
|
11761
11836
|
done: {
|
|
11762
11837
|
success: "Opened Galtee Outdoor in your browser",
|
|
11763
|
-
detail: "
|
|
11838
|
+
detail: "Testmode \u2014 no real charge."
|
|
11764
11839
|
}
|
|
11765
11840
|
};
|
|
11766
11841
|
var SPT_FLOW = {
|
|
11767
11842
|
title: "Flow 2: Machine Payment (SPT)",
|
|
11768
11843
|
intro: {
|
|
11769
|
-
description: "
|
|
11770
|
-
preamble:
|
|
11844
|
+
description: "No checkout form. The server returns **HTTP 402** with a payment challenge. The link-cli creates and sends a **Shared Payment Token** (SPT) programmaticaly scoped to the business and amount.",
|
|
11845
|
+
preamble: `${sptAmount} donation to Stripe Climate demonstrates:`,
|
|
11771
11846
|
steps: [
|
|
11772
|
-
"
|
|
11773
|
-
"
|
|
11774
|
-
"
|
|
11775
|
-
"Approve
|
|
11776
|
-
"`mpp pay` signs
|
|
11847
|
+
"Select payment method",
|
|
11848
|
+
"Probe API \u2014 get HTTP 402 challenge and decode `network_id`",
|
|
11849
|
+
"Create SPT spend request",
|
|
11850
|
+
"Approve",
|
|
11851
|
+
"`mpp pay` signs and retries"
|
|
11777
11852
|
],
|
|
11778
11853
|
prompt: "Press [Enter] to start"
|
|
11779
11854
|
},
|
|
11780
11855
|
probe: {
|
|
11781
|
-
description: `
|
|
11856
|
+
description: `POST to ${DEMO_CLIMATE_API_URL} without credentials \u2014 server returns 402 with a \`WWW-Authenticate\` challenge.`,
|
|
11782
11857
|
loading: "Probing...",
|
|
11783
|
-
detail: "
|
|
11858
|
+
detail: "Challenge contains a `network_id` \u2014 the business identifier on Stripe's network.",
|
|
11859
|
+
prompt: "Press [Enter] to create a spend request"
|
|
11784
11860
|
},
|
|
11785
11861
|
createSpend: {
|
|
11786
|
-
description:
|
|
11862
|
+
description: `Request an SPT using the decoded \`network_id\` and amount (${sptAmount}).`,
|
|
11787
11863
|
loading: "Creating spend request..."
|
|
11788
11864
|
},
|
|
11789
11865
|
approval: {
|
|
11790
|
-
description: "Approve
|
|
11866
|
+
description: "Approve to issue the SPT.",
|
|
11791
11867
|
loading: "Waiting for approval...",
|
|
11792
11868
|
browserHint: "Press [Enter] to open in browser"
|
|
11793
11869
|
},
|
|
11794
11870
|
mppPay: {
|
|
11795
|
-
description: "`mpp pay` retrieves the SPT,
|
|
11871
|
+
description: "`mpp pay` retrieves the SPT, signs the challenge, retries with `Authorization: Payment`.",
|
|
11796
11872
|
loading: "Completing payment...",
|
|
11797
11873
|
prompt: "Press [Enter] to pay"
|
|
11798
11874
|
},
|
|
11799
11875
|
done: {
|
|
11800
11876
|
success: "Payment complete",
|
|
11801
|
-
detail:
|
|
11877
|
+
detail: `${sptAmount} donation completed via API \u2014 no forms, no browser.`
|
|
11802
11878
|
}
|
|
11803
11879
|
};
|
|
11804
11880
|
var DEMO_MENU = {
|
|
11805
11881
|
title: "Link CLI Demo",
|
|
11806
|
-
subtitle: "
|
|
11882
|
+
subtitle: "See how agents use Link to make payments.",
|
|
11807
11883
|
question: "Which flow would you like to run?",
|
|
11808
11884
|
hint: "Use \u2191\u2193 to select, [Enter] to confirm",
|
|
11809
11885
|
options: [
|
|
11810
11886
|
{
|
|
11811
11887
|
key: "both",
|
|
11812
11888
|
label: "Both flows",
|
|
11813
|
-
description: "
|
|
11889
|
+
description: "Run both end-to-end."
|
|
11814
11890
|
},
|
|
11815
11891
|
{
|
|
11816
11892
|
key: "card",
|
|
11817
11893
|
label: "Virtual card",
|
|
11818
|
-
description: "
|
|
11894
|
+
description: "One-time card number for checkout forms."
|
|
11819
11895
|
},
|
|
11820
11896
|
{
|
|
11821
11897
|
key: "spt",
|
|
11822
11898
|
label: "Machine payment (SPT)",
|
|
11823
|
-
description: "
|
|
11899
|
+
description: "Pay via API \u2014 no browser, no forms."
|
|
11824
11900
|
}
|
|
11825
11901
|
],
|
|
11826
|
-
transition: "
|
|
11902
|
+
transition: "Card flow done. Next: **machine payment** \u2014 paying an API directly.",
|
|
11827
11903
|
transitionPrompt: "Press [Enter] to continue to Flow 2"
|
|
11828
11904
|
};
|
|
11829
11905
|
var ONBOARD = {
|
|
11830
11906
|
title: "Welcome to Link CLI",
|
|
11831
|
-
subtitle: "
|
|
11907
|
+
subtitle: "Let agents make secure payments on your behalf.",
|
|
11832
11908
|
auth: {
|
|
11833
11909
|
alreadyLoggedIn: "Already logged in",
|
|
11834
11910
|
authenticated: "Authenticated",
|
|
@@ -11838,48 +11914,23 @@ var ONBOARD = {
|
|
|
11838
11914
|
loading: "Checking payment methods...",
|
|
11839
11915
|
pickPrompt: "Which payment method should we use for the demo?",
|
|
11840
11916
|
pickHint: "Use \u2191\u2193 to select, [Enter] to confirm",
|
|
11841
|
-
missing: "No payment methods
|
|
11917
|
+
missing: "No payment methods in your Link wallet.",
|
|
11842
11918
|
missingSteps: [
|
|
11843
11919
|
"Open the Link app or visit link.com",
|
|
11844
11920
|
"Add a payment method",
|
|
11845
|
-
"
|
|
11921
|
+
"Press [Enter] to retry"
|
|
11846
11922
|
],
|
|
11847
11923
|
retryPrompt: "Press [Enter] to retry"
|
|
11848
11924
|
},
|
|
11849
11925
|
appTip: {
|
|
11850
11926
|
title: "Get the Link app",
|
|
11851
|
-
description: "Approve spend requests from your phone
|
|
11927
|
+
description: "Approve spend requests from your phone with push notifications.",
|
|
11852
11928
|
url: "https://link.com/download"
|
|
11853
11929
|
}
|
|
11854
11930
|
};
|
|
11855
11931
|
|
|
11856
|
-
// src/commands/demo/step-data.tsx
|
|
11857
|
-
import { Box as Box4, Text as Text5 } from "ink";
|
|
11858
|
-
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
11859
|
-
var StepData = ({ data }) => {
|
|
11860
|
-
const entries = Object.entries(data).filter(
|
|
11861
|
-
([, v]) => v !== void 0 && v !== null
|
|
11862
|
-
);
|
|
11863
|
-
const maxKeyLen = Math.max(...entries.map(([k]) => k.length));
|
|
11864
|
-
return /* @__PURE__ */ jsx6(
|
|
11865
|
-
Box4,
|
|
11866
|
-
{
|
|
11867
|
-
flexDirection: "column",
|
|
11868
|
-
paddingX: 2,
|
|
11869
|
-
marginTop: 1,
|
|
11870
|
-
borderStyle: "single",
|
|
11871
|
-
borderColor: "gray",
|
|
11872
|
-
children: entries.map(([key, value]) => /* @__PURE__ */ jsxs3(Text5, { children: [
|
|
11873
|
-
/* @__PURE__ */ jsx6(Text5, { dimColor: true, children: key.padEnd(maxKeyLen) }),
|
|
11874
|
-
" ",
|
|
11875
|
-
/* @__PURE__ */ jsx6(Text5, { children: typeof value === "object" ? JSON.stringify(value) : String(value) })
|
|
11876
|
-
] }, key))
|
|
11877
|
-
}
|
|
11878
|
-
);
|
|
11879
|
-
};
|
|
11880
|
-
|
|
11881
11932
|
// src/commands/demo/card-flow.tsx
|
|
11882
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
11933
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
11883
11934
|
function formatPmLabel(pm) {
|
|
11884
11935
|
return `${pm.card_details?.brand ?? pm.type} ****${pm.card_details?.last4 ?? ""}`;
|
|
11885
11936
|
}
|
|
@@ -11895,15 +11946,14 @@ var CardFlow = ({
|
|
|
11895
11946
|
paymentMethodId: initialPaymentMethodId,
|
|
11896
11947
|
onComplete
|
|
11897
11948
|
}) => {
|
|
11898
|
-
const [step, setStep] =
|
|
11899
|
-
const [paymentMethod, setPaymentMethod] =
|
|
11949
|
+
const [step, setStep] = useState4("intro");
|
|
11950
|
+
const [paymentMethod, setPaymentMethod] = useState4(
|
|
11900
11951
|
null
|
|
11901
11952
|
);
|
|
11902
|
-
const [paymentMethods, setPaymentMethods] =
|
|
11903
|
-
const [selectedPmIndex, setSelectedPmIndex] =
|
|
11904
|
-
const [spendRequest, setSpendRequest] =
|
|
11905
|
-
const [
|
|
11906
|
-
const [error, setError] = useState3("");
|
|
11953
|
+
const [paymentMethods, setPaymentMethods] = useState4([]);
|
|
11954
|
+
const [selectedPmIndex, setSelectedPmIndex] = useState4(0);
|
|
11955
|
+
const [spendRequest, setSpendRequest] = useState4(null);
|
|
11956
|
+
const [error, setError] = useState4("");
|
|
11907
11957
|
const approvalUrl = spendRequest?.approval_url ?? "";
|
|
11908
11958
|
const enterResolver = useRef(null);
|
|
11909
11959
|
const pmResolver = useRef(null);
|
|
@@ -11956,7 +12006,7 @@ var CardFlow = ({
|
|
|
11956
12006
|
}
|
|
11957
12007
|
});
|
|
11958
12008
|
const started = useRef(false);
|
|
11959
|
-
|
|
12009
|
+
useEffect4(() => {
|
|
11960
12010
|
if (started.current) return;
|
|
11961
12011
|
started.current = true;
|
|
11962
12012
|
const run = async () => {
|
|
@@ -11992,7 +12042,7 @@ var CardFlow = ({
|
|
|
11992
12042
|
await waitForEnter();
|
|
11993
12043
|
}
|
|
11994
12044
|
setStep("create-spend");
|
|
11995
|
-
const
|
|
12045
|
+
const result = await spendRequestRepo2.createSpendRequest({
|
|
11996
12046
|
payment_details: pmId,
|
|
11997
12047
|
credential_type: "card",
|
|
11998
12048
|
amount: DEMO_CARD_AMOUNT,
|
|
@@ -12001,9 +12051,7 @@ var CardFlow = ({
|
|
|
12001
12051
|
merchant_url: DEMO_MERCHANT_URL,
|
|
12002
12052
|
request_approval: true,
|
|
12003
12053
|
test: true
|
|
12004
|
-
};
|
|
12005
|
-
setSpendRequestPayload(payload);
|
|
12006
|
-
const result = await spendRequestRepo2.createSpendRequest(payload);
|
|
12054
|
+
});
|
|
12007
12055
|
setSpendRequest(result);
|
|
12008
12056
|
setStep("await-approval");
|
|
12009
12057
|
for (; ; ) {
|
|
@@ -12075,177 +12123,160 @@ var CardFlow = ({
|
|
|
12075
12123
|
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: DEMO_MERCHANT_URL })
|
|
12076
12124
|
] }),
|
|
12077
12125
|
/* @__PURE__ */ jsx7(MarkdownText, { children: CARD_FLOW.intro.description }),
|
|
12078
|
-
/* @__PURE__ */
|
|
12079
|
-
"What happens:",
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12126
|
+
/* @__PURE__ */ jsxs4(Box5, { marginTop: 1, flexDirection: "column", children: [
|
|
12127
|
+
/* @__PURE__ */ jsx7(Text6, { children: "What happens:" }),
|
|
12128
|
+
CARD_FLOW.intro.steps.map((s, i) => {
|
|
12129
|
+
const doneAfter = [
|
|
12130
|
+
"pick-pm",
|
|
12131
|
+
"create-spend",
|
|
12132
|
+
"await-approval",
|
|
12133
|
+
"show-card"
|
|
12134
|
+
];
|
|
12135
|
+
const activeFrom = [
|
|
12136
|
+
"fetch-pm",
|
|
12137
|
+
"create-spend",
|
|
12138
|
+
"await-approval",
|
|
12139
|
+
"show-card"
|
|
12140
|
+
];
|
|
12141
|
+
const done = pastStep(doneAfter[i]);
|
|
12142
|
+
const active = !done && (step === activeFrom[i] || pastStep(activeFrom[i]));
|
|
12143
|
+
return done ? /* @__PURE__ */ jsxs4(Text6, { dimColor: true, strikethrough: true, children: [
|
|
12144
|
+
" ",
|
|
12145
|
+
i + 1,
|
|
12146
|
+
". ",
|
|
12147
|
+
s
|
|
12148
|
+
] }, s) : active ? /* @__PURE__ */ jsxs4(Text6, { bold: true, color: "cyan", children: [
|
|
12149
|
+
" ",
|
|
12150
|
+
i + 1,
|
|
12151
|
+
". ",
|
|
12152
|
+
s
|
|
12153
|
+
] }, s) : /* @__PURE__ */ jsxs4(Text6, { dimColor: true, children: [
|
|
12154
|
+
" ",
|
|
12155
|
+
i + 1,
|
|
12156
|
+
". ",
|
|
12157
|
+
s
|
|
12158
|
+
] }, s);
|
|
12159
|
+
})
|
|
12160
|
+
] }),
|
|
12083
12161
|
step === "intro" && prompt(CARD_FLOW.intro.prompt)
|
|
12084
12162
|
] }),
|
|
12085
12163
|
step === "fetch-pm" && /* @__PURE__ */ jsx7(Box5, { flexDirection: "column", children: /* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Fetching payment methods from your Link wallet..." }) }),
|
|
12086
|
-
step === "pick-pm"
|
|
12087
|
-
/* @__PURE__ */
|
|
12088
|
-
|
|
12089
|
-
"
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
|
|
12096
|
-
|
|
12097
|
-
|
|
12098
|
-
|
|
12099
|
-
|
|
12100
|
-
pastStep("fetch-pm") && paymentMethod && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12101
|
-
/* @__PURE__ */ jsxs4(Text6, { color: "green", children: [
|
|
12102
|
-
"\u2713 Using ",
|
|
12103
|
-
/* @__PURE__ */ jsx7(Text6, { bold: true, children: pmLabel }),
|
|
12104
|
-
paymentMethod.is_default ? " (default)" : ""
|
|
12164
|
+
(step === "pick-pm" || step === "explain-pm") && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12165
|
+
step === "pick-pm" && paymentMethods.length > 1 && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12166
|
+
/* @__PURE__ */ jsx7(Text6, { children: "Which payment method should we use for the demo?" }),
|
|
12167
|
+
/* @__PURE__ */ jsx7(Box5, { flexDirection: "column", marginTop: 1, children: paymentMethods.map((pm, i) => /* @__PURE__ */ jsx7(Text6, { children: i === selectedPmIndex ? /* @__PURE__ */ jsxs4(Text6, { color: "cyan", bold: true, children: [
|
|
12168
|
+
">",
|
|
12169
|
+
" ",
|
|
12170
|
+
formatPmLabel(pm),
|
|
12171
|
+
pm.is_default ? " (default)" : ""
|
|
12172
|
+
] }) : /* @__PURE__ */ jsxs4(Text6, { dimColor: true, children: [
|
|
12173
|
+
" ",
|
|
12174
|
+
formatPmLabel(pm),
|
|
12175
|
+
pm.is_default ? " (default)" : ""
|
|
12176
|
+
] }) }, pm.id)) }),
|
|
12177
|
+
/* @__PURE__ */ jsx7(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Use \u2191\u2193 to select, [Enter] to confirm" }) })
|
|
12105
12178
|
] }),
|
|
12106
|
-
|
|
12179
|
+
paymentMethod && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12180
|
+
/* @__PURE__ */ jsxs4(Text6, { color: "green", children: [
|
|
12181
|
+
"\u2713 Using ",
|
|
12182
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, children: pmLabel }),
|
|
12183
|
+
paymentMethod.is_default ? " (default)" : ""
|
|
12184
|
+
] }),
|
|
12185
|
+
step === "explain-pm" && prompt(CARD_FLOW.explainPm.prompt)
|
|
12186
|
+
] })
|
|
12107
12187
|
] }),
|
|
12108
|
-
|
|
12188
|
+
step === "create-spend" && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12109
12189
|
/* @__PURE__ */ jsx7(MarkdownText, { children: CARD_FLOW.createSpend.description }),
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12190
|
+
/* @__PURE__ */ jsx7(Box5, { marginY: 1, children: /* @__PURE__ */ jsx7(Text6, { color: "cyan", children: CARD_FLOW.createSpend.loading }) })
|
|
12191
|
+
] }),
|
|
12192
|
+
(step === "await-approval" || step === "approval-timeout") && spendRequest && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12193
|
+
/* @__PURE__ */ jsxs4(Text6, { color: "green", children: [
|
|
12194
|
+
"\u2713 Spend request created (",
|
|
12195
|
+
spendRequest.id,
|
|
12196
|
+
")"
|
|
12197
|
+
] }),
|
|
12198
|
+
step === "await-approval" && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
12199
|
+
/* @__PURE__ */ jsx7(Text6, { children: CARD_FLOW.approval.description }),
|
|
12200
|
+
/* @__PURE__ */ jsxs4(
|
|
12113
12201
|
Box5,
|
|
12114
12202
|
{
|
|
12115
12203
|
flexDirection: "column",
|
|
12116
|
-
borderStyle: "
|
|
12117
|
-
borderColor: "
|
|
12204
|
+
borderStyle: "round",
|
|
12205
|
+
borderColor: "cyan",
|
|
12118
12206
|
paddingX: 2,
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12207
|
+
paddingY: 1,
|
|
12208
|
+
marginTop: 1,
|
|
12209
|
+
children: [
|
|
12210
|
+
/* @__PURE__ */ jsxs4(Text6, { children: [
|
|
12211
|
+
"Approve at:",
|
|
12212
|
+
" ",
|
|
12213
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, color: "cyan", children: approvalUrl })
|
|
12214
|
+
] }),
|
|
12215
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: CARD_FLOW.approval.browserHint })
|
|
12216
|
+
]
|
|
12124
12217
|
}
|
|
12125
|
-
)
|
|
12126
|
-
|
|
12127
|
-
step === "create-spend" && /* @__PURE__ */ jsx7(Box5, { marginY: 1, children: /* @__PURE__ */ jsx7(Text6, { color: "cyan", children: CARD_FLOW.createSpend.loading }) })
|
|
12128
|
-
] }),
|
|
12129
|
-
(step === "await-approval" || step === "approval-timeout" || pastStep("await-approval")) && spendRequest && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12130
|
-
/* @__PURE__ */ jsxs4(Text6, { color: "green", children: [
|
|
12131
|
-
"\u2713 Spend request created (ID: ",
|
|
12132
|
-
/* @__PURE__ */ jsx7(Text6, { bold: true, children: spendRequest.id }),
|
|
12133
|
-
")"
|
|
12218
|
+
),
|
|
12219
|
+
/* @__PURE__ */ jsx7(Box5, { marginY: 1, children: /* @__PURE__ */ jsx7(Text6, { color: "cyan", children: CARD_FLOW.approval.loading }) })
|
|
12134
12220
|
] }),
|
|
12135
|
-
/* @__PURE__ */
|
|
12136
|
-
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
|
|
12221
|
+
step === "approval-timeout" && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
12222
|
+
/* @__PURE__ */ jsx7(Text6, { color: "yellow", children: "\u26A0 Approval timed out (5 min). Still pending \u2014 you can still approve." }),
|
|
12223
|
+
/* @__PURE__ */ jsxs4(
|
|
12224
|
+
Box5,
|
|
12225
|
+
{
|
|
12226
|
+
flexDirection: "column",
|
|
12227
|
+
borderStyle: "round",
|
|
12228
|
+
borderColor: "yellow",
|
|
12229
|
+
paddingX: 2,
|
|
12230
|
+
paddingY: 1,
|
|
12231
|
+
marginTop: 1,
|
|
12232
|
+
children: [
|
|
12233
|
+
/* @__PURE__ */ jsxs4(Text6, { children: [
|
|
12234
|
+
"Approve at:",
|
|
12235
|
+
" ",
|
|
12236
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, color: "cyan", children: approvalUrl })
|
|
12237
|
+
] }),
|
|
12238
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Press [Enter] to open in browser" })
|
|
12239
|
+
]
|
|
12147
12240
|
}
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
step === "await-approval" && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12152
|
-
/* @__PURE__ */ jsx7(Text6, { children: CARD_FLOW.approval.description }),
|
|
12153
|
-
/* @__PURE__ */ jsxs4(
|
|
12154
|
-
Box5,
|
|
12155
|
-
{
|
|
12156
|
-
flexDirection: "column",
|
|
12157
|
-
borderStyle: "round",
|
|
12158
|
-
borderColor: "cyan",
|
|
12159
|
-
paddingX: 2,
|
|
12160
|
-
paddingY: 1,
|
|
12161
|
-
marginTop: 1,
|
|
12162
|
-
children: [
|
|
12163
|
-
/* @__PURE__ */ jsxs4(Text6, { children: [
|
|
12164
|
-
"Approve at:",
|
|
12165
|
-
" ",
|
|
12166
|
-
/* @__PURE__ */ jsx7(Text6, { bold: true, color: "cyan", children: approvalUrl })
|
|
12167
|
-
] }),
|
|
12168
|
-
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: CARD_FLOW.approval.browserHint })
|
|
12169
|
-
]
|
|
12170
|
-
}
|
|
12171
|
-
),
|
|
12172
|
-
/* @__PURE__ */ jsx7(Box5, { marginY: 1, children: /* @__PURE__ */ jsx7(Text6, { color: "cyan", children: CARD_FLOW.approval.loading }) })
|
|
12173
|
-
] }),
|
|
12174
|
-
step === "approval-timeout" && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12175
|
-
/* @__PURE__ */ jsx7(Text6, { color: "yellow", children: "\u26A0 Approval timed out (5 min). The spend request is still pending \u2014 you can still approve it." }),
|
|
12176
|
-
/* @__PURE__ */ jsxs4(
|
|
12177
|
-
Box5,
|
|
12178
|
-
{
|
|
12179
|
-
flexDirection: "column",
|
|
12180
|
-
borderStyle: "round",
|
|
12181
|
-
borderColor: "yellow",
|
|
12182
|
-
paddingX: 2,
|
|
12183
|
-
paddingY: 1,
|
|
12184
|
-
marginTop: 1,
|
|
12185
|
-
children: [
|
|
12186
|
-
/* @__PURE__ */ jsxs4(Text6, { children: [
|
|
12187
|
-
"Approve at:",
|
|
12188
|
-
" ",
|
|
12189
|
-
/* @__PURE__ */ jsx7(Text6, { bold: true, color: "cyan", children: approvalUrl })
|
|
12190
|
-
] }),
|
|
12191
|
-
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Press [Enter] to open in browser" })
|
|
12192
|
-
]
|
|
12193
|
-
}
|
|
12194
|
-
),
|
|
12195
|
-
/* @__PURE__ */ jsx7(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "r Retry polling q Quit demo" }) })
|
|
12241
|
+
),
|
|
12242
|
+
/* @__PURE__ */ jsx7(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "r Retry polling q Quit demo" }) })
|
|
12243
|
+
] })
|
|
12196
12244
|
] }),
|
|
12197
|
-
|
|
12245
|
+
(step === "show-card" || step === "open-url" || step === "done") && card && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12198
12246
|
/* @__PURE__ */ jsx7(Text6, { color: "green", children: "\u2713 Approved!" }),
|
|
12199
12247
|
/* @__PURE__ */ jsx7(MarkdownText, { children: CARD_FLOW.showCard.description }),
|
|
12200
|
-
/* @__PURE__ */ jsxs4(
|
|
12201
|
-
|
|
12202
|
-
{
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
/* @__PURE__ */ jsx7(Text6, { bold: true, children: card.billing_address.postal_code })
|
|
12227
|
-
] }),
|
|
12228
|
-
card.valid_until && /* @__PURE__ */ jsxs4(Text6, { dimColor: true, children: [
|
|
12229
|
-
"Expires:",
|
|
12230
|
-
" ",
|
|
12231
|
-
new Date(card.valid_until).toLocaleTimeString([], {
|
|
12232
|
-
hour: "2-digit",
|
|
12233
|
-
minute: "2-digit"
|
|
12234
|
-
})
|
|
12235
|
-
] })
|
|
12236
|
-
]
|
|
12237
|
-
}
|
|
12238
|
-
),
|
|
12239
|
-
/* @__PURE__ */ jsx7(Box5, { marginTop: 1, children: /* @__PURE__ */ jsx7(MarkdownText, { children: CARD_FLOW.showCard.openUrl }) }),
|
|
12248
|
+
/* @__PURE__ */ jsx7(Box5, { flexDirection: "column", paddingX: 2, marginTop: 1, children: /* @__PURE__ */ jsxs4(Text6, { children: [
|
|
12249
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Number " }),
|
|
12250
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, children: formatCardNumber(card.number) }),
|
|
12251
|
+
" ",
|
|
12252
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Exp " }),
|
|
12253
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, children: formatExpiry(card.exp_month, card.exp_year) }),
|
|
12254
|
+
" ",
|
|
12255
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "CVC " }),
|
|
12256
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, children: card.cvc }),
|
|
12257
|
+
card.billing_address?.postal_code && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
12258
|
+
" ",
|
|
12259
|
+
/* @__PURE__ */ jsx7(Text6, { dimColor: true, children: "Zip " }),
|
|
12260
|
+
/* @__PURE__ */ jsx7(Text6, { bold: true, children: card.billing_address.postal_code })
|
|
12261
|
+
] }),
|
|
12262
|
+
card.valid_until && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
12263
|
+
" ",
|
|
12264
|
+
/* @__PURE__ */ jsxs4(Text6, { dimColor: true, children: [
|
|
12265
|
+
"expires",
|
|
12266
|
+
" ",
|
|
12267
|
+
new Date(card.valid_until).toLocaleTimeString([], {
|
|
12268
|
+
hour: "2-digit",
|
|
12269
|
+
minute: "2-digit"
|
|
12270
|
+
})
|
|
12271
|
+
] })
|
|
12272
|
+
] })
|
|
12273
|
+
] }) }),
|
|
12240
12274
|
step === "show-card" && prompt(CARD_FLOW.showCard.prompt)
|
|
12241
12275
|
] }),
|
|
12242
12276
|
step === "done" && /* @__PURE__ */ jsxs4(Box5, { flexDirection: "column", children: [
|
|
12243
|
-
/* @__PURE__ */ jsxs4(
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
"\u2713 ",
|
|
12247
|
-
CARD_FLOW.done.success
|
|
12248
|
-
] })
|
|
12277
|
+
/* @__PURE__ */ jsxs4(Text6, { color: "green", children: [
|
|
12278
|
+
"\u2713 ",
|
|
12279
|
+
CARD_FLOW.done.success
|
|
12249
12280
|
] }),
|
|
12250
12281
|
/* @__PURE__ */ jsx7(Text6, { children: CARD_FLOW.done.detail })
|
|
12251
12282
|
] }),
|
|
@@ -12258,7 +12289,7 @@ var CardFlow = ({
|
|
|
12258
12289
|
|
|
12259
12290
|
// src/commands/demo/spt-flow.tsx
|
|
12260
12291
|
import { Box as Box7, Text as Text8, useInput as useInput3 } from "ink";
|
|
12261
|
-
import { useEffect as
|
|
12292
|
+
import { useEffect as useEffect6, useRef as useRef2, useState as useState6 } from "react";
|
|
12262
12293
|
|
|
12263
12294
|
// src/commands/mpp/decode.ts
|
|
12264
12295
|
import { Challenge } from "mppx";
|
|
@@ -12344,7 +12375,7 @@ import Spinner2 from "ink-spinner";
|
|
|
12344
12375
|
import { Credential, Method } from "mppx";
|
|
12345
12376
|
import { Mppx, Transport } from "mppx/client";
|
|
12346
12377
|
import { Methods as StripeMethods } from "mppx/stripe";
|
|
12347
|
-
import { useEffect as
|
|
12378
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
12348
12379
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
12349
12380
|
function buildHeaders(data, headers) {
|
|
12350
12381
|
const result = {};
|
|
@@ -12450,10 +12481,10 @@ function MppPay({
|
|
|
12450
12481
|
repository,
|
|
12451
12482
|
onComplete
|
|
12452
12483
|
}) {
|
|
12453
|
-
const [step, setStep] =
|
|
12454
|
-
const [result, setResult] =
|
|
12455
|
-
const [error, setError] =
|
|
12456
|
-
|
|
12484
|
+
const [step, setStep] = useState5("retrieving");
|
|
12485
|
+
const [result, setResult] = useState5(null);
|
|
12486
|
+
const [error, setError] = useState5(null);
|
|
12487
|
+
useEffect5(() => {
|
|
12457
12488
|
(async () => {
|
|
12458
12489
|
try {
|
|
12459
12490
|
setStep("retrieving");
|
|
@@ -12545,22 +12576,20 @@ function MppPay({
|
|
|
12545
12576
|
}
|
|
12546
12577
|
|
|
12547
12578
|
// src/commands/demo/spt-flow.tsx
|
|
12548
|
-
import { Fragment, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
12579
|
+
import { Fragment as Fragment2, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
12549
12580
|
var SptFlow = ({
|
|
12550
12581
|
spendRequestRepo: spendRequestRepo2,
|
|
12551
12582
|
paymentMethodsResource,
|
|
12552
12583
|
paymentMethodId: initialPaymentMethodId,
|
|
12553
12584
|
onComplete
|
|
12554
12585
|
}) => {
|
|
12555
|
-
const [step, setStep] =
|
|
12556
|
-
const [networkId, setNetworkId] =
|
|
12557
|
-
const [paymentMethods, setPaymentMethods] =
|
|
12558
|
-
const [selectedPmIndex, setSelectedPmIndex] =
|
|
12559
|
-
const [spendRequest, setSpendRequest] =
|
|
12560
|
-
const [
|
|
12561
|
-
const [
|
|
12562
|
-
const [challengeData, setChallengeData] = useState5(null);
|
|
12563
|
-
const [error, setError] = useState5("");
|
|
12586
|
+
const [step, setStep] = useState6("intro");
|
|
12587
|
+
const [networkId, setNetworkId] = useState6("");
|
|
12588
|
+
const [paymentMethods, setPaymentMethods] = useState6([]);
|
|
12589
|
+
const [selectedPmIndex, setSelectedPmIndex] = useState6(0);
|
|
12590
|
+
const [spendRequest, setSpendRequest] = useState6(null);
|
|
12591
|
+
const [payResult, setPayResult] = useState6(null);
|
|
12592
|
+
const [error, setError] = useState6("");
|
|
12564
12593
|
const approvalUrl = spendRequest?.approval_url ?? "";
|
|
12565
12594
|
const enterResolver = useRef2(null);
|
|
12566
12595
|
const pmResolver = useRef2(null);
|
|
@@ -12613,7 +12642,7 @@ var SptFlow = ({
|
|
|
12613
12642
|
}
|
|
12614
12643
|
});
|
|
12615
12644
|
const started = useRef2(false);
|
|
12616
|
-
|
|
12645
|
+
useEffect6(() => {
|
|
12617
12646
|
if (started.current) return;
|
|
12618
12647
|
started.current = true;
|
|
12619
12648
|
const run = async () => {
|
|
@@ -12652,17 +12681,10 @@ var SptFlow = ({
|
|
|
12652
12681
|
const wwwAuth = probeResponse.headers.get("www-authenticate") ?? "";
|
|
12653
12682
|
const decoded = decodeStripeChallenge(wwwAuth);
|
|
12654
12683
|
setNetworkId(decoded.network_id);
|
|
12655
|
-
setChallengeData({
|
|
12656
|
-
status: probeResponse.status,
|
|
12657
|
-
method: decoded.method,
|
|
12658
|
-
intent: decoded.intent,
|
|
12659
|
-
network_id: decoded.network_id,
|
|
12660
|
-
realm: decoded.realm
|
|
12661
|
-
});
|
|
12662
12684
|
setStep("explain-402");
|
|
12663
12685
|
await waitForEnter();
|
|
12664
12686
|
setStep("create-spend");
|
|
12665
|
-
const
|
|
12687
|
+
const result = await spendRequestRepo2.createSpendRequest({
|
|
12666
12688
|
payment_details: pmId,
|
|
12667
12689
|
credential_type: "shared_payment_token",
|
|
12668
12690
|
network_id: decoded.network_id,
|
|
@@ -12670,9 +12692,7 @@ var SptFlow = ({
|
|
|
12670
12692
|
context: DEMO_SPT_CONTEXT,
|
|
12671
12693
|
request_approval: true,
|
|
12672
12694
|
test: true
|
|
12673
|
-
};
|
|
12674
|
-
setSpendRequestPayload(payload);
|
|
12675
|
-
const result = await spendRequestRepo2.createSpendRequest(payload);
|
|
12695
|
+
});
|
|
12676
12696
|
setSpendRequest(result);
|
|
12677
12697
|
setStep("await-approval");
|
|
12678
12698
|
for (; ; ) {
|
|
@@ -12754,7 +12774,41 @@ var SptFlow = ({
|
|
|
12754
12774
|
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.intro.description }),
|
|
12755
12775
|
/* @__PURE__ */ jsxs6(Box7, { marginTop: 1, flexDirection: "column", children: [
|
|
12756
12776
|
/* @__PURE__ */ jsx9(Text8, { children: SPT_FLOW.intro.preamble }),
|
|
12757
|
-
SPT_FLOW.intro.steps.map((s, i) =>
|
|
12777
|
+
SPT_FLOW.intro.steps.map((s, i) => {
|
|
12778
|
+
const doneAfter = [
|
|
12779
|
+
"pick-pm",
|
|
12780
|
+
"probe",
|
|
12781
|
+
"create-spend",
|
|
12782
|
+
"await-approval",
|
|
12783
|
+
"mpp-pay"
|
|
12784
|
+
];
|
|
12785
|
+
const activeFrom = [
|
|
12786
|
+
"fetch-pm",
|
|
12787
|
+
"probe",
|
|
12788
|
+
"create-spend",
|
|
12789
|
+
"await-approval",
|
|
12790
|
+
"mpp-pay-gate"
|
|
12791
|
+
];
|
|
12792
|
+
const done = pastStep(doneAfter[i]);
|
|
12793
|
+
const active = !done && (step === activeFrom[i] || pastStep(activeFrom[i]));
|
|
12794
|
+
const label = s.replace(/`/g, "");
|
|
12795
|
+
return done ? /* @__PURE__ */ jsxs6(Text8, { dimColor: true, strikethrough: true, children: [
|
|
12796
|
+
" ",
|
|
12797
|
+
i + 1,
|
|
12798
|
+
". ",
|
|
12799
|
+
label
|
|
12800
|
+
] }, s) : active ? /* @__PURE__ */ jsxs6(Text8, { bold: true, color: "cyan", children: [
|
|
12801
|
+
" ",
|
|
12802
|
+
i + 1,
|
|
12803
|
+
". ",
|
|
12804
|
+
label
|
|
12805
|
+
] }, s) : /* @__PURE__ */ jsxs6(Text8, { dimColor: true, children: [
|
|
12806
|
+
" ",
|
|
12807
|
+
i + 1,
|
|
12808
|
+
". ",
|
|
12809
|
+
label
|
|
12810
|
+
] }, s);
|
|
12811
|
+
})
|
|
12758
12812
|
] }),
|
|
12759
12813
|
step === "intro" && prompt(SPT_FLOW.intro.prompt)
|
|
12760
12814
|
] }),
|
|
@@ -12773,146 +12827,90 @@ var SptFlow = ({
|
|
|
12773
12827
|
] }) }, pm.id)) }),
|
|
12774
12828
|
/* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "Use \u2191\u2193 to select, [Enter] to confirm" }) })
|
|
12775
12829
|
] }),
|
|
12776
|
-
|
|
12830
|
+
(step === "probe" || step === "explain-402") && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12777
12831
|
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.probe.description }),
|
|
12778
|
-
step === "probe" && /* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.probe.loading }) })
|
|
12832
|
+
step === "probe" && /* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.probe.loading }) }),
|
|
12833
|
+
step === "explain-402" && networkId && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
12834
|
+
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.probe.detail }),
|
|
12835
|
+
/* @__PURE__ */ jsxs6(Text8, { color: "green", children: [
|
|
12836
|
+
"\u2713 Got HTTP 402 \u2014 network_id: ",
|
|
12837
|
+
/* @__PURE__ */ jsx9(Text8, { bold: true, children: networkId })
|
|
12838
|
+
] }),
|
|
12839
|
+
prompt(SPT_FLOW.probe.prompt)
|
|
12840
|
+
] })
|
|
12779
12841
|
] }),
|
|
12780
|
-
|
|
12842
|
+
step === "create-spend" && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12843
|
+
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.createSpend.description }),
|
|
12844
|
+
/* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.createSpend.loading }) })
|
|
12845
|
+
] }),
|
|
12846
|
+
(step === "await-approval" || step === "approval-timeout") && spendRequest && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12781
12847
|
/* @__PURE__ */ jsxs6(Text8, { color: "green", children: [
|
|
12782
|
-
"\u2713
|
|
12783
|
-
|
|
12784
|
-
"
|
|
12848
|
+
"\u2713 Spend request created (",
|
|
12849
|
+
spendRequest.id,
|
|
12850
|
+
")"
|
|
12785
12851
|
] }),
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
] }),
|
|
12790
|
-
pastStep("explain-402") && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12791
|
-
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.createSpend.description }),
|
|
12792
|
-
spendRequestPayload && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", marginTop: 1, children: [
|
|
12793
|
-
/* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "spend-request create" }),
|
|
12794
|
-
/* @__PURE__ */ jsx9(
|
|
12852
|
+
step === "await-approval" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
12853
|
+
/* @__PURE__ */ jsx9(Text8, { children: SPT_FLOW.approval.description }),
|
|
12854
|
+
/* @__PURE__ */ jsxs6(
|
|
12795
12855
|
Box7,
|
|
12796
12856
|
{
|
|
12797
12857
|
flexDirection: "column",
|
|
12798
|
-
borderStyle: "
|
|
12799
|
-
borderColor: "
|
|
12858
|
+
borderStyle: "round",
|
|
12859
|
+
borderColor: "cyan",
|
|
12800
12860
|
paddingX: 2,
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12861
|
+
paddingY: 1,
|
|
12862
|
+
marginTop: 1,
|
|
12863
|
+
children: [
|
|
12864
|
+
/* @__PURE__ */ jsxs6(Text8, { children: [
|
|
12865
|
+
"Approve at:",
|
|
12866
|
+
" ",
|
|
12867
|
+
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "cyan", children: approvalUrl })
|
|
12868
|
+
] }),
|
|
12869
|
+
/* @__PURE__ */ jsx9(Text8, { dimColor: true, children: SPT_FLOW.approval.browserHint })
|
|
12870
|
+
]
|
|
12806
12871
|
}
|
|
12807
|
-
)
|
|
12808
|
-
|
|
12809
|
-
step === "create-spend" && /* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.createSpend.loading }) })
|
|
12810
|
-
] }),
|
|
12811
|
-
(step === "await-approval" || step === "approval-timeout" || pastStep("await-approval")) && spendRequest && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12812
|
-
/* @__PURE__ */ jsxs6(Text8, { color: "green", children: [
|
|
12813
|
-
"\u2713 Spend request created (ID: ",
|
|
12814
|
-
/* @__PURE__ */ jsx9(Text8, { bold: true, children: spendRequest.id }),
|
|
12815
|
-
")"
|
|
12872
|
+
),
|
|
12873
|
+
/* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.approval.loading }) })
|
|
12816
12874
|
] }),
|
|
12817
|
-
/* @__PURE__ */
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12875
|
+
step === "approval-timeout" && /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
12876
|
+
/* @__PURE__ */ jsx9(Text8, { color: "yellow", children: "\u26A0 Approval timed out (5 min). Still pending \u2014 you can still approve." }),
|
|
12877
|
+
/* @__PURE__ */ jsxs6(
|
|
12878
|
+
Box7,
|
|
12879
|
+
{
|
|
12880
|
+
flexDirection: "column",
|
|
12881
|
+
borderStyle: "round",
|
|
12882
|
+
borderColor: "yellow",
|
|
12883
|
+
paddingX: 2,
|
|
12884
|
+
paddingY: 1,
|
|
12885
|
+
marginTop: 1,
|
|
12886
|
+
children: [
|
|
12887
|
+
/* @__PURE__ */ jsxs6(Text8, { children: [
|
|
12888
|
+
"Approve at:",
|
|
12889
|
+
" ",
|
|
12890
|
+
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "cyan", children: approvalUrl })
|
|
12891
|
+
] }),
|
|
12892
|
+
/* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "Press [Enter] to open in browser" })
|
|
12893
|
+
]
|
|
12828
12894
|
}
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
step === "await-approval" && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12833
|
-
/* @__PURE__ */ jsx9(Text8, { children: SPT_FLOW.approval.description }),
|
|
12834
|
-
/* @__PURE__ */ jsxs6(
|
|
12835
|
-
Box7,
|
|
12836
|
-
{
|
|
12837
|
-
flexDirection: "column",
|
|
12838
|
-
borderStyle: "round",
|
|
12839
|
-
borderColor: "cyan",
|
|
12840
|
-
paddingX: 2,
|
|
12841
|
-
paddingY: 1,
|
|
12842
|
-
marginTop: 1,
|
|
12843
|
-
children: [
|
|
12844
|
-
/* @__PURE__ */ jsxs6(Text8, { children: [
|
|
12845
|
-
"Approve at:",
|
|
12846
|
-
" ",
|
|
12847
|
-
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "cyan", children: approvalUrl })
|
|
12848
|
-
] }),
|
|
12849
|
-
/* @__PURE__ */ jsx9(Text8, { dimColor: true, children: SPT_FLOW.approval.browserHint })
|
|
12850
|
-
]
|
|
12851
|
-
}
|
|
12852
|
-
),
|
|
12853
|
-
/* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.approval.loading }) })
|
|
12854
|
-
] }),
|
|
12855
|
-
step === "approval-timeout" && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12856
|
-
/* @__PURE__ */ jsx9(Text8, { color: "yellow", children: "\u26A0 Approval timed out (5 min). The spend request is still pending \u2014 you can still approve it." }),
|
|
12857
|
-
/* @__PURE__ */ jsxs6(
|
|
12858
|
-
Box7,
|
|
12859
|
-
{
|
|
12860
|
-
flexDirection: "column",
|
|
12861
|
-
borderStyle: "round",
|
|
12862
|
-
borderColor: "yellow",
|
|
12863
|
-
paddingX: 2,
|
|
12864
|
-
paddingY: 1,
|
|
12865
|
-
marginTop: 1,
|
|
12866
|
-
children: [
|
|
12867
|
-
/* @__PURE__ */ jsxs6(Text8, { children: [
|
|
12868
|
-
"Approve at:",
|
|
12869
|
-
" ",
|
|
12870
|
-
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "cyan", children: approvalUrl })
|
|
12871
|
-
] }),
|
|
12872
|
-
/* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "Press [Enter] to open in browser" })
|
|
12873
|
-
]
|
|
12874
|
-
}
|
|
12875
|
-
),
|
|
12876
|
-
/* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "r Retry polling q Quit demo" }) })
|
|
12895
|
+
),
|
|
12896
|
+
/* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "r Retry polling q Quit demo" }) })
|
|
12897
|
+
] })
|
|
12877
12898
|
] }),
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.mppPay.description })
|
|
12882
|
-
] }),
|
|
12899
|
+
(step === "mpp-pay-gate" || step === "mpp-pay") && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12900
|
+
/* @__PURE__ */ jsx9(Text8, { color: "green", children: "\u2713 Approved!" }),
|
|
12901
|
+
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.mppPay.description }),
|
|
12883
12902
|
step === "mpp-pay-gate" && prompt(SPT_FLOW.mppPay.prompt),
|
|
12884
12903
|
step === "mpp-pay" && /* @__PURE__ */ jsx9(Box7, { marginY: 1, children: /* @__PURE__ */ jsx9(Text8, { color: "cyan", children: SPT_FLOW.mppPay.loading }) })
|
|
12885
12904
|
] }),
|
|
12886
12905
|
step === "done" && payResult && /* @__PURE__ */ jsxs6(Box7, { flexDirection: "column", children: [
|
|
12887
|
-
/* @__PURE__ */ jsxs6(
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
children: [
|
|
12896
|
-
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "green", children: SPT_FLOW.done.success }),
|
|
12897
|
-
/* @__PURE__ */ jsxs6(Text8, { children: [
|
|
12898
|
-
"Status: ",
|
|
12899
|
-
/* @__PURE__ */ jsxs6(Text8, { bold: true, children: [
|
|
12900
|
-
"HTTP ",
|
|
12901
|
-
payResult.status
|
|
12902
|
-
] })
|
|
12903
|
-
] }),
|
|
12904
|
-
payResult.body && (() => {
|
|
12905
|
-
const body = payResult.body;
|
|
12906
|
-
try {
|
|
12907
|
-
return /* @__PURE__ */ jsx9(Text8, { children: JSON.stringify(JSON.parse(body), null, 2) });
|
|
12908
|
-
} catch {
|
|
12909
|
-
return /* @__PURE__ */ jsx9(Text8, { children: body });
|
|
12910
|
-
}
|
|
12911
|
-
})()
|
|
12912
|
-
]
|
|
12913
|
-
}
|
|
12914
|
-
),
|
|
12915
|
-
/* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.done.detail }) })
|
|
12906
|
+
/* @__PURE__ */ jsxs6(Text8, { bold: true, color: "green", children: [
|
|
12907
|
+
"\u2713 ",
|
|
12908
|
+
SPT_FLOW.done.success,
|
|
12909
|
+
" (HTTP ",
|
|
12910
|
+
payResult.status,
|
|
12911
|
+
")"
|
|
12912
|
+
] }),
|
|
12913
|
+
/* @__PURE__ */ jsx9(MarkdownText, { children: SPT_FLOW.done.detail })
|
|
12916
12914
|
] }),
|
|
12917
12915
|
step === "error" && /* @__PURE__ */ jsxs6(Text8, { color: "red", children: [
|
|
12918
12916
|
"Error: ",
|
|
@@ -12922,7 +12920,7 @@ var SptFlow = ({
|
|
|
12922
12920
|
};
|
|
12923
12921
|
|
|
12924
12922
|
// src/commands/demo/demo-runner.tsx
|
|
12925
|
-
import { Fragment as
|
|
12923
|
+
import { Fragment as Fragment3, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
12926
12924
|
var DemoRunner = ({
|
|
12927
12925
|
authRepo: authRepo2,
|
|
12928
12926
|
spendRequestRepo: spendRequestRepo2,
|
|
@@ -12933,17 +12931,17 @@ var DemoRunner = ({
|
|
|
12933
12931
|
onComplete
|
|
12934
12932
|
}) => {
|
|
12935
12933
|
const preselected = onlyCard ? "card" : onlySpt ? "spt" : null;
|
|
12936
|
-
const [choice, setChoice] =
|
|
12937
|
-
const [menuIndex, setMenuIndex] =
|
|
12934
|
+
const [choice, setChoice] = useState7(preselected);
|
|
12935
|
+
const [menuIndex, setMenuIndex] = useState7(0);
|
|
12938
12936
|
const postAuthPhase = preselected === "spt" ? "spt-flow" : preselected ? "card-flow" : "menu";
|
|
12939
|
-
const [phase, setPhase] =
|
|
12937
|
+
const [phase, setPhase] = useState7(
|
|
12940
12938
|
storage.isAuthenticated() ? postAuthPhase : "auth"
|
|
12941
12939
|
);
|
|
12942
|
-
const [paymentMethodId, setPaymentMethodId] =
|
|
12940
|
+
const [paymentMethodId, setPaymentMethodId] = useState7(
|
|
12943
12941
|
preselectedPmId ?? ""
|
|
12944
12942
|
);
|
|
12945
|
-
const [cardSuccess, setCardSuccess] =
|
|
12946
|
-
const [sptSuccess, setSptSuccess] =
|
|
12943
|
+
const [cardSuccess, setCardSuccess] = useState7(null);
|
|
12944
|
+
const [sptSuccess, setSptSuccess] = useState7(null);
|
|
12947
12945
|
const runCard = choice === "card" || choice === "both";
|
|
12948
12946
|
const runSpt = choice === "spt" || choice === "both";
|
|
12949
12947
|
useInput4((_input, key) => {
|
|
@@ -12997,7 +12995,7 @@ var DemoRunner = ({
|
|
|
12997
12995
|
),
|
|
12998
12996
|
phase === "menu" && /* @__PURE__ */ jsxs7(Box8, { flexDirection: "column", children: [
|
|
12999
12997
|
/* @__PURE__ */ jsx10(Text9, { children: DEMO_MENU.question }),
|
|
13000
|
-
/* @__PURE__ */ jsx10(Box8, { flexDirection: "column", marginTop: 1, gap: 1, children: DEMO_MENU.options.map((opt, i) => /* @__PURE__ */ jsx10(Box8, { flexDirection: "column", children: i === menuIndex ? /* @__PURE__ */ jsxs7(
|
|
12998
|
+
/* @__PURE__ */ jsx10(Box8, { flexDirection: "column", marginTop: 1, gap: 1, children: DEMO_MENU.options.map((opt, i) => /* @__PURE__ */ jsx10(Box8, { flexDirection: "column", children: i === menuIndex ? /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
13001
12999
|
/* @__PURE__ */ jsxs7(Text9, { color: "cyan", bold: true, children: [
|
|
13002
13000
|
">",
|
|
13003
13001
|
" ",
|
|
@@ -13244,7 +13242,7 @@ import { render as render4 } from "ink";
|
|
|
13244
13242
|
|
|
13245
13243
|
// src/commands/onboard/onboard-runner.tsx
|
|
13246
13244
|
import { Box as Box10, Text as Text11, useInput as useInput5 } from "ink";
|
|
13247
|
-
import { useEffect as
|
|
13245
|
+
import { useEffect as useEffect7, useRef as useRef3, useState as useState8 } from "react";
|
|
13248
13246
|
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
13249
13247
|
var OnboardRunner = ({
|
|
13250
13248
|
authRepo: authRepo2,
|
|
@@ -13252,10 +13250,10 @@ var OnboardRunner = ({
|
|
|
13252
13250
|
paymentMethodsResource,
|
|
13253
13251
|
onComplete
|
|
13254
13252
|
}) => {
|
|
13255
|
-
const [phase, setPhase] =
|
|
13256
|
-
const [authSkipped, setAuthSkipped] =
|
|
13257
|
-
const [pmMissing, setPmMissing] =
|
|
13258
|
-
const [error, setError] =
|
|
13253
|
+
const [phase, setPhase] = useState8("welcome");
|
|
13254
|
+
const [authSkipped, setAuthSkipped] = useState8(false);
|
|
13255
|
+
const [pmMissing, setPmMissing] = useState8(false);
|
|
13256
|
+
const [error, setError] = useState8("");
|
|
13259
13257
|
const enterResolver = useRef3(null);
|
|
13260
13258
|
function waitForEnter() {
|
|
13261
13259
|
return new Promise((resolve) => {
|
|
@@ -13276,7 +13274,7 @@ var OnboardRunner = ({
|
|
|
13276
13274
|
}
|
|
13277
13275
|
});
|
|
13278
13276
|
const started = useRef3(false);
|
|
13279
|
-
|
|
13277
|
+
useEffect7(() => {
|
|
13280
13278
|
if (started.current) return;
|
|
13281
13279
|
started.current = true;
|
|
13282
13280
|
const run = async () => {
|
|
@@ -13437,18 +13435,18 @@ var AddPaymentMethod = () => {
|
|
|
13437
13435
|
// src/commands/payment-methods/list.tsx
|
|
13438
13436
|
import { Box as Box12, Text as Text13 } from "ink";
|
|
13439
13437
|
import Spinner3 from "ink-spinner";
|
|
13440
|
-
import { useEffect as
|
|
13438
|
+
import { useEffect as useEffect8, useState as useState9 } from "react";
|
|
13441
13439
|
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
13442
13440
|
var PaymentMethodsList = ({
|
|
13443
13441
|
resource,
|
|
13444
13442
|
onComplete
|
|
13445
13443
|
}) => {
|
|
13446
|
-
const [status, setStatus] =
|
|
13444
|
+
const [status, setStatus] = useState9(
|
|
13447
13445
|
"loading"
|
|
13448
13446
|
);
|
|
13449
|
-
const [methods, setMethods] =
|
|
13450
|
-
const [error, setError] =
|
|
13451
|
-
|
|
13447
|
+
const [methods, setMethods] = useState9([]);
|
|
13448
|
+
const [error, setError] = useState9("");
|
|
13449
|
+
useEffect8(() => {
|
|
13452
13450
|
const fetch2 = async () => {
|
|
13453
13451
|
try {
|
|
13454
13452
|
const result = await resource.listPaymentMethods();
|
|
@@ -13621,7 +13619,7 @@ function parseTotalFlag(raw) {
|
|
|
13621
13619
|
// src/commands/spend-request/create.tsx
|
|
13622
13620
|
import { Box as Box14, Text as Text15 } from "ink";
|
|
13623
13621
|
import Spinner5 from "ink-spinner";
|
|
13624
|
-
import { useCallback as useCallback2, useEffect as
|
|
13622
|
+
import { useCallback as useCallback2, useEffect as useEffect10, useState as useState10 } from "react";
|
|
13625
13623
|
|
|
13626
13624
|
// src/commands/spend-request/approval-waiting-view.tsx
|
|
13627
13625
|
import { Box as Box13, Text as Text14 } from "ink";
|
|
@@ -13658,7 +13656,7 @@ var ApprovalWaitingView = ({
|
|
|
13658
13656
|
|
|
13659
13657
|
// src/commands/spend-request/use-approval-polling.ts
|
|
13660
13658
|
import { useInput as useInput7 } from "ink";
|
|
13661
|
-
import { useEffect as
|
|
13659
|
+
import { useEffect as useEffect9 } from "react";
|
|
13662
13660
|
function useApprovalPolling({
|
|
13663
13661
|
status,
|
|
13664
13662
|
setStatus,
|
|
@@ -13676,12 +13674,12 @@ function useApprovalPolling({
|
|
|
13676
13674
|
},
|
|
13677
13675
|
{ isActive: isWaiting }
|
|
13678
13676
|
);
|
|
13679
|
-
|
|
13677
|
+
useEffect9(() => {
|
|
13680
13678
|
if (status !== "waiting") return;
|
|
13681
13679
|
const timeout = setTimeout(() => setStatus("polling"), 1e3);
|
|
13682
13680
|
return () => clearTimeout(timeout);
|
|
13683
13681
|
}, [status, setStatus]);
|
|
13684
|
-
|
|
13682
|
+
useEffect9(() => {
|
|
13685
13683
|
if (status !== "polling" || !requestId) return;
|
|
13686
13684
|
let cancelled = false;
|
|
13687
13685
|
const poll = async () => {
|
|
@@ -13690,7 +13688,7 @@ function useApprovalPolling({
|
|
|
13690
13688
|
if (!cancelled) {
|
|
13691
13689
|
onSuccess(final);
|
|
13692
13690
|
setStatus("success");
|
|
13693
|
-
setTimeout(onComplete, 1e3);
|
|
13691
|
+
setTimeout(() => onComplete(final), 1e3);
|
|
13694
13692
|
}
|
|
13695
13693
|
} catch (err) {
|
|
13696
13694
|
if (!cancelled) {
|
|
@@ -13715,16 +13713,16 @@ function useApprovalPolling({
|
|
|
13715
13713
|
}
|
|
13716
13714
|
|
|
13717
13715
|
// src/commands/spend-request/create.tsx
|
|
13718
|
-
import { Fragment as
|
|
13716
|
+
import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
13719
13717
|
var CreateSpendRequest = ({
|
|
13720
13718
|
repository,
|
|
13721
13719
|
params,
|
|
13722
13720
|
requestApproval = false,
|
|
13723
13721
|
onComplete
|
|
13724
13722
|
}) => {
|
|
13725
|
-
const [status, setStatus] =
|
|
13726
|
-
const [request, setRequest] =
|
|
13727
|
-
const [error, setError] =
|
|
13723
|
+
const [status, setStatus] = useState10("creating");
|
|
13724
|
+
const [request, setRequest] = useState10(null);
|
|
13725
|
+
const [error, setError] = useState10("");
|
|
13728
13726
|
const approvalUrl = request?.approval_url ?? "";
|
|
13729
13727
|
const onSuccess = useCallback2(
|
|
13730
13728
|
(result) => setRequest(result),
|
|
@@ -13741,7 +13739,7 @@ var CreateSpendRequest = ({
|
|
|
13741
13739
|
onSuccess,
|
|
13742
13740
|
onError
|
|
13743
13741
|
});
|
|
13744
|
-
|
|
13742
|
+
useEffect10(() => {
|
|
13745
13743
|
const create = async () => {
|
|
13746
13744
|
try {
|
|
13747
13745
|
const result = await repository.createSpendRequest(params);
|
|
@@ -13750,12 +13748,12 @@ var CreateSpendRequest = ({
|
|
|
13750
13748
|
setStatus("waiting");
|
|
13751
13749
|
} else {
|
|
13752
13750
|
setStatus("success");
|
|
13753
|
-
setTimeout(onComplete, 1500);
|
|
13751
|
+
setTimeout(() => onComplete(result), 1500);
|
|
13754
13752
|
}
|
|
13755
13753
|
} catch (err) {
|
|
13756
13754
|
setError(err.message);
|
|
13757
13755
|
setStatus("error");
|
|
13758
|
-
setTimeout(onComplete, 1500);
|
|
13756
|
+
setTimeout(() => onComplete(null), 1500);
|
|
13759
13757
|
}
|
|
13760
13758
|
};
|
|
13761
13759
|
create();
|
|
@@ -13787,10 +13785,7 @@ var CreateSpendRequest = ({
|
|
|
13787
13785
|
/* @__PURE__ */ jsxs13(Text15, { children: [
|
|
13788
13786
|
"Amount:",
|
|
13789
13787
|
" ",
|
|
13790
|
-
/* @__PURE__ */ jsx20(Text15, { bold: true, children: (()
|
|
13791
|
-
const t = request?.totals.find((t2) => t2.type === "total");
|
|
13792
|
-
return t ? String(t.amount) : "N/A";
|
|
13793
|
-
})() })
|
|
13788
|
+
/* @__PURE__ */ jsx20(Text15, { bold: true, children: request?.amount != null ? `${request.amount} ${request.currency?.toUpperCase() ?? ""}`.trim() : "N/A" })
|
|
13794
13789
|
] }),
|
|
13795
13790
|
/* @__PURE__ */ jsxs13(Text15, { children: [
|
|
13796
13791
|
"Merchant: ",
|
|
@@ -13800,12 +13795,16 @@ var CreateSpendRequest = ({
|
|
|
13800
13795
|
"Line Items:",
|
|
13801
13796
|
" ",
|
|
13802
13797
|
/* @__PURE__ */ jsx20(Text15, { bold: true, children: request?.line_items.map((li) => li.name).join(", ") || "N/A" })
|
|
13798
|
+
] }),
|
|
13799
|
+
request?.credential_type === "shared_payment_token" && request.shared_payment_token && /* @__PURE__ */ jsxs13(Text15, { children: [
|
|
13800
|
+
"Token: ",
|
|
13801
|
+
/* @__PURE__ */ jsx20(Text15, { bold: true, children: request.shared_payment_token.id })
|
|
13803
13802
|
] })
|
|
13804
13803
|
] }),
|
|
13805
13804
|
/* @__PURE__ */ jsx20(AppDownloadQrCodes, {})
|
|
13806
13805
|
] });
|
|
13807
13806
|
}
|
|
13808
|
-
return /* @__PURE__ */ jsxs13(
|
|
13807
|
+
return /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
13809
13808
|
/* @__PURE__ */ jsx20(Box14, { children: /* @__PURE__ */ jsxs13(Text15, { color: "green", children: [
|
|
13810
13809
|
"\u2713 Spend request created (ID: ",
|
|
13811
13810
|
/* @__PURE__ */ jsx20(Text15, { bold: true, children: request?.id }),
|
|
@@ -13824,17 +13823,17 @@ var CreateSpendRequest = ({
|
|
|
13824
13823
|
// src/commands/spend-request/request-approval.tsx
|
|
13825
13824
|
import { Box as Box15, Text as Text16 } from "ink";
|
|
13826
13825
|
import Spinner6 from "ink-spinner";
|
|
13827
|
-
import { useCallback as useCallback3, useEffect as
|
|
13826
|
+
import { useCallback as useCallback3, useEffect as useEffect11, useState as useState11 } from "react";
|
|
13828
13827
|
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
13829
13828
|
var RequestApproval = ({
|
|
13830
13829
|
repository,
|
|
13831
13830
|
id,
|
|
13832
13831
|
onComplete
|
|
13833
13832
|
}) => {
|
|
13834
|
-
const [status, setStatus] =
|
|
13835
|
-
const [approvalUrl, setApprovalUrl] =
|
|
13836
|
-
const [result, setResult] =
|
|
13837
|
-
const [error, setError] =
|
|
13833
|
+
const [status, setStatus] = useState11("requesting");
|
|
13834
|
+
const [approvalUrl, setApprovalUrl] = useState11("");
|
|
13835
|
+
const [result, setResult] = useState11(null);
|
|
13836
|
+
const [error, setError] = useState11("");
|
|
13838
13837
|
const onSuccess = useCallback3((r) => setResult(r), []);
|
|
13839
13838
|
const onError = useCallback3((msg) => setError(msg), []);
|
|
13840
13839
|
useApprovalPolling({
|
|
@@ -13847,7 +13846,7 @@ var RequestApproval = ({
|
|
|
13847
13846
|
onSuccess,
|
|
13848
13847
|
onError
|
|
13849
13848
|
});
|
|
13850
|
-
|
|
13849
|
+
useEffect11(() => {
|
|
13851
13850
|
const request = async () => {
|
|
13852
13851
|
try {
|
|
13853
13852
|
const res = await repository.requestApproval(id);
|
|
@@ -13887,14 +13886,15 @@ var RequestApproval = ({
|
|
|
13887
13886
|
/* @__PURE__ */ jsxs14(Text16, { children: [
|
|
13888
13887
|
"Amount:",
|
|
13889
13888
|
" ",
|
|
13890
|
-
/* @__PURE__ */ jsx21(Text16, { bold: true, children: (()
|
|
13891
|
-
const t = result?.totals.find((t2) => t2.type === "total");
|
|
13892
|
-
return t ? String(t.amount) : "N/A";
|
|
13893
|
-
})() })
|
|
13889
|
+
/* @__PURE__ */ jsx21(Text16, { bold: true, children: result?.amount != null ? `${result.amount} ${result.currency?.toUpperCase() ?? ""}`.trim() : "N/A" })
|
|
13894
13890
|
] }),
|
|
13895
13891
|
/* @__PURE__ */ jsxs14(Text16, { children: [
|
|
13896
13892
|
"Merchant: ",
|
|
13897
13893
|
/* @__PURE__ */ jsx21(Text16, { bold: true, children: result?.merchant_name })
|
|
13894
|
+
] }),
|
|
13895
|
+
result?.credential_type === "shared_payment_token" && result.shared_payment_token && /* @__PURE__ */ jsxs14(Text16, { children: [
|
|
13896
|
+
"Token: ",
|
|
13897
|
+
/* @__PURE__ */ jsx21(Text16, { bold: true, children: result.shared_payment_token.id })
|
|
13898
13898
|
] })
|
|
13899
13899
|
] })
|
|
13900
13900
|
] });
|
|
@@ -13911,7 +13911,7 @@ var RequestApproval = ({
|
|
|
13911
13911
|
// src/commands/spend-request/retrieve.tsx
|
|
13912
13912
|
import { Box as Box16, Text as Text17 } from "ink";
|
|
13913
13913
|
import Spinner7 from "ink-spinner";
|
|
13914
|
-
import { useEffect as
|
|
13914
|
+
import { useEffect as useEffect12, useRef as useRef4, useState as useState12 } from "react";
|
|
13915
13915
|
import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
13916
13916
|
var RetrieveSpendRequest = ({
|
|
13917
13917
|
repository,
|
|
@@ -13920,36 +13920,38 @@ var RetrieveSpendRequest = ({
|
|
|
13920
13920
|
include,
|
|
13921
13921
|
onComplete
|
|
13922
13922
|
}) => {
|
|
13923
|
-
const [phase, setPhase] =
|
|
13924
|
-
const [request, setRequest] =
|
|
13925
|
-
const [error, setError] =
|
|
13926
|
-
const [elapsed, setElapsed] =
|
|
13923
|
+
const [phase, setPhase] = useState12("fetching");
|
|
13924
|
+
const [request, setRequest] = useState12(null);
|
|
13925
|
+
const [error, setError] = useState12("");
|
|
13926
|
+
const [elapsed, setElapsed] = useState12(0);
|
|
13927
13927
|
const startTimeRef = useRef4(Date.now());
|
|
13928
13928
|
const pollRef = useRef4(null);
|
|
13929
13929
|
const timerRef = useRef4(null);
|
|
13930
|
-
|
|
13930
|
+
const requestRef = useRef4(null);
|
|
13931
|
+
useEffect12(() => {
|
|
13931
13932
|
return () => {
|
|
13932
13933
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
13933
13934
|
if (timerRef.current) clearInterval(timerRef.current);
|
|
13934
13935
|
};
|
|
13935
13936
|
}, []);
|
|
13936
|
-
|
|
13937
|
+
useEffect12(() => {
|
|
13937
13938
|
const fetch2 = async () => {
|
|
13938
13939
|
try {
|
|
13939
13940
|
const result = await repository.getSpendRequest(id, { include });
|
|
13940
13941
|
if (!result) {
|
|
13941
13942
|
setError(`Spend request ${id} not found`);
|
|
13942
13943
|
setPhase("error");
|
|
13943
|
-
setTimeout(onComplete, 1500);
|
|
13944
|
+
setTimeout(() => onComplete(null), 1500);
|
|
13944
13945
|
return;
|
|
13945
13946
|
}
|
|
13947
|
+
requestRef.current = result;
|
|
13946
13948
|
setRequest(result);
|
|
13947
13949
|
if (result.status === "approved") {
|
|
13948
13950
|
setPhase("success");
|
|
13949
|
-
setTimeout(onComplete, 1500);
|
|
13951
|
+
setTimeout(() => onComplete(result), 1500);
|
|
13950
13952
|
} else if (result.status === "denied") {
|
|
13951
13953
|
setPhase("declined");
|
|
13952
|
-
setTimeout(onComplete, 1500);
|
|
13954
|
+
setTimeout(() => onComplete(result), 1500);
|
|
13953
13955
|
} else {
|
|
13954
13956
|
startTimeRef.current = Date.now();
|
|
13955
13957
|
setPhase("polling");
|
|
@@ -13957,12 +13959,12 @@ var RetrieveSpendRequest = ({
|
|
|
13957
13959
|
} catch (err) {
|
|
13958
13960
|
setError(err.message);
|
|
13959
13961
|
setPhase("error");
|
|
13960
|
-
setTimeout(onComplete, 1500);
|
|
13962
|
+
setTimeout(() => onComplete(null), 1500);
|
|
13961
13963
|
}
|
|
13962
13964
|
};
|
|
13963
13965
|
fetch2();
|
|
13964
13966
|
}, [repository, id, include, onComplete]);
|
|
13965
|
-
|
|
13967
|
+
useEffect12(() => {
|
|
13966
13968
|
if (phase !== "polling") return;
|
|
13967
13969
|
timerRef.current = setInterval(() => {
|
|
13968
13970
|
const secs = Math.floor((Date.now() - startTimeRef.current) / 1e3);
|
|
@@ -13974,23 +13976,24 @@ var RetrieveSpendRequest = ({
|
|
|
13974
13976
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
13975
13977
|
if (timerRef.current) clearInterval(timerRef.current);
|
|
13976
13978
|
setPhase("timeout");
|
|
13977
|
-
setTimeout(onComplete, 1500);
|
|
13979
|
+
setTimeout(() => onComplete(requestRef.current), 1500);
|
|
13978
13980
|
return;
|
|
13979
13981
|
}
|
|
13980
13982
|
try {
|
|
13981
13983
|
const result = await repository.getSpendRequest(id, { include });
|
|
13982
13984
|
if (!result) return;
|
|
13985
|
+
requestRef.current = result;
|
|
13983
13986
|
setRequest(result);
|
|
13984
13987
|
if (result.status === "approved") {
|
|
13985
13988
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
13986
13989
|
if (timerRef.current) clearInterval(timerRef.current);
|
|
13987
13990
|
setPhase("success");
|
|
13988
|
-
setTimeout(onComplete, 1500);
|
|
13991
|
+
setTimeout(() => onComplete(result), 1500);
|
|
13989
13992
|
} else if (result.status === "denied") {
|
|
13990
13993
|
if (pollRef.current) clearInterval(pollRef.current);
|
|
13991
13994
|
if (timerRef.current) clearInterval(timerRef.current);
|
|
13992
13995
|
setPhase("declined");
|
|
13993
|
-
setTimeout(onComplete, 1500);
|
|
13996
|
+
setTimeout(() => onComplete(result), 1500);
|
|
13994
13997
|
}
|
|
13995
13998
|
} catch {
|
|
13996
13999
|
}
|
|
@@ -14063,10 +14066,7 @@ var RetrieveSpendRequest = ({
|
|
|
14063
14066
|
/* @__PURE__ */ jsxs15(Text17, { children: [
|
|
14064
14067
|
"Amount:",
|
|
14065
14068
|
" ",
|
|
14066
|
-
/* @__PURE__ */ jsx22(Text17, { bold: true, children: (
|
|
14067
|
-
const t = request?.totals.find((t2) => t2.type === "total");
|
|
14068
|
-
return t ? String(t.amount) : "N/A";
|
|
14069
|
-
})() })
|
|
14069
|
+
/* @__PURE__ */ jsx22(Text17, { bold: true, children: request?.amount != null ? String(request.amount) : "N/A" })
|
|
14070
14070
|
] }),
|
|
14071
14071
|
/* @__PURE__ */ jsxs15(Text17, { children: [
|
|
14072
14072
|
"Merchant: ",
|
|
@@ -14090,10 +14090,7 @@ var RetrieveSpendRequest = ({
|
|
|
14090
14090
|
/* @__PURE__ */ jsxs15(Text17, { children: [
|
|
14091
14091
|
"Amount:",
|
|
14092
14092
|
" ",
|
|
14093
|
-
/* @__PURE__ */ jsx22(Text17, { bold: true, children: (
|
|
14094
|
-
const t = request?.totals.find((t2) => t2.type === "total");
|
|
14095
|
-
return t ? String(t.amount) : "N/A";
|
|
14096
|
-
})() })
|
|
14093
|
+
/* @__PURE__ */ jsx22(Text17, { bold: true, children: request?.amount != null ? String(request.amount) : "N/A" })
|
|
14097
14094
|
] }),
|
|
14098
14095
|
/* @__PURE__ */ jsxs15(Text17, { children: [
|
|
14099
14096
|
"Merchant: ",
|
|
@@ -14231,7 +14228,7 @@ var updateOptions = z6.object({
|
|
|
14231
14228
|
// src/commands/spend-request/update.tsx
|
|
14232
14229
|
import { Box as Box17, Text as Text18 } from "ink";
|
|
14233
14230
|
import Spinner8 from "ink-spinner";
|
|
14234
|
-
import { useEffect as
|
|
14231
|
+
import { useEffect as useEffect13, useState as useState13 } from "react";
|
|
14235
14232
|
import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
14236
14233
|
var UpdateSpendRequest = ({
|
|
14237
14234
|
repository,
|
|
@@ -14239,22 +14236,22 @@ var UpdateSpendRequest = ({
|
|
|
14239
14236
|
params,
|
|
14240
14237
|
onComplete
|
|
14241
14238
|
}) => {
|
|
14242
|
-
const [status, setStatus] =
|
|
14239
|
+
const [status, setStatus] = useState13(
|
|
14243
14240
|
"loading"
|
|
14244
14241
|
);
|
|
14245
|
-
const [request, setRequest] =
|
|
14246
|
-
const [error, setError] =
|
|
14247
|
-
|
|
14242
|
+
const [request, setRequest] = useState13(null);
|
|
14243
|
+
const [error, setError] = useState13("");
|
|
14244
|
+
useEffect13(() => {
|
|
14248
14245
|
const update = async () => {
|
|
14249
14246
|
try {
|
|
14250
14247
|
const result = await repository.updateSpendRequest(id, params);
|
|
14251
14248
|
setRequest(result);
|
|
14252
14249
|
setStatus("success");
|
|
14253
|
-
setTimeout(onComplete, 1500);
|
|
14250
|
+
setTimeout(() => onComplete(result), 1500);
|
|
14254
14251
|
} catch (err) {
|
|
14255
14252
|
setError(err.message);
|
|
14256
14253
|
setStatus("error");
|
|
14257
|
-
setTimeout(onComplete, 1500);
|
|
14254
|
+
setTimeout(() => onComplete(null), 1500);
|
|
14258
14255
|
}
|
|
14259
14256
|
};
|
|
14260
14257
|
update();
|
|
@@ -14386,6 +14383,7 @@ function createSpendRequestCli(repository) {
|
|
|
14386
14383
|
};
|
|
14387
14384
|
if (!c.agent && !c.formatExplicit) {
|
|
14388
14385
|
return new Promise((resolve) => {
|
|
14386
|
+
let capturedResult = null;
|
|
14389
14387
|
const { waitUntilExit } = render6(
|
|
14390
14388
|
/* @__PURE__ */ jsx24(
|
|
14391
14389
|
CreateSpendRequest,
|
|
@@ -14393,14 +14391,14 @@ function createSpendRequestCli(repository) {
|
|
|
14393
14391
|
repository,
|
|
14394
14392
|
params: createParams,
|
|
14395
14393
|
requestApproval,
|
|
14396
|
-
onComplete: () => {
|
|
14394
|
+
onComplete: (result) => {
|
|
14395
|
+
capturedResult = result;
|
|
14397
14396
|
}
|
|
14398
14397
|
}
|
|
14399
14398
|
)
|
|
14400
14399
|
);
|
|
14401
|
-
waitUntilExit().then(
|
|
14402
|
-
|
|
14403
|
-
resolve(created2);
|
|
14400
|
+
waitUntilExit().then(() => {
|
|
14401
|
+
resolve(capturedResult);
|
|
14404
14402
|
});
|
|
14405
14403
|
});
|
|
14406
14404
|
}
|
|
@@ -14459,6 +14457,7 @@ function createSpendRequestCli(repository) {
|
|
|
14459
14457
|
);
|
|
14460
14458
|
if (!c.agent && !c.formatExplicit) {
|
|
14461
14459
|
return new Promise((resolve) => {
|
|
14460
|
+
let capturedResult = null;
|
|
14462
14461
|
const { waitUntilExit } = render6(
|
|
14463
14462
|
/* @__PURE__ */ jsx24(
|
|
14464
14463
|
UpdateSpendRequest,
|
|
@@ -14466,13 +14465,14 @@ function createSpendRequestCli(repository) {
|
|
|
14466
14465
|
repository,
|
|
14467
14466
|
id,
|
|
14468
14467
|
params,
|
|
14469
|
-
onComplete: () => {
|
|
14468
|
+
onComplete: (result) => {
|
|
14469
|
+
capturedResult = result;
|
|
14470
14470
|
}
|
|
14471
14471
|
}
|
|
14472
14472
|
)
|
|
14473
14473
|
);
|
|
14474
|
-
waitUntilExit().then(
|
|
14475
|
-
resolve(
|
|
14474
|
+
waitUntilExit().then(() => {
|
|
14475
|
+
resolve(capturedResult);
|
|
14476
14476
|
});
|
|
14477
14477
|
});
|
|
14478
14478
|
}
|
|
@@ -14500,20 +14500,21 @@ function createSpendRequestCli(repository) {
|
|
|
14500
14500
|
const id = c.args.id;
|
|
14501
14501
|
if (!c.agent && !c.formatExplicit) {
|
|
14502
14502
|
return new Promise((resolve) => {
|
|
14503
|
+
let capturedResult = null;
|
|
14503
14504
|
const { waitUntilExit } = render6(
|
|
14504
14505
|
/* @__PURE__ */ jsx24(
|
|
14505
14506
|
RequestApproval,
|
|
14506
14507
|
{
|
|
14507
14508
|
repository,
|
|
14508
14509
|
id,
|
|
14509
|
-
onComplete: () => {
|
|
14510
|
+
onComplete: (result) => {
|
|
14511
|
+
capturedResult = result;
|
|
14510
14512
|
}
|
|
14511
14513
|
}
|
|
14512
14514
|
)
|
|
14513
14515
|
);
|
|
14514
|
-
waitUntilExit().then(
|
|
14515
|
-
|
|
14516
|
-
resolve(approval2);
|
|
14516
|
+
waitUntilExit().then(() => {
|
|
14517
|
+
resolve(capturedResult);
|
|
14517
14518
|
});
|
|
14518
14519
|
});
|
|
14519
14520
|
}
|
|
@@ -14556,6 +14557,7 @@ function createSpendRequestCli(repository) {
|
|
|
14556
14557
|
const include = includeArr?.length ? includeArr : void 0;
|
|
14557
14558
|
if (!c.agent && !c.formatExplicit) {
|
|
14558
14559
|
return new Promise((resolve) => {
|
|
14560
|
+
let capturedResult = null;
|
|
14559
14561
|
const { waitUntilExit } = render6(
|
|
14560
14562
|
/* @__PURE__ */ jsx24(
|
|
14561
14563
|
RetrieveSpendRequest,
|
|
@@ -14564,14 +14566,14 @@ function createSpendRequestCli(repository) {
|
|
|
14564
14566
|
id,
|
|
14565
14567
|
timeout,
|
|
14566
14568
|
include,
|
|
14567
|
-
onComplete: () => {
|
|
14569
|
+
onComplete: (result) => {
|
|
14570
|
+
capturedResult = result;
|
|
14568
14571
|
}
|
|
14569
14572
|
}
|
|
14570
14573
|
)
|
|
14571
14574
|
);
|
|
14572
|
-
waitUntilExit().then(
|
|
14573
|
-
|
|
14574
|
-
resolve(request);
|
|
14575
|
+
waitUntilExit().then(() => {
|
|
14576
|
+
resolve(capturedResult);
|
|
14575
14577
|
});
|
|
14576
14578
|
});
|
|
14577
14579
|
}
|
|
@@ -14915,7 +14917,7 @@ var ResourceFactory = class {
|
|
|
14915
14917
|
};
|
|
14916
14918
|
|
|
14917
14919
|
// src/cli.tsx
|
|
14918
|
-
var cliVersion = "0.
|
|
14920
|
+
var cliVersion = "0.4.0";
|
|
14919
14921
|
var buildNumber = "1";
|
|
14920
14922
|
var cliName = "@stripe/link-cli";
|
|
14921
14923
|
var defaultHeaders = {
|