sekura 0.3.0 → 0.4.1

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/README.md CHANGED
@@ -28,6 +28,16 @@ Sekura is an AI red team as a service: it scans a GitHub repository you have gra
28
28
 
29
29
  Every scan you then ask for in your coding tool is quoted first, with the price and the authorization wording, and starts only after you agree.
30
30
 
31
+ ## Paying from your coding tool
32
+
33
+ The quote lists how you can pay:
34
+
35
+ - **A saved card**, shown only by brand and last four (`Visa •••• •••• •••• 4242`). Pick one and it is charged right there, with no browser: `Charged $10 to Visa ending 4242`, then the scan id and link.
36
+ - **Pay with a Checkout link.** The agent runs `npx sekura@latest pay "<link>" --plan <id>`, which opens Stripe Checkout in your default browser and waits. When the payment lands, the same session shows the scan id and link. Your first payment is always made this way, and the card you use is saved for next time.
37
+ - **Change payment method.** The agent runs `npx sekura@latest billing --open`, which opens the page where you add or change a card, then shows the updated list.
38
+
39
+ Nothing is charged without a quote and your yes, and only the card you pick is charged.
40
+
31
41
  ## Flags
32
42
 
33
43
  | Flag | What it does |
@@ -53,9 +63,12 @@ npx sekura@latest init --no-login # no sign-in here; each tool signs in on
53
63
  npx sekura@latest init --device # sign in with a code, for a terminal on another machine
54
64
  npx sekura@latest login # sign in again, give connected tools the key, pick a repository
55
65
  npx sekura@latest status # what is connected, and who is signed in
66
+ npx sekura@latest billing # your saved cards, masked; --open to change them
67
+ npx sekura@latest pay "<checkout link>" --plan <id> # open Checkout and wait for the payment
56
68
  npx sekura@latest logout # forget the saved key
57
69
  npx sekura@latest uninstall # remove the entries, the skill, the guidance block and the saved key
58
70
  SEKURA_API_KEY=sek_live_… npx sekura@latest init --yes # unattended, with a key from Settings
