Commit 339c23a6 authored by Ray Schamp's avatar Ray Schamp

Add some sources to the unsign method

parent 21dffa73
...@@ -12,7 +12,9 @@ var pako = require('pako'); ...@@ -12,7 +12,9 @@ var pako = require('pako');
*/ */
var Jar = { var Jar = {
unsign: function (value, callback) { unsign: function (value, callback) {
// Return the usable content portion of a signed, compressed cookie // Return the usable content portion of a signed, compressed cookie generated by
// Django's signing module
// https://github.com/django/django/blob/stable/1.8.x/django/core/signing.py
if (!value) return callback('No value to unsign'); if (!value) return callback('No value to unsign');
try { try {
var b64Data = value.split(':')[0]; var b64Data = value.split(':')[0];
...@@ -23,6 +25,8 @@ var Jar = { ...@@ -23,6 +25,8 @@ var Jar = {
} }
// Django makes its base64 strings url safe by replacing + and / with - and _ respectively // Django makes its base64 strings url safe by replacing + and / with - and _ respectively
// using base64.urlsafe_b64encode
// https://docs.python.org/2/library/base64.html#base64.b64encode
b64Data = b64Data.replace(/[-_]/g, function (c) {return {'-':'+', '_':'/'}[c]; }); b64Data = b64Data.replace(/[-_]/g, function (c) {return {'-':'+', '_':'/'}[c]; });
var strData = atob(b64Data); var strData = atob(b64Data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment