@tapflowio/relay 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/RelayServer.d.ts.map +1 -1
  2. package/dist/RelayServer.js +6 -0
  3. package/dist/RelayServer.js.map +1 -1
  4. package/dist/api/builds.d.ts +19 -3
  5. package/dist/api/builds.d.ts.map +1 -1
  6. package/dist/api/builds.js +232 -43
  7. package/dist/api/builds.js.map +1 -1
  8. package/dist/api/webhooks.d.ts +6 -0
  9. package/dist/api/webhooks.d.ts.map +1 -0
  10. package/dist/api/webhooks.js +72 -0
  11. package/dist/api/webhooks.js.map +1 -0
  12. package/dist/lib/config.d.ts +11 -0
  13. package/dist/lib/config.d.ts.map +1 -1
  14. package/dist/lib/config.js +47 -0
  15. package/dist/lib/config.js.map +1 -1
  16. package/dist/lib/webhookUrl.d.ts +11 -0
  17. package/dist/lib/webhookUrl.d.ts.map +1 -0
  18. package/dist/lib/webhookUrl.js +40 -0
  19. package/dist/lib/webhookUrl.js.map +1 -0
  20. package/dist/lib/webhooks.d.ts +33 -0
  21. package/dist/lib/webhooks.d.ts.map +1 -0
  22. package/dist/lib/webhooks.js +54 -0
  23. package/dist/lib/webhooks.js.map +1 -0
  24. package/dist/migrations/013_webhook_endpoints.sql +13 -0
  25. package/package.json +2 -2
  26. package/public/assets/AppCenter-DbFf7BKA.js +21 -0
  27. package/public/assets/AppCenter-DbFf7BKA.js.br +0 -0
  28. package/public/assets/{Default-iwN63mvx.js → Default-BXiTKHz2.js} +1 -1
  29. package/public/assets/Default-BXiTKHz2.js.br +0 -0
  30. package/public/assets/{Invite-KgNlAGmi.js → Invite-Dw4wdx9j.js} +1 -1
  31. package/public/assets/Invite-Dw4wdx9j.js.br +0 -0
  32. package/public/assets/{MacResources-DeoMc2P5.js → MacResources-D-j1pG9s.js} +1 -1
  33. package/public/assets/MacResources-D-j1pG9s.js.br +0 -0
  34. package/public/assets/{NotFound-DXxeYVTc.js → NotFound-BwAREUV8.js} +1 -1
  35. package/public/assets/NotFound-BwAREUV8.js.br +2 -0
  36. package/public/assets/{QASession-D7Jq7r4v.js → QASession-Du5LOUTZ.js} +1 -1
  37. package/public/assets/QASession-Du5LOUTZ.js.br +0 -0
  38. package/public/assets/{ResetPassword-jaM2ctjM.js → ResetPassword-C6cya_7-.js} +1 -1
  39. package/public/assets/ResetPassword-C6cya_7-.js.br +0 -0
  40. package/public/assets/{Setup-mmxbjJ83.js → Setup-DHS2ZvMu.js} +1 -1
  41. package/public/assets/Setup-DHS2ZvMu.js.br +0 -0
  42. package/public/assets/{Team-C_u-hG_S.js → Team-DkIXb37o.js} +1 -1
  43. package/public/assets/Team-DkIXb37o.js.br +0 -0
  44. package/public/assets/{Tokens-Dkd2LkfB.js → Tokens-DxZUmUPI.js} +1 -1
  45. package/public/assets/Tokens-DxZUmUPI.js.br +0 -0
  46. package/public/assets/{alert-dialog-CFyLEW41.js → alert-dialog-CPQLr1ij.js} +1 -1
  47. package/public/assets/alert-dialog-CPQLr1ij.js.br +0 -0
  48. package/public/assets/{badge-D6kZI81S.js → badge-B63ynAZJ.js} +1 -1
  49. package/public/assets/badge-B63ynAZJ.js.br +0 -0
  50. package/public/assets/{build-format-Ff9JwBl0.js → build-format-CcGvUI_j.js} +1 -1
  51. package/public/assets/build-format-CcGvUI_j.js.br +0 -0
  52. package/public/assets/{dialog-BZAnuIhx.js → dialog-CEEdc-Oq.js} +1 -1
  53. package/public/assets/dialog-CEEdc-Oq.js.br +0 -0
  54. package/public/assets/{index-nsRC4db_.js → index-D8ViYmeP.js} +2 -2
  55. package/public/assets/index-D8ViYmeP.js.br +0 -0
  56. package/public/assets/{pencil-sNgkZjUH.js → pencil-BAhJ8VF-.js} +1 -1
  57. package/public/assets/pencil-BAhJ8VF-.js.br +0 -0
  58. package/public/assets/{table-CRY1fpd-.js → table-IfQacRqI.js} +1 -1
  59. package/public/assets/table-IfQacRqI.js.br +0 -0
  60. package/public/assets/{tabs-C6bzsSdg.js → tabs-DKQ2XF1o.js} +1 -1
  61. package/public/assets/tabs-DKQ2XF1o.js.br +0 -0
  62. package/public/assets/{trash-2-nLbk3HF-.js → trash-2-Bfw6hch4.js} +1 -1
  63. package/public/assets/trash-2-Bfw6hch4.js.br +0 -0
  64. package/public/index.html +1 -1
  65. package/public/index.html.br +0 -0
  66. package/public/assets/AppCenter-DXghiZpr.js +0 -21
  67. package/public/assets/AppCenter-DXghiZpr.js.br +0 -0
  68. package/public/assets/Default-iwN63mvx.js.br +0 -0
  69. package/public/assets/Invite-KgNlAGmi.js.br +0 -0
  70. package/public/assets/MacResources-DeoMc2P5.js.br +0 -0
  71. package/public/assets/NotFound-DXxeYVTc.js.br +0 -2
  72. package/public/assets/QASession-D7Jq7r4v.js.br +0 -0
  73. package/public/assets/ResetPassword-jaM2ctjM.js.br +0 -0
  74. package/public/assets/Setup-mmxbjJ83.js.br +0 -0
  75. package/public/assets/Team-C_u-hG_S.js.br +0 -0
  76. package/public/assets/Tokens-Dkd2LkfB.js.br +0 -0
  77. package/public/assets/alert-dialog-CFyLEW41.js.br +0 -0
  78. package/public/assets/badge-D6kZI81S.js.br +0 -0
  79. package/public/assets/build-format-Ff9JwBl0.js.br +0 -0
  80. package/public/assets/dialog-BZAnuIhx.js.br +0 -0
  81. package/public/assets/index-nsRC4db_.js.br +0 -0
  82. package/public/assets/pencil-sNgkZjUH.js.br +0 -0
  83. package/public/assets/table-CRY1fpd-.js.br +0 -0
  84. package/public/assets/tabs-C6bzsSdg.js.br +0 -0
  85. package/public/assets/trash-2-nLbk3HF-.js.br +0 -0
@@ -6,6 +6,7 @@ import { createLogger } from '@tapflowio/agent-core';
6
6
  import { parseTrustedProxies } from './clientAddress.js';
7
7
  import { dnsProviders } from './cert/dnsRegistry.js';
8
8
  import { loadDataDirEnv } from './loadEnvFile.js';
9
+ import { validateWebhookUrl } from './webhookUrl.js';
9
10
  const logger = createLogger('relay:config');
10
11
  const tunnelSshSchema = z.object({
11
12
  host: z.string().min(1),
@@ -63,6 +64,13 @@ const configSchema = z.object({
63
64
  pass: z.string(),
64
65
  from: z.string(),
65
66
  }),
67
+ // Declarative outbound webhook endpoints. secret is resolved from an env var
68
+ // (secretEnv in the file) — secrets never live in config.json.
69
+ webhooks: z.array(z.object({
70
+ url: z.string().min(1),
71
+ secret: z.string(),
72
+ enabled: z.boolean(),
73
+ })),
66
74
  });
67
75
  const DEFAULTS = {
68
76
  local: {
@@ -84,10 +92,48 @@ const DEFAULTS = {
84
92
  pass: '',
85
93
  from: 'tapflow <noreply@tapflow.local>',
86
94
  },
95
+ webhooks: [],
87
96
  };
88
97
  function resolveDataDir(raw) {
89
98
  return path.isAbsolute(raw) ? raw : path.join(process.cwd(), raw);
90
99
  }
100
+ const rawWebhookEntrySchema = z.array(z.object({
101
+ url: z.string().optional(),
102
+ secretEnv: z.string().optional(),
103
+ enabled: z.boolean().optional(),
104
+ }));
105
+ // Map raw config.json webhook entries ({ url, secretEnv?, enabled? }) to resolved
106
+ // endpoints. The signing secret is read from the named env var, never from the file.
107
+ // Entries are dropped (with a warning) when they have no url or fail the SSRF/format
108
+ // gate, so config-file endpoints run under the same checks as REST-registered ones.
109
+ export function resolveWebhooksConfig(raw, env) {
110
+ if (raw === undefined)
111
+ return [];
112
+ const parsed = rawWebhookEntrySchema.safeParse(raw);
113
+ if (!parsed.success) {
114
+ logger.warn('webhooks in tapflow.config.json is malformed — ignoring');
115
+ return [];
116
+ }
117
+ const out = [];
118
+ for (const w of parsed.data) {
119
+ if (!w.url)
120
+ continue;
121
+ const err = validateWebhookUrl(w.url);
122
+ if (err) {
123
+ logger.warn(`ignoring config webhook ${w.url}: ${err}`);
124
+ continue;
125
+ }
126
+ if (w.secretEnv && !env[w.secretEnv]) {
127
+ logger.warn(`config webhook ${w.url}: secretEnv ${w.secretEnv} is not set — deliveries will be unsigned`);
128
+ }
129
+ out.push({
130
+ url: w.url,
131
+ secret: w.secretEnv ? (env[w.secretEnv] ?? '') : '',
132
+ enabled: w.enabled !== false,
133
+ });
134
+ }
135
+ return out;
136
+ }
91
137
  // Populated by load(): path of the dataDir/.env that was loaded, or null. CLI/server use it for a "loaded credentials" log.
92
138
  export let loadedEnvPath = null;
93
139
  function load() {
@@ -162,6 +208,7 @@ function load() {
162
208
  pass: file.smtp?.pass ?? DEFAULTS.smtp.pass,
163
209
  from: file.smtp?.from ?? DEFAULTS.smtp.from,
164
210
  },
211
+ webhooks: resolveWebhooksConfig(file.webhooks, process.env),
165
212
  };
166
213
  if (process.env.TAPFLOW_PORT)
167
214
  cfg.local.port = Number(process.env.TAPFLOW_PORT);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAA;AAE3C,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA;AAEF,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,QAAQ,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AAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACrD,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,qDAAqD;IACvD,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,yCAAyC,UAAU,+BAA+B,CAAC,CAAA;IAC/F,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAA;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAA;IAC/B,CAAC;IACD,OAAO,2BAA2B,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;AAC1D,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,EAAE,CAAA;AAC5B,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Validate a webhook destination URL. Returns an error string, or null when allowed.
3
+ * Blocks loopback and cloud-metadata addresses; private LAN ranges (10/172.16/192.168)
4
+ * are intentionally allowed because self-hosted CI often lives there.
5
+ *
6
+ * Lives in its own module so both webhooks.ts (delivery) and config.ts (config-file
7
+ * endpoints) can validate without a circular import — webhooks.ts imports config.ts,
8
+ * so config.ts can't import back into webhooks.ts.
9
+ */
10
+ export declare function validateWebhookUrl(raw: string): string | null;
11
+ //# sourceMappingURL=webhookUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhookUrl.d.ts","sourceRoot":"","sources":["../../src/lib/webhookUrl.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA8B7D"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Validate a webhook destination URL. Returns an error string, or null when allowed.
3
+ * Blocks loopback and cloud-metadata addresses; private LAN ranges (10/172.16/192.168)
4
+ * are intentionally allowed because self-hosted CI often lives there.
5
+ *
6
+ * Lives in its own module so both webhooks.ts (delivery) and config.ts (config-file
7
+ * endpoints) can validate without a circular import — webhooks.ts imports config.ts,
8
+ * so config.ts can't import back into webhooks.ts.
9
+ */
10
+ export function validateWebhookUrl(raw) {
11
+ let u;
12
+ try {
13
+ u = new URL(raw);
14
+ }
15
+ catch {
16
+ return 'Invalid URL';
17
+ }
18
+ if (u.protocol !== 'http:' && u.protocol !== 'https:') {
19
+ return 'URL must use http or https';
20
+ }
21
+ let host = u.hostname.toLowerCase().replace(/^\[|\]$/g, ''); // strip IPv6 brackets
22
+ // Node normalizes an IPv4-mapped IPv6 host (e.g. ::ffff:127.0.0.1) to a hex form
23
+ // like ::ffff:7f00:1, which would slip past the IPv4 checks below yet still connect
24
+ // to the embedded IPv4 — an SSRF bypass. Unwrap it back to dotted IPv4 first.
25
+ const mapped = host.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);
26
+ if (mapped) {
27
+ const hi = parseInt(mapped[1], 16);
28
+ const lo = parseInt(mapped[2], 16);
29
+ host = [hi >> 8, hi & 0xff, lo >> 8, lo & 0xff].join('.');
30
+ }
31
+ if (host === 'localhost' ||
32
+ host === '0.0.0.0' ||
33
+ host === '::1' ||
34
+ host.startsWith('127.') ||
35
+ host.startsWith('169.254.')) {
36
+ return 'URL host is not allowed (loopback or metadata address)';
37
+ }
38
+ return null;
39
+ }
40
+ //# sourceMappingURL=webhookUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webh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,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,33 @@
1
+ export { validateWebhookUrl } from './webhookUrl.js';
2
+ export declare const WEBHOOK_TIMEOUT_MS = 5000;
3
+ export interface WebhookPayload {
4
+ event: string;
5
+ build: {
6
+ id: string;
7
+ platform: string | null;
8
+ appVersion: string | null;
9
+ status: string;
10
+ };
11
+ changedAt: string;
12
+ }
13
+ export type FetchLike = (url: string, init: {
14
+ method: string;
15
+ headers: Record<string, string>;
16
+ body: string;
17
+ signal: AbortSignal;
18
+ }) => Promise<{
19
+ ok: boolean;
20
+ status: number;
21
+ text: () => Promise<string>;
22
+ }>;
23
+ /** HMAC-SHA256 signature of the raw request body, formatted like EAS's expo-signature. */
24
+ export declare function signPayload(secret: string, body: string): string;
25
+ /**
26
+ * Deliver a payload to every enabled webhook endpoint. Best-effort: a failed or slow
27
+ * endpoint is logged and never throws to the caller (callers fire-and-forget so the
28
+ * originating request is unaffected). One endpoint's failure does not stop the others.
29
+ */
30
+ export declare function deliverWebhooks(payload: WebhookPayload, opts?: {
31
+ fetchFn?: FetchLike;
32
+ }): Promise<void>;
33
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/lib/webhooks.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAKpD,eAAO,MAAM,kBAAkB,OAAO,CAAA;AAEtC,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE;QACL,EAAE,EAAE,MAAM,CAAA;QACV,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;QACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QACzB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;CAClB;AAGD,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,KACzF,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAAA;AAE1E,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhE;AAOD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,cAAc,EACvB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,SAAS,CAAA;CAAO,GACjC,OAAO,CAAC,IAAI,CAAC,CAiCf"}
@@ -0,0 +1,54 @@
1
+ import crypto from 'crypto';
2
+ import { createLogger } from '@tapflowio/agent-core';
3
+ import { getDb } from '../db.js';
4
+ import { config } from './config.js';
5
+ // Re-exported so existing importers keep using webhooks.ts; the implementation lives
6
+ // in webhookUrl.ts to avoid a circular import with config.ts (which also validates).
7
+ export { validateWebhookUrl } from './webhookUrl.js';
8
+ const logger = createLogger('relay:webhooks');
9
+ // Each outbound request is bounded so a slow receiver can't tie up delivery.
10
+ export const WEBHOOK_TIMEOUT_MS = 5000;
11
+ /** HMAC-SHA256 signature of the raw request body, formatted like EAS's expo-signature. */
12
+ export function signPayload(secret, body) {
13
+ return 'sha256=' + crypto.createHmac('sha256', secret).update(body).digest('hex');
14
+ }
15
+ /**
16
+ * Deliver a payload to every enabled webhook endpoint. Best-effort: a failed or slow
17
+ * endpoint is logged and never throws to the caller (callers fire-and-forget so the
18
+ * originating request is unaffected). One endpoint's failure does not stop the others.
19
+ */
20
+ export async function deliverWebhooks(payload, opts = {}) {
21
+ const dbRows = getDb()
22
+ .prepare('SELECT url, secret FROM webhook_endpoints WHERE enabled = 1')
23
+ .all();
24
+ // Declarative config.json endpoints are delivered alongside the DB-registered ones.
25
+ const configRows = config.webhooks
26
+ .filter((w) => w.enabled)
27
+ .map((w) => ({ url: w.url, secret: w.secret || null }));
28
+ const rows = [...configRows, ...dbRows];
29
+ if (rows.length === 0)
30
+ return;
31
+ const body = JSON.stringify(payload);
32
+ const fetchFn = opts.fetchFn ?? globalThis.fetch;
33
+ await Promise.allSettled(rows.map(async (ep) => {
34
+ const headers = { 'Content-Type': 'application/json' };
35
+ if (ep.secret)
36
+ headers['X-Tapflow-Signature'] = signPayload(ep.secret, body);
37
+ try {
38
+ const res = await fetchFn(ep.url, {
39
+ method: 'POST',
40
+ headers,
41
+ body,
42
+ signal: AbortSignal.timeout(WEBHOOK_TIMEOUT_MS),
43
+ });
44
+ // Drain the body so undici releases the connection back to the pool.
45
+ await res.text();
46
+ if (!res.ok)
47
+ logger.warn(`webhook POST ${ep.url} returned ${res.status}`);
48
+ }
49
+ catch (err) {
50
+ logger.warn(`webhook POST ${ep.url} failed: ${String(err)}`);
51
+ }
52
+ }));
53
+ }
54
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/lib/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,qFAAqF;AACrF,qFAAqF;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAA;AAE7C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAmBtC,0FAA0F;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CAAC;YACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI;gBACJ,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC;aAChD,CAAC,CAAA;YACF,qEAAqE;YACrE,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;YAChB,IAAI,CAAC,GAAG,CAAC,EAAE;gBAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,GAAG,aAAa,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,GAAG,YAAY,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ -- 013_webhook_endpoints.sql
2
+ -- Outbound webhooks: notify registered URLs when a build's review status
3
+ -- transitions to Done/Rejected. Payload carries metadata only (build id, status,
4
+ -- platform, version) — never app binaries or screen data (see AGENTS.md).
5
+ -- secret is optional; when set, deliveries are HMAC-SHA256 signed.
6
+
7
+ CREATE TABLE webhook_endpoints (
8
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
9
+ url TEXT NOT NULL,
10
+ secret TEXT,
11
+ enabled INTEGER NOT NULL DEFAULT 1,
12
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
13
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapflowio/relay",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "WebSocket relay server for tapflow — NAT traversal, session routing, JWT auth, bundled dashboard",
5
5
  "keywords": [
6
6
  "tapflow",
@@ -52,7 +52,7 @@
52
52
  "nodemailer": "^9.0.3",
53
53
  "ws": "^8.21.0",
54
54
  "zod": "^4.4.3",
55
- "@tapflowio/agent-core": "0.11.1"
55
+ "@tapflowio/agent-core": "0.13.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/better-sqlite3": "^7.6.13",
@@ -0,0 +1,21 @@
1
+ import{Y as C,a7 as r,a4 as e,B as y,L as b,a9 as k,K as G,I as M,S as K,g as Q,al as J,am as W}from"./index-D8ViYmeP.js";import{e as X,S as ee,P as se,g as ae,h as te,i as le,b as ne,d as re,s as ce,u as ie}from"./build-format-CcGvUI_j.js";import{D as O,f as L,a as U,d as E,e as V,S as A,i as _,j as B,g as z,h as i,C as oe}from"./dialog-CEEdc-Oq.js";import{P as de,T as ue}from"./trash-2-Bfw6hch4.js";import{B as T}from"./badge-B63ynAZJ.js";import{A as he,c as xe,f as pe,g as me,d as fe,e as ge,b as je,a as ve}from"./alert-dialog-CPQLr1ij.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ne=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Se=C("layers",Ne);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ye=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],we=C("package",ye);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const be=[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]],ke=C("timer-off",be);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const De=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Ce=C("upload",De);function Ae({onSuccess:s,appId:l}){const[h,c]=r.useState(!1),[t,g]=r.useState(null),[o,x]=r.useState("none"),j=r.useRef(null);function p(n){if(n.preventDefault(),!t)return;const d=new FormData;d.append("file",t),o!=="none"&&d.append("status",o),l&&d.append("app_id",String(l));const w=fetch("/api/v1/builds",{method:"POST",credentials:"include",body:d}).then(async u=>{if(!u.ok){const m=await u.json().catch(()=>({}));throw new Error(m.error??"Upload failed. Check the file format.")}s()});k.promise(w,{loading:"Uploading build…",success:"Build uploaded",error:u=>u instanceof Error?u.message:"Failed to upload build"}),c(!1),g(null),x("none")}function N(n){c(n),n||(g(null),x("none"))}return e.jsxs(O,{open:h,onOpenChange:N,children:[e.jsx(L,{asChild:!0,children:e.jsxs(y,{size:"sm",children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),"Upload build"]})}),e.jsxs(U,{className:"sm:max-w-md",children:[e.jsx(E,{children:e.jsx(V,{children:"Upload build"})}),e.jsxs("form",{onSubmit:p,className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(b,{children:"File"}),e.jsx("div",{className:"flex h-24 cursor-pointer items-center justify-center rounded-md border-2 border-dashed text-sm text-muted-foreground hover:border-primary",onClick:()=>{var n;return(n=j.current)==null?void 0:n.click()},onDragOver:n=>n.preventDefault(),onDrop:n=>{n.preventDefault();const d=n.dataTransfer.files[0];d&&g(d)},children:t?t.name:"Click or drag to upload"}),e.jsx("input",{ref:j,type:"file",accept:".zip,.apk,.tgz,.tar.gz,application/gzip,application/x-gzip",className:"hidden",onChange:n=>{var d;return g(((d=n.target.files)==null?void 0:d[0])??null)}}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["iOS: ",e.jsx("code",{children:".app.zip"})," or ",e.jsx("code",{children:".tar.gz"})," / ",e.jsx("code",{children:".tgz"})," (e.g. an EAS simulator build)  · Android: ",e.jsx("code",{children:".apk"})]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(b,{children:["Status ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsxs(A,{value:o,onValueChange:x,children:[e.jsx(_,{children:e.jsx(B,{})}),e.jsxs(z,{children:[e.jsx(i,{value:"none",children:"None"}),e.jsx(i,{value:"Backlog",children:"Backlog"}),e.jsx(i,{value:"In Progress",children:"In Progress"}),e.jsx(i,{value:"Done",children:"Done"}),e.jsx(i,{value:"Rejected",children:"Rejected"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(y,{type:"button",variant:"outline",className:"w-24",onClick:()=>c(!1),children:"Cancel"}),e.jsx(y,{type:"submit",className:"w-24",disabled:!t,children:"Upload"})]})]})]})]})}function D({className:s,...l}){return e.jsx("span",{className:G("font-mono text-xs tabular-nums tracking-tight",s),...l})}function _e({onSuccess:s}){const[l,h]=r.useState(!1),[c,t]=r.useState(""),[g,o]=r.useState(""),[x,j]=r.useState("ios"),[p,N]=r.useState(""),[n,d]=r.useState(!1);async function w(u){u.preventDefault(),N(""),d(!0);try{const m=await X({name:c.trim(),bundle_id_key:g.trim(),platform:x});if(!m){N("Failed to create app");return}if("error"in m){N(m.error);return}h(!1),t(""),o(""),j("ios"),k.success("App created"),s()}catch{k.error("Failed to create app — check your network")}finally{d(!1)}}return e.jsxs(O,{open:l,onOpenChange:h,children:[e.jsx(L,{asChild:!0,children:e.jsxs("button",{className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:[e.jsx(de,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"Add App"})]})}),e.jsxs(U,{className:"sm:max-w-sm",children:[e.jsx(E,{children:e.jsx(V,{children:"Add App"})}),e.jsxs("form",{onSubmit:w,className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(b,{htmlFor:"app-name",children:"Name"}),e.jsx(M,{id:"app-name",value:c,onChange:u=>t(u.target.value),placeholder:"My App",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(b,{htmlFor:"bundle-id",children:"Bundle ID"}),e.jsx(M,{id:"bundle-id",value:g,onChange:u=>o(u.target.value),placeholder:"com.example.myapp",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(b,{htmlFor:"platform",children:"Platform"}),e.jsxs(A,{value:x,onValueChange:u=>j(u),children:[e.jsx(_,{id:"platform",children:e.jsx(B,{})}),e.jsxs(z,{children:[e.jsx(i,{value:"ios",children:"iOS"}),e.jsx(i,{value:"android",children:"Android"}),e.jsx(i,{value:"both",children:"Both"})]})]})]}),p&&e.jsx("p",{className:"text-sm text-destructive",children:p}),e.jsx(y,{type:"submit",disabled:n,className:"w-full",children:n?"Creating…":"Create App"})]})]})]})}function Be({apps:s,selectedAppId:l,onSelect:h,onAdd:c}){return e.jsxs("aside",{className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[e.jsx("span",{className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Apps"}),s.length===0&&e.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"No apps yet"}),s.map(t=>e.jsxs("button",{onClick:()=>h(t.id),className:["flex flex-col gap-0.5 rounded-md px-2 py-2 text-left text-sm hover:bg-accent overflow-hidden",t.id===l?"bg-accent font-medium":""].join(" "),children:[e.jsx("span",{className:"truncate",children:t.name}),e.jsx(D,{className:"text-muted-foreground truncate",children:t.bundle_id_key})]},t.id)),e.jsx("div",{className:"mt-1 border-t pt-1",children:e.jsx(_e,{onSuccess:c})})]})}function ze(s){const l=/[zZ]|[+-]\d{2}:?\d{2}$/.test(s),c=new Date(l?s:s.replace(" ","T")+"Z").getTime()-Date.now();if(c<=0)return{label:"Deleting…",urgent:!0};const t=Math.floor(c/36e5);return t<1?{label:"Deletes in < 1h",urgent:!0}:t<24?{label:`Deletes in ${t}h`,urgent:t<6}:{label:`Deletes in ${Math.floor(t/24)}d`,urgent:!1}}function Ie({build:s,isLast:l,onNavigate:h,onStatusChange:c,onScheduleDeletion:t,onCancelDeletion:g}){const[o,x]=r.useState(!1),j=s.status_label==="Done",p=s.delete_after?ze(s.delete_after):null;function N(n){c(s.id,n==="none"?null:n)}return e.jsxs(e.Fragment,{children:[e.jsx(he,{open:o,onOpenChange:x,children:e.jsxs(xe,{children:[e.jsxs(pe,{children:[e.jsx(me,{children:"Schedule deletion?"}),e.jsx(fe,{children:"Build files will be deleted after 7 days. You can cancel the scheduled deletion anytime before then."})]}),e.jsxs(ge,{children:[e.jsx(je,{children:"Cancel"}),e.jsx(ve,{onClick:()=>{t(s.id),x(!1)},children:"Schedule deletion"})]})]})}),e.jsxs("div",{className:["flex items-center gap-3 px-4 py-3",l?"":"border-b"].join(" "),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium",children:["build ",e.jsx(D,{children:s.build_number??"—"})]}),e.jsx(T,{tone:s.platform==="ios"?"ios":"android",className:"text-xs capitalize",children:s.platform}),s.status_label&&e.jsx(T,{tone:ee[s.status_label],className:"text-xs",children:s.status_label}),p&&e.jsx(T,{tone:p.urgent?"rejected":"backlog",className:"text-xs",children:p.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"14px",marginTop:"0.7rem",alignItems:"center"},className:"text-xs text-muted-foreground",children:[s.uploader&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:s.uploader}),e.jsx(K,{orientation:"vertical",className:"h-3"})]}),e.jsx(D,{children:new Date(s.uploaded_at).toLocaleDateString()})]})]}),e.jsxs(A,{value:s.status_label??"none",onValueChange:N,children:[e.jsx(_,{className:"h-9 w-32 text-xs",children:e.jsx(B,{})}),e.jsxs(z,{children:[e.jsx(i,{value:"none",children:e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(i,{value:"Backlog",children:"Backlog"}),e.jsx(i,{value:"In Progress",children:"In Progress"}),e.jsx(i,{value:"Done",children:"Done"}),e.jsx(i,{value:"Rejected",children:"Rejected"})]})]}),p?e.jsx(y,{size:"icon-sm",variant:"outline",onClick:()=>g(s.id),title:"Cancel scheduled deletion",children:e.jsx(ke,{className:"h-3.5 w-3.5"})}):e.jsx(y,{size:"icon-sm",variant:"destructive",onClick:()=>x(!0),title:"Schedule deletion",children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsxs(y,{size:"sm",onClick:()=>h(s.id),disabled:j,children:[e.jsx(se,{className:"mr-1.5 h-3.5 w-3.5"}),"Start QA"]})]})]})}function Pe({versionName:s,builds:l,isOpen:h,onToggle:c,onNavigate:t,onStatusChange:g,onScheduleDeletion:o,onCancelDeletion:x}){return e.jsxs("div",{className:"rounded-lg shadow-card-2 overflow-hidden",children:[e.jsxs("button",{className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent/50 bg-card",onClick:c,children:[h?e.jsx(oe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Q,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx(D,{className:"font-medium text-sm text-foreground",children:s}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.length," build",l.length>1?"s":"",")"]})]}),h&&e.jsx("div",{className:"border-t bg-card",children:l.map((j,p)=>e.jsx(Ie,{build:j,isLast:p===l.length-1,onNavigate:t,onStatusChange:g,onScheduleDeletion:o,onCancelDeletion:x},j.id))})]})}function Ue(){const s=J(),[l,h]=W(),[c,t]=r.useState([]),[g,o]=r.useState([]),[x,j]=r.useState(""),[p,N]=r.useState("all"),[n,d]=r.useState(!0),[w,u]=r.useState(new Set),m=l.get("appId")?Number(l.get("appId")):null,F=c.find(a=>a.id===m)??null,I=r.useCallback(async()=>{const a=await ae();t(a),!l.get("appId")&&a.length>0&&h({appId:String(a[0].id)},{replace:!0})},[l,h]),P=r.useCallback(async()=>{if(!m){o([]),d(!1);return}d(!0);try{const a=await te({appId:m,search:x,statusFilter:p});o(a),a.length>0&&w.size===0&&u(new Set([a[0].version_name??"Unversioned"]))}finally{d(!1)}},[m,x,p]);r.useEffect(()=>{I()},[]),r.useEffect(()=>{P()},[P]);function $(a){a!==m&&(o([]),u(new Set)),h({appId:String(a)})}function q(a){u(v=>{const f=new Set(v);return f.has(a)?f.delete(a):f.add(a),f})}async function H(a,v){await ie(a,v),o(f=>f.map(S=>S.id===a?{...S,status_label:v}:S))}async function Y(a){try{const v=await ce(a);o(f=>f.map(S=>S.id===a?{...S,delete_after:v}:S))}catch{k.error("Failed to schedule deletion")}}async function Z(a){try{await re(a),o(v=>v.map(f=>f.id===a?{...f,delete_after:null}:f))}catch{k.error("Failed to cancel scheduled deletion")}}const R=le(g);return e.jsxs("div",{className:"flex h-full gap-0",children:[e.jsx(Be,{apps:c,selectedAppId:m,onSelect:$,onAdd:I}),e.jsxs("main",{className:"flex-1 flex flex-col gap-4 p-4 overflow-y-auto min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:F?F.name:"App Center"}),e.jsx(Ae,{onSuccess:()=>{I(),P()},appId:m})]}),m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ne,{placeholder:"Search version…",value:x,onChange:j}),e.jsxs(A,{value:p,onValueChange:N,children:[e.jsx(_,{className:"h-8 w-36",children:e.jsx(B,{placeholder:"Status"})}),e.jsxs(z,{children:[e.jsx(i,{value:"all",children:"All statuses"}),e.jsx(i,{value:"Backlog",children:"Backlog"}),e.jsx(i,{value:"In Progress",children:"In Progress"}),e.jsx(i,{value:"Done",children:"Done"}),e.jsx(i,{value:"Rejected",children:"Rejected"})]})]})]}),n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):R.length===0?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[e.jsx(we,{className:"w-8 h-8 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm font-medium",children:"No builds yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload the first build to get started."})]}):e.jsx("div",{className:"flex flex-col gap-2",children:R.map(({versionName:a,builds:v})=>e.jsx(Pe,{versionName:a,builds:v,isOpen:w.has(a),onToggle:()=>q(a),onNavigate:f=>s(`/app-center/build?id=${f}`),onStatusChange:H,onScheduleDeletion:Y,onCancelDeletion:Z},a))})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[e.jsx(Se,{className:"w-8 h-8 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm font-medium",children:"No app selected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose an app from the sidebar to view its builds."})]})]})]})}export{Ue as AppCenter};
@@ -1 +1 @@
1
- import{ap as X,ab as Z,a7 as i,ai as S,aa as y,ao as I,a4 as e,C as g,d as j,e as v,b as w,L as m,I as u,S as M,i as O,a9 as n,B as h,G as ee,K as se,J as ae,a5 as A,_ as $,a8 as p}from"./index-nsRC4db_.js";import{B as re}from"./badge-D6kZI81S.js";import{A as te,h as oe,c as ne,f as ie,g as le,d as ce,e as de,b as me,a as ue}from"./alert-dialog-CFyLEW41.js";import{P as W}from"./pencil-sNgkZjUH.js";const he=A({teamName:p().min(1),logo:$(File).nullable().optional()}),pe=A({displayName:p().min(1),avatar:$(File).nullable().optional()}),fe=A({currentPassword:p().min(1),newPassword:p().min(8),confirmPassword:p()}).refine(f=>f.newPassword===f.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function we(){const{resolvedTheme:f}=X(),J=f==="dark"?"/logo-dark.svg":"/logo.svg",{user:o}=Z(),b=(o==null?void 0:o.role)==="Admin",N=(o==null?void 0:o.role)==="Admin"||(o==null?void 0:o.role)==="Developer",[V,P]=i.useState(null),C=i.useRef(null),d=S({resolver:y(he),mode:"onBlur",defaultValues:{teamName:"",logo:null}});i.useEffect(()=>{b&&fetch("/api/v1/settings",{credentials:"include"}).then(s=>s.ok?s.json():null).then(s=>{s&&(d.reset({teamName:s.team_name,logo:null}),P(s.logo_url))})},[b]);async function G(s){const a=new FormData;a.append("team_name",s.teamName),s.logo&&a.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:a})).ok){n.error("Failed to update workspace");return}n.success("Workspace updated")}catch{n.error("Failed to update workspace")}}const[k,F]=i.useState(null),D=i.useRef(null),c=S({resolver:y(pe),mode:"onBlur",defaultValues:{displayName:"",avatar:null}});i.useEffect(()=>{o&&(c.reset({displayName:o.displayName??"",avatar:null}),F(o.avatarUrl??null))},[o]);async function K(s){const a=new FormData;a.append("display_name",s.displayName),s.avatar&&a.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:a})).ok){n.error("Failed to update profile");return}n.success("Profile updated")}catch{n.error("Failed to update profile")}}const t=S({resolver:y(fe),mode:"onBlur"});async function Q(s){try{const a=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!a.ok){const r=await a.json();t.setError("root",{message:r.error??"Failed to change password"});return}t.reset(),n.success("Password changed")}catch{t.setError("root",{message:"Network error"})}}const[T,E]=i.useState([]),[B,L]=i.useState({}),[U,z]=i.useState({}),[R,_]=i.useState({});i.useEffect(()=>{N&&fetch("/api/v1/apps",{credentials:"include"}).then(s=>s.ok?s.json():null).then(s=>{if(!s)return;E(s.items);const a={};s.items.forEach(r=>{a[r.id]=r.name}),L(a)})},[N]);async function Y(s){_(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){n.error("Failed to delete app");return}E(r=>r.filter(l=>l.id!==s)),n.success("App deleted")}catch{n.error("Failed to delete app")}finally{_(a=>({...a,[s]:!1}))}}async function q(s){z(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B[s]})})).ok){n.error("Failed to update app");return}n.success("App updated")}catch{n.error("Failed to update app")}finally{z(a=>({...a,[s]:!1}))}}const x=I({control:c.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),b&&e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Workspace"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:d.handleSubmit(G),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team",...d.register("teamName")}),d.formState.errors.teamName&&e.jsx("p",{className:"text-sm text-destructive",children:d.formState.errors.teamName.message})]}),e.jsx(M,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(O,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:V??J,alt:"logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button",onClick:()=>{var a;return(a=C.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(W,{className:"w-3 h-3"})}),e.jsx("input",{ref:C,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var l;const r=(l=a.target.files)==null?void 0:l[0];if(r&&r.size>2*1024*1024){n.error("Image must be 2MB or less");return}r&&(s.onChange(r),P(URL.createObjectURL(r)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Profile"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:c.handleSubmit(K),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name",...c.register("displayName")}),c.formState.errors.displayName&&e.jsx("p",{className:"text-sm text-destructive",children:c.formState.errors.displayName.message})]}),e.jsx(M,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(O,{name:"avatar",control:c.control,render:({field:s})=>{var a;return e.jsxs("div",{className:"relative w-14 h-14",children:[k?e.jsx("img",{src:k,alt:"avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const r=ee(x||(o==null?void 0:o.email)||"");return{backgroundColor:r.bg,color:r.fg}})(),children:((a=x==null?void 0:x[0])==null?void 0:a.toUpperCase())??"?"}),e.jsx("button",{type:"button",onClick:()=>{var r;return(r=D.current)==null?void 0:r.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(W,{className:"w-3 h-3"})}),e.jsx("input",{ref:D,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var H;const l=(H=r.target.files)==null?void 0:H[0];if(l&&l.size>2*1024*1024){n.error("Image must be 2MB or less");return}l&&(s.onChange(l),F(URL.createObjectURL(l)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:c.formState.isSubmitting,children:c.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Password"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:t.handleSubmit(Q),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password",...t.register("currentPassword")}),t.formState.errors.currentPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.currentPassword.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password",...t.register("newPassword")}),t.formState.errors.newPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.newPassword.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password",...t.register("confirmPassword")}),t.formState.errors.confirmPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.confirmPassword.message})]}),t.formState.errors.root&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.root.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:t.formState.isSubmitting,children:t.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),N&&T.length>0&&e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Apps"})}),e.jsx(w,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:T.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(m,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:B[s.id]??"",onChange:a=>L(r=>({...r,[s.id]:a.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:s.bundle_id_key}),e.jsx(re,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",disabled:U[s.id],onClick:()=>q(s.id),children:U[s.id]?"Saving…":"Save"}),e.jsxs(te,{children:[e.jsx(oe,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"destructive",disabled:R[s.id],children:R[s.id]?"Deleting…":"Delete"})}),e.jsxs(ne,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Delete app?"}),e.jsxs(ce,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(de,{children:[e.jsx(me,{className:"w-24",children:"Cancel"}),e.jsx(ue,{className:se(ae({variant:"destructive"}),"w-24"),onClick:()=>Y(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{we as DefaultSettings};
1
+ import{ap as X,ab as Z,a7 as i,ai as S,aa as y,ao as I,a4 as e,C as g,d as j,e as v,b as w,L as m,I as u,S as M,i as O,a9 as n,B as h,G as ee,K as se,J as ae,a5 as A,_ as $,a8 as p}from"./index-D8ViYmeP.js";import{B as re}from"./badge-B63ynAZJ.js";import{A as te,h as oe,c as ne,f as ie,g as le,d as ce,e as de,b as me,a as ue}from"./alert-dialog-CPQLr1ij.js";import{P as W}from"./pencil-BAhJ8VF-.js";const he=A({teamName:p().min(1),logo:$(File).nullable().optional()}),pe=A({displayName:p().min(1),avatar:$(File).nullable().optional()}),fe=A({currentPassword:p().min(1),newPassword:p().min(8),confirmPassword:p()}).refine(f=>f.newPassword===f.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function we(){const{resolvedTheme:f}=X(),J=f==="dark"?"/logo-dark.svg":"/logo.svg",{user:o}=Z(),b=(o==null?void 0:o.role)==="Admin",N=(o==null?void 0:o.role)==="Admin"||(o==null?void 0:o.role)==="Developer",[V,P]=i.useState(null),C=i.useRef(null),d=S({resolver:y(he),mode:"onBlur",defaultValues:{teamName:"",logo:null}});i.useEffect(()=>{b&&fetch("/api/v1/settings",{credentials:"include"}).then(s=>s.ok?s.json():null).then(s=>{s&&(d.reset({teamName:s.team_name,logo:null}),P(s.logo_url))})},[b]);async function G(s){const a=new FormData;a.append("team_name",s.teamName),s.logo&&a.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:a})).ok){n.error("Failed to update workspace");return}n.success("Workspace updated")}catch{n.error("Failed to update workspace")}}const[k,F]=i.useState(null),D=i.useRef(null),c=S({resolver:y(pe),mode:"onBlur",defaultValues:{displayName:"",avatar:null}});i.useEffect(()=>{o&&(c.reset({displayName:o.displayName??"",avatar:null}),F(o.avatarUrl??null))},[o]);async function K(s){const a=new FormData;a.append("display_name",s.displayName),s.avatar&&a.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:a})).ok){n.error("Failed to update profile");return}n.success("Profile updated")}catch{n.error("Failed to update profile")}}const t=S({resolver:y(fe),mode:"onBlur"});async function Q(s){try{const a=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!a.ok){const r=await a.json();t.setError("root",{message:r.error??"Failed to change password"});return}t.reset(),n.success("Password changed")}catch{t.setError("root",{message:"Network error"})}}const[T,E]=i.useState([]),[B,L]=i.useState({}),[U,z]=i.useState({}),[R,_]=i.useState({});i.useEffect(()=>{N&&fetch("/api/v1/apps",{credentials:"include"}).then(s=>s.ok?s.json():null).then(s=>{if(!s)return;E(s.items);const a={};s.items.forEach(r=>{a[r.id]=r.name}),L(a)})},[N]);async function Y(s){_(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){n.error("Failed to delete app");return}E(r=>r.filter(l=>l.id!==s)),n.success("App deleted")}catch{n.error("Failed to delete app")}finally{_(a=>({...a,[s]:!1}))}}async function q(s){z(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B[s]})})).ok){n.error("Failed to update app");return}n.success("App updated")}catch{n.error("Failed to update app")}finally{z(a=>({...a,[s]:!1}))}}const x=I({control:c.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),b&&e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Workspace"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:d.handleSubmit(G),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team",...d.register("teamName")}),d.formState.errors.teamName&&e.jsx("p",{className:"text-sm text-destructive",children:d.formState.errors.teamName.message})]}),e.jsx(M,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(O,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:V??J,alt:"logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button",onClick:()=>{var a;return(a=C.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(W,{className:"w-3 h-3"})}),e.jsx("input",{ref:C,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var l;const r=(l=a.target.files)==null?void 0:l[0];if(r&&r.size>2*1024*1024){n.error("Image must be 2MB or less");return}r&&(s.onChange(r),P(URL.createObjectURL(r)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Profile"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:c.handleSubmit(K),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name",...c.register("displayName")}),c.formState.errors.displayName&&e.jsx("p",{className:"text-sm text-destructive",children:c.formState.errors.displayName.message})]}),e.jsx(M,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(m,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(O,{name:"avatar",control:c.control,render:({field:s})=>{var a;return e.jsxs("div",{className:"relative w-14 h-14",children:[k?e.jsx("img",{src:k,alt:"avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const r=ee(x||(o==null?void 0:o.email)||"");return{backgroundColor:r.bg,color:r.fg}})(),children:((a=x==null?void 0:x[0])==null?void 0:a.toUpperCase())??"?"}),e.jsx("button",{type:"button",onClick:()=>{var r;return(r=D.current)==null?void 0:r.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(W,{className:"w-3 h-3"})}),e.jsx("input",{ref:D,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var H;const l=(H=r.target.files)==null?void 0:H[0];if(l&&l.size>2*1024*1024){n.error("Image must be 2MB or less");return}l&&(s.onChange(l),F(URL.createObjectURL(l)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:c.formState.isSubmitting,children:c.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Password"})}),e.jsx(w,{children:e.jsxs("form",{onSubmit:t.handleSubmit(Q),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password",...t.register("currentPassword")}),t.formState.errors.currentPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.currentPassword.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password",...t.register("newPassword")}),t.formState.errors.newPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.newPassword.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(m,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password",...t.register("confirmPassword")}),t.formState.errors.confirmPassword&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.confirmPassword.message})]}),t.formState.errors.root&&e.jsx("p",{className:"text-sm text-destructive",children:t.formState.errors.root.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{type:"submit",size:"sm",disabled:t.formState.isSubmitting,children:t.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),N&&T.length>0&&e.jsxs(g,{children:[e.jsx(j,{children:e.jsx(v,{children:"Apps"})}),e.jsx(w,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:T.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(m,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:B[s.id]??"",onChange:a=>L(r=>({...r,[s.id]:a.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:s.bundle_id_key}),e.jsx(re,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",disabled:U[s.id],onClick:()=>q(s.id),children:U[s.id]?"Saving…":"Save"}),e.jsxs(te,{children:[e.jsx(oe,{asChild:!0,children:e.jsx(h,{size:"sm",variant:"destructive",disabled:R[s.id],children:R[s.id]?"Deleting…":"Delete"})}),e.jsxs(ne,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Delete app?"}),e.jsxs(ce,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(de,{children:[e.jsx(me,{className:"w-24",children:"Cancel"}),e.jsx(ue,{className:se(ae({variant:"destructive"}),"w-24"),onClick:()=>Y(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{we as DefaultSettings};
@@ -1 +1 @@
1
- import{al as E,am as L,a7 as i,ai as A,aa as M,ao as T,a4 as e,C as b,d as y,e as C,c as k,b as U,L as d,I as x,i as _,G as D,S as O,B as Y,a5 as z,a8 as h,_ as G}from"./index-nsRC4db_.js";import{P as H}from"./pencil-sNgkZjUH.js";const V=z({displayName:h().optional(),avatar:G(File).nullable().optional(),password:h().min(8),confirm:h()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function q(){const o=E(),[S]=L(),c=S.get("token")??"",[f,m]=i.useState("loading"),[P,F]=i.useState(""),[v,R]=i.useState(null),j=i.useRef(null),{register:p,handleSubmit:B,control:g,setError:u,formState:{errors:t,isSubmitting:w}}=A({resolver:M(V),mode:"onBlur",defaultValues:{displayName:"",avatar:null}}),l=T({control:g,name:"displayName"})??"";i.useEffect(()=>{if(!c){m("invalid");return}fetch(`/api/v1/invitations/verify?token=${c}`).then(a=>a.ok?a.json():Promise.reject()).then(a=>{F(a.role),m("valid")}).catch(()=>m("invalid"))},[c]);async function I(a){var r;try{const s=new FormData;if(s.append("token",c),s.append("password",a.password),(r=a.displayName)!=null&&r.trim()&&s.append("display_name",a.displayName.trim()),a.avatar&&s.append("avatar",a.avatar),!(await fetch("/api/v1/invitations/accept",{method:"POST",body:s})).ok){u("root",{message:"Failed to accept invitation"});return}o("/app-center",{replace:!0})}catch{u("root",{message:"Network error. Please try again."})}}return f==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):f==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(b,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(y,{children:[e.jsx(C,{children:"Invitation expired"}),e.jsx(k,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(b,{level:4,className:"w-full max-w-sm",children:[e.jsxs(y,{className:"text-center",children:[e.jsx(C,{children:"Set up your account"}),e.jsxs(k,{children:["You're joining as ",e.jsx("strong",{children:P})]})]}),e.jsx(U,{children:e.jsxs("form",{onSubmit:B(I),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(x,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(_,{name:"avatar",control:g,render:({field:a})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[v?e.jsx("img",{src:v,alt:"avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=D(l);return{backgroundColor:s.bg,color:s.fg}})(),children:((r=l==null?void 0:l[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button",onClick:()=>{var s;return(s=j.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(H,{className:"w-3 h-3"})}),e.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var N;const n=(N=s.target.files)==null?void 0:N[0];if(n){if(n.size>2*1024*1024){u("avatar",{message:"Max 2MB for avatar"});return}a.onChange(n),R(URL.createObjectURL(n))}}})]})}}),t.avatar&&e.jsx("p",{className:"text-sm text-destructive",children:t.avatar.message})]}),e.jsx(O,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"password",children:"Password"}),e.jsx(x,{id:"password",type:"password",...p("password")}),t.password&&e.jsx("p",{className:"text-sm text-destructive",children:t.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(x,{id:"confirm",type:"password",...p("confirm")}),t.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:t.confirm.message})]}),t.root&&e.jsx("p",{className:"text-sm text-destructive",children:t.root.message}),e.jsx(Y,{type:"submit",disabled:w,className:"w-full",children:w?"Creating account…":"Create account"})]})})]})})}export{q as Invite};
1
+ import{al as E,am as L,a7 as i,ai as A,aa as M,ao as T,a4 as e,C as b,d as y,e as C,c as k,b as U,L as d,I as x,i as _,G as D,S as O,B as Y,a5 as z,a8 as h,_ as G}from"./index-D8ViYmeP.js";import{P as H}from"./pencil-BAhJ8VF-.js";const V=z({displayName:h().optional(),avatar:G(File).nullable().optional(),password:h().min(8),confirm:h()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function q(){const o=E(),[S]=L(),c=S.get("token")??"",[f,m]=i.useState("loading"),[P,F]=i.useState(""),[v,R]=i.useState(null),j=i.useRef(null),{register:p,handleSubmit:B,control:g,setError:u,formState:{errors:t,isSubmitting:w}}=A({resolver:M(V),mode:"onBlur",defaultValues:{displayName:"",avatar:null}}),l=T({control:g,name:"displayName"})??"";i.useEffect(()=>{if(!c){m("invalid");return}fetch(`/api/v1/invitations/verify?token=${c}`).then(a=>a.ok?a.json():Promise.reject()).then(a=>{F(a.role),m("valid")}).catch(()=>m("invalid"))},[c]);async function I(a){var r;try{const s=new FormData;if(s.append("token",c),s.append("password",a.password),(r=a.displayName)!=null&&r.trim()&&s.append("display_name",a.displayName.trim()),a.avatar&&s.append("avatar",a.avatar),!(await fetch("/api/v1/invitations/accept",{method:"POST",body:s})).ok){u("root",{message:"Failed to accept invitation"});return}o("/app-center",{replace:!0})}catch{u("root",{message:"Network error. Please try again."})}}return f==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):f==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(b,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(y,{children:[e.jsx(C,{children:"Invitation expired"}),e.jsx(k,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(b,{level:4,className:"w-full max-w-sm",children:[e.jsxs(y,{className:"text-center",children:[e.jsx(C,{children:"Set up your account"}),e.jsxs(k,{children:["You're joining as ",e.jsx("strong",{children:P})]})]}),e.jsx(U,{children:e.jsxs("form",{onSubmit:B(I),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(x,{id:"display-name",placeholder:"Your name",...p("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(_,{name:"avatar",control:g,render:({field:a})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[v?e.jsx("img",{src:v,alt:"avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const s=D(l);return{backgroundColor:s.bg,color:s.fg}})(),children:((r=l==null?void 0:l[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button",onClick:()=>{var s;return(s=j.current)==null?void 0:s.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(H,{className:"w-3 h-3"})}),e.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:s=>{var N;const n=(N=s.target.files)==null?void 0:N[0];if(n){if(n.size>2*1024*1024){u("avatar",{message:"Max 2MB for avatar"});return}a.onChange(n),R(URL.createObjectURL(n))}}})]})}}),t.avatar&&e.jsx("p",{className:"text-sm text-destructive",children:t.avatar.message})]}),e.jsx(O,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"password",children:"Password"}),e.jsx(x,{id:"password",type:"password",...p("password")}),t.password&&e.jsx("p",{className:"text-sm text-destructive",children:t.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(x,{id:"confirm",type:"password",...p("confirm")}),t.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:t.confirm.message})]}),t.root&&e.jsx("p",{className:"text-sm text-destructive",children:t.root.message}),e.jsx(Y,{type:"submit",disabled:w,className:"w-full",children:w?"Creating account…":"Create account"})]})})]})})}export{q as Invite};