base64 shim

This commit is contained in:
Mark Nadal 2019-09-16 12:36:18 -07:00
parent 89578efd68
commit 4fb04b8f53
3 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "gun", "name": "gun",
"version": "0.2019.910", "version": "0.2019.915",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.", "description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js", "main": "index.js",
"browser": "gun.js", "browser": "gun.js",

17
sea.js
View File

@ -17,13 +17,6 @@
} }
if(typeof module !== "undefined"){ var common = module } if(typeof module !== "undefined"){ var common = module }
/* UNBUILD */ /* UNBUILD */
function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
function btoa(b) {
return new Buffer(b).toString('base64');
};
;USE(function(module){ ;USE(function(module){
// Security, Encryption, and Authorization: SEA.js // Security, Encryption, and Authorization: SEA.js
@ -54,6 +47,15 @@
})(USE, './https'); })(USE, './https');
;USE(function(module){ ;USE(function(module){
if(typeof global !== "undefined"){
var g = global;
g.btoa = function (data) { return Buffer.from(data, "binary").toString("base64"); };
g.atob = function (data) { return Buffer.from(data, "base64").toString("binary"); };
}
})(USE, './base64');
;USE(function(module){
USE('./base64');
// This is Array extended to have .toString(['utf8'|'hex'|'base64']) // This is Array extended to have .toString(['utf8'|'hex'|'base64'])
function SeaArray() {} function SeaArray() {}
Object.assign(SeaArray, { from: Array.from }) Object.assign(SeaArray, { from: Array.from })
@ -79,6 +81,7 @@
})(USE, './array'); })(USE, './array');
;USE(function(module){ ;USE(function(module){
USE('./base64');
// This is Buffer implementation used in SEA. Functionality is mostly // This is Buffer implementation used in SEA. Functionality is mostly
// compatible with NodeJS 'safe-buffer' and is used for encoding conversions // compatible with NodeJS 'safe-buffer' and is used for encoding conversions
// between binary and 'hex' | 'utf8' | 'base64' // between binary and 'hex' | 'utf8' | 'base64'

View File

@ -1,8 +1,5 @@
var root; var root;
var Gun; var Gun;
function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
(function(){ (function(){
var env; var env;
if(typeof global !== 'undefined'){ env = global } if(typeof global !== 'undefined'){ env = global }