@flowselections/floriday-authenticatie-module 1.0.22 → 1.0.23

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 (41) hide show
  1. package/dist-lib/integrations/supabase/auth-middleware.d.ts +385 -3
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  3. package/dist-lib/integrations/supabase/client.d.ts +385 -3
  4. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  5. package/dist-lib/integrations/supabase/client.server.d.ts +385 -3
  6. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +389 -3
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/central-auth.server.d.ts +17 -0
  10. package/dist-lib/lib/central-auth.server.d.ts.map +1 -0
  11. package/dist-lib/lib/central-auth.server.js +65 -0
  12. package/dist-lib/lib/floricode.functions.d.ts +2757 -83
  13. package/dist-lib/lib/floricode.functions.d.ts.map +1 -1
  14. package/dist-lib/lib/floriday-auction-letters.functions.d.ts +385 -3
  15. package/dist-lib/lib/floriday-auction-letters.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/floriday-labels.functions.d.ts +385 -3
  17. package/dist-lib/lib/floriday-labels.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/floriday-public.functions.d.ts +2310 -18
  19. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  20. package/dist-lib/lib/floriday-stickers.functions.d.ts +385 -3
  21. package/dist-lib/lib/floriday-stickers.functions.d.ts.map +1 -1
  22. package/dist-lib/lib/floriday-sync.functions.d.ts +12493 -651
  23. package/dist-lib/lib/floriday-sync.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/floriday-writes.functions.d.ts +2310 -18
  25. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/floriday.functions.d.ts +7178 -302
  27. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/floriday.functions.js +9 -21
  29. package/dist-lib/lib/gateway/cache-tables.d.ts +2 -0
  30. package/dist-lib/lib/gateway/cache-tables.d.ts.map +1 -0
  31. package/dist-lib/lib/gateway/cache-tables.js +27 -0
  32. package/dist-lib/lib/gateway/cached-list.d.ts +15 -0
  33. package/dist-lib/lib/gateway/cached-list.d.ts.map +1 -0
  34. package/dist-lib/lib/gateway/cached-list.js +35 -0
  35. package/dist-lib/lib/gateway/index.d.ts +4 -0
  36. package/dist-lib/lib/gateway/index.d.ts.map +1 -0
  37. package/dist-lib/lib/gateway/index.js +3 -0
  38. package/dist-lib/lib/gateway/shared.d.ts +2 -0
  39. package/dist-lib/lib/gateway/shared.d.ts.map +1 -0
  40. package/dist-lib/lib/gateway/shared.js +3 -0
  41. package/package.json +6 -2
@@ -0,0 +1,17 @@
1
+ export type CentralFlorydayTokenResult = {
2
+ ok: true;
3
+ access_token: string;
4
+ expires_at: string;
5
+ raw: {
6
+ status: number;
7
+ body: string;
8
+ };
9
+ } | {
10
+ ok: false;
11
+ raw: {
12
+ status: number;
13
+ body: string;
14
+ };
15
+ };
16
+ export declare function getFlorydayTokenFromCentral(environment: "staging" | "live", scope: string): Promise<CentralFlorydayTokenResult>;
17
+ //# sourceMappingURL=central-auth.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"central-auth.server.d.ts","sourceRoot":"","sources":["../../src/lib/central-auth.server.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,0BAA0B,GAClC;IACE,EAAE,EAAE,IAAI,CAAC;IACT,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC,CAAC;AAEN,wBAAsB,2BAA2B,CAC/C,WAAW,EAAE,SAAS,GAAG,MAAM,EAC/B,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,0BAA0B,CAAC,CAwDrC"}
@@ -0,0 +1,65 @@
1
+ // Server-only: haalt een Floriday-token bij central-auth. Spiegelt de Bearer-
2
+ // signing van de e-mail-tak (@flowselections/core/server → provider-token.js:
3
+ // `Authorization: Bearer ${CENTRAL_AUTH_SECRET}` + `Content-Type: application/json`).
4
+ //
5
+ // Gebruikt bewust NIET core.getProviderToken: die plet de upstream-body naar
6
+ // typed errors, terwijl createFlorydayTokenError (stap B, in floriday.functions.ts)
7
+ // de originele foutsubstrings moet kunnen matchen op `raw.body`. Central plet
8
+ // een mislukte grant naar HTTP 502 { "error": "upstream_error" } — dat is exact
9
+ // waarom raw.body op het niet-ok-pad bewaard moet blijven, letterlijk, zonder
10
+ // wrap of parse.
11
+ //
12
+ // Contract:
13
+ // - Vier faalgevallen (!res.ok, niet-parseerbare body, ontbrekend access_token,
14
+ // ontbrekend expiry) → allemaal { ok: false, raw }. Geen throws.
15
+ // - Alleen een echte netwerkfout (fetch throwt vóór er een response is) gooit;
16
+ // daar bestaat geen raw.
17
+ //
18
+ // NIET importeren vanuit client-code. De .server.ts-suffix houdt dit bestand
19
+ // buiten de client-bundle (zoals bij client.server.ts).
20
+ export async function getFlorydayTokenFromCentral(environment, scope) {
21
+ const baseUrl = process.env.CENTRAL_AUTH_URL;
22
+ const secret = process.env.CENTRAL_AUTH_SECRET;
23
+ if (!baseUrl || !secret) {
24
+ throw new Error("Missing CENTRAL_AUTH_URL or CENTRAL_AUTH_SECRET environment variable.");
25
+ }
26
+ const url = `${baseUrl.replace(/\/+$/, "")}/api/token/floriday`;
27
+ // Netwerkfout (fetch throwt vóór er een response is) → doorgooien, er is
28
+ // geen raw om te retourneren. Alle andere paden gaan via raw.
29
+ const res = await fetch(url, {
30
+ method: "POST",
31
+ headers: {
32
+ Authorization: `Bearer ${secret}`,
33
+ "Content-Type": "application/json",
34
+ },
35
+ body: JSON.stringify({ environment, scope }),
36
+ });
37
+ // Response ALTIJD eerst als tekst lezen — raw.body moet op elk pad gevuld
38
+ // zijn (2xx én niet-ok). Bij niet-ok is dit het enige wat stap B heeft om
39
+ // de oorzaak te bepalen (central plet Floriday-fouten naar 502
40
+ // { "error": "upstream_error" }).
41
+ const text = await res.text();
42
+ const raw = { status: res.status, body: text };
43
+ if (!res.ok) {
44
+ return { ok: false, raw };
45
+ }
46
+ let json;
47
+ try {
48
+ json = JSON.parse(text);
49
+ }
50
+ catch {
51
+ return { ok: false, raw };
52
+ }
53
+ if (typeof json.access_token !== "string" || !json.access_token) {
54
+ return { ok: false, raw };
55
+ }
56
+ const expires_at = typeof json.expires_at === "string" && json.expires_at
57
+ ? json.expires_at
58
+ : typeof json.expires_in === "number"
59
+ ? new Date(Date.now() + json.expires_in * 1000).toISOString()
60
+ : null;
61
+ if (!expires_at) {
62
+ return { ok: false, raw };
63
+ }
64
+ return { ok: true, access_token: json.access_token, expires_at, raw };
65
+ }