feat: Passwordless cross-device authentication

- Arkitektur: docs/auth/passwordless-architecture.md
- Backend: iom/quixzoom-auth-service/ (FastAPI + Redis)
- Webb: quixzoom-market-pages/se/login/ (QR-kod + polling)
- App: iom/quixzoom-app/src/features/auth/ (push + deep links)

Flöde: QR-kod → app-godkännande → webb-inloggad
This commit is contained in:
Bernt
2026-07-07 07:11:50 +00:00
parent 4aa984ad74
commit 6989a98d75
61843 changed files with 5491611 additions and 872231 deletions
+21
View File
@@ -0,0 +1,21 @@
{
"checkbuild": {
"enable": ["jshint", "jsinspect", "nsp", "david"],
// don't exit immediately if one of the tools reports an error
"continueOnError": true,
// don't exit(1) even if we had some failures
"allowFailures": false
},
"jshint": {
"args": ["**/*.js", "!*node_modules/**", "!*example/**"]
},
"jsinspect": {
"args": ["**/*.js", "!*node_modules/**", "!*example/**", "!*tests/**"],
"diff": true,
"threshold": 40
},
"david":{
"stable": true
},
"nsp": {}
}
+27
View File
@@ -0,0 +1,27 @@
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- run: npm run build --if-present
- run: npm test
+16
View File
@@ -0,0 +1,16 @@
{
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 4,
"space_in_paren": false,
"jslint_happy": true,
"brace_style": "collapse",
"keep_array_indentation": true,
"keep_function_indentation": true,
"eval_code": false,
"unescape_strings": false,
"break_chained_methods": false,
"e4x": false,
"wrap_line_length": 0,
"format_on_save": true
}
+130
View File
@@ -0,0 +1,130 @@
{
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"indent" : 2, // {int} Number of spaces to use for indentation
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` & `--`
"quotmark" : false, // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // true: Require all defined variables be used
"strict" : false, // true: Requires all functions run in ES5 Strict Mode
"trailing" : false, // true: Prohibit trailing whitespaces
"maxparams" : 5, // {int} Max number of formal params allowed per function
"maxdepth" : 4, // {int} Max depth of nested blocks (within functions)
"maxstatements" : 25, // {int} Max number statements per function
"maxcomplexity" : 7, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements"
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : true, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function
// Environments
"browser" : true, // Web Browser (window, document, etc)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jquery" : false, // jQuery
"mootools" : false, // MooTools
"node" : true, // Node.js
"mocha" : true, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"prototypejs" : false, // Prototype and Scriptaculous
"rhino" : false, // Rhino
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface
// Legacy
"nomen" : false, // true: Prohibit dangling `_` in variables
"onevar" : false, // true: Allow only one `var` statement per function
"passfail" : false, // true: Stop on first error
"white" : false, // true: Check against strict whitespace and indentation rules
// Custom Globals
"predef" : [
"Buffer",
"view",
"test",
"factoryKey",
"RedisStub",
"equal",
"strictEqual",
"ok",
"expect",
"checkGrid",
"module",
"prompt",
"require",
"exports",
"console",
"__dirname",
"process",
"setInterval",
"setTimeout",
"clearTimeout",
"Redsmin",
"window",
"Backbone",
"bootbox",
"Highcharts",
"ReadLine",
"CodeMirror",
"$",
"jQuery",
"document",
"io",
"Pound",
"alert",
"grunt",
"escape",
"ifAvailableThenCall",
"ifAvailableThenCallOr",
"walk",
"returnfalse",
"forEachAsync",
"humanize",
"Mousetrap",
"store",
"Slick",
"Slickback"] // additional predefined global variables
}
+44
View File
@@ -0,0 +1,44 @@
var module_exist = require('node-module_exist'),
redis_info = require('../')
// Default fallback
,
redis = {
info: function (cb) {
cb(null, 'redis_version:2.4.10\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\narch_bits:64\r\nmultiplexing_api:kqueue\r\ngcc_version:4.2.1\r\nprocess_id:3961\r\nuptime_in_seconds:1040648\r\nuptime_in_days:12\r\nlru_clock:44167\r\nused_cpu_sys:64.06\r\nused_cpu_user:84.21\r\nused_cpu_sys_children:0.15\r\nused_cpu_user_children:0.73\r\nconnected_clients:5\r\nconnected_slaves:0\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0\r\nused_memory:15088992\r\nused_memory_human:14.39M\r\nused_memory_rss:21258240\r\nused_memory_peak:18985904\r\nused_memory_peak_human:18.11M\r\nmem_fragmentation_ratio:1.41\r\nmem_allocator:libc\r\nloading:0\r\naof_enabled:0\r\nchanges_since_last_save:0\r\nbgsave_in_progress:0\r\nlast_save_time:1341952654\r\nbgrewriteaof_in_progress:0\r\ntotal_connections_received:2069\r\ntotal_commands_processed:8897\r\nexpired_keys:0\r\nevicted_keys:0\r\nkeyspace_hits:2554\r\nkeyspace_misses:0\r\npubsub_channels:2\r\npubsub_patterns:0\r\nlatest_fork_usec:851\r\nvm_enabled:0\r\nrole:master\r\ndb0:keys=27012,expires=18\r\ndb15:keys=1,expires=0\r\n');
},
end: function () {}
};
if (module_exist('redis')) {
redis = require('redis').createClient();
}
/**
* Helpers
*/
function join(sep) {
return function (v) {
return v.join(sep);
};
};
function printDatabase(v) {
return Object.keys(v).map(function (key) {
return key + ': ' + v[key];
}).join('\n') + "\n___________\n";
}
function print(array, mapper) {
return '\n' + array.map(mapper).join('\n');
}
redis.info(function (err, info) {
redis.end();
var info = redis_info.parse(info);
console.log('\n-- .contains(\'memory\')', print(info.contains('memory'), join(':')));
console.log('\n-- .databases.length\n', info.databases.length);
console.log('\n-- .databases', print(info.databases, printDatabase));
});
+117
View File
@@ -0,0 +1,117 @@
'use strict';
var _ = require('lodash');
module.exports = {
parse: function (info) {
return parseFields(splitStr(info));
}
};
function startWith(pattern) {
return function (value) {
return value.indexOf(pattern) === 0;
};
}
function split(s) {
return function (v) {
return v.split(s);
};
}
function orEmptyStr(v) {
return v || '';
}
function takeN(func, n) {
return function (v) {
return func(v[n]);
};
}
function takeFirst(func) {
return takeN(func, 0);
}
/**
* Split the info string by \n and :
* @param {String} str the returned redis info
* @return {Array} Array of [key, value]
*/
function splitStr(str) {
return str.split('\n')
.filter(function (line) {
return line.length > 0 && line.indexOf('#') !== 0;
})
.map(function (line) {
return line.trim().split(':');
});
}
function parseDatabases(info) {
return info
.filter(takeFirst(startWith('db')))
.map(function _parseDatabaseInfo(args) {
var dbName = args[0];
var value = args[1];
var values = orEmptyStr(value).split(',');
function extract(param) {
return parseInt(orEmptyStr(_.find(values, startWith(param))).split('=')[1] || 0, 10);
}
return {
index: parseInt(dbName.substr(2), 10),
keys: extract('keys'),
expires: extract('expires'),
avg_ttl: extract('avg_ttl')
};
})
.reduce(function (m, v) {
m[v.index] = {
keys: v.keys,
expires: v.expires,
avg_ttl: v.avg_ttl
};
return m;
}, {});
}
function parseCommands(info) {
return _.fromPairs(info.filter(function (a) {
return orEmptyStr(a[0]).indexOf('cmdstat_') === 0;
})
.map(function _parseCommands(args) {
var v = args[0];
var a = args[1];
var val = _.fromPairs(orEmptyStr(a).split(',').map(split('=')));
if (_.has(val, 'calls')) {
val.calls = parseInt(val.calls, 10);
}
if (_.has(val, 'usec')) {
val.usec = parseInt(val.usec, 10);
}
if (_.has(val, 'usec_per_call')) {
val.usec_per_call = parseFloat(val.usec_per_call, 10);
}
return [orEmptyStr(v).split('_')[1], val];
}));
}
function parseFields(info) {
var fields = info.reduce(function (m, v) {
if (!v[0].trim() || v[0].indexOf('db') === 0 ||  v[0].indexOf('cmdstat_') === 0) {
return m;
}
m[v[0]] = v.slice(1).join(':');
return m;
}, {
databases: parseDatabases(info),
commands: parseCommands(info)
});
return fields;
}
+26
View File
@@ -0,0 +1,26 @@
{
"name": "redis-info",
"version": "3.1.0",
"description": "Info output parser for Redis",
"repository": {
"type": "git",
"url": "https://github.com/FGRibreau/node-redis-info.git"
},
"main": "index.js",
"scripts": {
"test": "mocha test/*.test.js"
},
"author": {
"name": "Francois-Guillaume Ribreau",
"url": "https://fgribreau.com/"
},
"license": "MIT",
"devDependencies": {
"chai": "^2.0.0",
"mocha": "^6.0.2",
"node-module_exist": "0.0.x"
},
"dependencies": {
"lodash": "^4.17.11"
}
}
+51
View File
@@ -0,0 +1,51 @@
# Redis-info
[![Node.js CI](https://github.com/FGRibreau/node-redis-info/actions/workflows/ci.yaml/badge.svg)](https://github.com/FGRibreau/node-redis-info/actions/workflows/ci.yaml) [![Deps](https://img.shields.io/david/FGRibreau/node-redis-info.svg)](https://david-dm.org/FGRibreau/node-redis-info) [![NPM version](https://img.shields.io/npm/v/redis-info.svg)](https://www.npmjs.com/package/redis-info) [![Downloads](http://img.shields.io/npm/dm/redis-info.svg)](https://www.npmjs.com/package/redis-info) [![Slack](https://img.shields.io/badge/Slack-Join%20our%20tech%20community-17202A?logo=slack)](https://join.slack.com/t/fgribreau/shared_invite/zt-edpjwt2t-Zh39mDUMNQ0QOr9qOj~jrg)
Overview
--------
Redis info string parser
Npm
------------
```bash
npm install redis-info
```
Usage
--------
```
> const info = require('redis-info').parse("redis_version:2.4.10\nredis_git_sha1:00000000\nredis_git_dirty:0\narch_bits:64\n ...");
undefined
> info.redis_version
2.4.10
> info.redis_git_dirty
0
```
## Donate
[Donate Bitcoins](https://coinbase.com/checkouts/fc3041b9d8116e0b98e7d243c4727a30)
License
-------
Copyright (c) 2019 Francois-Guillaume Ribreau (npm@fgribreau.com)
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.
+7
View File
@@ -0,0 +1,7 @@
'use strict';
module.exports = {
parsed_info_output: require('./parsed_info_output'),
info: "# Server\n\n\nredis_version:2.4.10\nredis_git_sha1:00000000\nredis_git_dirty:0\narch_bits:64\nmultiplexing_api:kqueue\ngcc_version:4.2.1\nprocess_id:3961\nuptime_in_seconds:681311\nuptime_in_days:7\nlru_clock:8233\nused_cpu_sys:45.19\nused_cpu_user:59.74\nused_cpu_sys_children:0.15\nused_cpu_user_children:0.73\nconnected_clients:4\nconnected_slaves:0\nclient_longest_output_list:0\nclient_biggest_input_buf:0\nblocked_clients:0\nused_memory:15080416\nused_memory_human:14.38M\nused_memory_rss:21258240\nused_memory_peak:18985904\nused_memory_peak_human:18.11M\nmem_fragmentation_ratio:1.41\nmem_allocator:libc\nloading:0\naof_enabled:0\nchanges_since_last_save:0\nbgsave_in_progress:0\nlast_save_time:1341952654\nbgrewriteaof_in_progress:0\ntotal_connections_received:1501\ntotal_commands_processed:8325\nexpired_keys:0\nevicted_keys:0\nkeyspace_hits:2554\nkeyspace_misses:0\npubsub_channels:2\npubsub_patterns:0\nlatest_fork_usec:851\nvm_enabled:0\nrole:master\ndb0:keys=27012,expires=18,avg_ttl=149384827\ndb15:keys=1,expires=0",
info_2_6: "redis_version:2.6.10\r\nredis_git_sha1:00000000\r\nredis_git_dirty:0\r\narch_bits:64\r\nmultiplexing_api:epoll\r\ngcc_version:4.4.5\r\nprocess_id:4094\r\nuptime_in_seconds:32\r\nuptime_in_days:0\r\nlru_clock:1474263\r\nused_cpu_sys:0.00\r\nused_cpu_user:0.05\r\nused_cpu_sys_children:0.00\r\nused_cpu_user_children:0.00\r\nconnected_clients:1\r\nconnected_slaves:0\r\nclient_longest_output_list:0\r\nclient_biggest_input_buf:0\r\nblocked_clients:0\r\nused_memory:846904\r\nused_memory_human:827.05K\r\nused_memory_rss:1679360\r\nused_memory_peak:846864\r\nused_memory_peak_human:827.02K\r\nmem_fragmentation_ratio:1.98\r\nmem_allocator:libc\r\nloading:0\r\naof_enabled:0\r\nchanges_since_last_save:0\r\nbgsave_in_progress:0\r\nlast_save_time:1377891405\r\nbgrewriteaof_in_progress:0\r\ntotal_connections_received:1\r\ntotal_commands_processed:2\r\nexpired_keys:0\r\nevicted_keys:0\r\nkeyspace_hits:0\r\nkeyspace_misses:0\r\npubsub_channels:0\r\npubsub_patterns:0\r\nlatest_fork_usec:0\r\nvm_enabled:0\r\nrole:master\r\ndb0:keys=13,expires=12\r\n",
info_cmds: "# Commandstats\r\ncmdstat_set:calls=1,usec=15,usec_per_call=15.00\r\ncmdstat_lpush:calls=1,usec=14,usec_per_call=14.00\r\ncmdstat_zadd:calls=2,usec=84,usec_per_call=42.00\r\ncmdstat_hset:calls=1,usec=26,usec_per_call=26.00\r\ncmdstat_keys:calls=2,usec=91,usec_per_call=45.50\r\ncmdstat_info:calls=5,usec=807,usec_per_call=161.40\r\ncmdstat_ttl:calls=1,usec=6,usec_per_call=6.00\r\ncmdstat_slowlog:calls=4,usec=47,usec_per_call=11.75\r\n"
};
+100
View File
@@ -0,0 +1,100 @@
'use strict';
module.exports = {
redis_version: '2.4.10',
redis_git_sha1: '00000000',
redis_git_dirty: '0',
arch_bits: '64',
multiplexing_api: 'kqueue',
gcc_version: '4.2.1',
process_id: '3961',
uptime_in_seconds: '681311',
uptime_in_days: '7',
lru_clock: '8233',
used_cpu_sys: '45.19',
used_cpu_user: '59.74',
used_cpu_sys_children: '0.15',
used_cpu_user_children: '0.73',
connected_clients: '4',
connected_slaves: '0',
client_longest_output_list: '0',
client_biggest_input_buf: '0',
blocked_clients: '0',
used_memory: '15080416',
used_memory_human: '14.38M',
used_memory_rss: '21258240',
used_memory_peak: '18985904',
used_memory_peak_human: '18.11M',
mem_fragmentation_ratio: '1.41',
mem_allocator: 'libc',
loading: '0',
aof_enabled: '0',
changes_since_last_save: '0',
bgsave_in_progress: '0',
last_save_time: '1341952654',
bgrewriteaof_in_progress: '0',
total_connections_received: '1501',
total_commands_processed: '8325',
expired_keys: '0',
evicted_keys: '0',
keyspace_hits: '2554',
keyspace_misses: '0',
pubsub_channels: '2',
pubsub_patterns: '0',
latest_fork_usec: '851',
vm_enabled: '0',
role: 'master',
databases: {
'0': {
keys: 27012,
expires: 18,
avg_ttl: 149384827
},
'15': {
keys: 1,
expires: 0,
avg_ttl: 0
}
},
commands: {
set: {
calls: 1,
usec: 15,
usec_per_call: 15
},
lpush: {
calls: 1,
usec: 14,
usec_per_call: 14
},
zadd: {
calls: 2,
usec: 84,
usec_per_call: 42
},
hset: {
calls: 1,
usec: 26,
usec_per_call: 26
},
keys: {
calls: 2,
usec: 91,
usec_per_call: 45.5
},
info: {
calls: 5,
usec: 807,
usec_per_call: 161.4
},
ttl: {
calls: 1,
usec: 6,
usec_per_call: 6
},
slowlog: {
calls: 4,
usec: 47,
usec_per_call: 11.75
}
}
};
+33
View File
@@ -0,0 +1,33 @@
'use strict';
var t = require('chai').assert;
var redis_info = require('../');
var fix = require('./fixtures');
describe('redis-info', function () {
describe('.parse', function () {
it('should parse an info str to an object', function (done) {
var parser = redis_info.parse(fix.info + fix.info_cmds);
t.deepEqual(parser, fix.parsed_info_output);
done();
});
it('should handle field values containing the colon character', function (done) {
var parsedInfo = redis_info.parse('# Server\r\nconfig_file:Y:\\redis\\redis.conf\r\n');
t.isObject(parsedInfo);
t.equal(parsedInfo.config_file, 'Y:\\redis\\redis.conf');
done();
});
it('should return an empty DB if the database keys are not defined', function (done) {
var parser = redis_info.parse("db0\r\n");
t.deepEqual(parser.databases, {
'0': {
keys: 0,
expires: 0,
avg_ttl: 0
}
});
done();
});
});
});