@securitydept/client-react 0.2.0 → 0.3.0-beta.10
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 +101 -84
- package/dist/index.mjs +404 -71
- package/dist/index.mjs.map +1 -1
- package/dist/tanstack-router/index.d.mts +76 -415
- package/dist/tanstack-router/index.mjs +96 -380
- package/dist/tanstack-router/index.mjs.map +1 -1
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -2,4 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Client React 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/client-react)
|
|
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,88 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { CreateFoundationEnvironmentOptions, DisposableTrait, EventStreamTrait, FoundationEnvironment, InteropObservableTrait, ReadableSignalTrait, ResourceSnapshot, ResourceTrait, SYMBOL_DISPOSE, SecuritydeptInjectorTrait, SecuritydeptProvider as SecuritydeptProvider$1, SubscribableTrait, TimeTrait } from "@securitydept/client";
|
|
2
|
+
import { DependencyList, ReactNode, RefObject } from "react";
|
|
3
|
+
//#region src/environment.d.ts
|
|
4
|
+
type ReactEnvironmentCreatorOptions = {
|
|
5
|
+
providers?: readonly SecuritydeptProvider$1[];
|
|
6
|
+
};
|
|
7
|
+
type ReactEnvironmentCreator<TOptions extends ReactEnvironmentCreatorOptions, TEnvironment extends FoundationEnvironment> = (options: TOptions) => TEnvironment;
|
|
8
|
+
interface CreateEnvironmentForReactOptions extends CreateFoundationEnvironmentOptions {}
|
|
9
|
+
type CreateEnvironmentForReactWithBaseOptions<TBaseOptions extends ReactEnvironmentCreatorOptions, TEnvironment extends FoundationEnvironment> = Omit<TBaseOptions, "providers" | "createBaseEnvironment"> & {
|
|
10
|
+
createBaseEnvironment: ReactEnvironmentCreator<TBaseOptions, TEnvironment>;
|
|
11
|
+
providers?: readonly SecuritydeptProvider$1[];
|
|
12
|
+
};
|
|
13
|
+
declare function createEnvironmentForReact(): FoundationEnvironment;
|
|
14
|
+
declare function createEnvironmentForReact(options: CreateEnvironmentForReactOptions): FoundationEnvironment;
|
|
15
|
+
declare function createEnvironmentForReact<TBaseOptions extends ReactEnvironmentCreatorOptions, TEnvironment extends FoundationEnvironment>(options: CreateEnvironmentForReactWithBaseOptions<TBaseOptions, TEnvironment>): TEnvironment;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/hooks/use-initial-ref.d.ts
|
|
18
|
+
declare function useInitialRef<T>(initialize: () => T): RefObject<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/injection/index.d.ts
|
|
21
|
+
declare const SecuritydeptContext: import("react").Context<any>;
|
|
22
|
+
interface SecuritydeptProviderProps {
|
|
23
|
+
readonly injector: SecuritydeptInjectorTrait;
|
|
24
|
+
readonly children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
declare function SecuritydeptProvider({ injector, children }: SecuritydeptProviderProps): import("react").JSX.Element;
|
|
27
|
+
declare function useSecuritydeptContext(): SecuritydeptInjectorTrait;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/interop.d.ts
|
|
30
|
+
declare function useSignal<T>(source: ReadableSignalTrait<T>): T;
|
|
31
|
+
declare function useResourceSnapshot<T>(resource: ResourceTrait<T>): ResourceSnapshot<T>;
|
|
32
|
+
declare function useResourceSnapshot<T>(snapshot: ReadableSignalTrait<ResourceSnapshot<T>>): ResourceSnapshot<T>;
|
|
33
|
+
declare function useResourceSnapshot<T>(compute: () => ResourceSnapshot<T>, dependencies: DependencyList): ResourceSnapshot<T>;
|
|
34
|
+
interface UseInteropObservableOptions<T> {
|
|
35
|
+
initialValue?: T;
|
|
36
|
+
requireSync?: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare function useInteropObservable<T>(source: InteropObservableTrait<T> | SubscribableTrait<T>): T | undefined;
|
|
39
|
+
declare function useInteropObservable<T>(source: InteropObservableTrait<T> | SubscribableTrait<T>, options: UseInteropObservableOptions<T> & {
|
|
40
|
+
initialValue?: undefined;
|
|
41
|
+
requireSync?: false;
|
|
42
|
+
}): T | undefined;
|
|
43
|
+
declare function useInteropObservable<T>(source: InteropObservableTrait<T> | SubscribableTrait<T>, options: UseInteropObservableOptions<T | null> & {
|
|
44
|
+
initialValue?: null;
|
|
45
|
+
requireSync?: false;
|
|
46
|
+
}): T | null;
|
|
47
|
+
declare function useInteropObservable<T>(source: InteropObservableTrait<T> | SubscribableTrait<T>, options: UseInteropObservableOptions<T> & {
|
|
48
|
+
initialValue?: undefined;
|
|
49
|
+
requireSync: true;
|
|
50
|
+
}): T;
|
|
51
|
+
declare function useInteropObservable<T, const U extends T>(source: InteropObservableTrait<T> | SubscribableTrait<T>, options: UseInteropObservableOptions<T | U> & {
|
|
52
|
+
initialValue: U;
|
|
53
|
+
requireSync?: false;
|
|
54
|
+
}): T | U;
|
|
55
|
+
declare function useEventStream<T>(source: EventStreamTrait<T>, handler: (event: T) => void, options?: {
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
}): void;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/query-store.d.ts
|
|
60
|
+
type QueryStoreKeyValue = null | boolean | number | string | readonly QueryStoreKeyValue[] | {
|
|
61
|
+
readonly [key: string]: QueryStoreKeyValue;
|
|
62
|
+
};
|
|
63
|
+
type QueryStoreKey = readonly QueryStoreKeyValue[];
|
|
64
|
+
interface QueryStoreOptions {
|
|
65
|
+
readonly time: TimeTrait;
|
|
66
|
+
readonly gcTimeMs?: number;
|
|
67
|
+
}
|
|
68
|
+
interface ProvideQueryStoreOptions {
|
|
69
|
+
readonly gcTimeMs?: number;
|
|
70
|
+
}
|
|
71
|
+
declare class QueryStore implements DisposableTrait {
|
|
72
|
+
[SYMBOL_DISPOSE]: () => void;
|
|
73
|
+
static readonly defaultOptions: Readonly<{
|
|
74
|
+
gcTimeMs: 300000;
|
|
75
|
+
}>;
|
|
76
|
+
private readonly queries;
|
|
77
|
+
private readonly weakKeyIds;
|
|
78
|
+
private readonly scheduler;
|
|
79
|
+
private readonly gcTimeMs;
|
|
80
|
+
private nextWeakKeyId;
|
|
81
|
+
private disposed;
|
|
82
|
+
constructor(options: QueryStoreOptions);
|
|
83
|
+
getWeakKeyId(value: object): string;
|
|
84
|
+
dispose(): void;
|
|
85
|
+
private removeQuery;
|
|
86
|
+
}
|
|
87
|
+
declare function provideQueryStore(options?: ProvideQueryStoreOptions): readonly SecuritydeptProvider$1[];
|
|
88
|
+
declare function useQueryStore(): QueryStore;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/suspense-resource.d.ts
|
|
91
|
+
interface UseSuspenseResourceValueOptions {
|
|
92
|
+
readonly queryKey?: QueryStoreKey;
|
|
93
|
+
readonly gcTimeMs?: number;
|
|
94
|
+
readonly retainWhilePending?: boolean;
|
|
19
95
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* Use at the app level or at feature-route boundaries to establish
|
|
24
|
-
* planner-host scopes. Child components inherit the nearest provider.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* // App-level (default sequential strategy)
|
|
29
|
-
* <AuthPlannerHostProvider>
|
|
30
|
-
* <App />
|
|
31
|
-
* </AuthPlannerHostProvider>
|
|
32
|
-
*
|
|
33
|
-
* // Feature-route with custom chooser
|
|
34
|
-
* <AuthPlannerHostProvider selectCandidate={showChooser}>
|
|
35
|
-
* <FeatureRoutes />
|
|
36
|
-
* </AuthPlannerHostProvider>
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function AuthPlannerHostProvider({
|
|
40
|
-
selectCandidate,
|
|
41
|
-
plannerHost,
|
|
42
|
-
children
|
|
43
|
-
}: AuthPlannerHostProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
44
|
-
/**
|
|
45
|
-
* Look up the nearest {@link PlannerHost} from the React Context tree.
|
|
46
|
-
*
|
|
47
|
-
* Throws an explicit error if no provider is found, preventing
|
|
48
|
-
* silent fallback behavior.
|
|
49
|
-
*/
|
|
50
|
-
declare function useAuthPlannerHost(): PlannerHost;
|
|
51
|
-
/** Props for {@link AuthRequirementsClientSetProvider}. */
|
|
52
|
-
interface AuthRequirementsClientSetProviderProps {
|
|
53
|
-
/** The scoped set to provide at this level. */
|
|
54
|
-
scopedSet: ScopedRequirementsClientSet;
|
|
55
|
-
children: ReactNode;
|
|
96
|
+
interface UseSuspenseComputedResourceValueOptions extends Omit<UseSuspenseResourceValueOptions, "queryKey"> {
|
|
97
|
+
readonly dependencies: DependencyList;
|
|
98
|
+
readonly queryKey: QueryStoreKey;
|
|
56
99
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* Automatically resolves the effective client set by composing with the
|
|
61
|
-
* parent scope's options according to the declared composition strategy.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```tsx
|
|
65
|
-
* // Feature route: merge OIDC requirement with parent's session requirement
|
|
66
|
-
* <AuthRequirementsClientSetProvider
|
|
67
|
-
* scopedSet={{
|
|
68
|
-
* composition: RequirementsClientSetComposition.Merge,
|
|
69
|
-
* options: [oidcClientOption],
|
|
70
|
-
* }}
|
|
71
|
-
* >
|
|
72
|
-
* <ProtectedFeature />
|
|
73
|
-
* </AuthRequirementsClientSetProvider>
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
declare function AuthRequirementsClientSetProvider({
|
|
77
|
-
scopedSet,
|
|
78
|
-
children
|
|
79
|
-
}: AuthRequirementsClientSetProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
80
|
-
/**
|
|
81
|
-
* Get the effective requirements client set for the current React tree scope.
|
|
82
|
-
*
|
|
83
|
-
* Returns the resolved options after applying all parent/child composition.
|
|
84
|
-
*/
|
|
85
|
-
declare function useEffectiveClientSet(): readonly AuthGuardClientOption[];
|
|
100
|
+
declare function useSuspenseResourceValue<T>(resource: ResourceTrait<T>, options?: UseSuspenseResourceValueOptions): T;
|
|
101
|
+
declare function useSuspenseResourceValue<T>(snapshot: ReadableSignalTrait<ResourceSnapshot<T>>, options?: UseSuspenseResourceValueOptions): T;
|
|
102
|
+
declare function useSuspenseResourceValue<T>(compute: () => ResourceSnapshot<T>, options: UseSuspenseComputedResourceValueOptions): T;
|
|
86
103
|
//#endregion
|
|
87
|
-
export {
|
|
104
|
+
export { CreateEnvironmentForReactOptions, CreateEnvironmentForReactWithBaseOptions, type ProvideQueryStoreOptions, QueryStore, type QueryStoreKey, type QueryStoreKeyValue, type QueryStoreOptions, ReactEnvironmentCreator, ReactEnvironmentCreatorOptions, SecuritydeptContext, SecuritydeptProvider, SecuritydeptProviderProps, UseInteropObservableOptions, type UseSuspenseComputedResourceValueOptions, type UseSuspenseResourceValueOptions, createEnvironmentForReact, provideQueryStore, useEventStream, useInitialRef, useInteropObservable, useQueryStore, useResourceSnapshot, useSecuritydeptContext, useSignal, useSuspenseResourceValue };
|
|
88
105
|
//# sourceMappingURL=index.d.mts.map
|