Skip to content

Commit

Permalink
tngan#142 Fix build error caused from lodash.get in test (node v4, v6…
Browse files Browse the repository at this point in the history
…, v7)
  • Loading branch information
killalau committed Oct 20, 2017
1 parent f778f1c commit 6155248
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/binding-post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function base64LoginRequest(referenceTagXPath: string, entity: any, customTagRep

if (metadata && metadata.idp && metadata.sp) {
const base = metadata.idp.getSingleSignOnService(binding.post);
let rawSamlRequest;
let rawSamlRequest: string;
if (spSetting.loginRequestTemplate) {
const info = customTagReplacement(spSetting.loginRequestTemplate.context);
id = get<string>(info, 'id');
rawSamlRequest = get<string>(info, 'context');
id = get<BindingContext, keyof BindingContext>(info, 'id');
rawSamlRequest = get<BindingContext, keyof BindingContext>(info, 'context');
} else {
id = spSetting.generateID();
rawSamlRequest = libsaml.replaceTagsByValue(libsaml.defaultLoginRequestTemplate.context, {
Expand Down Expand Up @@ -84,7 +84,7 @@ async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any
};
if (metadata && metadata.idp && metadata.sp) {
const base = metadata.sp.getAssertionConsumerService(binding.post);
let rawSamlResponse;
let rawSamlResponse: string;
const nowTime = new Date();
const spEntityID = metadata.sp.getEntityID();
const fiveMinutesLaterTime = new Date(nowTime.getTime());
Expand All @@ -109,13 +109,13 @@ async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any
SubjectConfirmationDataNotOnOrAfter: fiveMinutesLater,
NameIDFormat: namespace.format[idpSetting.logoutNameIDFormat] || namespace.format.emailAddress,
NameID: user.email || '',
InResponseTo: get<string>(requestInfo, 'extract.authnrequest.id') || '',
InResponseTo: get(requestInfo, 'extract.authnrequest.id') || '',
AuthnStatement: '',
AttributeStatement: '',
};
if (idpSetting.loginResponseTemplate) {
const template = customTagReplacement(idpSetting.loginResponseTemplate.context);
rawSamlResponse = get<string>(template, 'context');
rawSamlResponse = get<BindingContext, keyof BindingContext>(template, 'context');
} else {
if (requestInfo !== null) {
tvalue.InResponseTo = requestInfo.extract.authnrequest.id;
Expand Down Expand Up @@ -161,7 +161,7 @@ async function base64LoginResponse(requestInfo: any = {}, entity: any, user: any
const context = await libsaml.encryptAssertion(entity.idp, entity.sp, rawSamlResponse);
if (encryptThenSign) {
//need to decode it
rawSamlResponse = utility.base64Decode(context);
rawSamlResponse = utility.base64Decode(context) as string;
} else {
return Promise.resolve({ id, context });
}
Expand Down Expand Up @@ -201,11 +201,11 @@ function base64LogoutRequest(user, referenceTagXPath, entity, customTagReplaceme
const initSetting = entity.init.entitySetting;
let id: string = '';
if (metadata && metadata.init && metadata.target) {
let rawSamlRequest;
let rawSamlRequest: string;
if (initSetting.logoutRequestTemplate) {
const template = customTagReplacement(initSetting.logoutRequestTemplate.context);
id = get<string>(template, 'id');
rawSamlRequest = get<string>(template, 'context');
id = get<BindingContext, keyof BindingContext>(template, 'id');
rawSamlRequest = get<BindingContext, keyof BindingContext>(template, 'context');
} else {
id = initSetting.generateID();
const tvalue: any = {
Expand Down
16 changes: 8 additions & 8 deletions src/binding-redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function buildRedirectURL(opts: BuildRedirectConfig) {
context,
entitySetting,
} = opts;
let {relayState = '' } = opts;
let { relayState = '' } = opts;
const noParams = (url.parse(baseUrl).query || []).length === 0;
const queryParam = libsaml.getQueryParamByType(type);
// In general, this xmlstring is required to do deflate -> base64 -> urlencode
Expand Down Expand Up @@ -85,8 +85,8 @@ function loginRequestRedirectURL(entity: { idp: Idp, sp: Sp }, customTagReplacem
let rawSamlRequest: string;
if (spSetting.loginRequestTemplate) {
const info = customTagReplacement(spSetting.loginRequestTemplate);
id = get<string>(info, 'id');
rawSamlRequest = get<string>(info, 'context');
id = get<BindingContext, keyof BindingContext>(info, 'id');
rawSamlRequest = get<BindingContext, keyof BindingContext>(info, 'context');
} else {
id = spSetting.generateID();
rawSamlRequest = libsaml.replaceTagsByValue(libsaml.defaultLoginRequestTemplate.context, {
Expand Down Expand Up @@ -130,8 +130,8 @@ function logoutRequestRedirectURL(user, entity, relayState?: string, customTagRe
let rawSamlRequest: string = '';
if (initSetting.logoutRequestTemplate) {
const info = customTagReplacement(initSetting.logoutRequestTemplate);
id = get<string>(info, 'id');
rawSamlRequest = get<string>(info, 'context');
id = get<BindingContext, keyof BindingContext>(info, 'id');
rawSamlRequest = get<BindingContext, keyof BindingContext>(info, 'context');
} else {
id = initSetting.generateID();
rawSamlRequest = libsaml.replaceTagsByValue(libsaml.defaultLogoutRequestTemplate.context, {
Expand Down Expand Up @@ -174,12 +174,12 @@ function logoutResponseRedirectURL(requestInfo: any, entity: any, relayState?: s
const initSetting = entity.init.entitySetting;
if (metadata && metadata.init && metadata.target) {
const base = metadata.target.getSingleLogoutService(binding.redirect);
let rawSamlResponse;
let rawSamlResponse: string;

if (initSetting.logoutResponseTemplate) {
const template = customTagReplacement(initSetting.logoutResponseTemplate);
id = get<string>(template, 'id');
rawSamlResponse = get<string>(template, 'context');
id = get<BindingContext, keyof BindingContext>(template, 'id');
rawSamlResponse = get<BindingContext, keyof BindingContext>(template, 'context');
} else {
id = initSetting.generateID();
const tvalue: any = {
Expand Down

0 comments on commit 6155248

Please sign in to comment.