wallaby-cash 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/dist/base.d.ts +10 -0
  4. package/dist/helpers/logger.d.ts +2 -0
  5. package/dist/index.d.ts +45 -0
  6. package/dist/index.esm.js +2 -0
  7. package/dist/index.esm.js.map +1 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.umd.js +2 -0
  11. package/dist/index.umd.js.map +1 -0
  12. package/dist/lib/auth/index.d.ts +54 -0
  13. package/dist/lib/index.d.ts +3 -0
  14. package/dist/lib/system/index.d.ts +32 -0
  15. package/dist/lib/transactions/index.d.ts +80 -0
  16. package/dist/lib/utils/index.d.ts +21 -0
  17. package/dist/lib/utils/utils.d.ts +68 -0
  18. package/dist/lib/wallet/index.d.ts +99 -0
  19. package/dist/localStorageMock.d.ts +7 -0
  20. package/dist/routes/auth.d.ts +33 -0
  21. package/dist/routes/index.d.ts +3 -0
  22. package/dist/routes/system.d.ts +23 -0
  23. package/dist/routes/transactions.d.ts +28 -0
  24. package/dist/routes/wallet.d.ts +53 -0
  25. package/dist/tests/data/auth.d.ts +11 -0
  26. package/dist/tests/data/config.d.ts +6 -0
  27. package/dist/tests/data/index.d.ts +4 -0
  28. package/dist/tests/data/system.d.ts +47 -0
  29. package/dist/tests/data/user.d.ts +20 -0
  30. package/dist/types/auth.d.ts +48 -0
  31. package/dist/types/common.d.ts +206 -0
  32. package/dist/types/index.d.ts +5 -0
  33. package/dist/types/merchants.d.ts +43 -0
  34. package/dist/types/transactions.d.ts +127 -0
  35. package/dist/types/wallet.d.ts +123 -0
  36. package/package.json +90 -0
  37. package/src/base.ts +95 -0
  38. package/src/helpers/logger.ts +11 -0
  39. package/src/index.ts +58 -0
  40. package/src/lib/auth/index.ts +225 -0
  41. package/src/lib/index.ts +3 -0
  42. package/src/lib/system/index.ts +104 -0
  43. package/src/lib/transactions/index.ts +259 -0
  44. package/src/lib/utils/index.ts +80 -0
  45. package/src/lib/utils/utils.ts +224 -0
  46. package/src/lib/wallet/index.ts +515 -0
  47. package/src/localStorageMock.js +23 -0
  48. package/src/routes/auth.ts +34 -0
  49. package/src/routes/index.ts +3 -0
  50. package/src/routes/system.ts +24 -0
  51. package/src/routes/transactions.ts +29 -0
  52. package/src/routes/wallet.ts +65 -0
  53. package/src/tests/__mocks__/axios.js +4 -0
  54. package/src/tests/__mocks__/localStorageMock.js +23 -0
  55. package/src/tests/auth.spec.ts +117 -0
  56. package/src/tests/data/auth.ts +49 -0
  57. package/src/tests/data/config.ts +8 -0
  58. package/src/tests/data/index.ts +4 -0
  59. package/src/tests/data/system.ts +54 -0
  60. package/src/tests/data/user.ts +25 -0
  61. package/src/tests/system.spec.ts +47 -0
  62. package/src/tests/utils.spec.ts +70 -0
  63. package/src/tests/wallet.spec.ts +44 -0
  64. package/src/types/auth.ts +57 -0
  65. package/src/types/common.ts +230 -0
  66. package/src/types/index.ts +5 -0
  67. package/src/types/merchants.ts +47 -0
  68. package/src/types/transactions.ts +139 -0
  69. package/src/types/wallet.ts +141 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/uuid/dist/esm-browser/rng.js","../node_modules/uuid/dist/esm-browser/stringify.js","../node_modules/uuid/dist/esm-browser/native.js","../node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["/**\n * Helpers.\n */\n\nvar s = 1000;\nvar m = s * 60;\nvar h = m * 60;\nvar d = h * 24;\nvar w = d * 7;\nvar y = d * 365.25;\n\n/**\n * Parse or format the given `val`.\n *\n * Options:\n *\n * - `long` verbose formatting [false]\n *\n * @param {String|Number} val\n * @param {Object} [options]\n * @throws {Error} throw an error if val is not a non-empty string or a number\n * @return {String|Number}\n * @api public\n */\n\nmodule.exports = function(val, options) {\n options = options || {};\n var type = typeof val;\n if (type === 'string' && val.length > 0) {\n return parse(val);\n } else if (type === 'number' && isFinite(val)) {\n return options.long ? fmtLong(val) : fmtShort(val);\n }\n throw new Error(\n 'val is not a non-empty string or a valid number. val=' +\n JSON.stringify(val)\n );\n};\n\n/**\n * Parse the given `str` and return milliseconds.\n *\n * @param {String} str\n * @return {Number}\n * @api private\n */\n\nfunction parse(str) {\n str = String(str);\n if (str.length > 100) {\n return;\n }\n var match = /^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(\n str\n );\n if (!match) {\n return;\n }\n var n = parseFloat(match[1]);\n var type = (match[2] || 'ms').toLowerCase();\n switch (type) {\n case 'years':\n case 'year':\n case 'yrs':\n case 'yr':\n case 'y':\n return n * y;\n case 'weeks':\n case 'week':\n case 'w':\n return n * w;\n case 'days':\n case 'day':\n case 'd':\n return n * d;\n case 'hours':\n case 'hour':\n case 'hrs':\n case 'hr':\n case 'h':\n return n * h;\n case 'minutes':\n case 'minute':\n case 'mins':\n case 'min':\n case 'm':\n return n * m;\n case 'seconds':\n case 'second':\n case 'secs':\n case 'sec':\n case 's':\n return n * s;\n case 'milliseconds':\n case 'millisecond':\n case 'msecs':\n case 'msec':\n case 'ms':\n return n;\n default:\n return undefined;\n }\n}\n\n/**\n * Short format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtShort(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return Math.round(ms / d) + 'd';\n }\n if (msAbs >= h) {\n return Math.round(ms / h) + 'h';\n }\n if (msAbs >= m) {\n return Math.round(ms / m) + 'm';\n }\n if (msAbs >= s) {\n return Math.round(ms / s) + 's';\n }\n return ms + 'ms';\n}\n\n/**\n * Long format for `ms`.\n *\n * @param {Number} ms\n * @return {String}\n * @api private\n */\n\nfunction fmtLong(ms) {\n var msAbs = Math.abs(ms);\n if (msAbs >= d) {\n return plural(ms, msAbs, d, 'day');\n }\n if (msAbs >= h) {\n return plural(ms, msAbs, h, 'hour');\n }\n if (msAbs >= m) {\n return plural(ms, msAbs, m, 'minute');\n }\n if (msAbs >= s) {\n return plural(ms, msAbs, s, 'second');\n }\n return ms + ' ms';\n}\n\n/**\n * Pluralization helper.\n */\n\nfunction plural(ms, msAbs, n, name) {\n var isPlural = msAbs >= n * 1.5;\n return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');\n}\n","\n/**\n * This is the common logic for both the Node.js and web browser\n * implementations of `debug()`.\n */\n\nfunction setup(env) {\n\tcreateDebug.debug = createDebug;\n\tcreateDebug.default = createDebug;\n\tcreateDebug.coerce = coerce;\n\tcreateDebug.disable = disable;\n\tcreateDebug.enable = enable;\n\tcreateDebug.enabled = enabled;\n\tcreateDebug.humanize = require('ms');\n\tcreateDebug.destroy = destroy;\n\n\tObject.keys(env).forEach(key => {\n\t\tcreateDebug[key] = env[key];\n\t});\n\n\t/**\n\t* The currently active debug mode names, and names to skip.\n\t*/\n\n\tcreateDebug.names = [];\n\tcreateDebug.skips = [];\n\n\t/**\n\t* Map of special \"%n\" handling functions, for the debug \"format\" argument.\n\t*\n\t* Valid key names are a single, lower or upper-case letter, i.e. \"n\" and \"N\".\n\t*/\n\tcreateDebug.formatters = {};\n\n\t/**\n\t* Selects a color for a debug namespace\n\t* @param {String} namespace The namespace string for the debug instance to be colored\n\t* @return {Number|String} An ANSI color code for the given namespace\n\t* @api private\n\t*/\n\tfunction selectColor(namespace) {\n\t\tlet hash = 0;\n\n\t\tfor (let i = 0; i < namespace.length; i++) {\n\t\t\thash = ((hash << 5) - hash) + namespace.charCodeAt(i);\n\t\t\thash |= 0; // Convert to 32bit integer\n\t\t}\n\n\t\treturn createDebug.colors[Math.abs(hash) % createDebug.colors.length];\n\t}\n\tcreateDebug.selectColor = selectColor;\n\n\t/**\n\t* Create a debugger with the given `namespace`.\n\t*\n\t* @param {String} namespace\n\t* @return {Function}\n\t* @api public\n\t*/\n\tfunction createDebug(namespace) {\n\t\tlet prevTime;\n\t\tlet enableOverride = null;\n\t\tlet namespacesCache;\n\t\tlet enabledCache;\n\n\t\tfunction debug(...args) {\n\t\t\t// Disabled?\n\t\t\tif (!debug.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst self = debug;\n\n\t\t\t// Set `diff` timestamp\n\t\t\tconst curr = Number(new Date());\n\t\t\tconst ms = curr - (prevTime || curr);\n\t\t\tself.diff = ms;\n\t\t\tself.prev = prevTime;\n\t\t\tself.curr = curr;\n\t\t\tprevTime = curr;\n\n\t\t\targs[0] = createDebug.coerce(args[0]);\n\n\t\t\tif (typeof args[0] !== 'string') {\n\t\t\t\t// Anything else let's inspect with %O\n\t\t\t\targs.unshift('%O');\n\t\t\t}\n\n\t\t\t// Apply any `formatters` transformations\n\t\t\tlet index = 0;\n\t\t\targs[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {\n\t\t\t\t// If we encounter an escaped % then don't increase the array index\n\t\t\t\tif (match === '%%') {\n\t\t\t\t\treturn '%';\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\tconst formatter = createDebug.formatters[format];\n\t\t\t\tif (typeof formatter === 'function') {\n\t\t\t\t\tconst val = args[index];\n\t\t\t\t\tmatch = formatter.call(self, val);\n\n\t\t\t\t\t// Now we need to remove `args[index]` since it's inlined in the `format`\n\t\t\t\t\targs.splice(index, 1);\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t\treturn match;\n\t\t\t});\n\n\t\t\t// Apply env-specific formatting (colors, etc.)\n\t\t\tcreateDebug.formatArgs.call(self, args);\n\n\t\t\tconst logFn = self.log || createDebug.log;\n\t\t\tlogFn.apply(self, args);\n\t\t}\n\n\t\tdebug.namespace = namespace;\n\t\tdebug.useColors = createDebug.useColors();\n\t\tdebug.color = createDebug.selectColor(namespace);\n\t\tdebug.extend = extend;\n\t\tdebug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.\n\n\t\tObject.defineProperty(debug, 'enabled', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t\tget: () => {\n\t\t\t\tif (enableOverride !== null) {\n\t\t\t\t\treturn enableOverride;\n\t\t\t\t}\n\t\t\t\tif (namespacesCache !== createDebug.namespaces) {\n\t\t\t\t\tnamespacesCache = createDebug.namespaces;\n\t\t\t\t\tenabledCache = createDebug.enabled(namespace);\n\t\t\t\t}\n\n\t\t\t\treturn enabledCache;\n\t\t\t},\n\t\t\tset: v => {\n\t\t\t\tenableOverride = v;\n\t\t\t}\n\t\t});\n\n\t\t// Env-specific initialization logic for debug instances\n\t\tif (typeof createDebug.init === 'function') {\n\t\t\tcreateDebug.init(debug);\n\t\t}\n\n\t\treturn debug;\n\t}\n\n\tfunction extend(namespace, delimiter) {\n\t\tconst newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);\n\t\tnewDebug.log = this.log;\n\t\treturn newDebug;\n\t}\n\n\t/**\n\t* Enables a debug mode by namespaces. This can include modes\n\t* separated by a colon and wildcards.\n\t*\n\t* @param {String} namespaces\n\t* @api public\n\t*/\n\tfunction enable(namespaces) {\n\t\tcreateDebug.save(namespaces);\n\t\tcreateDebug.namespaces = namespaces;\n\n\t\tcreateDebug.names = [];\n\t\tcreateDebug.skips = [];\n\n\t\tlet i;\n\t\tconst split = (typeof namespaces === 'string' ? namespaces : '').split(/[\\s,]+/);\n\t\tconst len = split.length;\n\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tif (!split[i]) {\n\t\t\t\t// ignore empty strings\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tnamespaces = split[i].replace(/\\*/g, '.*?');\n\n\t\t\tif (namespaces[0] === '-') {\n\t\t\t\tcreateDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));\n\t\t\t} else {\n\t\t\t\tcreateDebug.names.push(new RegExp('^' + namespaces + '$'));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t* Disable debug output.\n\t*\n\t* @return {String} namespaces\n\t* @api public\n\t*/\n\tfunction disable() {\n\t\tconst namespaces = [\n\t\t\t...createDebug.names.map(toNamespace),\n\t\t\t...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)\n\t\t].join(',');\n\t\tcreateDebug.enable('');\n\t\treturn namespaces;\n\t}\n\n\t/**\n\t* Returns true if the given mode name is enabled, false otherwise.\n\t*\n\t* @param {String} name\n\t* @return {Boolean}\n\t* @api public\n\t*/\n\tfunction enabled(name) {\n\t\tif (name[name.length - 1] === '*') {\n\t\t\treturn true;\n\t\t}\n\n\t\tlet i;\n\t\tlet len;\n\n\t\tfor (i = 0, len = createDebug.skips.length; i < len; i++) {\n\t\t\tif (createDebug.skips[i].test(name)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = createDebug.names.length; i < len; i++) {\n\t\t\tif (createDebug.names[i].test(name)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t* Convert regexp to namespace\n\t*\n\t* @param {RegExp} regxep\n\t* @return {String} namespace\n\t* @api private\n\t*/\n\tfunction toNamespace(regexp) {\n\t\treturn regexp.toString()\n\t\t\t.substring(2, regexp.toString().length - 2)\n\t\t\t.replace(/\\.\\*\\?$/, '*');\n\t}\n\n\t/**\n\t* Coerce `val`.\n\t*\n\t* @param {Mixed} val\n\t* @return {Mixed}\n\t* @api private\n\t*/\n\tfunction coerce(val) {\n\t\tif (val instanceof Error) {\n\t\t\treturn val.stack || val.message;\n\t\t}\n\t\treturn val;\n\t}\n\n\t/**\n\t* XXX DO NOT USE. This is a temporary stub function.\n\t* XXX It WILL be removed in the next major release.\n\t*/\n\tfunction destroy() {\n\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t}\n\n\tcreateDebug.enable(createDebug.load());\n\n\treturn createDebug;\n}\n\nmodule.exports = setup;\n","/* eslint-env browser */\n\n/**\n * This is the web browser implementation of `debug()`.\n */\n\nexports.formatArgs = formatArgs;\nexports.save = save;\nexports.load = load;\nexports.useColors = useColors;\nexports.storage = localstorage();\nexports.destroy = (() => {\n\tlet warned = false;\n\n\treturn () => {\n\t\tif (!warned) {\n\t\t\twarned = true;\n\t\t\tconsole.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');\n\t\t}\n\t};\n})();\n\n/**\n * Colors.\n */\n\nexports.colors = [\n\t'#0000CC',\n\t'#0000FF',\n\t'#0033CC',\n\t'#0033FF',\n\t'#0066CC',\n\t'#0066FF',\n\t'#0099CC',\n\t'#0099FF',\n\t'#00CC00',\n\t'#00CC33',\n\t'#00CC66',\n\t'#00CC99',\n\t'#00CCCC',\n\t'#00CCFF',\n\t'#3300CC',\n\t'#3300FF',\n\t'#3333CC',\n\t'#3333FF',\n\t'#3366CC',\n\t'#3366FF',\n\t'#3399CC',\n\t'#3399FF',\n\t'#33CC00',\n\t'#33CC33',\n\t'#33CC66',\n\t'#33CC99',\n\t'#33CCCC',\n\t'#33CCFF',\n\t'#6600CC',\n\t'#6600FF',\n\t'#6633CC',\n\t'#6633FF',\n\t'#66CC00',\n\t'#66CC33',\n\t'#9900CC',\n\t'#9900FF',\n\t'#9933CC',\n\t'#9933FF',\n\t'#99CC00',\n\t'#99CC33',\n\t'#CC0000',\n\t'#CC0033',\n\t'#CC0066',\n\t'#CC0099',\n\t'#CC00CC',\n\t'#CC00FF',\n\t'#CC3300',\n\t'#CC3333',\n\t'#CC3366',\n\t'#CC3399',\n\t'#CC33CC',\n\t'#CC33FF',\n\t'#CC6600',\n\t'#CC6633',\n\t'#CC9900',\n\t'#CC9933',\n\t'#CCCC00',\n\t'#CCCC33',\n\t'#FF0000',\n\t'#FF0033',\n\t'#FF0066',\n\t'#FF0099',\n\t'#FF00CC',\n\t'#FF00FF',\n\t'#FF3300',\n\t'#FF3333',\n\t'#FF3366',\n\t'#FF3399',\n\t'#FF33CC',\n\t'#FF33FF',\n\t'#FF6600',\n\t'#FF6633',\n\t'#FF9900',\n\t'#FF9933',\n\t'#FFCC00',\n\t'#FFCC33'\n];\n\n/**\n * Currently only WebKit-based Web Inspectors, Firefox >= v31,\n * and the Firebug extension (any Firefox version) are known\n * to support \"%c\" CSS customizations.\n *\n * TODO: add a `localStorage` variable to explicitly enable/disable colors\n */\n\n// eslint-disable-next-line complexity\nfunction useColors() {\n\t// NB: In an Electron preload script, document will be defined but not fully\n\t// initialized. Since we know we're in Chrome, we'll just detect this case\n\t// explicitly\n\tif (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {\n\t\treturn true;\n\t}\n\n\t// Internet Explorer and Edge do not support colors.\n\tif (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)) {\n\t\treturn false;\n\t}\n\n\t// Is webkit? http://stackoverflow.com/a/16459606/376773\n\t// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632\n\treturn (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||\n\t\t// Is firebug? http://stackoverflow.com/a/398120/376773\n\t\t(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||\n\t\t// Is firefox >= v31?\n\t\t// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||\n\t\t// Double check webkit in userAgent just in case we are in a worker\n\t\t(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/));\n}\n\n/**\n * Colorize log arguments if enabled.\n *\n * @api public\n */\n\nfunction formatArgs(args) {\n\targs[0] = (this.useColors ? '%c' : '') +\n\t\tthis.namespace +\n\t\t(this.useColors ? ' %c' : ' ') +\n\t\targs[0] +\n\t\t(this.useColors ? '%c ' : ' ') +\n\t\t'+' + module.exports.humanize(this.diff);\n\n\tif (!this.useColors) {\n\t\treturn;\n\t}\n\n\tconst c = 'color: ' + this.color;\n\targs.splice(1, 0, c, 'color: inherit');\n\n\t// The final \"%c\" is somewhat tricky, because there could be other\n\t// arguments passed either before or after the %c, so we need to\n\t// figure out the correct index to insert the CSS into\n\tlet index = 0;\n\tlet lastC = 0;\n\targs[0].replace(/%[a-zA-Z%]/g, match => {\n\t\tif (match === '%%') {\n\t\t\treturn;\n\t\t}\n\t\tindex++;\n\t\tif (match === '%c') {\n\t\t\t// We only are interested in the *last* %c\n\t\t\t// (the user may have provided their own)\n\t\t\tlastC = index;\n\t\t}\n\t});\n\n\targs.splice(lastC, 0, c);\n}\n\n/**\n * Invokes `console.debug()` when available.\n * No-op when `console.debug` is not a \"function\".\n * If `console.debug` is not available, falls back\n * to `console.log`.\n *\n * @api public\n */\nexports.log = console.debug || console.log || (() => {});\n\n/**\n * Save `namespaces`.\n *\n * @param {String} namespaces\n * @api private\n */\nfunction save(namespaces) {\n\ttry {\n\t\tif (namespaces) {\n\t\t\texports.storage.setItem('debug', namespaces);\n\t\t} else {\n\t\t\texports.storage.removeItem('debug');\n\t\t}\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\n/**\n * Load `namespaces`.\n *\n * @return {String} returns the previously persisted debug modes\n * @api private\n */\nfunction load() {\n\tlet r;\n\ttry {\n\t\tr = exports.storage.getItem('debug');\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n\n\t// If debug isn't set in LS, and we're in Electron, try to load $DEBUG\n\tif (!r && typeof process !== 'undefined' && 'env' in process) {\n\t\tr = process.env.DEBUG;\n\t}\n\n\treturn r;\n}\n\n/**\n * Localstorage attempts to return the localstorage.\n *\n * This is necessary because safari throws\n * when a user disables cookies/localstorage\n * and you attempt to access it.\n *\n * @return {LocalStorage}\n * @api private\n */\n\nfunction localstorage() {\n\ttry {\n\t\t// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context\n\t\t// The Browser also has localStorage in the global context.\n\t\treturn localStorage;\n\t} catch (error) {\n\t\t// Swallow\n\t\t// XXX (@Qix-) should we be logging these?\n\t}\n}\n\nmodule.exports = require('./common')(exports);\n\nconst {formatters} = module.exports;\n\n/**\n * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.\n */\n\nformatters.j = function (v) {\n\ttry {\n\t\treturn JSON.stringify(v);\n\t} catch (error) {\n\t\treturn '[UnexpectedJSONParseError]: ' + error.message;\n\t}\n};\n","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;"],"names":["s","m","h","d","ms","val","options","type","length","str","String","match","exec","n","parseFloat","toLowerCase","parse","isFinite","long","msAbs","Math","abs","plural","fmtLong","round","fmtShort","Error","JSON","stringify","name","isPlural","exports","formatArgs","args","this","useColors","namespace","module","humanize","diff","c","color","splice","index","lastC","replace","save","namespaces","storage","setItem","removeItem","error","load","r","getItem","process","env","DEBUG","window","__nwjs","navigator","userAgent","document","documentElement","style","WebkitAppearance","console","firebug","exception","table","parseInt","RegExp","$1","localStorage","localstorage","destroy","warned","warn","colors","log","debug","createDebug","prevTime","namespacesCache","enabledCache","enableOverride","enabled","self","curr","Number","Date","prev","coerce","unshift","format","formatter","formatters","call","apply","selectColor","extend","Object","defineProperty","enumerable","configurable","get","set","v","init","delimiter","newDebug","toNamespace","regexp","toString","substring","default","stack","message","disable","names","map","skips","join","enable","i","split","len","push","slice","test","require$$0","keys","forEach","key","hash","charCodeAt","j","getRandomValues","rnds8","Uint8Array","rng","crypto","bind","byteToHex","native","randomUUID","v4","buf","offset","rnds","random","arr","unsafeStringify"],"mappings":"i+DAIA,IAAIA,EAAI,IACJC,EAAQ,GAAJD,EACJE,EAAQ,GAAJD,EACJE,EAAQ,GAAJD,EAkBRE,EAAiB,SAASC,EAAKC,GAC7BA,EAAUA,GAAW,GACrB,IAAIC,SAAcF,EAClB,GAAa,WAATE,GAAqBF,EAAIG,OAAS,EACpC,OAkBJ,SAAeC,GAEb,MADAA,EAAMC,OAAOD,IACLD,OAAS,KAAjB,CAGA,IAAIG,EAAQ,mIAAmIC,KAC7IH,GAEF,GAAKE,EAAL,CAGA,IAAIE,EAAIC,WAAWH,EAAM,IAEzB,QADYA,EAAM,IAAM,MAAMI,eAE5B,IAAK,QACL,IAAK,OACL,IAAK,MACL,IAAK,KACL,IAAK,IACH,OAzDEZ,SAyDKU,EACT,IAAK,QACL,IAAK,OACL,IAAK,IACH,OA9DEV,OA8DKU,EACT,IAAK,OACL,IAAK,MACL,IAAK,IACH,OAAOA,EAAIV,EACb,IAAK,QACL,IAAK,OACL,IAAK,MACL,IAAK,KACL,IAAK,IACH,OAAOU,EAAIX,EACb,IAAK,UACL,IAAK,SACL,IAAK,OACL,IAAK,MACL,IAAK,IACH,OAAOW,EAAIZ,EACb,IAAK,UACL,IAAK,SACL,IAAK,OACL,IAAK,MACL,IAAK,IACH,OAAOY,EAAIb,EACb,IAAK,eACL,IAAK,cACL,IAAK,QACL,IAAK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EAAIH,EAAS,IAAM,IAAML,EAAUQ,EAAIH,EAAS,IAAML,EAAUQ,EAAIH,EAAS,IAAM,IAAML,EAAUQ,EAAIH,EAAS,IAAML,EAAUQ,EAAIH,EAAS,IAAM,IAAML,EAAUQ,EAAIH,EAAS,KAAOL,EAAUQ,EAAIH,EAAS,KAAOL,EAAUQ,EAAIH,EAAS,KAAOL,EAAUQ,EAAIH,EAAS,KAAOL,EAAUQ,EAAIH,EAAS,KAAOL,EAAUQ,EAAIH,EAAS,MAAMrI,aACvf,CESSyI,CAAgBH,EACzB"}
