@cedarjs/auth-azure-active-directory-web 5.0.7-next.338 → 5.0.7

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.
@@ -0,0 +1,11 @@
1
+ import type { EndSessionRequest, PublicClientApplication as AzureActiveDirectoryClient, RedirectRequest } from '@azure/msal-browser';
2
+ import type { CurrentUser } from '@cedarjs/auth';
3
+ export declare function createAuth(azureActiveDirectoryClient: AzureActiveDirectoryClient, customProviderHooks?: {
4
+ useCurrentUser?: () => Promise<CurrentUser>;
5
+ useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
6
+ }): {
7
+ AuthContext: import("react").Context<import("@cedarjs/auth").AuthContextInterface<import("@azure/msal-browser").AccountInfo, RedirectRequest, void, EndSessionRequest, void, RedirectRequest, void, unknown, unknown, unknown, unknown, AzureActiveDirectoryClient> | undefined>;
8
+ AuthProvider: ({ children }: import("@cedarjs/auth").AuthProviderProps) => import("react").JSX.Element;
9
+ useAuth: () => import("@cedarjs/auth").AuthContextInterface<import("@azure/msal-browser").AccountInfo, RedirectRequest, void, EndSessionRequest, void, RedirectRequest, void, unknown, unknown, unknown, unknown, AzureActiveDirectoryClient>;
10
+ };
11
+ //# sourceMappingURL=azureActiveDirectory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"azureActiveDirectory.d.ts","sourceRoot":"","sources":["../../src/azureActiveDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,IAAI,0BAA0B,EACrD,eAAe,EAEhB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAGhD,wBAAgB,UAAU,CACxB,0BAA0B,EAAE,0BAA0B,EACtD,mBAAmB,CAAC,EAAE;IACpB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD;;;;EAOF"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var azureActiveDirectory_exports = {};
20
+ __export(azureActiveDirectory_exports, {
21
+ createAuth: () => createAuth
22
+ });
23
+ module.exports = __toCommonJS(azureActiveDirectory_exports);
24
+ var import_msal_browser = require("@azure/msal-browser");
25
+ var import_auth = require("@cedarjs/auth");
26
+ function createAuth(azureActiveDirectoryClient, customProviderHooks) {
27
+ const authImplementation = createAuthImplementation(
28
+ azureActiveDirectoryClient
29
+ );
30
+ return (0, import_auth.createAuthentication)(authImplementation, customProviderHooks);
31
+ }
32
+ function createAuthImplementation(azureActiveDirectoryClient) {
33
+ return {
34
+ type: "azureActiveDirectory",
35
+ client: azureActiveDirectoryClient,
36
+ login: async (options) => azureActiveDirectoryClient.loginRedirect(options),
37
+ logout: (options) => azureActiveDirectoryClient.logoutRedirect(options),
38
+ signup: async (options) => azureActiveDirectoryClient.loginRedirect(options),
39
+ getToken: async (options) => {
40
+ const request = options || {
41
+ scopes: ["openid", "profile"]
42
+ };
43
+ try {
44
+ const token = await azureActiveDirectoryClient.acquireTokenSilent(request);
45
+ return token.idToken;
46
+ } catch (error) {
47
+ if (error instanceof import_msal_browser.InteractionRequiredAuthError) {
48
+ azureActiveDirectoryClient.acquireTokenRedirect(request);
49
+ }
50
+ }
51
+ return null;
52
+ },
53
+ getUserMetadata: async () => {
54
+ return azureActiveDirectoryClient.getActiveAccount();
55
+ },
56
+ restoreAuthState: async () => {
57
+ await azureActiveDirectoryClient.handleRedirectPromise().then((token) => {
58
+ if (token) {
59
+ const accounts = azureActiveDirectoryClient.getAllAccounts();
60
+ switch (accounts.length) {
61
+ case 0:
62
+ azureActiveDirectoryClient.loginRedirect();
63
+ break;
64
+ case 1:
65
+ azureActiveDirectoryClient.setActiveAccount(accounts[0]);
66
+ break;
67
+ default:
68
+ azureActiveDirectoryClient.loginRedirect();
69
+ }
70
+ }
71
+ });
72
+ }
73
+ };
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ createAuth
78
+ });
@@ -0,0 +1,2 @@
1
+ export { createAuth } from './azureActiveDirectory.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var index_exports = {};
20
+ __export(index_exports, {
21
+ createAuth: () => import_azureActiveDirectory.createAuth
22
+ });
23
+ module.exports = __toCommonJS(index_exports);
24
+ var import_azureActiveDirectory = require("./azureActiveDirectory.js");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ createAuth
28
+ });
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/auth-azure-active-directory-web",
3
- "version": "5.0.7-next.338",
3
+ "version": "5.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -10,19 +10,28 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "default": {
13
+ "import": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
+ },
17
+ "default": {
18
+ "types": "./dist/cjs/index.d.ts",
19
+ "default": "./dist/cjs/index.js"
16
20
  }
17
21
  },
18
22
  "./dist/azureActiveDirectory": {
19
- "default": {
23
+ "import": {
20
24
  "types": "./dist/azureActiveDirectory.d.ts",
21
25
  "default": "./dist/azureActiveDirectory.js"
26
+ },
27
+ "default": {
28
+ "types": "./dist/cjs/azureActiveDirectory.d.ts",
29
+ "default": "./dist/cjs/azureActiveDirectory.js"
22
30
  }
23
31
  }
24
32
  },
25
- "main": "./dist/index.js",
33
+ "main": "./dist/cjs/index.js",
34
+ "module": "./dist/index.js",
26
35
  "types": "./dist/index.d.ts",
27
36
  "files": [
28
37
  "dist"
@@ -31,6 +40,7 @@
31
40
  "build": "node ./build.mts",
32
41
  "build:pack": "yarn pack -o cedarjs-auth-azure-active-directory-web.tgz",
33
42
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
43
+ "build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
34
44
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
35
45
  "check:attw": "yarn cedar-fwtools-attw",
36
46
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -39,17 +49,19 @@
39
49
  "test:watch": "vitest watch"
40
50
  },
41
51
  "dependencies": {
42
- "@cedarjs/auth": "5.0.7-next.338"
52
+ "@cedarjs/auth": "5.0.7"
43
53
  },
44
54
  "devDependencies": {
55
+ "@arethetypeswrong/cli": "0.18.4",
45
56
  "@azure/msal-browser": "2.39.0",
46
- "@cedarjs/framework-tools": "5.0.7-next.338",
57
+ "@cedarjs/framework-tools": "5.0.7",
58
+ "@types/netlify-identity-widget": "1.9.7",
47
59
  "@types/react": "^18.2.55",
48
60
  "concurrently": "9.2.4",
49
- "publint": "0.3.23",
61
+ "publint": "0.3.21",
50
62
  "react": "18.3.1",
51
63
  "typescript": "5.9.3",
52
- "vitest": "4.1.10"
64
+ "vitest": "3.2.6"
53
65
  },
54
66
  "peerDependencies": {
55
67
  "@azure/msal-browser": "2.39.0"