@oxy.so/app-preset 6.4.0 → 6.5.1
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/README.md +6 -2
- package/babel/index.js +1 -1
- package/bin/oxy-check-keychain-entitlements.js +145 -4
- package/package.json +1 -1
- package/plugin/oxyKeychainGroups.js +27 -2
- package/plugin/withOxyAppPreset.js +5 -4
package/README.md
CHANGED
|
@@ -419,8 +419,12 @@ module.exports = require('@oxy.so/app-preset/babel');
|
|
|
419
419
|
In development this is exactly `babel-preset-expo`. Expo's oxc transformer,
|
|
420
420
|
Noxcturnal, runs only when the Babel config resolves to the bare Expo preset;
|
|
421
421
|
one extra plugin or preset option sends every file back to Babel. The config
|
|
422
|
-
plugin
|
|
423
|
-
|
|
422
|
+
plugin leaves the experiment (`experiments.noxcturnalTransformWorker`) unset by
|
|
423
|
+
default, following Expo's Babel default. Noxcturnal 0.1.11 with Expo Metro 58.0.21
|
|
424
|
+
miscompiles a derived class with a private field and private method, causing
|
|
425
|
+
TanStack Query 5.103.3 observers to throw during Nilo startup. `noxcturnal: true`
|
|
426
|
+
opts into the experimental development transformer; `false` leaves it unset.
|
|
427
|
+
An explicit app experiment keeps its own value. Preset-managed production builds stay on Babel,
|
|
424
428
|
with the build-id inliner, because Noxcturnal keeps the requires of dead
|
|
425
429
|
platform branches and pulls native-only packages into a web bundle.
|
|
426
430
|
|
package/babel/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* In development the config is exactly `babel-preset-expo`, nothing else.
|
|
5
5
|
* Expo's oxc transformer (Noxcturnal, `experiments.noxcturnalTransformWorker`,
|
|
6
|
-
*
|
|
6
|
+
* enabled explicitly with `noxcturnal: true`) runs only when the project's Babel
|
|
7
7
|
* config resolves to the bare Expo preset; one extra plugin or preset option
|
|
8
8
|
* sends every file back to Babel. Everything the config used to add is covered
|
|
9
9
|
* without it in SDK 58: `babel-preset-expo` adds `react-native-worklets/plugin`
|
|
@@ -14,12 +14,24 @@
|
|
|
14
14
|
* the file is codesigned output of that team, whose entries are expanded
|
|
15
15
|
* (`<TEAMID>.so.oxy.wallet`, not `$(AppIdentifierPrefix)so.oxy.wallet`).
|
|
16
16
|
*
|
|
17
|
+
* `<path>` may also be a SIGNED build (security review R6-15): an `.app`, an
|
|
18
|
+
* `.xcarchive` or an `.ipa`. Then what is checked is what the binary will
|
|
19
|
+
* actually run with: `codesign -d --entitlements - --xml` (macOS) over the
|
|
20
|
+
* app and every extension it embeds (`PlugIns/*.appex`, `Extensions/*.appex`).
|
|
21
|
+
* Each bundle's id and team come from its OWN signed `application-identifier`
|
|
22
|
+
* and `com.apple.developer.team-identifier`, never from the command line; the
|
|
23
|
+
* app's id must be `<bundle-id>` (compared without case, as Apple does), and
|
|
24
|
+
* each extension is judged under its own id. Run it on every archive before it
|
|
25
|
+
* is uploaded (docs/engineering/build-and-deploy.md).
|
|
26
|
+
*
|
|
17
27
|
* Exits 0 when every file passes, 1 on a policy violation, 2 on a usage or
|
|
18
28
|
* read error. A directory with no entitlements file is an error: there was
|
|
19
29
|
* nothing to check.
|
|
20
30
|
*/
|
|
21
|
-
const {
|
|
22
|
-
const {
|
|
31
|
+
const { execFileSync } = require('node:child_process');
|
|
32
|
+
const { mkdtempSync, readFileSync, readdirSync, rmSync, statSync } = require('node:fs');
|
|
33
|
+
const { tmpdir } = require('node:os');
|
|
34
|
+
const { basename, join, resolve } = require('node:path');
|
|
23
35
|
const { assertOxyKeychainGroups } = require('../plugin/oxyKeychainGroups');
|
|
24
36
|
|
|
25
37
|
const KEY = 'keychain-access-groups';
|
|
@@ -86,6 +98,121 @@ function findEntitlements(dir) {
|
|
|
86
98
|
return found.sort();
|
|
87
99
|
}
|
|
88
100
|
|
|
101
|
+
/** The entitlements dictionary of a plist text, or a UsageError naming `source`. */
|
|
102
|
+
function parseEntitlements(text, source, plist) {
|
|
103
|
+
let parsed;
|
|
104
|
+
try {
|
|
105
|
+
parsed = plist.parse(text);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new UsageError(`${source} is not a readable plist: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
110
|
+
throw new UsageError(`${source} carries no entitlements dictionary`);
|
|
111
|
+
}
|
|
112
|
+
return parsed;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const SIGNED_BUNDLE = /\.(app|xcarchive|ipa)$/i;
|
|
116
|
+
|
|
117
|
+
/** `codesign -d --entitlements - --xml <bundle>`: the entitlements a signed bundle runs with (macOS). */
|
|
118
|
+
function codesignEntitlements(bundle) {
|
|
119
|
+
try {
|
|
120
|
+
return execFileSync('codesign', ['-d', '--entitlements', '-', '--xml', bundle], {
|
|
121
|
+
encoding: 'utf8',
|
|
122
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
throw new UsageError(
|
|
126
|
+
`codesign could not read the entitlements of ${bundle} (macOS only): ${error.message}`,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The `.app` directories directly in `dir`. */
|
|
132
|
+
function appsIn(dir) {
|
|
133
|
+
let entries;
|
|
134
|
+
try {
|
|
135
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
136
|
+
} catch {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
return entries
|
|
140
|
+
.filter((entry) => entry.isDirectory() && entry.name.endsWith('.app'))
|
|
141
|
+
.map((entry) => join(dir, entry.name));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** The app of a signed build, and every extension it embeds. */
|
|
145
|
+
function signedBundles(app) {
|
|
146
|
+
const extensions = ['PlugIns', 'Extensions'].flatMap((folder) => {
|
|
147
|
+
try {
|
|
148
|
+
return readdirSync(join(app, folder), { withFileTypes: true })
|
|
149
|
+
.filter((entry) => entry.isDirectory() && entry.name.endsWith('.appex'))
|
|
150
|
+
.map((entry) => join(app, folder, entry.name));
|
|
151
|
+
} catch {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return [app, ...extensions.sort()];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Check a SIGNED `.app`, `.xcarchive` or `.ipa` (R6-15): the entitlements
|
|
160
|
+
* codesign reports for the app and each embedded extension, each bundle judged
|
|
161
|
+
* under the id and team its own signature names.
|
|
162
|
+
*
|
|
163
|
+
* @param {{ bundleId: string, target: string, plist: { parse(text: string): unknown },
|
|
164
|
+
* codesign?: (bundle: string) => string, unzip?: (ipa: string, into: string) => void }} options
|
|
165
|
+
*/
|
|
166
|
+
function checkSignedBuild({ bundleId, target, plist, codesign = codesignEntitlements, unzip }) {
|
|
167
|
+
let scratch;
|
|
168
|
+
try {
|
|
169
|
+
let apps;
|
|
170
|
+
if (/\.ipa$/i.test(target)) {
|
|
171
|
+
scratch = mkdtempSync(join(tmpdir(), 'oxy-ipa-'));
|
|
172
|
+
(
|
|
173
|
+
unzip ??
|
|
174
|
+
((ipa, into) => execFileSync('unzip', ['-q', ipa, '-d', into], { stdio: 'ignore' }))
|
|
175
|
+
)(target, scratch);
|
|
176
|
+
apps = appsIn(join(scratch, 'Payload'));
|
|
177
|
+
} else if (/\.xcarchive$/i.test(target)) {
|
|
178
|
+
apps = appsIn(join(target, 'Products', 'Applications'));
|
|
179
|
+
} else {
|
|
180
|
+
apps = [target];
|
|
181
|
+
}
|
|
182
|
+
if (apps.length !== 1) {
|
|
183
|
+
throw new UsageError(`${target} must hold exactly one .app (found ${apps.length})`);
|
|
184
|
+
}
|
|
185
|
+
return signedBundles(apps[0]).map((bundle, index) => {
|
|
186
|
+
const source = `${basename(target)}:${bundle === apps[0] ? basename(bundle) : bundle.slice(apps[0].length + 1)}`;
|
|
187
|
+
const entitlements = parseEntitlements(codesign(bundle), source, plist);
|
|
188
|
+
const teamId = entitlements['com.apple.developer.team-identifier'];
|
|
189
|
+
const appId = entitlements['application-identifier'];
|
|
190
|
+
if (
|
|
191
|
+
typeof teamId !== 'string' ||
|
|
192
|
+
typeof appId !== 'string' ||
|
|
193
|
+
!appId.startsWith(`${teamId}.`)
|
|
194
|
+
) {
|
|
195
|
+
throw new UsageError(
|
|
196
|
+
`${source}: no signed application-identifier and team-identifier (is it signed?)`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
const signedId = appId.slice(teamId.length + 1);
|
|
200
|
+
if (index === 0 && signedId.toLowerCase() !== bundleId.toLowerCase()) {
|
|
201
|
+
throw new Error(`${source}: is signed as ${signedId}, not ${bundleId}`);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
assertOxyKeychainGroups(signedId, entitlements[KEY], { teamId });
|
|
205
|
+
} catch (error) {
|
|
206
|
+
error.message = `${source}: ${error.message}`;
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
return { file: source, groups: entitlements[KEY] };
|
|
210
|
+
});
|
|
211
|
+
} finally {
|
|
212
|
+
if (scratch) rmSync(scratch, { recursive: true, force: true });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
89
216
|
/**
|
|
90
217
|
* Check `target` for `bundleId`. Throws the policy's Error on a violation and
|
|
91
218
|
* a UsageError when there is nothing readable to check.
|
|
@@ -93,7 +220,7 @@ function findEntitlements(dir) {
|
|
|
93
220
|
* @param {{ bundleId: string, target: string, teamId?: string, plist?: { parse(text: string): unknown } }} options
|
|
94
221
|
* @returns {{ file: string, groups: unknown }[]}
|
|
95
222
|
*/
|
|
96
|
-
function checkKeychainEntitlements({ bundleId, target, teamId, plist }) {
|
|
223
|
+
function checkKeychainEntitlements({ bundleId, target, teamId, plist, codesign, unzip }) {
|
|
97
224
|
const path = resolve(target);
|
|
98
225
|
let stats;
|
|
99
226
|
try {
|
|
@@ -101,6 +228,18 @@ function checkKeychainEntitlements({ bundleId, target, teamId, plist }) {
|
|
|
101
228
|
} catch {
|
|
102
229
|
throw new UsageError(`${target} does not exist`);
|
|
103
230
|
}
|
|
231
|
+
if (SIGNED_BUNDLE.test(path)) {
|
|
232
|
+
if (teamId !== undefined) {
|
|
233
|
+
throw new UsageError('--team-id is read from the signature of a signed build; drop it');
|
|
234
|
+
}
|
|
235
|
+
return checkSignedBuild({
|
|
236
|
+
bundleId,
|
|
237
|
+
target: path,
|
|
238
|
+
plist: plist ?? loadPlist(),
|
|
239
|
+
codesign,
|
|
240
|
+
unzip,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
104
243
|
const files = stats.isDirectory() ? findEntitlements(path) : [path];
|
|
105
244
|
if (files.length === 0) {
|
|
106
245
|
throw new UsageError(`no *.entitlements file under ${target}`);
|
|
@@ -137,7 +276,8 @@ function parseArgs(argv) {
|
|
|
137
276
|
}
|
|
138
277
|
if (positional.length !== 2) {
|
|
139
278
|
throw new UsageError(
|
|
140
|
-
'usage: oxy-check-keychain-entitlements <bundle-id> <entitlements-file-or-ios-dir> [--team-id <TEAMID>]'
|
|
279
|
+
'usage: oxy-check-keychain-entitlements <bundle-id> <entitlements-file-or-ios-dir> [--team-id <TEAMID>]\n' +
|
|
280
|
+
' oxy-check-keychain-entitlements <bundle-id> <signed .app | .xcarchive | .ipa>',
|
|
141
281
|
);
|
|
142
282
|
}
|
|
143
283
|
return { bundleId: positional[0], target: positional[1], teamId };
|
|
@@ -159,6 +299,7 @@ function main(argv = process.argv.slice(2), { log = console.log, error = console
|
|
|
159
299
|
|
|
160
300
|
module.exports = {
|
|
161
301
|
checkKeychainEntitlements,
|
|
302
|
+
checkSignedBuild,
|
|
162
303
|
findEntitlements,
|
|
163
304
|
main,
|
|
164
305
|
readKeychainGroups,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.1",
|
|
4
4
|
"description": "The Oxy distro of Expo — centralized Expo config plugin, Metro/Babel/ESLint factories, Tailwind base CSS and TypeScript bases shared by every Oxy app (Mention, Homiio, Allo, accounts, …). A zero-build package: apps replace copy-pasted config with a single dependency bump.",
|
|
5
5
|
"main": "./app.plugin.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -132,12 +132,28 @@ function keychainEntries(groups) {
|
|
|
132
132
|
return groups.map((group) => `${PREFIX}${group}`);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* The holder id `bundleId` names, compared as Apple compares bundle ids:
|
|
137
|
+
* WITHOUT case (security review R6-15). App Store Connect and the developer
|
|
138
|
+
* portal treat `So.Oxy.Commons` and `so.oxy.commons` as the same identifier,
|
|
139
|
+
* so a case variant is never "every other app"; it is a holder spelled
|
|
140
|
+
* differently, which `assertOxyKeychainGroups` refuses.
|
|
141
|
+
* @param {string|undefined} bundleId
|
|
142
|
+
* @returns {string|undefined}
|
|
143
|
+
*/
|
|
144
|
+
function holderIdOf(bundleId) {
|
|
145
|
+
if (typeof bundleId !== 'string') return undefined;
|
|
146
|
+
const lower = bundleId.toLowerCase();
|
|
147
|
+
return Object.keys(HOLDER_LAYOUTS).find((id) => id === lower);
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
/**
|
|
136
151
|
* The groups this app should list: its holder layout, or the shared group.
|
|
137
152
|
* @param {string|undefined} bundleId
|
|
138
153
|
*/
|
|
139
154
|
function keychainGroupsFor(bundleId) {
|
|
140
|
-
|
|
155
|
+
const holder = holderIdOf(bundleId);
|
|
156
|
+
return holder === undefined ? [G.shared] : [...HOLDER_LAYOUTS[holder]];
|
|
141
157
|
}
|
|
142
158
|
|
|
143
159
|
function refuse(message) {
|
|
@@ -159,7 +175,8 @@ function pinnedEntry(name, teamId) {
|
|
|
159
175
|
*/
|
|
160
176
|
function allowedKeychainLayouts(bundleId) {
|
|
161
177
|
const layouts = [[], [G.shared]];
|
|
162
|
-
|
|
178
|
+
const holder = holderIdOf(bundleId);
|
|
179
|
+
if (holder !== undefined) layouts.push(HOLDER_LAYOUTS[holder]);
|
|
163
180
|
return layouts;
|
|
164
181
|
}
|
|
165
182
|
|
|
@@ -182,6 +199,14 @@ function assertOxyKeychainGroups(bundleId, entries, options = {}) {
|
|
|
182
199
|
if (typeof bundleId === 'string' && restrictedGroup(bundleId) !== undefined) {
|
|
183
200
|
refuse(`${bundleId} is reserved for an Oxy restricted keychain group, not an app bundle id`);
|
|
184
201
|
}
|
|
202
|
+
// Apple compares bundle ids without case (R6-15): a holder's id in another
|
|
203
|
+
// case is the holder misspelled, never a different app.
|
|
204
|
+
const holder = holderIdOf(bundleId);
|
|
205
|
+
if (holder !== undefined && holder !== bundleId) {
|
|
206
|
+
refuse(
|
|
207
|
+
`${bundleId} must be spelled exactly "${holder}" (bundle ids are compared without case)`,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
185
210
|
if (entries === undefined || entries === null) return;
|
|
186
211
|
const app = bundleId ?? 'This app';
|
|
187
212
|
if (!Array.isArray(entries)) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* ios: { deploymentTarget: '17.0' }, // false → skip iOS build properties
|
|
20
20
|
* android: { targetSdkVersion: 34 }, // false → skip Android build properties
|
|
21
21
|
* webgpu: true, // opt-in: react-native-webgpu's config plugin
|
|
22
|
-
* noxcturnal:
|
|
22
|
+
* noxcturnal: true, // opt in of Expo's oxc transformer in development
|
|
23
23
|
* }]
|
|
24
24
|
*
|
|
25
25
|
* Android never gets `android:sharedUserId`: each Oxy app has its own UID and
|
|
@@ -52,9 +52,10 @@
|
|
|
52
52
|
* @param {boolean} [options.webgpu=false] Apply `react-native-webgpu`'s
|
|
53
53
|
* config plugin (an app drawing with WebGPU on native). Needs
|
|
54
54
|
* `react-native-webgpu` installed in the app.
|
|
55
|
-
* @param {boolean} [options.noxcturnal=
|
|
55
|
+
* @param {boolean} [options.noxcturnal=false] Bundle development builds with
|
|
56
56
|
* Noxcturnal, Expo's oxc transformer (`experiments.noxcturnalTransformWorker`),
|
|
57
|
-
*
|
|
57
|
+
* disabled by default: private-field lowering can break dependency code.
|
|
58
|
+
* It only runs when the app's
|
|
58
59
|
* Babel config is the preset's (or none), and never in a production build: it
|
|
59
60
|
* keeps the requires of dead platform branches, pulling native-only packages
|
|
60
61
|
* into a web bundle. The Expo CLI sets NODE_ENV before it reads the config.
|
|
@@ -84,7 +85,7 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
const { keychainGroup, ios = {}, android = {}, webgpu = false, noxcturnal =
|
|
88
|
+
const { keychainGroup, ios = {}, android = {}, webgpu = false, noxcturnal = false } = options;
|
|
88
89
|
|
|
89
90
|
let next = config;
|
|
90
91
|
|