bugfix: must call atob/btoa from window context
This commit is contained in:
parent
8710a751ed
commit
7a3d5777e0
|
@ -16,6 +16,8 @@
|
||||||
}
|
}
|
||||||
, _base64: {
|
, _base64: {
|
||||||
atob: function (base64) {
|
atob: function (base64) {
|
||||||
|
// atob must be called from the global context
|
||||||
|
// http://stackoverflow.com/questions/9677985/uncaught-typeerror-illegal-invocation-in-chrome
|
||||||
return (exports.atob || require('atob'))(base64);
|
return (exports.atob || require('atob'))(base64);
|
||||||
}
|
}
|
||||||
, decodeUrlSafe: function (b64) {
|
, decodeUrlSafe: function (b64) {
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
|
|
||||||
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.implicit.js').OAUTH3;
|
var OAUTH3 = exports.OAUTH3 = exports.OAUTH3 || require('./oauth3.implicit.js').OAUTH3;
|
||||||
|
|
||||||
OAUTH3._base64.btoa = exports.btoa || require('btoa');
|
OAUTH3._base64.btoa = function (b64) {
|
||||||
|
// http://stackoverflow.com/questions/9677985/uncaught-typeerror-illegal-invocation-in-chrome
|
||||||
|
(exports.btoa || require('btoa'))(b64);
|
||||||
|
}
|
||||||
OAUTH3._base64.encodeUrlSafe = function (b64) {
|
OAUTH3._base64.encodeUrlSafe = function (b64) {
|
||||||
// Base64 to URL-safe Base64
|
// Base64 to URL-safe Base64
|
||||||
b64 = b64.replace(/\+/g, '-').replace(/\//g, '_');
|
b64 = b64.replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
|
|
Loading…
Reference in New Issue