@4players/odin-tokens 中文文档教程

发布于 3年前 浏览 25 项目主页 更新于 3年前

@4players/odin-tokens

npmnpmnpm

这是一个轻量级模块,用于生成 4Players ODIN 使用的 API 密钥和令牌。

4Players ODIN 是一个跨平台软件开发工具包 (SDK),使开发人员能够将语音和视频聊天技术集成到多人游戏中。

Flowchart

graph TB
  RandomBytes[Random Bytes] --> AccessKey;
  AccessKey --> PublicKey;
  AccessKey --> SecretKey;
  PublicKey --> KeyId;

Example

import { TokenGenerator } from "@4players/odin-tokens";

const accessKey = "<YOUR API KEY HERE>";
const generator = new TokenGenerator(accessKey);
const token = generator.createToken("my room", "john doe");

console.log(`generated a new token: ${token}`);

Terminology

TermDescription
AccessKeyGives access to the ODIN network for a customer. It is a 44 character long Base64-String, which consists of a version, random bytes and a checksum.
SecretKeyGenerated from the AccessKey, it is based on the Ed25519-Curve and used to sign a Token generated by the customer.
PublicKeyGenerated from the AccessKey, it is based on the Ed25519-Curve and must be uploaded to 4Players so that a generated Token can be verified.
KeyIdA shortened PublicKey, included in Token, making it possible to identify what PublicKey must be used to verify the Token.
TokenA JWT given to the game clients that allows them to connect to a voice/video chat room in the ODIN network.

@4players/odin-tokens

npmnpmnpm

This is a lightweight module to generate API keys and tokens used by 4Players ODIN.

4Players ODIN is a cross-platform software development kit (SDK) that enables developers to integrate voice and video chat technology into multiplayer games.

Flowchart

graph TB
  RandomBytes[Random Bytes] --> AccessKey;
  AccessKey --> PublicKey;
  AccessKey --> SecretKey;
  PublicKey --> KeyId;

Example

import { TokenGenerator } from "@4players/odin-tokens";

const accessKey = "<YOUR API KEY HERE>";
const generator = new TokenGenerator(accessKey);
const token = generator.createToken("my room", "john doe");

console.log(`generated a new token: ${token}`);

Terminology

TermDescription
AccessKeyGives access to the ODIN network for a customer. It is a 44 character long Base64-String, which consists of a version, random bytes and a checksum.
SecretKeyGenerated from the AccessKey, it is based on the Ed25519-Curve and used to sign a Token generated by the customer.
PublicKeyGenerated from the AccessKey, it is based on the Ed25519-Curve and must be uploaded to 4Players so that a generated Token can be verified.
KeyIdA shortened PublicKey, included in Token, making it possible to identify what PublicKey must be used to verify the Token.
TokenA JWT given to the game clients that allows them to connect to a voice/video chat room in the ODIN network.
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文