Page MenuHomeSealhub

secret-token.ts
No OneTemporary

secret-token.ts

import { Field, Context } from "../../../main";
import { v4 as uuid } from "uuid";
export default class SecretToken extends Field {
typeName = "secret-token";
isOldValueSensitive = () => true;
async isProperValue() {
return Field.valid();
}
async encode(_: Context, __: any, old_value: string) {
const ret = old_value ? old_value : uuid();
return ret;
}
async decode(context: Context, value: string) {
return context.is_super ? value : "it's a secret to everybody";
}
async getMatchQueryValue(context: Context, filter: unknown) {
if (context.is_super) {
return { $eq: filter };
} else {
return { $eq: "nice try" };
}
}
async getDefaultValue() {
return uuid();
}
}

File Metadata

Mime Type
text/x-java
Expires
Mon, Dec 23, 01:01 (2 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
556791
Default Alt Text
secret-token.ts (706 B)

Event Timeline