@hasna/tenants 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/LICENSE +191 -0
- package/README.md +86 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +228 -0
- package/dist/db.d.ts +22 -0
- package/dist/db.js +480 -0
- package/dist/generated/storage-kit/health.d.ts +19 -0
- package/dist/generated/storage-kit/index.d.ts +7 -0
- package/dist/generated/storage-kit/migrations.d.ts +47 -0
- package/dist/generated/storage-kit/mode.d.ts +47 -0
- package/dist/generated/storage-kit/pool.d.ts +33 -0
- package/dist/generated/storage-kit/query.d.ts +35 -0
- package/dist/generated/storage-kit/tls.d.ts +25 -0
- package/dist/idp/backfill.d.ts +12 -0
- package/dist/idp/ids.d.ts +24 -0
- package/dist/idp/mailer.d.ts +58 -0
- package/dist/idp/migrations.d.ts +10 -0
- package/dist/idp/passwords.d.ts +4 -0
- package/dist/idp/policy.d.ts +27 -0
- package/dist/idp/service.d.ts +103 -0
- package/dist/idp/store.d.ts +205 -0
- package/dist/idp/tokens.d.ts +89 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +2129 -0
- package/dist/migrations.d.ts +3 -0
- package/dist/migrations.js +452 -0
- package/dist/sdk/client.d.ts +115 -0
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.js +88 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2149 -0
- package/dist/server/openapi.d.ts +819 -0
- package/dist/server/serve.d.ts +41 -0
- package/dist/version.d.ts +3 -0
- package/package.json +82 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiKeyStore, type ApiKeyVerifier } from "@hasna/contracts/auth";
|
|
2
|
+
import type { PoolQueryClient } from "../generated/storage-kit/index.js";
|
|
3
|
+
import { AuthService } from "../idp/service.js";
|
|
4
|
+
import { type JwkPublic } from "../idp/tokens.js";
|
|
5
|
+
export declare const TENANTS_SERVE_APP = "tenants";
|
|
6
|
+
export interface ServeOptions {
|
|
7
|
+
port?: number;
|
|
8
|
+
host?: string;
|
|
9
|
+
/** Provide a pre-built cloud client (tests). Otherwise built from env. */
|
|
10
|
+
client?: PoolQueryClient;
|
|
11
|
+
/** Called on process close to release the pool (tests may omit). */
|
|
12
|
+
close?: () => Promise<void>;
|
|
13
|
+
/** Override the HMAC signing secret. Defaults to env. */
|
|
14
|
+
signingSecret?: string;
|
|
15
|
+
/** Called on each auth decision for the AUDIT trail. */
|
|
16
|
+
audit?: (event: unknown) => void;
|
|
17
|
+
/** Provide a pre-built IdP auth service (tests). Otherwise built from env. */
|
|
18
|
+
auth?: AuthService;
|
|
19
|
+
}
|
|
20
|
+
export interface RunningServer {
|
|
21
|
+
port: number;
|
|
22
|
+
hostname: string;
|
|
23
|
+
stop: () => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
interface Handler {
|
|
26
|
+
client: PoolQueryClient;
|
|
27
|
+
close: () => Promise<void>;
|
|
28
|
+
verifier: ApiKeyVerifier;
|
|
29
|
+
keys: ApiKeyStore;
|
|
30
|
+
auth: AuthService;
|
|
31
|
+
/** Cached JWKS public keys for token verification (short TTL). */
|
|
32
|
+
getJwks: () => Promise<JwkPublic[]>;
|
|
33
|
+
version: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildHandler(options?: ServeOptions): Promise<Handler>;
|
|
36
|
+
export declare function createFetchHandler(options?: ServeOptions): Promise<{
|
|
37
|
+
handler: Handler;
|
|
38
|
+
fetch: (req: Request) => Promise<Response>;
|
|
39
|
+
}>;
|
|
40
|
+
export declare function startServer(options?: ServeOptions): Promise<RunningServer>;
|
|
41
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hasna/tenants",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Hasna fleet tenant auth / IdP: tenants, users, memberships, service principals, sessions + OTP login front door, and asymmetric (EdDSA) fleet token issuance with a published JWKS. Distinct from @hasna/identities (the agent registry).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"tenants": "dist/cli.js",
|
|
10
|
+
"tenants-serve": "dist/server/index.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./sdk": {
|
|
18
|
+
"types": "./dist/sdk/index.d.ts",
|
|
19
|
+
"import": "./dist/sdk/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./db": {
|
|
22
|
+
"types": "./dist/db.d.ts",
|
|
23
|
+
"import": "./dist/db.js"
|
|
24
|
+
},
|
|
25
|
+
"./migrations": {
|
|
26
|
+
"types": "./dist/migrations.d.ts",
|
|
27
|
+
"import": "./dist/migrations.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"build": "bun run clean && bun build ./src/index.ts ./src/cli.ts ./src/server/index.ts ./src/sdk/index.ts ./src/db.ts ./src/migrations.ts --outdir dist --target bun --external pg --external @hasna/contracts && tsc --emitDeclarationOnly --outDir dist",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "bun test",
|
|
40
|
+
"dev:cli": "bun run src/cli.ts",
|
|
41
|
+
"dev:serve": "bun run src/server/index.ts",
|
|
42
|
+
"verify:release": "bun run typecheck && bun test && bun run build"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"tenants",
|
|
46
|
+
"tenancy",
|
|
47
|
+
"idp",
|
|
48
|
+
"auth",
|
|
49
|
+
"login",
|
|
50
|
+
"jwks",
|
|
51
|
+
"eddsa",
|
|
52
|
+
"fleet",
|
|
53
|
+
"cli"
|
|
54
|
+
],
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"registry": "https://registry.npmjs.org",
|
|
57
|
+
"access": "restricted"
|
|
58
|
+
},
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "git",
|
|
61
|
+
"url": "git+https://github.com/hasna/tenants.git"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/hasna/tenants",
|
|
64
|
+
"bugs": {
|
|
65
|
+
"url": "https://github.com/hasna/tenants/issues"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"bun": ">=1.0.0"
|
|
69
|
+
},
|
|
70
|
+
"author": "Andrei Hasna <andrei@hasna.com>",
|
|
71
|
+
"license": "Apache-2.0",
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/bun": "^1.2.4",
|
|
74
|
+
"@types/node": "^22.13.4",
|
|
75
|
+
"@types/pg": "^8.11.10",
|
|
76
|
+
"typescript": "^5.7.3"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"@hasna/contracts": "0.4.2",
|
|
80
|
+
"pg": "^8.16.3"
|
|
81
|
+
}
|
|
82
|
+
}
|