71
+ SEKURA_ENDPOINT=https://dev.sekura.ai/mcp npx sekura@latest billing # against another Sekura server, for testing
59
72
  ```
60
73
 
61
74
  ## What it writes
package/dist/api.js CHANGED
@@ -39,4 +39,6 @@ export async function callTool(key, name, args = {}) {
39
39
  throw new Error(`Sekura ${name}: no data in the answer`);
40
40
  }
41
41
  export const getAccount = (key) => callTool(key, 'getAccount');
42
+ export const getPlans = (key) => callTool(key, 'getPlans');
43
+ export const getBilling = (key) => callTool(key, 'getBilling');
42
44
  export const listRepositories = (key) => callTool(key, 'listRepositories');
package/dist/catalogue.js CHANGED
@@ -12,7 +12,7 @@
12
12
  import { existsSync, readdirSync } from 'node:fs';
13
13
  import { homedir, platform } from 'node:os';
14
14
  import { join, delimiter } from 'node:path';
15
- export const ENDPOINT = 'https://sekura.ai/mcp';
15
+ export const ENDPOINT = process.env.SEKURA_ENDPOINT?.trim() || 'https://sekura.ai/mcp';
16
16
  export const SERVER_NAME = 'sekura';
17
17
  export const DOCS = 'https://sekura.ai/connect/';
18
18
  /** The home directory, overridable for tests. */
package/dist/cli.js CHANGED
@@ -16,6 +16,8 @@ import { initCommand } from './commands/init.js';
16
16
  import { statusCommand } from './commands/status.js';
17
17
  import { uninstallCommand } from './commands/uninstall.js';
18
18
  import { loginCommand, logoutCommand } from './commands/login.js';
19
+ import { payCommand } from './commands/pay.js';
20
+ import { billingCommand } from './commands/billing.js';
19
21
  import { DOCS } from './catalogue.js';
20
22
  const { version } = createRequire(import.meta.url)('../package.json');
21
23
  const program = new Command();
@@ -27,7 +29,9 @@ program
27
29
  .addCommand(loginCommand)
28
30
  .addCommand(statusCommand)
29
31
  .addCommand(uninstallCommand)
30
- .addCommand(logoutCommand);
32
+ .addCommand(logoutCommand)
33
+ .addCommand(payCommand)
34
+ .addCommand(billingCommand);
31
35
  try {
32
36
  await program.parseAsync(process.argv);
33
37
  }
@@ -0,0 +1,60 @@
1
+ import { Command } from 'commander';
2
+ import { openBrowser, readKey } from '../auth.js';
3
+ import { getBilling, SignedOut } from '../api.js';
4
+ import { cardLines, cardsFingerprint, paymentMethodsLink } from '../payment.js';
5
+ import { cross, dot, say, tick, waitFor } from '../ui.js';
6
+ function sayCards(b, heading) {
7
+ const lines = cardLines(b);
8
+ if (!lines.length) {
9
+ say(`${dot} No saved card. Your first payment on a Stripe Checkout page saves the card you use there.`);
10
+ return;
11
+ }
12
+ say(`${tick} ${heading}`);
13
+ for (const l of lines)
14
+ say(` ${l}`);
15
+ }
16
+ export async function runBilling(opts = {}) {
17
+ const key = readKey();
18
+ if (!key) {
19
+ say(`${cross} Not signed in here: run npx sekura@latest login first.`);
20
+ return 4;
21
+ }
22
+ let before;
23
+ try {
24
+ before = await getBilling(key);
25
+ }
26
+ catch (e) {
27
+ say(`${cross} ${e instanceof SignedOut ? `Your Sekura key no longer works (${e.message}); run npx sekura@latest login.` : `Sekura could not be asked: ${e.message}`}`);
28
+ return 1;
29
+ }
30
+ if (!opts.open) {
31
+ sayCards(before, 'Saved cards:');
32
+ return 0;
33
+ }
34
+ const link = paymentMethodsLink();
35
+ const opened = opts.browser === false ? false : openBrowser(link);
36
+ say(opened ? `${tick} Opened your payment methods in the browser: ${link}` : `${dot} Open this link in a browser to add or change a card: ${link}`);
37
+ const was = cardsFingerprint(before);
38
+ let now = before;
39
+ const minutes = Number(opts.timeout);
40
+ const result = await waitFor('Waiting for your cards to change (Enter when you are done)', async () => {
41
+ now = await getBilling(key);
42
+ return cardsFingerprint(now) !== was;
43
+ }, { timeoutMs: (Number.isFinite(minutes) && minutes > 0 ? Math.min(minutes, 60) : 5) * 60_000, ...(opts.intervalMs ? { intervalMs: opts.intervalMs } : {}) });
44
+ if (result !== 'done') {
45
+ try {
46
+ now = await getBilling(key);
47
+ }
48
+ catch {
49
+ now = before;
50
+ }
51
+ }
52
+ sayCards(now, cardsFingerprint(now) !== was ? 'Your cards now:' : 'No change seen. Saved cards:');
53
+ return 0;
54
+ }
55
+ export const billingCommand = new Command('billing')
56
+ .description('Show your saved cards, masked; with --open, change them in the browser and show the new list.')
57
+ .option('--open', 'open the page where cards are added or changed, then wait for the change')
58
+ .option('--timeout <minutes>', 'how long to wait with --open', '5')
59
+ .option('--no-browser', 'print the link instead of opening it')
60
+ .action(async (opts) => { process.exitCode = await runBilling(opts); });
@@ -0,0 +1,91 @@
1
+ import { Command } from 'commander';
2
+ import { openBrowser, readKey } from '../auth.js';
3
+ import { getPlans, SignedOut } from '../api.js';
4
+ import { openableLink, paymentState, scanLink } from '../payment.js';
5
+ import { cross, dot, say, tick, waitFor } from '../ui.js';
6
+ export const PAY_EXIT = { started: 0, paid: 0, notSignedIn: 4, cancelled: 3, timeout: 2, badLink: 1 };
7
+ const planName = (p) => (p?.owner && p?.name ? `${p.owner}/${p.name}` : 'the repository');
8
+ // The names a user reads for a monthly plan, keyed by the tier id the server
9
+ // sends, which stays as it is (26 November 2026 pricing). Until 27 November
10
+ // 2026 this line printed a retired plan name for 'always' and named no plan at
11
+ // all for 'pro'. 'plus' is retired but still held by some accounts, so it reads
12
+ // as "Your monthly plan" rather than by its old name.
13
+ const MONTHLY = { always: 'Weekly', pro: 'More frequently', plus: 'Your monthly plan' };
14
+ const minutes = (raw, fallback) => {
15
+ const n = Number(raw);
16
+ return Number.isFinite(n) && n > 0 ? Math.min(n, 60) : fallback;
17
+ };
18
+ async function planById(key, planId) {
19
+ return (await getPlans(key)).plans.find((p) => p.id === planId);
20
+ }
21
+ function sayOpened(link, opened) {
22
+ if (opened)
23
+ say(`${tick} Opened Stripe Checkout in your browser: ${link.href}`);
24
+ else
25
+ say(`${dot} Open this link in a browser to pay: ${link.href}`);
26
+ }
27
+ function sayOutcome(state, plan) {
28
+ const repo = planName(plan);
29
+ if (state.kind === 'started') {
30
+ const monthly = plan?.plan ? MONTHLY[plan.plan] : undefined;
31
+ const what = monthly ? `${monthly} is on for ${repo}, and its first scan` : `The scan of ${repo}`;
32
+ say(`${tick} Payment received. ${what} has started: scan id ${state.scanId} (${state.scanStatus}).`);
33
+ say(` ${scanLink(state.scanId)}`);
34
+ }
35
+ else if (state.kind === 'paid') {
36
+ say(`${tick} Payment received for ${repo}. The scan starts within a few minutes; ask your coding tool for listScans or getScan to follow it.`);
37
+ }
38
+ else if (state.kind === 'cancelled') {
39
+ say(`${cross} Checkout was closed without paying, so nothing was charged and ${repo} is back to how it was.`);
40
+ }
41
+ }
42
+ export async function runPay(link, opts = {}) {
43
+ const url = openableLink(link);
44
+ if (!url) {
45
+ say(`${cross} Not a Stripe Checkout or Sekura link, so it was not opened: ${link}`);
46
+ return PAY_EXIT.badLink;
47
+ }
48
+ const opened = opts.open === false ? false : openBrowser(url.href);
49
+ sayOpened(url, opened);
50
+ const key = readKey();
51
+ if (!opts.plan || !key) {
52
+ say(`${dot} ${key ? 'No plan id was given' : 'Not signed in here (npx sekura@latest login)'}, so this terminal cannot tell when the payment lands. After paying, ask your coding tool for getPlans.`);
53
+ return PAY_EXIT.notSignedIn;
54
+ }
55
+ const planId = opts.plan;
56
+ let start;
57
+ try {
58
+ start = await planById(key, planId);
59
+ }
60
+ catch (e) {
61
+ if (e instanceof SignedOut) {
62
+ say(`${cross} Your Sekura key no longer works (${e.message}); run npx sekura@latest login.`);
63
+ return PAY_EXIT.notSignedIn;
64
+ }
65
+ }
66
+ let last = start;
67
+ let state = { kind: 'waiting' };
68
+ let cancelledSeen = 0;
69
+ const result = await waitFor('Waiting for the payment to complete in your browser (Enter to stop waiting)', async () => {
70
+ last = await planById(key, planId);
71
+ state = paymentState(start, last);
72
+ if (state.kind === 'cancelled')
73
+ return ++cancelledSeen >= 2;
74
+ cancelledSeen = 0;
75
+ return state.kind === 'started';
76
+ }, { timeoutMs: minutes(opts.timeout, 9) * 60_000, ...(opts.intervalMs ? { intervalMs: opts.intervalMs } : {}) });
77
+ const final = state;
78
+ if (result === 'done' || final.kind === 'paid') {
79
+ sayOutcome(final, last);
80
+ return final.kind === 'cancelled' ? PAY_EXIT.cancelled : PAY_EXIT.started;
81
+ }
82
+ say(`${dot} ${result === 'skipped' ? 'Stopped waiting' : 'No payment yet'}. The Checkout link stays valid for 24 hours; the scan starts as soon as it is paid. Ask your coding tool for getPlans to check.`);
83
+ return PAY_EXIT.timeout;
84
+ }
85
+ export const payCommand = new Command('pay')
86
+ .description('Open a Stripe Checkout link from a Sekura quote in your browser and wait until the payment lands.')
87
+ .argument('<checkout-link>', 'the Checkout link Sekura answered with')
88
+ .option('--plan <id>', 'the plan id from the same answer, to wait on')
89
+ .option('--timeout <minutes>', 'how long to wait', '9')
90
+ .option('--no-open', 'print the link instead of opening it')
91
+ .action(async (link, opts) => { process.exitCode = await runPay(link, opts); });
@@ -0,0 +1,37 @@
1
+ import { ENDPOINT } from './catalogue.js';
2
+ export const SEKURA_ORIGIN = new URL(ENDPOINT).origin;
3
+ const OPENABLE_HOSTS = new Set(['checkout.stripe.com', 'billing.stripe.com', new URL(ENDPOINT).host]);
4
+ export function openableLink(raw) {
5
+ let url;
6
+ try {
7
+ url = new URL(raw);
8
+ }
9
+ catch {
10
+ return null;
11
+ }
12
+ const local = url.hostname === '127.0.0.1' || url.hostname === 'localhost';
13
+ if (url.protocol !== 'https:' && !(local && url.protocol === 'http:'))
14
+ return null;
15
+ return OPENABLE_HOSTS.has(url.host) ? url : null;
16
+ }
17
+ export const paymentMethodsLink = () => `${SEKURA_ORIGIN}/app/payment-methods`;
18
+ export const scanLink = (scanId) => `${SEKURA_ORIGIN}/app/scans/${encodeURIComponent(scanId.startsWith('ss-') ? scanId : `ss-${scanId}`)}`;
19
+ const newScanOf = (start, now) => now.lastScan && now.lastScan.id !== start?.lastScan?.id ? now.lastScan : null;
20
+ export function paymentState(start, now) {
21
+ if (!now)
22
+ return start ? { kind: 'cancelled' } : { kind: 'waiting' };
23
+ if (now.status === 'active') {
24
+ const scan = newScanOf(start, now);
25
+ if (scan)
26
+ return { kind: 'started', scanId: scan.id, scanStatus: scan.status };
27
+ const backAsItWas = start?.status === 'pending' && (start.pendingFrom === 'rerun' || start.pendingFrom === 'upgrade') && !now.nextRunAt && !now.pendingFrom;
28
+ return backAsItWas && start.plan === now.plan ? { kind: 'cancelled' } : { kind: 'paid' };
29
+ }
30
+ if (now.status === 'pending' && start?.selected && !now.selected)
31
+ return { kind: 'cancelled' };
32
+ if (now.status === 'canceled')
33
+ return { kind: 'cancelled' };
34
+ return { kind: 'waiting' };
35
+ }
36
+ export const cardLines = (b) => (b.cards ?? []).map((c) => `${c.masked}${c.isDefault ? ' (default)' : ''}`);
37
+ export const cardsFingerprint = (b) => (b.cards ?? []).map((c) => `${c.masked}:${c.isDefault ? 1 : 0}`).join('|');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sekura",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Connect your coding tool to Sekura in one command: npx sekura@latest init",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.json && node -e \"require('fs').chmodSync('dist/cli.js', 0o755)\"",
40
- "test": "npm run build && node --test test/init.test.mjs test/login.test.mjs test/guide.test.mjs test/device.test.mjs test/skill.test.mjs",
40
+ "test": "npm run build && node --test test/init.test.mjs test/login.test.mjs test/guide.test.mjs test/device.test.mjs test/skill.test.mjs test/pay.test.mjs",
41
41
  "prepack": "npm run build"
42
42
  },
43
43
  "dependencies": {
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: sekura
3
- description: Use when the user wants a GitHub repository scanned for vulnerabilities, wants to read scan findings or a report, or wants to put a repository on a recurring Sekura scan. Covers the sekura MCP tools and the rule that every scan and plan is quoted first and started only after the user agrees.
4
- argument-hint: "[help | repos | scan <owner/repo> | scans | scan-status <scan> | findings <scan> | report <scan> | cancel <scan|owner/repo> | always <owner/repo> | schedule <owner/repo> | plans | billing]"
3
+ description: Use when the user wants a GitHub repository scanned for vulnerabilities, wants to read scan findings or a report, or wants to put a repository on a monthly plan. Covers the sekura MCP tools and the rule that every scan and plan is quoted first and started only after the user agrees.
4
+ argument-hint: "[help | repos | scan <owner/repo> | scans | scan-status <scan> | findings <scan> | report <scan> | cancel <scan|owner/repo> | monthly <owner/repo> | schedule <owner/repo> | plans | billing]"
5
5
  ---
6
6
 
7
7
  # Sekura
@@ -25,18 +25,26 @@ the first word:
25
25
  anything the account still needs on sekura.ai, and the repositories Sekura can
26
26
  scan, then end with "Type `/sekura help` for commands."
27
27
  - `repos`: `listRepositories`.
28
- - `scan <owner/repo>`: `quoteScan` for that repository, then the two-step rule below.
28
+ - `scan <owner/repo>`: `quoteScan` for that repository (a one-time scan), then the two-step rule below.
29
29
  - `scans`: `listScans`.
30
30
  - `scan-status <scan>`: `getScan`. `findings <scan>`: `getScanFindings`.
31
31
  - `report <scan>`: `getReportLink`.
32
32
  - `cancel <scan>`: `previewCancelScan` with that scan id. `cancel <owner/repo>`:
33
33
  `previewCancelPlan` with that repository. An argument with a `/` in it is a
34
34
  repository; anything else is a scan id. Then the two-step rule below.
35
- - `always <owner/repo>`: `quoteAlways` for that repository, then the two-step rule.
36
- It needs a schedule; if the user gave none, ask when it should run (daily,
37
- weekly on a weekday, or monthly on the Nth weekday, at what time, in which time
38
- zone) before quoting. The plan (`tier`) is `always` unless the user asks for
39
- `plus` or `pro`.
35
+ - `monthly <owner/repo>` (or `always <owner/repo>`, its older name):
36
+ `quoteAlways` for that repository, then the two-step rule. There are two
37
+ monthly plans: Weekly (`tier` `always`, the default) and More frequently
38
+ (`tier` `pro`). Use `pro` only when the user asks for More frequently, and
39
+ call it More frequently, never by its schedule kind (`daily`). It needs a
40
+ schedule; if the user gave none, ask before quoting, and always ask the time zone.
41
+ - Weekly: a weekday and a time (`schedule.kind` `weekly`), or on demand. At most
42
+ one scan in seven days.
43
+ - More frequently: every day, every second day or every third day at a time
44
+ (`schedule.kind` `daily`, `everyDays` 1, 2 or 3), or on demand. At most one scan
45
+ a day.
46
+ - On demand: `onDemand` true, keeping the plan's own `kind`, with `minute` and
47
+ `tz`. Nothing runs until the user asks; `runNow` starts each scan.
40
48
  - `schedule <owner/repo>`: `updateSchedule` for that repository with the schedule
41
49
  the user gives; ask for one if they gave none.
42
50
  - `plans`: `getPlans`. `billing`: `getBilling`.
@@ -49,16 +57,16 @@ Sekura: AI red team scans for your GitHub repositories
49
57
 
50
58
  /sekura account and repositories at a glance
51
59
  /sekura repos repositories Sekura can scan
52
- /sekura scan <owner/repo> quote a scan; it starts only after you agree
60
+ /sekura scan <owner/repo> quote a one-time scan; it starts only after you agree
53
61
  /sekura scans your scans and their status
54
62
  /sekura scan-status <scan> one scan's progress
55
63
  /sekura findings <scan> a scan's findings, with proof
56
64
  /sekura report <scan> link to the report
57
65
  /sekura cancel <scan> what cancelling a scan means; cancels only after you agree
58
- /sekura cancel <owner/repo> the same for a repository's Sekura Always plan
59
- /sekura always <owner/repo> quote a recurring Sekura Always plan
60
- /sekura schedule <owner/repo> change when a Sekura Always plan runs
61
- /sekura plans repositories on a recurring plan
66
+ /sekura cancel <owner/repo> the same for a repository's monthly plan
67
+ /sekura monthly <owner/repo> quote a monthly plan: Weekly or More frequently
68
+ /sekura schedule <owner/repo> change when a monthly plan runs
69
+ /sekura plans repositories on a monthly plan
62
70
  /sekura billing what is being billed
63
71
  /sekura help this list
64
72
 
@@ -68,6 +76,7 @@ only after you say yes. Cancelling is shown first too.
68
76
  Setup, in a terminal:
69
77
  npx sekura@latest login sign in again, or pick another repository
70
78
  npx sekura@latest status what is connected on this machine
79
+ npx sekura@latest billing your saved cards (--open to change them)
71
80
 
72
81
  Add repositories: https://sekura.ai/app (the Sekura GitHub App)
73
82
  Documentation: https://sekura.ai/connect/
@@ -80,22 +89,22 @@ The server has eighteen tools. Read, change nothing, no confirmation:
80
89
  - `getAccount`: who is signed in, whether the Terms are accepted and the email verified, where the Sekura GitHub App is installed, and what is billed. Call it first.
81
90
  - `listRepositories`: the repositories the Sekura GitHub App is installed on.
82
91
  - `listScans`, `getScan`, `getScanFindings`, `getReportLink`: scans, their status, their findings and the report.
83
- - `getPlans`, `getBilling`: the repositories on a recurring plan, and a billing summary without card numbers.
92
+ - `getPlans`, `getBilling`: the repositories on a monthly plan, and a billing summary without card numbers.
84
93
 
85
94
  Quote, then confirm. The quote changes nothing and charges nothing:
86
95
 
87
- - `quoteScan` → `startScan`: a Sekura Once scan of one repository.
88
- - `quoteAlways` → `startAlways`: a recurring Sekura Always plan for one repository.
96
+ - `quoteScan` → `startScan`: a one-time scan of one repository.
97
+ - `quoteAlways` → `startAlways`: a monthly plan (Weekly or More frequently) for one repository.
89
98
 
90
99
  Preview, then act. The preview cancels nothing:
91
100
 
92
101
  - `previewCancelScan` → `cancelScan`: stop a scan inside its five-minute window.
93
- - `previewCancelPlan` → `cancelPlan`: end a repository's Sekura Always plan.
102
+ - `previewCancelPlan` → `cancelPlan`: end a repository's monthly plan.
94
103
 
95
104
  One call, charges nothing:
96
105
 
97
- - `updateSchedule`: change when a repository on Sekura Always is scanned.
98
- - `runNow`: bring an Always plan's next scheduled run forward. It is one of the plan's own runs, so there is no quote.
106
+ - `updateSchedule`: change when a repository on a monthly plan is scanned.
107
+ - `runNow`: run a monthly plan's next scan now: brought forward on a schedule, started on demand. It is one of the plan's own runs, so there is no charge. Over the plan's limit it is refused with the first day a scan may start; tell the user that day.
99
108
 
100
109
  ## The two-step rule
101
110
 
@@ -112,11 +121,10 @@ A scan or a plan is never started in one call.
112
121
  authorization wording, and ask whether they agree. Start nothing until they
113
122
  have said yes in the conversation.
114
123
  3. Then call `startScan` or `startAlways` with `confirmArguments` exactly as the
115
- quote returned them, plus the `payment` the user chose from the ways the quote
116
- lists: `{ "savedCard": true }` for the card the quote names, or no payment for
117
- a Stripe Checkout link. Never invent a `disclosureVersion` or an `amountCents`,
118
- never reuse one from an older quote, and never call a confirm before the user
119
- has said yes. A confirm without the `disclosureVersion` is refused.
124
+ quote returned them, plus the `payment` for the way the user chose to pay (see
125
+ Paying, below). Never invent a `disclosureVersion` or an `amountCents`, never
126
+ reuse one from an older quote, and never call a confirm before the user has
127
+ said yes. A confirm without the `disclosureVersion` is refused.
120
128
 
121
129
  If the confirm is refused because the wording or the price changed, the answer
122
130
  carries a fresh quote: show that one to the user and ask again.
@@ -129,13 +137,53 @@ they agree.
129
137
  `updateSchedule` and `runNow` take one call each and charge nothing; call them
130
138
  only when the user has asked for that change.
131
139
 
132
- A card is charged only after the user approves the quoted amount. If no card is
133
- used, the answer carries a Stripe Checkout link: give it to the user as it is
134
- and stop; the scan or plan starts once they have paid on sekura.ai.
140
+ ## Paying
141
+
142
+ The quote's `paymentOptions` are the only ways to pay. Show them to the user as a
143
+ numbered list, each by its `label`, in the quote's order, and ask which one they
144
+ want together with whether they agree:
145
+
146
+ - With saved cards: one line per card, masked as the quote gives it (for example
147
+ `Visa •••• •••• •••• 4242`), then `Pay with a Checkout link`, then
148
+ `Change payment method`. Never show more of a card than the quote does.
149
+ - With no saved card: only `Pay with a Checkout link`. The first payment is
150
+ always made in the browser, and the card used there is saved for next time.
151
+
152
+ Then:
153
+
154
+ - **A saved card**: call the confirm with that option's `payment`, which is
155
+ `{ "savedCard": { "card": "pm_…" } }` with the card the user picked. Only that
156
+ card is charged, in place, with no browser. Relay the answer: what was charged
157
+ to which card ("Charged $10 to Visa ending 4242"), the scan id and the link.
158
+ - **Pay with a Checkout link**: call the confirm with no `payment`. It answers 402
159
+ with `checkoutUrl` and `planId`. Run, in the terminal, with a timeout of ten
160
+ minutes:
161
+
162
+ ```
163
+ npx sekura@latest pay "<checkoutUrl>" --plan <planId>
164
+ ```
165
+
166
+ It opens the link in the user's browser (where they are signed in to Sekura)
167
+ and waits until the payment lands, then prints the scan id and link, or that
168
+ Checkout was closed unpaid. Tell the user the page is open and you are
169
+ waiting, then relay what it printed. If the command cannot run here, give the
170
+ user the link to open, and once they say they have paid, call `getPlans` and
171
+ report the plan and its scan.
172
+ - **Change payment method**: starts and charges nothing. Run
173
+ `npx sekura@latest billing --open`, which opens the page where the user adds
174
+ or changes a card and waits for the change. Then call the quote again and show
175
+ its updated list of cards, and ask again.
176
+
177
+ Nothing is charged without a quote and the user's yes, and only the card the user
178
+ picked is charged.
135
179
 
136
180
  ## What to tell the user
137
181
 
138
- - Through this connection a scan is Sekura Once at the quoted price. Do not mention or offer any free scan.
182
+ - Through this connection a scan is a one-time scan at the quoted price. Do not mention or offer any free scan.
183
+ - The plans a user can buy here: a one-time scan ($10), or a monthly plan for
184
+ one repository, Weekly ($10 a month per repository) or More frequently ($25 a
185
+ month per repository). The quote's price is the one that counts. There is no
186
+ trial. Enterprise is quoted by Sekura: give no price or plan name for it.
139
187
  - When `getAccount` says the Terms or the email are not done, or the GitHub App is not installed, give the user the sekura.ai link it names; a scan cannot start before that.
140
188
  - A scan can take a while. Offer `getScan` to check on it rather than polling in a loop.
141
189
  - Findings carry proof. When summarising, keep the evidence the finding gives; do not soften a severity.