@securitydept/basic-auth-context-client-react 0.2.0-beta.1
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/dist/index.d.mts +20 -0
- package/dist/index.mjs +22 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +26 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BasicAuthContextClient, BasicAuthContextClientConfig } from "@securitydept/basic-auth-context-client";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
interface BasicAuthContextProviderProps {
|
|
7
|
+
/** Auth-context config only (baseUrl, zones, redirect policy). */
|
|
8
|
+
config: BasicAuthContextClientConfig;
|
|
9
|
+
/** React host glue only; runtime capability wiring does not live here. */
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare function BasicAuthContextProvider({
|
|
13
|
+
config,
|
|
14
|
+
children
|
|
15
|
+
}: BasicAuthContextProviderProps): _$react_jsx_runtime0.JSX.Element;
|
|
16
|
+
/** Access the `BasicAuthContextClient` from React context. */
|
|
17
|
+
declare function useBasicAuthContext(): BasicAuthContextClient;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BasicAuthContextClient, type BasicAuthContextClientConfig, BasicAuthContextProvider, BasicAuthContextProviderProps, useBasicAuthContext };
|
|
20
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BasicAuthContextClient } from "@securitydept/basic-auth-context-client";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/index.tsx
|
|
5
|
+
const BasicAuthContext = createContext(null);
|
|
6
|
+
function BasicAuthContextProvider({ config, children }) {
|
|
7
|
+
const client = useMemo(() => new BasicAuthContextClient(config), [config]);
|
|
8
|
+
return /* @__PURE__ */ jsx(BasicAuthContext.Provider, {
|
|
9
|
+
value: client,
|
|
10
|
+
children
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** Access the `BasicAuthContextClient` from React context. */
|
|
14
|
+
function useBasicAuthContext() {
|
|
15
|
+
const ctx = useContext(BasicAuthContext);
|
|
16
|
+
if (!ctx) throw new Error("useBasicAuthContext must be used inside <BasicAuthContextProvider>");
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { BasicAuthContextClient, BasicAuthContextProvider, useBasicAuthContext };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["// Basic Auth Context Client — React adapter\n//\n// Canonical import path:\n// import { ... } from \"@securitydept/basic-auth-context-client-react\"\n//\n// Provides React context / hooks for integrating BasicAuthContextClient in a\n// React application. The core client lives in @securitydept/basic-auth-context-client;\n// this package supplies the React-specific binding layer only.\n//\n// Stability: provisional (React adapter)\n\nimport type { BasicAuthContextClientConfig } from \"@securitydept/basic-auth-context-client\";\nimport { BasicAuthContextClient } from \"@securitydept/basic-auth-context-client\";\nimport { createContext, type ReactNode, useContext, useMemo } from \"react\";\n\nexport type { BasicAuthContextClientConfig };\nexport { BasicAuthContextClient };\n\nconst BasicAuthContext = createContext<BasicAuthContextClient | null>(null);\n\nexport interface BasicAuthContextProviderProps {\n\t/** Auth-context config only (baseUrl, zones, redirect policy). */\n\tconfig: BasicAuthContextClientConfig;\n\t/** React host glue only; runtime capability wiring does not live here. */\n\tchildren: ReactNode;\n}\n\nexport function BasicAuthContextProvider({\n\tconfig,\n\tchildren,\n}: BasicAuthContextProviderProps) {\n\tconst client = useMemo(() => new BasicAuthContextClient(config), [config]);\n\n\treturn (\n\t\t<BasicAuthContext.Provider value={client}>\n\t\t\t{children}\n\t\t</BasicAuthContext.Provider>\n\t);\n}\n\n/** Access the `BasicAuthContextClient` from React context. */\nexport function useBasicAuthContext(): BasicAuthContextClient {\n\tconst ctx = useContext(BasicAuthContext);\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t\"useBasicAuthContext must be used inside <BasicAuthContextProvider>\",\n\t\t);\n\t}\n\treturn ctx;\n}\n"],"mappings":";;;;AAkBA,MAAM,mBAAmB,cAA6C,KAAK;AAS3E,SAAgB,yBAAyB,EACxC,QACA,YACiC;CACjC,MAAM,SAAS,cAAc,IAAI,uBAAuB,OAAO,EAAE,CAAC,OAAO,CAAC;AAE1E,QACC,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAChC;EAC0B,CAAA;;;AAK9B,SAAgB,sBAA8C;CAC7D,MAAM,MAAM,WAAW,iBAAiB;AACxC,KAAI,CAAC,IACJ,OAAM,IAAI,MACT,qEACA;AAEF,QAAO"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@securitydept/basic-auth-context-client-react",
|
|
3
|
+
"version": "0.2.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"monorepo-tsc": "./src/index.ts",
|
|
9
|
+
"types": "./dist/index.d.mts",
|
|
10
|
+
"import": "./dist/index.mjs"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsdown",
|
|
18
|
+
"typecheck": "tsc -b"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@securitydept/basic-auth-context-client": "workspace:*"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=19.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|