@clearance/api 0.1.4
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 +29 -0
- package/LICENSE.md +20 -0
- package/dist/server.d.ts +54 -0
- package/dist/server.js +2321 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clearance contributors
|
|
4
|
+
|
|
5
|
+
This project includes substantial portions of software originally developed
|
|
6
|
+
by Bereket Engida and used under the following license terms.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
The MIT License (MIT)
|
|
11
|
+
Copyright (c) 2024 - present, Bereket Engida
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
14
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
15
|
+
the Software without restriction, including without limitation the rights to
|
|
16
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
17
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
26
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
27
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
28
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
29
|
+
DEALINGS IN THE SOFTWARE.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2024 - present, Bereket Engida
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
6
|
+
the Software without restriction, including without limitation the rights to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
DEALINGS IN THE SOFTWARE.
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { Context } from "hono";
|
|
3
|
+
import { type ManagementStore, type ResourceScope } from "@clearance/management";
|
|
4
|
+
import type { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
5
|
+
export declare const DEFAULT_MAX_REQUEST_BODY_BYTES: number;
|
|
6
|
+
export declare function resolveMaxRequestBodyBytes(env?: Record<string, string | undefined>): number;
|
|
7
|
+
declare function getStore(): Promise<ManagementStore>;
|
|
8
|
+
/**
|
|
9
|
+
* Long-lived API process: refresh so external CLI writes are visible before
|
|
10
|
+
* serving. Flushes pending local mutations first.
|
|
11
|
+
*/
|
|
12
|
+
declare function storeForRequest(): Promise<ManagementStore>;
|
|
13
|
+
/**
|
|
14
|
+
* Operator principal scope (server-side only)
|
|
15
|
+
* -------------------------------------------
|
|
16
|
+
* CLEARANCE_OPERATOR_TOKEN authenticates the operator. Project/environment
|
|
17
|
+
* authority is derived exclusively from server configuration:
|
|
18
|
+
* CLEARANCE_PROJECT_ID + CLEARANCE_ENV_ID, or the store's initialized
|
|
19
|
+
* meta.config after `init` (local single-project profile).
|
|
20
|
+
*
|
|
21
|
+
* Client headers `X-Clearance-Project-Id` / `X-Clearance-Environment-Id` are
|
|
22
|
+
* never used as authority. If present they must match principal scope
|
|
23
|
+
* (consistency check only) — they cannot broaden or select another scope.
|
|
24
|
+
*
|
|
25
|
+
* Resource routes reject with SCOPE_REQUIRED when principal scope is absent.
|
|
26
|
+
* Init and health remain usable without scope (bootstrapping).
|
|
27
|
+
*/
|
|
28
|
+
declare function principalScope(store: ManagementStore): ResourceScope;
|
|
29
|
+
declare function scopeForRequest(store: ManagementStore, c: Context): ResourceScope;
|
|
30
|
+
/** @deprecated Use principalScope — kept for tests that import scopeFromStore */
|
|
31
|
+
declare function scopeFromStore(store: ManagementStore): {
|
|
32
|
+
projectId?: string;
|
|
33
|
+
environmentId?: string;
|
|
34
|
+
};
|
|
35
|
+
/** @deprecated Prefer scopeForRequest — header check only, never authority */
|
|
36
|
+
declare function assertScope(store: ManagementStore, headerProject?: string | null, headerEnv?: string | null): ResourceScope;
|
|
37
|
+
declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
38
|
+
/**
|
|
39
|
+
* Build the response body that is safe to persist for a later replay.
|
|
40
|
+
* Generated temporary passwords are one-time delivery credentials: retaining
|
|
41
|
+
* one in either the Postgres companion table or the development memory backend
|
|
42
|
+
* would extend its lifetime to the idempotency TTL. A replay still returns the
|
|
43
|
+
* original user and status while explicitly reporting the omitted secret.
|
|
44
|
+
*/
|
|
45
|
+
declare function idempotencyReplayBody(path: string, body: string): string | null;
|
|
46
|
+
declare function readBoundedRequestBody(req: IncomingMessage): Promise<Buffer | undefined>;
|
|
47
|
+
/** Node HTTP bridge with a hard limit before Hono authentication/body parsing. */
|
|
48
|
+
declare function nodeRequestHandler(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
49
|
+
declare function installGracefulShutdown(server: Server, store: ManagementStore, options?: {
|
|
50
|
+
registerSignals?: boolean;
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
}): (signal: string) => Promise<void>;
|
|
53
|
+
declare function start(): Promise<Server<typeof IncomingMessage, typeof ServerResponse>>;
|
|
54
|
+
export { app, getStore, storeForRequest, start, assertScope, scopeFromStore, principalScope, scopeForRequest, nodeRequestHandler, readBoundedRequestBody, idempotencyReplayBody, installGracefulShutdown, };
|