Replit Identity
Supports TypeScript
Create and verify Replit Identity tokens.
const { create, verify } = require('replit-identity');
const audience = 'target-repl-id';
const token = await create(audience);
const info = await verify(token, audience);
console.log(info);
Installation
npm install replit-identity
Important: This package can only be used within a Replit environment.
API
The replit-identity
module exports the following functions:
create
Creates a new identity token.
- param:
audience
(string): The target audience for the token. - returns: A Promise resolving to the string token, or null on error.
verify
Verifies an existing identity token.
- param:
token
(string): The token to verify. - param:
audience
(string): The audience to verify against. - returns: A Promise resolving to an object containing token information, or null if the token is invalid.
Example return value:
const info = {
slug: "repl-name",
replId: "unique-repl-id",
audience: "target-repl-id",
username: "jane_doe" ,
userId: 12345,
runtime: {
interactive: {
cluster: 'example-cluster',
subcluster: 'example-subcluster'
},
hosting: {
cluster: 'example-cluster',
subcluster: 'example-subcluster'
},
deployment: true,
}
}