Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: upgrade all packages to @itwin/eslint-plugin@6 and eslint@9",
"packageName": "@itwin/browser-authorization",
"email": "50554904+hl662@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: upgrade all packages to @itwin/eslint-plugin@6 and eslint@9",
"packageName": "@itwin/electron-authorization",
"email": "50554904+hl662@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: upgrade all packages to @itwin/eslint-plugin@6 and eslint@9",
"packageName": "@itwin/node-cli-authorization",
"email": "50554904+hl662@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: upgrade all packages to @itwin/eslint-plugin@6 and eslint@9",
"packageName": "@itwin/oidc-signin-tool",
"email": "50554904+hl662@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "chore: upgrade all packages to @itwin/eslint-plugin@6 and eslint@9",
"packageName": "@itwin/service-authorization",
"email": "50554904+hl662@users.noreply.github.com",
"dependentChangeType": "patch"
}
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
"pnpm": {
"overrides": {
"path-to-regexp": "0.1.12",
"minimatch@>=9.0.0 <9.0.7": ">=9.0.7",
"serialize-javascript@<=7.0.2": ">=7.0.3",
"flat-cache>flatted": ">=3.4.2"
"serialize-javascript@<=7.0.2": ">=7.0.3"
}
},
"packageManager": "pnpm@9.15.9+sha512.68046141893c66fad01c079231128e9afb89ef87e2691d69e4d40eee228988295fd4682181bae55b58418c3a253bde65a505ec7c5f9403ece5cc3cd37dcf2531"
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
"@itwin/build-tools": "^5.5.0",
"@itwin/core-bentley": "^5.0.0",
"@itwin/core-common": "^5.0.0",
"@itwin/eslint-plugin": "^4.1.1",
"@itwin/eslint-plugin": "^6.0.0",
"@playwright/test": "~1.56.1",
"@types/chai": "^4.3.20",
"@types/mocha": "^8.2.3",
"@types/node": "^20.19.1",
"@types/sinon": "^10.0.20",
"chai": "^4.5.0",
"dotenv": "~16.0.3",
"eslint": "^8.57.1",
"eslint": "^9.11.1",
"mocha": "^10.8.2",
"nyc": "^17.1.0",
"rimraf": "^3.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class BrowserAuthorizationClient implements AuthorizationClient {

this._basicSettings = {
...configuration,
authority: configuration.authority ?? getImsAuthority(), // eslint-disable-line deprecation/deprecation
authority: configuration.authority ?? getImsAuthority(), // eslint-disable-line @typescript-eslint/no-deprecated
};
}

