Skip to content

grupo-a/lti-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ A Launch LTI (Learning Tools Interoperability)


In your package.json > dependencies:

  "lti-node": "git+https://github.com/grupo-a/lti-node.git#<TAG_VERSION>"

You need to change <TAG_VERSION>. See all tags clicking here.


The Launch LTI is implemented following the specification: http://www.imsglobal.org/specs/ltiv1p1/implementation-guide.

If the parameters (oauth_timestamp, oauth_signature_method, oauth_nonce, oauth_version, oauth_callback, lti_message_type, lti_version) are null, they will be generated automatically.

It's a function used to generate the oauth_signature field of the LTI protocol.

Example:

    const { launchV1 } = require('lti-node');

    const launchData = {
        user_id                                : 'test',
        roles                                  : 'urn:lti:role:ims/lis/Instructor',
        context_label                          : 'Discipline Test',
        context_title                          : 'Discipline Test',
        context_id                             : '1',
        resource_link_id                       : '1',
        resource_link_title                    : 'Link Test',
        lis_person_name_full                   : 'ABC',
        lis_person_name_family                 : 'ABC',
        lis_person_name_given                  : 'ABC',
        lis_person_contact_email_primary       : 'abc@grupoa.com.br',
        lis_person_sourcedid                   : 'abc',
        tool_consumer_instance_guid            : 'grupoa.com.br',
        tool_consumer_info_product_family_code : 'Plataforma'
    };

    const url = 'https://grupoa.com.br/lti?param=1&param=2';
    const consumerKey = 'test';
    const secretKey = '@@123@@';
  
    const signature = launchV1.buildSignature(url, launchData, consumerKey, secretKey);

It's a function used to generate the oauth_signature field of the LTI protocol. It also returns all fields required for building the LTI initialization form.

Example:

    const { launchV1 } = require('lti-node');

    const launchData = {
        user_id                                : 'test',
        roles                                  : 'urn:lti:role:ims/lis/Instructor',
        context_label                          : 'Discipline Test',
        context_title                          : 'Discipline Test',
        context_id                             : '1',
        resource_link_id                       : '1',
        resource_link_title                    : 'Link Test',
        lis_person_name_full                   : 'ABC',
        lis_person_name_family                 : 'ABC',
        lis_person_name_given                  : 'ABC',
        lis_person_contact_email_primary       : 'abc@grupoa.com.br',
        lis_person_sourcedid                   : 'abc',
        tool_consumer_instance_guid            : 'grupoa.com.br',
        tool_consumer_info_product_family_code : 'Plataforma'
    };

    const url = 'https://grupoa.com.br/lti?param=1&param=2';
    const consumerKey = 'test';
    const secretKey = '@@123@@';
  
    const launchFormaData = launchV1.buildForm(url, launchData, consumerKey, secretKey);

Return:

    {
        action: 'https://grupoa.com.br/lti?param=1&param=2',
        properties: {
            user_id: 'test',
            roles: 'urn:lti:role:ims/lis/Instructor',
            context_label: 'Discipline Test',
            context_title: 'Discipline Test',
            context_id: '1',
            resource_link_id: '1',
            resource_link_title: 'Link Test',
            lis_person_name_full: 'ABC',
            lis_person_name_family: 'ABC',
            lis_person_name_given: 'ABC',
            lis_person_contact_email_primary: 'abc@grupoa.com.br',
            lis_person_sourcedid: 'abc',
            tool_consumer_instance_guid: 'grupoa.com.br',
            tool_consumer_info_product_family_code: 'Plataforma',
            oauth_consumer_key: 'test',
            lti_version: 'LTI-1p0',
            lti_message_type: 'basic-lti-launch-request',
            oauth_callback: 'about:blank',
            oauth_version: '1.0',
            oauth_nonce: 161184495424800,
            oauth_signature_method: 'HMAC-SHA1',
            oauth_timestamp: 1611844954,
            oauth_signature: 'KomlyEQCWk/zy6Mljiunk0BhZug='
        }
    }

The Outcome Service LTI is implemented following the specification: https://www.imsglobal.org/spec/lti-bo/v1p1.

It's a function used to check if the oauth_signature field of the LTI protocol is valid.

Example:

    const { outcomeV1 } = require('lti-node');

    const url = 'https://grupoa.com.br.outcome';
    const header = 'oauth_consumer_key=12345678, oauth_signature_method=HMAC-SHA1,oauth_timestamp=1627929009,oauth_nonce=d7d5d9a6278815d1c09f4e558b9a8272,oauth_version=1.0,oauth_signature=iHwxH4busDQpEAru0eWwwa2Mmdg%3D';
    const secretKey = 'secret';
  
    const signature = outcomeV1.checkIsSignatureValid(url, body, secretKey);

Return:

  true

It's a function used to build an result response according to the type of request (read, replace, delete).

Example:

    const { outcomeV1 } = require('lti-node');

    const readResult = outcomeV1.buildResponse({
        requestType : 'read',
        status      : 'success',
        resultScore : '0.9'
    });

Return:

    <?xml version="1.0" encoding="UTF-8"?>
    <imsx_POXEnvelopeResponse xmlns="http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0">
    <imsx_POXHeader>
      <imsx_POXResponseHeaderInfo>
        <imsx_version>V1.0</imsx_version>
        <imsx_messageIdentifier>162810903930706</imsx_messageIdentifier>
        <imsx_statusInfo>
          <imsx_codeMajor>success</imsx_codeMajor>
          <imsx_severity>status</imsx_severity>
          <imsx_description>Result read</imsx_description>
          <imsx_messageRefIdentifier>162810903930707</imsx_messageRefIdentifier>
          <imsx_operationRefIdentifier>readResult</imsx_operationRefIdentifier>
        </imsx_statusInfo>
      </imsx_POXResponseHeaderInfo>
    </imsx_POXHeader>
    <imsx_POXBody>
      <readResultResponse>
        <result>
          <resultScore>
            <language>en</language>
            <textString>0.9</textString>
          </resultScore>
        </result>
      </readResultResponse>
    </imsx_POXBody>
    </imsx_POXEnvelopeResponse>

🚧 Open for contribuitions... 🚧

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published