Authentication module to handle apple authentication.
npm install @universal-packages/authentication-apple-module
Enable the apple module in your authentication instance.
import { Authentication } from '@universal-packages/authentication-apple-module'
const authentication = new Authentication({
dynamicsLocation: './src',
secret: 'my secret',
modules: {
apple: {
enabled: true,
options: {
teamId: '<your-team-id>',
clientId: '<your-client-id>',
keyId: '<your-key-id>',
p8Certificate: '<your-p8-certificate>'
}
}
}
})
await authentication.loadDynamics()
const result = await authentication.performDynamic('sign-in-with-apple', { code: '<your-code>' })
console.log(result)
// > { status: 'success', user: { id: 69, username: 'username', createdAt: [Date], appleId: '<your-apple-id>' } }
-
teamId
String
Your apple team id. -
clientId
String
Your id of the service certificate you created in the apple developer console it looks like an app id but is not that one. -
keyId
String
The key id of the key you created in the apple developer console. -
p8Certificate
String
When you created your key you downloaded a p8 certificate file, you can provide the content of the file here. -
p8CertificateLocation
String
When you created your key you downloaded a p8 certificate file, you can provide the location of the file here.
These dynamics are required to be override to have a fully functional apple module.
Logic to find or create a user by apple id or email.
-
PAYLOAD
Object
-
appleId
String
-
email
String
-
locale
String
-
timezone
String
-
-
RESULT
User
When something goes wrong during the sign in with apple process.
-
PAYLOAD
Object
-
message
String
-
-
RESULT
void
When the sign in with apple is successful.
-
PAYLOAD
Object
-
user
User
-
-
RESULT
void
This library is developed in TypeScript and shipped fully typed.
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.