1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { Template } from "./template.js"
export enum Scope {
AUTHENTICATION = "Authentication",
IDENTIFICATION = "Identification",
RECOVERY = "Recovery",
}
export function defaultTemplate(s: Scope): Template {
switch (s) {
case Scope.AUTHENTICATION:
return Template.LONG
case Scope.IDENTIFICATION:
return Template.NAME
case Scope.RECOVERY:
return Template.MAXIMUM
}
}
export interface Scoper {
scope(s: Scope): string;
}
export class SimpleScoper implements Scoper {
private key: string
constructor(key: string) {
this.key = key
}
scope(s: Scope): string {
switch (s) {
case Scope.AUTHENTICATION:
return this.key
case Scope.IDENTIFICATION:
return `${this.key}.login`
case Scope.RECOVERY:
return `${this.key}.answer`
}
}
}
export const defaultScoper: Scoper = new SimpleScoper(
"com.lyndir.masterpassword",
)
|