@tegis/server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/crypto/ed25519.d.ts +8 -0
- package/dist/crypto/jose.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/server.d.ts +16 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@tegis/server` are documented here. This project follows [semver](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## [0.1.0] — unreleased
|
|
6
|
+
|
|
7
|
+
Initial extraction from the Tegis reference SDK (formerly the private `@aegis/sdk`).
|
|
8
|
+
|
|
9
|
+
- `TegisServer.mintEntitlement(sub, assetId, opts)` — short-lived, EdDSA-signed entitlement grants.
|
|
10
|
+
- Vendored, zero-dependency crypto (Ed25519 + compact JWS) — no repo-relative imports; byte-parity
|
|
11
|
+
with the Go data plane's verifier (golden-vector gate).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Burak Saraloglu (okbrk)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @tegis/server
|
|
2
|
+
|
|
3
|
+
Backend SDK for **Tegis** — the content-protection gateway for video. Use it on your own server to
|
|
4
|
+
mint short-lived, signed **entitlement grants** that authorize one viewer to play one asset. The
|
|
5
|
+
tenant signing key never leaves your backend and never reaches the browser; Tegis validates each grant
|
|
6
|
+
against your published JWKS.
|
|
7
|
+
|
|
8
|
+
Zero npm dependencies (`node:crypto` only). Runs on Node ≥18 and Bun.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
bun add @tegis/server
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { TegisServer } from "@tegis/server";
|
|
20
|
+
|
|
21
|
+
const tegis = new TegisServer({
|
|
22
|
+
tid: "t_yourtenant", // your Tegis tenant id
|
|
23
|
+
issuer: "https://yourapp.example", // your token issuer
|
|
24
|
+
jwksKid: "k1", // key id, must match your published JWKS
|
|
25
|
+
signSeed: Buffer.from(process.env.TEGIS_SIGN_SEED!, "base64url"), // 32-byte Ed25519 seed — keep server-side
|
|
26
|
+
ttlSeconds: 300,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// In your "can this user watch this asset?" endpoint, after your own authz check:
|
|
30
|
+
const entitlement = tegis.mintEntitlement(userId, assetId, { maxRes: "1080p" });
|
|
31
|
+
return Response.json({ entitlement }); // the browser hands this to @tegis/player
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The browser never sees `signSeed`; it only receives the short-lived `entitlement`, which
|
|
35
|
+
[`@tegis/player`](https://www.npmjs.com/package/@tegis/player) exchanges for a playback grant.
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
- `new TegisServer(config: TegisServerConfig)`
|
|
40
|
+
- `.mintEntitlement(sub, assetId, opts?: { maxRes?: string; drm?: string }): string`
|
|
41
|
+
|
|
42
|
+
## Security
|
|
43
|
+
|
|
44
|
+
Treat `signSeed` like a private key: load it from a secret store, never log it, never ship it to the
|
|
45
|
+
client. Rotate by publishing a new `kid` in your JWKS.
|
|
46
|
+
|
|
47
|
+
MIT © okbrk
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type KeyObject } from "node:crypto";
|
|
2
|
+
export declare function privateKeyFromSeed(seed: Buffer): KeyObject;
|
|
3
|
+
export declare function publicRawFromSeed(seed: Buffer): Buffer;
|
|
4
|
+
export declare function signEd25519(seed: Buffer, msg: Buffer): Buffer;
|
|
5
|
+
export declare function verifyEd25519(pubRaw: Buffer, msg: Buffer, sig: Buffer): boolean;
|
|
6
|
+
export declare const b64u: (b: Buffer | Uint8Array) => string;
|
|
7
|
+
export declare const unb64u: (s: string) => Buffer<ArrayBuffer>;
|
|
8
|
+
export declare const utf8: (s: string) => Buffer<ArrayBuffer>;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface TegisServerConfig {
|
|
2
|
+
tid: string;
|
|
3
|
+
issuer: string;
|
|
4
|
+
jwksKid: string;
|
|
5
|
+
signSeed: Buffer;
|
|
6
|
+
ttlSeconds?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class TegisServer {
|
|
9
|
+
private cfg;
|
|
10
|
+
constructor(cfg: TegisServerConfig);
|
|
11
|
+
/** Mint a short-lived entitlement JWT authorizing one viewer to play one asset. */
|
|
12
|
+
mintEntitlement(sub: string, assetId: string, opts?: {
|
|
13
|
+
maxRes?: string;
|
|
14
|
+
drm?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tegis/server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Tegis backend SDK — mint short-lived, EdDSA-signed entitlement grants. The tenant signing key never leaves your server.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "okbrk <burak@okbrk.com>",
|
|
8
|
+
"homepage": "https://tegis.io",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/okbrk/aegis.git",
|
|
12
|
+
"directory": "reference/sdk-ts/packages/server"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"tegis",
|
|
16
|
+
"content-protection",
|
|
17
|
+
"anti-piracy",
|
|
18
|
+
"entitlement",
|
|
19
|
+
"drm",
|
|
20
|
+
"video",
|
|
21
|
+
"jws",
|
|
22
|
+
"eddsa",
|
|
23
|
+
"ed25519"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"CHANGELOG.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"test": "bun test",
|
|
50
|
+
"typecheck": "tsc --noEmit",
|
|
51
|
+
"clean": "rm -rf dist",
|
|
52
|
+
"build": "bun run clean && bun build ./src/index.ts --target=node --format=esm --outdir dist && tsc -p tsconfig.build.json && bun ../../scripts/fix-dts.ts dist",
|
|
53
|
+
"prepublishOnly": "bun run build"
|
|
54
|
+
}
|
|
55
|
+
}
|