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
+100
View File
@@ -0,0 +1,100 @@
import assert from 'assert';
import {Optional, uint8, DecodeStream, EncodeStream} from 'restructure';
describe('Optional', function() {
describe('decode', function() {
it('should not decode when condition is falsy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, false);
assert.equal(optional.decode(stream), null);
assert.equal(stream.pos, 0);
});
it('should not decode when condition is a function and falsy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, function() { return false; });
assert.equal(optional.decode(stream), null);
assert.equal(stream.pos, 0);
});
it('should decode when condition is omitted', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8);
assert(optional.decode(stream) != null);
assert.equal(stream.pos, 1);
});
it('should decode when condition is truthy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, true);
assert(optional.decode(stream) != null);
assert.equal(stream.pos, 1);
});
it('should decode when condition is a function and truthy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, function() { return true; });
assert(optional.decode(stream) != null);
assert.equal(stream.pos, 1);
});
});
describe('size', function() {
it('should return 0 when condition is falsy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, false);
assert.equal(optional.size(), 0);
});
it('should return 0 when condition is a function and falsy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, function() { return false; });
assert.equal(optional.size(), 0);
});
it('should return given type size when condition is omitted', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8);
assert.equal(optional.size(), 1);
});
it('should return given type size when condition is truthy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, true);
assert.equal(optional.size(), 1);
});
it('should return given type size when condition is a function and truthy', function() {
const stream = new DecodeStream(new Uint8Array([0]));
const optional = new Optional(uint8, function() { return true; });
assert.equal(optional.size(), 1);
});
});
describe('encode', function() {
it('should not encode when condition is falsy', function() {
const optional = new Optional(uint8, false);
assert.deepEqual(optional.toBuffer(128), new Uint8Array(0));
});
it('should not encode when condition is a function and falsy', function() {
const optional = new Optional(uint8, function() { return false; });
assert.deepEqual(optional.toBuffer(128), new Uint8Array(0));
});
it('should encode when condition is omitted', function() {
const optional = new Optional(uint8);
assert.deepEqual(optional.toBuffer(128), new Uint8Array([128]));
});
it('should encode when condition is truthy', function() {
const optional = new Optional(uint8, true);
assert.deepEqual(optional.toBuffer(128), new Uint8Array([128]));
});
it('should encode when condition is a function and truthy', function() {
const optional = new Optional(uint8, function() { return true; });
assert.deepEqual(optional.toBuffer(128), new Uint8Array([128]));
});
});
});