Expand Down Expand Up @@ -237,7 +237,7 @@ export class BrowserAuthorizationClient implements AuthorizationClient {
try {
user = (await userManager.signinSilent()) ?? undefined; // calls events
return user;
} catch (err) {
} catch {
return undefined;
}
}
Expand Down Expand Up @@ -311,7 +311,7 @@ export class BrowserAuthorizationClient implements AuthorizationClient {
const userManager = await this.getUserManager();
try {
await userManager.querySessionStatus();
} catch (err) {
} catch {
// Access token is no longer valid in this session
await userManager.removeUser();
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ describe("BrowserAuthorizationClient", () => {
const client = new BrowserAuthorizationClient(testConfigWithoutAuthority);

// getImsAuthority manages the value of the default authority
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line deprecation/deprecation
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("default authority is used and when none is given and uses environment prefix", () => {
process.env.IMJS_URL_PREFIX = "prefix-";
const client = new BrowserAuthorizationClient(testConfigWithoutAuthority);

// getImsAuthority manages the value of the default authority
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line deprecation/deprecation
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("_basicSettings contains passed in configuration", () => {
Expand Down Expand Up @@ -111,15 +111,15 @@ describe("BrowserAuthorizationClient", () => {
const client = new BrowserAuthorizationClient(testConfigWithoutAuthority);

// getImsAuthority manages the value of the default authority
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line deprecation/deprecation
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("default authority is used and when none is given and uses environment prefix", () => {
process.env.IMJS_URL_PREFIX = "prefix-";
const client = new BrowserAuthorizationClient(testConfigWithoutAuthority);

// getImsAuthority manages the value of the default authority
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line deprecation/deprecation
assert.equal(client.authorityUrl, getImsAuthority()); // eslint-disable-line @typescript-eslint/no-deprecated
});

it('successfully sets "query" as response mode', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/src/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ describe("getImsAuthority", () => {
it("has no prefix when no prefix is defined", async () => {
process.env.IMJS_URL_PREFIX = "";

assert.equal(getImsAuthority(), "https://ims.bentley.com"); // eslint-disable-line deprecation/deprecation
assert.equal(getImsAuthority(), "https://ims.bentley.com"); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("has correct prefix when prefix is defined", async () => {
process.env.IMJS_URL_PREFIX = "prefix-";

assert.equal(getImsAuthority(), "https://prefix-ims.bentley.com"); // eslint-disable-line deprecation/deprecation
assert.equal(getImsAuthority(), "https://prefix-ims.bentley.com"); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("replaces \"dev-\" prefix with \"qa-\"", async () => {
process.env.IMJS_URL_PREFIX = "dev-";

assert.equal(getImsAuthority(), "https://qa-ims.bentley.com"); // eslint-disable-line deprecation/deprecation
assert.equal(getImsAuthority(), "https://qa-ims.bentley.com"); // eslint-disable-line @typescript-eslint/no-deprecated
});

it("does not modify \"qa-\" prefix", async () => {
process.env.IMJS_URL_PREFIX = "qa-";

assert.equal(getImsAuthority(), "https://qa-ims.bentley.com"); // eslint-disable-line deprecation/deprecation
assert.equal(getImsAuthority(), "https://qa-ims.bentley.com"); // eslint-disable-line @typescript-eslint/no-deprecated
});
});
4 changes: 2 additions & 2 deletions packages/browser/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Returns the IMS authority URL.
* A prefix will be prepended based on the value of the IMJS_URL_PREFIX environment variable.
* The prefix "dev-" will automatically be converted to "qa-".
* @deprecated in 1.1.x Please set the authority in `BrowserAuthorizationClientConfiguration` configuration object.
* @deprecated in 1.1.0. Please set the authority in `BrowserAuthorizationClientConfiguration` configuration object.
*/
export function getImsAuthority(): string {
try {
Expand All @@ -22,7 +22,7 @@ export function getImsAuthority(): string {
prefix = "qa-";

return `https://${prefix}ims.bentley.com`;
} catch (_) {
} catch {
// swallow error
}

Expand Down
4 changes: 2 additions & 2 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@itwin/build-tools": "^5.5.0",
"@itwin/core-bentley": "^5.0.0",
"@itwin/core-common": "^5.0.0",
"@itwin/eslint-plugin": "^4.1.1",
"@itwin/eslint-plugin": "^6.0.0",
"@playwright/test": "~1.56.1",
"@types/chai": "4.3.14",
"@types/chai-as-promised": "^7.1.8",
Expand All @@ -64,7 +64,7 @@
"cpx2": "^5.0.0",
"dotenv": "~16.0.3",
"electron": "^41.0.0",
"eslint": "^8.57.1",
"eslint": "^9.11.1",
"mocha": "^10.8.2",
"nyc": "^17.1.0",
"rimraf": "^3.0.2",
Expand Down
10 changes: 7 additions & 3 deletions packages/electron/src/integration-test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ const getElectronUserDataPath = (): string | undefined => {
switch (process.platform) {
case "darwin": // For MacOS
return `${process.env.HOME}/Library/Application Support/Electron`;
case "win32": // For Windows
return `${process.env.APPDATA!}/Electron`;
case "win32": { // For Windows
const appData = process.env.APPDATA;
if (!appData)
throw new Error("APPDATA environment variable not set on Windows");
return `${appData}/Electron`;
}
case "linux": // For Linux
return undefined; // Linux uses the same path for both main and renderer processes, no need to manually resolve path.
default:
Expand Down Expand Up @@ -80,7 +84,7 @@ test.beforeEach(async () => {
args: ["./dist/integration-test/test-app/index.js"],
});
electronPage = await electronApp.firstWindow();
} catch (error) {
} catch {
}
});

Expand Down
4 changes: 0 additions & 4 deletions packages/electron/src/integration-test/test-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@ void app.whenReady().then(async () => {
channelClientPrefix: "prefixed",
});

// TODO: revisit this lint problem later
// eslint-disable-next-line deprecation/deprecation
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0)
createWindow();
});
});

// TODO: revisit this lint problem later
// eslint-disable-next-line deprecation/deprecation
app.on("window-all-closed", () => {
if (process.platform !== "darwin")
app.quit();
Expand Down
6 changes: 3 additions & 3 deletions packages/electron/src/integration-test/test-app/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ const otherGetStatusButton = document.getElementById("otherGetStatus");
signOutButton?.addEventListener("click", async () => {
try {
await auth.signOut();
} catch (error) {
} catch {

}
});

signInButton?.addEventListener("click", async () => {
try {
await auth.signIn();
} catch (error) {
} catch {

}
});

otherSignInButton?.addEventListener("click", async () => {
try {
await otherAuth.signIn();
} catch (error) {
} catch {

}
});
Expand Down
16 changes: 10 additions & 6 deletions packages/electron/src/main/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class ElectronMainAuthorization implements AuthorizationClient {

/**
* Event raised whenever the access token changes on any instance of ElectronMainAuthorization
* @deprecated in 0.22 - please use the onUserStateChanged instance event instead.
* @deprecated in 0.22.0. Please use the onUserStateChanged instance event instead.
*/
public static readonly onUserStateChanged = new BeEvent<
(token: AccessToken) => void
Expand Down Expand Up @@ -307,7 +307,7 @@ export class ElectronMainAuthorization implements AuthorizationClient {

this._accessToken = token;
this.notifyFrontendAccessTokenChange(this._accessToken);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
ElectronMainAuthorization.onUserStateChanged.raiseEvent(this._accessToken);
this.onUserStateChanged.raiseEvent(this._accessToken);
}
Expand Down Expand Up @@ -378,7 +378,7 @@ export class ElectronMainAuthorization implements AuthorizationClient {
await LoopbackWebServer.start(tryRedirectUri);
redirectUri = tryRedirectUri;
break;
} catch (e: unknown) {
} catch {
// Most common error is EADDRINUSE (port already in use) - just continue with the next port
continue;
}
Expand Down Expand Up @@ -440,7 +440,7 @@ export class ElectronMainAuthorization implements AuthorizationClient {
authRequest,
authResponse,
authError,
).catch((e) => reject(e));
).catch(reject);

authorizationEvents.onAuthorizationResponseCompleted.raiseEvent(
authError ? authError : undefined,
Expand Down Expand Up @@ -519,9 +519,11 @@ export class ElectronMainAuthorization implements AuthorizationClient {
}

// Phase 2: Swap the authorization code for the access token
if (!authRequest.internal)
throw new Error("Missing internal state in authorization request");
const tokenResponse = await this.swapAuthorizationCodeForTokens(
authResponse.code,
authRequest.internal!.code_verifier,
authRequest.internal.code_verifier,
authRequest.redirectUri,
);
Logger.logTrace(
Expand Down Expand Up @@ -662,6 +664,8 @@ export class ElectronMainAuthorization implements AuthorizationClient {
throw new Error(
"Missing refresh token. First call signIn() and ensure it's successful",
);
if (!this._configuration)
throw new Error("Not initialized. First call initialize()");
assert(this._clientId !== "");

const revokeTokenRequestJson: RevokeTokenRequestJson = {
Expand All @@ -676,7 +680,7 @@ export class ElectronMainAuthorization implements AuthorizationClient {
tokenRequestor,
);
await tokenHandler.performRevokeTokenRequest(
this._configuration!,
this._configuration,
revokeTokenRequest,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/main/LoopbackWebServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class LoopbackWebServer {
let authorizationError: AuthorizationErrorJson | null = null;
let httpResponseContent: HtmlTemplateParams;

httpResponse.writeHead(200, { "Content-Type": "text/html" }); // eslint-disable-line @typescript-eslint/naming-convention
httpResponse.writeHead(200, { "Content-Type": "text/html" });

if (error) {
authorizationError = { error, error_description: errorDescription ?? undefined, error_uri: errorUri ?? undefined, state }; // eslint-disable-line @typescript-eslint/naming-convention
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/main/TokenStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { safeStorage } from "electron";
// eslint-disable-next-line @typescript-eslint/naming-convention
const Store = require("electron-store"); // eslint-disable-line @typescript-eslint/no-var-requires
const Store = require("electron-store"); // eslint-disable-line @typescript-eslint/no-require-imports
Comment thread
anmolshres98 marked this conversation as resolved.

/**
* Utility class used to store and read OAuth refresh tokens.
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/renderer/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ElectronAuthIPC {
} else {
// use the methods on window.itwinjs exposed by ElectronPreload.ts, or ipcRenderer directly if running with nodeIntegration=true (**only** for tests).
// Note that `require("electron")` doesn't work with nodeIntegration=false - that's what it stops
this._ipcSocket = (window as any).itwinjs ?? require("electron").ipcRenderer; // eslint-disable-line @typescript-eslint/no-var-requires
this._ipcSocket = (window as any).itwinjs ?? require("electron").ipcRenderer; // eslint-disable-line @typescript-eslint/no-require-imports
Comment thread
anmolshres98 marked this conversation as resolved.
}
}
}
Expand Down
Loading
Loading