Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 7429bcd

Browse files
Merge pull request #4 from passageidentity/PSG-4571-improve-plugin
Make plugin more flexible
2 parents 89a30eb + d0f5dab commit 7429bcd

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/app.plugin.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ function withIosPodfile(configuration) {
4444
function withIosAssociatedDomain(configuration) {
4545
const associatedDomain = process.env.ASSOCIATED_DOMAIN;
4646
if (!associatedDomain) {
47-
throw new Error('ASSOCIATED_DOMAIN environment variable is not set');
47+
return configuration;
4848
}
4949
return withEntitlementsPlist(configuration, (config) => {
50-
config.modResults['com.apple.developer.associated-domains'] = [
51-
`webcredentials:${associatedDomain}`,
52-
];
50+
const key = 'com.apple.developer.associated-domains';
51+
const webCredEntitlement = `webcredentials:${associatedDomain}`;
52+
// Get existing associated domains if they exist
53+
let domains = config.modResults[key] || [];
54+
// Add the new domain only if it's not already present
55+
if (!domains.includes(webCredEntitlement)) {
56+
domains.push(webCredEntitlement);
57+
}
58+
config.modResults[key] = domains;
5359
return config;
5460
});
5561
}
@@ -88,7 +94,7 @@ function withAndroidGradleDependency(configuration) {
8894
function withAndroidAssociatedDomain(configuration) {
8995
const associatedDomain = process.env.ASSOCIATED_DOMAIN;
9096
if (!associatedDomain) {
91-
throw new Error('ASSOCIATED_DOMAIN environment variable is not set');
97+
return configuration;
9298
}
9399

94100
// Modify AndroidManifest.xml
@@ -124,7 +130,7 @@ function withAndroidAssociatedDomain(configuration) {
124130
}
125131
let stringsXmlContent = fs.readFileSync(stringsXmlPath, 'utf-8');
126132
// Check if the string already exists
127-
if (!stringsXmlContent.includes('<string name="passage_auth_origin">')) {
133+
if (!stringsXmlContent.includes('<string name="asset_statements">')) {
128134
const newStrings = `<string name="passage_auth_origin">${associatedDomain}</string>
129135
<string name="asset_statements">[{"include": "https://@string/passage_auth_origin/.well-known/assetlinks.json"}]</string>`;
130136
// Insert the new strings before the closing </resources> tag

0 commit comments

Comments
 (0)