Skip to content

Commit 4cbbc7c

Browse files
committed
mac/swift encryption binary + cross platform client
1 parent 045d362 commit 4cbbc7c

37 files changed

Lines changed: 3212 additions & 135 deletions

.changeset/red-wasps-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"varlock": minor
3+
---
4+
5+
add new varlock() function for built-in encryption

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ smoke-tests/pnpm-lock.yaml
1616
framework-tests/.packed
1717
framework-tests/.test-projects
1818
.magent
19+
.claude/worktrees/
1920
eslint-output.txt

bun.lock

Lines changed: 31 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export default tseslint.config(
159159
},
160160
},
161161
{
162+
// allow console.log in some scripts/tests/etc
162163
files: [
163164
'scripts/**',
164165
'ignore/**',
@@ -168,6 +169,7 @@ export default tseslint.config(
168169
'packages/varlock/scripts/**',
169170
'smoke-tests/**',
170171
'framework-tests/**',
172+
'packages/encryption-binary-swift/scripts/**',
171173
],
172174
rules: {
173175
'no-console': 0,
@@ -179,22 +181,6 @@ export default tseslint.config(
179181
'@typescript-eslint/no-require-imports': 0,
180182
},
181183
},
182-
{
183-
// plugin files use triple-slash directives for the `plugin` global type
184-
// which is injected at runtime by varlock via globalThis
185-
files: [
186-
'smoke-tests/**/plugins/**',
187-
'packages/varlock/src/env-graph/test/plugins/**',
188-
],
189-
languageOptions: {
190-
globals: {
191-
plugin: 'readonly',
192-
},
193-
},
194-
rules: {
195-
'@typescript-eslint/triple-slash-reference': 0,
196-
},
197-
},
198184
{
199185
// these files use build-time globals declared in globals.d.ts
200186
files: [

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
"@typescript-eslint/parser": "^8.56.1",
3939
"@varlock/changeset-changelog": "workspace:*",
4040
"@varlock/tsconfig": "workspace:*",
41-
"@varlock/cloudflare-integration": "workspace:*",
42-
"@varlock/keepass-plugin": "workspace:*",
4341
"eslint": "^10.0.2",
4442
"eslint-plugin-es-x": "^9.5.0",
4543
"eslint-plugin-fix-disabled-rules": "^0.0.2",
@@ -49,7 +47,8 @@
4947
"globals": "^17.3.0",
5048
"turbo": "^2.8.12",
5149
"typescript": "catalog:",
52-
"typescript-eslint": "^8.56.1"
50+
"typescript-eslint": "^8.56.1",
51+
"varlock": "workspace:*"
5352
},
5453
"packageManager": "bun@1.3.11",
5554
"engines": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# @defaultSensitive=false @defaultRequired=infer
2+
# @plugin(@varlock/1password-plugin)
3+
# @initOp(allowAppAuth=true, token=$OP_CI_TOKEN)
4+
# ---
5+
6+
# this must be set in github actions secrets
7+
# @type=opServiceAccountToken @sensitive
8+
OP_CI_TOKEN=
9+
10+
# Apple code signing - used in CI to sign the macOS native binary
11+
# @sensitive
12+
APPLE_CERTIFICATE_BASE64=op("op://VarlockCI/apple developer/APPLE_CERTIFICATE_BASE64")
13+
# @sensitive
14+
APPLE_CERTIFICATE_PASSWORD=op("op://VarlockCI/apple developer/APPLE_CERTIFICATE_PASSWORD")
15+
APPLE_SIGNING_IDENTITY=op("op://VarlockCI/apple developer/APPLE_SIGNING_IDENTITY")
16+
APPLE_TEAM_ID=op("op://VarlockCI/apple developer/APPLE_TEAM_ID")
17+
18+
# Apple notarization
19+
# @sensitive
20+
APPLE_ID=op("op://VarlockCI/apple developer/APPLE_NOTARIZATION_APPLE_ID")
21+
# @sensitive
22+
APPLE_APP_PASSWORD=op("op://VarlockCI/apple developer/APPLE_NOTARIZATION_APP_PASSWORD")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
swift/.build
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# @varlock/encryption-binary-swift
2+
3+
macOS native binary for varlock's local encryption, built in Swift.
4+
5+
## Why Swift?
6+
7+
Varlock uses the **Secure Enclave** for hardware-backed key storage on macOS. The Secure Enclave, Touch ID biometric prompts, and native UI (status bar menu, secure input dialogs) are only accessible through Apple's `Security`, `LocalAuthentication`, and `AppKit` frameworks — which are designed for Swift/Objective-C. Rust or other languages would require fragile FFI bindings with no stable C ABI to target.
8+
9+
The `.app` bundle format is also required for custom Touch ID icons, `LSUIElement` (menu-bar-only) behavior, and proper code signing + notarization.
10+
11+
Rust is planned for Windows (TPM / Windows Hello) and Linux (TPM2), where the platform APIs have C-friendly interfaces. The IPC protocol (length-prefixed JSON over a Unix socket) is the same across all platforms.
12+
13+
## Structure
14+
15+
- `swift/` — Swift Package Manager project (`VarlockEnclave` executable)
16+
- `scripts/build-swift.ts` — Two-phase build: compile (cacheable) + bundle (mode-specific `.app` wrapping + codesign)
17+
- `resources/` — App icon and other bundle resources
18+
19+
## Building
20+
21+
```bash
22+
# Local dev (current arch, dev mode)
23+
bun run build:swift:dev
24+
25+
# Universal binary (arm64 + x86_64, for CI)
26+
bun run build:swift
27+
28+
# With signing and release metadata
29+
bun run build:swift -- --mode release --version 1.2.3 --sign "Developer ID Application: ..."
30+
```
31+
32+
Output: `packages/varlock/native-bins/darwin/VarlockEnclave.app`
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@varlock/encryption-binary-swift",
3+
"description": "macOS Secure Enclave encryption binary for varlock (Swift)",
4+
"version": "0.0.1",
5+
"private": true,
6+
"scripts": {
7+
"kill-daemon": "bun run scripts/kill-daemon.ts",
8+
"build:swift": "bun run kill-daemon && bun run scripts/build-swift.ts --universal",
9+
"build:swift:dev": "bun run kill-daemon && bun run scripts/build-swift.ts",
10+
"clean": "rm -rf swift/.build"
11+
},
12+
"devDependencies": {
13+
"@varlock/1password-plugin": "workspace:*",
14+
"varlock": "workspace:*"
15+
},
16+
"author": "dmno-dev",
17+
"license": "MIT"
18+
}
658 KB
Binary file not shown.

0 commit comments

Comments
 (0)