@oxy.so/app-preset 6.1.0 → 6.2.0
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 +14 -3
- package/package.json +1 -1
- package/plugin/oxyKeychainGroups.js +106 -0
- package/plugin/withOxyAbiSplits.js +15 -2
- package/plugin/withOxyAppPreset.js +11 -12
- package/plugin/withOxyKeychain.js +53 -20
- package/plugin/withOxyUpdates.js +4 -1
package/README.md
CHANGED
|
@@ -81,7 +81,9 @@ plugins: [
|
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
This adds the iOS `keychain-access-groups` entitlement
|
|
84
|
-
(`$(AppIdentifierPrefix)group.so.oxy.shared
|
|
84
|
+
(`$(AppIdentifierPrefix)group.so.oxy.shared`; only Commons and the Peable wallet get
|
|
85
|
+
more, and any other app naming `so.oxy.identity` or `so.oxy.wallet` fails prebuild —
|
|
86
|
+
ADR 0062 of the oxy repo), the Oxy `expo-build-properties`
|
|
85
87
|
defaults (iOS `deploymentTarget 16.4`; Android ProGuard + resource shrinking — the
|
|
86
88
|
Android compile/target SDK and build tools are the Expo SDK's own, never pinned here), and `@oxy.so/services/plugins/withOxySharedPermissions`:
|
|
87
89
|
the app declares and requests the signature-level `so.oxy.permission.IDENTITY` and
|
|
@@ -94,7 +96,7 @@ The iOS and build-property pieces are overridable:
|
|
|
94
96
|
|
|
95
97
|
```js
|
|
96
98
|
['@oxy.so/app-preset', {
|
|
97
|
-
keychainGroup: 'group.so.oxy.shared', // false → skip
|
|
99
|
+
keychainGroup: 'group.so.oxy.shared', // default: the bundle id's groups; false → skip (the policy still checks)
|
|
98
100
|
ios: { deploymentTarget: '17.0' }, // deep-merges over defaults; false → skip iOS build props
|
|
99
101
|
android: { targetSdkVersion: 34 }, // deep-merges over defaults; false → skip Android build props
|
|
100
102
|
}]
|
|
@@ -186,7 +188,7 @@ bump it for a native change and the next push to main releases a new binary
|
|
|
186
188
|
(oxy's `android-release.yml`, docs/engineering/build-and-deploy.md#native-android-releases);
|
|
187
189
|
a JS-only change keeps the version and ships as an OTA update.
|
|
188
190
|
|
|
189
|
-
#### One APK per ABI (always on, 6.1.
|
|
191
|
+
#### One APK per ABI (always on, 6.1.1+)
|
|
190
192
|
|
|
191
193
|
`withOxyAbiSplits`, applied by the preset and by `withOxyUpdates`, adds Gradle
|
|
192
194
|
ABI splits to `android/app/build.gradle`, so `assembleRelease` writes one APK per
|
|
@@ -202,6 +204,15 @@ A universal APK carries every ABI's native libraries and a phone loads one
|
|
|
202
204
|
`bundleRelease` is unaffected: the AAB keeps every ABI and Google Play serves
|
|
203
205
|
each device its slice.
|
|
204
206
|
|
|
207
|
+
Build the AAB and the APKs in **two Gradle invocations**
|
|
208
|
+
(`./gradlew :app:bundleRelease`, then `./gradlew :app:assembleRelease`). When R8
|
|
209
|
+
shrinks resources, AGP fails a build that makes split APKs next to an app bundle
|
|
210
|
+
("Multiple shrunk-resources files found … Please disable building multiple APKs
|
|
211
|
+
when building an Android app bundle",
|
|
212
|
+
[issuetracker 402800800](https://issuetracker.google.com/402800800)), so the
|
|
213
|
+
splits are off in any invocation that builds a bundle, and that invocation's
|
|
214
|
+
`assembleRelease` gives a universal APK.
|
|
215
|
+
|
|
205
216
|
A build that compiles none of those ABIs splits to the ones it compiles, so
|
|
206
217
|
`expo run:android` on an x86_64 emulator (it passes
|
|
207
218
|
`-PreactNativeArchitectures=x86_64`) still gets `app-x86_64-debug.apk`, which the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/app-preset",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
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": {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who may name which Oxy iOS keychain access group
|
|
3
|
+
* (docs/identity/ios-keychain-access-groups.md, ADR 0062 in the oxy repo).
|
|
4
|
+
*
|
|
5
|
+
* | Group | Holders | Holds |
|
|
6
|
+
* |------------------------|---------------------------------------|----------------------------------------|
|
|
7
|
+
* | `so.oxy.identity` | Commons only, FIRST in its list | the personal root, phrases, org index |
|
|
8
|
+
* | `so.oxy.wallet` | Commons, the Peable wallet | private keys the wallet signs with |
|
|
9
|
+
* | `group.so.oxy.shared` | every Oxy app | public keys, the device-session credential |
|
|
10
|
+
*
|
|
11
|
+
* The first entry of `keychain-access-groups` is the app's DEFAULT group, and
|
|
12
|
+
* `@oxy.so/core` reads its role from it at runtime: identity first is Commons,
|
|
13
|
+
* wallet first is the Peable wallet, anything else holds no private key. So the
|
|
14
|
+
* ORDER is part of the policy, not only the membership: Commons lists
|
|
15
|
+
* `[identity, wallet, shared]`, the Peable wallet `[wallet, shared]`.
|
|
16
|
+
*
|
|
17
|
+
* Every other app keeps the shared group only. An app config that names a
|
|
18
|
+
* restricted group without being its holder fails prebuild; the entitlement is
|
|
19
|
+
* native, so this is the one place it can be stopped before it ships.
|
|
20
|
+
*/
|
|
21
|
+
const PREFIX = '$(AppIdentifierPrefix)';
|
|
22
|
+
|
|
23
|
+
const OXY_KEYCHAIN_GROUPS = Object.freeze({
|
|
24
|
+
identity: 'so.oxy.identity',
|
|
25
|
+
wallet: 'so.oxy.wallet',
|
|
26
|
+
shared: 'group.so.oxy.shared',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const COMMONS = ['so.oxy.commons', 'so.oxy.commons.dev'];
|
|
30
|
+
const PEABLE_WALLET = ['to.peable.app', 'to.peable.app.dev'];
|
|
31
|
+
|
|
32
|
+
/** The exact leading entries each holder lists, by bundle id. */
|
|
33
|
+
const HOLDER_LAYOUTS = Object.freeze({
|
|
34
|
+
...Object.fromEntries(
|
|
35
|
+
COMMONS.map((id) => [
|
|
36
|
+
id,
|
|
37
|
+
[OXY_KEYCHAIN_GROUPS.identity, OXY_KEYCHAIN_GROUPS.wallet, OXY_KEYCHAIN_GROUPS.shared],
|
|
38
|
+
]),
|
|
39
|
+
),
|
|
40
|
+
...Object.fromEntries(
|
|
41
|
+
PEABLE_WALLET.map((id) => [id, [OXY_KEYCHAIN_GROUPS.wallet, OXY_KEYCHAIN_GROUPS.shared]]),
|
|
42
|
+
),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const RESTRICTED = new Set([OXY_KEYCHAIN_GROUPS.identity, OXY_KEYCHAIN_GROUPS.wallet]);
|
|
46
|
+
|
|
47
|
+
/** `$(AppIdentifierPrefix)so.oxy.wallet` → `so.oxy.wallet`. */
|
|
48
|
+
function groupName(entry) {
|
|
49
|
+
return typeof entry === 'string' && entry.startsWith(PREFIX) ? entry.slice(PREFIX.length) : entry;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The entitlement entries for these group names, in order. */
|
|
53
|
+
function keychainEntries(groups) {
|
|
54
|
+
return groups.map((group) => `${PREFIX}${group}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The groups this app should list: its holder layout, or the shared group.
|
|
59
|
+
* @param {string|undefined} bundleId
|
|
60
|
+
*/
|
|
61
|
+
function keychainGroupsFor(bundleId) {
|
|
62
|
+
return HOLDER_LAYOUTS[bundleId] ? [...HOLDER_LAYOUTS[bundleId]] : [OXY_KEYCHAIN_GROUPS.shared];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Throw unless `entries` (a `keychain-access-groups` value) is one this bundle
|
|
67
|
+
* id may ship: a restricted group only for its holders, and a holder's layout
|
|
68
|
+
* as the leading entries, in order.
|
|
69
|
+
*
|
|
70
|
+
* @param {string|undefined} bundleId
|
|
71
|
+
* @param {unknown} entries
|
|
72
|
+
*/
|
|
73
|
+
function assertOxyKeychainGroups(bundleId, entries) {
|
|
74
|
+
if (!Array.isArray(entries)) return;
|
|
75
|
+
const names = entries.map(groupName);
|
|
76
|
+
const layout = HOLDER_LAYOUTS[bundleId];
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
if (RESTRICTED.has(name) && !layout?.includes(name)) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`[@oxy.so/app-preset] ${bundleId ?? 'This app'} may not list the keychain access group "${name}": ` +
|
|
81
|
+
'only Commons holds the identity group and only Commons and the Peable wallet the wallet group ' +
|
|
82
|
+
'(docs/identity/ios-keychain-access-groups.md). Every other Oxy app lists group.so.oxy.shared.',
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const namesRestricted = names.some((name) => RESTRICTED.has(name));
|
|
87
|
+
if (layout && namesRestricted) {
|
|
88
|
+
const leading = names.slice(0, layout.length);
|
|
89
|
+
if (leading.join(',') !== layout.join(',')) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`[@oxy.so/app-preset] ${bundleId} must list its keychain access groups as [${layout.join(', ')}] ` +
|
|
92
|
+
`first, in that order (got [${names.join(', ')}]): the first entry is the default group, ` +
|
|
93
|
+
'which decides where the identity is written and what @oxy.so/core lets this app read.',
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
OXY_KEYCHAIN_GROUPS,
|
|
101
|
+
HOLDER_LAYOUTS,
|
|
102
|
+
assertOxyKeychainGroups,
|
|
103
|
+
keychainEntries,
|
|
104
|
+
keychainGroupsFor,
|
|
105
|
+
groupName,
|
|
106
|
+
};
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
* still builds one AAB with every ABI, and Google Play serves each device its
|
|
14
14
|
* own slice of it.
|
|
15
15
|
*
|
|
16
|
+
* The splits are OFF in a Gradle invocation that builds a bundle. When R8
|
|
17
|
+
* shrinks resources (`shrinkResources`, which every Oxy release does), AGP
|
|
18
|
+
* fails `buildReleasePreBundle` with "Multiple shrunk-resources files found …
|
|
19
|
+
* Please disable building multiple APKs when building an Android app bundle"
|
|
20
|
+
* (https://issuetracker.google.com/402800800). So the AAB and the APKs are
|
|
21
|
+
* two invocations, `./gradlew :app:bundleRelease` then
|
|
22
|
+
* `./gradlew :app:assembleRelease`; one invocation asking for both builds a
|
|
23
|
+
* universal APK, which Oxy's release workflow refuses.
|
|
24
|
+
*
|
|
16
25
|
* A build for ONE device keeps working: `expo run:android` passes
|
|
17
26
|
* `-PreactNativeArchitectures=<the device's ABI>` for a debug build, so the
|
|
18
27
|
* split follows the ABIs Gradle compiles whenever none of the release ABIs is
|
|
@@ -47,16 +56,20 @@ const RESOLVE_ABIS = `// ${MARKER}: one APK per ABI, no universal APK (@oxy.so/a
|
|
|
47
56
|
def oxyBuiltAbis = (findProperty('reactNativeArchitectures') ?: 'armeabi-v7a,arm64-v8a,x86,x86_64').toString().split(',').collect { it.trim() }.findAll { it }
|
|
48
57
|
def oxyReleaseAbis = [${RELEASE_ABIS.map((abi) => `'${abi}'`).join(', ')}].findAll { oxyBuiltAbis.contains(it) }
|
|
49
58
|
def oxyApkAbis = oxyReleaseAbis ?: oxyBuiltAbis
|
|
59
|
+
// AGP refuses ABI splits in an invocation that also builds an app bundle while R8 shrinks
|
|
60
|
+
// resources (https://issuetracker.google.com/402800800), and a bundle never uses them: build
|
|
61
|
+
// the AAB and the APKs in two invocations.
|
|
62
|
+
def oxyBuildsBundle = gradle.startParameter.taskNames.any { it.tokenize(':').last().toLowerCase().startsWith('bundle') }
|
|
50
63
|
|
|
51
64
|
`;
|
|
52
65
|
|
|
53
66
|
/** Inserted as the first entry of `android {`. */
|
|
54
67
|
const SPLITS = `
|
|
55
|
-
// ${MARKER}: the APKs are oxyApkAbis, one each;
|
|
68
|
+
// ${MARKER}: the APKs are oxyApkAbis, one each; off while building a bundle.
|
|
56
69
|
splits {
|
|
57
70
|
abi {
|
|
58
71
|
reset()
|
|
59
|
-
enable
|
|
72
|
+
enable !oxyBuildsBundle
|
|
60
73
|
universalApk false
|
|
61
74
|
include(*oxyApkAbis)
|
|
62
75
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* Options:
|
|
16
16
|
*
|
|
17
17
|
* ['@oxy.so/app-preset', {
|
|
18
|
-
* keychainGroup:
|
|
18
|
+
* keychainGroup: undefined, // default: the app's groups (shared; Commons and the Peable wallet more); false → skip
|
|
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
|
|
@@ -42,7 +42,11 @@
|
|
|
42
42
|
*
|
|
43
43
|
* @param {import('expo/config').ExpoConfig} config
|
|
44
44
|
* @param {object} [options]
|
|
45
|
-
* @param {string|false} [options.keychainGroup
|
|
45
|
+
* @param {string|string[]|false} [options.keychainGroup] The iOS keychain
|
|
46
|
+
* access group name(s), without `$(AppIdentifierPrefix)`. Default: the
|
|
47
|
+
* policy's groups for the bundle id (`./oxyKeychainGroups`): the shared group,
|
|
48
|
+
* or a holder's layout. `false` skips the entitlement (the policy still checks
|
|
49
|
+
* whatever the app declares itself).
|
|
46
50
|
* @param {object|false} [options.ios]
|
|
47
51
|
* @param {object|false} [options.android]
|
|
48
52
|
* @param {boolean} [options.webgpu=false] Apply `react-native-webgpu`'s
|
|
@@ -80,13 +84,7 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
const {
|
|
84
|
-
keychainGroup = 'group.so.oxy.shared',
|
|
85
|
-
ios = {},
|
|
86
|
-
android = {},
|
|
87
|
-
webgpu = false,
|
|
88
|
-
noxcturnal = true,
|
|
89
|
-
} = options;
|
|
87
|
+
const { keychainGroup, ios = {}, android = {}, webgpu = false, noxcturnal = true } = options;
|
|
90
88
|
|
|
91
89
|
let next = config;
|
|
92
90
|
|
|
@@ -100,9 +98,10 @@ module.exports = function withOxyAppPreset(config, options = {}) {
|
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
next =
|
|
102
|
+
keychainGroup === false
|
|
103
|
+
? withOxyKeychain.withOxyKeychainPolicy(next)
|
|
104
|
+
: withOxyKeychain(next, keychainGroup);
|
|
106
105
|
|
|
107
106
|
if (ios !== false || android !== false) {
|
|
108
107
|
next = withOxyBuildProperties(next, { ios, android });
|
|
@@ -1,35 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Expo Config Plugin: withOxyKeychain
|
|
3
3
|
*
|
|
4
|
-
* Adds
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Adds the iOS `keychain-access-groups` entitlement an Oxy app needs, prefixed
|
|
5
|
+
* with `$(AppIdentifierPrefix)` so Xcode expands it to the Team ID at build
|
|
6
|
+
* time. Which groups, and in which order, is `./oxyKeychainGroups`: every app
|
|
7
|
+
* the shared group (`group.so.oxy.shared`: public keys and the device-session
|
|
8
|
+
* credential), Commons `[so.oxy.identity, so.oxy.wallet, group.so.oxy.shared]`
|
|
9
|
+
* and the Peable wallet `[so.oxy.wallet, group.so.oxy.shared]` — the first
|
|
10
|
+
* entry is the default group, so it is part of the rule. The Android half is
|
|
11
|
+
* Commons' identity host (`withOxySharedPermissions` in @oxy.so/services).
|
|
9
12
|
*
|
|
10
|
-
*
|
|
11
|
-
* already declared
|
|
12
|
-
*
|
|
13
|
+
* The Oxy groups are put FIRST, in their order; entries the app or another
|
|
14
|
+
* plugin already declared are kept after them. Then the policy is checked on
|
|
15
|
+
* the result, and on the app's own `ios.entitlements`: an app that is not a
|
|
16
|
+
* holder and names the identity or wallet group fails prebuild.
|
|
13
17
|
*
|
|
14
18
|
* @param {import('expo/config').ExpoConfig} config
|
|
15
|
-
* @param {string} [
|
|
16
|
-
*
|
|
19
|
+
* @param {string|string[]} [keychainGroups] Group name(s) without the prefix.
|
|
20
|
+
* Default: what `keychainGroupsFor(ios.bundleIdentifier)` gives.
|
|
17
21
|
*/
|
|
18
22
|
const { withEntitlementsPlist } = require('expo/config-plugins');
|
|
23
|
+
const {
|
|
24
|
+
assertOxyKeychainGroups,
|
|
25
|
+
groupName,
|
|
26
|
+
keychainEntries,
|
|
27
|
+
keychainGroupsFor,
|
|
28
|
+
} = require('./oxyKeychainGroups');
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
const entry = `$(AppIdentifierPrefix)${keychainGroup}`;
|
|
30
|
+
const KEY = 'keychain-access-groups';
|
|
22
31
|
|
|
32
|
+
/** Check the groups an app config declares itself (`ios.entitlements`). */
|
|
33
|
+
function withOxyKeychainPolicy(config) {
|
|
34
|
+
const bundleId = config.ios?.bundleIdentifier;
|
|
35
|
+
assertOxyKeychainGroups(bundleId, config.ios?.entitlements?.[KEY]);
|
|
23
36
|
return withEntitlementsPlist(config, (config) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
assertOxyKeychainGroups(bundleId, config.modResults[KEY]);
|
|
38
|
+
return config;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
function withOxyKeychain(config, keychainGroups) {
|
|
43
|
+
const bundleId = config.ios?.bundleIdentifier;
|
|
44
|
+
const wanted = keychainEntries(
|
|
45
|
+
keychainGroups === undefined
|
|
46
|
+
? keychainGroupsFor(bundleId)
|
|
47
|
+
: Array.isArray(keychainGroups)
|
|
48
|
+
? keychainGroups
|
|
49
|
+
: [keychainGroups],
|
|
50
|
+
);
|
|
51
|
+
// At config time, not only in the mod: a refused group fails `expo config` too.
|
|
52
|
+
assertOxyKeychainGroups(bundleId, wanted);
|
|
53
|
+
assertOxyKeychainGroups(bundleId, config.ios?.entitlements?.[KEY]);
|
|
31
54
|
|
|
32
|
-
|
|
55
|
+
const next = withEntitlementsPlist(config, (config) => {
|
|
56
|
+
const existing = Array.isArray(config.modResults[KEY]) ? config.modResults[KEY] : [];
|
|
57
|
+
const wantedNames = new Set(wanted.map(groupName));
|
|
58
|
+
const rest = existing.filter((entry) => !wantedNames.has(groupName(entry)));
|
|
59
|
+
const groups = [...wanted, ...rest];
|
|
60
|
+
assertOxyKeychainGroups(bundleId, groups);
|
|
61
|
+
config.modResults[KEY] = groups;
|
|
33
62
|
return config;
|
|
34
63
|
});
|
|
35
|
-
|
|
64
|
+
return next;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = withOxyKeychain;
|
|
68
|
+
module.exports.withOxyKeychainPolicy = withOxyKeychainPolicy;
|
package/plugin/withOxyUpdates.js
CHANGED
|
@@ -70,6 +70,7 @@ const path = require('path');
|
|
|
70
70
|
const { WarningAggregator } = require('expo/config-plugins');
|
|
71
71
|
const withOxyReleaseVersion = require('./withOxyReleaseVersion');
|
|
72
72
|
const withOxyAbiSplits = require('./withOxyAbiSplits');
|
|
73
|
+
const { withOxyKeychainPolicy } = require('./withOxyKeychain');
|
|
73
74
|
|
|
74
75
|
/** Origin of the Oxy Updates server. `updates.oxy.so` does not exist; oxy-api serves it. */
|
|
75
76
|
const DEFAULT_API_ORIGIN = 'https://api.oxy.so';
|
|
@@ -185,5 +186,7 @@ module.exports = function withOxyUpdates(config, options = {}) {
|
|
|
185
186
|
// `version` is the OTA boundary, so it also numbers the store build: an
|
|
186
187
|
// OTA-enabled app that skips the preset's main plugin gets the same rule,
|
|
187
188
|
// and the same per-ABI APKs (every app on the release pipeline lists this).
|
|
188
|
-
|
|
189
|
+
// Every Oxy app applies this plugin, Commons and the Peable wallet included
|
|
190
|
+
// (neither uses the preset), so the keychain access-group policy is checked here too.
|
|
191
|
+
return withOxyKeychainPolicy(withOxyAbiSplits(withOxyReleaseVersion(next)));
|
|
189
192
|
};
|