@@ -0,0 +1,54 @@
1
+ import { Base } from '../../base';
2
+ import { SignatureMessageRequest, SignatureMessageResponse, SignInRequest, SignInResponse, SignUpRequest, SignUpResponse, WallabyConfig, ClientAuthPubKeyRequest, RefreshAccessTokenResponse, ClientAuthPubKeyResponse } from '../../types';
3
+ export declare class Auth extends Base {
4
+ constructor(config: WallabyConfig);
5
+ /**
6
+ *
7
+ * @public
8
+ * @description The returned message will be used to authorize the user to sign operations
9
+ * @param {string} hashKey
10
+ * @param {string} userId
11
+ * @returns {SignatureMessageResponse} The returned message will be used for sign up and sign in signature
12
+ */
13
+ signatureMessage({ hashKey, userId }: SignatureMessageRequest): Promise<SignatureMessageResponse | undefined>;
14
+ /**
15
+ *
16
+ * @public
17
+ * @description Users will be able to sign in by providing a signature and message. Use the same key pair used on sign up'
18
+ * @param {string} hashKey
19
+ * @param {string} firstName
20
+ * @param {string} lastName
21
+ * @param {string} email
22
+ * @returns {SignUpResponse}
23
+ */
24
+ signUp({ hashKey, firstName, lastName, email }: SignUpRequest): Promise<SignUpResponse | undefined>;
25
+ /**
26
+ *
27
+ * @public
28
+ * @description Users will be able to sign in by providing a signature and message. Use the same key pair used on sign up'
29
+ * @param {string} hashKey
30
+ * @returns {SignInResponse}
31
+ */
32
+ signIn({ hashKey }: SignInRequest): Promise<SignInResponse | undefined>;
33
+ /**
34
+ *
35
+ * @public
36
+ * @description Users will be able to sign up by providing a signature and message. Use the same pair keys used on sign up
37
+ * @param {null}
38
+ * @returns {string} Access token
39
+ */
40
+ refreshAccessToken({}: {}): Promise<RefreshAccessTokenResponse | undefined>;
41
+ /**
42
+ * @description Change user authentication public key
43
+ * @param {string} hashKey
44
+ * @param {string} userId
45
+ * @returns {User} User object
46
+ */
47
+ updateClientAuthPubKey({ hashKey, userId, }: Pick<ClientAuthPubKeyRequest, 'hashKey' | 'userId'>): Promise<ClientAuthPubKeyResponse | undefined>;
48
+ /**
49
+ * @description
50
+ * @param {string} clientAuthPubKey
51
+ * @returns {WallabyAuthPubKeyResponse} Returns user's Wallaby WallabyAuthPubKey
52
+ */
53
+ getWallabyAuthPublicKey(): Promise<void>;
54
+ }
@@ -0,0 +1,3 @@
1
+ export * from './wallet';
2
+ export * from './auth';
3
+ export * from './utils';
@@ -0,0 +1,32 @@
1
+ import { Base } from '../../base';
2
+ import { WallabyConfig, Blockchain, AssetConfig, User } from '../../types';
3
+ export declare class System extends Base {
4
+ constructor(config: WallabyConfig);
5
+ /**
6
+ * @public
7
+ * @description Get all supported chains
8
+ * @param {null}
9
+ * @returns {Array<Blockchain>} Array of supported chains
10
+ */
11
+ getSupportedBlockchains(): Promise<Array<Blockchain> | undefined>;
12
+ /**
13
+ * @public
14
+ * @description Get all supported assets configuration
15
+ * @param {null}
16
+ * @returns {Array<AssetConfig>} Array of supported tokens
17
+ */
18
+ getSupportedTokens(): Promise<AssetConfig[] | undefined>;
19
+ /**
20
+ * @public
21
+ * @param {string} userId
22
+ * @returns {User} Returns user public data
23
+ */
24
+ getUserData(userId: string): Promise<User | undefined>;
25
+ /**
26
+ * @public
27
+ * @description This returns essential data by the external user ID provided at sign up.
28
+ * @param {string} externalUserId
29
+ * @returns {User} Returns user public data
30
+ */
31
+ getUserByExternalUserId(externalUserId: string): Promise<User | undefined>;
32
+ }
@@ -0,0 +1,80 @@
1
+ import { Base } from '../../base';
2
+ import { WallabyConfig, BlockchainName, TokenStandard } from '../../types';
3
+ import { CreateAllowanceRequest, FeeEstimateRequest, FeeEstimatesResponse, Transaction, TransactionStatusResponse, TransferRequest, TransferResponse } from '../../types';
4
+ export declare class Transactions extends Base {
5
+ private auth;
6
+ constructor(config: WallabyConfig);
7
+ /**
8
+ *
9
+ * @public
10
+ * @param {string} originAddress
11
+ * @param {string} recipientAddress
12
+ * @param {number} amount
13
+ * @param {string} assetSymbol
14
+ * @param {TransactionType} transactionType
15
+ * @param {TokenStandard} tokenStandard
16
+ * @returns {FeeEstimateRequest}
17
+ */
18
+ estimateFee({ originAddress, recipientAddress, amount, assetSymbol, transactionType, tokenStandard, }: FeeEstimateRequest): Promise<FeeEstimatesResponse | undefined>;
19
+ /**
20
+ *
21
+ * @public
22
+ * @param {string} originAddress
23
+ * @param {string} recipientAddress
24
+ * @param {number} amount
25
+ * @param {string} assetId
26
+ * @param {string} reference
27
+ * @param {string} memo
28
+ * @param {string} hashKey
29
+ * @returns {TransferResponse} Transaction object which contains the transaction hash and status
30
+ */
31
+ transfer({ originAddress, recipientAddress, amount, assetId, reference, memo, hashKey, }: TransferRequest): Promise<TransferResponse | undefined>;
32
+ /**
33
+ *
34
+ * @public
35
+ * @param {string} transactionHash the transaction hash from the blockchain
36
+ * @param {string} reference a uuid unique to the transaction that links it with external systems
37
+ * @param {BlockchainName} blockchain blockchain name
38
+ * @returns {TransactionStatusResponse} Includes the status, the hash and other attributes.
39
+ */
40
+ getTransactionStatus({ transactionHash, reference, blockchain, }: {
41
+ transactionHash: string;
42
+ reference: string;
43
+ blockchain: BlockchainName;
44
+ hashKey: string;
45
+ }): Promise<TransactionStatusResponse | undefined>;
46
+ /**
47
+ *
48
+ * @public
49
+ * @param {string} address
50
+ * @param {string} symbol
51
+ * @param {TokenStandard} tokenStandard an optional param used when dealing with non native assets
52
+ * @returns {Promise<{ address: string; transactions: Transaction[] }>}
53
+ */
54
+ getTransactions({ address, symbol, tokenStandard, }: {
55
+ address: string;
56
+ symbol: string;
57
+ tokenStandard?: TokenStandard;
58
+ }): Promise<{
59
+ address: string;
60
+ transactions: Transaction[];
61
+ error?: any;
62
+ } | undefined>;
63
+ /**
64
+ *
65
+ * @public
66
+ * @param {string} hashKey
67
+ * @param {string} ownerAddress
68
+ * @param {string} spenderAddress
69
+ * @param {string} amount
70
+ * @param {string} assetId
71
+ * @param {string} contractAddress
72
+ * @param {string} reference
73
+ * @param {string} memo
74
+ * @returns {CreateAllowanceResponse}
75
+ *
76
+ */
77
+ createAllowance({ hashKey, ownerAddress, spenderAddress, amount, assetId, contractAddress, reference, memo, }: CreateAllowanceRequest): Promise<{
78
+ transaction: Transaction;
79
+ } | undefined>;
80
+ }
@@ -0,0 +1,21 @@
1
+ import { UtilsResponse, PasswordValidatorResponse, WallabyConfig, SeedPhraseType, RequestMothod } from '../../types';
2
+ import { Base } from '../../base';
3
+ import { Encrypted } from 'eth-crypto';
4
+ export declare class Utils extends Base {
5
+ setWallabyAuthPubKey: (userId: string, wallabyAuthPubKey: string) => void;
6
+ getWallabyAuthPubKey: (userId: string) => UtilsResponse;
7
+ setEncryptedPrivateKey: (userId: string, privateKey: string, hashKey: string) => boolean;
8
+ getEncryptedPrivateKey: (userId: string) => UtilsResponse;
9
+ getDecryptedPrivateKey: (userId: string, hashKey: string) => string | undefined;
10
+ setEncryptedSeedPhrase: (userId: string, clientAuthPubKey: string, decryptedSeedPhrase: string, seedPhraseType: SeedPhraseType) => Promise<boolean>;
11
+ getEncryptedSeedPhrase: (userId: string, seedPhraseType: SeedPhraseType) => Encrypted | undefined;
12
+ getDecryptedSeedPhrase: (userId: string, hashKey: string, seedphraseType: SeedPhraseType) => Promise<UtilsResponse>;
13
+ validatePassword: (userId: string, hashKey: string) => PasswordValidatorResponse;
14
+ constructor(config: WallabyConfig);
15
+ fetchFromEndpoint({ endpoint, method, accessTokenRequired, payload, }: {
16
+ endpoint: string;
17
+ method: RequestMothod;
18
+ accessTokenRequired?: boolean;
19
+ payload?: any;
20
+ }): Promise<any>;
21
+ }
@@ -0,0 +1,68 @@
1
+ import { Encrypted } from 'eth-crypto';
2
+ import { UtilsResponse, PasswordValidatorResponse, WallabyError, SeedPhraseType } from '../../types';
3
+ /**
4
+ *
5
+ * Stores Wallaby auth pubilc key to local storage
6
+ * @param userId
7
+ * @param wallabyAuthPubKey
8
+ */
9
+ export declare const setWallabyAuthPubKey: (userId: string, wallabyAuthPubKey: string) => boolean;
10
+ /**
11
+ *
12
+ * @description Fetches Wallaby auth pubilc key from local storage
13
+ * @param userId
14
+ * @returns a string of Wallaby Auth Public key or undefined.
15
+ */
16
+ export declare const getWallabyAuthPubKey: (userId: string) => UtilsResponse;
17
+ /**
18
+ *
19
+ * Encrypts and stores user private key
20
+ * @param userId ID of the user (should be a uuid)
21
+ * @param privateKey private key
22
+ * @param hashKey hashKey that is used to encrypt the private key
23
+ */
24
+ export declare const setEncryptedPrivateKey: (userId: string, privateKey: string, hashKey: string) => boolean;
25
+ /**
26
+ *
27
+ * Fetches encrypted private key from local storage
28
+ * @param userId
29
+ */
30
+ export declare const getEncryptedPrivateKey: (userId: string) => UtilsResponse;
31
+ /**
32
+ *
33
+ * Decrypts user private key
34
+ * @param userId
35
+ * @param hashKey
36
+ * @returns
37
+ */
38
+ export declare const getDecryptedPrivateKey: (userId: string, hashKey: string) => UtilsResponse;
39
+ /**
40
+ *
41
+ * @param userId
42
+ * @param encryptedSeedPhrase
43
+ */
44
+ export declare const setEncryptedSeedPhrase: (userId: string, clientAuthPubKey: string, decryptedSeedPhrase: string, seedPhraseType: SeedPhraseType) => Promise<boolean>;
45
+ /**
46
+ *
47
+ * @param {string} userId The user ID for whome the seedphrase belongs.
48
+ * @param {SeedPhraseType} seedPhraseType Standard or Mnemonic seedphrase
49
+ * @returns {UtilsResponse} It returns the encrypted seedphrase as a string or undefined
50
+ */
51
+ export declare const getEncryptedSeedPhrase: (userId: string, seedPhraseType: SeedPhraseType) => Encrypted | undefined;
52
+ /**
53
+ *
54
+ * @param {string} userId
55
+ * @param {string} hashKey
56
+ * @returns {UtilsResponse} It returns the decrypted seedphrase as a string or undefined
57
+ */
58
+ export declare const getDecryptedSeedPhrase: (userId: string, hashKey: string, seedPhraseType: SeedPhraseType) => Promise<UtilsResponse>;
59
+ export declare const setAccessToken: (userId: string, accessToken: string) => boolean;
60
+ export declare const getAccessToken: (userId: string) => UtilsResponse | WallabyError;
61
+ /**
62
+ *
63
+ * @param userId
64
+ * @param hashKey
65
+ * @returns
66
+ */
67
+ export declare const validatePassword: (userId: string, hashKey: string) => PasswordValidatorResponse;
68
+ export declare const clearLocalStorage: (userId: string) => void;
@@ -0,0 +1,99 @@
1
+ import { Base } from '../../base';
2
+ import { QueryUserRequest, CreateWalletRequest, CreateWalletResponse, RecoverWalletRequest, RecoverWalletResponse, TokenBalanceRequest, TokenBalancResponse, WallabyError, QueryWalletRequest, UserAssetsResponse, UserWalletsResponse, WalletAssetsResponse, WallabyConfig, ConvertMnemonicSeedPhraseRequest, ConvertMnemonicSeedPhraseResponse, CreateMultisigAssetRequest, CreateMultisigAssetResponse, ClearWalletInput } from '../../types';
3
+ export declare class Wallet extends Base {
4
+ private auth;
5
+ constructor(config: WallabyConfig);
6
+ /**
7
+ *
8
+ * @public
9
+ * @description Create a newly fresh wallet, returns asset list and encrypted seedPhrase
10
+ * @param {string} address Wallet address
11
+ * @param {string} symbol Token symbol
12
+ * @param {TokenStandard} tokenStandard Token standard. Leave as null if the token is native to the blockchain. i.e ALGO BTC or ETH
13
+ * @returns {CreateWalletResponse} The wallet has been created successfully
14
+ */
15
+ getTokenBalance({ address, symbol, tokenStandard }: TokenBalanceRequest): Promise<TokenBalancResponse | undefined>;
16
+ /**
17
+ *
18
+ * @public
19
+ * @description Create a newly fresh wallet, returns asset list and encrypted seedPhrase
20
+ * @param {string} firstName The user's first name
21
+ * @param {string} lastName The user's last name
22
+ * @param {email} email The user's email
23
+ * @param {string} hashKey The user's chosen password
24
+ * @returns {CreateWalletResponse} The wallet has been created successfully
25
+ */
26
+ create({ firstName, lastName, email, hashKey, }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'hashKey'>): Promise<CreateWalletResponse | WallabyError>;
27
+ /**
28
+ *
29
+ * @public
30
+ * @description Create a newly fresh wallet, returns asset list and encrypted seedPhrase
31
+ * @param {string} firstName The user's first name
32
+ * @param {string} lastName The user's last name
33
+ * @param {email} email The user's email
34
+ * @param {string} hashKey The user's chosen password
35
+ * @returns {CreateWalletResponse} The wallet has been created successfully
36
+ */
37
+ createWithNewAccount({ firstName, lastName, email, hashKey, }: Pick<CreateWalletRequest, 'firstName' | 'lastName' | 'email' | 'hashKey'>): Promise<CreateWalletResponse | WallabyError>;
38
+ /**
39
+ *
40
+ * @public
41
+ * @description Removes all Wallaby data from local storage.
42
+ * @param {string} userId The user's ID that is associated with their stored keys
43
+ * @returns {Boolean}
44
+ */
45
+ clearWalletData({ userId }: ClearWalletInput): Boolean;
46
+ /**
47
+ *
48
+ * @public
49
+ * @description Convert BIP39 Standard seed phrase to Algorand fixed 25 words mnemonic phrase
50
+ * @param {string} hashKey
51
+ * @param {Encrypted} encryptedSeedPhrase It needs to be encypted using wallabyAuthPubKey
52
+ * @returns {ConvertMnemonicSeedPhraseResponse} The mnemonic seed phrase has been converted successfully.
53
+ */
54
+ convertMnemonicSeedphrase({ hashKey, encryptedSeedPhrase, }: Pick<ConvertMnemonicSeedPhraseRequest, 'hashKey' | 'encryptedSeedPhrase'>): Promise<ConvertMnemonicSeedPhraseResponse | undefined>;
55
+ /**
56
+ *
57
+ * @public
58
+ * @description Recover the lost wallet and its assets.
59
+ * @param {string} newHashKey User need to set a new password while recovering the wallet
60
+ * @param {string} seedPhrase It needs to be encypted using wallabyAuthPubKey
61
+ * @returns {RecoverWalletResponse} The wallet has been recovered successfully.
62
+ */
63
+ recover({ newHashKey, seedPhrase, }: Omit<RecoverWalletRequest, 'clientAuthPubKey'>): Promise<RecoverWalletResponse | undefined>;
64
+ /**
65
+ *
66
+ * @description Get all user assets across all wallets by specifying user id
67
+ * @param userId Wallaby's user ID
68
+ * @returns {UserWalletsResponse} Returns an array of user assets by specifying user id
69
+ */
70
+ getUserAssets({ userId }: QueryUserRequest): Promise<UserAssetsResponse | undefined>;
71
+ /**
72
+ *
73
+ * @description Get all wallets belonging to a user.
74
+ * @param userId Wallaby's user ID
75
+ * @returns {UserWalletsResponse} Returns an array of user wallets by specifying user ID
76
+ */
77
+ getUserWallets({ userId }: QueryUserRequest): Promise<UserWalletsResponse | undefined>;
78
+ /**
79
+ *
80
+ * @description Get all assets that exist in a certain wallet, by specifying a wallet ID
81
+ * @param walletId Wallaby's wallet ID
82
+ * @returns {WalletAssetsResponse} Returns all assets belonging in a certain wallet ID
83
+ */
84
+ getWalletAssets({ walletId }: QueryWalletRequest): Promise<WalletAssetsResponse | undefined>;
85
+ /**
86
+ *
87
+ * @public
88
+ * @description Initiate creation for a new multisig asset, by specifying participants and the threshold
89
+ * @param {string} assetSymbol Asset symbol
90
+ * @param {string} tokenType Optional value only used when dealing with non native assets (aka tokens), If native asset, keep the field empty
91
+ * @param {number} threshold The threshold is the number of signatures required to sign a transaction
92
+ * @param {string} creatorAddress The address of the account that is initiating the multisig asset creation
93
+ * @param {Array} participants The array containing the addresses of the users requested to participate in the multisig
94
+ * @param {number} version Version of the multi-sig
95
+ * @returns {CreateMultisigAssetResponse} Multisig asset was created successfully
96
+ */
97
+ createMultisigAsset({ assetSymbol, tokenType, threshold, creatorAddress, participants, version, }: CreateMultisigAssetRequest): Promise<CreateMultisigAssetResponse>;
98
+ private initRecoveryFlow;
99
+ }
@@ -0,0 +1,7 @@
1
+ declare class LocalStorageMock {
2
+ store: {};
3
+ clear(): void;
4
+ getItem(key: any): any;
5
+ setItem(key: any, value: any): void;
6
+ removeItem(key: any): void;
7
+ }
@@ -0,0 +1,33 @@
1
+ import { RequestMothod } from '../types';
2
+ export declare const AuthRoutes: {
3
+ signatureMessage: {
4
+ fullPath: string;
5
+ method: RequestMothod;
6
+ accessTokenRequired: boolean;
7
+ };
8
+ signIn: {
9
+ fullPath: string;
10
+ method: RequestMothod;
11
+ accessTokenRequired: boolean;
12
+ };
13
+ signUp: {
14
+ fullPath: string;
15
+ method: RequestMothod;
16
+ accessTokenRequired: boolean;
17
+ };
18
+ refreshAcessToken: {
19
+ fullPath: string;
20
+ method: RequestMothod;
21
+ accessTokenRequired: boolean;
22
+ };
23
+ clientAuthPubKey: {
24
+ fullPath: string;
25
+ method: RequestMothod;
26
+ accessTokenRequired: boolean;
27
+ };
28
+ wallabyAuthPublicKey: {
29
+ fullPath: string;
30
+ method: RequestMothod;
31
+ accessTokenRequired: boolean;
32
+ };
33
+ };
@@ -0,0 +1,3 @@
1
+ export { WalletRoutes } from './wallet';
2
+ export { AuthRoutes } from './auth';
3
+ export { SystemRoutes } from './system';
@@ -0,0 +1,23 @@
1
+ import { QueryUserRequest, RequestMothod } from '../types';
2
+ export declare const SystemRoutes: {
3
+ getSupportedBlockchains: {
4
+ fullPath: string;
5
+ method: RequestMothod;
6
+ accessTokenRequired: boolean;
7
+ };
8
+ getSupportedTokens: {
9
+ fullPath: string;
10
+ method: RequestMothod;
11
+ accessTokenRequired: boolean;
12
+ };
13
+ getUserByExternalUserId: {
14
+ fullPath: ({ externalUserId }: QueryUserRequest) => string;
15
+ method: RequestMothod;
16
+ accessTokenRequired: boolean;
17
+ };
18
+ getUserData: {
19
+ fullPath: ({ userId }: QueryUserRequest) => string;
20
+ method: RequestMothod;
21
+ accessTokenRequired: boolean;
22
+ };
23
+ };
@@ -0,0 +1,28 @@
1
+ import { RequestMothod } from '../types';
2
+ export declare const TransactionsRoutes: {
3
+ transfer: {
4
+ fullPath: string;
5
+ method: RequestMothod;
6
+ accessTokenRequired: boolean;
7
+ };
8
+ createAllowance: {
9
+ fullPath: string;
10
+ method: RequestMothod;
11
+ accessTokenRequired: boolean;
12
+ };
13
+ estimateFee: {
14
+ fullPath: string;
15
+ method: RequestMothod;
16
+ accessTokenRequired: boolean;
17
+ };
18
+ getTransaction: {
19
+ fullPath: string;
20
+ method: RequestMothod;
21
+ accessTokenRequired: boolean;
22
+ };
23
+ getTransactions: {
24
+ fullPath: string;
25
+ method: RequestMothod;
26
+ accessTokenRequired: boolean;
27
+ };
28
+ };
@@ -0,0 +1,53 @@
1
+ import { TokenBalanceRequest, QueryUserRequest, QueryWalletRequest, RequestMothod } from '../types';
2
+ export declare const WalletRoutes: {
3
+ create: {
4
+ fullPath: string;
5
+ method: RequestMothod;
6
+ accessTokenRequired: boolean;
7
+ };
8
+ initRecoveryFlow: {
9
+ fullPath: string;
10
+ method: RequestMothod;
11
+ accessTokenRequired: boolean;
12
+ };
13
+ recover: {
14
+ fullPath: string;
15
+ method: RequestMothod;
16
+ accessTokenRequired: boolean;
17
+ };
18
+ getTokenBalance: {
19
+ fullPath: ({ address, symbol, tokenStandard }: TokenBalanceRequest) => string;
20
+ method: RequestMothod;
21
+ accessTokenRequired: boolean;
22
+ };
23
+ estimateFee: {
24
+ fullPath: string;
25
+ method: RequestMothod;
26
+ accessTokenRequired: boolean;
27
+ };
28
+ getWalletAssets: {
29
+ fullPath: ({ walletId }: QueryWalletRequest) => string;
30
+ method: RequestMothod;
31
+ accessTokenRequired: boolean;
32
+ };
33
+ getUserAssets: {
34
+ fullPath: ({ userId }: QueryUserRequest) => string;
35
+ method: RequestMothod;
36
+ accessTokenRequired: boolean;
37
+ };
38
+ getUserWallets: {
39
+ fullPath: ({ userId }: QueryUserRequest) => string;
40
+ method: RequestMothod;
41
+ accessTokenRequired: boolean;
42
+ };
43
+ convertMnemonicSeedphrase: {
44
+ fullPath: string;
45
+ method: RequestMothod;
46
+ accessTokenRequired: boolean;
47
+ };
48
+ createMultisigAsset: {
49
+ fullPath: string;
50
+ method: RequestMothod;
51
+ accessTokenRequired: boolean;
52
+ };
53
+ };
@@ -0,0 +1,11 @@
1
+ export declare const signatureMessageMockResponse: {
2
+ message: string;
3
+ hashedMessage: string;
4
+ signature: string;
5
+ decryptedClientAuthPrivKey: string;
6
+ clientAuthPubKey: string;
7
+ };
8
+ export declare const testClientJWTKeyPair: {
9
+ privateKey: string;
10
+ publicKey: string;
11
+ };
@@ -0,0 +1,6 @@
1
+ export declare const config: {
2
+ apiKey: string;
3
+ baseUrl: string;
4
+ userId: string;
5
+ jwt: string;
6
+ };
@@ -0,0 +1,4 @@
1
+ export * from './auth';
2
+ export * from './config';
3
+ export * from './user';
4
+ export * from './system';