@screencloud/auth-sdk
Advanced tools
Comparing version 2.0.4 to 2.1.0
import { EventEmitter } from '@screencloud/event-emitter'; | ||
import { AuthServiceErrorResponse, AuthServiceSuccessResponse } from './authRestfulTypes'; | ||
import { AuthLoggedOutEvent, IAuthRefreshError, IAuthSession } from './types'; | ||
import { AuthLoggedOutEvent, IAuthRefreshError, IAuthSession, IRefreshParameters } from './types'; | ||
export declare function isAuthSession(session: IAuthSession | any): session is IAuthSession; | ||
@@ -49,3 +49,3 @@ export declare function isAuthCache(x: IAuthCache | any): x is IAuthCache; | ||
}): Promise<T_RESPONSE | AuthServiceErrorResponse>; | ||
refresh(): Promise<IAuthSession>; | ||
refresh(parameters?: IRefreshParameters): Promise<IAuthSession>; | ||
setCache(session: IAuthSession | null, date?: number): void; | ||
@@ -52,0 +52,0 @@ shouldRefresh(): boolean; |
@@ -228,5 +228,6 @@ "use strict"; | ||
}; | ||
Auth.prototype.refresh = function () { | ||
Auth.prototype.refresh = function (parameters) { | ||
if (parameters === void 0) { parameters = { shouldFetchSkillJar: false }; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, e_2, error, claims, token, session; | ||
var response, shouldFetchSkillJar, path, e_2, error, claims, token, skilljar, session; | ||
return __generator(this, function (_a) { | ||
@@ -239,3 +240,5 @@ switch (_a.label) { | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.fetchJson('/token/refresh')]; | ||
shouldFetchSkillJar = parameters.shouldFetchSkillJar; | ||
path = "/token/refresh" + (shouldFetchSkillJar ? "?skilljar=1" : ''); | ||
return [4 /*yield*/, this.fetchJson(path)]; | ||
case 2: | ||
@@ -250,3 +253,3 @@ response = _a.sent(); | ||
case 4: | ||
error = response.error, claims = response.claims, token = response.token; | ||
error = response.error, claims = response.claims, token = response.token, skilljar = response.skilljar; | ||
// error message received, throw to forward | ||
@@ -258,3 +261,3 @@ if (isAuthSessionError(error)) { | ||
} | ||
session = { claims: claims, token: token }; | ||
session = { claims: claims, token: token, skilljar: skilljar }; | ||
if (!isAuthSession(session)) { | ||
@@ -261,0 +264,0 @@ this.log('refresh() received invalid payload', response); |
@@ -58,2 +58,5 @@ "use strict"; | ||
token: 'eyFooFoo', | ||
skilljar: { | ||
loginToken: 'loginToken', | ||
} | ||
}; | ||
@@ -69,2 +72,5 @@ var defaultSessionWithPC = { | ||
token: 'eyFooFoo', | ||
skilljar: { | ||
loginToken: 'loginToken', | ||
} | ||
}; | ||
@@ -71,0 +77,0 @@ var defaultConfig = { |
import { AuthServiceSuccessResponse, PublicUserIdentity, User } from './authRestfulTypes'; | ||
export interface IRefreshParameters { | ||
shouldFetchSkillJar?: boolean; | ||
} | ||
export interface IAuthBaseClaims { | ||
@@ -19,5 +22,9 @@ aud: string; | ||
} | ||
export interface ISkillJar { | ||
loginToken: string; | ||
} | ||
export interface IAuthSession { | ||
claims: IAuthClaims; | ||
token: string; | ||
skilljar?: ISkillJar; | ||
} | ||
@@ -24,0 +31,0 @@ export interface IAuthRefreshError { |
@@ -67,3 +67,3 @@ { | ||
}, | ||
"version": "2.0.4" | ||
"version": "2.1.0" | ||
} |
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
77618
1471