@universal-packages/authentication-apple-module
v1.1.8
Published
Universal authentication apple module
Readme
Authentication Apple Module
Authentication module to handle apple authentication.
Install
npm install @universal-packages/authentication-apple-moduleAuthentication
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>' } }Module options
teamIdStringYour apple team id.clientIdStringYour id of the service certificate you created in the apple developer console it looks like an app id but is not that one.keyIdStringThe key id of the key you created in the apple developer console.p8CertificateStringWhen you created your key you downloaded a p8 certificate file, you can provide the content of the file here.p8CertificateLocationStringWhen you created your key you downloaded a p8 certificate file, you can provide the location of the file here.
Override required dynamics
These dynamics are required to be override to have a fully functional apple module.
find-or-create-user-by-apple-id
Logic to find or create a user by apple id or email.
PAYLOADObjectappleIdStringemailStringlocaleStringtimezoneString
RESULTUser
Not override required dynamics
after-sign-in-with-apple-failure
When something goes wrong during the sign in with apple process.
PAYLOADObjectmessageString
RESULTvoid
after-sign-in-with-apple-success
When the sign in with apple is successful.
PAYLOADObjectuserUser
RESULTvoid
Typescript
This library is developed in TypeScript and shipped fully typed.
Contributing
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.
