in lti-components/web/amplify/backend/function/chimeLtiApiAuth/src/utils/LTIMessage.js [56:100]
constructor(token, platformConfig) {
this.__token = token;
this.__platformConfig = platformConfig;
this.__deploymentId = token[`https://purl.imsglobal.org/spec/lti/claim/deployment_id`] || ``;
this.__clientId = token[`aud`] || ``;
this.__resourceId = (token[`https://purl.imsglobal.org/spec/lti/claim/resource_link`] || {}).id || ``;
const context = token[`https://purl.imsglobal.org/spec/lti/claim/context`] || {};
// ensure deployment-wide uniqueness of resource id
const contextId = crypto.createHash(`md5`).update(`${this.__platformConfig.platformId}:${this.__deploymentId}:${context.id}:${this.__resourceId}`).digest(`hex`);
// according to https://www.imsglobal.org/spec/lti/v1p3/#context-claim
this.__context = {
title: ``,
label: ``,
type: [],
...context,
id: contextId,
externalId: context.id
};
// ensure platform-wide uniqueness of user id
const userId = crypto.createHash(`md5`).update(`${this.__platformConfig.platformId}:${token.sub}`).digest(`hex`);
// according to https://www.imsglobal.org/spec/lti/v1p3/#user-identity-claims
this.__user = {
id: userId,
name: token.name || (`${token.givenName || ``} ${token.family_name || ``}`),
email: token.email
};
// according to http://www.imsglobal.org/spec/lti/v1p3/#launch-presentation-claim
this.__launchPresentation = Object.assign({
document_target: ``,
return_url: ``,
}, token[`https://purl.imsglobal.org/spec/lti/claim/launch_presentation`] || {});
// resolving https://www.imsglobal.org/spec/lti/v1p3/#role-vocabularies
const ltiRoles = token[`https://purl.imsglobal.org/spec/lti/claim/roles`] || [];
this.__roles = ltiRoleMap.resolveRoles(...ltiRoles).map((role) => role.name);
this.__highestPrivilegeRole = (ltiRoleMap.resolveToMostPrivilegedRole(...ltiRoles) || {}).name;
this.__issuer = token[`iss`];
}