瀏覽代碼

doc(game): sign_in return types

Bryan Lee 1 年之前
父節點
當前提交
00a4f81ecc
共有 2 個文件被更改,包括 60 次插入22 次删除
  1. 18 21
      project/authentication/providers/auth_provider.gd
  2. 42 1
      project/services/apple_game_center_service.gd

+ 18 - 21
project/authentication/providers/auth_provider.gd

@@ -37,22 +37,9 @@ func initialize() -> Result:
 	return await err.to_promise().settled
 
 
+## Sign in to the authentication server. The server will set a `access_token`
+## cookie and also return the token as JSON.
 ## [codeblock]
-## User {
-##   id: String
-##   name?: String
-## }
-##
-## Token {
-##   value: String
-##   expires_at: String
-## }
-##
-## UserWithAuthProviders {
-##   user: User
-##   providers: Array<AuthProvider>
-## }
-##
 ## SignInSuccess {
 ##   type: "success"
 ##   payload: {
@@ -68,12 +55,22 @@ func initialize() -> Result:
 ## }
 ##
 ## SignInResult = SignInSuccess | SignInPendingLinkOrCreate
-## [/codeblock]
-
-
-## Sign in to the authentication server. The server will set a `access_token`
-## cookie and also return the token as JSON.
-## [codeblock]
+##
+## User {
+##   id: String
+##   name?: String
+## }
+##
+## Token {
+##   value: String
+##   expires_at: String
+## }
+##
+## UserWithAuthProviders {
+##   user: User
+##   providers: Array<AuthProvider>
+## }
+##
 ## @returns Result<SignInResult, String>
 ## [/codeblock]
 func server_sign_in() -> Result:

+ 42 - 1
project/services/apple_game_center_service.gd

@@ -47,7 +47,7 @@ func _process(_delta: float) -> void:
 ##   | AuthenticationSuccess
 ##   | AuthenticatoinError
 ##
-## @returns Promise<AuthenticationResult, String>
+## @returns Promise<AuthenticationResult>
 ## [/codeblock]
 func authenticate() -> Promise:
 	game_center.authenticate()
@@ -64,3 +64,44 @@ func authenticate() -> Promise:
 		# Auto-disconnected when `response_handler` is deallocated.
 		pending_event.connect(response_handler)
 	)
+
+
+## [codeblock]
+## RequestIdVerificationSignatureSuccess {
+##   type: "identity_verification_signature"
+##   result: "ok"
+##   public_key_url: String
+##   signature: String
+##   salt: String
+##   timestamp: int
+##   player_id: String
+## }
+##
+## RequestIdVerificationSignatureError {
+##   type: "identity_verification_signature"
+##   result: "error"
+##   error_code: int
+##   error_description: String
+## }
+##
+## RequestIdVerificationSignatureResult = |
+##   | RequestIdVerificationSignatureSuccess
+##   | RequestIdVerificationSignatureError
+##
+## @returns Promise<RequestIdVerificationSignatureResult>
+## [/codeblock]
+func request_identity_verification_signature():
+	game_center.request_identity_verification_signature()
+
+	return Promise.new(func (resolve, reject):
+		var response_handler := func (payload: Dictionary):
+			if payload.type != "identity_verification_signature":
+				return
+			if payload.result != "ok":
+				reject.call(payload)
+			else:
+				resolve.call(payload)
+		
+		# Auto-disconnected when `response_handler` is deallocated.
+		pending_event.connect(response_handler)
+	)