Skip to main content
Home

Generate API keys and tokens used by 4Players ODIN.

This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
100%
Published
8 months ago (2.2.0)

@4players/odin-tokens

npm npm npm

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 = await generator.createToken("my room", "john doe");

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

Terminology

Term Description
AccessKey Gives 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.
SecretKey Generated from the AccessKey, it is based on the Ed25519-Curve and used to sign a Token generated by the customer.
PublicKey Generated from the AccessKey, it is based on the Ed25519-Curve and must be uploaded to 4Players so that a generated Token can be verified.
KeyId A shortened PublicKey, included in Token, making it possible to identify what PublicKey must be used to verify the Token.
Token A JWT given to the game clients that allows them to connect to a voice/video chat room in the ODIN network.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";
or

Import directly with a jsr specifier

import * as odin_tokens from "jsr:@4players/odin-tokens";

Add Package

pnpm i jsr:@4players/odin-tokens
or (using pnpm 10.8 or older)
pnpm dlx jsr add @4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";

Add Package

yarn add jsr:@4players/odin-tokens
or (using Yarn 4.8 or older)
yarn dlx jsr add @4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";

Add Package

vlt install jsr:@4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";

Add Package

npx jsr add @4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";

Add Package

bunx jsr add @4players/odin-tokens

Import symbol

import * as odin_tokens from "@4players/odin-tokens";