create-signet-app 0.9.1 → 0.9.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-signet-app",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "license": "MIT",
5
5
  "description": "Scaffold a Vite + React + Tailwind app wired to Signet.",
6
6
  "keywords": [
@@ -2,7 +2,7 @@ import { ApiError, createApiClient, errorCopy } from "@dapplelight/signet-lib/ap
2
2
  import { queryDefaults } from "@dapplelight/signet-lib/api/query-client"
3
3
  import { QueryClient } from "@tanstack/react-query"
4
4
  import { analytics } from "./analytics"
5
- import { API_URL } from "./config"
5
+ import { API_URL, USER_AGENT } from "./config"
6
6
  import { session } from "./session"
7
7
 
8
8
  export const queryClient = new QueryClient({ defaultOptions: queryDefaults() })
@@ -18,7 +18,7 @@ export const api = createApiClient({
18
18
  credentials: "omit",
19
19
  token: session.token,
20
20
  refresh: session.refresh,
21
- headers: () => analytics.headers(),
21
+ headers: async () => ({ ...(await analytics.headers()), "User-Agent": USER_AGENT }),
22
22
  onAuthError: () => void session.clear(),
23
23
  })
24
24
 
@@ -1,4 +1,5 @@
1
1
  import Constants from "expo-constants"
2
+ import { Platform } from "react-native"
2
3
 
3
4
  /** What app.config.ts put in `extra`, read once. */
4
5
  const extra = (Constants.expoConfig?.extra ?? {}) as {
@@ -12,3 +13,15 @@ export const API_URL = (extra.apiUrl ?? "http://localhost:3000").replace(/\/$/,
12
13
  export const ANALYTICS_URL = extra.analyticsUrl
13
14
  export const EAS_PROJECT_ID = extra.eas?.projectId
14
15
  export const APP_VERSION = Constants.expoConfig?.version ?? "0.0.0"
16
+
17
+ /**
18
+ * Sent as User-Agent: the server names each session after it (the Devices
19
+ * tab), and React Native's own is "okhttp/…" on Android, CFNetwork on iOS.
20
+ * Header values must be printable ASCII (okhttp throws otherwise, failing every
21
+ * request), and the app name is whatever the developer typed, so strip the rest.
22
+ */
23
+ const model = (Platform.constants as { Model?: string }).Model
24
+ const ascii = (s: string) => s.replace(/[^\x20-\x7e]/g, "").trim()
25
+ export const USER_AGENT = `${ascii(Constants.expoConfig?.name ?? "") || "app"}/${ascii(APP_VERSION)} (${
26
+ Platform.OS === "ios" ? "iPhone; iOS" : "Android"
27
+ } ${Platform.Version}${model && ascii(model) ? `; ${ascii(model)}` : ""})`