ozone-typescript-client
Advanced tools
Comparing version 0.9.6 to 0.9.8
@@ -37,4 +37,2 @@ import { fsm } from "typescript-state-machine"; | ||
call<T>(request: Request): Promise<T>; | ||
waitUntilLeft(state: ClientState): Promise<ClientState>; | ||
waitUntilEntered(state: ClientState): Promise<ClientState>; | ||
onMessage(messageType: string, callBack: (message: Message) => void): ListenerRegistration; | ||
@@ -44,2 +42,3 @@ onAnyMessage(callBack: (message: Message) => void): ListenerRegistration; | ||
itemClient<T extends Item>(typeIdentifier: string): ItemClient<T>; | ||
insertSessionIdInURL(url: string): string; | ||
} | ||
@@ -135,3 +134,4 @@ type UUID = string; | ||
private setupFilters; | ||
itemClient<T extends Item>(typeIdentifier: string): OzoneClient.ItemClient<T>; | ||
itemClient<T extends Item>(typeIdentifier: string): ItemClient<T>; | ||
insertSessionIdInURL(url: string): string; | ||
} | ||
@@ -170,3 +170,4 @@ abstract class OzoneCredentials { | ||
webSocketsURL?: string; | ||
defaultTimeout?: number; | ||
} | ||
} |
@@ -64,3 +64,2 @@ var __extends = (this && this.__extends) || (function () { | ||
var AssumeStateIsNot = fsm.AssumeStateIsNot; | ||
var log = log4javascript.getLogger("ozone.client"); | ||
var State = fsm.State; | ||
@@ -71,2 +70,4 @@ var AssumeStateIs = fsm.AssumeStateIs; | ||
var newHttpClient = httpclient.newHttpClient; | ||
var log = log4javascript.getLogger("ozone.client"); | ||
var DEFAULT_TIMEOUT = 5000; | ||
var ClientState = /** @class */ (function (_super) { | ||
@@ -608,4 +609,2 @@ __extends(ClientState, _super); | ||
this.onEnterState(OzoneClient.states.AUTHENTICATING, function () { return _this.login(); }); | ||
// Connect to message server when entering state "CONNECTING" | ||
this.onEnterState(OzoneClient.states.WS_CONNECTING, function () { return _this.connect(); }); | ||
// Auto re-authenticate to Ozone in case of error | ||
@@ -618,2 +617,4 @@ this.onEnterState(OzoneClient.states.NETWORK_OR_SERVER_ERROR, function () { return _this.createAutoReAuthTimer(); }); | ||
this.onEnterState(OzoneClient.states.AUTHENTICATED, function () { return _this.connectIfPossible(); }); | ||
// Connect to message server when entering state "CONNECTING" | ||
this.onEnterState(OzoneClient.states.WS_CONNECTING, function () { return _this.connect(); }); | ||
// WS Ping KeepAlive | ||
@@ -635,3 +636,3 @@ this.onEnterState(OzoneClient.states.WS_CONNECTED, function () { return _this.installWSPingKeepAlive(); }); | ||
// Set some sensible default to all requests | ||
this._httpClient.addFilter(new DefaultsOptions()); | ||
this._httpClient.addFilter(new DefaultsOptions(this._config.defaultTimeout || DEFAULT_TIMEOUT)); | ||
}; | ||
@@ -718,2 +719,5 @@ OzoneClientImpl.prototype.itemClient = function (typeIdentifier) { | ||
}; | ||
OzoneClientImpl.prototype.insertSessionIdInURL = function (url) { | ||
return ""; | ||
}; | ||
__decorate([ | ||
@@ -786,3 +790,3 @@ AssumeStateIs(OzoneClient.states.WS_CONNECTED), | ||
call.headers[name] = value; | ||
log.trace("AddHeader called. Headers are now " + call.headers); | ||
log.trace("AddHeader called with name=" + name + " and value=" + value + ". Headers are now " + JSON.stringify(call.headers)); | ||
} | ||
@@ -896,5 +900,12 @@ var OzoneCredentials = /** @class */ (function () { | ||
response = e_2; | ||
if (!((response.status == 403 || response.status == 401) | ||
if (! | ||
// Only try to re-authenticate if we receive a 401 or 403 status code | ||
((response.status == 403 || response.status == 401) | ||
// If we receive a principal id, it means we are still authenticated with a valid session, so there is no need | ||
// to try to re-authenticate | ||
&& !response.headers["ozone-principal-id"] | ||
&& this.client.isAuthenticated)) return [3 /*break*/, 8]; | ||
// Only try to re-authenticate if we are already authenticated | ||
&& this.client.isAuthenticated)) | ||
// Only try to re-authenticate if we receive a 401 or 403 status code | ||
return [3 /*break*/, 8]; | ||
_a.label = 3; | ||
@@ -918,3 +929,3 @@ case 3: | ||
e_3 = _a.sent(); | ||
// TODO AB set state to authentication error in case of login error? | ||
// TODO AB Maybe : set state to authentication error in case of login error? | ||
throw e_3; | ||
@@ -943,4 +954,4 @@ case 7: return [3 /*break*/, 9]; | ||
authInfo = this.authProvider(); | ||
log.trace("SessionFilter : authInfo = " + authInfo); | ||
if (authInfo) { | ||
log.trace("SessionFilter : authInfo = " + authInfo + ", class=" + authInfo.constructor.name + ", sessionId=" + authInfo.sessionId + ", sessionId=" + authInfo["sessionId"]); | ||
addHeader(call, "Ozone-Session-Id", authInfo.sessionId); | ||
@@ -958,3 +969,4 @@ } | ||
var DefaultsOptions = /** @class */ (function () { | ||
function DefaultsOptions() { | ||
function DefaultsOptions(defaultTimeout) { | ||
this.defaultTimeout = defaultTimeout; | ||
} | ||
@@ -964,11 +976,5 @@ DefaultsOptions.prototype.doFilter = function (request, filterChain) { | ||
return __generator(this, function (_a) { | ||
if (!request.responseType) { | ||
request.responseType = 'json'; | ||
if (!request.timeout || request.timeout > this.defaultTimeout) { | ||
request.timeout = this.defaultTimeout; | ||
} | ||
if (!request.contentType) { | ||
request.contentType = 'application/json; charset=UTF-8'; | ||
} | ||
if (!request.timeout) { | ||
request.timeout = 30000; | ||
} | ||
return [2 /*return*/, filterChain.doFilter(request)]; | ||
@@ -975,0 +981,0 @@ }); |
{ | ||
"name": "ozone-typescript-client", | ||
"version": "0.9.6", | ||
"version": "0.9.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
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
108995
11
1167