capacitor-app-attest
v7.2.1
Published
Apple App Attest for Capacitor
Readme
Maintainers
| Maintainer | GitHub | Social | LinkedIn | | ---------------------- | ------------------------------------- | --------------------------------- | ------------------------------------------------------------------ | | Luan Freitas (ludufre) | ludufre | @ludufre | Luan Freitas |
Installation
npm install capacitor-app-attest
npx cap sync
# or using pnpm
pnpm install capacitor-app-attest
npx cap syncAdd App Attest capability to your iOS project in Xcode.
Examples
Credits
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).
API
isSupported()generateKey()attestKey(...)generateAssertion(...)storeKeyId(...)getStoredKeyId()clearStoredKeyId()
isSupported()
isSupported() => Promise<{ isSupported: boolean; }>Checks if App Attest is supported on the device
Returns: Promise<{ isSupported: boolean; }>
generateKey()
generateKey() => Promise<{ keyId: string; }>Generates a new key for App Attest
Returns: Promise<{ keyId: string; }>
attestKey(...)
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(...)
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(...)
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()
getStoredKeyId() => Promise<{ keyId: string | null; hasStoredKey: boolean; }>Retrieves the stored keyId locally
Returns: Promise<{ keyId: string | null; hasStoredKey: boolean; }>
clearStoredKeyId()
clearStoredKeyId() => Promise<{ success: boolean; }>Removes the stored keyId
Returns: Promise<{ success: boolean; }>
