Skip to content

Commit 1e4f44b

Browse files
authored
Merge branch 'main' into fix/checkpoint-index-metadata
2 parents f9506c3 + 6c58362 commit 1e4f44b

82 files changed

Lines changed: 7882 additions & 668 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/deploy-relay.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
6464
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
6565
APNS_PRIVATE_KEY: ${{ secrets.APNS_PRIVATE_KEY }}
66+
FCM_SERVICE_ACCOUNT: ${{ secrets.FCM_SERVICE_ACCOUNT }}
6667

6768
- name: Publish relay deploy commit status
6869
uses: actions/github-script@v8
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { expect, it } from "@effect/vitest";
2+
import * as Effect from "effect/Effect";
3+
import { ChildProcessSpawner } from "effect/unstable/process";
4+
import { vi } from "vite-plus/test";
5+
6+
vi.mock("@napi-rs/keyring", () => {
7+
throw new Error("Cannot find native binding");
8+
});
9+
10+
it("loads browser import code without a keyring native binding", async () => {
11+
await expect(import("./ChromiumKeys.ts")).resolves.toBeDefined();
12+
});
13+
14+
it.effect("reports an unavailable keychain when the macOS binding cannot load", () =>
15+
Effect.gen(function* () {
16+
const { ChromiumKeyError, resolveChromiumKeys } = yield* Effect.promise(
17+
() => import("./ChromiumKeys.ts"),
18+
);
19+
const error = yield* resolveChromiumKeys({
20+
platform: "darwin",
21+
keychainService: "Chrome Safe Storage",
22+
keychainAccount: "Chrome",
23+
linuxSecretApplication: undefined,
24+
}).pipe(Effect.flip);
25+
26+
expect(error).toBeInstanceOf(ChromiumKeyError);
27+
expect(error.reason).toBe("keychainUnavailable");
28+
expect(error.cause).toBeInstanceOf(Error);
29+
}).pipe(
30+
Effect.provideService(
31+
ChildProcessSpawner.ChildProcessSpawner,
32+
ChildProcessSpawner.make(() => Effect.die("must not spawn")),
33+
),
34+
),
35+
);

‎apps/desktop/src/preview/BrowserImport/ChromiumKeys.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Sink from "effect/Sink";
77
import * as Stream from "effect/Stream";
88
import * as PlatformError from "effect/PlatformError";
99
import { ChildProcessSpawner } from "effect/unstable/process";
10+
import { beforeEach, vi } from "vite-plus/test";
1011

