@quatronic/sdk 0.10.1 → 0.11.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.
- package/README.md +6 -0
- package/dist/chunk-JM5LHJUJ.js +32 -0
- package/dist/chunk-JM5LHJUJ.js.map +1 -0
- package/dist/{chunk-YFZB5EW6.js → chunk-P5GBQVO7.js} +2 -2
- package/dist/{chunk-IFESUTF2.js → chunk-VQKYPW5V.js} +7 -3
- package/dist/chunk-VQKYPW5V.js.map +1 -0
- package/dist/{chunk-POZI4OKJ.js → chunk-WOFBDOMY.js} +2 -2
- package/dist/{chunk-TPBRMW5N.js → chunk-YCKDMG4B.js} +30 -1
- package/dist/chunk-YCKDMG4B.js.map +1 -0
- package/dist/chunk-YJZZURE4.js +83 -0
- package/dist/chunk-YJZZURE4.js.map +1 -0
- package/dist/cli/skills-postinstall.js +12 -5
- package/dist/cli/skills.js +10 -4
- package/dist/context-CWvUIBHJ.d.ts +196 -0
- package/dist/eslint/index.d.ts +11 -1
- package/dist/eslint/index.js +123 -4
- package/dist/eslint/index.js.map +1 -1
- package/dist/expo/auth/index.d.ts +14 -0
- package/dist/expo/auth/index.js +324 -0
- package/dist/expo/auth/index.js.map +1 -0
- package/dist/expo/config/index.d.ts +38 -0
- package/dist/expo/config/index.js +35 -0
- package/dist/expo/config/index.js.map +1 -0
- package/dist/expo/log/index.d.ts +9 -0
- package/dist/expo/log/index.js +16 -0
- package/dist/expo/log/index.js.map +1 -0
- package/dist/expo/query/index.d.ts +41 -0
- package/dist/expo/query/index.js +98 -0
- package/dist/expo/query/index.js.map +1 -0
- package/dist/expo/sentry/index.d.ts +33 -0
- package/dist/expo/sentry/index.js +121 -0
- package/dist/expo/sentry/index.js.map +1 -0
- package/dist/expo/testing/index.d.ts +32 -0
- package/dist/expo/testing/index.js +58 -0
- package/dist/expo/testing/index.js.map +1 -0
- package/dist/expo/updates/index.d.ts +51 -0
- package/dist/expo/updates/index.js +163 -0
- package/dist/expo/updates/index.js.map +1 -0
- package/dist/next/auth/index.d.ts +50 -0
- package/dist/next/auth/index.js +523 -101
- package/dist/next/auth/index.js.map +1 -1
- package/dist/next/boot/index.js +3 -3
- package/dist/next/db/index.js +1 -1
- package/dist/next/security/index.d.ts +24 -1
- package/dist/next/security/index.js +29 -0
- package/dist/next/security/index.js.map +1 -1
- package/dist/next/sentry/client.js +3 -3
- package/dist/next/sentry/client.js.map +1 -1
- package/dist/next/sentry/index.js +1 -1
- package/dist/next/sentry/register.js +3 -3
- package/dist/node/sentry/index.js +1 -1
- package/dist/node/sentry/register.js +2 -2
- package/package.json +85 -2
- package/skills/catalog.json +3 -0
- package/skills/qore-add-api-route/SKILL.md +1 -1
- package/skills/qore-add-feature/SKILL.md +1 -1
- package/skills/qore-add-page/SKILL.md +1 -1
- package/skills/qore-debug-issue/SKILL.md +10 -0
- package/skills/qore-mobile-add-screen/SKILL.md +64 -0
- package/skills/qore-mobile-call-server/SKILL.md +75 -0
- package/skills/qore-mobile-run-on-device/SKILL.md +44 -0
- package/skills/qore-observability/SKILL.md +17 -0
- package/skills/qore-secure-io/SKILL.md +15 -0
- package/skills/qore-ship-checklist/SKILL.md +10 -0
- package/skills/qore-translate-strings/SKILL.md +10 -0
- package/skills/qore-use-design-system/SKILL.md +1 -1
- package/skills/qore-use-permissions/SKILL.md +10 -0
- package/dist/chunk-IFESUTF2.js.map +0 -1
- package/dist/chunk-TPBRMW5N.js.map +0 -1
- /package/dist/{chunk-YFZB5EW6.js.map → chunk-P5GBQVO7.js.map} +0 -0
- /package/dist/{chunk-POZI4OKJ.js.map → chunk-WOFBDOMY.js.map} +0 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface ServerResolverOptions {
|
|
5
|
+
/** The Qore portal, e.g. `https://portal.qore.app`. Baked into the build. */
|
|
6
|
+
portalUrl: string;
|
|
7
|
+
/** The tenant's slug in the portal. Baked into the build. */
|
|
8
|
+
tenant: string;
|
|
9
|
+
/** This app's module slug in the portal. Baked into the build. */
|
|
10
|
+
module: string;
|
|
11
|
+
/** The portal environment this build belongs to (`stag`, `acc`, `prod`). */
|
|
12
|
+
env: string;
|
|
13
|
+
/**
|
|
14
|
+
* A fixed server for local development (`EXPO_PUBLIC_SERVER_URL` in
|
|
15
|
+
* `mobile/.env.local`). When set, the portal is never asked.
|
|
16
|
+
*/
|
|
17
|
+
override?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ServerResolver {
|
|
20
|
+
/** The server's origin, without a trailing slash. Throws `ServerUnavailable` when there is none to give. */
|
|
21
|
+
origin(): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Report that a request to `failed` did not reach a server (a network error,
|
|
24
|
+
* not an error status). The next `origin()` asks the portal again, at most
|
|
25
|
+
* once a minute; while the portal cannot answer, the old origin stays.
|
|
26
|
+
*/
|
|
27
|
+
reportUnreachable(failed: string): void;
|
|
28
|
+
/** The origin known right now, or null before the first answer. Synchronous, for Sentry's trace targets. */
|
|
29
|
+
current(): string | null;
|
|
30
|
+
}
|
|
31
|
+
/** No server is known for this build: the portal does not answer and nothing is cached. */
|
|
32
|
+
declare class ServerUnavailable extends Error {
|
|
33
|
+
readonly reason: "not_found" | "unreachable" | "invalid";
|
|
34
|
+
constructor(reason: "not_found" | "unreachable" | "invalid");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Sent on every request by a build that declares its level. */
|
|
38
|
+
declare const API_LEVEL_HEADER = "x-qore-api-level";
|
|
39
|
+
/** Public route on the app's server: `{ apiLevel, minApiLevel }`. */
|
|
40
|
+
declare const APP_VERSION_PATH = "/api/qore/app-version";
|
|
41
|
+
type VersionGate =
|
|
42
|
+
/** The server still serves this build. */
|
|
43
|
+
{
|
|
44
|
+
state: "ok";
|
|
45
|
+
}
|
|
46
|
+
/** The server no longer serves this build: show the upgrade screen. */
|
|
47
|
+
| {
|
|
48
|
+
state: "upgrade";
|
|
49
|
+
minApiLevel: number;
|
|
50
|
+
}
|
|
51
|
+
/** The server could not be asked. Not a reason to block the app. */
|
|
52
|
+
| {
|
|
53
|
+
state: "unknown";
|
|
54
|
+
};
|
|
55
|
+
/** Throws `UpgradeRequired` for a 426 answer; otherwise returns nothing. */
|
|
56
|
+
declare function throwIfUpgradeRequired(res: Response): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Asks the server whether it still serves `apiLevel`. Any failure to ask is
|
|
59
|
+
* `unknown`: an unreachable server must not lock the user out of an app that
|
|
60
|
+
* may still work offline.
|
|
61
|
+
*/
|
|
62
|
+
declare function checkApiLevel(origin: string, apiLevel: number, fetchImpl: typeof fetch): Promise<VersionGate>;
|
|
63
|
+
|
|
64
|
+
/** What `/api/auth/me` answers to a bearer caller. */
|
|
65
|
+
interface Me {
|
|
66
|
+
sub: string;
|
|
67
|
+
email: string | null;
|
|
68
|
+
name: string | null;
|
|
69
|
+
organizationAlias: string | null;
|
|
70
|
+
roles: string[];
|
|
71
|
+
permissions: string[];
|
|
72
|
+
}
|
|
73
|
+
/** Why a login did not produce a session. The server sends all but `cancelled` and `failed` itself. */
|
|
74
|
+
type LoginFailure = "cancelled" | "expired" | "no_app_access" | "identity_mismatch" | "failed";
|
|
75
|
+
type LoginResult = {
|
|
76
|
+
ok: true;
|
|
77
|
+
} | {
|
|
78
|
+
ok: false;
|
|
79
|
+
reason: LoginFailure;
|
|
80
|
+
detail?: string;
|
|
81
|
+
};
|
|
82
|
+
interface MobileAuthOptions {
|
|
83
|
+
/**
|
|
84
|
+
* Where the app's own Next server is, asked by environment from the portal
|
|
85
|
+
* (`createServerResolver`). The device talks to nothing else. Set this or
|
|
86
|
+
* `serverUrl`.
|
|
87
|
+
*/
|
|
88
|
+
server?: ServerResolver;
|
|
89
|
+
/** A fixed server origin instead, e.g. `https://shop.acme.qore.app`. */
|
|
90
|
+
serverUrl?: string;
|
|
91
|
+
/** Sent as `X-Qore-App-Version` on every request, so server logs say which build called. */
|
|
92
|
+
appVersion?: string;
|
|
93
|
+
/**
|
|
94
|
+
* The server API level this build was written against (the template's
|
|
95
|
+
* `mobile/src/config/api-level.ts`). Sent as `X-Qore-Api-Level`; a server
|
|
96
|
+
* that no longer serves it answers 426, which `apiFetch` throws as
|
|
97
|
+
* `UpgradeRequired`.
|
|
98
|
+
*/
|
|
99
|
+
apiLevel?: number;
|
|
100
|
+
}
|
|
101
|
+
interface MobileAuth {
|
|
102
|
+
login(locale: string): Promise<LoginResult>;
|
|
103
|
+
logout(): Promise<void>;
|
|
104
|
+
/** Fetch a route of the app's own server (`/api/...`) with the session token. Throws `Unauthenticated` on 401 (the token is cleared), `ApiError` on any other error status. */
|
|
105
|
+
apiFetch<T>(path: string, init?: RequestInit): Promise<T>;
|
|
106
|
+
/** Keycloak's "forgot password" page in the system browser. Keycloak mails the link; nothing comes back to the app. */
|
|
107
|
+
openPasswordReset(locale: string): Promise<void>;
|
|
108
|
+
/** Whether a token is stored. Says nothing about whether the server still accepts it. */
|
|
109
|
+
hasSession(): Promise<boolean>;
|
|
110
|
+
/** Whether the server still serves this build's `apiLevel`; `ok` when the build declares none. */
|
|
111
|
+
checkApiLevel(): Promise<VersionGate>;
|
|
112
|
+
/** The server's origin as known right now; empty before the first answer. */
|
|
113
|
+
readonly serverUrl: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The app holds no session, or the server no longer accepts it. Show the login screen. */
|
|
117
|
+
declare class Unauthenticated extends Error {
|
|
118
|
+
constructor();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The server no longer serves this build's API level (HTTP 426). Show the
|
|
122
|
+
* upgrade screen; retrying cannot succeed. `minApiLevel` is what the server
|
|
123
|
+
* asks for, when it said.
|
|
124
|
+
*/
|
|
125
|
+
declare class UpgradeRequired extends Error {
|
|
126
|
+
readonly minApiLevel: number | null;
|
|
127
|
+
constructor(minApiLevel: number | null);
|
|
128
|
+
}
|
|
129
|
+
/** The app's server answered with an error status. `code` is its `{ error }` field, when it sent one. */
|
|
130
|
+
declare class ApiError extends Error {
|
|
131
|
+
readonly status: number;
|
|
132
|
+
readonly code: string | null;
|
|
133
|
+
constructor(status: number, code: string | null);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Why the login screen is showing; the app turns it into text. */
|
|
137
|
+
type SignedOutNotice = {
|
|
138
|
+
reason: "session_ended";
|
|
139
|
+
} | {
|
|
140
|
+
reason: Exclude<LoginFailure, "cancelled">;
|
|
141
|
+
detail?: string;
|
|
142
|
+
};
|
|
143
|
+
type AuthStatus = {
|
|
144
|
+
state: "loading";
|
|
145
|
+
} | {
|
|
146
|
+
state: "signedOut";
|
|
147
|
+
notice?: SignedOutNotice;
|
|
148
|
+
} | {
|
|
149
|
+
state: "signedIn";
|
|
150
|
+
me: Me;
|
|
151
|
+
}
|
|
152
|
+
/** The server could not be reached. The token is kept: a network error is not a logout. */
|
|
153
|
+
| {
|
|
154
|
+
state: "error";
|
|
155
|
+
detail: string;
|
|
156
|
+
};
|
|
157
|
+
interface AuthContextValue {
|
|
158
|
+
status: AuthStatus;
|
|
159
|
+
/** Signs in with Keycloak's pages in `locale`. A cancelled login leaves the status as it was. */
|
|
160
|
+
signIn(locale: string): Promise<void>;
|
|
161
|
+
signOut(): Promise<void>;
|
|
162
|
+
/** Re-reads `/api/auth/me`. */
|
|
163
|
+
refresh(): Promise<void>;
|
|
164
|
+
/** A screen got `Unauthenticated`: the token is already cleared, show the login screen. */
|
|
165
|
+
expire(): void;
|
|
166
|
+
/** The auth client, for `apiFetch` and `openPasswordReset`. */
|
|
167
|
+
auth: MobileAuth;
|
|
168
|
+
}
|
|
169
|
+
interface QoreAuthProviderProps {
|
|
170
|
+
auth: MobileAuth;
|
|
171
|
+
children: ReactNode;
|
|
172
|
+
/** Skip the server entirely and show the login screen, e.g. while the app's config is invalid. */
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
/** Called with the Keycloak subject on sign-in and null on sign-out, e.g. `setTelemetryUser`. Never the email. */
|
|
175
|
+
onUserChange?: (sub: string | null) => void;
|
|
176
|
+
/** Called on a failed login or an unreachable server, for the app's log. Holds no personal data. */
|
|
177
|
+
onProblem?: (event: "auth.login.failed" | "auth.me.unreachable", detail: string) => void;
|
|
178
|
+
}
|
|
179
|
+
declare function QoreAuthProvider({ auth, children, disabled, onUserChange, onProblem }: QoreAuthProviderProps): react.JSX.Element;
|
|
180
|
+
declare function useAuth(): AuthContextValue;
|
|
181
|
+
/** The signed-in user, or null. For screens behind the signed-in guard. */
|
|
182
|
+
declare function useMe(): Me | null;
|
|
183
|
+
/**
|
|
184
|
+
* Whether the signed-in user holds `permission` (the server's
|
|
185
|
+
* `src/lib/permissions.ts`). For showing or hiding UI only: the server checks
|
|
186
|
+
* every request again.
|
|
187
|
+
*/
|
|
188
|
+
declare function useCan(permission: string): boolean;
|
|
189
|
+
/** Renders `children` only when the user holds `permission`; `fallback` otherwise. UI only, like `useCan`. */
|
|
190
|
+
declare function Can({ permission, children, fallback }: {
|
|
191
|
+
permission: string;
|
|
192
|
+
children: ReactNode;
|
|
193
|
+
fallback?: ReactNode;
|
|
194
|
+
}): react.JSX.Element;
|
|
195
|
+
|
|
196
|
+
export { API_LEVEL_HEADER as A, Can as C, type LoginFailure as L, type MobileAuthOptions as M, QoreAuthProvider as Q, type ServerResolverOptions as S, Unauthenticated as U, type VersionGate as V, type MobileAuth as a, type ServerResolver as b, APP_VERSION_PATH as c, ApiError as d, type AuthContextValue as e, type AuthStatus as f, type LoginResult as g, type Me as h, type QoreAuthProviderProps as i, ServerUnavailable as j, type SignedOutNotice as k, UpgradeRequired as l, checkApiLevel as m, useCan as n, useMe as o, throwIfUpgradeRequired as t, useAuth as u };
|
package/dist/eslint/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Rule, Linter } from 'eslint';
|
|
2
2
|
|
|
3
|
+
declare const mobileRules: Record<string, Rule.RuleModule>;
|
|
4
|
+
declare const MOBILE_RULE_IDS: Record<string, string>;
|
|
5
|
+
|
|
3
6
|
declare const observabilityRules: Record<string, Rule.RuleModule>;
|
|
4
7
|
declare const OBSERVABILITY_RULE_IDS: Record<string, string>;
|
|
5
8
|
|
|
@@ -31,6 +34,13 @@ interface QdcSecurityConfigs {
|
|
|
31
34
|
* Separate from `recommended` so a bump does not turn an older app's lint red.
|
|
32
35
|
*/
|
|
33
36
|
observability: Linter.Config[];
|
|
37
|
+
/**
|
|
38
|
+
* For the Expo app in a module's `mobile/` directory, spread from
|
|
39
|
+
* `mobile/eslint.config.js`. Its `src/` is the phone's code: no server
|
|
40
|
+
* imports, no secrets or server variables, and every request through
|
|
41
|
+
* `apiFetch`. The web counterpart is `qdc/no-mobile-import` in `recommended`.
|
|
42
|
+
*/
|
|
43
|
+
expo: Linter.Config[];
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
46
|
* The plugin object, typed explicitly: an inferred type here reaches into
|
|
@@ -47,4 +57,4 @@ interface QdcSecurityPlugin {
|
|
|
47
57
|
declare const configs: QdcSecurityConfigs;
|
|
48
58
|
declare const qdcSecurity: QdcSecurityPlugin;
|
|
49
59
|
|
|
50
|
-
export { OBSERVABILITY_RULE_IDS, type QdcSecurityConfigs, type QdcSecurityPlugin, RULE_IDS, configs, qdcSecurity as default, observabilityRules, rules };
|
|
60
|
+
export { MOBILE_RULE_IDS, OBSERVABILITY_RULE_IDS, type QdcSecurityConfigs, type QdcSecurityPlugin, RULE_IDS, configs, qdcSecurity as default, mobileRules, observabilityRules, rules };
|
package/dist/eslint/index.js
CHANGED
|
@@ -334,6 +334,101 @@ var RULE_IDS = {
|
|
|
334
334
|
"integration-static-call": "QDC-NET-003"
|
|
335
335
|
};
|
|
336
336
|
|
|
337
|
+
// src/eslint/mobile.ts
|
|
338
|
+
var WEB_ONLY = ["@quatronic/sdk/next/", "@quatronic/sdk/node/", "react-dom", "next", "next/"];
|
|
339
|
+
var DEVICE_ONLY = ["@quatronic/sdk/expo/", "react-native", "react-native/", "expo-", "@react-native/", "@react-native-community/"];
|
|
340
|
+
var matches = (source, prefixes) => prefixes.some((p) => p.endsWith("/") || p.endsWith("-") ? source.startsWith(p) : source === p || source.startsWith(`${p}/`));
|
|
341
|
+
function banPrefixes(id, message, prefixes) {
|
|
342
|
+
const text = `${id} - ${message}`;
|
|
343
|
+
return {
|
|
344
|
+
meta: meta(text, "problem"),
|
|
345
|
+
create(context) {
|
|
346
|
+
const report = reporter(context, text);
|
|
347
|
+
const flag = (node) => {
|
|
348
|
+
const source = node.source;
|
|
349
|
+
if (source?.type === "Literal" && typeof source.value === "string" && matches(source.value, prefixes)) report(node);
|
|
350
|
+
};
|
|
351
|
+
return listener({ ImportDeclaration: flag, ImportExpression: flag, ExportAllDeclaration: flag, ExportNamedDeclaration: flag });
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function envName(node) {
|
|
356
|
+
const object = node.object;
|
|
357
|
+
if (object?.type !== "MemberExpression") return null;
|
|
358
|
+
if (object.object?.type !== "Identifier" || object.object.name !== "process") return null;
|
|
359
|
+
if (object.property?.type !== "Identifier" || object.property.name !== "env") return null;
|
|
360
|
+
if (node.property?.type === "Identifier" && !node.computed) return node.property.name ?? null;
|
|
361
|
+
if (node.property?.type === "Literal" && typeof node.property.value === "string") return node.property.value;
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
var SECRET_WORD = /SECRET|TOKEN|PASSWORD|PRIVATE|(^|_)KEY($|_)/;
|
|
365
|
+
var PUBLIC_ALLOWED = /* @__PURE__ */ new Set(["EXPO_PUBLIC_SENTRY_DSN"]);
|
|
366
|
+
var noSecretPublicEnv = {
|
|
367
|
+
meta: meta("QDC-MOB-002 - no secret in an EXPO_PUBLIC_* variable", "problem"),
|
|
368
|
+
create(context) {
|
|
369
|
+
const report = reporter(
|
|
370
|
+
context,
|
|
371
|
+
"QDC-MOB-002 - every EXPO_PUBLIC_* value is compiled into the app and readable by anyone who installs it. A secret belongs on the app's server; call it through apiFetch."
|
|
372
|
+
);
|
|
373
|
+
return listener({
|
|
374
|
+
MemberExpression: (node) => {
|
|
375
|
+
const name = envName(node);
|
|
376
|
+
if (name?.startsWith("EXPO_PUBLIC_") && !PUBLIC_ALLOWED.has(name) && SECRET_WORD.test(name.slice(12))) report(node);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var noPrivateEnv = {
|
|
382
|
+
meta: meta("QDC-MOB-003 - the phone only has EXPO_PUBLIC_* variables", "problem"),
|
|
383
|
+
create(context) {
|
|
384
|
+
const report = reporter(
|
|
385
|
+
context,
|
|
386
|
+
"QDC-MOB-003 - only EXPO_PUBLIC_* variables reach the phone; anything else is undefined at runtime. Server configuration stays on the server."
|
|
387
|
+
);
|
|
388
|
+
return listener({
|
|
389
|
+
MemberExpression: (node) => {
|
|
390
|
+
const name = envName(node);
|
|
391
|
+
if (name && !name.startsWith("EXPO_PUBLIC_") && name !== "NODE_ENV") report(node);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var noRawFetch = {
|
|
397
|
+
meta: meta("QDC-MOB-004 - the phone calls its server through apiFetch", "problem"),
|
|
398
|
+
create(context) {
|
|
399
|
+
const report = reporter(
|
|
400
|
+
context,
|
|
401
|
+
"QDC-MOB-004 - call the app's own server through apiFetch from @quatronic/sdk/expo/auth: it adds the session, the app version and the trace, and refuses any other host. A third-party API is called from the server."
|
|
402
|
+
);
|
|
403
|
+
return listener({
|
|
404
|
+
"CallExpression[callee.name='fetch']": report,
|
|
405
|
+
"CallExpression[callee.type='MemberExpression'][callee.property.name='fetch'][callee.object.name=/^(globalThis|window|global)$/]": report
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var mobileRules = {
|
|
410
|
+
"no-web-import": banPrefixes(
|
|
411
|
+
"QDC-MOB-001",
|
|
412
|
+
"This is the phone app. Server and web entries (@quatronic/sdk/next/*, node/*, react-dom, next) do not run in React Native; use @quatronic/sdk/expo/*.",
|
|
413
|
+
WEB_ONLY
|
|
414
|
+
),
|
|
415
|
+
"no-secret-public-env": noSecretPublicEnv,
|
|
416
|
+
"no-private-env": noPrivateEnv,
|
|
417
|
+
"no-raw-fetch": noRawFetch,
|
|
418
|
+
"no-mobile-import": banPrefixes(
|
|
419
|
+
"QDC-MOB-005",
|
|
420
|
+
"This is the Next app. @quatronic/sdk/expo/*, react-native and expo-* run on the phone only and belong in mobile/.",
|
|
421
|
+
DEVICE_ONLY
|
|
422
|
+
)
|
|
423
|
+
};
|
|
424
|
+
var MOBILE_RULE_IDS = {
|
|
425
|
+
"no-web-import": "QDC-MOB-001",
|
|
426
|
+
"no-secret-public-env": "QDC-MOB-002",
|
|
427
|
+
"no-private-env": "QDC-MOB-003",
|
|
428
|
+
"no-raw-fetch": "QDC-MOB-004",
|
|
429
|
+
"no-mobile-import": "QDC-MOB-005"
|
|
430
|
+
};
|
|
431
|
+
|
|
337
432
|
// src/eslint/observability.ts
|
|
338
433
|
var SENTRY_MODULE = /^@sentry\//;
|
|
339
434
|
var BANNED = /* @__PURE__ */ new Set(["init", "withSentryConfig"]);
|
|
@@ -467,7 +562,7 @@ var OBSERVABILITY_RULE_IDS = {
|
|
|
467
562
|
// src/eslint/index.ts
|
|
468
563
|
var plugin = {
|
|
469
564
|
meta: { name: "@quatronic/sdk/eslint" },
|
|
470
|
-
rules: { ...rules, ...observabilityRules }
|
|
565
|
+
rules: { ...rules, ...observabilityRules, ...mobileRules }
|
|
471
566
|
};
|
|
472
567
|
var SRC_FILES = ["src/**/*.{ts,tsx}"];
|
|
473
568
|
var TEST_FILES = ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"];
|
|
@@ -495,7 +590,9 @@ var recommended = [
|
|
|
495
590
|
"qdc/safe-fetch": "warn",
|
|
496
591
|
"qdc/no-undeclared-external-call": "warn",
|
|
497
592
|
// Advisory too: the call works either way, the portal just cannot list it.
|
|
498
|
-
"qdc/integration-static-call": "warn"
|
|
593
|
+
"qdc/integration-static-call": "warn",
|
|
594
|
+
// The web half of the web/mobile boundary; `configs.expo` holds the other.
|
|
595
|
+
"qdc/no-mobile-import": "error"
|
|
499
596
|
}
|
|
500
597
|
},
|
|
501
598
|
{
|
|
@@ -556,14 +653,36 @@ var observability = [
|
|
|
556
653
|
rules: { "no-console": "off" }
|
|
557
654
|
}
|
|
558
655
|
];
|
|
559
|
-
var
|
|
560
|
-
|
|
656
|
+
var expo = [
|
|
657
|
+
{
|
|
658
|
+
files: SRC_FILES,
|
|
659
|
+
plugins: { qdc: plugin },
|
|
660
|
+
rules: {
|
|
661
|
+
"qdc/no-web-import": "error",
|
|
662
|
+
"qdc/no-secret-public-env": "error",
|
|
663
|
+
"qdc/no-private-env": "error",
|
|
664
|
+
"qdc/no-raw-fetch": "error",
|
|
665
|
+
"qdc/no-string-eval": "error",
|
|
666
|
+
// Phone logs go through `log` from @quatronic/sdk/expo/log, which reaches Sentry.
|
|
667
|
+
"no-console": "error"
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
// Tests stub fetch and print on purpose; the jest setup reads its own env.
|
|
672
|
+
files: [...TEST_FILES, "**/__tests__/**"],
|
|
673
|
+
rules: { "qdc/no-raw-fetch": "off", "qdc/no-private-env": "off", "no-console": "off" }
|
|
674
|
+
}
|
|
675
|
+
];
|
|
676
|
+
var configs = { recommended, warn, observability, expo };
|
|
677
|
+
var qdcSecurity = { ...plugin, configs, RULE_IDS: { ...RULE_IDS, ...MOBILE_RULE_IDS } };
|
|
561
678
|
var eslint_default = qdcSecurity;
|
|
562
679
|
export {
|
|
680
|
+
MOBILE_RULE_IDS,
|
|
563
681
|
OBSERVABILITY_RULE_IDS,
|
|
564
682
|
RULE_IDS,
|
|
565
683
|
configs,
|
|
566
684
|
eslint_default as default,
|
|
685
|
+
mobileRules,
|
|
567
686
|
observabilityRules,
|
|
568
687
|
rules
|
|
569
688
|
};
|