-
Notifications
You must be signed in to change notification settings - Fork 36
/
Identity.d.ts
112 lines (84 loc) · 3.34 KB
/
Identity.d.ts
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
declare module "orbit-db-identity-provider" {
import Store from 'orbit-db-store';
import { Keystore } from 'orbit-db-keystore';
export type IdentityProviderType = 'orbitdb' | 'ethereum' | string;
export interface IdentityProviderOptions {
/**
* required by OrbitDBIdentityProvider
*/
id?: string
/**
* required by OrbitDBIdentityProvider
*/
keystore?: Keystore
/**
* required by OrbitDBIdentityProvider
*/
signingKeystore?: Keystore
/**
* required by EthIdentityProvider
*/
wallet?: any
[k: string]: any
}
export class IdentityProvider {
constructor(options: IdentityProviderOptions)
/**
* Return the type for this identity-provider
*/
readonly type: IdentityProviderType;
/**
* Return id of identity (to be signed by orbit-db public key)
*/
getId(options?: IdentityProviderOptions): Promise<string>
/**
* Return signature of OrbitDB public key signature
*/
signIdentity(data: any, options?: { [key: string]: any, id: string }): Promise<any>
/**
* Verify a signature of OrbitDB public key signature
*/
static verifyIdentity(identity: IdentityAsJson): Promise<boolean>
}
export interface IdentityAsJson {
id: string;
publicKey: string;
signatures: {
id: string,
publicKey: string
};
type: IdentityProviderType;
}
export class Identity implements IdentityAsJson {
constructor(id: string, publicKey: string, idSignature: string, pubKeyIdSignature: string, type: string, provider: IdentityProvider)
readonly id: string;
readonly publicKey: string;
readonly signatures: { id: string; publicKey: string };
readonly type: IdentityProviderType;
readonly provider: Identities;
toJSON(): IdentityAsJson
}
export interface CreateIdentityOptions extends IdentityProviderOptions {
type?: IdentityProviderType
identityKeysPath?: string
migrate?: (options: { targetStore: Store, targetId: string }) => Promise<void>
}
export interface StaticCreateIdentityOptions extends CreateIdentityOptions {
identityKeysPath?: string
}
export default class Identities {
constructor(options: { keystore?: Keystore, signingKeystore?: Keystore })
readonly keystore: Keystore;
readonly signingKeystore: Keystore;
sign(identity: IdentityAsJson, data: any): Promise<string>
verify(signature: string, publicKey: string, data: any, verifier?: any): Promise<boolean>
createIdentity(options?: CreateIdentityOptions): Promise<Identity>
signId(id: string): Promise<{ publicKey: string, idSignature: string }>
verifyIdentity(identity: IdentityAsJson): Promise<boolean>
static verifyIdentity(identity: IdentityAsJson): Promise<boolean>
static createIdentity(options?: StaticCreateIdentityOptions): Promise<Identity>
static isSupported(type: IdentityProviderType): boolean
static addIdentityProvider(IdentityProviderType: typeof IdentityProvider): void
static removeIdentityProvider(type: IdentityProviderType): void
}
}