vidspotai-shared 1.0.147 → 1.0.149

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 (81) hide show
  1. package/lib/globals/plans.d.ts +17 -0
  2. package/lib/globals/plans.d.ts.map +1 -1
  3. package/lib/globals/plans.js +11 -1
  4. package/lib/globals/types.d.ts +6 -2
  5. package/lib/globals/types.d.ts.map +1 -1
  6. package/lib/globals/types.js +11 -0
  7. package/lib/models/agent.model.d.ts +6 -0
  8. package/lib/models/agent.model.d.ts.map +1 -1
  9. package/lib/models/demoVideoProject.model.d.ts +6 -0
  10. package/lib/models/demoVideoProject.model.d.ts.map +1 -1
  11. package/lib/models/image.model.d.ts +6 -0
  12. package/lib/models/image.model.d.ts.map +1 -1
  13. package/lib/models/musicJob.model.d.ts +6 -0
  14. package/lib/models/musicJob.model.d.ts.map +1 -1
  15. package/lib/models/social.model.d.ts +7 -2
  16. package/lib/models/social.model.d.ts.map +1 -1
  17. package/lib/models/upscale.model.d.ts +6 -0
  18. package/lib/models/upscale.model.d.ts.map +1 -1
  19. package/lib/models/user.model.d.ts +68 -1
  20. package/lib/models/user.model.d.ts.map +1 -1
  21. package/lib/models/video.model.d.ts +43 -0
  22. package/lib/models/video.model.d.ts.map +1 -1
  23. package/lib/models/videoTool.model.d.ts +6 -0
  24. package/lib/models/videoTool.model.d.ts.map +1 -1
  25. package/lib/schemas/social.schema.d.ts +9 -0
  26. package/lib/schemas/social.schema.d.ts.map +1 -1
  27. package/lib/schemas/social.schema.js +6 -1
  28. package/lib/services/accountStatus/index.d.ts +35 -0
  29. package/lib/services/accountStatus/index.d.ts.map +1 -1
  30. package/lib/services/accountStatus/index.js +54 -0
  31. package/lib/services/agent/repair/engine.d.ts.map +1 -1
  32. package/lib/services/agent/repair/engine.js +18 -0
  33. package/lib/services/agent/repair/strategies/llmRepair.strategy.d.ts.map +1 -1
  34. package/lib/services/agent/repair/strategies/llmRepair.strategy.js +20 -8
  35. package/lib/services/bullmq.service.d.ts +18 -1
  36. package/lib/services/bullmq.service.d.ts.map +1 -1
  37. package/lib/services/bullmq.service.js +13 -0
  38. package/lib/services/credit.service.d.ts +61 -1
  39. package/lib/services/credit.service.d.ts.map +1 -1
  40. package/lib/services/credit.service.js +124 -52
  41. package/lib/services/credits/grant.d.ts +105 -0
  42. package/lib/services/credits/grant.d.ts.map +1 -0
  43. package/lib/services/credits/grant.js +129 -0
  44. package/lib/services/demo/demoPrefill.d.ts.map +1 -1
  45. package/lib/services/demo/demoPrefill.js +101 -84
  46. package/lib/services/index.d.ts +1 -0
  47. package/lib/services/index.d.ts.map +1 -1
  48. package/lib/services/index.js +1 -0
  49. package/lib/services/moderation/generationModeration.service.d.ts +52 -0
  50. package/lib/services/moderation/generationModeration.service.d.ts.map +1 -0
  51. package/lib/services/moderation/generationModeration.service.js +260 -0
  52. package/lib/services/moderation/index.d.ts +4 -0
  53. package/lib/services/moderation/index.d.ts.map +1 -1
  54. package/lib/services/moderation/index.js +14 -1
  55. package/lib/services/moderation/moderationStrike.service.d.ts +67 -0
  56. package/lib/services/moderation/moderationStrike.service.d.ts.map +1 -0
  57. package/lib/services/moderation/moderationStrike.service.js +134 -0
  58. package/lib/services/rateLimiter/index.d.ts +1 -0
  59. package/lib/services/rateLimiter/index.d.ts.map +1 -1
  60. package/lib/services/rateLimiter/index.js +1 -0
  61. package/lib/services/rateLimiter/userRateLimiter.service.d.ts +55 -0
  62. package/lib/services/rateLimiter/userRateLimiter.service.d.ts.map +1 -0
  63. package/lib/services/rateLimiter/userRateLimiter.service.js +220 -0
  64. package/lib/services/socialOAuth/youtube.oauth.d.ts +1 -1
  65. package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -1
  66. package/lib/services/socialOAuth/youtube.oauth.js +15 -7
  67. package/lib/services/socialPublish/types.d.ts +31 -0
  68. package/lib/services/socialPublish/types.d.ts.map +1 -1
  69. package/lib/services/socialPublish/types.js +17 -0
  70. package/lib/services/socialPublish/youtube.publish.d.ts +12 -1
  71. package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -1
  72. package/lib/services/socialPublish/youtube.publish.js +95 -0
  73. package/lib/services/trialGuard/trialSignals.d.ts.map +1 -1
  74. package/lib/services/trialGuard/trialSignals.js +15 -0
  75. package/lib/utils/index.d.ts +1 -0
  76. package/lib/utils/index.d.ts.map +1 -1
  77. package/lib/utils/index.js +1 -0
  78. package/lib/utils/ssrfGuard.d.ts +59 -0
  79. package/lib/utils/ssrfGuard.d.ts.map +1 -0
  80. package/lib/utils/ssrfGuard.js +253 -0
  81. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ import type { DocumentData, DocumentReference, Transaction } from "firebase-admin/firestore";
