capacitor-app-attest
Ionic Capacitor plugin for App Attest from Apple
Maintainer | GitHub | Social | |
---|---|---|---|
Luan Freitas (ludufre) | ludufre | @ludufre | Luan Freitas |
npm install capacitor-app-attest
npx cap sync
# or using pnpm
pnpm install capacitor-app-attest
npx cap sync
This plugin is based on the App Attest feature from Apple, which provides a way to attest the integrity of your app and its interactions with your backend. WWDC 2021 session 10244 provides a good overview of how to use it.
Backend validation example in ./example-backend
is based on the node-app-attest-example (@uebelack).
isSupported()
generateKey()
attestKey(...)
generateAssertion(...)
storeKeyId(...)
getStoredKeyId()
clearStoredKeyId()
isSupported() => Promise<{ isSupported: boolean; }>
Checks if App Attest is supported on the device
Returns: Promise<{ isSupported: boolean; }>
generateKey() => Promise<{ keyId: string; }>
Generates a new key for App Attest
Returns: Promise<{ keyId: string; }>
attestKey(options: { keyId: string; challenge: string; }) => Promise<{ attestation: string; keyId: string; challenge: string; }>
Attests a key using a challenge
Param | Type | Description |
---|---|---|
options |
{ keyId: string; challenge: string; } |
- Object containing the keyId and challenge. |
Returns: Promise<{ attestation: string; keyId: string; challenge: string; }>
generateAssertion(options: { keyId: string; payload: string; }) => Promise<{ assertion: string; keyId: string; }>
Generates an assertion for a payload
Param | Type | Description |
---|---|---|
options |
{ keyId: string; payload: string; } |
- Object containing the keyId and payload |
Returns: Promise<{ assertion: string; keyId: string; }>
storeKeyId(options: { keyId: string; }) => Promise<{ success: boolean; }>
Stores the keyId locally in UserDefaults
Param | Type | Description |
---|---|---|
options |
{ keyId: string; } |
- Object containing the keyId to store. |
Returns: Promise<{ success: boolean; }>
getStoredKeyId() => Promise<{ keyId: string | null; hasStoredKey: boolean; }>
Retrieves the stored keyId locally
Returns: Promise<{ keyId: string | null; hasStoredKey: boolean; }>
clearStoredKeyId() => Promise<{ success: boolean; }>
Removes the stored keyId
Returns: Promise<{ success: boolean; }>