mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-13 06:43:16 +00:00
Compare commits
3 Commits
refactor/i
...
v2.10.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14a7833512 | ||
|
|
94d3ece7a9 | ||
|
|
8981b97632 |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -61,7 +61,7 @@ jobs:
|
|||||||
echo "::set-output name=branch-name::$BRANCH_NAME"
|
echo "::set-output name=branch-name::$BRANCH_NAME"
|
||||||
|
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
uses: bitwarden/gh-actions/download-artifacts@23433be15ed6fd046ce12b6889c5184a8d9c8783
|
uses: bitwarden/gh-actions/download-artifacts@c1fa8e09871a860862d6bbe36184b06d2c7e35a8
|
||||||
with:
|
with:
|
||||||
workflow: build.yml
|
workflow: build.yml
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
|
|||||||
2
jslib
2
jslib
Submodule jslib updated: 9950fb42a1...e595c0548e
@@ -30,7 +30,6 @@ import { NodeCryptoFunctionService } from "jslib-node/services/nodeCryptoFunctio
|
|||||||
|
|
||||||
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
||||||
import { Account } from "../../models/account";
|
import { Account } from "../../models/account";
|
||||||
import { refreshToken } from "../../services/api.service";
|
|
||||||
import { AuthService } from "../../services/auth.service";
|
import { AuthService } from "../../services/auth.service";
|
||||||
import { I18nService } from "../../services/i18n.service";
|
import { I18nService } from "../../services/i18n.service";
|
||||||
import { NoopTwoFactorService } from "../../services/noop/noopTwoFactor.service";
|
import { NoopTwoFactorService } from "../../services/noop/noopTwoFactor.service";
|
||||||
@@ -41,14 +40,6 @@ import { SyncService } from "../../services/sync.service";
|
|||||||
import { AuthGuardService } from "./auth-guard.service";
|
import { AuthGuardService } from "./auth-guard.service";
|
||||||
import { LaunchGuardService } from "./launch-guard.service";
|
import { LaunchGuardService } from "./launch-guard.service";
|
||||||
|
|
||||||
function refreshTokenCallback(injector: Injector) {
|
|
||||||
return () => {
|
|
||||||
const stateService = injector.get(StateServiceAbstraction);
|
|
||||||
const authService = injector.get(AuthServiceAbstraction);
|
|
||||||
return refreshToken(stateService, authService);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initFactory(
|
export function initFactory(
|
||||||
environmentService: EnvironmentServiceAbstraction,
|
environmentService: EnvironmentServiceAbstraction,
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
@@ -129,26 +120,26 @@ export function initFactory(
|
|||||||
platformUtilsService: PlatformUtilsServiceAbstraction,
|
platformUtilsService: PlatformUtilsServiceAbstraction,
|
||||||
environmentService: EnvironmentServiceAbstraction,
|
environmentService: EnvironmentServiceAbstraction,
|
||||||
messagingService: MessagingServiceAbstraction,
|
messagingService: MessagingServiceAbstraction,
|
||||||
injector: Injector
|
appIdService: AppIdServiceAbstraction
|
||||||
) =>
|
) =>
|
||||||
new NodeApiService(
|
new NodeApiService(
|
||||||
tokenService,
|
tokenService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
environmentService,
|
environmentService,
|
||||||
|
appIdService,
|
||||||
async (expired: boolean) => messagingService.send("logout", { expired: expired }),
|
async (expired: boolean) => messagingService.send("logout", { expired: expired }),
|
||||||
"Bitwarden_DC/" +
|
"Bitwarden_DC/" +
|
||||||
platformUtilsService.getApplicationVersion() +
|
platformUtilsService.getApplicationVersion() +
|
||||||
" (" +
|
" (" +
|
||||||
platformUtilsService.getDeviceString().toUpperCase() +
|
platformUtilsService.getDeviceString().toUpperCase() +
|
||||||
")",
|
")"
|
||||||
refreshTokenCallback(injector)
|
|
||||||
),
|
),
|
||||||
deps: [
|
deps: [
|
||||||
TokenServiceAbstraction,
|
TokenServiceAbstraction,
|
||||||
PlatformUtilsServiceAbstraction,
|
PlatformUtilsServiceAbstraction,
|
||||||
EnvironmentServiceAbstraction,
|
EnvironmentServiceAbstraction,
|
||||||
MessagingServiceAbstraction,
|
MessagingServiceAbstraction,
|
||||||
Injector,
|
AppIdServiceAbstraction,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
19
src/bwdc.ts
19
src/bwdc.ts
@@ -7,7 +7,6 @@ import { ClientType } from "jslib-common/enums/clientType";
|
|||||||
import { LogLevelType } from "jslib-common/enums/logLevelType";
|
import { LogLevelType } from "jslib-common/enums/logLevelType";
|
||||||
import { StateFactory } from "jslib-common/factories/stateFactory";
|
import { StateFactory } from "jslib-common/factories/stateFactory";
|
||||||
import { GlobalState } from "jslib-common/models/domain/globalState";
|
import { GlobalState } from "jslib-common/models/domain/globalState";
|
||||||
import { ApiLogInCredentials } from "jslib-common/models/domain/logInCredentials";
|
|
||||||
import { AppIdService } from "jslib-common/services/appId.service";
|
import { AppIdService } from "jslib-common/services/appId.service";
|
||||||
import { CipherService } from "jslib-common/services/cipher.service";
|
import { CipherService } from "jslib-common/services/cipher.service";
|
||||||
import { CollectionService } from "jslib-common/services/collection.service";
|
import { CollectionService } from "jslib-common/services/collection.service";
|
||||||
@@ -149,18 +148,20 @@ export class Main {
|
|||||||
this.tokenService = new TokenService(this.stateService);
|
this.tokenService = new TokenService(this.stateService);
|
||||||
this.messagingService = new NoopMessagingService();
|
this.messagingService = new NoopMessagingService();
|
||||||
this.environmentService = new EnvironmentService(this.stateService);
|
this.environmentService = new EnvironmentService(this.stateService);
|
||||||
this.apiService = new NodeApiService(
|
|
||||||
this.tokenService,
|
const customUserAgent =
|
||||||
this.platformUtilsService,
|
|
||||||
this.environmentService,
|
|
||||||
async (expired: boolean) => await this.logout(),
|
|
||||||
"Bitwarden_DC/" +
|
"Bitwarden_DC/" +
|
||||||
this.platformUtilsService.getApplicationVersion() +
|
this.platformUtilsService.getApplicationVersion() +
|
||||||
" (" +
|
" (" +
|
||||||
this.platformUtilsService.getDeviceString().toUpperCase() +
|
this.platformUtilsService.getDeviceString().toUpperCase() +
|
||||||
")",
|
")";
|
||||||
(clientId, clientSecret) =>
|
this.apiService = new NodeApiService(
|
||||||
this.authService.logIn(new ApiLogInCredentials(clientId, clientSecret))
|
this.tokenService,
|
||||||
|
this.platformUtilsService,
|
||||||
|
this.environmentService,
|
||||||
|
this.appIdService,
|
||||||
|
async (expired: boolean) => await this.logout(),
|
||||||
|
customUserAgent
|
||||||
);
|
);
|
||||||
this.containerService = new ContainerService(this.cryptoService);
|
this.containerService = new ContainerService(this.cryptoService);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@bitwarden/directory-connector",
|
"name": "@bitwarden/directory-connector",
|
||||||
"productName": "Bitwarden Directory Connector",
|
"productName": "Bitwarden Directory Connector",
|
||||||
"description": "Sync your user directory to your Bitwarden organization.",
|
"description": "Sync your user directory to your Bitwarden organization.",
|
||||||
"version": "2.10.0",
|
"version": "2.10.1",
|
||||||
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
|
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
|
||||||
"homepage": "https://bitwarden.com",
|
"homepage": "https://bitwarden.com",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
import { AuthService } from "jslib-common/abstractions/auth.service";
|
|
||||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
|
||||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
|
||||||
import { TokenService } from "jslib-common/abstractions/token.service";
|
|
||||||
import { ApiLogInCredentials } from "jslib-common/models/domain/logInCredentials";
|
|
||||||
import { ApiService as ApiServiceBase } from "jslib-common/services/api.service";
|
|
||||||
|
|
||||||
import { StateService } from "../abstractions/state.service";
|
|
||||||
|
|
||||||
export async function refreshToken(stateService: StateService, authService: AuthService) {
|
|
||||||
try {
|
|
||||||
const clientId = await stateService.getApiKeyClientId();
|
|
||||||
const clientSecret = await stateService.getApiKeyClientSecret();
|
|
||||||
if (clientId != null && clientSecret != null) {
|
|
||||||
await authService.logIn(new ApiLogInCredentials(clientId, clientSecret));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ApiService extends ApiServiceBase {
|
|
||||||
constructor(
|
|
||||||
tokenService: TokenService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
environmentService: EnvironmentService,
|
|
||||||
private refreshTokenCallback: () => Promise<void>,
|
|
||||||
logoutCallback: (expired: boolean) => Promise<void>,
|
|
||||||
customUserAgent: string = null
|
|
||||||
) {
|
|
||||||
super(tokenService, platformUtilsService, environmentService, logoutCallback, customUserAgent);
|
|
||||||
}
|
|
||||||
|
|
||||||
doRefreshToken(): Promise<void> {
|
|
||||||
return this.refreshTokenCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user