116 lines
3.1 KiB
Plaintext
116 lines
3.1 KiB
Plaintext
- name: siwa
|
||
type: table
|
||
desc: Functions and constants for interacting Sign in with Apple.
|
||
[icon:ios]
|
||
members:
|
||
|
||
#*****************************************************************************************************
|
||
|
||
- name: is_supported
|
||
type: function
|
||
desc: Check if Sign in with Apple is available (iOS 13+).
|
||
|
||
|
||
#*****************************************************************************************************
|
||
|
||
- name: get_credential_state
|
||
type: function
|
||
desc: Get the credential state of a user.
|
||
|
||
parameters:
|
||
- name: user_id
|
||
type: string
|
||
desc: User id to get credential state for.
|
||
- name: callback
|
||
type: function
|
||
desc: Credential state callback function.
|
||
parameters:
|
||
- name: self
|
||
type: object
|
||
desc: The current object.
|
||
|
||
- name: state
|
||
type: table
|
||
desc: The credential state (user_id, credential_state)
|
||
|
||
examples:
|
||
- desc: |-
|
||
```lua
|
||
siwa.get_credential_state(id, function(self, data)
|
||
if data.credential_state == siwa.STATE_AUTHORIZED then
|
||
print("User has still authorized the application", data.user_id)
|
||
elseif data.credential_state == siwa.STATE_REVOKED then
|
||
print("User has revoked authorization for the application", data.user_id)
|
||
end
|
||
end)
|
||
```
|
||
|
||
#*****************************************************************************************************
|
||
|
||
- name: authenticate
|
||
type: function
|
||
desc: Show the Sign in with Apple UI
|
||
|
||
parameters:
|
||
- name: callback
|
||
type: function
|
||
desc: Authentication callback function.
|
||
parameters:
|
||
- name: self
|
||
type: object
|
||
desc: The current object.
|
||
|
||
- name: state
|
||
type: table
|
||
desc: The authentication result data (user_id, identity_token, email, first_name, family_name, status, result)
|
||
|
||
examples:
|
||
- desc: |-
|
||
```lua
|
||
siwa.authenticate(function(self, data)
|
||
print(data.identity_token)
|
||
print(data.user_id)
|
||
print(data.first_name, data.family_name)
|
||
print(data.email)
|
||
if data.user_status == siwa.STATUS_LIKELY_REAL then
|
||
print("Likely a real person")
|
||
end
|
||
end)
|
||
```
|
||
|
||
#*****************************************************************************************************
|
||
|
||
- name: STATE_NOT_FOUND
|
||
type: number
|
||
desc: The user can’t be found.
|
||
|
||
|
||
- name: STATE_UNKNOWN
|
||
type: number
|
||
desc: Unknown credential state.
|
||
|
||
|
||
- name: STATE_AUTHORIZED
|
||
type: number
|
||
desc: The user is authorized.
|
||
|
||
|
||
- name: STATE_REVOKED
|
||
type: number
|
||
desc: Authorization for the given user has been revoked.
|
||
|
||
|
||
- name: STATUS_UNKNOWN
|
||
type: number
|
||
desc: The system hasn’t determined whether the user might be a real person.
|
||
|
||
|
||
- name: STATUS_UNSUPPORTED
|
||
type: number
|
||
desc: The system can’t determine this user’s status as a real person.
|
||
|
||
|
||
- name: STATUS_LIKELY_REAL
|
||
type: number
|
||
desc: The user appears to be a real person.
|