@securitydept/session-context-client 0.3.0-beta.1 → 0.3.0-beta.11
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/README.md +6 -0
- package/dist/index.d.mts +179 -13
- package/dist/index.mjs +674 -2
- package/dist/index.mjs.map +1 -0
- package/package.json +12 -11
- package/dist/client-BcZv4X8b.mjs +0 -183
- package/dist/client-BcZv4X8b.mjs.map +0 -1
- package/dist/client-Dzfx3BXp.d.mts +0 -83
- package/dist/server/index.d.mts +0 -66
- package/dist/server/index.mjs +0 -50
- package/dist/server/index.mjs.map +0 -1
- package/dist/web/index.d.mts +0 -32
- package/dist/web/index.mjs +0 -22
- package/dist/web/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Session Context Client of the SecurityDept TypeScript SDK, a layered authentication and authorization toolkit built as reusable Rust crates, a TypeScript client SDK workspace, and reference server/web apps.
|
|
4
4
|
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
- [Package documentation](https://www.npmjs.com/package/@securitydept/session-context-client)
|
|
8
|
+
- [SecurityDept TypeScript SDK guide](https://github.com/ethaxon/securitydept/blob/main/docs/en/007-CLIENT_SDK_GUIDE.md)
|
|
9
|
+
- [SecurityDept architecture](https://github.com/ethaxon/securitydept/blob/main/docs/en/001-ARCHITECTURE.md)
|
|
10
|
+
|
|
5
11
|
Repository: [ethaxon/securitydept](https://github.com/ethaxon/securitydept)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { CancellationTokenOptions, ClientError, DisposableTrait, EventStreamTrait, FoundationEnvironment, IdentityPrincipal, OperationSpanTrait, ReadableSignalTrait, ResourceSnapshot, ResourceTrait, SYMBOL_DISPOSE, SecuritydeptInjectorTrait, SecuritydeptProvider, SpanTrait } from "@securitydept/client";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
/** Session principal — shared authenticated principal semantics via @securitydept/client. */
|
|
4
|
+
type SessionPrincipal = IdentityPrincipal;
|
|
5
|
+
/** Session info returned from the server. */
|
|
6
|
+
interface SessionInfo {
|
|
7
|
+
principal: SessionPrincipal;
|
|
8
|
+
attributes?: Record<string, unknown>;
|
|
9
|
+
extra?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface SessionContextClientTracingOptions {
|
|
12
|
+
target?: string;
|
|
13
|
+
prefix?: string;
|
|
14
|
+
}
|
|
15
|
+
interface SessionContextOperationOptions extends CancellationTokenOptions {}
|
|
16
|
+
interface SessionLoginWithRedirectOptions extends CancellationTokenOptions {
|
|
17
|
+
postAuthRedirectUri?: string;
|
|
18
|
+
}
|
|
19
|
+
/** Configuration for the Session Context Client. */
|
|
20
|
+
interface SessionContextClientConfig {
|
|
21
|
+
id?: string;
|
|
22
|
+
/** Base URL of the SecurityDept server. */
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
/** Login path (default: "/auth/session/login"). */
|
|
25
|
+
loginPath?: string;
|
|
26
|
+
/** Logout path (default: "/auth/session/logout"). */
|
|
27
|
+
logoutPath?: string;
|
|
28
|
+
/** User info endpoint path (default: "/auth/session/user-info"). */
|
|
29
|
+
userInfoPath?: string;
|
|
30
|
+
autoStart?: boolean;
|
|
31
|
+
tracing?: SessionContextClientTracingOptions;
|
|
32
|
+
}
|
|
33
|
+
interface ResolvedSessionContextClientConfig {
|
|
34
|
+
id: string;
|
|
35
|
+
baseUrl: string;
|
|
36
|
+
loginPath: string;
|
|
37
|
+
logoutPath: string;
|
|
38
|
+
userInfoPath: string;
|
|
39
|
+
tracing: Required<SessionContextClientTracingOptions>;
|
|
40
|
+
}
|
|
41
|
+
declare const SessionContextEventType: {
|
|
42
|
+
readonly SessionRefreshStarted: "session.refresh.started";
|
|
43
|
+
readonly SessionRefreshSucceeded: "session.refresh.succeeded";
|
|
44
|
+
readonly SessionRefreshFailed: "session.refresh.failed";
|
|
45
|
+
readonly SessionLogoutStarted: "session.logout.started";
|
|
46
|
+
readonly SessionLogoutSucceeded: "session.logout.succeeded";
|
|
47
|
+
readonly SessionLogoutFailed: "session.logout.failed";
|
|
48
|
+
};
|
|
49
|
+
type SessionContextEventType = (typeof SessionContextEventType)[keyof typeof SessionContextEventType];
|
|
50
|
+
interface SessionContextEventBase {
|
|
51
|
+
readonly at: number;
|
|
52
|
+
readonly client: {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
type SessionContextEventData = {
|
|
57
|
+
readonly type: typeof SessionContextEventType.SessionRefreshStarted;
|
|
58
|
+
readonly session: SessionInfo | null;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: typeof SessionContextEventType.SessionRefreshSucceeded;
|
|
61
|
+
readonly session: SessionInfo | null;
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: typeof SessionContextEventType.SessionRefreshFailed;
|
|
64
|
+
readonly session: SessionInfo | null;
|
|
65
|
+
readonly error: ClientError;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: typeof SessionContextEventType.SessionLogoutStarted;
|
|
68
|
+
readonly session: SessionInfo | null;
|
|
69
|
+
} | {
|
|
70
|
+
readonly type: typeof SessionContextEventType.SessionLogoutSucceeded;
|
|
71
|
+
readonly session: null;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: typeof SessionContextEventType.SessionLogoutFailed;
|
|
74
|
+
readonly session: SessionInfo | null;
|
|
75
|
+
readonly error: ClientError;
|
|
76
|
+
};
|
|
77
|
+
type SessionContextEvent = SessionContextEventBase & SessionContextEventData;
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/client.d.ts
|
|
80
|
+
interface SessionContextOperationSignals {
|
|
81
|
+
readonly startPending: ReadableSignalTrait<boolean>;
|
|
82
|
+
readonly refreshPending: ReadableSignalTrait<boolean>;
|
|
83
|
+
readonly logoutPending: ReadableSignalTrait<boolean>;
|
|
84
|
+
readonly loginRedirectPending: ReadableSignalTrait<boolean>;
|
|
85
|
+
}
|
|
10
86
|
/**
|
|
11
|
-
*
|
|
87
|
+
* Session Context Client.
|
|
12
88
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
89
|
+
* Owns session state, lifecycle, login/logout navigation, and tracing.
|
|
90
|
+
* Host capabilities are resolved once through FoundationEnvironment at
|
|
91
|
+
* construction time.
|
|
15
92
|
*/
|
|
93
|
+
declare class SessionContextClient implements DisposableTrait {
|
|
94
|
+
[SYMBOL_DISPOSE]: () => void;
|
|
95
|
+
static defaultOptions: {
|
|
96
|
+
readonly loginPath: "/auth/session/login";
|
|
97
|
+
readonly logoutPath: "/auth/session/logout";
|
|
98
|
+
readonly userInfoPath: "/auth/session/user-info";
|
|
99
|
+
readonly tracing: {
|
|
100
|
+
readonly target: "session-context-client";
|
|
101
|
+
readonly prefix: "session_context";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
private readonly _environment;
|
|
105
|
+
private readonly _config;
|
|
106
|
+
private readonly _span;
|
|
107
|
+
private readonly _rootCancellation;
|
|
108
|
+
private readonly _destroyed;
|
|
109
|
+
private readonly destroyed$;
|
|
110
|
+
private readonly _sessionSnapshotSignal;
|
|
111
|
+
private readonly _operationSignals;
|
|
112
|
+
private readonly _eventSubject;
|
|
113
|
+
private readonly _refreshCommandSubject;
|
|
114
|
+
private readonly _refreshResponseSubject;
|
|
115
|
+
private readonly _logoutCommandSubject;
|
|
116
|
+
private readonly _logoutResponseSubject;
|
|
117
|
+
private readonly _startOnce;
|
|
118
|
+
readonly id: string;
|
|
119
|
+
readonly sessionSnapshot: ReadableSignalTrait<ResourceSnapshot<SessionInfo | null>>;
|
|
120
|
+
readonly sessionResource: ResourceTrait<SessionInfo | null>;
|
|
121
|
+
readonly isAuthenticated: ResourceTrait<boolean>;
|
|
122
|
+
readonly sessionOperations: SessionContextOperationSignals;
|
|
123
|
+
readonly events: EventStreamTrait<SessionContextEvent>;
|
|
124
|
+
protected get environment(): FoundationEnvironment;
|
|
125
|
+
protected get span(): SpanTrait;
|
|
126
|
+
protected get config(): ResolvedSessionContextClientConfig;
|
|
127
|
+
static fromEnvironmentConfig(options: {
|
|
128
|
+
readonly config: SessionContextClientConfig;
|
|
129
|
+
readonly environment: FoundationEnvironment;
|
|
130
|
+
}): SessionContextClient;
|
|
131
|
+
static fromInjector(injector: SecuritydeptInjectorTrait): SessionContextClient;
|
|
132
|
+
protected constructor(config: SessionContextClientConfig, environment: FoundationEnvironment);
|
|
133
|
+
start(operationSpan?: OperationSpanTrait): Promise<SessionInfo | null>;
|
|
134
|
+
refresh(options?: SessionContextOperationOptions): Promise<SessionInfo | null>;
|
|
135
|
+
private _refresh;
|
|
136
|
+
logout(options?: SessionContextOperationOptions): Promise<void>;
|
|
137
|
+
private _logout;
|
|
138
|
+
loginWithRedirect(options?: SessionLoginWithRedirectOptions): Promise<void>;
|
|
139
|
+
private _loginWithRedirect;
|
|
140
|
+
dispose(): void;
|
|
141
|
+
private _dispatchRefresh;
|
|
142
|
+
private _dispatchLogout;
|
|
143
|
+
private _executeRefresh;
|
|
144
|
+
private _executeLogout;
|
|
145
|
+
private _fetchSessionInfo;
|
|
146
|
+
private _createLoginRedirectUrl;
|
|
147
|
+
private _createLogoutUrl;
|
|
148
|
+
private _readCurrentSession;
|
|
149
|
+
private _emitSessionEvent;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/contracts/parsers.d.ts
|
|
153
|
+
declare function parseSessionInfoPayload(body: unknown): SessionInfo;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/contracts/schemas.d.ts
|
|
156
|
+
declare const SessionInfoSchema: import("arktype/internal/variants/object.ts").ObjectType<(In: {
|
|
157
|
+
[x: string]: any;
|
|
158
|
+
}) => import("arktype").Out<SessionInfo>, {}>;
|
|
16
159
|
declare const SessionUserInfoResponseSchema: any;
|
|
17
160
|
//#endregion
|
|
18
|
-
|
|
161
|
+
//#region src/error.d.ts
|
|
162
|
+
declare const SessionContextErrorCode: {
|
|
163
|
+
readonly OperationFailed: "session.operation_failed";
|
|
164
|
+
readonly ClientDisposed: "session.client_disposed";
|
|
165
|
+
readonly RouterUnavailable: "session.router_unavailable";
|
|
166
|
+
readonly InvalidSessionPayload: "session.invalid_user_info_payload";
|
|
167
|
+
};
|
|
168
|
+
type SessionContextErrorCode = (typeof SessionContextErrorCode)[keyof typeof SessionContextErrorCode];
|
|
169
|
+
declare const SessionContextSource: {
|
|
170
|
+
readonly SessionContext: "session-context";
|
|
171
|
+
};
|
|
172
|
+
type SessionContextSource = (typeof SessionContextSource)[keyof typeof SessionContextSource];
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/providers.d.ts
|
|
175
|
+
interface ProvideSessionContextOptions {
|
|
176
|
+
readonly config: SessionContextClientConfig;
|
|
177
|
+
}
|
|
178
|
+
declare function provideSessionContext(options: ProvideSessionContextOptions): readonly SecuritydeptProvider[];
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/tokens.d.ts
|
|
181
|
+
declare const SESSION_CONTEXT_CLIENT: any;
|
|
182
|
+
declare const SESSION_CONTEXT_CLIENT_CONFIG: any;
|
|
183
|
+
//#endregion
|
|
184
|
+
export { type ProvideSessionContextOptions, SESSION_CONTEXT_CLIENT, SESSION_CONTEXT_CLIENT_CONFIG, SessionContextClient, type SessionContextClientConfig, type SessionContextClientTracingOptions, SessionContextErrorCode, type SessionContextEvent, SessionContextEventType, type SessionContextOperationOptions, SessionContextSource, type SessionInfo, SessionInfoSchema, type SessionLoginWithRedirectOptions, type SessionPrincipal, SessionUserInfoResponseSchema, parseSessionInfoPayload, provideSessionContext };
|
|
19
185
|
//# sourceMappingURL=index.d.mts.map
|