@k9o/gate 0.0.0-stage → 1.0.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 +41 -0
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +110 -2
- package/dist/chunk-LZQ7MBXS.js +41 -0
- package/dist/chunk-LZQ7MBXS.js.map +1 -0
- package/dist/chunk-PEW6HZFB.js +51 -0
- package/dist/chunk-PEW6HZFB.js.map +1 -0
- package/dist/chunk-ZNFI2CQA.js +125 -0
- package/dist/chunk-ZNFI2CQA.js.map +1 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +717 -0
- package/dist/index.js +614 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt.d.ts +84 -0
- package/dist/jwt.js +12 -0
- package/dist/jwt.js.map +1 -0
- package/dist/mode.d.ts +82 -0
- package/dist/mode.js +13 -0
- package/dist/mode.js.map +1 -0
- package/dist/types.d.ts +250 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -4
- package/src/client-factory.ts +39 -0
- package/src/client.ts +175 -0
- package/src/errors.ts +117 -0
- package/src/gate.ts +385 -0
- package/src/idp-providers/identity-providers.ts +244 -0
- package/src/index.ts +62 -0
- package/src/jwt.ts +229 -0
- package/src/magic-link-redirects.ts +103 -0
- package/src/mode.ts +115 -0
- package/src/paths.ts +21 -0
- package/src/region.ts +85 -0
- package/src/types.ts +264 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate error shapes. `GateError` is `KError`-compatible per ch01 §2 —
|
|
3
|
+
* downstream catch blocks can `instanceof GateError`-narrow without
|
|
4
|
+
* importing the gateway's `KError` class directly (the SDK is a customer-
|
|
5
|
+
* facing dependency; reaching across to the gateway's internal error
|
|
6
|
+
* type would be a layering violation).
|
|
7
|
+
*
|
|
8
|
+
* The taxonomy below is the v0.1.0 closed set; additions follow the
|
|
9
|
+
* ch11 error-catalogue freeze cycle.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Closed-taxonomy error code per ch01 §2. Strings are the wire format —
|
|
13
|
+
* camelCase-cased KError families per the convention.
|
|
14
|
+
*/
|
|
15
|
+
type GateErrorCode = "UNAUTHENTICATED" | "INVALID_FIELD_VALUE" | "EMAIL_ALREADY_REGISTERED" | "INVALID_CREDENTIALS" | "SESSION_EXPIRED" | "REFRESH_TOKEN_INVALID" | "TIER_FEATURE_GATED" | "RBAC_DENY" | "FORBIDDEN" | "NOT_FOUND" | "GATE_REDIRECT_NOT_ALLOWED" | "POLICY_AUTHORING_AUTHORITY_INSUFFICIENT" | "UPSTREAM_UNAVAILABLE" | "INTERNAL_ERROR";
|
|
16
|
+
/**
|
|
17
|
+
* Surface error thrown by the SDK. Mirrors the gateway's `KError` shape
|
|
18
|
+
* per ch01 §2.1 — `code` (closed taxonomy), `message` (human-readable),
|
|
19
|
+
* `context` (structured per-code payload), `recommendation` (action the
|
|
20
|
+
* caller can take, or null when there's no canonical recommendation).
|
|
21
|
+
*/
|
|
22
|
+
declare class GateError extends Error {
|
|
23
|
+
readonly code: GateErrorCode;
|
|
24
|
+
readonly context: Readonly<Record<string, unknown>>;
|
|
25
|
+
readonly recommendation: string | null;
|
|
26
|
+
/** HTTP status the gateway returned (if the error came from a wire response). */
|
|
27
|
+
readonly status: number | null;
|
|
28
|
+
constructor(init: {
|
|
29
|
+
code: GateErrorCode;
|
|
30
|
+
message: string;
|
|
31
|
+
context?: Record<string, unknown>;
|
|
32
|
+
recommendation?: string | null;
|
|
33
|
+
status?: number | null;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Wire-shape sentinel matching the gateway's `KError` JSON payload. The
|
|
38
|
+
* client uses this to recognise gateway responses and rehydrate them
|
|
39
|
+
* into a `GateError` instance with the right code + context preserved.
|
|
40
|
+
*/
|
|
41
|
+
type KErrorWire = {
|
|
42
|
+
code: string;
|
|
43
|
+
message: string;
|
|
44
|
+
context?: Record<string, unknown>;
|
|
45
|
+
recommendation?: string | null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Narrow a wire `KError` to a strongly-typed `GateError`. Unknown codes
|
|
49
|
+
* pass through as `INTERNAL_ERROR` with the original code preserved in
|
|
50
|
+
* `context.originalCode` so consumers don't lose telemetry when the
|
|
51
|
+
* server-side taxonomy outpaces the SDK's bundled enum.
|
|
52
|
+
*/
|
|
53
|
+
declare function gateErrorFromWire(wire: KErrorWire, status: number): GateError;
|
|
54
|
+
|
|
55
|
+
export { GateError, type GateErrorCode, type KErrorWire, gateErrorFromWire };
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|