Socket
Socket
Sign inDemoInstall

@expo/config-plugins

Package Overview
Dependencies
Maintainers
26
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expo/config-plugins - npm Package Compare versions

Comparing version 0.0.1-canary-20240406-a4950c7 to 0.0.1-canary-20240411-33a7dc1

18

build/ios/PrivacyInfo.d.ts
import { ExpoConfig } from '@expo/config-types';
import type { XcodeProject } from 'xcode';
import { ExportedConfigWithProps } from '..';
export type PrivacyInfo = {
NSPrivacyAccessedAPITypes: {
NSPrivacyAccessedAPIType: string;
NSPrivacyAccessedAPITypeReasons: string[];
}[];
NSPrivacyCollectedDataTypes: {
NSPrivacyCollectedDataType: string;
NSPrivacyCollectedDataTypeLinked: boolean;
NSPrivacyCollectedDataTypeTracking: boolean;
NSPrivacyCollectedDataTypePurposes: string[];
}[];
NSPrivacyTracking: boolean;
NSPrivacyTrackingDomains: string[];
};
export declare function withPrivacyInfo(config: ExpoConfig): ExpoConfig;
export declare function setPrivacyInfo(projectConfig: ExportedConfigWithProps<XcodeProject>, privacyManifests: Partial<PrivacyInfo>): ExportedConfigWithProps<XcodeProject>;
export declare function mergePrivacyInfo(existing: Partial<PrivacyInfo>, privacyManifests: Partial<PrivacyInfo>): PrivacyInfo;

89

build/ios/PrivacyInfo.js

@@ -6,2 +6,4 @@ "use strict";

});
exports.mergePrivacyInfo = mergePrivacyInfo;
exports.setPrivacyInfo = setPrivacyInfo;
exports.withPrivacyInfo = withPrivacyInfo;

@@ -15,2 +17,9 @@ function _plist() {

}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
return data;
};
return data;
}
function _XcodeProjectFile() {

@@ -23,8 +32,47 @@ const data = require("./XcodeProjectFile");

}
function _Xcodeproj() {
const data = require("./utils/Xcodeproj");
_Xcodeproj = function () {
return data;
};
return data;
}
function _() {
const data = require("..");
_ = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function withPrivacyInfo(config) {
if (!config.ios?.privacyManifests) {
const privacyManifests = config.ios?.privacyManifests;
if (!privacyManifests) {
return config;
}
const {
return (0, _().withXcodeProject)(config, projectConfig => {
return setPrivacyInfo(projectConfig, privacyManifests);
});
}
function setPrivacyInfo(projectConfig, privacyManifests) {
const projectName = (0, _Xcodeproj().getProjectName)(projectConfig.modRequest.projectRoot);
const existingFileContent = (0, _XcodeProjectFile().readBuildSourceFile)({
project: projectConfig.modResults,
nativeProjectRoot: projectConfig.modRequest.platformProjectRoot,
filePath: _path().default.join(projectName, 'PrivacyInfo.xcprivacy')
});
const parsedContent = _plist().default.parse(existingFileContent);
const mergedContent = mergePrivacyInfo(parsedContent, privacyManifests);
const contents = _plist().default.build(mergedContent);
projectConfig.modResults = (0, _XcodeProjectFile().createBuildSourceFile)({
project: projectConfig.modResults,
nativeProjectRoot: projectConfig.modRequest.platformProjectRoot,
fileContents: contents,
filePath: _path().default.join(projectName, 'PrivacyInfo.xcprivacy'),
overwrite: true
});
return projectConfig;
}
function mergePrivacyInfo(existing, privacyManifests) {
let {
NSPrivacyAccessedAPITypes = [],

@@ -34,15 +82,32 @@ NSPrivacyCollectedDataTypes = [],

NSPrivacyTrackingDomains = []
} = config.ios?.privacyManifests;
const contents = _plist().default.build({
} = structuredClone(existing);
// tracking is a boolean, so we can just overwrite it
NSPrivacyTracking = privacyManifests.NSPrivacyTracking ?? existing.NSPrivacyTracking ?? false;
// merge the api types – for each type ensure the key is in the array, and if it is add the reason if it's not there
privacyManifests.NSPrivacyAccessedAPITypes?.forEach(newType => {
const existingType = NSPrivacyAccessedAPITypes.find(t => t.NSPrivacyAccessedAPIType === newType.NSPrivacyAccessedAPIType);
if (!existingType) {
NSPrivacyAccessedAPITypes.push(newType);
} else {
existingType.NSPrivacyAccessedAPITypeReasons = [...new Set(existingType?.NSPrivacyAccessedAPITypeReasons?.concat(...newType.NSPrivacyAccessedAPITypeReasons))];
}
});
// merge the collected data types – for each type ensure the key is in the array, and if it is add the purposes if it's not there
privacyManifests.NSPrivacyCollectedDataTypes?.forEach(newType => {
const existingType = NSPrivacyCollectedDataTypes.find(t => t.NSPrivacyCollectedDataType === newType.NSPrivacyCollectedDataType);
if (!existingType) {
NSPrivacyCollectedDataTypes.push(newType);
} else {
existingType.NSPrivacyCollectedDataTypePurposes = [...new Set(existingType?.NSPrivacyCollectedDataTypePurposes?.concat(...newType.NSPrivacyCollectedDataTypePurposes))];
}
});
// merge the tracking domains
NSPrivacyTrackingDomains = [...new Set(NSPrivacyTrackingDomains.concat(privacyManifests.NSPrivacyTrackingDomains ?? []))];
return {
NSPrivacyAccessedAPITypes,
NSPrivacyCollectedDataTypes,
NSPrivacyTracking,
NSPrivacyTrackingDomains,
NSPrivacyAccessedAPITypes
});
return (0, _XcodeProjectFile().withBuildSourceFile)(config, {
filePath: 'PrivacyInfo.xcprivacy',
contents,
overwrite: true
});
NSPrivacyTrackingDomains
};
}
//# sourceMappingURL=PrivacyInfo.js.map

@@ -32,1 +32,12 @@ /// <reference types="xcode" />

}): XcodeProject;
/**
* Read a source file from the Xcode project
*
* @param nativeProjectRoot absolute path to the native app root `user/app/ios`
* @param filePath path relative to the `nativeProjectRoot` for the file to read `user/app/ios/myapp/foobar.swift`
*/
export declare function readBuildSourceFile({ project, nativeProjectRoot, filePath, }: {
project: XcodeProject;
nativeProjectRoot: string;
filePath: string;
}): string;

