UNPKG

react-native-acoustic-connect-beta

Version:

BETA: React native plugin for Acoustic Connect

114 lines 5.48 kB
"use strict"; // Copyright (C) 2026 Acoustic, L.P. All rights reserved. // // NOTICE: This file contains material that is confidential and proprietary to // Acoustic, L.P. and/or other developers. No license is granted under any // intellectual or industrial property rights of Acoustic, L.P. except as may // be provided in an agreement with Acoustic, L.P. Any unauthorized copying or // distribution of content from this file is prohibited. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.withConnectIosSigning = exports.resolveDevelopmentTeam = void 0; const config_plugins_1 = require("@expo/config-plugins"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); const PLACEHOLDER_TEAM = 'YOUR_TEAM_ID'; /** * Resolves the iOS signing team (Apple Team ID) for the host + push extensions. * * Priority: * 1. `iosDevelopmentTeam` plugin prop in app.json (explicit override) * 2. `Connect.iOSDevelopmentTeam` in `<projectRoot>/ConnectConfig.json` * * Returns `undefined` when neither source provides a real value (the placeholder * `YOUR_TEAM_ID` counts as unset). The mod is then a no-op — never a regression. */ function resolveDevelopmentTeam(projectRoot, props) { var _a, _b; const fromProp = (_a = props.iosDevelopmentTeam) === null || _a === void 0 ? void 0 : _a.trim(); if (fromProp && fromProp !== PLACEHOLDER_TEAM) return fromProp; const configPath = path.join(projectRoot, 'ConnectConfig.json'); if (fs.existsSync(configPath)) { try { const parsed = JSON.parse(fs.readFileSync(configPath, 'utf8')); const team = (_b = parsed.Connect) === null || _b === void 0 ? void 0 : _b.iOSDevelopmentTeam; if (typeof team === 'string' && team.trim() && team.trim() !== PLACEHOLDER_TEAM) return team.trim(); } catch { // Malformed JSON is already surfaced by resolveAppGroupIdentifier (which // runs earlier in the NSE mod) — don't double-report here. } } return undefined; } exports.resolveDevelopmentTeam = resolveDevelopmentTeam; /** * Expo Config Plugin mod that stamps `DEVELOPMENT_TEAM` onto every target's * build configuration in the generated Xcode project (host + ConnectNSE + * ConnectNCE), so all three sign consistently. * * Why this matters: the NSE mod injects the `aps-environment` entitlement, but * a CLI build (`expo run:ios` / `xcodebuild`) with no signing team falls back * to ad-hoc signing (`CODE_SIGN_IDENTITY = -`), which DROPS that entitlement — * so the OS issues no APNs token and push silently fails (CA-144135 §6). Setting * the team closes that loop on the prebuild path the SDK owns. Provisioning * itself still needs the developer's Apple ID in Xcode and * `-allowProvisioningUpdates` on the build (documented in the README). * * No-op when no team is configured (no regression for consumers who sign in the * Xcode GUI or via EAS, which manages the whole chain itself). * * Must run AFTER withConnectNSE / withConnectNCE so the extension targets exist. */ const withConnectIosSigning = (config, props = {}) => { var _a; const projectRoot = (_a = config._internal) === null || _a === void 0 ? void 0 : _a.projectRoot; // withConnectNSE already throws an actionable error when projectRoot is // missing; here we simply skip so we never throw twice for the same cause. if (!projectRoot) return config; const team = resolveDevelopmentTeam(projectRoot, props); if (!team) return config; return (0, config_plugins_1.withXcodeProject)(config, (c) => { const xcodeProject = c.modResults; const configurations = xcodeProject.pbxXCBuildConfigurationSection(); // Set the team on every build configuration that has a buildSettings block // (host + both extensions). Project-level configs get it too, which is // harmless and ensures consistency across all targets. for (const key of Object.keys(configurations)) { const entry = configurations[key]; if (entry && typeof entry === 'object' && entry.buildSettings) { entry.buildSettings.DEVELOPMENT_TEAM = team; } } return c; }); }; exports.withConnectIosSigning = withConnectIosSigning; exports.default = exports.withConnectIosSigning; //# sourceMappingURL=withConnectIosSigning.js.map