Skip to content

Commit c4a15f3

Browse files
committed
refactor: 어떤 키가 누락되었는지 더 로그를 자세히 띄우도록 개선
1 parent b3354be commit c4a15f3

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

Firebase/functions/src/auth/apple.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,32 @@ function getAppleConfiguration() {
2424
const clientId = process.env.APPLE_CLIENT_ID;
2525
const keyId = process.env.APPLE_KEY_ID;
2626
const privateKey = (process.env.APPLE_PRIVATE_KEY || "").replace(/\\n/g, "\n");
27+
const configs = {
28+
APPLE_TEAM_ID: teamId,
29+
APPLE_CLIENT_ID: clientId,
30+
APPLE_KEY_ID: keyId,
31+
APPLE_PRIVATE_KEY: privateKey
32+
};
33+
const missingKeys = Object.entries(configs)
34+
.filter(([, value]) => !value)
35+
.map(([key]) => key);
2736

28-
if (!teamId || !clientId || !keyId || !privateKey) {
29-
throw new HttpsError('internal', 'Missing Apple configuration');
37+
if (0 < missingKeys.length) {
38+
console.error("Missing Apple configuration", {
39+
missingKeys
40+
});
41+
throw new HttpsError(
42+
'internal',
43+
`Missing Apple configuration for: ${missingKeys.join(", ")}`
44+
);
3045
}
3146

32-
return { teamId, clientId, keyId, privateKey };
47+
return {
48+
teamId: teamId!,
49+
clientId: clientId!,
50+
keyId: keyId!,
51+
privateKey: privateKey!
52+
};
3353
}
3454

3555
export const requestAppleCustomToken = onCall({

0 commit comments

Comments
 (0)