Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 017e93d

Browse files
committed
update name to AccessToken
1 parent c25636d commit 017e93d

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
JS := js
22

3+
echo:
4+
$(MAKE) -C $(JS) echo
5+
36
build:
47
$(MAKE) -C $(JS) build
58

examples/pulsebeam.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Context;
22
use clap::{Parser, Subcommand};
3-
use pulsebeam_core::{App, PeerClaims, PeerPolicy};
3+
use pulsebeam_core::{AccessToken, PeerClaims, PeerPolicy};
44

55
#[derive(Parser)]
66
#[command(author, version, about, long_about = None)]
@@ -54,7 +54,7 @@ fn main() -> anyhow::Result<()> {
5454
.or_else(|| std::env::var("PULSEBEAM_API_SECRET").ok())
5555
.context("PULSEBEAM_API_SECRET must be provided either as a CLI argument or an environment variable")?;
5656

57-
let app = App::new(&api_key, &api_secret);
57+
let app = AccessToken::new(&api_key, &api_secret);
5858

5959
match &cli.command {
6060
Commands::CreateToken {

js/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
12
TARGET := bundler
23

34
build:
45
$(MAKE) build-target
56
$(MAKE) build-target TARGET=deno
67

78
build-target:
8-
wasm-pack build --target $(TARGET) --out-dir $(PWD)/pkg-$(TARGET) --release --no-pack --weak-refs
9+
wasm-pack build --target $(TARGET) --out-dir $(ROOT_DIR)/pkg-$(TARGET) --release --no-pack --weak-refs
910
# jsr requires explicit d.ts reference, https://github.com/jsr-io/jsr/issues/370#issuecomment-2044467118
10-
sed -i '1s~^~/// <reference types="./pulsebeam_core.d.ts" />\n~' $(PWD)/pkg-$(TARGET)/pulsebeam_core.js
11-
sed -i '/free(): void;/d' $(PWD)/pkg-$(TARGET)/pulsebeam_core.d.ts
12-
# sed -i '/^export function __/d' $(PWD)/pkg-$(TARGET)/*.wasm.d.ts
13-
# sed -i '/^export const __/d' $(PWD)/pkg-$(TARGET)/*.wasm.d.ts
11+
sed -i '1s~^~/// <reference types="./pulsebeam_core.d.ts" />\n~' $(ROOT_DIR)/pkg-$(TARGET)/pulsebeam_core.js
12+
sed -i '/free(): void;/d' $(ROOT_DIR)/pkg-$(TARGET)/pulsebeam_core.d.ts
13+
# sed -i '/^export function __/d' $(ROOT_DIR)/pkg-$(TARGET)/*.wasm.d.ts
14+
# sed -i '/^export const __/d' $(ROOT_DIR)/pkg-$(TARGET)/*.wasm.d.ts
1415

1516
test: build
1617
deno test -A app.test.ts

js/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ Here's a step-by-step guide to using `@pulsebeam/server` to generate a token:
5858
### Example
5959

6060
```ts
61-
import { App, PeerPolicy, PeerClaims } from "@pulsebeam/server/node";
61+
import { AccessToken, PeerPolicy, PeerClaims } from "@pulsebeam/server";
6262

6363
// Step 1: Initialize app
64-
const { APP_ID, APP_SECRET } = process.env;
65-
const app = new App(APP_ID, APP_SECRET);
64+
const { API_KEY, API_SECRET } = process.env;
65+
const app = new AccessToken(API_KEY, API_SECRET);
6666

6767
// Step 2: Listen for JWT requests from your clients'
6868
router.post('/auth', (req, res) => {
@@ -79,7 +79,7 @@ router.post('/auth', (req, res) => {
7979

8080
### Explanation
8181

82-
* Set <APP_ID> and <APP_SECRET> with your credentials obtained from PulseBeam.
82+
* Set <API_KEY> and <API_SECRET> with your credentials obtained from PulseBeam.
8383
* PeerClaims specify the peer's group and ID within your application.
8484
* PeerPolicy define which peers this peer can connect to.
8585
* createToken generates a JWT token based on the provided claims and expiration time.

js/app.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { App, PeerClaims, PeerPolicy } from "./pkg-bundler/pulsebeam_core.js";
1+
import {
2+
AccessToken,
3+
PeerClaims,
4+
PeerPolicy,
5+
} from "./pkg-bundler/pulsebeam_core.js";
26

3-
const app = new App(
7+
const app = new AccessToken(
48
"kid_73d8caa6c387d46c",
59
"sk_7edea599046490dfd271b863b03398d2b613812b1f23efd023ca3b08026d3e67",
610
);

js/app.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { App, PeerClaims, PeerPolicy } from "./pkg-deno/pulsebeam_core.js";
1+
import {
2+
AccessToken,
3+
PeerClaims,
4+
PeerPolicy,
5+
} from "./pkg-deno/pulsebeam_core.js";
26
import { assertEquals } from "jsr:@std/assert";
37

48
Deno.test({
59
name: "create token",
610
fn: () => {
7-
const app = new App(
11+
const app = new AccessToken(
812
"kid_73d8caa6c387d46c",
913
"sk_7edea599046490dfd271b863b03398d2b613812b1f23efd023ca3b08026d3e67",
1014
);

0 commit comments

Comments
 (0)