///
import Long from "long";
import { BehaviorSubject } from "rxjs";
import { InstanceID } from "@dedis/cothority/byzcoin";
import { Credential, CredentialStruct } from "@dedis/cothority/byzcoin/contracts";
import { Point } from "@dedis/kyber";
import { SpawnerTransactionBuilder } from "./spawnerTransactionBuilder";
/**
* The CredentialStructBS is the main part of a user-account in ByzCoin.
* It references all other instances that are available to the user.
* This class and its subclasses only hold data that can be interpreted without having to look up something on the
* chain.
* For example, the `credDevices` only holds the `InstanceID`s that point to the devices available by this credential.
* The devices themselves are only available through the `CredentialSignerBS` class, which is referenced in `User`.
*
* The credential has a 2-level storage system, that has been arbitrarily chosen to hold the following data:
* - public: holds all data about the user that is publicly available. Most of it can be empty.
* - config: some configuration data used by the front-end
* - devices: implements the naming system to point to all DARCs that have access to this credential
* - recoveries: points to all DARCs that have the right to do a recovery of access to this credential
* - calypso: a list of all calypso instances held by this credential
*/
export declare class CredentialStructBS extends BehaviorSubject {
readonly id: InstanceID;
readonly darcID: InstanceID;
static readonly structVersionLatest = 2;
static readonly urlRegistered = "https://qrcode.c4dt.org/registered";
static readonly urlUnregistered = "https://qrcode.c4dt.org/unregistered";
credPublic: CredentialPublic;
credConfig: CredentialConfig;
credDevices: CredentialInstanceMapBS;
credRecoveries: CredentialInstanceMapBS;
credCalypso: CredentialInstanceMapBS;
constructor(id: InstanceID, darcID: InstanceID, credBS: BehaviorSubject);
getCredentialBS(name: ECredentials): CredentialBS;
/**
* updateCredentials sets all new credentials given in 'cred'.
* If a value of a Credential is empty, it will be deleted.
*
* @param tx
* @param cred
*/
updateCredential(tx: SpawnerTransactionBuilder, ...cred: IUpdateCredential[]): void;
setCredential(tx: SpawnerTransactionBuilder, cred: Credential): void;
setCredentialStruct(tx: SpawnerTransactionBuilder, credStruct: CredentialStruct): void;
getCredentialInstanceMapBS(name: ECredentials): CredentialInstanceMapBS;
}
export declare class CredentialBS extends BehaviorSubject {
private csbs;
private cred;
static fromScratch(csbs: CredentialStructBS, name: ECredentials): CredentialBS;
private static getAttribute;
constructor(csbs: CredentialStructBS, cred: ECredentials, cbs: BehaviorSubject);
getAttributeBufferBS(name: string): AttributeBufferBS;
getAttributeStringBS(name: string): AttributeStringBS;
getAttributeLongBS(name: string): AttributeLongBS;
getAttributePointBS(name: string): AttributePointBS;
getAttributeBoolBS(name: string): AttributeBoolBS;
getAttributeNumberBS(name: string): AttributeNumberBS;
getAttributeInstanceSetBS(name: string): AttributeInstanceSetBS;
setValue(tx: SpawnerTransactionBuilder, attr: string, value: string | Buffer): void;
rmValue(tx: SpawnerTransactionBuilder, attr: string): void;
set(tx: SpawnerTransactionBuilder, cred: Credential): void;
private getAttributeBS;
}
export declare class CredentialInstanceMapBS extends BehaviorSubject {
private cbs;
static fromScratch(cbs: CredentialBS): CredentialInstanceMapBS;
constructor(cbs: CredentialBS, bsim: BehaviorSubject);
setInstanceMap(tx: SpawnerTransactionBuilder, val: InstanceMap): void;
setEntry(tx: SpawnerTransactionBuilder, name: string, id: Buffer): void;
rmEntry(tx: SpawnerTransactionBuilder, id: Buffer): void;
hasEntry(id: Buffer): boolean;
getEntry(id: Buffer): string;
}
export declare class AttributeBufferBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bsb: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: Buffer): void;
}
export declare class AttributeStringBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bss: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: string): void;
}
export declare class AttributeLongBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bss: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: Long): void;
}
export declare class AttributePointBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bss: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: Point): void;
}
export declare class AttributeBoolBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bss: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: boolean): void;
}
export declare class AttributeNumberBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bss: BehaviorSubject, name: string);
setValue(tx: SpawnerTransactionBuilder, val: number): void;
}
export declare class AttributeInstanceSetBS extends BehaviorSubject {
private cbs;
private name;
constructor(cbs: CredentialBS, bsis: BehaviorSubject, name: string);
setInstanceSet(tx: SpawnerTransactionBuilder, val: InstanceSet): void;
}
/**
*
*/
export declare class CredentialPublic {
contacts: AttributeInstanceSetBS;
alias: AttributeStringBS;
email: AttributeStringBS;
coinID: AttributeBufferBS;
seedPub: AttributeBufferBS;
phone: AttributeStringBS;
actions: AttributeInstanceSetBS;
groups: AttributeInstanceSetBS;
url: AttributeStringBS;
challenge: AttributeLongBS;
personhood: AttributePointBS;
subscribe: AttributeBoolBS;
snacked: AttributeBoolBS;
version: AttributeNumberBS;
constructor(cbs: CredentialBS);
}
export declare class CredentialConfig {
view: AttributeStringBS;
spawnerID: AttributeBufferBS;
structVersion: AttributeNumberBS;
ltsID: AttributeBufferBS;
ltsX: AttributePointBS;
constructor(cbs: CredentialBS);
}
export declare class InstanceSet {
static splitList(contacts: Buffer | Credential | null | undefined): Buffer[];
readonly set: Set;
constructor(contacts: Buffer | Credential | null | undefined);
toBuffer(): Buffer;
toInstanceIDs(): InstanceID[];
add(contact: InstanceID | string): InstanceSet;
rm(contact: InstanceID | string): InstanceSet;
has(contact: InstanceID | string): boolean;
}
export declare class InstanceMap {
private cred?;
map: Map;
constructor(cred?: Credential);
toCredential(): Credential;
toInstanceIDs(): InstanceID[];
toKVs(): IInstanceMapKV[];
}
export interface IInstanceMapKV {
key: Buffer;
value: string;
}
export declare enum ECredentials {
pub = "1-public",
config = "1-config",
devices = "1-devices",
recoveries = "1-recovery",
calypso = "1-calypso"
}
export declare enum EAttributesPublic {
contacts = "contactsBuf",
alias = "alias",
email = "email",
coinID = "coin",
seedPub = "seedPub",
phone = "phone",
actions = "actions",
groups = "groups",
url = "url",
challenge = "challenge",
personhood = "personhood",
subscribe = "subscribe",
snacked = "snacked",
version = "version"
}
export declare enum EAttributesConfig {
view = "view",
spawner = "spawner",
structVersion = "structVersion",
ltsID = "ltsID",
ltsX = "ltsX"
}
export interface IUpdateCredential {
cred: ECredentials;
attr: EAttributesPublic | EAttributesConfig | string;
value: string | Buffer | undefined;
}