@@ -7,2 +7,3 @@ "use strict";

exports.createBuildSourceFile = createBuildSourceFile;
exports.readBuildSourceFile = readBuildSourceFile;
exports.withBuildSourceFile = void 0;

@@ -100,2 +101,19 @@ function _fs() {

}
/**
* Read a source file from the Xcode project
*
* @param nativeProjectRoot absolute path to the native app root `user/app/ios`
* @param filePath path relative to the `nativeProjectRoot` for the file to read `user/app/ios/myapp/foobar.swift`
*/
function readBuildSourceFile({
project,
nativeProjectRoot,
filePath
}) {
const absoluteFilePath = _path().default.join(nativeProjectRoot, filePath);
return _fs().default.readFileSync(absoluteFilePath, {
encoding: 'utf8'
});
}
//# sourceMappingURL=XcodeProjectFile.js.map

12

package.json
{
"name": "@expo/config-plugins",
"version": "0.0.1-canary-20240406-a4950c7",
"version": "0.0.1-canary-20240411-33a7dc1",
"description": "A library for Expo config plugins",

@@ -36,5 +36,5 @@ "main": "build/index.js",

"dependencies": {
"@expo/config-types": "51.0.0-canary-20240406-a4950c7",
"@expo/json-file": "0.0.1-canary-20240406-a4950c7",
"@expo/plist": "0.0.1-canary-20240406-a4950c7",
"@expo/config-types": "51.0.0-canary-20240411-33a7dc1",
"@expo/json-file": "0.0.1-canary-20240411-33a7dc1",
"@expo/plist": "0.0.1-canary-20240411-33a7dc1",
"@expo/sdk-runtime-versions": "^1.0.0",

@@ -57,3 +57,3 @@ "chalk": "^4.1.2",

"@types/xml2js": "~0.4.11",
"expo-module-scripts": "0.0.1-canary-20240406-a4950c7"
"expo-module-scripts": "0.0.1-canary-20240411-33a7dc1"
},

@@ -63,3 +63,3 @@ "publishConfig": {

},
"gitHead": "a4950c79a9191c7e8162b9529dd0858da19a8b79"
"gitHead": "33a7dc1ce3283426fd553cd6675d0540214ab902"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc