6989a98d75
- 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
28 lines
533 B
JavaScript
28 lines
533 B
JavaScript
import {Base} from './Base.js';
|
|
|
|
export class Enum extends Base {
|
|
constructor(type, options = []) {
|
|
super();
|
|
this.type = type;
|
|
this.options = options;
|
|
}
|
|
|
|
decode(stream) {
|
|
const index = this.type.decode(stream);
|
|
return this.options[index] || index;
|
|
}
|
|
|
|
size() {
|
|
return this.type.size();
|
|
}
|
|
|
|
encode(stream, val) {
|
|
const index = this.options.indexOf(val);
|
|
if (index === -1) {
|
|
throw new Error(`Unknown option in enum: ${val}`);
|
|
}
|
|
|
|
return this.type.encode(stream, index);
|
|
}
|
|
}
|