Commit 798a97cf authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Protocol changes for session token variables.

parent 1c61023c
Loading
Loading
Loading
Loading
+323 −246

File changed.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
@@ -52,12 +52,16 @@ message Account {
message AccountCustom {
  // A custom identifier.
  string id = 1;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 2;
}

// Send a device to the server. Used with authenticate/link/unlink and user.
message AccountDevice {
  // A device identifier. Should be obtained by a platform-specific device API.
  string id = 1;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 2;
}

// Send an email with password to the server. Used with authenticate/link/unlink.
@@ -66,12 +70,16 @@ message AccountEmail {
  string email = 1;
  // A password for the user account.
  string password = 2; // Ignored with unlink operations.
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 3;
}

// Send a Facebook token to the server. Used with authenticate/link/unlink.
message AccountFacebook {
  // The OAuth token received from Facebook to access their profile API.
  string token = 1;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 2;
}

// Send Apple's Game Center account credentials to the server. Used with authenticate/link/unlink.
@@ -90,18 +98,24 @@ message AccountGameCenter {
  string signature = 5;
  // The URL for the public encryption key.
  string public_key_url = 6;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 7;
}

// Send a Google token to the server. Used with authenticate/link/unlink.
message AccountGoogle {
  // The OAuth token received from Google to access their profile API.
  string token = 1;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 2;
}

// Send a Steam token to the server. Used with authenticate/link/unlink.
message AccountSteam {
  // The account token received from Steam to access their profile API.
  string token = 1;
  // Extra information that will be bundled in the session token.
  map<string, string> vars = 2;
}

// Add one or more friends to the current user.
+49 −0
Original line number Diff line number Diff line
@@ -2393,6 +2393,13 @@
        "id": {
          "type": "string",
          "description": "A custom identifier."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a custom ID to the server. Used with authenticate/link/unlink."
@@ -2403,6 +2410,13 @@
        "id": {
          "type": "string",
          "description": "A device identifier. Should be obtained by a platform-specific device API."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a device to the server. Used with authenticate/link/unlink and user."
@@ -2417,6 +2431,13 @@
        "password": {
          "type": "string",
          "description": "A password for the user account."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send an email with password to the server. Used with authenticate/link/unlink."
@@ -2427,6 +2448,13 @@
        "token": {
          "type": "string",
          "description": "The OAuth token received from Facebook to access their profile API."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a Facebook token to the server. Used with authenticate/link/unlink."
@@ -2458,6 +2486,13 @@
        "public_key_url": {
          "type": "string",
          "description": "The URL for the public encryption key."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send Apple's Game Center account credentials to the server. Used with authenticate/link/unlink."
@@ -2468,6 +2503,13 @@
        "token": {
          "type": "string",
          "description": "The OAuth token received from Google to access their profile API."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a Google token to the server. Used with authenticate/link/unlink."
@@ -2478,6 +2520,13 @@
        "token": {
          "type": "string",
          "description": "The account token received from Steam to access their profile API."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a Steam token to the server. Used with authenticate/link/unlink."
+7 −0
Original line number Diff line number Diff line
@@ -989,6 +989,13 @@
        "id": {
          "type": "string",
          "description": "A device identifier. Should be obtained by a platform-specific device API."
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Extra information that will be bundled in the session token."
        }
      },
      "description": "Send a device to the server. Used with authenticate/link/unlink and user."
+4 −1
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ const (
	// The username associated with the execution context.
	RUNTIME_CTX_USERNAME = "username"

	// Variables stored in the user's session token.
	RUNTIME_CTX_VARS = "vars"

	// The user session expiry in seconds associated with the execution context.
	RUNTIME_CTX_USER_SESSION_EXP = "user_session_exp"

@@ -764,7 +767,7 @@ type NakamaModule interface {
	AuthenticateGoogle(ctx context.Context, token, username string, create bool) (string, string, bool, error)
	AuthenticateSteam(ctx context.Context, token, username string, create bool) (string, string, bool, error)

	AuthenticateTokenGenerate(userID, username string, exp int64) (string, int64, error)
	AuthenticateTokenGenerate(userID, username string, vars map[string]string, exp int64) (string, int64, error)

	AccountGetId(ctx context.Context, userID string) (*api.Account, error)
	AccountsGetId(ctx context.Context, userIDs []string) ([]*api.Account, error)
Loading