capacitor-auth-manager 1.1.0 → 2.1.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 +385 -640
- package/dist/core.cjs.js +4952 -0
- package/dist/core.cjs.js.map +1 -0
- package/dist/esm/capacitor-plugin.d.ts +3 -0
- package/dist/esm/capacitor-plugin.js +7 -0
- package/dist/esm/capacitor-plugin.js.map +1 -0
- package/dist/esm/core/auth-manager.d.ts +33 -0
- package/dist/esm/core/auth-manager.js +296 -0
- package/dist/esm/core/auth-manager.js.map +1 -0
- package/dist/esm/core/index.d.ts +4 -0
- package/dist/esm/core/index.js +5 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/platform.d.ts +17 -0
- package/dist/esm/core/platform.js +80 -0
- package/dist/esm/core/platform.js.map +1 -0
- package/dist/esm/core/provider-registry.d.ts +21 -0
- package/dist/esm/core/provider-registry.js +605 -0
- package/dist/esm/core/provider-registry.js.map +1 -0
- package/dist/esm/core/types.d.ts +35 -0
- package/dist/esm/core/types.js +2 -0
- package/dist/esm/core/types.js.map +1 -0
- package/dist/esm/definitions.d.ts +40 -5
- package/dist/esm/definitions.js +14 -4
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +7 -5
- package/dist/esm/index.js +8 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/base-provider.d.ts +3 -1
- package/dist/esm/providers/base-provider.js +8 -5
- package/dist/esm/providers/base-provider.js.map +1 -1
- package/dist/esm/providers/oauth-provider.js +18 -16
- package/dist/esm/providers/oauth-provider.js.map +1 -1
- package/dist/esm/providers/provider-factory.js +1 -1
- package/dist/esm/providers/provider-factory.js.map +1 -1
- package/dist/esm/providers/web/apple-provider.js +27 -19
- package/dist/esm/providers/web/apple-provider.js.map +1 -1
- package/dist/esm/providers/web/biometric-provider.d.ts +47 -0
- package/dist/esm/providers/web/biometric-provider.js +267 -0
- package/dist/esm/providers/web/biometric-provider.js.map +1 -0
- package/dist/esm/providers/web/email-password-provider.d.ts +55 -0
- package/dist/esm/providers/web/email-password-provider.js +429 -0
- package/dist/esm/providers/web/email-password-provider.js.map +1 -0
- package/dist/esm/providers/web/facebook-provider.d.ts +29 -0
- package/dist/esm/providers/web/facebook-provider.js +249 -0
- package/dist/esm/providers/web/facebook-provider.js.map +1 -0
- package/dist/esm/providers/web/firebase-provider.d.ts +20 -0
- package/dist/esm/providers/web/firebase-provider.js +306 -0
- package/dist/esm/providers/web/firebase-provider.js.map +1 -0
- package/dist/esm/providers/web/github-provider.d.ts +25 -0
- package/dist/esm/providers/web/github-provider.js +248 -0
- package/dist/esm/providers/web/github-provider.js.map +1 -0
- package/dist/esm/providers/web/google-provider.js +18 -14
- package/dist/esm/providers/web/google-provider.js.map +1 -1
- package/dist/esm/providers/web/index.d.ts +13 -0
- package/dist/esm/providers/web/index.js +15 -0
- package/dist/esm/providers/web/index.js.map +1 -0
- package/dist/esm/providers/web/linkedin-provider.d.ts +38 -0
- package/dist/esm/providers/web/linkedin-provider.js +152 -0
- package/dist/esm/providers/web/linkedin-provider.js.map +1 -0
- package/dist/esm/providers/web/magic-link-provider.d.ts +46 -0
- package/dist/esm/providers/web/magic-link-provider.js +298 -0
- package/dist/esm/providers/web/magic-link-provider.js.map +1 -0
- package/dist/esm/providers/web/microsoft-provider.d.ts +21 -0
- package/dist/esm/providers/web/microsoft-provider.js +211 -0
- package/dist/esm/providers/web/microsoft-provider.js.map +1 -0
- package/dist/esm/providers/web/slack-provider.d.ts +40 -0
- package/dist/esm/providers/web/slack-provider.js +151 -0
- package/dist/esm/providers/web/slack-provider.js.map +1 -0
- package/dist/esm/providers/web/sms-provider.d.ts +48 -0
- package/dist/esm/providers/web/sms-provider.js +301 -0
- package/dist/esm/providers/web/sms-provider.js.map +1 -0
- package/dist/esm/providers/web/username-password-provider.d.ts +62 -0
- package/dist/esm/providers/web/username-password-provider.js +432 -0
- package/dist/esm/providers/web/username-password-provider.js.map +1 -0
- package/dist/esm/utils/auth-error.js +7 -5
- package/dist/esm/utils/auth-error.js.map +1 -1
- package/dist/esm/utils/event-emitter.js +1 -1
- package/dist/esm/utils/event-emitter.js.map +1 -1
- package/dist/esm/utils/storage.d.ts +4 -4
- package/dist/esm/utils/storage.js +13 -3
- package/dist/esm/utils/storage.js.map +1 -1
- package/dist/esm/web.js +7 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +4093 -354
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +4093 -354
- package/dist/plugin.js.map +1 -1
- package/package.json +75 -14
- package/scripts/configure.js +105 -61
package/package.json
CHANGED
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "capacitor-auth-manager",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Universal authentication manager with 13+ providers. Framework-agnostic, works with React, Vue, Angular, and vanilla JS. Optional Capacitor support for mobile apps.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
8
8
|
"unpkg": "dist/plugin.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/plugin.cjs.js",
|
|
13
|
+
"types": "./dist/esm/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"import": "./dist/esm/react/index.js",
|
|
17
|
+
"require": "./dist/react.cjs.js",
|
|
18
|
+
"types": "./dist/esm/react/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./vue": {
|
|
21
|
+
"import": "./dist/esm/vue/index.js",
|
|
22
|
+
"require": "./dist/vue.cjs.js",
|
|
23
|
+
"types": "./dist/esm/vue/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./angular": {
|
|
26
|
+
"import": "./dist/esm/angular/index.js",
|
|
27
|
+
"require": "./dist/angular.cjs.js",
|
|
28
|
+
"types": "./dist/esm/angular/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./core": {
|
|
31
|
+
"import": "./dist/esm/core/index.js",
|
|
32
|
+
"require": "./dist/core.cjs.js",
|
|
33
|
+
"types": "./dist/esm/core/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./providers/*": {
|
|
36
|
+
"import": "./dist/esm/providers/*/index.js",
|
|
37
|
+
"require": "./dist/providers/*.cjs.js",
|
|
38
|
+
"types": "./dist/esm/providers/*/index.d.ts"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
9
42
|
"files": [
|
|
10
43
|
"android/src/main/",
|
|
11
44
|
"android/build.gradle",
|
|
@@ -30,10 +63,9 @@
|
|
|
30
63
|
"url": "https://github.com/aoneahsan/capacitor-auth-manager/issues"
|
|
31
64
|
},
|
|
32
65
|
"keywords": [
|
|
33
|
-
"capacitor",
|
|
34
|
-
"plugin",
|
|
35
|
-
"native",
|
|
36
66
|
"auth",
|
|
67
|
+
"authentication",
|
|
68
|
+
"oauth",
|
|
37
69
|
"google",
|
|
38
70
|
"apple",
|
|
39
71
|
"microsoft",
|
|
@@ -41,15 +73,25 @@
|
|
|
41
73
|
"github",
|
|
42
74
|
"slack",
|
|
43
75
|
"linkedin",
|
|
76
|
+
"firebase",
|
|
44
77
|
"email-magic-link",
|
|
45
78
|
"sms",
|
|
46
79
|
"email-code",
|
|
47
|
-
"biometric"
|
|
80
|
+
"biometric",
|
|
81
|
+
"react",
|
|
82
|
+
"vue",
|
|
83
|
+
"angular",
|
|
84
|
+
"capacitor",
|
|
85
|
+
"plugin",
|
|
86
|
+
"native",
|
|
87
|
+
"web",
|
|
88
|
+
"pwa",
|
|
89
|
+
"universal"
|
|
48
90
|
],
|
|
49
91
|
"scripts": {
|
|
50
92
|
"build": "npm run clean && npm run tsc && rollup -c rollup.config.js",
|
|
51
93
|
"clean": "rimraf ./dist",
|
|
52
|
-
"tsc": "tsc",
|
|
94
|
+
"tsc": "tsc -p tsconfig.build.json",
|
|
53
95
|
"watch": "tsc --watch",
|
|
54
96
|
"lint": "eslint . --ext ts",
|
|
55
97
|
"prettier": "prettier --write .",
|
|
@@ -67,18 +109,37 @@
|
|
|
67
109
|
"@capacitor/ios": "^7.4.2",
|
|
68
110
|
"@rollup/plugin-json": "^6.1.0",
|
|
69
111
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
70
|
-
"@types/node": "^24.0
|
|
71
|
-
"@
|
|
72
|
-
"@typescript-eslint/
|
|
73
|
-
"eslint": "^
|
|
112
|
+
"@types/node": "^24.1.0",
|
|
113
|
+
"@types/react": "^19.1.9",
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
115
|
+
"@typescript-eslint/parser": "^8.38.0",
|
|
116
|
+
"eslint": "^9.32.0",
|
|
74
117
|
"prettier": "^3.6.2",
|
|
75
118
|
"rimraf": "^6.0.1",
|
|
76
|
-
"rollup": "^4.
|
|
77
|
-
"typescript": "^5.
|
|
119
|
+
"rollup": "^4.46.2",
|
|
120
|
+
"typescript": "^5.9.2"
|
|
78
121
|
},
|
|
79
122
|
"peerDependencies": {
|
|
80
|
-
"@capacitor/core": "^7.
|
|
123
|
+
"@capacitor/core": "^7.4.2",
|
|
124
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
125
|
+
"vue": "^3.0.0",
|
|
126
|
+
"@angular/core": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
127
|
+
},
|
|
128
|
+
"peerDependenciesMeta": {
|
|
129
|
+
"@capacitor/core": {
|
|
130
|
+
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"react": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
135
|
+
"vue": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
138
|
+
"@angular/core": {
|
|
139
|
+
"optional": true
|
|
140
|
+
}
|
|
81
141
|
},
|
|
142
|
+
"optionalDependencies": {},
|
|
82
143
|
"capacitor": {
|
|
83
144
|
"ios": {
|
|
84
145
|
"src": "ios"
|
package/scripts/configure.js
CHANGED
|
@@ -7,46 +7,49 @@ const readline = require('readline');
|
|
|
7
7
|
|
|
8
8
|
const rl = readline.createInterface({
|
|
9
9
|
input: process.stdin,
|
|
10
|
-
output: process.stdout
|
|
10
|
+
output: process.stdout,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
const question = (query) =>
|
|
13
|
+
const question = (query) =>
|
|
14
|
+
new Promise((resolve) => rl.question(query, resolve));
|
|
14
15
|
|
|
15
16
|
async function configure() {
|
|
16
17
|
console.log('\n🔐 Capacitor Auth Manager Configuration\n');
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
// Detect platform
|
|
19
20
|
const platform = await selectPlatform();
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
// Select providers
|
|
22
23
|
const providers = await selectProviders();
|
|
23
|
-
|
|
24
|
+
|
|
24
25
|
// Configure each provider
|
|
25
26
|
const configs = {};
|
|
26
27
|
for (const provider of providers) {
|
|
27
28
|
console.log(`\n📋 Configuring ${provider}...`);
|
|
28
29
|
configs[provider] = await configureProvider(provider);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
|
|
31
32
|
// Generate configuration files
|
|
32
33
|
await generateConfigs(platform, configs);
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
// Update native projects
|
|
35
36
|
if (platform.includes('ios')) {
|
|
36
37
|
await configureIOS(configs);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
|
|
39
40
|
if (platform.includes('android')) {
|
|
40
41
|
await configureAndroid(configs);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
|
|
43
44
|
console.log('\n✅ Configuration complete!\n');
|
|
44
45
|
console.log('Next steps:');
|
|
45
46
|
console.log('1. Review the generated configuration files');
|
|
46
47
|
console.log('2. Add your provider-specific credentials');
|
|
47
48
|
console.log('3. Run `npx cap sync` to update your native projects');
|
|
48
|
-
console.log(
|
|
49
|
-
|
|
49
|
+
console.log(
|
|
50
|
+
'4. Follow the platform-specific setup instructions in the README\n'
|
|
51
|
+
);
|
|
52
|
+
|
|
50
53
|
rl.close();
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -56,14 +59,18 @@ async function selectPlatform() {
|
|
|
56
59
|
console.log('2. iOS and Web');
|
|
57
60
|
console.log('3. Android and Web');
|
|
58
61
|
console.log('4. Web only');
|
|
59
|
-
|
|
62
|
+
|
|
60
63
|
const choice = await question('\nSelect platform (1-4): ');
|
|
61
|
-
|
|
64
|
+
|
|
62
65
|
switch (choice) {
|
|
63
|
-
case '1':
|
|
64
|
-
|
|
65
|
-
case '
|
|
66
|
-
|
|
66
|
+
case '1':
|
|
67
|
+
return ['ios', 'android', 'web'];
|
|
68
|
+
case '2':
|
|
69
|
+
return ['ios', 'web'];
|
|
70
|
+
case '3':
|
|
71
|
+
return ['android', 'web'];
|
|
72
|
+
case '4':
|
|
73
|
+
return ['web'];
|
|
67
74
|
default:
|
|
68
75
|
console.log('Invalid choice, defaulting to all platforms');
|
|
69
76
|
return ['ios', 'android', 'web'];
|
|
@@ -86,57 +93,65 @@ async function selectProviders() {
|
|
|
86
93
|
'phone_password',
|
|
87
94
|
'username_password',
|
|
88
95
|
'email_code',
|
|
89
|
-
'biometric'
|
|
96
|
+
'biometric',
|
|
90
97
|
];
|
|
91
|
-
|
|
98
|
+
|
|
92
99
|
console.log('\nAvailable authentication providers:');
|
|
93
100
|
allProviders.forEach((p, i) => console.log(`${i + 1}. ${p}`));
|
|
94
|
-
|
|
95
|
-
const input = await question(
|
|
96
|
-
|
|
101
|
+
|
|
102
|
+
const input = await question(
|
|
103
|
+
'\nSelect providers (comma-separated numbers, or "all"): '
|
|
104
|
+
);
|
|
105
|
+
|
|
97
106
|
if (input.toLowerCase() === 'all') {
|
|
98
107
|
return allProviders;
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
const indices = input.split(',').map(n => parseInt(n.trim()) - 1);
|
|
102
|
-
return indices
|
|
109
|
+
|
|
110
|
+
const indices = input.split(',').map((n) => parseInt(n.trim()) - 1);
|
|
111
|
+
return indices
|
|
112
|
+
.filter((i) => i >= 0 && i < allProviders.length)
|
|
113
|
+
.map((i) => allProviders[i]);
|
|
103
114
|
}
|
|
104
115
|
|
|
105
116
|
async function configureProvider(provider) {
|
|
106
117
|
const config = {};
|
|
107
|
-
|
|
118
|
+
|
|
108
119
|
switch (provider) {
|
|
109
120
|
case 'google':
|
|
110
121
|
config.clientId = await question('Google Client ID (Web): ');
|
|
111
|
-
config.serverClientId = await question(
|
|
122
|
+
config.serverClientId = await question(
|
|
123
|
+
'Google Server Client ID (Android): '
|
|
124
|
+
);
|
|
112
125
|
config.iosClientId = await question('Google iOS Client ID: ');
|
|
113
126
|
break;
|
|
114
|
-
|
|
127
|
+
|
|
115
128
|
case 'apple':
|
|
116
129
|
config.clientId = await question('Apple Service ID: ');
|
|
117
130
|
config.redirectUri = await question('Apple Redirect URI: ');
|
|
118
131
|
break;
|
|
119
|
-
|
|
132
|
+
|
|
120
133
|
case 'microsoft':
|
|
121
134
|
config.clientId = await question('Microsoft Azure Client ID: ');
|
|
122
135
|
config.tenantId = await question('Microsoft Tenant ID (or "common"): ');
|
|
123
136
|
config.redirectUri = await question('Microsoft Redirect URI: ');
|
|
124
137
|
break;
|
|
125
|
-
|
|
138
|
+
|
|
126
139
|
case 'facebook':
|
|
127
140
|
config.appId = await question('Facebook App ID: ');
|
|
128
141
|
config.appName = await question('Facebook App Name: ');
|
|
129
142
|
break;
|
|
130
|
-
|
|
143
|
+
|
|
131
144
|
case 'firebase':
|
|
132
145
|
config.apiKey = await question('Firebase API Key: ');
|
|
133
146
|
config.authDomain = await question('Firebase Auth Domain: ');
|
|
134
147
|
config.projectId = await question('Firebase Project ID: ');
|
|
135
148
|
config.appId = await question('Firebase App ID: ');
|
|
136
149
|
break;
|
|
137
|
-
|
|
150
|
+
|
|
138
151
|
case 'sms':
|
|
139
|
-
const smsProvider = await question(
|
|
152
|
+
const smsProvider = await question(
|
|
153
|
+
'SMS Provider (twilio/firebase/custom): '
|
|
154
|
+
);
|
|
140
155
|
config.provider = smsProvider;
|
|
141
156
|
if (smsProvider === 'twilio') {
|
|
142
157
|
config.accountSid = await question('Twilio Account SID: ');
|
|
@@ -145,7 +160,7 @@ async function configureProvider(provider) {
|
|
|
145
160
|
}
|
|
146
161
|
break;
|
|
147
162
|
}
|
|
148
|
-
|
|
163
|
+
|
|
149
164
|
return config;
|
|
150
165
|
}
|
|
151
166
|
|
|
@@ -154,17 +169,17 @@ async function generateConfigs(platforms, configs) {
|
|
|
154
169
|
const authConfig = {
|
|
155
170
|
providers: Object.entries(configs).map(([provider, config]) => ({
|
|
156
171
|
provider,
|
|
157
|
-
options: config
|
|
172
|
+
options: config,
|
|
158
173
|
})),
|
|
159
174
|
persistence: 'local',
|
|
160
175
|
autoRefreshToken: true,
|
|
161
|
-
enableLogging: process.env.NODE_ENV !== 'production'
|
|
176
|
+
enableLogging: process.env.NODE_ENV !== 'production',
|
|
162
177
|
};
|
|
163
|
-
|
|
178
|
+
|
|
164
179
|
const configPath = path.join(process.cwd(), 'capacitor-auth.config.json');
|
|
165
180
|
fs.writeFileSync(configPath, JSON.stringify(authConfig, null, 2));
|
|
166
181
|
console.log(`\n📄 Created ${configPath}`);
|
|
167
|
-
|
|
182
|
+
|
|
168
183
|
// Create example initialization file
|
|
169
184
|
const exampleCode = `import { CapacitorAuthManager } from 'capacitor-auth-manager';
|
|
170
185
|
import authConfig from './capacitor-auth.config.json';
|
|
@@ -185,7 +200,7 @@ export async function initializeAuth() {
|
|
|
185
200
|
// Call this in your app initialization
|
|
186
201
|
initializeAuth();
|
|
187
202
|
`;
|
|
188
|
-
|
|
203
|
+
|
|
189
204
|
const examplePath = path.join(process.cwd(), 'src', 'auth-init.ts');
|
|
190
205
|
if (!fs.existsSync(path.dirname(examplePath))) {
|
|
191
206
|
fs.mkdirSync(path.dirname(examplePath), { recursive: true });
|
|
@@ -196,18 +211,27 @@ initializeAuth();
|
|
|
196
211
|
|
|
197
212
|
async function configureIOS(configs) {
|
|
198
213
|
console.log('\n📱 Configuring iOS...');
|
|
199
|
-
|
|
200
|
-
const infoPlistPath = path.join(
|
|
214
|
+
|
|
215
|
+
const infoPlistPath = path.join(
|
|
216
|
+
process.cwd(),
|
|
217
|
+
'ios',
|
|
218
|
+
'App',
|
|
219
|
+
'App',
|
|
220
|
+
'Info.plist'
|
|
221
|
+
);
|
|
201
222
|
if (!fs.existsSync(infoPlistPath)) {
|
|
202
223
|
console.log('⚠️ iOS Info.plist not found. Please configure manually.');
|
|
203
224
|
return;
|
|
204
225
|
}
|
|
205
|
-
|
|
226
|
+
|
|
206
227
|
let plistAdditions = '\n<!-- Capacitor Auth Manager Configuration -->\n';
|
|
207
|
-
|
|
228
|
+
|
|
208
229
|
// Google Sign-In
|
|
209
230
|
if (configs.google) {
|
|
210
|
-
const reversedClientId = configs.google.iosClientId
|
|
231
|
+
const reversedClientId = configs.google.iosClientId
|
|
232
|
+
.split('.')
|
|
233
|
+
.reverse()
|
|
234
|
+
.join('.');
|
|
211
235
|
plistAdditions += `
|
|
212
236
|
<key>CFBundleURLTypes</key>
|
|
213
237
|
<array>
|
|
@@ -220,7 +244,7 @@ async function configureIOS(configs) {
|
|
|
220
244
|
</array>
|
|
221
245
|
`;
|
|
222
246
|
}
|
|
223
|
-
|
|
247
|
+
|
|
224
248
|
// Facebook
|
|
225
249
|
if (configs.facebook) {
|
|
226
250
|
plistAdditions += `
|
|
@@ -239,57 +263,77 @@ async function configureIOS(configs) {
|
|
|
239
263
|
</array>
|
|
240
264
|
`;
|
|
241
265
|
}
|
|
242
|
-
|
|
266
|
+
|
|
243
267
|
console.log('\nAdd the following to your Info.plist:');
|
|
244
268
|
console.log(plistAdditions);
|
|
245
269
|
}
|
|
246
270
|
|
|
247
271
|
async function configureAndroid(configs) {
|
|
248
272
|
console.log('\n🤖 Configuring Android...');
|
|
249
|
-
|
|
250
|
-
const stringsPath = path.join(
|
|
273
|
+
|
|
274
|
+
const stringsPath = path.join(
|
|
275
|
+
process.cwd(),
|
|
276
|
+
'android',
|
|
277
|
+
'app',
|
|
278
|
+
'src',
|
|
279
|
+
'main',
|
|
280
|
+
'res',
|
|
281
|
+
'values',
|
|
282
|
+
'strings.xml'
|
|
283
|
+
);
|
|
251
284
|
if (!fs.existsSync(stringsPath)) {
|
|
252
|
-
console.log(
|
|
285
|
+
console.log(
|
|
286
|
+
'⚠️ Android strings.xml not found. Please configure manually.'
|
|
287
|
+
);
|
|
253
288
|
return;
|
|
254
289
|
}
|
|
255
|
-
|
|
256
|
-
let stringsAdditions =
|
|
257
|
-
|
|
290
|
+
|
|
291
|
+
let stringsAdditions =
|
|
292
|
+
'\n <!-- Capacitor Auth Manager Configuration -->\n';
|
|
293
|
+
|
|
258
294
|
// Google Sign-In
|
|
259
295
|
if (configs.google && configs.google.serverClientId) {
|
|
260
296
|
stringsAdditions += ` <string name="default_web_client_id">${configs.google.serverClientId}</string>\n`;
|
|
261
297
|
}
|
|
262
|
-
|
|
298
|
+
|
|
263
299
|
// Facebook
|
|
264
300
|
if (configs.facebook) {
|
|
265
301
|
stringsAdditions += ` <string name="facebook_app_id">${configs.facebook.appId}</string>\n`;
|
|
266
302
|
stringsAdditions += ` <string name="facebook_client_token">CLIENT_TOKEN_HERE</string>\n`;
|
|
267
303
|
}
|
|
268
|
-
|
|
304
|
+
|
|
269
305
|
console.log('\nAdd the following to your strings.xml:');
|
|
270
306
|
console.log(stringsAdditions);
|
|
271
|
-
|
|
307
|
+
|
|
272
308
|
// Manifest additions
|
|
273
309
|
const manifestAdditions = `
|
|
274
310
|
<!-- Add to AndroidManifest.xml -->
|
|
275
|
-
${
|
|
311
|
+
${
|
|
312
|
+
configs.google
|
|
313
|
+
? `
|
|
276
314
|
<meta-data
|
|
277
315
|
android:name="com.google.android.gms.auth.api.signin.GoogleSignInOptions"
|
|
278
316
|
android:value="@string/default_web_client_id" />
|
|
279
|
-
`
|
|
280
|
-
|
|
317
|
+
`
|
|
318
|
+
: ''
|
|
319
|
+
}
|
|
320
|
+
${
|
|
321
|
+
configs.facebook
|
|
322
|
+
? `
|
|
281
323
|
<meta-data
|
|
282
324
|
android:name="com.facebook.sdk.ApplicationId"
|
|
283
325
|
android:value="@string/facebook_app_id"/>
|
|
284
326
|
<meta-data
|
|
285
327
|
android:name="com.facebook.sdk.ClientToken"
|
|
286
328
|
android:value="@string/facebook_client_token"/>
|
|
287
|
-
`
|
|
329
|
+
`
|
|
330
|
+
: ''
|
|
331
|
+
}
|
|
288
332
|
`;
|
|
289
|
-
|
|
333
|
+
|
|
290
334
|
console.log('\nAdd the following to your AndroidManifest.xml:');
|
|
291
335
|
console.log(manifestAdditions);
|
|
292
336
|
}
|
|
293
337
|
|
|
294
338
|
// Run configuration
|
|
295
|
-
configure().catch(console.error);
|
|
339
|
+
configure().catch(console.error);
|