smartstring/dist/smartstring.base64.js

60 lines
3.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartstring.plugins");
/**
* handle base64 strings
*/
class Base64 {
constructor(inputStringArg, typeArg) {
switch (typeArg) {
case 'string':// easiest case
this.refString = inputStringArg;
break;
case 'base64':
this.refString = exports.base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = exports.base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return exports.base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64UriString() {
return exports.base64.encodeUri(this.refString);
}
}
exports.Base64 = Base64;
exports.base64 = {
/**
* encodes the string
*/
encode: (stringArg) => {
return plugins.jsBase64.encode(stringArg);
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg) => {
return plugins.jsBase64.encodeURI(stringArg);
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg) => {
return plugins.jsBase64.decode(stringArg);
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJpbmcuYmFzZTY0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzdHJpbmcuYmFzZTY0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsaURBQWdEO0FBT2hEOztHQUVHO0FBQ0g7SUFFRSxZQUFZLGNBQWMsRUFBRSxPQUFxQjtRQUMvQyxNQUFNLENBQUMsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLEtBQUssUUFBUSxDQUFFLGVBQWU7Z0JBQzVCLElBQUksQ0FBQyxTQUFTLEdBQUcsY0FBYyxDQUFBO2dCQUMvQixLQUFLLENBQUE7WUFDUCxLQUFLLFFBQVE7Z0JBQ1gsSUFBSSxDQUFDLFNBQVMsR0FBRyxjQUF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