node-jose
Version:
A JavaScript implementation of the JSON Object Signing and Encryption (JOSE) for current web browsers and node.js-based servers
26 lines (22 loc) • 599 B
JavaScript
/*!
* parse/index.js - JOSE Parser Entry Point
*
* Copyright (c) 2015 Cisco Systems, Inc. See LICENSE file.
*/
;
var compact = require("./compact"),
json = require("./json");
var parse = module.exports = function(input) {
if (Buffer.isBuffer(input)) {
// assume buffer holds a Compact Serialization string
return compact(input.toString("ascii"));
} else if ("string" === typeof input) {
return compact(input);
} else if (input) {
return json(input);
} else {
throw new TypeError("invalid input");
}
};
parse.compact = compact;
parse.json = json;