1112
import {
1213
ChromiumKeyError,
@@ -17,6 +18,18 @@ import {
1718
} from "./ChromiumKeys.ts";
1819
import { LinuxBrowserSecretPath } from "./LinuxBrowserSecret.ts";
1920

21+
const { getPassword } = vi.hoisted(() => ({ getPassword: vi.fn<() => string | null>() }));
22+
23+
vi.mock("@napi-rs/keyring", () => ({
24+
Entry: class {
25+
getPassword = getPassword;
26+
},
27+
}));
28+
29+
beforeEach(() => {
30+
getPassword.mockReset();
31+
});
32+
2033
type CapturedCommand = {
2134
readonly command: string;
2235
readonly args: ReadonlyArray<string>;
@@ -63,6 +76,47 @@ const helperLayer = (input: {
6376
),
6477
);
6578

79+
describe("macOS Chromium secrets", () => {
80+
const request = {
81+
platform: "darwin",
82+
keychainService: "Chrome Safe Storage",
83+
keychainAccount: "Chrome",
84+
linuxSecretApplication: undefined,
85+
} as const;
86+
const noProcesses = Layer.succeed(
87+
ChildProcessSpawner.ChildProcessSpawner,
88+
ChildProcessSpawner.make(() => Effect.die("must not spawn")),
89+
);
90+
91+
it.effect("derives the cookie key from the keychain secret", () =>
92+
Effect.gen(function* () {
93+
getPassword.mockReturnValue("macos-secret");
94+
const keys = yield* resolveChromiumKeys(request);
95+
expect(keys.cbcV10?.toString("hex")).toBe("3df7306fb1eac353289565a2f6b64f74");
96+
}).pipe(Effect.provide(noProcesses)),
97+
);
98+
99+
it.effect("reports a missing keychain entry", () =>
100+
Effect.gen(function* () {
101+
getPassword.mockReturnValue(null);
102+
const error = yield* resolveChromiumKeys(request).pipe(Effect.flip);
103+
expect(error.reason).toBe("keychainItemMissing");
104+
}).pipe(Effect.provide(noProcesses)),
105+
);
106+
107+
it.effect("preserves a denied keychain approval", () =>
108+
Effect.gen(function* () {
109+
const denied = new Error("User denied access");
110+
getPassword.mockImplementation(() => {
111+
throw denied;
112+
});
113+
const error = yield* resolveChromiumKeys(request).pipe(Effect.flip);
114+
expect(error.reason).toBe("needsKeychainApproval");
115+
expect(error.cause).toBe(denied);
116+
}).pipe(Effect.provide(noProcesses)),
117+
);
118+
});
119+
66120
describe("Linux Chromium secrets", () => {
67121
it.effect("retains a missing helper failure alongside the keyring-free fallback", () =>
68122
Effect.gen(function* () {

‎apps/desktop/src/preview/BrowserImport/ChromiumKeys.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*
1818
* @module ChromiumKeys
1919
*/
20-
import * as Keyring from "@napi-rs/keyring";
2120
import * as NodeCrypto from "node:crypto";
2221

2322
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
@@ -102,6 +101,12 @@ const readKeychainSecret = Effect.fn("ChromiumKeys.readKeychainSecret")(function
102101
service: string,
103102
account: string,
104103
) {
104+
// Only macOS cookie imports need this binding; loading it at startup can
105+
// prevent the desktop from opening on platforms that never use it.
106+
const Keyring = yield* Effect.tryPromise({
107+
try: () => import("@napi-rs/keyring"),
108+
catch: (cause) => new ChromiumKeyError({ reason: "keychainUnavailable", cause }),
109+
});
105110
const secret = yield* Effect.try({
106111
try: () => new Keyring.Entry(service, account).getPassword(),
107112
catch: (cause) => {

‎apps/mobile/app.config.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const config: ExpoConfig = {
186186
icon: variant.assets.appIcon,
187187
userInterfaceStyle: "automatic",
188188
updates: {
189-
enabled: true,
189+
enabled: repoEnv.T3CODE_MOBILE_UPDATES_ENABLED !== "0",
190190
url: "https://u.expo.dev/d763fcb8-d37c-41ea-a773-b54a0ab4a454",
191191
checkAutomatically: "ON_LOAD",
192192
fallbackToCacheTimeout: 0,
@@ -237,6 +237,9 @@ const config: ExpoConfig = {
237237
android: {
238238
icon: variant.assets.appIcon,
239239
package: variant.androidPackage,
240+
...(repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE
241+
? { googleServicesFile: repoEnv.T3CODE_ANDROID_GOOGLE_SERVICES_FILE }
242+
: {}),
240243
adaptiveIcon: {
241244
backgroundColor: variant.assets.androidAdaptiveBackgroundColor,
242245
...(variant.assets.androidAdaptiveBackgroundImage
@@ -356,6 +359,10 @@ const config: ExpoConfig = {
356359
[
357360
"expo-build-properties",
358361
{
362+
android: {
363+
// Keep the supported floor explicit and covered by native notification tests.
364+
minSdkVersion: 24,
365+
},
359366
ios: {
360367
deploymentTarget: "18.0",
361368
// AppCheckCore 11.3+ includes Swift and needs module maps for these Objective-C dependencies.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'expo-module-gradle-plugin'
4+
}
5+
6+
group = 'com.t3tools.agentnotifications'
7+
version = '0.0.0'
8+
9+
android {
10+
namespace 'expo.modules.t3agentnotifications'
11+
defaultConfig {
12+
versionCode 1
13+
versionName '0.0.0'
14+
}
15+
testOptions {
16+
unitTests.includeAndroidResources = true
17+
}
18+
}
19+
20+
dependencies {
21+
implementation project(':expo-notifications')
22+
implementation 'com.google.firebase:firebase-messaging:25.0.1'
23+
implementation 'androidx.core:core:1.17.0'
24+
implementation 'androidx.lifecycle:lifecycle-process:2.9.3'
25+
testImplementation 'junit:junit:4.13.2'
26+
testImplementation 'org.robolectric:robolectric:4.16.1'
27+
}
28+
29+
// Expo compiles modules with Java 17; Robolectric's Android 16 runtime needs 21.
30+
tasks.withType(Test).configureEach {
31+
javaLauncher = javaToolchains.launcherFor {
32+
languageVersion = JavaLanguageVersion.of(21)
33+
}
34+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
2+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
3+
<uses-permission android:name="android.permission.POST_PROMOTED_NOTIFICATIONS" />
4+
<application>
5+
<service android:name="expo.modules.notifications.service.ExpoFirebaseMessagingService" tools:node="remove" />
6+
<service android:name=".AgentMessagingService" android:exported="false">
7+
<intent-filter>
8+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
9+
</intent-filter>
10+
</service>
11+
<receiver android:name=".AgentActivityDismissReceiver" android:exported="false" />
12+
<receiver android:name=".AgentActivityExpiryReceiver" android:exported="false" />
13+
</application>
14+
</manifest>

0 commit comments

Comments
 (0)