Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created plugin for apple authentication #11979

Merged
merged 2 commits into from Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/expo-apple-authentication/CHANGELOG.md
Expand Up @@ -6,6 +6,8 @@

### 🎉 New features

- Created config plugin ([#11979](https://github.com/expo/expo/pull/11979) by [@EvanBacon](https://github.com/EvanBacon))

### 🐛 Bug fixes

## 3.0.0 — 2021-01-15
Expand Down
1 change: 1 addition & 0 deletions packages/expo-apple-authentication/app.plugin.js
@@ -0,0 +1 @@
module.exports = require('./plugin/build/withAppleAuth')
4 changes: 3 additions & 1 deletion packages/expo-apple-authentication/package.json
Expand Up @@ -39,7 +39,9 @@
"react": "*",
"react-native": "*"
},
"dependencies": {},
"dependencies": {
"@expo/config-plugins": "^1.0.18"
},
"devDependencies": {
"expo-module-scripts": "~1.2.0"
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/expo-apple-authentication/plugin/jest.config.js
@@ -0,0 +1 @@
module.exports = require('expo-module-scripts/jest-preset-plugin');
@@ -0,0 +1,9 @@
import { setAppleAuthEntitlements } from '../withAppleAuthIOS';

describe(setAppleAuthEntitlements, () => {
it(`sets the apple auth entitlements`, () => {
expect(setAppleAuthEntitlements({ ios: { usesAppleSignIn: true } }, {})).toMatchObject({
'com.apple.developer.applesignin': ['Default'],
});
});
});
12 changes: 12 additions & 0 deletions packages/expo-apple-authentication/plugin/src/withAppleAuth.ts
@@ -0,0 +1,12 @@
import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';

import { withAppleAuthIOS } from './withAppleAuthIOS';

const pkg = require('expo-apple-authentication/package.json');

const withAppleAuth: ConfigPlugin = config => {
config = withAppleAuthIOS(config);
return config;
};

export default createRunOncePlugin(withAppleAuth, pkg.name, pkg.version);
@@ -0,0 +1,20 @@
import { ConfigPlugin, withEntitlementsPlist } from '@expo/config-plugins';
import { ExpoConfig } from '@expo/config-types';

export const withAppleAuthIOS: ConfigPlugin = config => {
return withEntitlementsPlist(config, config => {
config.modResults = setAppleAuthEntitlements(config, config.modResults);

return config;
});
};

export function setAppleAuthEntitlements(
config: Pick<ExpoConfig, 'ios'>,
entitlements: Record<string, any>
): Record<string, any> {
if (config.ios?.usesAppleSignIn) {
entitlements['com.apple.developer.applesignin'] = ['Default'];
}
return entitlements;
}
9 changes: 9 additions & 0 deletions packages/expo-apple-authentication/plugin/tsconfig.json
@@ -0,0 +1,9 @@
{
"extends": "expo-module-scripts/tsconfig.plugin",
"compilerOptions": {
"outDir": "build",
"rootDir": "src"
},
"include": ["./src"],
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
}