create-signet-app 0.9.0 → 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.0",
3
+ "version": "0.9.2",
4
4
  "license": "MIT",
5
5
  "description": "Scaffold a Vite + React + Tailwind app wired to Signet.",
6
6
  "keywords": [
package/src/mobile.ts CHANGED
@@ -9,9 +9,12 @@
9
9
  export const MOBILE_PKG = {
10
10
  main: "expo-router/entry",
11
11
  scripts: {
12
- start: "expo start",
13
- android: "expo start --android",
14
- ios: "expo start --ios",
12
+ // --go: Expo Go, since expo-dev-client otherwise expects a development
13
+ // build to be installed. start:dev is for that build (push needs it).
14
+ start: "expo start --go",
15
+ android: "expo start --go --android",
16
+ ios: "expo start --go --ios",
17
+ "start:dev": "expo start --dev-client",
15
18
  lint: "biome check .",
16
19
  format: "biome check --write .",
17
20
  typecheck: "tsc --noEmit",
@@ -97,6 +97,9 @@ __PM_X__ eas-cli init # creates the project; put its id in EAS_PROJEC
97
97
  __PM_X__ eas-cli build --profile development --platform ios # or android
98
98
  ```
99
99
 
100
+ Once it is installed, run `__PM_RUN__ start:dev` instead of `start` (which
101
+ opens Expo Go).
102
+
100
103
  `eas.json` has three profiles: `development` (a development build with the dev
101
104
  client, for push and native debugging), `preview` (an internal build to share)
102
105
  and `production` (store builds, version numbers kept by EAS). Change the
@@ -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)}` : ""})`
@@ -1,6 +1,19 @@
1
- import { randomUUID } from "expo-crypto"
2
-
3
1
  // Signet's outbox and analytics call crypto.randomUUID, which Hermes lacks.
2
+ // expo-crypto supplies it in a development or store build; an Expo Go build
3
+ // without the ExpoCrypto native module falls back to Math.random.
4
+ // ponytail: Math.random v4 ids are fine for outbox and analytics ids, not for secrets.
4
5
  const g = globalThis as { crypto?: { randomUUID?: () => string } }
5
6
  g.crypto ??= {}
6
- g.crypto.randomUUID ??= randomUUID
7
+ if (!g.crypto.randomUUID) {
8
+ let native: (() => string) | undefined
9
+ try {
10
+ native = (require("expo-crypto") as { randomUUID: () => string }).randomUUID
11
+ } catch {}
12
+ g.crypto.randomUUID =
13
+ native ??
14
+ (() =>
15
+ "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
16
+ const r = (Math.random() * 16) | 0
17
+ return (c === "x" ? r : (r & 3) | 8).toString(16)
18
+ }))
19
+ }