Initial push

This commit is contained in:
2021-02-25 00:51:33 +01:00
parent 13844c3e93
commit 1525e40378
16 changed files with 1508 additions and 0 deletions

115
siwa/api/siwa.script_api Normal file
View File

@@ -0,0 +1,115 @@
- 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 cant 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 hasnt determined whether the user might be a real person.
- name: STATUS_UNSUPPORTED
type: number
desc: The system cant determine this users status as a real person.
- name: STATUS_LIKELY_REAL
type: number
desc: The user appears to be a real person.