@easy-web/auth 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/dist/components/AuthProvider.d.ts +21 -0
- package/dist/components/AuthProvider.d.ts.map +1 -0
- package/dist/components/AuthProvider.js +30 -0
- package/dist/components/AuthProvider.js.map +1 -0
- package/dist/components/LoginButton.d.ts +16 -0
- package/dist/components/LoginButton.d.ts.map +1 -0
- package/dist/components/LoginButton.js +14 -0
- package/dist/components/LoginButton.js.map +1 -0
- package/dist/components/ProtectedContent.d.ts +30 -0
- package/dist/components/ProtectedContent.d.ts.map +1 -0
- package/dist/components/ProtectedContent.js +45 -0
- package/dist/components/ProtectedContent.js.map +1 -0
- package/dist/components/SharePointFileList.d.ts +8 -0
- package/dist/components/SharePointFileList.d.ts.map +1 -0
- package/dist/components/SharePointFileList.js +49 -0
- package/dist/components/SharePointFileList.js.map +1 -0
- package/dist/components/SharePointGallery.d.ts +9 -0
- package/dist/components/SharePointGallery.d.ts.map +1 -0
- package/dist/components/SharePointGallery.js +22 -0
- package/dist/components/SharePointGallery.js.map +1 -0
- package/dist/components/SharePointListView.d.ts +9 -0
- package/dist/components/SharePointListView.d.ts.map +1 -0
- package/dist/components/SharePointListView.js +17 -0
- package/dist/components/SharePointListView.js.map +1 -0
- package/dist/components/UserAvatar.d.ts +13 -0
- package/dist/components/UserAvatar.d.ts.map +1 -0
- package/dist/components/UserAvatar.js +31 -0
- package/dist/components/UserAvatar.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/graph/client.d.ts +9 -0
- package/dist/graph/client.d.ts.map +1 -0
- package/dist/graph/client.js +18 -0
- package/dist/graph/client.js.map +1 -0
- package/dist/graph/sharepoint.d.ts +55 -0
- package/dist/graph/sharepoint.d.ts.map +1 -0
- package/dist/graph/sharepoint.js +39 -0
- package/dist/graph/sharepoint.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +24 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +29 -0
- package/dist/hooks/useAuth.js.map +1 -0
- package/dist/hooks/useGraphClient.d.ts +8 -0
- package/dist/hooks/useGraphClient.d.ts.map +1 -0
- package/dist/hooks/useGraphClient.js +22 -0
- package/dist/hooks/useGraphClient.js.map +1 -0
- package/dist/hooks/useSharePointFiles.d.ts +9 -0
- package/dist/hooks/useSharePointFiles.d.ts.map +1 -0
- package/dist/hooks/useSharePointFiles.js +30 -0
- package/dist/hooks/useSharePointFiles.js.map +1 -0
- package/dist/hooks/useSharePointList.d.ts +9 -0
- package/dist/hooks/useSharePointList.d.ts.map +1 -0
- package/dist/hooks/useSharePointList.js +30 -0
- package/dist/hooks/useSharePointList.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/msalConfig.d.ts +8 -0
- package/dist/msalConfig.d.ts.map +1 -0
- package/dist/msalConfig.js +34 -0
- package/dist/msalConfig.js.map +1 -0
- package/dist/scopes.d.ts +13 -0
- package/dist/scopes.d.ts.map +1 -0
- package/dist/scopes.js +15 -0
- package/dist/scopes.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { AuthConfig } from "../config";
|
|
3
|
+
interface AuthProviderProps {
|
|
4
|
+
config: AuthConfig;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Root authentication provider. Wrap ALL auth-dependent UI inside this component.
|
|
9
|
+
*
|
|
10
|
+
* CRITICAL ASTRO CONSTRAINT:
|
|
11
|
+
* React context does NOT cross Astro island boundaries. All components that use
|
|
12
|
+
* useAuth(), useMsal(), ProtectedContent, LoginButton, etc. must be children of
|
|
13
|
+
* the SAME AuthProvider React tree — rendered in a single `client:only="react"` island.
|
|
14
|
+
*
|
|
15
|
+
* Usage in Astro:
|
|
16
|
+
* <AuthShell client:only="react" config={siteConfig.auth} />
|
|
17
|
+
* where AuthShell renders <AuthProvider config={config}>...</AuthProvider>
|
|
18
|
+
*/
|
|
19
|
+
export declare function AuthProvider({ config, children }: AuthProviderProps): import("react").JSX.Element;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=AuthProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../src/components/AuthProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,UAAU,iBAAiB;IACzB,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,+BAanE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import { MsalProvider } from "@azure/msal-react";
|
|
4
|
+
import { PublicClientApplication } from "@azure/msal-browser";
|
|
5
|
+
import { buildMsalConfig } from "../msalConfig";
|
|
6
|
+
/**
|
|
7
|
+
* Root authentication provider. Wrap ALL auth-dependent UI inside this component.
|
|
8
|
+
*
|
|
9
|
+
* CRITICAL ASTRO CONSTRAINT:
|
|
10
|
+
* React context does NOT cross Astro island boundaries. All components that use
|
|
11
|
+
* useAuth(), useMsal(), ProtectedContent, LoginButton, etc. must be children of
|
|
12
|
+
* the SAME AuthProvider React tree — rendered in a single `client:only="react"` island.
|
|
13
|
+
*
|
|
14
|
+
* Usage in Astro:
|
|
15
|
+
* <AuthShell client:only="react" config={siteConfig.auth} />
|
|
16
|
+
* where AuthShell renders <AuthProvider config={config}>...</AuthProvider>
|
|
17
|
+
*/
|
|
18
|
+
export function AuthProvider({ config, children }) {
|
|
19
|
+
// Singleton ref — one PCA instance per client ID, shared across re-renders
|
|
20
|
+
const instanceRef = useRef(null);
|
|
21
|
+
const msalInstance = useMemo(() => {
|
|
22
|
+
if (!instanceRef.current) {
|
|
23
|
+
instanceRef.current = new PublicClientApplication(buildMsalConfig(config));
|
|
24
|
+
}
|
|
25
|
+
return instanceRef.current;
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, [config.clientId, config.tenantId]);
|
|
28
|
+
return _jsx(MsalProvider, { instance: msalInstance, children: children });
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=AuthProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../../src/components/AuthProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAQhD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAqB;IAClE,2EAA2E;IAC3E,MAAM,WAAW,GAAG,MAAM,CAAiC,IAAI,CAAC,CAAC;IAEjE,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE;QAChC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,WAAW,CAAC,OAAO,GAAG,IAAI,uBAAuB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,WAAW,CAAC,OAAO,CAAC;QAC3B,uDAAuD;IACzD,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEvC,OAAO,KAAC,YAAY,IAAC,QAAQ,EAAE,YAAY,YAAG,QAAQ,GAAgB,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface LoginButtonProps {
|
|
2
|
+
/** Optional CSS class(es) to apply to the button */
|
|
3
|
+
className?: string;
|
|
4
|
+
/** Text when user is not authenticated (default: "Sign in") */
|
|
5
|
+
signInText?: string;
|
|
6
|
+
/** Text when user is authenticated (default: "Sign out") */
|
|
7
|
+
signOutText?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Button that initiates MSAL redirect login or logout.
|
|
11
|
+
* Renders "Sign in" when unauthenticated, "Sign out" when authenticated.
|
|
12
|
+
* Disabled during MSAL interaction in progress.
|
|
13
|
+
*/
|
|
14
|
+
export declare function LoginButton({ className, signInText, signOutText, }: LoginButtonProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=LoginButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginButton.d.ts","sourceRoot":"","sources":["../../src/components/LoginButton.tsx"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACxB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,UAAsB,EACtB,WAAwB,GACzB,EAAE,gBAAgB,+BAelB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth } from "../hooks/useAuth";
|
|
3
|
+
import { InteractionStatus } from "@azure/msal-browser";
|
|
4
|
+
/**
|
|
5
|
+
* Button that initiates MSAL redirect login or logout.
|
|
6
|
+
* Renders "Sign in" when unauthenticated, "Sign out" when authenticated.
|
|
7
|
+
* Disabled during MSAL interaction in progress.
|
|
8
|
+
*/
|
|
9
|
+
export function LoginButton({ className, signInText = "Sign in", signOutText = "Sign out", }) {
|
|
10
|
+
const { login, logout, isAuthenticated, inProgress } = useAuth();
|
|
11
|
+
const isLoading = inProgress !== InteractionStatus.None;
|
|
12
|
+
return (_jsx("button", { type: "button", className: className, onClick: isAuthenticated ? logout : login, disabled: isLoading, "aria-busy": isLoading, children: isLoading ? "..." : isAuthenticated ? signOutText : signInText }));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=LoginButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoginButton.js","sourceRoot":"","sources":["../../src/components/LoginButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,SAAS,EACT,UAAU,GAAG,SAAS,EACtB,WAAW,GAAG,UAAU,GACP;IACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IACjE,MAAM,SAAS,GAAG,UAAU,KAAK,iBAAiB,CAAC,IAAI,CAAC;IAExD,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EACzC,QAAQ,EAAE,SAAS,eACR,SAAS,YAEnB,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,GACxD,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface ProtectedContentProps {
|
|
3
|
+
/** Content to show when authenticated */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Content to show when NOT authenticated.
|
|
7
|
+
* Defaults to a "Sign in to access this content" message with a login button.
|
|
8
|
+
*/
|
|
9
|
+
fallback?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Content to show while MSAL is initializing (redirect returning, etc.)
|
|
12
|
+
* Defaults to null (nothing shown while loading)
|
|
13
|
+
*/
|
|
14
|
+
loadingFallback?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Gate component for client-side auth protection.
|
|
18
|
+
*
|
|
19
|
+
* Shows children only when the user is authenticated.
|
|
20
|
+
* When unauthenticated, shows the fallback (default: a login prompt).
|
|
21
|
+
* When MSAL is in progress (e.g., redirect returning), shows loadingFallback.
|
|
22
|
+
*
|
|
23
|
+
* Works on SWA Free tier — protection is at the data layer (Graph API requires a token).
|
|
24
|
+
* The page HTML is served to everyone; only authenticated users see the actual content.
|
|
25
|
+
*
|
|
26
|
+
* Must be rendered inside an AuthProvider (MsalProvider) tree.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ProtectedContent({ children, fallback, loadingFallback, }: ProtectedContentProps): import("react").JSX.Element;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=ProtectedContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtectedContent.d.ts","sourceRoot":"","sources":["../../src/components/ProtectedContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,UAAU,qBAAqB;IAC7B,yCAAyC;IACzC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,eAAsB,GACvB,EAAE,qBAAqB,+BAgBvB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AuthenticatedTemplate, UnauthenticatedTemplate, } from "@azure/msal-react";
|
|
3
|
+
import { useMsal } from "@azure/msal-react";
|
|
4
|
+
import { InteractionStatus } from "@azure/msal-browser";
|
|
5
|
+
/**
|
|
6
|
+
* Gate component for client-side auth protection.
|
|
7
|
+
*
|
|
8
|
+
* Shows children only when the user is authenticated.
|
|
9
|
+
* When unauthenticated, shows the fallback (default: a login prompt).
|
|
10
|
+
* When MSAL is in progress (e.g., redirect returning), shows loadingFallback.
|
|
11
|
+
*
|
|
12
|
+
* Works on SWA Free tier — protection is at the data layer (Graph API requires a token).
|
|
13
|
+
* The page HTML is served to everyone; only authenticated users see the actual content.
|
|
14
|
+
*
|
|
15
|
+
* Must be rendered inside an AuthProvider (MsalProvider) tree.
|
|
16
|
+
*/
|
|
17
|
+
export function ProtectedContent({ children, fallback, loadingFallback = null, }) {
|
|
18
|
+
const { inProgress } = useMsal();
|
|
19
|
+
// Show loading state while MSAL is handling a redirect or startup
|
|
20
|
+
if (inProgress !== InteractionStatus.None) {
|
|
21
|
+
return _jsx(_Fragment, { children: loadingFallback });
|
|
22
|
+
}
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(AuthenticatedTemplate, { children: children }), _jsx(UnauthenticatedTemplate, { children: fallback ?? _jsx(DefaultLoginFallback, {}) })] }));
|
|
24
|
+
}
|
|
25
|
+
function DefaultLoginFallback() {
|
|
26
|
+
const { instance } = useMsal();
|
|
27
|
+
const handleLogin = () => {
|
|
28
|
+
instance.loginRedirect({ scopes: ["openid", "profile", "User.Read"] });
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs("div", { style: {
|
|
31
|
+
padding: "1.5rem",
|
|
32
|
+
textAlign: "center",
|
|
33
|
+
border: "1px solid var(--ew-border, #e5e7eb)",
|
|
34
|
+
borderRadius: "0.5rem",
|
|
35
|
+
}, children: [_jsx("p", { style: { marginBottom: "1rem", color: "var(--ew-text, #374151)" }, children: "Sign in to access this content." }), _jsx("button", { type: "button", onClick: handleLogin, style: {
|
|
36
|
+
padding: "0.5rem 1.25rem",
|
|
37
|
+
backgroundColor: "var(--ew-primary, #6366f1)",
|
|
38
|
+
color: "#fff",
|
|
39
|
+
border: "none",
|
|
40
|
+
borderRadius: "0.375rem",
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
fontWeight: 500,
|
|
43
|
+
}, children: "Sign in" })] }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ProtectedContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtectedContent.js","sourceRoot":"","sources":["../../src/components/ProtectedContent.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAiBxD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,eAAe,GAAG,IAAI,GACA;IACtB,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IAEjC,kEAAkE;IAClE,IAAI,UAAU,KAAK,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAC1C,OAAO,4BAAG,eAAe,GAAI,CAAC;IAChC,CAAC;IAED,OAAO,CACL,8BACE,KAAC,qBAAqB,cAAE,QAAQ,GAAyB,EACzD,KAAC,uBAAuB,cACrB,QAAQ,IAAI,KAAC,oBAAoB,KAAG,GACb,IACzB,CACJ,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB;IAC3B,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC;IAE/B,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC,CAAC;IAEF,OAAO,CACL,eACE,KAAK,EAAE;YACL,OAAO,EAAE,QAAQ;YACjB,SAAS,EAAE,QAAQ;YACnB,MAAM,EAAE,qCAAqC;YAC7C,YAAY,EAAE,QAAQ;SACvB,aAED,YAAG,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,gDAEhE,EACJ,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE;oBACL,OAAO,EAAE,gBAAgB;oBACzB,eAAe,EAAE,4BAA4B;oBAC7C,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,MAAM;oBACd,YAAY,EAAE,UAAU;oBACxB,MAAM,EAAE,SAAS;oBACjB,UAAU,EAAE,GAAG;iBAChB,wBAGM,IACL,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface SharePointFileListProps {
|
|
2
|
+
siteId: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function SharePointFileList({ siteId, path, className }: SharePointFileListProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=SharePointFileList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointFileList.d.ts","sourceRoot":"","sources":["../../src/components/SharePointFileList.tsx"],"names":[],"mappings":"AAOA,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAoDtF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useSharePointFiles } from "../hooks/useSharePointFiles";
|
|
4
|
+
function formatSize(b) {
|
|
5
|
+
if (b === undefined)
|
|
6
|
+
return "—";
|
|
7
|
+
if (b < 1024)
|
|
8
|
+
return `${b} B`;
|
|
9
|
+
if (b < 1048576)
|
|
10
|
+
return `${(b / 1024).toFixed(1)} KB`;
|
|
11
|
+
return `${(b / 1048576).toFixed(1)} MB`;
|
|
12
|
+
}
|
|
13
|
+
function formatDate(iso) {
|
|
14
|
+
return iso ? new Date(iso).toLocaleDateString() : "—";
|
|
15
|
+
}
|
|
16
|
+
export function SharePointFileList({ siteId, path, className }) {
|
|
17
|
+
const { files, loading, error, refetch } = useSharePointFiles(siteId, path);
|
|
18
|
+
const [sortKey, setSortKey] = useState("name");
|
|
19
|
+
const [sortDir, setSortDir] = useState("asc");
|
|
20
|
+
const handleSort = (key) => {
|
|
21
|
+
if (key === sortKey)
|
|
22
|
+
setSortDir((d) => (d === "asc" ? "desc" : "asc"));
|
|
23
|
+
else {
|
|
24
|
+
setSortKey(key);
|
|
25
|
+
setSortDir("asc");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const sorted = [...files].sort((a, b) => {
|
|
29
|
+
let cmp = 0;
|
|
30
|
+
if (sortKey === "name")
|
|
31
|
+
cmp = a.name.localeCompare(b.name);
|
|
32
|
+
else if (sortKey === "size")
|
|
33
|
+
cmp = (a.size ?? 0) - (b.size ?? 0);
|
|
34
|
+
else
|
|
35
|
+
cmp = new Date(a.lastModifiedDateTime ?? 0).getTime() - new Date(b.lastModifiedDateTime ?? 0).getTime();
|
|
36
|
+
return sortDir === "asc" ? cmp : -cmp;
|
|
37
|
+
});
|
|
38
|
+
if (loading)
|
|
39
|
+
return _jsx("p", { style: { color: "var(--ew-text, #374151)" }, children: "Loading files\u2026" });
|
|
40
|
+
if (error)
|
|
41
|
+
return _jsxs("div", { children: [_jsxs("p", { style: { color: "#ef4444" }, children: ["Error: ", error.message] }), _jsx("button", { type: "button", onClick: refetch, children: "Retry" })] });
|
|
42
|
+
if (files.length === 0)
|
|
43
|
+
return _jsx("p", { children: "No files found." });
|
|
44
|
+
const thStyle = { padding: "0.75rem", textAlign: "left", cursor: "pointer", borderBottom: "2px solid var(--ew-border, #e5e7eb)", color: "var(--ew-text, #374151)", fontWeight: 600 };
|
|
45
|
+
return (_jsx("div", { className: className, style: { overflowX: "auto" }, children: _jsxs("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: "0.875rem" }, children: [_jsx("thead", { children: _jsxs("tr", { children: [["name", "modified", "size"].map((k) => (_jsxs("th", { onClick: () => handleSort(k), style: thStyle, children: [k.charAt(0).toUpperCase() + k.slice(1), " ", sortKey === k ? (sortDir === "asc" ? "↑" : "↓") : ""] }, k))), _jsx("th", { style: { ...thStyle, cursor: "default" }, children: "Download" })] }) }), _jsx("tbody", { children: sorted.map((file) => (_jsxs("tr", { style: { borderBottom: "1px solid var(--ew-border, #e5e7eb)" }, children: [_jsx("td", { style: { padding: "0.625rem 0.75rem" }, children: file.name }), _jsx("td", { style: { padding: "0.625rem 0.75rem" }, children: formatDate(file.lastModifiedDateTime) }), _jsx("td", { style: { padding: "0.625rem 0.75rem" }, children: formatSize(file.size) }), _jsx("td", { style: { padding: "0.625rem 0.75rem" }, children: file["@microsoft.graph.downloadUrl"]
|
|
46
|
+
? _jsx("a", { href: file["@microsoft.graph.downloadUrl"], download: file.name, style: { color: "var(--ew-primary, #6366f1)" }, children: "Download" })
|
|
47
|
+
: "—" })] }, file.id))) })] }) }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=SharePointFileList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointFileList.js","sourceRoot":"","sources":["../../src/components/SharePointFileList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAYjE,SAAS,UAAU,CAAC,CAAU;IAC5B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAChC,IAAI,CAAC,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAC9B,IAAI,CAAC,GAAG,OAAO;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IACtD,OAAO,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1C,CAAC;AAED,SAAS,UAAU,CAAC,GAAY;IAC9B,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAA2B;IACrF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5E,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,MAAM,CAAC,CAAC;IACxD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEvD,MAAM,UAAU,GAAG,CAAC,GAAY,EAAE,EAAE;QAClC,IAAI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,IAAI,CAAC,IAAI,GAAM,EAC5D,aAAI,KAAK,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,YAAG,UAAU,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAM,EACxF,aAAI,KAAK,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,YAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAM,EACxE,aAAI,KAAK,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,YACvC,IAAI,CAAC,8BAA8B,CAAC;oCACnC,CAAC,CAAC,YAAG,IAAI,EAAE,IAAI,CAAC,8BAA8B,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,4BAA4B,EAAE,yBAAc;oCAClI,CAAC,CAAC,GAAG,GACJ,KARE,IAAI,CAAC,EAAE,CASX,CACN,CAAC,GACI,IACF,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface SharePointGalleryProps {
|
|
2
|
+
siteId: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
columns?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function SharePointGallery({ siteId, path, columns, className }: SharePointGalleryProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=SharePointGallery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointGallery.d.ts","sourceRoot":"","sources":["../../src/components/SharePointGallery.tsx"],"names":[],"mappings":"AAGA,UAAU,sBAAsB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAW,EAAE,SAAS,EAAE,EAAE,sBAAsB,+BAkDjG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useSharePointFiles } from "../hooks/useSharePointFiles";
|
|
4
|
+
export function SharePointGallery({ siteId, path, columns = 3, className }) {
|
|
5
|
+
const { files, loading, error, refetch } = useSharePointFiles(siteId, path);
|
|
6
|
+
const [lightboxUrl, setLightboxUrl] = useState(null);
|
|
7
|
+
const images = files.filter((f) => f.file?.mimeType?.startsWith("image/") || /\.(jpg|jpeg|png|gif|webp|svg)$/i.test(f.name));
|
|
8
|
+
if (loading) {
|
|
9
|
+
return (_jsx("div", { className: className, style: { display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap: "0.75rem" }, "aria-label": "Loading gallery", children: Array.from({ length: columns * 2 }).map((_, i) => (_jsx("div", { style: { aspectRatio: "1", backgroundColor: "var(--ew-surface, #f9fafb)", borderRadius: "0.5rem" } }, i))) }));
|
|
10
|
+
}
|
|
11
|
+
if (error) {
|
|
12
|
+
return (_jsxs("div", { className: className, style: { color: "#ef4444", padding: "1rem" }, children: [_jsxs("p", { children: ["Failed to load gallery: ", error.message] }), _jsx("button", { type: "button", onClick: refetch, children: "Retry" })] }));
|
|
13
|
+
}
|
|
14
|
+
if (images.length === 0) {
|
|
15
|
+
return _jsx("div", { className: className, style: { color: "var(--ew-text, #374151)", padding: "1rem", textAlign: "center" }, children: "No images found." });
|
|
16
|
+
}
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: className, style: { display: "grid", gridTemplateColumns: `repeat(${columns}, 1fr)`, gap: "0.75rem" }, role: "list", "aria-label": "SharePoint image gallery", children: images.map((img) => {
|
|
18
|
+
const url = img["@microsoft.graph.downloadUrl"] ?? img.webUrl ?? "";
|
|
19
|
+
return (_jsx("button", { type: "button", role: "listitem", onClick: () => setLightboxUrl(url), style: { aspectRatio: "1", overflow: "hidden", borderRadius: "0.5rem", border: "none", padding: 0, cursor: "pointer", background: "var(--ew-surface, #f9fafb)" }, title: img.name, children: _jsx("img", { src: url, alt: img.name, loading: "lazy", style: { width: "100%", height: "100%", objectFit: "cover" } }) }, img.id));
|
|
20
|
+
}) }), lightboxUrl && (_jsx("div", { role: "dialog", "aria-label": "Image lightbox", onClick: () => setLightboxUrl(null), style: { position: "fixed", inset: 0, backgroundColor: "rgba(0,0,0,0.85)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 9999, cursor: "zoom-out" }, children: _jsx("img", { src: lightboxUrl, alt: "Full size", style: { maxWidth: "90vw", maxHeight: "90vh", objectFit: "contain", borderRadius: "0.5rem" }, onClick: (e) => e.stopPropagation() }) }))] }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=SharePointGallery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointGallery.js","sourceRoot":"","sources":["../../src/components/SharePointGallery.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AASjE,MAAM,UAAU,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,EAAE,SAAS,EAA0B;IAChG,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC5E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CACzB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI,iCAAiC,CAAC,IAAI,CAAC,CAAC,CAAC,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AS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,GAAI,GACxK,CACP,IACA,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface SharePointListViewProps {
|
|
2
|
+
siteId: string;
|
|
3
|
+
listId: string;
|
|
4
|
+
columns?: string[];
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function SharePointListView({ siteId, listId, columns, className }: SharePointListViewProps): import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=SharePointListView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointListView.d.ts","sourceRoot":"","sources":["../../src/components/SharePointListView.tsx"],"names":[],"mappings":"AAEA,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAmCjG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useSharePointList } from "../hooks/useSharePointList";
|
|
3
|
+
export function SharePointListView({ siteId, listId, columns, className }) {
|
|
4
|
+
const { items, loading, error, refetch } = useSharePointList(siteId, listId);
|
|
5
|
+
if (loading)
|
|
6
|
+
return _jsx("p", { style: { color: "var(--ew-text, #374151)" }, children: "Loading list\u2026" });
|
|
7
|
+
if (error)
|
|
8
|
+
return _jsxs("div", { children: [_jsxs("p", { style: { color: "#ef4444" }, children: ["Error: ", error.message] }), _jsx("button", { type: "button", onClick: refetch, children: "Retry" })] });
|
|
9
|
+
if (items.length === 0)
|
|
10
|
+
return _jsx("p", { children: "No items found." });
|
|
11
|
+
const cols = columns?.length
|
|
12
|
+
? columns
|
|
13
|
+
: Object.keys(items[0]?.fields ?? {}).filter((k) => !k.startsWith("_") && k !== "id" && k !== "@odata.etag").slice(0, 8);
|
|
14
|
+
const cellStyle = { padding: "0.625rem 0.75rem", color: "var(--ew-text, #374151)", maxWidth: "20rem", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" };
|
|
15
|
+
return (_jsx("div", { className: className, style: { overflowX: "auto" }, children: _jsxs("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: "0.875rem" }, children: [_jsx("thead", { children: _jsx("tr", { children: cols.map((col) => (_jsx("th", { style: { padding: "0.75rem", textAlign: "left", borderBottom: "2px solid var(--ew-border, #e5e7eb)", color: "var(--ew-text, #374151)", fontWeight: 600 }, children: col }, col))) }) }), _jsx("tbody", { children: items.map((item) => (_jsx("tr", { style: { borderBottom: "1px solid var(--ew-border, #e5e7eb)" }, children: cols.map((col) => (_jsx("td", { style: cellStyle, children: String(item.fields?.[col] ?? "—") }, col))) }, item.id))) })] }) }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SharePointListView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SharePointListView.js","sourceRoot":"","sources":["../../src/components/SharePointListView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,MAAM,UAAU,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAA2B;IAChG,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7E,IAAI,OAAO;QAAE,OAAO,YAAG,KAAK,EAAE,EAAE,KAAK,EAAE,yBAA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AE,UAAU,EAAE,GAAG,EAAE,YAAG,GAAG,IAAnK,GAAG,CAAsK,CACnL,CAAC,GACC,GACC,EACR,0BACG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,aAAkB,KAAK,EAAE,EAAE,YAAY,EAAE,qCAAqC,EAAE,YAC7E,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,aAAc,KAAK,EAAE,SAAS,YAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAzD,GAAG,CAA4D,CACzE,CAAC,IAHK,IAAI,CAAC,EAAE,CAIX,CACN,CAAC,GACI,IACF,GACJ,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface UserAvatarProps {
|
|
2
|
+
/** Avatar circle size in pixels (default: 32) */
|
|
3
|
+
size?: number;
|
|
4
|
+
/** Optional CSS class(es) */
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Displays user initials in a circle when authenticated.
|
|
9
|
+
* Renders nothing when unauthenticated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function UserAvatar({ size, className }: UserAvatarProps): import("react").JSX.Element | null;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=UserAvatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserAvatar.d.ts","sourceRoot":"","sources":["../../src/components/UserAvatar.tsx"],"names":[],"mappings":"AAEA,UAAU,eAAe;IACvB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,IAAS,EAAE,SAAS,EAAE,EAAE,eAAe,sCAoCnE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useAuth } from "../hooks/useAuth";
|
|
3
|
+
/**
|
|
4
|
+
* Displays user initials in a circle when authenticated.
|
|
5
|
+
* Renders nothing when unauthenticated.
|
|
6
|
+
*/
|
|
7
|
+
export function UserAvatar({ size = 32, className }) {
|
|
8
|
+
const { user, isAuthenticated } = useAuth();
|
|
9
|
+
if (!isAuthenticated || !user?.name) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
// Extract initials: first char of first + last word
|
|
13
|
+
const words = user.name.trim().split(/\s+/);
|
|
14
|
+
const initials = words.length >= 2
|
|
15
|
+
? `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase()
|
|
16
|
+
: words[0].slice(0, 2).toUpperCase();
|
|
17
|
+
return (_jsx("span", { className: className, title: user.name, "aria-label": `${user.name} (signed in)`, style: {
|
|
18
|
+
display: "inline-flex",
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
justifyContent: "center",
|
|
21
|
+
width: size,
|
|
22
|
+
height: size,
|
|
23
|
+
borderRadius: "50%",
|
|
24
|
+
backgroundColor: "var(--ew-primary, #6366f1)",
|
|
25
|
+
color: "#fff",
|
|
26
|
+
fontSize: Math.round(size * 0.4),
|
|
27
|
+
fontWeight: 600,
|
|
28
|
+
userSelect: "none",
|
|
29
|
+
}, children: initials }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=UserAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserAvatar.js","sourceRoot":"","sources":["../../src/components/UserAvatar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAS3C;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAmB;IAClE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAE5C,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oDAAoD;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,QAAQ,GACZ,KAAK,CAAC,MAAM,IAAI,CAAC;QACf,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE;QAC7D,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAEzC,OAAO,CACL,eACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,IAAI,gBACJ,GAAG,IAAI,CAAC,IAAI,cAAc,EACtC,KAAK,EAAE;YACL,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;YACZ,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,4BAA4B;YAC7C,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;YAChC,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,MAAM;SACnB,YAEA,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-instance authentication configuration.
|
|
3
|
+
* Provided by the consuming site (e.g., from siteConfig.auth).
|
|
4
|
+
* The @easy-web/auth package NEVER reads siteConfig directly.
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthConfig {
|
|
7
|
+
/** Entra app registration client ID for this site instance */
|
|
8
|
+
clientId: string;
|
|
9
|
+
/** IT-CI tenant ID */
|
|
10
|
+
tenantId: string;
|
|
11
|
+
/** Redirect URI after login. Defaults to window.location.origin at runtime. */
|
|
12
|
+
redirectUri?: string;
|
|
13
|
+
/** Override default scopes for token acquisition. */
|
|
14
|
+
scopes?: string[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
2
|
+
import { type IPublicClientApplication, type AccountInfo } from "@azure/msal-browser";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Microsoft Graph client authenticated via MSAL.
|
|
5
|
+
* Uses AuthCodeMSALBrowserAuthenticationProvider — the official MSAL+Graph bridge.
|
|
6
|
+
* Only call this from within a React component inside AuthProvider.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGraphClient(msalInstance: IPublicClientApplication, account: AccountInfo, scopes?: string[]): Client;
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/graph/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,OAAO,EAAmB,KAAK,wBAAwB,EAAgC,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGrI;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,wBAAwB,EACtC,OAAO,EAAE,WAAW,EACpB,MAAM,GAAE,MAAM,EAAwB,GACrC,MAAM,CAWR"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
2
|
+
import { AuthCodeMSALBrowserAuthenticationProvider } from "@microsoft/microsoft-graph-client/authProviders/authCodeMsalBrowser";
|
|
3
|
+
import { InteractionType } from "@azure/msal-browser";
|
|
4
|
+
import { DEFAULT_SCOPES } from "../scopes";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Microsoft Graph client authenticated via MSAL.
|
|
7
|
+
* Uses AuthCodeMSALBrowserAuthenticationProvider — the official MSAL+Graph bridge.
|
|
8
|
+
* Only call this from within a React component inside AuthProvider.
|
|
9
|
+
*/
|
|
10
|
+
export function createGraphClient(msalInstance, account, scopes = [...DEFAULT_SCOPES]) {
|
|
11
|
+
const authProvider = new AuthCodeMSALBrowserAuthenticationProvider(msalInstance, {
|
|
12
|
+
account,
|
|
13
|
+
scopes,
|
|
14
|
+
interactionType: InteractionType.Redirect,
|
|
15
|
+
});
|
|
16
|
+
return Client.initWithMiddleware({ authProvider });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/graph/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,yCAAyC,EAAE,MAAM,qEAAqE,CAAC;AAChI,OAAO,EAAE,eAAe,EAAiF,MAAM,qBAAqB,CAAC;AACrI,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,YAAsC,EACtC,OAAoB,EACpB,SAAmB,CAAC,GAAG,cAAc,CAAC;IAEtC,MAAM,YAAY,GAAG,IAAI,yCAAyC,CAChE,YAAuC,EACvC;QACE,OAAO;QACP,MAAM;QACN,eAAe,EAAE,eAAe,CAAC,QAAQ;KAC1C,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,kBAAkB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Client } from "@microsoft/microsoft-graph-client";
|
|
2
|
+
/** A SharePoint site resource */
|
|
3
|
+
export interface SpSite {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
webUrl: string;
|
|
8
|
+
}
|
|
9
|
+
/** A SharePoint list item with dynamically typed fields */
|
|
10
|
+
export interface SpListItem {
|
|
11
|
+
id: string;
|
|
12
|
+
fields: Record<string, unknown>;
|
|
13
|
+
lastModifiedDateTime?: string;
|
|
14
|
+
createdDateTime?: string;
|
|
15
|
+
}
|
|
16
|
+
/** A Drive item (file or folder) */
|
|
17
|
+
export interface SpDriveItem {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
size?: number;
|
|
21
|
+
lastModifiedDateTime?: string;
|
|
22
|
+
file?: {
|
|
23
|
+
mimeType: string;
|
|
24
|
+
};
|
|
25
|
+
folder?: {
|
|
26
|
+
childCount: number;
|
|
27
|
+
};
|
|
28
|
+
"@microsoft.graph.downloadUrl"?: string;
|
|
29
|
+
webUrl?: string;
|
|
30
|
+
}
|
|
31
|
+
/** A thumbnail set */
|
|
32
|
+
export interface SpThumbnail {
|
|
33
|
+
id: string;
|
|
34
|
+
small?: {
|
|
35
|
+
url: string;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
medium?: {
|
|
40
|
+
url: string;
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
44
|
+
large?: {
|
|
45
|
+
url: string;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function getSite(client: Client, hostname: string, sitePath: string): Promise<SpSite>;
|
|
51
|
+
export declare function getListItems(client: Client, siteId: string, listId: string): Promise<SpListItem[]>;
|
|
52
|
+
export declare function getDocumentLibraryFiles(client: Client, siteId: string, driveId?: string, path?: string): Promise<SpDriveItem[]>;
|
|
53
|
+
export declare function getFileContent(client: Client, siteId: string, itemId: string): Promise<Blob>;
|
|
54
|
+
export declare function getImageThumbnails(client: Client, siteId: string, itemId: string): Promise<SpThumbnail[]>;
|
|
55
|
+
//# sourceMappingURL=sharepoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharepoint.d.ts","sourceRoot":"","sources":["../../src/graph/sharepoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEhE,iCAAiC;AACjC,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,oCAAoC;AACpC,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,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O,CAAC,IAAI,CAAC,CAIf;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,EAAE,CAAC,CAKxB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export async function getSite(client, hostname, sitePath) {
|
|
2
|
+
return client.api(`/sites/${hostname}:${sitePath}`).get();
|
|
3
|
+
}
|
|
4
|
+
export async function getListItems(client, siteId, listId) {
|
|
5
|
+
const response = await client
|
|
6
|
+
.api(`/sites/${siteId}/lists/${listId}/items`)
|
|
7
|
+
.expand("fields")
|
|
8
|
+
.get();
|
|
9
|
+
return response.value ?? [];
|
|
10
|
+
}
|
|
11
|
+
export async function getDocumentLibraryFiles(client, siteId, driveId, path) {
|
|
12
|
+
let apiPath;
|
|
13
|
+
if (driveId && path) {
|
|
14
|
+
apiPath = `/sites/${siteId}/drives/${driveId}/root:${path}:/children`;
|
|
15
|
+
}
|
|
16
|
+
else if (driveId) {
|
|
17
|
+
apiPath = `/sites/${siteId}/drives/${driveId}/root/children`;
|
|
18
|
+
}
|
|
19
|
+
else if (path) {
|
|
20
|
+
apiPath = `/sites/${siteId}/drive/root:${path}:/children`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
apiPath = `/sites/${siteId}/drive/root/children`;
|
|
24
|
+
}
|
|
25
|
+
const response = await client.api(apiPath).get();
|
|
26
|
+
return response.value ?? [];
|
|
27
|
+
}
|
|
28
|
+
export async function getFileContent(client, siteId, itemId) {
|
|
29
|
+
return client
|
|
30
|
+
.api(`/sites/${siteId}/drive/items/${itemId}/content`)
|
|
31
|
+
.getStream();
|
|
32
|
+
}
|
|
33
|
+
export async function getImageThumbnails(client, siteId, itemId) {
|
|
34
|
+
const response = await client
|
|
35
|
+
.api(`/sites/${siteId}/drive/items/${itemId}/thumbnails`)
|
|
36
|
+
.get();
|
|
37
|
+
return response.value ?? [];
|
|
38
|
+
}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AAI,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAc,EACd,MAAc,EACd,MAAc;IAEd,OAAO,MAAM;SACV,GAAG,CAAC,UAAU,MAAM,gBAAgB,MAAM,UAAU,CAAC;SACrD,SAAS,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc,EACd,MAAc,EACd,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,MAAM;SAC1B,GAAG,CAAC,UAAU,MAAM,gBAAgB,MAAM,aAAa,CAAC;SACxD,GAAG,EAAE,CAAC;IACT,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InteractionStatus } from "@azure/msal-browser";
|
|
2
|
+
export interface AuthUser {
|
|
3
|
+
name: string | null;
|
|
4
|
+
email: string | null;
|
|
5
|
+
id: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface UseAuthReturn {
|
|
8
|
+
/** Initiate redirect-based login */
|
|
9
|
+
login: () => Promise<void>;
|
|
10
|
+
/** Initiate redirect-based logout */
|
|
11
|
+
logout: () => Promise<void>;
|
|
12
|
+
/** True when user has an active session */
|
|
13
|
+
isAuthenticated: boolean;
|
|
14
|
+
/** Current user info (null when unauthenticated) */
|
|
15
|
+
user: AuthUser | null;
|
|
16
|
+
/** MSAL interaction in-progress status — gate token calls on InteractionStatus.None */
|
|
17
|
+
inProgress: InteractionStatus;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Primary hook for authentication state and actions.
|
|
21
|
+
* Must be used inside an AuthProvider (MsalProvider) tree.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useAuth(): UseAuthReturn;
|
|
24
|
+
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,qCAAqC;IACrC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,2CAA2C;IAC3C,eAAe,EAAE,OAAO,CAAC;IACzB,oDAAoD;IACpD,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,uFAAuF;IACvF,UAAU,EAAE,iBAAiB,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,OAAO,IAAI,aAAa,CAwBvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useMsal, useIsAuthenticated, useAccount, } from "@azure/msal-react";
|
|
3
|
+
import { LOGIN_SCOPES } from "../scopes";
|
|
4
|
+
/**
|
|
5
|
+
* Primary hook for authentication state and actions.
|
|
6
|
+
* Must be used inside an AuthProvider (MsalProvider) tree.
|
|
7
|
+
*/
|
|
8
|
+
export function useAuth() {
|
|
9
|
+
const { instance, accounts, inProgress } = useMsal();
|
|
10
|
+
const isAuthenticated = useIsAuthenticated();
|
|
11
|
+
const account = useAccount(accounts[0] ?? {});
|
|
12
|
+
const login = useCallback(async () => {
|
|
13
|
+
await instance.loginRedirect({ scopes: [...LOGIN_SCOPES] });
|
|
14
|
+
}, [instance]);
|
|
15
|
+
const logout = useCallback(async () => {
|
|
16
|
+
await instance.logoutRedirect({
|
|
17
|
+
account: instance.getActiveAccount() ?? accounts[0],
|
|
18
|
+
});
|
|
19
|
+
}, [instance, accounts]);
|
|
20
|
+
const user = account
|
|
21
|
+
? {
|
|
22
|
+
name: account.name ?? null,
|
|
23
|
+
email: account.username ?? null,
|
|
24
|
+
id: account.localAccountId ?? null,
|
|
25
|
+
}
|
|
26
|
+
: null;
|
|
27
|
+
return { login, logout, isAuthenticated, user, inProgress };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAqBzC;;;GAGG;AACH,MAAM,UAAU,OAAO;IACrB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IACrD,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACnC,MAAM,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACpC,MAAM,QAAQ,CAAC,cAAc,CAAC;YAC5B,OAAO,EAAE,QAAQ,CAAC,gBAAgB,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC;SACpD,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEzB,MAAM,IAAI,GAAoB,OAAO;QACnC,CAAC,CAAC;YACE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,KAAK,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI;YAC/B,EAAE,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;SACnC;QACH,CAAC,CAAC,IAAI,CAAC;IAET,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Client } from "@microsoft/microsoft-graph-client";
|
|
2
|
+
export interface UseGraphClientReturn {
|
|
3
|
+
client: Client | null;
|
|
4
|
+
isReady: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function useGraphClient(): UseGraphClientReturn;
|
|
8
|
+
//# sourceMappingURL=useGraphClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraphClient.d.ts","sourceRoot":"","sources":["../../src/hooks/useGraphClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,cAAc,IAAI,oBAAoB,CAkBrD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useMsal, useAccount } from "@azure/msal-react";
|
|
3
|
+
import { InteractionStatus } from "@azure/msal-browser";
|
|
4
|
+
import { createGraphClient } from "../graph/client";
|
|
5
|
+
export function useGraphClient() {
|
|
6
|
+
const { instance, accounts, inProgress } = useMsal();
|
|
7
|
+
const account = useAccount(accounts[0] ?? {});
|
|
8
|
+
const client = useMemo(() => {
|
|
9
|
+
if (!account || inProgress !== InteractionStatus.None) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return createGraphClient(instance, account);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}, [instance, account, inProgress]);
|
|
19
|
+
const isReady = client !== null;
|
|
20
|
+
return { client, isReady, error: null };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useGraphClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraphClient.js","sourceRoot":"","sources":["../../src/hooks/useGraphClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AASpD,MAAM,UAAU,cAAc;IAC5B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;IACrD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAE9C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI,CAAC,OAAO,IAAI,UAAU,KAAK,iBAAiB,CAAC,IAAI,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC;YACH,OAAO,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IAEpC,MAAM,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;IAEhC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SpDriveItem } from "../graph/sharepoint";
|
|
2
|
+
export interface UseSharePointFilesReturn {
|
|
3
|
+
files: SpDriveItem[];
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
refetch: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSharePointFiles(siteId: string, path?: string): UseSharePointFilesReturn;
|
|
9
|
+
//# sourceMappingURL=useSharePointFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharePointFiles.d.ts","sourceRoot":"","sources":["../../src/hooks/useSharePointFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEhF,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,GACZ,wBAAwB,CAwB1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { useGraphClient } from "./useGraphClient";
|
|
3
|
+
import { getDocumentLibraryFiles } from "../graph/sharepoint";
|
|
4
|
+
export function useSharePointFiles(siteId, path) {
|
|
5
|
+
const { client, isReady } = useGraphClient();
|
|
6
|
+
const [files, setFiles] = useState([]);
|
|
7
|
+
const [loading, setLoading] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const [refetchTrigger, setRefetchTrigger] = useState(0);
|
|
10
|
+
const refetch = useCallback(() => setRefetchTrigger((n) => n + 1), []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!client || !isReady || !siteId)
|
|
13
|
+
return;
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
getDocumentLibraryFiles(client, siteId, undefined, path)
|
|
18
|
+
.then((data) => { if (!cancelled)
|
|
19
|
+
setFiles(data); })
|
|
20
|
+
.catch((err) => {
|
|
21
|
+
if (!cancelled)
|
|
22
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
23
|
+
})
|
|
24
|
+
.finally(() => { if (!cancelled)
|
|
25
|
+
setLoading(false); });
|
|
26
|
+
return () => { cancelled = true; };
|
|
27
|
+
}, [client, isReady, siteId, path, refetchTrigger]);
|
|
28
|
+
return { files, loading, error, refetch };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=useSharePointFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharePointFiles.js","sourceRoot":"","sources":["../../src/hooks/useSharePointFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAoB,MAAM,qBAAqB,CAAC;AAShF,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,IAAa;IAEb,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,EAAE,CAAC,CAAC;IACtD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IA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,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type SpListItem } from "../graph/sharepoint";
|
|
2
|
+
export interface UseSharePointListReturn {
|
|
3
|
+
items: SpListItem[];
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
refetch: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function useSharePointList(siteId: string, listId: string): UseSharePointListReturn;
|
|
9
|
+
//# sourceMappingURL=useSharePointList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharePointList.d.ts","sourceRoot":"","sources":["../../src/hooks/useSharePointList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEpE,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,uBAAuB,CAwBzB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { useGraphClient } from "./useGraphClient";
|
|
3
|
+
import { getListItems } from "../graph/sharepoint";
|
|
4
|
+
export function useSharePointList(siteId, listId) {
|
|
5
|
+
const { client, isReady } = useGraphClient();
|
|
6
|
+
const [items, setItems] = useState([]);
|
|
7
|
+
const [loading, setLoading] = useState(false);
|
|
8
|
+
const [error, setError] = useState(null);
|
|
9
|
+
const [refetchTrigger, setRefetchTrigger] = useState(0);
|
|
10
|
+
const refetch = useCallback(() => setRefetchTrigger((n) => n + 1), []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!client || !isReady || !siteId || !listId)
|
|
13
|
+
return;
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
setError(null);
|
|
17
|
+
getListItems(client, siteId, listId)
|
|
18
|
+
.then((data) => { if (!cancelled)
|
|
19
|
+
setItems(data); })
|
|
20
|
+
.catch((err) => {
|
|
21
|
+
if (!cancelled)
|
|
22
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
23
|
+
})
|
|
24
|
+
.finally(() => { if (!cancelled)
|
|
25
|
+
setLoading(false); });
|
|
26
|
+
return () => { cancelled = true; };
|
|
27
|
+
}, [client, isReady, siteId, listId, refetchTrigger]);
|
|
28
|
+
return { items, loading, error, refetch };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=useSharePointList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharePointList.js","sourceRoot":"","sources":["../../src/hooks/useSharePointList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAmB,MAAM,qBAAqB,CAAC;AASpE,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,MAAc;IAEd,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEvE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;YAAE,OAAO;QACtD,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;aACjC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;aACnD,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;YACtB,IAAI,CAAC,SAAS;gBAAE,QAAQ,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,OAAO,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAEtD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { AuthProvider } from "./components/AuthProvider";
|
|
2
|
+
export { buildMsalConfig } from "./msalConfig";
|
|
3
|
+
export type { AuthConfig } from "./config";
|
|
4
|
+
export { DEFAULT_SCOPES, LOGIN_SCOPES } from "./scopes";
|
|
5
|
+
export type { DefaultScope, LoginScope } from "./scopes";
|
|
6
|
+
export { useAuth } from "./hooks/useAuth";
|
|
7
|
+
export type { AuthUser, UseAuthReturn } from "./hooks/useAuth";
|
|
8
|
+
export { useGraphClient } from "./hooks/useGraphClient";
|
|
9
|
+
export type { UseGraphClientReturn } from "./hooks/useGraphClient";
|
|
10
|
+
export { useSharePointList } from "./hooks/useSharePointList";
|
|
11
|
+
export type { UseSharePointListReturn } from "./hooks/useSharePointList";
|
|
12
|
+
export { useSharePointFiles } from "./hooks/useSharePointFiles";
|
|
13
|
+
export type { UseSharePointFilesReturn } from "./hooks/useSharePointFiles";
|
|
14
|
+
export { LoginButton } from "./components/LoginButton";
|
|
15
|
+
export { UserAvatar } from "./components/UserAvatar";
|
|
16
|
+
export { ProtectedContent } from "./components/ProtectedContent";
|
|
17
|
+
export { SharePointGallery } from "./components/SharePointGallery";
|
|
18
|
+
export { SharePointFileList } from "./components/SharePointFileList";
|
|
19
|
+
export { SharePointListView } from "./components/SharePointListView";
|
|
20
|
+
export { createGraphClient } from "./graph/client";
|
|
21
|
+
export { getSite, getListItems, getDocumentLibraryFiles, getFileContent, getImageThumbnails, } from "./graph/sharepoint";
|
|
22
|
+
export type { SpSite, SpListItem, SpDriveItem, SpThumbnail, } from "./graph/sharepoint";
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,OAAO,EACP,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,MAAM,EACN,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @easy-web/auth — public API barrel
|
|
2
|
+
// Core
|
|
3
|
+
export { AuthProvider } from "./components/AuthProvider";
|
|
4
|
+
export { buildMsalConfig } from "./msalConfig";
|
|
5
|
+
export { DEFAULT_SCOPES, LOGIN_SCOPES } from "./scopes";
|
|
6
|
+
// Auth hooks
|
|
7
|
+
export { useAuth } from "./hooks/useAuth";
|
|
8
|
+
// Graph hooks
|
|
9
|
+
export { useGraphClient } from "./hooks/useGraphClient";
|
|
10
|
+
export { useSharePointList } from "./hooks/useSharePointList";
|
|
11
|
+
export { useSharePointFiles } from "./hooks/useSharePointFiles";
|
|
12
|
+
// UI Components
|
|
13
|
+
export { LoginButton } from "./components/LoginButton";
|
|
14
|
+
export { UserAvatar } from "./components/UserAvatar";
|
|
15
|
+
export { ProtectedContent } from "./components/ProtectedContent";
|
|
16
|
+
export { SharePointGallery } from "./components/SharePointGallery";
|
|
17
|
+
export { SharePointFileList } from "./components/SharePointFileList";
|
|
18
|
+
export { SharePointListView } from "./components/SharePointListView";
|
|
19
|
+
// Graph utilities
|
|
20
|
+
export { createGraphClient } from "./graph/client";
|
|
21
|
+
export { getSite, getListItems, getDocumentLibraryFiles, getFileContent, getImageThumbnails, } from "./graph/sharepoint";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,OAAO;AACP,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxD,aAAa;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,kBAAkB;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,OAAO,EACP,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Configuration } from "@azure/msal-browser";
|
|
2
|
+
import type { AuthConfig } from "./config";
|
|
3
|
+
/**
|
|
4
|
+
* Builds an MSAL PublicClientApplication Configuration from an AuthConfig.
|
|
5
|
+
* Never called during SSR — only runs in the browser (inside client:only components).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildMsalConfig(config: AuthConfig): Configuration;
|
|
8
|
+
//# sourceMappingURL=msalConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msalConfig.d.ts","sourceRoot":"","sources":["../src/msalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CA+BjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BrowserCacheLocation, LogLevel, } from "@azure/msal-browser";
|
|
2
|
+
/**
|
|
3
|
+
* Builds an MSAL PublicClientApplication Configuration from an AuthConfig.
|
|
4
|
+
* Never called during SSR — only runs in the browser (inside client:only components).
|
|
5
|
+
*/
|
|
6
|
+
export function buildMsalConfig(config) {
|
|
7
|
+
const redirectUri = config.redirectUri ??
|
|
8
|
+
(typeof window !== "undefined" ? window.location.origin : "/");
|
|
9
|
+
return {
|
|
10
|
+
auth: {
|
|
11
|
+
clientId: config.clientId,
|
|
12
|
+
authority: `https://login.microsoftonline.com/${config.tenantId}`,
|
|
13
|
+
redirectUri,
|
|
14
|
+
postLogoutRedirectUri: redirectUri,
|
|
15
|
+
navigateToLoginRequestUrl: true,
|
|
16
|
+
},
|
|
17
|
+
cache: {
|
|
18
|
+
cacheLocation: BrowserCacheLocation.SessionStorage,
|
|
19
|
+
},
|
|
20
|
+
system: {
|
|
21
|
+
loggerOptions: {
|
|
22
|
+
logLevel: LogLevel.Warning,
|
|
23
|
+
loggerCallback: (level, message, containsPii) => {
|
|
24
|
+
const nodeEnv = globalThis.process?.env?.NODE_ENV;
|
|
25
|
+
if (!containsPii && nodeEnv === "development") {
|
|
26
|
+
console.warn(`[MSAL] ${message}`);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
piiLoggingEnabled: false,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=msalConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msalConfig.js","sourceRoot":"","sources":["../src/msalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACpB,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAG7B;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAChD,MAAM,WAAW,GACf,MAAM,CAAC,WAAW;QAClB,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEjE,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,SAAS,EAAE,qCAAqC,MAAM,CAAC,QAAQ,EAAE;YACjE,WAAW;YACX,qBAAqB,EAAE,WAAW;YAClC,yBAAyB,EAAE,IAAI;SAChC;QACD,KAAK,EAAE;YACL,aAAa,EAAE,oBAAoB,CAAC,cAAc;SACnD;QACD,MAAM,EAAE;YACN,aAAa,EAAE;gBACb,QAAQ,EAAE,QAAQ,CAAC,OAAO;gBAC1B,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE;oBAC9C,MAAM,OAAO,GAAI,UAEf,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC;oBAC1B,IAAI,CAAC,WAAW,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;wBAC9C,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC;gBACD,iBAAiB,EAAE,KAAK;aACzB;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/scopes.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Graph API delegated scopes for SharePoint access.
|
|
3
|
+
* All three are registered on the Entra app registrations with admin consent.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_SCOPES: readonly ["User.Read", "Sites.Read.All", "Files.Read.All"];
|
|
6
|
+
/**
|
|
7
|
+
* Scopes used during the login redirect flow.
|
|
8
|
+
* Minimal set to identify the user; token for data is acquired separately.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LOGIN_SCOPES: readonly ["openid", "profile", "User.Read"];
|
|
11
|
+
export type DefaultScope = (typeof DEFAULT_SCOPES)[number];
|
|
12
|
+
export type LoginScope = (typeof LOGIN_SCOPES)[number];
|
|
13
|
+
//# sourceMappingURL=scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc,4DAIjB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,YAAY,6CAA8C,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/scopes.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Graph API delegated scopes for SharePoint access.
|
|
3
|
+
* All three are registered on the Entra app registrations with admin consent.
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_SCOPES = [
|
|
6
|
+
"User.Read",
|
|
7
|
+
"Sites.Read.All",
|
|
8
|
+
"Files.Read.All",
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Scopes used during the login redirect flow.
|
|
12
|
+
* Minimal set to identify the user; token for data is acquired separately.
|
|
13
|
+
*/
|
|
14
|
+
export const LOGIN_SCOPES = ["openid", "profile", "User.Read"];
|
|
15
|
+
//# sourceMappingURL=scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.js","sourceRoot":"","sources":["../src/scopes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW;IACX,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easy-web/auth",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"packageManager": "pnpm@10.34.4",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./components/*": {
|
|
12
|
+
"types": "./dist/components/*.d.ts",
|
|
13
|
+
"import": "./dist/components/*.js"
|
|
14
|
+
},
|
|
15
|
+
"./hooks/*": {
|
|
16
|
+
"types": "./dist/hooks/*.d.ts",
|
|
17
|
+
"import": "./dist/hooks/*.js"
|
|
18
|
+
},
|
|
19
|
+
"./graph/*": {
|
|
20
|
+
"types": "./dist/graph/*.d.ts",
|
|
21
|
+
"import": "./dist/graph/*.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"typecheck": "tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=18.0.0",
|
|
36
|
+
"react-dom": ">=18.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
40
|
+
"@testing-library/react": "^16.3.2",
|
|
41
|
+
"@testing-library/user-event": "^14.6.1",
|
|
42
|
+
"@types/react": "^19.1.8",
|
|
43
|
+
"@types/react-dom": "^19.1.6",
|
|
44
|
+
"jsdom": "^29.1.1",
|
|
45
|
+
"react": "^19.1.1",
|
|
46
|
+
"react-dom": "^19.1.1",
|
|
47
|
+
"typescript": "^5.5.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"provenance": true
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/achimismaili/easy-web.git",
|
|
56
|
+
"directory": "packages/auth"
|
|
57
|
+
},
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@azure/msal-browser": "4",
|
|
61
|
+
"@azure/msal-react": "3",
|
|
62
|
+
"@microsoft/microsoft-graph-client": "^3.0.7"
|
|
63
|
+
}
|
|
64
|
+
}
|