2
+ /**
3
+ * Single source of truth for every credit GRANT and CLAWBACK on a user's
4
+ * personal balance (2026-11-25).
5
+ *
6
+ * Why this exists: grants used to be ad-hoc writes scattered across the
7
+ * invoice webhook (`total = P, consumed = 0`), the yearly refresh trigger
8
+ * (`consumed = 0`) and the trial path (`total += 10`). Two exploits came out
9
+ * of that:
10
+ * - `credits.owed` (credits a job really cost beyond the balance, written by
11
+ * the worker's finalization) was wiped by the next reset, so going into
12
+ * debt was free.
13
+ * - a plan reset threw away the paid-for top-up credits the user still had.
14
+ *
15
+ * Ledger fields (all on `users/{uid}.credits`):
16
+ * - total credits granted in the current period
17
+ * - consumed credits used against `total`
18
+ * - owed credits used but not paid for (debt). While > 0 the
19
+ * CreditService refuses new spending; every grant pays it
20
+ * off first.
21
+ * - topUpBalance how much of the remaining balance (total - consumed) came
22
+ * from pay-as-you-go top-ups. Never decremented on spend;
23
+ * instead it is clamped to the remaining balance, which
24
+ * means PLAN credits are considered spent first.
25
+ *
26
+ * Invariants kept by every function here:
27
+ * - 0 <= owed
28
+ * - 0 <= topUpBalance <= max(0, total - consumed)
29
+ * - total >= consumed is never violated by a grant or a clawback (a clawback
30
+ * pulls total down to consumed at most — `consumed > total` is treated as a
31
+ * corrupt account by the credit precheck).
32
+ */
33
+ export interface ICreditLedgerState {
34
+ total: number;
35
+ consumed: number;
36
+ owed: number;
37
+ topUpBalance: number;
38
+ }
39
+ export type CreditGrant =
40
+ /** Monthly/yearly plan period start: total = P + carried top-up, consumed reset. */
41
+ {
42
+ kind: "plan_reset";
43
+ planCredits: number;
44
+ }
45
+ /** Mid-period upgrade: add the positive difference in plan credits, no reset. */
46
+ | {
47
+ kind: "plan_delta";
48
+ credits: number;
49
+ }
50
+ /** Paid pay-as-you-go pack: adds to total AND to topUpBalance. */
51
+ | {
52
+ kind: "top_up";
53
+ credits: number;
54
+ }
55
+ /** Free grant (trial): adds to total, not counted as a paid top-up. */
56
+ | {
57
+ kind: "bonus";
58
+ credits: number;
59
+ };
60
+ export type CreditClawback =
61
+ /** Dispute: every unused credit, top-ups included, is revoked. */
62
+ {
63
+ kind: "revoke_all";
64
+ }
65
+ /** Subscription payment refunded: revoke unused PLAN credits, keep paid top-ups. */
66
+ | {
67
+ kind: "revoke_plan";
68
+ }
69
+ /** A top-up payment refunded/disputed: revoke up to `credits` of the unused balance. */
70
+ | {
71
+ kind: "revoke_top_up";
72
+ credits: number;
73
+ };
74
+ export interface ICreditChangeResult {
75
+ before: ICreditLedgerState;
76
+ after: ICreditLedgerState;
77
+ /** Owed credits this grant paid off. */
78
+ paidOwed: number;
79
+ /** Credits removed from the spendable balance (clawbacks only). */
80
+ revoked: number;
81
+ }
82
+ /** Reads a user doc's `credits` map defensively (missing fields → 0). */
83
+ export declare function readCreditState(userData: DocumentData | undefined): ICreditLedgerState;
84
+ /** Pure: the ledger after a grant. Unit-testable without Firestore. */
85
+ export declare function computeCreditGrant(before: ICreditLedgerState, grant: CreditGrant): ICreditChangeResult;
86
+ /** Pure: the ledger after a refund/dispute clawback. */
87
+ export declare function computeCreditClawback(before: ICreditLedgerState, clawback: CreditClawback): ICreditChangeResult;
88
+ /** Dot-path update for the ledger fields only (never clobbers `reserved`). */
89
+ export declare function creditStateUpdate(s: ICreditLedgerState): Record<string, number>;
90
+ /**
91
+ * Transactional grant. The caller passes the user doc's data if it already
92
+ * read it inside `tx` (Firestore requires all reads before writes); otherwise
93
+ * it is read here. `extra` is merged into the same `tx.update` (dot paths),
94
+ * so a grant and the subscription fields it belongs to commit atomically.
95
+ */
96
+ export declare function applyCreditGrantInTx(tx: Transaction, ref: DocumentReference, grant: CreditGrant, opts?: {
97
+ userData?: DocumentData;
98
+ extra?: Record<string, unknown>;
99
+ }): Promise<ICreditChangeResult>;
100
+ /** Transactional clawback; same read/write contract as applyCreditGrantInTx. */
101
+ export declare function applyCreditClawbackInTx(tx: Transaction, ref: DocumentReference, clawback: CreditClawback, opts?: {
102
+ userData?: DocumentData;
103
+ extra?: Record<string, unknown>;
104
+ }): Promise<ICreditChangeResult>;
105
+ //# sourceMappingURL=grant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant.d.ts","sourceRoot":"","sources":["../../../src/services/credits/grant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,WAAW;AACrB,oFAAoF;AAClF;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;AAC7C,iFAAiF;GAC/E;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACzC,kEAAkE;GAChE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACrC,uEAAuE;GACrE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CA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B,QAAQ,EAAE,cAAc,EACxB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAO,GACtE,OAAO,CAAC,mBAAmB,CAAC,CAS9B"}
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCreditState = readCreditState;
4
+ exports.computeCreditGrant = computeCreditGrant;
5
+ exports.computeCreditClawback = computeCreditClawback;
6
+ exports.creditStateUpdate = creditStateUpdate;
7
+ exports.applyCreditGrantInTx = applyCreditGrantInTx;
8
+ exports.applyCreditClawbackInTx = applyCreditClawbackInTx;
9
+ function num(v) {
10
+ return typeof v === "number" && Number.isFinite(v) ? v : 0;
11
+ }
12
+ /** Reads a user doc's `credits` map defensively (missing fields → 0). */
13
+ function readCreditState(userData) {
14
+ const c = (userData?.credits ?? {});
15
+ return {
16
+ total: Math.max(0, num(c.total)),
17
+ consumed: Math.max(0, num(c.consumed)),
18
+ owed: Math.max(0, num(c.owed)),
19
+ topUpBalance: Math.max(0, num(c.topUpBalance)),
20
+ };
21
+ }
22
+ function remaining(s) {
23
+ return Math.max(0, s.total - s.consumed);
24
+ }
25
+ /** Moves as much of `owed` as the balance allows into `consumed`. */
26
+ function payOwed(s) {
27
+ const paid = Math.min(s.owed, remaining(s));
28
+ return {
29
+ state: { ...s, consumed: s.consumed + paid, owed: s.owed - paid },
30
+ paid,
31
+ };
32
+ }
33
+ function clampTopUp(s) {
34
+ return { ...s, topUpBalance: Math.min(Math.max(0, s.topUpBalance), remaining(s)) };
35
+ }
36
+ /** Pure: the ledger after a grant. Unit-testable without Firestore. */
37
+ function computeCreditGrant(before, grant) {
38
+ const amount = Math.max(0, Math.floor(grant.kind === "plan_reset" ? grant.planCredits : grant.credits));
39
+ let next;
40
+ switch (grant.kind) {
41
+ case "plan_reset": {
42
+ // Remaining top-up credits survive the reset; plan credits are spent
43
+ // first, so at most the whole remaining balance is carried.
44
+ const carried = Math.min(before.topUpBalance, remaining(before));
45
+ next = { total: amount + carried, consumed: 0, owed: before.owed, topUpBalance: carried };
46
+ break;
47
+ }
48
+ case "top_up":
49
+ next = {
50
+ ...before,
51
+ total: before.total + amount,
52
+ topUpBalance: before.topUpBalance + amount,
53
+ };
54
+ break;
55
+ case "plan_delta":
56
+ case "bonus":
57
+ next = { ...before, total: before.total + amount };
58
+ break;
59
+ }
60
+ // Debt is paid before anything becomes spendable. topUpBalance is clamped
61
+ // afterwards, so owed is paid out of plan credits first, then top-ups.
62
+ const { state, paid } = payOwed(next);
63
+ return { before, after: clampTopUp(state), paidOwed: paid, revoked: 0 };
64
+ }
65
+ /** Pure: the ledger after a refund/dispute clawback. */
66
+ function computeCreditClawback(before, clawback) {
67
+ const rem = remaining(before);
68
+ const carriedTopUp = Math.min(before.topUpBalance, rem);
69
+ let revoked;
70
+ switch (clawback.kind) {
71
+ case "revoke_all":
72
+ revoked = rem;
73
+ break;
74
+ case "revoke_plan":
75
+ revoked = rem - carriedTopUp;
76
+ break;
77
+ case "revoke_top_up":
78
+ revoked = Math.min(Math.max(0, Math.floor(clawback.credits)), rem);
79
+ break;
80
+ }
81
+ const total = before.total - revoked;
82
+ let topUpBalance;
83
+ switch (clawback.kind) {
84
+ case "revoke_all":
85
+ topUpBalance = 0;
86
+ break;
87
+ case "revoke_plan":
88
+ topUpBalance = carriedTopUp;
89
+ break;
90
+ case "revoke_top_up":
91
+ topUpBalance = Math.max(0, carriedTopUp - revoked);
92
+ break;
93
+ }
94
+ const after = clampTopUp({ ...before, total, topUpBalance });
95
+ return { before, after, paidOwed: 0, revoked };
96
+ }
97
+ /** Dot-path update for the ledger fields only (never clobbers `reserved`). */
98
+ function creditStateUpdate(s) {
99
+ return {
100
+ "credits.total": s.total,
101
+ "credits.consumed": s.consumed,
102
+ "credits.owed": s.owed,
103
+ "credits.topUpBalance": s.topUpBalance,
104
+ };
105
+ }
106
+ /**
107
+ * Transactional grant. The caller passes the user doc's data if it already
108
+ * read it inside `tx` (Firestore requires all reads before writes); otherwise
109
+ * it is read here. `extra` is merged into the same `tx.update` (dot paths),
110
+ * so a grant and the subscription fields it belongs to commit atomically.
111
+ */
112
+ async function applyCreditGrantInTx(tx, ref, grant, opts = {}) {
113
+ const data = opts.userData ?? (await tx.get(ref)).data();
114
+ const result = computeCreditGrant(readCreditState(data), grant);
115
+ tx.update(ref, { ...creditStateUpdate(result.after), ...(opts.extra ?? {}) });
116
+ return result;
117
+ }
118
+ /** Transactional clawback; same read/write contract as applyCreditGrantInTx. */
119
+ async function applyCreditClawbackInTx(tx, ref, clawback, opts = {}) {
120
+ const data = opts.userData ?? (await tx.get(ref)).data();
121
+ const result = computeCreditClawback(readCreditState(data), clawback);
122
+ if (result.revoked > 0 || result.after.topUpBalance !== result.before.topUpBalance) {
123
+ tx.update(ref, { ...creditStateUpdate(result.after), ...(opts.extra ?? {}) });
124
+ }
125
+ else if (opts.extra && Object.keys(opts.extra).length > 0) {
126
+ tx.update(ref, opts.extra);
127
+ }
128
+ return result;
129
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"demoPrefill.d.ts","sourceRoot":"","sources":["../../../src/services/demo/demoPrefill.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA0BhE,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,+EAA+E;IAC/E,MAAM,EAAE,KAAK,GAAG,UAAU,CAAC;IAC3B,SAAS,CAAC,EAAE,WAAW,CAA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B,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAqKD,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AA+ED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAc1D;AA4ED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,MAAM,EAAE,iBAAiB,CAAC;IAC1B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,cAAc,GAAG,UAAU,CAAM,GAC1E,OAAO,CAAC,eAAe,CAAC,CAqC1B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CA8C5B"}
@@ -4,9 +4,11 @@ exports.DemoPrefillError = void 0;
4
4
  exports.extractPageMeta = extractPageMeta;
5
5
  exports.gatherPageSignals = gatherPageSignals;
6
6
  exports.prefillDemoBasics = prefillDemoBasics;
7
- const promises_1 = require("dns/promises");
8
- const net_1 = require("net");
7
+ // REMOVED FOR v1 — kept for reference: guard moved to utils/ssrfGuard.ts
8
+ // import { lookup } from "dns/promises";
9
+ // import { isIP } from "net";
9
10
  const zod_1 = require("zod");
11
+ const ssrfGuard_1 = require("../../utils/ssrfGuard");
10
12
  const llmCallerRegistry_1 = require("../agent/llmCallerRegistry");
11
13
  const modelRouter_1 = require("../agent/modelRouter");
12
14
  /**
@@ -40,94 +42,109 @@ class DemoPrefillError extends Error {
40
42
  }
41
43
  exports.DemoPrefillError = DemoPrefillError;
42
44
  // ── SSRF guard ───────────────────────────────────────────────────────────────
43
- /** IPv4/IPv6 ranges we must never fetch (cloud metadata, loopback, LAN, etc.). */
44
- function isPrivateAddress(ip) {
45
- const v = (0, net_1.isIP)(ip);
46
- if (v === 4) {
47
- const p = ip.split(".").map(Number);
48
- if (p.length !== 4 || p.some((n) => Number.isNaN(n)))
49
- return true;
50
- const a = p[0];
51
- const b = p[1];
52
- if (a === 10)
53
- return true; // 10.0.0.0/8
54
- if (a === 127)
55
- return true; // loopback
56
- if (a === 0)
57
- return true; // "this" network
58
- if (a === 169 && b === 254)
59
- return true; // link-local incl. 169.254.169.254
60
- if (a === 172 && b >= 16 && b <= 31)
61
- return true; // 172.16.0.0/12
62
- if (a === 192 && b === 168)
63
- return true; // 192.168.0.0/16
64
- if (a === 100 && b >= 64 && b <= 127)
65
- return true; // CGNAT 100.64.0.0/10
66
- if (a >= 224)
67
- return true; // multicast / reserved
68
- return false;
69
- }
70
- if (v === 6) {
71
- const lower = ip.toLowerCase();
72
- if (lower === "::1" || lower === "::")
73
- return true; // loopback / unspecified
74
- if (lower.startsWith("fc") || lower.startsWith("fd"))
75
- return true; // ULA fc00::/7
76
- if (lower.startsWith("fe80"))
77
- return true; // link-local
78
- // IPv4-mapped (::ffff:a.b.c.d) — extract and re-check as v4.
79
- const mapped = lower.match(/::ffff:(\d+\.\d+\.\d+\.\d+)$/);
80
- if (mapped?.[1])
81
- return isPrivateAddress(mapped[1]);
82
- return false;
83
- }
84
- return true; // not an IP literal ⇒ treat as unsafe
85
- }
86
- /**
87
- * Validate a URL is a public http(s) target: parseable, http/https, not a
88
- * localhost-ish hostname, and every resolved IP is public. Throws a
89
- * DemoPrefillError otherwise. Called on the initial URL AND every redirect hop.
90
- */
45
+ // WHY (2026-11-25): the guard below was extracted to utils/ssrfGuard.ts so the
46
+ // worker's headless-browser capture, browser sessions, video-tool downloads
47
+ // and webhook delivery share ONE implementation (it also now handles the
48
+ // hex-normalised IPv4-mapped form `[::ffff:7f00:1]` that WHATWG URL produces,
49
+ // which the old regex missed). This thin wrapper keeps DemoPrefillError codes.
91
50
  async function assertPublicHttpUrl(raw) {
92
- let url;
93
51
  try {
94
- url = new URL(raw);
95
- }
96
- catch {
97
- throw new DemoPrefillError("invalid_url", "That doesn't look like a valid URL.");
98
- }
99
- if (url.protocol !== "http:" && url.protocol !== "https:") {
100
- throw new DemoPrefillError("invalid_url", "Only http(s) URLs are supported.");
52
+ return await (0, ssrfGuard_1.assertPublicUrl)(raw);
101
53
  }
102
- const host = url.hostname.replace(/^\[|\]$/g, ""); // strip IPv6 brackets
103
- // Obvious internal hostnames — reject before any DNS.
104
- const lowered = host.toLowerCase();
105
- if (lowered === "localhost" ||
106
- lowered.endsWith(".localhost") ||
107
- lowered.endsWith(".local") ||
108
- lowered.endsWith(".internal") ||
109
- lowered === "metadata.google.internal") {
110
- throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
111
- }
112
- // Literal IP ⇒ check directly; hostname ⇒ resolve every address and check all.
113
- if ((0, net_1.isIP)(host)) {
114
- if (isPrivateAddress(host)) {
115
- throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
54
+ catch (err) {
55
+ if (err instanceof ssrfGuard_1.SsrfBlockedError) {
56
+ if (err.reason === "unresolvable") {
57
+ throw new DemoPrefillError("unreachable", "We couldn't reach that site.");
58
+ }
59
+ if (err.reason === "blocked_host") {
60
+ throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
61
+ }
62
+ throw new DemoPrefillError("invalid_url", err.message);
116
63
  }
117
- return url;
118
- }
119
- let addresses;
120
- try {
121
- addresses = await (0, promises_1.lookup)(host, { all: true });
122
- }
123
- catch {
124
- throw new DemoPrefillError("unreachable", "We couldn't reach that site.");
125
- }
126
- if (addresses.length === 0 || addresses.some((a) => isPrivateAddress(a.address))) {
127
- throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
64
+ throw err;
128
65
  }
129
- return url;
130
66
  }
67
+ // REMOVED FOR v1 — kept for reference (superseded by utils/ssrfGuard.ts)
68
+ // // ── SSRF guard ───────────────────────────────────────────────────────────────
69
+ //
70
+ // /** IPv4/IPv6 ranges we must never fetch (cloud metadata, loopback, LAN, etc.). */
71
+ // function isPrivateAddress(ip: string): boolean {
72
+ // const v = isIP(ip);
73
+ // if (v === 4) {
74
+ // const p = ip.split(".").map(Number);
75
+ // if (p.length !== 4 || p.some((n) => Number.isNaN(n))) return true;
76
+ // const a = p[0]!;
77
+ // const b = p[1]!;
78
+ // if (a === 10) return true; // 10.0.0.0/8
79
+ // if (a === 127) return true; // loopback
80
+ // if (a === 0) return true; // "this" network
81
+ // if (a === 169 && b === 254) return true; // link-local incl. 169.254.169.254
82
+ // if (a === 172 && b >= 16 && b <= 31) return true; // 172.16.0.0/12
83
+ // if (a === 192 && b === 168) return true; // 192.168.0.0/16
84
+ // if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT 100.64.0.0/10
85
+ // if (a >= 224) return true; // multicast / reserved
86
+ // return false;
87
+ // }
88
+ // if (v === 6) {
89
+ // const lower = ip.toLowerCase();
90
+ // if (lower === "::1" || lower === "::") return true; // loopback / unspecified
91
+ // if (lower.startsWith("fc") || lower.startsWith("fd")) return true; // ULA fc00::/7
92
+ // if (lower.startsWith("fe80")) return true; // link-local
93
+ // // IPv4-mapped (::ffff:a.b.c.d) — extract and re-check as v4.
94
+ // const mapped = lower.match(/::ffff:(\d+\.\d+\.\d+\.\d+)$/);
95
+ // if (mapped?.[1]) return isPrivateAddress(mapped[1]);
96
+ // return false;
97
+ // }
98
+ // return true; // not an IP literal ⇒ treat as unsafe
99
+ // }
100
+ //
101
+ // /**
102
+ // * Validate a URL is a public http(s) target: parseable, http/https, not a
103
+ // * localhost-ish hostname, and every resolved IP is public. Throws a
104
+ // * DemoPrefillError otherwise. Called on the initial URL AND every redirect hop.
105
+ // */
106
+ // async function assertPublicHttpUrl(raw: string): Promise<URL> {
107
+ // let url: URL;
108
+ // try {
109
+ // url = new URL(raw);
110
+ // } catch {
111
+ // throw new DemoPrefillError("invalid_url", "That doesn't look like a valid URL.");
112
+ // }
113
+ // if (url.protocol !== "http:" && url.protocol !== "https:") {
114
+ // throw new DemoPrefillError("invalid_url", "Only http(s) URLs are supported.");
115
+ // }
116
+ // const host = url.hostname.replace(/^\[|\]$/g, ""); // strip IPv6 brackets
117
+ //
118
+ // // Obvious internal hostnames — reject before any DNS.
119
+ // const lowered = host.toLowerCase();
120
+ // if (
121
+ // lowered === "localhost" ||
122
+ // lowered.endsWith(".localhost") ||
123
+ // lowered.endsWith(".local") ||
124
+ // lowered.endsWith(".internal") ||
125
+ // lowered === "metadata.google.internal"
126
+ // ) {
127
+ // throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
128
+ // }
129
+ //
130
+ // // Literal IP ⇒ check directly; hostname ⇒ resolve every address and check all.
131
+ // if (isIP(host)) {
132
+ // if (isPrivateAddress(host)) {
133
+ // throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
134
+ // }
135
+ // return url;
136
+ // }
137
+ // let addresses: { address: string }[];
138
+ // try {
139
+ // addresses = await lookup(host, { all: true });
140
+ // } catch {
141
+ // throw new DemoPrefillError("unreachable", "We couldn't reach that site.");
142
+ // }
143
+ // if (addresses.length === 0 || addresses.some((a) => isPrivateAddress(a.address))) {
144
+ // throw new DemoPrefillError("blocked_host", "That host isn't reachable.");
145
+ // }
146
+ // return url;
147
+ // }
131
148
  // ── Fetch (SSRF-safe, manual redirects) ──────────────────────────────────────
132
149
  async function safeFetchHtml(initialUrl, deps) {
133
150
  let target = initialUrl;
@@ -11,6 +11,7 @@ export * from "./credit.service";
11
11
  export * from "./notification.service";
12
12
  export * from "./credits/pricing";
13
13
  export * from "./credits/unlimitedPlanImageLimiter";
14
+ export * from "./credits/grant";
14
15
  export * from "./analytics.service";
15
16
  export * from "./providerHealth.service";
16
17
  export * from "./tts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qCAAqC,CAAC;AACpD,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,OAAO,CAAC;AACtB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cA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AAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
@@ -27,6 +27,7 @@ __exportStar(require("./credit.service"), exports);
27
27
  __exportStar(require("./notification.service"), exports);
28
28
  __exportStar(require("./credits/pricing"), exports);
29
29
  __exportStar(require("./credits/unlimitedPlanImageLimiter"), exports);
30
+ __exportStar(require("./credits/grant"), exports);
30
31
  __exportStar(require("./analytics.service"), exports);
31
32
  __exportStar(require("./providerHealth.service"), exports);
32
33
  __exportStar(require("./tts"), exports);
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Pre-generation moderation gate (2026-11-25).
3
+ *
4
+ * WHY: an abuser submitted ~950 generations, 289 of them "undressing" prompts
5
+ * (Korean) against uploaded photos of real people. Every generation surface was
6
+ * reactive-only — the provider rejected mid-flight after credits moved — and
7
+ * nothing tied repeat attempts to the account. This runs BEFORE any charge /
8
+ * enqueue on every generation entry point (REST route middleware, MCP tools,
9
+ * agent execute) and blocks ONLY:
10
+ * - sexual content involving minors (OpenAI `sexual/minors`, any score),
11
+ * - sexual intent combined with an uploaded/reference image (real-person
12
+ * sexualization / "nudify"),
13
+ * - unambiguous text-only sexual content (`sexual` score above a high bar).
14
+ *
15
+ * Deliberately NOT blocked (owner's standing rule, 2026-11-01): violence,
16
+ * horror, action, brands/franchises/IP. Do not add those categories here.
17
+ *
18
+ * FAIL-OPEN: an OpenAI outage / timeout must never take generation down, so any
19
+ * error resolves to `{ blocked: false }` with a logger.warn. The keyword
20
+ * prefilter below still runs without OpenAI, so the exact abuse pattern we saw
21
+ * (undress-intent + photo) is blocked even while OpenAI is unreachable.
22
+ */
23
+ export interface GenerationModerationInput {
24
+ texts: string[];
25
+ imageUrls?: string[];
26
+ }
27
+ export interface GenerationModerationResult {
28
+ blocked: boolean;
29
+ /** Categories that drove the decision (e.g. "sexual/minors", "keyword:undress"). */
30
+ categories: string[];
31
+ /** Internal reason (logged / stored on the strike); not shown verbatim to users. */
32
+ reason?: string;
33
+ /** True when OpenAI could not be consulted and the verdict is prefilter-only. */
34
+ failedOpen?: boolean;
35
+ }
36
+ /** User-facing copy for a blocked generation (422 content_policy_violation). */
37
+ export declare const CONTENT_POLICY_VIOLATION_MESSAGE = "This request can't be generated: it appears to involve sexual content involving minors or sexualizing a real person, which our content policy doesn't allow. Repeated attempts will suspend your account.";
38
+ export declare const CONTENT_POLICY_VIOLATION_CODE = "content_policy_violation";
39
+ export declare function hasUndressIntent(text: string): boolean;
40
+ /**
41
+ * Moderate a generation request's text + image inputs. Never throws.
42
+ */
43
+ export declare function moderateGenerationInput(input: GenerationModerationInput): Promise<GenerationModerationResult>;
44
+ /**
45
+ * Walk an arbitrary request body / plan / tool-args object and collect the
46
+ * creative texts and image URLs that a generation would consume.
47
+ */
48
+ export declare function collectModerationInputs(...roots: unknown[]): {
49
+ texts: string[];
50
+ imageUrls: string[];
51
+ };
52
+ //# sourceMappingURL=generationModeration.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generationModeration.service.d.ts","sourceRoot":"","sources":["../../../src/services/moderation/generationModeration.service.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,gFAAgF;AAChF,eAAO,MAAM,gCAAgC,8MACgK,CAAC;AAE9M,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AA+CxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGtD;AA8CD;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,0BAA0B,CAAC,CAyGrC;AAuBD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG;IAC5D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CA0CA"}