Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rayhanadev/replidentity-lib
Typescript/Node.js port of go-replidentity
https://github.com/rayhanadev/replidentity-lib
authentication replidentity replit replit-api
Last synced: about 2 months ago
JSON representation
Typescript/Node.js port of go-replidentity
- Host: GitHub
- URL: https://github.com/rayhanadev/replidentity-lib
- Owner: rayhanadev
- License: mit
- Created: 2022-09-14T15:19:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-14T21:55:49.000Z (over 2 years ago)
- Last Synced: 2024-09-16T00:31:44.396Z (3 months ago)
- Topics: authentication, replidentity, replit, replit-api
- Language: TypeScript
- Homepage: https://replit.com/@RayhanADev/replidentity-lib
- Size: 104 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Repl Identity
(for Typescript/Javascript!)
From [go-replidentity](https://github.com/replit/go-replidentity)
> Repl Identity stores a REPL_IDENTITY token in every Repl automatically. This token is a signed PASETO that includes verifiable repl identity data (such as the user in the repl, and the repl ID).
>
> **WARNING: in their current form, these tokens are very forwardable! You should only send these tokens to repls that you trust, or between repls that you own.**
>
> This package provides the necessary code to verify these tokens.
>
> Check the example at tests/identity.test.js for an example usage. You can also see this in action at https://replit.com/@RayhanADev/replidentity-lib. If you are logged in to Replit, you'll see your username when you click "Run" on the Cover Page - that's Repl Identity at work.## Install
```sh
# with NPM
$ npm install replidentity# with Yarn
$ yarn add replidentity
```## Usage
```js
import * as replidentity from 'replidentity';async function main() {
let audience = 'another-cool-repl-id';
const identityToken = await replidentity.CreateIdentityTokenAddressedTo(audience);const parsedIdentity = await replidentity.VerifyIdentity(
identityToken,
audience,
replidentity.ReadPublicKeyFromEnv,
);console.log(`The identity token (${identityToken.length} bytes) is:`);
console.log(`
repl id: ${parsedIdentity.replid}
user: ${parsedIdentity.user}
slug: ${parsedIdentity.slug}
audience: ${parsedIdentity.aud}
ephemeral: ${parsedIdentity.ephemeral}
origin: ${parsedIdentity.originReplid}`);
}main();
```For more information, visit [the blog post](https://blog.replit.com/repl-identity)!