@oxy.so/app-preset 6.1.1 → 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 +4 -2
- package/package.json +1 -1
- package/plugin/oxyKeychainGroups.js +106 -0
- 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
|
}]
|
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
|
+
};
|
|
@@ -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
|
};
|