feat: x-app-platform header
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { AppType } from "@follow/shared"
|
||||
import { env } from "@follow/shared/env.desktop"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
import PKG from "@pkg"
|
||||
import { hc } from "hono/client"
|
||||
import { ofetch } from "ofetch"
|
||||
@@ -10,7 +11,7 @@ import { WindowManager } from "~/manager/window"
|
||||
import { logger } from "../logger"
|
||||
|
||||
const abortController = new AbortController()
|
||||
export const apiFetch = ofetch.create({
|
||||
const apiFetch = ofetch.create({
|
||||
baseURL: env.VITE_API_URL,
|
||||
credentials: "include",
|
||||
signal: abortController.signal,
|
||||
@@ -36,12 +37,12 @@ export const apiClient = hc<AppType>("", {
|
||||
cookie.name.includes(BETTER_AUTH_COOKIE_NAME_SESSION_TOKEN),
|
||||
)
|
||||
const headerCookie = sessionCookie ? `${sessionCookie.name}=${sessionCookie.value}` : ""
|
||||
const userAgent = window?.webContents.getUserAgent() || `Folo/${PKG.version}`
|
||||
|
||||
return {
|
||||
"X-App-Version": PKG.version,
|
||||
"X-App-Dev": process.env.NODE_ENV === "development" ? "1" : "0",
|
||||
...createDesktopAPIHeaders({ version: PKG.version }),
|
||||
Cookie: headerCookie,
|
||||
"User-Agent": `Folo/${PKG.version}`,
|
||||
"User-Agent": userAgent,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DEV } from "@follow/shared/constants"
|
||||
import { env } from "@follow/shared/env.desktop"
|
||||
import type { AppType } from "@follow/shared/hono"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
import PKG from "@pkg"
|
||||
import { hc } from "hono/client"
|
||||
import { FetchError, ofetch } from "ofetch"
|
||||
@@ -21,11 +22,12 @@ export const apiFetch = ofetch.create({
|
||||
onRequest: ({ options }) => {
|
||||
const header = new Headers(options.headers)
|
||||
|
||||
header.set("X-App-Version", PKG.version)
|
||||
if (DEV) {
|
||||
header.set("X-App-Dev", "1")
|
||||
}
|
||||
header.set("X-App-Name", "Folo Web")
|
||||
const headers = createDesktopAPIHeaders({ version: PKG.version })
|
||||
|
||||
Object.entries(headers).forEach(([key, value]) => {
|
||||
header.set(key, value)
|
||||
})
|
||||
|
||||
header.set("X-Client-Id", getClientId())
|
||||
header.set("X-Session-Id", getSessionId())
|
||||
options.headers = header
|
||||
@@ -87,14 +89,6 @@ export const apiClient = hc<AppType>(env.VITE_API_URL, {
|
||||
}
|
||||
throw err
|
||||
}),
|
||||
headers() {
|
||||
return {
|
||||
"X-App-Version": PKG.version,
|
||||
"X-App-Name": "Folo Web",
|
||||
"X-Client-Id": getClientId(),
|
||||
"X-Session-Id": getSessionId(),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
if (DEV) {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { Auth } from "@follow/shared/auth"
|
||||
import { env } from "@follow/shared/env.desktop"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
import PKG from "@pkg"
|
||||
|
||||
const headers = createDesktopAPIHeaders({ version: PKG.version })
|
||||
|
||||
const auth = new Auth({
|
||||
apiURL: env.VITE_API_URL,
|
||||
webURL: env.VITE_WEB_URL,
|
||||
fetchOptions: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
|
||||
export const { authClient } = auth
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
"react-native-awesome-slider": "2.9.0",
|
||||
"react-native-bouncy-checkbox": "4.1.2",
|
||||
"react-native-color-matrix-image-filters": "7.0.2",
|
||||
"react-native-device-info": "14.0.4",
|
||||
"react-native-gesture-handler": "2.26.0",
|
||||
"react-native-image-colors": "2.4.0",
|
||||
"react-native-ios-context-menu": "3.1.2",
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
/* eslint-disable no-console */
|
||||
import type { AppType } from "@follow/shared"
|
||||
import { userActions } from "@follow/store/user/store"
|
||||
import { createMobileAPIHeaders } from "@follow/utils/headers"
|
||||
import { nativeApplicationVersion } from "expo-application"
|
||||
import { hc } from "hono/client"
|
||||
import { FetchError, ofetch } from "ofetch"
|
||||
import { Platform } from "react-native"
|
||||
import DeviceInfo from "react-native-device-info"
|
||||
|
||||
import { InvitationScreen } from "../screens/(modal)/InvitationScreen"
|
||||
import { getCookie } from "./auth"
|
||||
@@ -25,6 +29,19 @@ export const apiFetch = ofetch.create({
|
||||
// add cookie
|
||||
options.headers = options.headers || new Headers()
|
||||
options.headers.set("cookie", getCookie())
|
||||
|
||||
const headers = createMobileAPIHeaders({
|
||||
version: nativeApplicationVersion || "",
|
||||
rnPlatform: {
|
||||
OS: Platform.OS,
|
||||
isPad: Platform.OS === "ios" && Platform.isPad,
|
||||
},
|
||||
installerPackageName: await DeviceInfo.getInstallerPackageName(),
|
||||
})
|
||||
|
||||
Object.entries(headers).forEach(([key, value]) => {
|
||||
options.headers.set(key, value)
|
||||
})
|
||||
},
|
||||
onRequestError: ({ error, request, options }) => {
|
||||
if (__DEV__) {
|
||||
@@ -66,7 +83,6 @@ export const apiClient = hc<AppType>(proxyEnv.API_URL, {
|
||||
}),
|
||||
async headers() {
|
||||
return {
|
||||
"X-App-Name": "Folo Mobile",
|
||||
cookie: getCookie(),
|
||||
"User-Agent": await getUserAgent(),
|
||||
"X-Client-Id": getClientId(),
|
||||
|
||||
@@ -40,6 +40,7 @@ const plugins = [
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: `${proxyEnv.API_URL}/better-auth`,
|
||||
plugins,
|
||||
// TODO: add x-app-platform, x-app-version headers
|
||||
})
|
||||
|
||||
// @keep-sorted
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
import { env } from "@follow/shared/env.ssr"
|
||||
import type { AppType } from "@follow/shared/hono"
|
||||
import { createSSRAPIHeaders } from "@follow/utils/headers"
|
||||
import { hc } from "hono/client"
|
||||
import { ofetch } from "ofetch"
|
||||
|
||||
import PKG from "../../../desktop/package.json"
|
||||
|
||||
const apiFetch = ofetch.create({
|
||||
credentials: "include",
|
||||
retry: false,
|
||||
onRequest: ({ options }) => {
|
||||
const header = new Headers(options.headers)
|
||||
|
||||
header.set("x-app-version", "Web External")
|
||||
const headers = createSSRAPIHeaders({ version: PKG.version })
|
||||
|
||||
Object.entries(headers).forEach(([key, value]) => {
|
||||
header.set(key, value)
|
||||
})
|
||||
|
||||
options.headers = header
|
||||
},
|
||||
})
|
||||
@@ -19,9 +27,4 @@ export const apiClient = hc<AppType>(env.VITE_EXTERNAL_API_URL || env.VITE_API_U
|
||||
apiFetch(input.toString(), options).catch((err) => {
|
||||
throw err
|
||||
}),
|
||||
headers() {
|
||||
return {
|
||||
"X-App-Version": "Web External",
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import { Auth } from "@follow/shared/auth"
|
||||
import { env } from "@follow/shared/env.ssr"
|
||||
import { createDesktopAPIHeaders } from "@follow/utils/headers"
|
||||
|
||||
import PKG from "../../../desktop/package.json"
|
||||
|
||||
const headers = createDesktopAPIHeaders({ version: PKG.version })
|
||||
|
||||
const auth = new Auth({
|
||||
apiURL: env.VITE_API_URL,
|
||||
webURL: env.VITE_WEB_URL,
|
||||
fetchOptions: {
|
||||
headers,
|
||||
},
|
||||
})
|
||||
|
||||
// @keep-sorted
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Object.assign(globalThis, {
|
||||
APP_NAME: "Folo",
|
||||
ELECTRON: false,
|
||||
})
|
||||
|
||||
try {
|
||||
|
||||
@@ -3,6 +3,7 @@ import "./load-env"
|
||||
import { requestContext } from "@fastify/request-context"
|
||||
import { env } from "@follow/shared/env.ssr"
|
||||
import type { AppType } from "@follow/shared/hono"
|
||||
import { createSSRAPIHeaders } from "@follow/utils/headers"
|
||||
import { hc } from "hono/client"
|
||||
import { ofetch } from "ofetch"
|
||||
|
||||
@@ -35,7 +36,15 @@ export const createApiFetch = () => {
|
||||
onRequest(context) {
|
||||
if (__DEV__) console.info(`request: ${context.request}`)
|
||||
|
||||
context.options.headers.set("User-Agent", `Folo External Server Api Client/${PKG.version}`)
|
||||
const header = new Headers(context.options.headers)
|
||||
|
||||
const headers = createSSRAPIHeaders({ version: PKG.version })
|
||||
|
||||
Object.entries(headers).forEach(([key, value]) => {
|
||||
header.set(key, value)
|
||||
})
|
||||
|
||||
context.options.headers = header
|
||||
},
|
||||
onRequestError(context) {
|
||||
if (context.error.name === "AbortError") {
|
||||
@@ -55,8 +64,6 @@ export const createApiClient = () => {
|
||||
fetch: async (input: any, options = {}) => apiFetch(input.toString(), options),
|
||||
headers() {
|
||||
return {
|
||||
"X-App-Version": PKG.version,
|
||||
"X-App-Dev": __DEV__ ? "1" : "0",
|
||||
"User-Agent": `Folo External Server Api Client/${PKG.version}`,
|
||||
Cookie: authSessionToken ? `__Secure-better-auth.session_token=${authSessionToken}` : "",
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IN_ELECTRON } from "@follow/shared"
|
||||
import type { authPlugins } from "@follow/shared/hono"
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client"
|
||||
import type { BetterAuthClientPlugin, BetterFetchOption } from "better-auth/client"
|
||||
import { inferAdditionalFields, twoFactorClient } from "better-auth/client/plugins"
|
||||
import { createAuthClient } from "better-auth/react"
|
||||
|
||||
@@ -44,11 +44,13 @@ export class Auth {
|
||||
private readonly options: {
|
||||
apiURL: string
|
||||
webURL: string
|
||||
fetchOptions?: BetterFetchOption
|
||||
},
|
||||
) {
|
||||
this.authClient = createAuthClient({
|
||||
baseURL: `${this.options.apiURL}/better-auth`,
|
||||
plugins: baseAuthPlugins,
|
||||
fetchOptions: this.options.fetchOptions,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1077,6 +1077,98 @@ declare const actionsRelations: drizzle_orm.Relations<"actions", {
|
||||
type ActionsModel = z.infer<typeof actionsOpenAPISchema>;
|
||||
type SettingsModel = Exclude<z.infer<typeof actionsItemOpenAPISchema>["result"], undefined>;
|
||||
|
||||
declare const activities: drizzle_orm_pg_core.PgTableWithColumns<{
|
||||
name: "activities";
|
||||
schema: undefined;
|
||||
columns: {
|
||||
userId: drizzle_orm_pg_core.PgColumn<{
|
||||
name: "user_id";
|
||||
tableName: "activities";
|
||||
dataType: "string";
|
||||
columnType: "PgText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
activeAt: drizzle_orm_pg_core.PgColumn<{
|
||||
name: "active_at";
|
||||
tableName: "activities";
|
||||
dataType: "date";
|
||||
columnType: "PgDate";
|
||||
data: Date;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: undefined;
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
platform: drizzle_orm_pg_core.PgColumn<{
|
||||
name: "platform";
|
||||
tableName: "activities";
|
||||
dataType: "string";
|
||||
columnType: "PgText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: true;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
version: drizzle_orm_pg_core.PgColumn<{
|
||||
name: "version";
|
||||
tableName: "activities";
|
||||
dataType: "string";
|
||||
columnType: "PgText";
|
||||
data: string;
|
||||
driverParam: string;
|
||||
notNull: false;
|
||||
hasDefault: false;
|
||||
isPrimaryKey: false;
|
||||
isAutoincrement: false;
|
||||
hasRuntimeDefault: false;
|
||||
enumValues: [string, ...string[]];
|
||||
baseColumn: never;
|
||||
identity: undefined;
|
||||
generated: undefined;
|
||||
}, {}, {}>;
|
||||
};
|
||||
dialect: "pg";
|
||||
}>;
|
||||
declare const activitiesOpenAPISchema: zod.ZodObject<{
|
||||
userId: zod.ZodString;
|
||||
activeAt: zod.ZodString;
|
||||
platform: zod.ZodString;
|
||||
version: zod.ZodNullable<zod.ZodString>;
|
||||
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
|
||||
userId: string;
|
||||
activeAt: string;
|
||||
platform: string;
|
||||
version: string | null;
|
||||
}, {
|
||||
userId: string;
|
||||
activeAt: string;
|
||||
platform: string;
|
||||
version: string | null;
|
||||
}>;
|
||||
|
||||
declare const detailModelSchema: z.ZodNullable<z.ZodObject<{
|
||||
"Invitations count": z.ZodNumber;
|
||||
"Purchase lists cost": z.ZodNumber;
|
||||
@@ -19417,6 +19509,23 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
|
||||
input: {};
|
||||
output: {
|
||||
code: 0;
|
||||
data: {
|
||||
successfulItems: {
|
||||
id?: string | undefined;
|
||||
title?: string | null | undefined;
|
||||
url?: string | undefined;
|
||||
}[];
|
||||
conflictItems: {
|
||||
id: string;
|
||||
url: string;
|
||||
title?: string | null | undefined;
|
||||
}[];
|
||||
parsedErrorItems: {
|
||||
url: string;
|
||||
id?: string | undefined;
|
||||
title?: string | null | undefined;
|
||||
}[];
|
||||
};
|
||||
};
|
||||
outputFormat: "json";
|
||||
status: 200;
|
||||
@@ -20942,4 +21051,4 @@ declare const _routes: hono_hono_base.HonoBase<Env, ({
|
||||
}, "/data">, "/">;
|
||||
type AppType = typeof _routes;
|
||||
|
||||
export { type ActionItem, type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type ExtraModel, type FeedModel, type ListModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, type UrlReadsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, captcha, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, extraZodSchema, feedAnalytics, feedAnalyticsOpenAPISchema, feedAnalyticsRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, listAnalytics, listAnalyticsOpenAPISchema, listAnalyticsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, readabilities, rsshub, rsshubAnalytics, rsshubAnalyticsOpenAPISchema, rsshubOpenAPISchema, rsshubPurchase, rsshubUsage, rsshubUsageOpenAPISchema, rsshubUsageRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, trendingFeeds, trendingFeedsOpenAPISchema, trendingFeedsRelations, twoFactor, uploads, urlReads, urlReadsOpenAPISchema, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations };
|
||||
export { type ActionItem, type ActionsModel, type AirdropActivity, type AppType, type AttachmentsModel, type AuthSession, type AuthUser, CommonEntryFields, type ConditionItem, type DetailModel, type EntriesModel, type ExtraModel, type FeedModel, type ListModel, type MediaModel, type MessagingData, MessagingType, type SettingsModel, type UrlReadsModel, account, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, activities, activitiesOpenAPISchema, activityEnum, airdrops, airdropsOpenAPISchema, attachmentsZodSchema, authPlugins, boosts, captcha, collections, collectionsOpenAPISchema, collectionsRelations, detailModelSchema, entries, entriesOpenAPISchema, entriesRelations, extraZodSchema, feedAnalytics, feedAnalyticsOpenAPISchema, feedAnalyticsRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsOpenAPISchema, feedsRelations, inboxHandleSchema, inboxes, inboxesEntries, inboxesEntriesInsertOpenAPISchema, type inboxesEntriesModel, inboxesEntriesOpenAPISchema, inboxesEntriesRelations, inboxesOpenAPISchema, inboxesRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, levels, levelsOpenAPISchema, levelsRelations, listAnalytics, listAnalyticsOpenAPISchema, listAnalyticsRelations, lists, listsOpenAPISchema, listsRelations, listsSubscriptions, listsSubscriptionsOpenAPISchema, listsSubscriptionsRelations, lower, mediaZodSchema, messaging, messagingOpenAPISchema, messagingRelations, readabilities, rsshub, rsshubAnalytics, rsshubAnalyticsOpenAPISchema, rsshubOpenAPISchema, rsshubPurchase, rsshubUsage, rsshubUsageOpenAPISchema, rsshubUsageRelations, session, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, trendingFeeds, trendingFeedsOpenAPISchema, trendingFeedsRelations, twoFactor, uploads, urlReads, urlReadsOpenAPISchema, user, users, usersOpenApiSchema, usersRelations, verification, wallets, walletsOpenAPISchema, walletsRelations };
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { DEV, WEB_BUILD } from "@follow/shared/constants"
|
||||
|
||||
import { imageRefererMatches } from "./img-proxy"
|
||||
|
||||
export const createBuildSafeHeaders =
|
||||
@@ -47,3 +49,107 @@ export const createBuildSafeHeaders =
|
||||
|
||||
return headers
|
||||
}
|
||||
|
||||
enum DesktopPlatform {
|
||||
Desktop = "desktop",
|
||||
DesktopWeb = "desktop/web",
|
||||
DesktopMacOS = "desktop/macos",
|
||||
DesktopMacOSDMG = "desktop/macos/dmg",
|
||||
DesktopMacOSMAS = "desktop/macos/mas",
|
||||
DesktopWindowsEXE = "desktop/windows/exe",
|
||||
DesktopWindowsMS = "desktop/windows/ms",
|
||||
DesktopLinux = "desktop/linux",
|
||||
}
|
||||
|
||||
export const createDesktopAPIHeaders = ({ version }: { version: string }) => {
|
||||
let platform: DesktopPlatform | null = null
|
||||
|
||||
if (WEB_BUILD) {
|
||||
platform = DesktopPlatform.DesktopWeb
|
||||
} else if (typeof process !== "undefined") {
|
||||
switch (process.platform) {
|
||||
case "darwin": {
|
||||
if (process.mas) {
|
||||
platform = DesktopPlatform.DesktopMacOSMAS
|
||||
} else {
|
||||
platform = DesktopPlatform.DesktopMacOSDMG
|
||||
}
|
||||
break
|
||||
}
|
||||
case "win32": {
|
||||
if (process.windowsStore) {
|
||||
platform = DesktopPlatform.DesktopWindowsMS
|
||||
} else {
|
||||
platform = DesktopPlatform.DesktopWindowsEXE
|
||||
}
|
||||
break
|
||||
}
|
||||
case "linux": {
|
||||
platform = DesktopPlatform.DesktopLinux
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...(platform ? { "X-App-Platform": platform } : {}),
|
||||
"X-App-Name": "Folo Web",
|
||||
"X-App-Version": version,
|
||||
...(DEV ? { "X-App-Dev": "1" } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
enum SSRPlatform {
|
||||
SSR = "ssr",
|
||||
}
|
||||
|
||||
export const createSSRAPIHeaders = ({ version }: { version: string }) => {
|
||||
return {
|
||||
"X-App-Platform": SSRPlatform.SSR,
|
||||
"X-App-Name": "Folo SSR",
|
||||
"X-App-Version": version,
|
||||
...(DEV ? { "X-App-Dev": "1" } : {}),
|
||||
}
|
||||
}
|
||||
|
||||
enum MobilePlatform {
|
||||
MobileIOSiPhone = "mobile/ios/iphone",
|
||||
MobileIOSiPad = "mobile/ios/ipad",
|
||||
MobileAndroidAPK = "mobile/android/apk",
|
||||
MobileAndroidGooglePlay = "mobile/android/googleplay",
|
||||
}
|
||||
|
||||
export const createMobileAPIHeaders = ({
|
||||
version,
|
||||
rnPlatform,
|
||||
installerPackageName,
|
||||
}: {
|
||||
version: string
|
||||
rnPlatform: {
|
||||
OS: "ios" | "android" | "windows" | "macos" | "web"
|
||||
isPad: boolean
|
||||
}
|
||||
installerPackageName?: string
|
||||
}) => {
|
||||
let platform: MobilePlatform | null = null
|
||||
|
||||
if (rnPlatform.OS === "ios") {
|
||||
if (rnPlatform.isPad) {
|
||||
platform = MobilePlatform.MobileIOSiPad
|
||||
} else {
|
||||
platform = MobilePlatform.MobileIOSiPhone
|
||||
}
|
||||
} else if (rnPlatform.OS === "android") {
|
||||
if (installerPackageName === "com.android.vending") {
|
||||
platform = MobilePlatform.MobileAndroidGooglePlay
|
||||
} else {
|
||||
platform = MobilePlatform.MobileAndroidAPK
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...(platform ? { "X-App-Platform": platform } : {}),
|
||||
"X-App-Name": "Folo Mobile",
|
||||
"X-App-Version": version,
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+18
-21
@@ -976,7 +976,7 @@ importers:
|
||||
version: 1.4.1
|
||||
posthog-react-native:
|
||||
specifier: 4.1.3
|
||||
version: 4.1.3(2121d6ac0841ff6678f1ed39c5b47959)
|
||||
version: 4.1.3(79cf2c8a1f8799a2678807a7f0a97f8a)
|
||||
qrcode:
|
||||
specifier: 1.5.4
|
||||
version: 1.5.4
|
||||
@@ -1007,6 +1007,9 @@ importers:
|
||||
react-native-color-matrix-image-filters:
|
||||
specifier: 7.0.2
|
||||
version: 7.0.2(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0)
|
||||
react-native-device-info:
|
||||
specifier: 14.0.4
|
||||
version: 14.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))
|
||||
react-native-gesture-handler:
|
||||
specifier: 2.26.0
|
||||
version: 2.26.0(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0)
|
||||
@@ -1739,7 +1742,7 @@ importers:
|
||||
version: 1.255.0
|
||||
posthog-react-native:
|
||||
specifier: ^4.1.3
|
||||
version: 4.1.3(2121d6ac0841ff6678f1ed39c5b47959)
|
||||
version: 4.1.3(79cf2c8a1f8799a2678807a7f0a97f8a)
|
||||
devDependencies:
|
||||
'@follow/configs':
|
||||
specifier: workspace:*
|
||||
@@ -13114,6 +13117,11 @@ packages:
|
||||
react-native-svg:
|
||||
optional: true
|
||||
|
||||
react-native-device-info@14.0.4:
|
||||
resolution: {integrity: sha512-NX0wMAknSDBeFnEnSFQ8kkAcQrFHrG4Cl0mVjoD+0++iaKrOupiGpBXqs8xR0SeJyPC5zpdPl4h/SaBGly6UxA==}
|
||||
peerDependencies:
|
||||
react-native: '*'
|
||||
|
||||
react-native-edge-to-edge@1.6.0:
|
||||
resolution: {integrity: sha512-2WCNdE3Qd6Fwg9+4BpbATUxCLcouF6YRY7K+J36KJ4l3y+tWN6XCqAC4DuoGblAAbb2sLkhEDp4FOlbOIot2Og==}
|
||||
peerDependencies:
|
||||
@@ -21460,7 +21468,7 @@ snapshots:
|
||||
debug: 2.6.9
|
||||
invariant: 2.2.4
|
||||
metro: 0.82.4(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
||||
metro-config: 0.82.4(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
||||
metro-config: 0.82.4(bufferutil@4.0.9)
|
||||
metro-core: 0.82.4
|
||||
semver: 7.7.2
|
||||
transitivePeerDependencies:
|
||||
@@ -28731,22 +28739,6 @@ snapshots:
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
|
||||
metro-config@0.82.4(bufferutil@4.0.9)(utf-8-validate@6.0.5):
|
||||
dependencies:
|
||||
connect: 3.7.0
|
||||
cosmiconfig: 5.2.1
|
||||
flow-enums-runtime: 0.0.6
|
||||
jest-validate: 29.7.0
|
||||
metro: 0.82.4(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
||||
metro-cache: 0.82.4
|
||||
metro-core: 0.82.4
|
||||
metro-runtime: 0.82.4
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
metro-core@0.82.4:
|
||||
dependencies:
|
||||
flow-enums-runtime: 0.0.6
|
||||
@@ -28932,7 +28924,7 @@ snapshots:
|
||||
metro-babel-transformer: 0.82.4
|
||||
metro-cache: 0.82.4
|
||||
metro-cache-key: 0.82.4
|
||||
metro-config: 0.82.4(bufferutil@4.0.9)(utf-8-validate@6.0.5)
|
||||
metro-config: 0.82.4(bufferutil@4.0.9)
|
||||
metro-core: 0.82.4
|
||||
metro-file-map: 0.82.4
|
||||
metro-resolver: 0.82.4
|
||||
@@ -30220,7 +30212,7 @@ snapshots:
|
||||
preact: 10.26.9
|
||||
web-vitals: 4.2.4
|
||||
|
||||
posthog-react-native@4.1.3(2121d6ac0841ff6678f1ed39c5b47959):
|
||||
posthog-react-native@4.1.3(79cf2c8a1f8799a2678807a7f0a97f8a):
|
||||
dependencies:
|
||||
react-native-svg: 15.12.0(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0)
|
||||
optionalDependencies:
|
||||
@@ -30228,6 +30220,7 @@ snapshots:
|
||||
expo-device: 7.1.4(expo@53.0.12(@babel/core@7.27.4)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))
|
||||
expo-file-system: 18.1.10(expo@53.0.12(@babel/core@7.27.4)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))
|
||||
expo-localization: 16.1.5(expo@53.0.12(@babel/core@7.27.4)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react@19.0.0)
|
||||
react-native-device-info: 14.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))
|
||||
react-native-safe-area-context: 5.4.1(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0)
|
||||
|
||||
postject@1.0.0-alpha.6:
|
||||
@@ -30556,6 +30549,10 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
react-native-device-info@14.0.4(react-native@0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)):
|
||||
dependencies:
|
||||
react-native: 0.79.1(@babel/core@7.27.4)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)
|
||||
|
||||
react-native-edge-to-edge@1.6.0(react-native@0.79.1(@babel/core@7.26.10)(@types/react@19.1.6)(bufferutil@4.0.9)(react@19.0.0)(utf-8-validate@6.0.5))(react@19.0.0):
|
||||
dependencies:
|
||||
react: 19.0.0
|
||||
|
||||
Reference in New Issue
Block a user