ozone-typescript-client
Advanced tools
Comparing version 6.1.0 to 6.1.2
import type { Logger } from 'generic-logger-typings'; | ||
import { StateMachine, ListenerRegistration } from 'typescript-state-machine'; | ||
import type { Filter, InstalledFilter, Request, Response } from 'typescript-http-client'; | ||
import { DeviceMessage, Item } from 'ozone-type'; | ||
import { DeviceMessage, Item, Principal, User, UUID } from 'ozone-type'; | ||
import { ClientState } from './clientState'; | ||
@@ -29,2 +29,9 @@ import { ItemClient } from '../itemClient/itemClient'; | ||
} | ||
export declare type AuthenticatedPrincipal = ((User & { | ||
tenantId: UUID; | ||
}) | (Principal & { | ||
tenant: UUID; | ||
})) & { | ||
id: UUID; | ||
}; | ||
export interface OzoneClient extends StateMachine<ClientState> { | ||
@@ -41,2 +48,7 @@ readonly config: ClientConfiguration; | ||
updateCredentials(ozoneCredentials: OzoneCredentials): void; | ||
/** | ||
* Retrieve the principal this client has authenticated with | ||
* @throws if client is not authenticated | ||
*/ | ||
currentPrincipal(): Promise<AuthenticatedPrincipal>; | ||
stop(): Promise<void>; | ||
@@ -43,0 +55,0 @@ callForResponse<T>(request: Request): Promise<Response<T>>; |
@@ -11,3 +11,3 @@ import type { Logger } from 'generic-logger-typings'; | ||
import { TypeClient } from '../typeClient/typeClient'; | ||
import { OzoneClient, OzoneCredentials, AuthInfo, ClientConfiguration } from './ozoneClient'; | ||
import { OzoneClient, OzoneCredentials, AuthInfo, ClientConfiguration, AuthenticatedPrincipal } from './ozoneClient'; | ||
import { TaskClient } from '../taskClient/taskClient'; | ||
@@ -44,2 +44,3 @@ import { ImportExportClient } from '../importExportClient/importExportClient'; | ||
updateCredentials(credentials: OzoneCredentials): void; | ||
currentPrincipal(): Promise<AuthenticatedPrincipal>; | ||
stop(): Promise<void>; | ||
@@ -46,0 +47,0 @@ call<T>(call: Request): Promise<T>; |
@@ -141,2 +141,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
} | ||
currentPrincipal() { | ||
if (!this.isAuthenticated) { | ||
throw Error('Cannot retrieve principal: client is not authenticated.'); | ||
} | ||
const request = new Request(`${this.config.ozoneURL}/rest/v3/authentication/current/principal`) | ||
.set({ | ||
method: 'GET', | ||
withCredentials: true | ||
}); | ||
return this.call(request); | ||
} | ||
stop() { | ||
@@ -143,0 +154,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "ozone-typescript-client", | ||
"version": "6.1.0", | ||
"version": "6.1.2", | ||
"description": "", | ||
@@ -38,3 +38,3 @@ "main": "dist/src/index.js", | ||
}, | ||
"gitHead": "a723ead1ef0f5b31a3a055f10366be78dc4cd3b4" | ||
"gitHead": "d9d26ea781f7fcb7ad5e515ea0a2d66708520482" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
471887
5136