feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "8.0"
- "8"
- "10"

View File

@@ -0,0 +1,7 @@
1) What version of the module is the issue happening on? Does the issue happen on latest version?
2) What platform and Node.js version? (For example Node.js 0.12 on Mac OS X)
3) Sample source code or steps to reproduce
(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Bojan D.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,22 @@
(The MIT License)
Copyright (c) 2014 Bojan Djurkovic
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,102 @@
# json-schema-deref-sync
[![npm version](https://img.shields.io/npm/v/json-schema-deref-sync.svg?style=flat-square)](https://www.npmjs.com/package/json-schema-deref-sync)
[![build status](https://img.shields.io/travis/bojand/json-schema-deref-sync/master.svg?style=flat-square)](https://travis-ci.org/bojand/json-schema-deref-sync)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![License](https://img.shields.io/github/license/bojand/json-schema-deref-sync.svg?style=flat-square)](https://raw.githubusercontent.com/bojand/json-schema-deref-sync/master/LICENSE)
Dereference JSON pointers in a JSON schemas with their true resolved values.
Basically a lighter, synchronous version of [json-schema-deref](https://github.com/bojand/json-schema-deref) but omits web references.
## Installation
`npm install json-schema-deref-sync`
## Overview
Let's say you have the following JSON Schema:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"$ref": "#/definitions/id"
},
"bar": {
"$ref": "bar.json"
}
}
}
```
Sometimes you just want that schema to be fully expanded, with `$ref`'s being their (true) resolved values:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
},
"bar": {
"description": "bar property",
"type": "boolean"
}
}
}
```
This utility lets you do that:
```js
var deref = require('json-schema-deref-sync');
var myschema = require('schema.json');
var fullSchema = deref(myschema);
```
## API Reference
<a name="deref"></a>
## deref(schema, options) ⇒ <code>Object</code> \| <code>Error</code>
Derefs <code>$ref</code>'s in JSON Schema to actual resolved values. Supports local, and file refs.
**Kind**: global function
**Returns**: <code>Object</code> \| <code>Error</code> - the deref schema oran instance of <code>Error</code> if error.
| Param | Type | Description |
| --- | --- | --- |
| schema | <code>Object</code> | The JSON schema |
| options | <code>Object</code> | options |
| options.baseFolder | <code>String</code> | the base folder to get relative path files from. Default is <code>process.cwd()</code> |
| options.failOnMissing | <code>Boolean</code> | By default missing / unresolved refs will be left as is with their ref value intact. If set to <code>true</code> we will error out on first missing ref that we cannot resolve. Default: <code>false</code>. |
| options.mergeAdditionalProperties | <code>Boolean</code> | By default properties in a object with $ref will be removed in the output. If set to <code>true</code> they will be added/overwrite the output. This will use lodash's merge function. Default: <code>false</code>. |
| options.removeIds | <code>Boolean</code> | By default <code>$id</code> fields will get copied when dereferencing. If set to <code>true</code> they will be removed. Merged properties will not get removed. Default: <code>false</code>. |
| options.loaders | <code>Object</code> | A hash mapping reference types (e.g., 'file') to loader functions. |

View File

@@ -0,0 +1,317 @@
const path = require('path')
const _ = require('lodash')
const clone = require('clone')
const traverse = require('traverse')
const DAG = require('dag-map')
const md5 = require('md5')
const utils = require('./utils')
const fileLoader = require('./loaders/file')
const defaults = {
baseFolder: process.cwd()
}
let cache = {}
const loaders = {
file: fileLoader
}
function getLoader (refType, options) {
return _.get(options, `loaders.${refType}`, loaders[refType]);
}
/**
* Returns the reference schema that refVal points to.
* If the ref val points to a ref within a file, the file is loaded and fully derefed, before we get the
* pointing property. Derefed files are cached.
*
* @param refVal
* @param refType
* @param parent
* @param options
* @param state
* @private
*/
function getRefSchema (refVal, refType, parent, options, state) {
const loader = getLoader(refType, options)
if (refType && loader) {
let newVal
let oldBasePath
let loaderValue
let filePath
let fullRefFilePath
if (refType === 'file') {
filePath = utils.getRefFilePath(refVal)
fullRefFilePath = utils.isAbsolute(filePath) ? filePath : path.resolve(state.cwd, filePath)
if (cache[fullRefFilePath]) {
loaderValue = cache[fullRefFilePath]
}
}
if (!loaderValue) {
loaderValue = loader(refVal, options)
if (loaderValue) {
// adjust base folder if needed so that we can handle paths in nested folders
if (refType === 'file') {
let dirname = path.dirname(filePath)
if (dirname === '.') {
dirname = ''
}
if (dirname) {
oldBasePath = state.cwd
const newBasePath = path.resolve(state.cwd, dirname)
options.baseFolder = state.cwd = newBasePath
}
}
loaderValue = derefSchema(loaderValue, options, state)
// reset
if (oldBasePath) {
options.baseFolder = state.cwd = oldBasePath
}
}
}
if (loaderValue) {
if (refType === 'file' && fullRefFilePath && !cache[fullRefFilePath]) {
cache[fullRefFilePath] = loaderValue
}
if (refVal.indexOf('#') >= 0) {
const refPaths = refVal.split('#')
const refPath = refPaths[1]
const refNewVal = utils.getRefPathValue(loaderValue, refPath)
if (refNewVal) {
newVal = refNewVal
}
} else {
newVal = loaderValue
}
}
return newVal
} else if (refType === 'local') {
return utils.getRefPathValue(parent, refVal)
}
}
/**
* Add to state history
* @param {Object} state the state
* @param {String} type ref type
* @param {String} value ref value
* @private
*/
function addToHistory (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
} else {
if (value === '#') {
return false
}
dest = state.current.concat(`:${value}`)
}
if (dest) {
dest = dest.toLowerCase()
if (state.history.indexOf(dest) >= 0) {
return false
}
state.history.push(dest)
}
return true
}
/**
* Set the current into state
* @param {Object} state the state
* @param {String} type ref type
* @param {String} value ref value
* @private
*/
function setCurrent (state, type, value) {
let dest
if (type === 'file') {
dest = utils.getRefFilePath(value)
}
if (dest) {
state.current = dest
}
}
/**
* Check the schema for local circular refs using DAG
* @param {Object} schema the schema
* @return {Error|undefined} <code>Error</code> if circular ref, <code>undefined</code> otherwise if OK
* @private
*/
function checkLocalCircular (schema) {
const dag = new DAG()
const locals = traverse(schema).reduce(function (acc, node) {
if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') {
const refType = utils.getRefType(node)
if (refType === 'local') {
const value = utils.getRefValue(node)
if (value) {
const path = this.path.join('/')
acc.push({
from: path,
to: value
})
}
}
}
return acc
}, [])
if (!locals || !locals.length) {
return
}
if (_.some(locals, elem => elem.to === '#')) {
return new Error('Circular self reference')
}
const check = _.find(locals, elem => {
const fromEdge = elem.from.concat('/')
const dest = elem.to.substring(2).concat('/')
try {
dag.addEdge(fromEdge, dest)
} catch (e) {
return elem
}
if (fromEdge.indexOf(dest) === 0) {
return elem
}
})
if (check) {
return new Error(`Circular self reference from ${check.from} to ${check.to}`)
}
}
/**
* Derefs $ref types in a schema
* @param schema
* @param options
* @param state
* @param type
* @private
*/
function derefSchema (schema, options, state) {
const check = checkLocalCircular(schema)
if (check instanceof Error) {
return check
}
if (state.circular) {
return new Error(`circular references found: ${state.circularRefs.toString()}`)
} else if (state.error) {
return state.error
}
return traverse(schema).forEach(function (node) {
if (!_.isNull(node) && !_.isUndefined(null) && typeof node.$ref === 'string') {
const refType = utils.getRefType(node)
const refVal = utils.getRefValue(node)
const addOk = addToHistory(state, refType, refVal)
if (!addOk) {
state.circular = true
state.circularRefs.push(refVal)
state.error = new Error(`circular references found: ${state.circularRefs.toString()}`)
this.update(node, true)
} else {
setCurrent(state, refType, refVal)
let newValue = getRefSchema(refVal, refType, schema, options, state)
state.history.pop()
if (newValue === undefined) {
if (state.missing.indexOf(refVal) === -1) {
state.missing.push(refVal)
}
if (options.failOnMissing) {
state.error = new Error(`Missing $ref: ${refVal}`)
}
this.update(node, options.failOnMissing)
} else {
if (options.removeIds && newValue.hasOwnProperty('$id')) {
delete newValue.$id
}
if (options.mergeAdditionalProperties) {
delete node.$ref
newValue = _.merge(newValue, node)
}
this.update(newValue)
if (state.missing.indexOf(refVal) !== -1) {
state.missing.splice(state.missing.indexOf(refVal), 1)
}
}
}
}
})
}
/**
* Derefs <code>$ref</code>'s in JSON Schema to actual resolved values. Supports local, and file refs.
* @param {Object} schema - The JSON schema
* @param {Object} options - options
* @param {String} options.baseFolder - the base folder to get relative path files from. Default is <code>process.cwd()</code>
* @param {Boolean} options.failOnMissing - By default missing / unresolved refs will be left as is with their ref value intact.
* If set to <code>true</code> we will error out on first missing ref that we cannot
* resolve. Default: <code>false</code>.
* @param {Boolean} options.mergeAdditionalProperties - By default properties in a object with $ref will be removed in the output.
* If set to <code>true</code> they will be added/overwrite the output. This will use lodash's merge function.
* Default: <code>false</code>.
* @param {Boolean} options.removeIds - By default <code>$id</code> fields will get copied when dereferencing.
* If set to <code>true</code> they will be removed. Merged properties will not get removed.
* Default: <code>false</code>.
* @param {Object} options.loaders - A hash mapping reference types (e.g., 'file') to loader functions.
* @return {Object|Error} the deref schema oran instance of <code>Error</code> if error.
*/
function deref (schema, options) {
options = _.defaults(options, defaults)
const bf = options.baseFolder
let cwd = bf
if (!utils.isAbsolute(bf)) {
cwd = path.resolve(process.cwd(), bf)
}
const state = {
graph: new DAG(),
circular: false,
circularRefs: [],
cwd: cwd,
missing: [],
history: []
}
try {
const str = JSON.stringify(schema)
state.current = md5(str)
} catch (e) {
return e
}
const baseSchema = clone(schema)
cache = {}
let ret = derefSchema(baseSchema, options, state)
if (ret instanceof Error === false && state.error) {
return state.error
}
return ret
}
module.exports = deref

View File

@@ -0,0 +1,34 @@
const fs = require('fs')
const path = require('path')
const { getRefFilePath } = require('../utils')
var cwd = process.cwd()
/**
* Resolves a file link of a json schema to the actual value it references
* @param refValue the value. String. Ex. `/some/path/schema.json#/definitions/foo`
* @param options
* baseFolder - the base folder to get relative path files from. Default is `process.cwd()`
* @returns {*}
* @private
*/
module.exports = function (refValue, options) {
let refPath = refValue
const baseFolder = options.baseFolder ? path.resolve(cwd, options.baseFolder) : cwd
if (refPath.indexOf('file:') === 0) {
refPath = refPath.substring(5)
} else {
refPath = path.resolve(baseFolder, refPath)
}
const filePath = getRefFilePath(refPath)
let newValue
try {
var data = fs.readFileSync(filePath)
newValue = JSON.parse(data)
} catch (e) {}
return newValue
};

View File

@@ -0,0 +1,122 @@
const path = require('path')
const validUrl = require('valid-url')
const isValidPath = require('is-valid-path')
const isWindows = process.platform === 'win32'
/**
* Gets the ref value of a search result from prop-search or ref object
* @param ref The search result object from prop-search
* @returns {*} The value of $ref or undefined if not present in search object
* @private
*/
function getRefValue (ref) {
const thing = ref ? (ref.value ? ref.value : ref) : null
if (thing && thing.$ref && typeof thing.$ref === 'string') {
return thing.$ref
}
}
exports.getRefValue = getRefValue
/**
* Gets the type of $ref from search result object.
* @param ref The search result object from prop-search or a ref object
* @returns {string} `web` if it's a web url.
* `file` if it's a file path.
* `local` if it's a link to local schema.
* undefined otherwise
* @private
*/
function getRefType (ref) {
const val = getRefValue(ref)
if (val) {
if ((val.charAt(0) === '#')) {
return 'local'
}
if (validUrl.isWebUri(val)) {
return 'web'
}
return 'file'
}
}
exports.getRefType = getRefType
/**
* Determines if object is a $ref object. That is { $ref: <something> }
* @param thing object to test
* @returns {boolean} true if passes the test. false otherwise.
* @private
*/
function isRefObject (thing) {
if (thing && typeof thing === 'object' && !Array.isArray(thing)) {
const keys = Object.keys(thing)
return keys.length === 1 && keys[0] === '$ref' && typeof thing.$ref === 'string'
}
return false
}
exports.isRefObject = isRefObject
/**
* Gets the value at the ref path within schema
* @param schema the (root) json schema to search
* @param refPath string ref path to get within the schema. Ex. `#/definitions/id`
* @returns {*} Returns the value at the path location or undefined if not found within the given schema
* @private
*/
function getRefPathValue (schema, refPath) {
let rpath = refPath
const hashIndex = refPath.indexOf('#')
if (hashIndex >= 0) {
rpath = refPath.substring(hashIndex)
if (rpath.length > 1) {
rpath = refPath.substring(1)
} else {
rpath = ''
}
}
// Walk through each /-separated path component, and get
// the value for that key (ignoring empty keys)
const keys = rpath.split('/').filter(k => !!k)
return keys.reduce(function (value, key) {
return value[key]
}, schema)
}
exports.getRefPathValue = getRefPathValue
function getRefFilePath (refPath) {
let filePath = refPath
const hashIndex = filePath.indexOf('#')
if (hashIndex > 0) {
filePath = refPath.substring(0, hashIndex)
}
return filePath
}
exports.getRefFilePath = getRefFilePath
// Regex to split a windows path into three parts: [*, device, slash,
// tail] windows-only
const splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/
function win32StatPath (path) {
const result = splitDeviceRe.exec(path)
const device = result[1] || ''
const isUnc = !!device && device[1] !== ':'
return {
device: device,
isUnc: isUnc,
isAbsolute: isUnc || !!result[2], // UNC paths are always absolute
tail: result[3]
}
}
exports.isAbsolute = typeof path.isAbsolute === 'function' ? path.isAbsolute : function utilIsAbsolute (path) {
if (isWindows) {
return win32StatPath(path).isAbsolute
}
return !!path && path[0] === '/'
}

View File

@@ -0,0 +1 @@
node_modules/mocha

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.6
- 0.8

View File

@@ -0,0 +1,27 @@
Copyright © 2011-2012, Paul Vorbach.
Copyright © 2009, Jeff Mott.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name Crypto-JS nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,108 @@
# MD5
[![build status](https://secure.travis-ci.org/pvorb/node-md5.png)](http://travis-ci.org/pvorb/node-md5)
a JavaScript function for hashing messages with MD5.
## Installation
You can use this package on the server side as well as the client side.
### [Node.js](http://nodejs.org/):
~~~
npm install md5
~~~
## API
~~~ javascript
md5(message)
~~~
* `message` -- `String` or `Buffer`
* returns `String`
## Usage
~~~ javascript
var md5 = require('md5');
console.log(md5('message'));
~~~
This will print the following
~~~
78e731027d8fd50ed642340b7c9a63b3
~~~
It supports buffers, too
~~~ javascript
var fs = require('fs');
var md5 = require('md5');
fs.readFile('example.txt', function(err, buf) {
console.log(md5(buf));
});
~~~
## Versions
Before version 2.0.0 there were two packages called md5 on npm, one lowercase,
one uppercase (the one you're looking at). As of version 2.0.0, all new versions
of this module will go to lowercase [md5](https://www.npmjs.com/package/md5) on
npm. To use the correct version, users of this module will have to change their
code from `require('MD5')` to `require('md5')` if they want to use versions >=
2.0.0.
## Bugs and Issues
If you encounter any bugs or issues, feel free to open an issue at
[github](https://github.com/pvorb/node-md5/issues).
## Credits
This package is based on the work of Jeff Mott, who did a pure JS implementation
of the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a
npm package of the algorithm, so I used Jeffs implementation for this package.
The original implementation can be found in the
[CryptoJS](http://code.google.com/p/crypto-js/) project.
## License
~~~
Copyright © 2011-2015, Paul Vorbach.
Copyright © 2009, Jeff Mott.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name Crypto-JS nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
~~~

View File

@@ -0,0 +1,160 @@
(function(){
var crypt = require('crypt'),
utf8 = require('charenc').utf8,
isBuffer = require('is-buffer'),
bin = require('charenc').bin,
// The core
md5 = function (message, options) {
// Convert to byte array
if (message.constructor == String)
if (options && options.encoding === 'binary')
message = bin.stringToBytes(message);
else
message = utf8.stringToBytes(message);
else if (isBuffer(message))
message = Array.prototype.slice.call(message, 0);
else if (!Array.isArray(message))
message = message.toString();
// else, assume byte array already
var m = crypt.bytesToWords(message),
l = message.length * 8,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878;
// Swap endian
for (var i = 0; i < m.length; i++) {
m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
}
// Padding
m[l >>> 5] |= 0x80 << (l % 32);
m[(((l + 64) >>> 9) << 4) + 14] = l;
// Method shortcuts
var FF = md5._ff,
GG = md5._gg,
HH = md5._hh,
II = md5._ii;
for (var i = 0; i < m.length; i += 16) {
var aa = a,
bb = b,
cc = c,
dd = d;
a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
c = FF(c, d, a, b, m[i+10], 17, -42063);
b = FF(b, c, d, a, m[i+11], 22, -1990404162);
a = FF(a, b, c, d, m[i+12], 7, 1804603682);
d = FF(d, a, b, c, m[i+13], 12, -40341101);
c = FF(c, d, a, b, m[i+14], 17, -1502002290);
b = FF(b, c, d, a, m[i+15], 22, 1236535329);
a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
c = GG(c, d, a, b, m[i+11], 14, 643717713);
b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
d = GG(d, a, b, c, m[i+10], 9, 38016083);
c = GG(c, d, a, b, m[i+15], 14, -660478335);
b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
d = GG(d, a, b, c, m[i+14], 9, -1019803690);
c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
a = GG(a, b, c, d, m[i+13], 5, -1444681467);
d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
b = GG(b, c, d, a, m[i+12], 20, -1926607734);
a = HH(a, b, c, d, m[i+ 5], 4, -378558);
d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
c = HH(c, d, a, b, m[i+11], 16, 1839030562);
b = HH(b, c, d, a, m[i+14], 23, -35309556);
a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
b = HH(b, c, d, a, m[i+10], 23, -1094730640);
a = HH(a, b, c, d, m[i+13], 4, 681279174);
d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
d = HH(d, a, b, c, m[i+12], 11, -421815835);
c = HH(c, d, a, b, m[i+15], 16, 530742520);
b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
a = II(a, b, c, d, m[i+ 0], 6, -198630844);
d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
c = II(c, d, a, b, m[i+14], 15, -1416354905);
b = II(b, c, d, a, m[i+ 5], 21, -57434055);
a = II(a, b, c, d, m[i+12], 6, 1700485571);
d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
c = II(c, d, a, b, m[i+10], 15, -1051523);
b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
d = II(d, a, b, c, m[i+15], 10, -30611744);
c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
b = II(b, c, d, a, m[i+13], 21, 1309151649);
a = II(a, b, c, d, m[i+ 4], 6, -145523070);
d = II(d, a, b, c, m[i+11], 10, -1120210379);
c = II(c, d, a, b, m[i+ 2], 15, 718787259);
b = II(b, c, d, a, m[i+ 9], 21, -343485551);
a = (a + aa) >>> 0;
b = (b + bb) >>> 0;
c = (c + cc) >>> 0;
d = (d + dd) >>> 0;
}
return crypt.endian([a, b, c, d]);
};
// Auxiliary functions
md5._ff = function (a, b, c, d, x, s, t) {
var n = a + (b & c | ~b & d) + (x >>> 0) + t;
return ((n << s) | (n >>> (32 - s))) + b;
};
md5._gg = function (a, b, c, d, x, s, t) {
var n = a + (b & d | c & ~d) + (x >>> 0) + t;
return ((n << s) | (n >>> (32 - s))) + b;
};
md5._hh = function (a, b, c, d, x, s, t) {
var n = a + (b ^ c ^ d) + (x >>> 0) + t;
return ((n << s) | (n >>> (32 - s))) + b;
};
md5._ii = function (a, b, c, d, x, s, t) {
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
return ((n << s) | (n >>> (32 - s))) + b;
};
// Package private blocksize
md5._blocksize = 16;
md5._digestsize = 16;
module.exports = function (message, options) {
if (message === undefined || message === null)
throw new Error('Illegal argument ' + message);
var digestbytes = crypt.wordsToBytes(md5(message, options));
return options && options.asBytes ? digestbytes :
options && options.asString ? bin.bytesToString(digestbytes) :
crypt.bytesToHex(digestbytes);
};
})();

View File

@@ -0,0 +1,36 @@
{
"name": "md5",
"description": "js function for hashing messages with MD5",
"version": "2.2.1",
"author": "Paul Vorbach <paul@vorba.ch> (http://paul.vorba.ch)",
"contributors": [
"salba"
],
"tags": [
"md5",
"hash",
"encryption",
"message digest"
],
"repository": {
"type": "git",
"url": "git://github.com/pvorb/node-md5.git"
},
"bugs": {
"url": "https://github.com/pvorb/node-md5/issues"
},
"main": "md5.js",
"scripts": {
"test": "mocha"
},
"dependencies": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
"is-buffer": "~1.1.1"
},
"devDependencies": {
"mocha": "~2.3.4"
},
"optionalDependencies": {},
"license": "BSD-3-Clause"
}

View File

@@ -0,0 +1,45 @@
var md5 = require('./md5.js');
var assert = require('assert');
describe('md5', function () {
it('should throw an error for `undefined`', function() {
assert.throws(function() {
md5(undefined);
});
});
it('should throw an error for `null`', function() {
assert.throws(function() {
md5(null);
});
});
it('should return the expected MD5 hash for "message"', function() {
assert.equal('78e731027d8fd50ed642340b7c9a63b3', md5('message'));
});
it('should not return the same hash for random numbers twice', function() {
var msg1 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
var msg2 = Math.floor((Math.random() * 100000) + 1) + (new Date).getTime();
if (msg1 !== msg2) {
assert.notEqual(md5(msg1), md5(msg2));
} else {
assert.equal(md5(msg1), md5(msg1));
}
});
it('should support Node.js Buffers', function() {
var buffer = new Buffer('message áßäöü', 'utf8');
assert.equal(md5(buffer), md5('message áßäöü'));
})
it('should be able to use a binary encoded string', function() {
var hash1 = md5('abc', { asString: true });
var hash2 = md5(hash1 + 'a', { asString: true, encoding : 'binary' });
var hash3 = md5(hash1 + 'a', { encoding : 'binary' });
assert.equal(hash3, '131f0ac52813044f5110e4aec638c169');
});
});

View File

@@ -0,0 +1,53 @@
{
"author": {
"name": "Bojan D.",
"email": "dbojan@gmail.com"
},
"name": "json-schema-deref-sync",
"description": "Simple Node.js JSON Schema dereferencer",
"keywords": [
"json",
"schema",
"deref"
],
"version": "0.13.0",
"homepage": "https://github.com/bojand/json-schema-deref-sync",
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/bojand/json-schema-deref-sync.git"
},
"bugs": {
"url": "http://github.com/bojand/json-schema-deref-sync/issues"
},
"engines": {
"node": ">=6.0.0"
},
"main": "lib/index.js",
"dependencies": {
"clone": "^2.1.2",
"dag-map": "~1.0.0",
"is-valid-path": "^0.1.1",
"lodash": "^4.17.13",
"md5": "~2.2.0",
"memory-cache": "~0.2.0",
"traverse": "~0.6.6",
"valid-url": "~1.0.9"
},
"devDependencies": {
"async": "^2.6.2",
"chai": "^4.2.0",
"fs.extra": "~1.3.2",
"js-yaml": "^3.13.1",
"jsdoc-to-markdown": "^4.0.0",
"mocha": "^6.1.4",
"standard": "~12.0.0"
},
"scripts": {
"test": "mocha",
"docs": "jsdoc2md \"lib/**/*.js\" --template readme.hbs > README.md"
},
"directories": {
"test": "test"
}
}

View File

@@ -0,0 +1,93 @@
# json-schema-deref-sync
[![npm version](https://img.shields.io/npm/v/json-schema-deref-sync.svg?style=flat-square)](https://www.npmjs.com/package/json-schema-deref-sync)
[![build status](https://img.shields.io/travis/bojand/json-schema-deref-sync/master.svg?style=flat-square)](https://travis-ci.org/bojand/json-schema-deref-sync)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![License](https://img.shields.io/github/license/bojand/json-schema-deref-sync.svg?style=flat-square)](https://raw.githubusercontent.com/bojand/json-schema-deref-sync/master/LICENSE)
Dereference JSON pointers in a JSON schemas with their true resolved values.
Basically a lighter, synchronous version of [json-schema-deref](https://github.com/bojand/json-schema-deref) but omits web references.
## Installation
`npm install json-schema-deref-sync`
## Overview
Let's say you have the following JSON Schema:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"$ref": "#/definitions/id"
},
"foo": {
"$ref": "http://www.mysite.com/myschema.json#/definitions/foo"
},
"bar": {
"$ref": "bar.json"
}
}
}
```
Sometimes you just want that schema to be fully expanded, with `$ref`'s being their (true) resolved values:
```json
{
"description": "Just some JSON schema.",
"title": "Basic Widget",
"type": "object",
"definitions": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
}
},
"properties": {
"id": {
"description": "unique identifier",
"type": "string",
"minLength": 1,
"readOnly": true
},
"foo": {
"description": "foo property",
"readOnly": true,
"type": "number"
},
"bar": {
"description": "bar property",
"type": "boolean"
}
}
}
```
This utility lets you do that:
```js
var deref = require('json-schema-deref-sync');
var myschema = require('schema.json');
var fullSchema = deref(myschema);
```
## API Reference
{{>all-docs~}}