export declare type DnsType = "regular" | "dashed"; export declare type Name = { name: string; dns: DnsType; }; export declare class HostComponent { name: string; dns: DnsType; key: string; generatedStart: number; generatedEnd: number; generatedType: string; generationContext: string | null; generationOrigin: string | null; serialPosition: number; constructor(name: string, dns: DnsType, key: string, generatedStart: number, generatedEnd: number, generatedType: string, generationContext: string | null, generationOrigin: string | null, serialPosition: number); combineWithParent(parent: HostComponent): string; } /** * Host templates are used to allocated new host names or store existing ones. * Host names can be allocated by their parent host using name generators. * * Virtual host names are seperated by "-" where networked host names are seperated by ".". * The reason for this is that https (ssl) certificates does not allow for deep wildcards such * that nested random host names is avoided. For example foo.bar.mydomain.com requires that * the name "bar" is known as a fixed name in the certificated whereas "foo" can be a wildcard. * The certificate may certify *.bar.mydomain.com but not *.*.mydomain.com. The burpa network * having deep nested hosts looks like "foo-bar.mycomain.com" rather than "foo.bar.mydomain.com". * Thus, "-" is not allowed in host names unless they are also reflected in the network DNS. * * A name generator is employed using the wildcard "*" character or using braces/brackets. * Curly braces are used to generate names that are easy to remember (like the name "dog") * based on an `origin` string. If the same origin string is provided to the name generator, * the same name will be returned provided that that name is available. If it is not available, * a second name is provided that is the same as previously provided second names (and so forth). * * By storing the origin in cookies or local storages or generating it from an unique identifier * of the device it is likely that a device will receive the same host name as it may have had * in the past. * * The bracket builds on the origin idea by providing a default origin based on the implementation. * For example, on browsers a random number stored in the local storage is used and on iOS devices * the vendor device id is used as the origin. To be able to create multiple origins that are stable, * the bracket allows a context for the origin to be used. The context can be thought of as the origin * of the origin. For example lets assume that the user spawns the two hosts * "[mycontext].burpa.net" and "[myothercontext].burpa.net" on a device * with the serial id "12345". The orgin will then become "12345_mycontext" for the first host and * "12345_myothercontext" for the second. The parent host "burpa.net" will then stably provide the * host names "dog.burpa.net" and "cat.burpa.net" if these names are available. * * Examples: * "{12345}.stockholm.burpa.net" * "[userbrowser]-acmecompany.heads.com" * "*.stockholm.burpa.net" * "foo*bar.polyjuice.com" */ export declare abstract class HostNameBase { port: string; nameTemplate: string; components: HostComponent[]; get parent(): string; isLocal(): boolean; isNameChar(char: string): boolean; isNumberChar(char: string): boolean; isDownstreamOf(parent: HostNameTemplate): boolean; static reconstruct(components: HostComponent[], port: string): string; getRoot(rootHostname: HostName, extra: number): HostName; get name(): string | null; get first(): HostComponent; get hosts(): Name[]; constructor(nameTemplate: string); resolveConstants(localHost: () => string, localGateway: string): void; get isFixed(): boolean; get leftmost(): string; getHostName(root: string): string; get reconstructed(): string; get origin(): string | null; resolveWithOrigin(origin: string): HostNameTemplate; get leftOfGeneration(): string; get networkHost(): string; get rightOfGeneration(): string; } export declare class HostName extends HostNameBase { get name(): string; isGateway(): boolean; } export declare class HostNameTemplate extends HostNameBase { }