affitor 0.4.5 → 0.4.7

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.
@@ -0,0 +1,172 @@
1
+ import { applySetup, credentialWarnings, readPlannedAgentCredential, stageAgentCredential } from "./agent-setup.js";
2
+ export class AgentSetupError extends Error {
3
+ cleanupIds;
4
+ uncertainMint;
5
+ constructor(message, cleanupIds = [], uncertainMint = false) {
6
+ super(message);
7
+ this.cleanupIds = cleanupIds;
8
+ this.uncertainMint = uncertainMint;
9
+ }
10
+ }
11
+ const positive = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
12
+ function object(value) { return !!value && typeof value === "object" && !Array.isArray(value); }
13
+ function rootOrigin(value) {
14
+ const url = new URL(value);
15
+ if (url.username || url.password || url.search || url.hash || url.pathname !== "/" || !["https:", "http:"].includes(url.protocol))
16
+ throw new Error();
17
+ return url;
18
+ }
19
+ export function agentApiOrigin(value) {
20
+ try {
21
+ const url = rootOrigin(value);
22
+ if (url.origin === "https://api.affitor.com")
23
+ return url.origin;
24
+ const development = process.env.AFFITOR_AGENT_DEV_API_ORIGIN;
25
+ if (development && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) && rootOrigin(development).origin === url.origin)
26
+ return url.origin;
27
+ throw new Error();
28
+ }
29
+ catch {
30
+ throw new AgentSetupError("Agent setup sends login credentials only to https://api.affitor.com. Local development requires AFFITOR_AGENT_DEV_API_ORIGIN to match the exact loopback API origin.");
31
+ }
32
+ }
33
+ /** User JWT only. Mint is never retried: a lost response may already have created a row. */
34
+ export class ProgramAgentClient {
35
+ token;
36
+ origin;
37
+ constructor(token, origin) {
38
+ this.token = token;
39
+ this.origin = agentApiOrigin(origin);
40
+ if (!token || /^aff_|^agt_/.test(token))
41
+ throw new AgentSetupError("Sign in with affitor login before creating agent keys.");
42
+ }
43
+ async request(path, method = "GET", body) {
44
+ try {
45
+ const response = await fetch(this.origin + path, {
46
+ method, redirect: "error", signal: AbortSignal.timeout(15_000),
47
+ headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json" },
48
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
49
+ });
50
+ if (!response.ok)
51
+ throw new AgentSetupError(`Agent key request failed (HTTP ${response.status}). Check login, Owner access and the CMS release.`, [], method === "POST" && response.status >= 500);
52
+ try {
53
+ return await response.json();
54
+ }
55
+ catch {
56
+ throw new AgentSetupError("Agent key response could not be read.", [], method === "POST");
57
+ }
58
+ }
59
+ catch (error) {
60
+ if (error instanceof AgentSetupError)
61
+ throw error;
62
+ throw new AgentSetupError("Agent key request did not complete. Check the API origin and connection.", [], method === "POST");
63
+ }
64
+ }
65
+ async programs() {
66
+ const result = await this.request("/api/v1/cli/programs");
67
+ const rows = object(result) ? result.data : null;
68
+ if (!Array.isArray(rows) || rows.some(row => !object(row) || !positive(row.id) || typeof row.name !== "string"))
69
+ throw new AgentSetupError("Program list response is invalid.");
70
+ return rows.map(row => ({ id: row.id, name: row.name.slice(0, 160).replace(/[\x00-\x1f\x7f]/g, "") }));
71
+ }
72
+ async list(programId) {
73
+ const rows = [];
74
+ let before = null;
75
+ for (let page = 0; page < 100; page++) {
76
+ const result = await this.request(`/api/v1/programs/${programId}/agents${before ? `?before=${before}` : ""}`);
77
+ if (!object(result) || !Array.isArray(result.data) || result.data.length > 100 || !object(result.meta))
78
+ throw new AgentSetupError("Agent key list response is invalid.");
79
+ for (const row of result.data) {
80
+ if (!object(row) || !positive(row.id) || typeof row.client !== "string" || typeof row.key_hint !== "string" || typeof row.status !== "string" || !["waiting", "connected", "verified", "failing", "revoked"].includes(row.status))
81
+ throw new AgentSetupError("Agent key list response is invalid.");
82
+ rows.push({ id: row.id, client: row.client, key_hint: row.key_hint, status: row.status, revoked_at: typeof row.revoked_at === "string" ? row.revoked_at : null });
83
+ }
84
+ const next = result.meta.next_cursor;
85
+ if (next === null)
86
+ return rows;
87
+ if (!positive(next) || (before !== null && next >= before))
88
+ throw new AgentSetupError("Agent key pagination is invalid.");
89
+ before = next;
90
+ }
91
+ throw new AgentSetupError("Agent key list is too large. Review credentials in the dashboard before retrying.");
92
+ }
93
+ async mint(programId, client) {
94
+ const result = await this.request(`/api/v1/programs/${programId}/agents`, "POST", { name: client, client });
95
+ const row = object(result) && object(result.data) ? result.data : null;
96
+ if (!row || !positive(row.id) || row.client !== client || typeof row.api_key !== "string" || !/^aff_ag_[A-Za-z0-9_-]{43}$/.test(row.api_key)) {
97
+ throw new AgentSetupError("Agent mint response is invalid. Review Waiting agents in the dashboard.", row && positive(row.id) ? [row.id] : [], !(row && positive(row.id)));
98
+ }
99
+ const created = new Date().toISOString();
100
+ return { version: 1, id: row.id, program_id: programId, client, api_url: this.origin, created_at: created,
101
+ credential_note: `Signed-in account; program ${programId}; ${client}; readiness/status/synthetic-test/click/test-only lead; created ${created}; not verified. Never commit this file.`,
102
+ api_key: row.api_key };
103
+ }
104
+ async revoke(programId, id) {
105
+ const result = await this.request(`/api/v1/programs/${programId}/agents/${id}`, "DELETE");
106
+ if (!object(result) || !object(result.data) || result.data.revoked !== true)
107
+ throw new AgentSetupError("Agent revocation could not be confirmed.");
108
+ }
109
+ }
110
+ /** Prepare every client before local writes; compensate only keys minted by this run. */
111
+ export async function installProgramAgents(plan, programId, api, apply = applySetup) {
112
+ if (!positive(programId) || !plan.agentKeys || plan.agentKeys.length !== plan.clients.length)
113
+ throw new AgentSetupError("Generate a fresh agent-key setup plan.");
114
+ const existing = plan.clients.map(client => {
115
+ const warnings = credentialWarnings(plan.project, `.affitor/agents/${client}.json`);
116
+ if (warnings.includes("credential_tracked"))
117
+ throw new AgentSetupError("A private agent credential is tracked by Git. Rotate it and resolve tracking/history before setup.");
118
+ if (warnings.length)
119
+ throw new AgentSetupError("Git credential tracking could not be checked. Resolve Git access and retry; no agent key was minted or files written.");
120
+ const record = readPlannedAgentCredential(plan, client);
121
+ if (record && (record.program_id !== programId || record.api_url !== api.origin))
122
+ throw new AgentSetupError("A selected agent belongs to another program or API origin. Revoke and remove that private credential before switching.");
123
+ return { client, record };
124
+ });
125
+ // Only owner list reads: never call readiness/status to pretend a client connected.
126
+ const rows = await api.list(programId), minted = [], replaced = [];
127
+ try {
128
+ for (const { client, record } of existing) {
129
+ const row = record && rows.find(row => row.id === record.id && row.client === client);
130
+ const active = row && row.status !== "revoked" && !row.revoked_at;
131
+ const reusable = record && active && row.key_hint === `aff_ag_…${record.api_key.slice(-4)}`;
132
+ const credential = reusable ? record : await api.mint(programId, client);
133
+ if (!reusable)
134
+ minted.push(credential.id);
135
+ if (record && active && !reusable)
136
+ replaced.push(record.id);
137
+ stageAgentCredential(plan, client, credential, !reusable);
138
+ }
139
+ apply(plan);
140
+ }
141
+ catch (error) {
142
+ const known = [...new Set([...minted, ...(error instanceof AgentSetupError ? error.cleanupIds : [])])];
143
+ const failed = [];
144
+ for (const id of known) {
145
+ try {
146
+ await api.revoke(programId, id);
147
+ }
148
+ catch {
149
+ failed.push(id);
150
+ }
151
+ }
152
+ const uncertain = error instanceof AgentSetupError && error.uncertainMint;
153
+ throw new AgentSetupError(uncertain || failed.length
154
+ ? "Setup did not finish. Review Waiting agents in the dashboard and revoke unused credentials before retrying. Local files/private backups may need recovery."
155
+ : "Setup did not finish; newly minted credentials were revoked. Check local files/private backups before retrying.", failed, uncertain);
156
+ }
157
+ // Local installation has committed. Failure to retire an old key must not
158
+ // compensate the new credentials that the client now uses.
159
+ const failed = [];
160
+ for (const id of new Set(replaced)) {
161
+ try {
162
+ await api.revoke(programId, id);
163
+ }
164
+ catch {
165
+ failed.push(id);
166
+ }
167
+ }
168
+ if (failed.length)
169
+ throw new AgentSetupError("New agent credentials were installed, but previous keys could not be confirmed revoked. Review the reported old key ids in Settings → Agents before retrying.", failed);
170
+ return plan.agentKeys.map(({ client, path, id, state }) => ({ client, path, id, state }));
171
+ }
172
+ //# sourceMappingURL=program-agent-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program-agent-client.js","sourceRoot":"","sources":["../../src/lib/program-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YAAY,eAAe,IAAI,KAAK,CAAC,aAAa,CAAC;QAC1E,MAAM,IAAI,eAAe,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM;YAClD,CAAC,CAAC,4JAA4J;YAC9J,CAAC,CAAC,iHAAiH,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5I,CAAC;IACD,0EAA0E;IAC1E,2DAA2D;IAC3D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,EAAE,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAAC,IAAI,CAAC;YAAC,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAAC,CAAC;IAAC,CAAC;IAC3G,IAAI,MAAM,CAAC,MAAM;QAAE,MAAM,IAAI,eAAe,CAAC,+JAA+J,EAAE,MAAM,CAAC,CAAC;IACtN,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AAC5F,CAAC"}
@@ -63,7 +63,7 @@ export async function promptDurationMonths() {
63
63
  export async function promptCookieDuration() {
64
64
  return input({
65
65
  message: "Cookie duration (days):",
66
- default: "90",
66
+ default: "60",
67
67
  validate: (v) => {
68
68
  const n = parseInt(v, 10);
69
69
  if (isNaN(n) || n < 1)
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "affitor",
3
- "version": "0.4.5",
4
- "description": "CLI-native affiliate tracking. Connect Stripe, track commissions, manage partners \u2014 all from your terminal.",
3
+ "version": "0.4.7",
4
+ "description": "CLI-native affiliate tracking. Connect Stripe, track commissions, manage partners — all from your terminal.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "affitor": "./dist/cli.js"
7
+ "affitor": "dist/cli.js"
8
8
  },
9
9
  "scripts": {
10
10
  "build": "tsc",
@@ -30,7 +30,7 @@
30
30
  "license": "MIT",
31
31
  "repository": {
32
32
  "type": "git",
33
- "url": "https://github.com/Affitor/cli"
33
+ "url": "git+https://github.com/Affitor/cli.git"
34
34
  },
35
35
  "homepage": "https://affitor.com",
36
36
  "engines": {