Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need access to original statement from HTTP response #144

Open
mhailstone opened this issue Sep 18, 2017 · 3 comments
Open

Need access to original statement from HTTP response #144

mhailstone opened this issue Sep 18, 2017 · 3 comments

Comments

@mhailstone
Copy link

I am creating/consuming signed statements. I would like to be able to get at the original string of the statement in a multi-part response. In LRS.js line 237, you could pass parameters to indicate you would like to keep the original statement object (minus the content attribute in the attachment). Or you could assign the originalJSON to JSON.parse(parsedResponse[0].body) after you created the statement. Either way, is there a reason not to set the original string of the statement from the response? I'm wanting it so I can verify/validate the JWS in the attachment, and then provide that to another LRS (exporting it so to speak). Thoughts on this export process that would be better?

@mhailstone
Copy link
Author

I think I just saw the answer to this in another issue. I should be using the statement.asVersion("1.0.0") method (for example) to get the statement.

@brianjmiller
Copy link
Member

I don't know of one, but having said that you shouldn't need it to accomplish your goal. You can access the individual objects themselves, or as you've found use the serialized versions via the asVersion methods. Verifying the JWS has to go beyond regular string comparison as JSON isn't ordered, and there are properties that can be ignored because they don't pertain to the statement's semantics.

@mhailstone
Copy link
Author

mhailstone commented Sep 20, 2017

@brianjmiller Thanks for the response. The use case I'm trying to address is to export xAPI statements either to another LRS, or provide the signed statement standalone. I could use the TinCanJS module to connect to and save in a different LRS, but if I wanted to save the signed statement standalone in some other long term storage strategy, would the raw multi-part response work in your opinion? Here is an example:

Content-Length:1886
Content-Type:application/json; charset=UTF-8

{"id":"7a3940c1-6d66-4328-9ad3-0d5b2b077f66","actor":{"objectType":"Agent","account":{"homePage":"http://byu.edu/","name":"123456789"}},"verb":{"id":"http://byu.edu/expapi/verbs/completed","display":{"en-US":"completed"}},"result":{"extensions":{"http://byu.edu/expapi/extensions/grade":"A-"}},"context":{"contextActivities":{"category":[{"id":"http://byu.edu/expapi/ces","objectType":"Activity"}]}},"timestamp":"2017-09-18T20:46:08.076Z","stored":"2017-09-18T20:46:08.547Z","authority":{"objectType":"Agent","mbox":"mailto:matthew_hailstone@byu.edu","name":"Matthew Hailstone"},"version":"1.0.0","attachments":[{"usageType":"http://adlnet.gov/expapi/attachments/signature","display":{"en-US":"Signature"},"description":{"en-US":"Course Completed Signature"},"contentType":"application/octet-stream","length":4661,"sha2":"071af7ed9305009d3bbf2b5fffc1eadfc4730a611554595fad3f205c27597eb5"}],"object":{"id":"http://api.byu.edu/classes/20175,06387,001,001","definition":{"extensions":{"http://byu.edu/expapi/extensions/title_code":"001","http://byu.edu/expapi/extensions/section_number":"001","http://byu.edu/expapi/extensions/course_title":"College Algebra","http://byu.edu/expapi/extensions/section_type":"DAY","http://byu.edu/expapi/extensions/year_term":"20175","http://byu.edu/expapi/extensions/instructors":[{"id":"123456789","name":"Billy Jones","type":"Primary"}],"http://byu.edu/expapi/extensions/subject_area":"MATH","http://byu.edu/expapi/extensions/audit":false,"http://byu.edu/expapi/extensions/credit_hours":3,"http://byu.edu/expapi/extensions/catalog_number":"110","http://byu.edu/expapi/extensions/curriculum_id":"06387","http://byu.edu/expapi/extensions/institution":"BYU","http://byu.edu/expapi/extensions/catalog_suffix":""},"name":{"en-US":"MATH 110"},"description":{"en-US":"College Algebra"},"type":"http://byu.edu/expapi/activities/course"},"objectType":"Activity"}}
--e17395ece693460f8f9d9cd7e2aaf06f
X-Experience-API-Hash:071af7ed9305009d3bbf2b5fffc1eadfc4730a611554595fad3f205c27597eb5
Content-Transfer-Encoding:binary
Content-Length:4661
Content-Type:application/octet-stream

eyJhbGciOiJSUzI1NiIsIng1YyI6WyJNSUlGTURDQ0JCaWdBd0lCQWdJSkFQMXhvenBra1Ixb01BMEdDU3FHU0liM0RRRUJDd1VBTUlIQU1Rc3dDUVlEVlFRR0V3SlZVekVOTUFzR0ExVUVDQk1FVlhSaGFERU9NQXdHQTFVRUJ4TUZVSEp2ZG04eElUQWZCZ05WQkFvVEdFSnlhV2RvWVcwZ1dXOTF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aLCb1TKLYqG1jIvYmvNC9BiK-s-d2TjrJMH0rn54dlCTjoR7Gxk2q6z-fN-vJ9lDjb-nXFdPqzOxPvyRMuDYOJXA-v3FhLPfs_HIMvixOYD2kbc46z7JJwixYTT6NAM3oTGYxwHIcfWdtF8MRw0Ofh6hbyTaPbglVWvg3ek9qCXLh8k7TRPGgEENe8ADAmSIAf53xaPtWXRj7R36iN_m7ABm3V5YLezUkPThSQ
--e17395ece693460f8f9d9cd7e2aaf06f--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants