/
LearnCard.ts
132 lines (120 loc) · 3.91 KB
/
LearnCard.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { InitInput } from '@didkit/index';
import { DidMethod } from '@wallet/plugins/didkit/types';
import { DidKeyPluginMethods } from '@wallet/plugins/didkey/types';
import { EthereumPluginMethods } from '@wallet/plugins/EthereumPlugin/types';
import { IDXPluginMethods, CeramicIDXArgs } from '@wallet/plugins/idx/types';
import { VCPluginMethods, VerifyExtension } from '@wallet/plugins/vc/types';
import { DidkitPluginMethods } from '@wallet/plugins/didkit/types';
import { EthereumConfig } from '@wallet/plugins/EthereumPlugin/types';
import { VpqrPluginMethods } from '@wallet/plugins/vpqr/types';
import { CHAPIPluginMethods } from '@wallet/plugins/chapi';
import { VCTemplatePluginMethods } from '@wallet/plugins/vc-templates';
import { VCAPIPluginMethods } from '@wallet/plugins/vc-api/types';
import { InitFunction, GenericInitFunction } from 'types/helpers';
import { Wallet } from 'types/wallet';
import { AllLearnCardMethods } from 'types/methods';
import { MergeObjects } from './utilities';
import { VCResolutionPluginMethods } from '@wallet/plugins/vc-resolution';
export { MergeObjects } from './utilities';
export * from 'types/methods';
// export * from '@learncard/types';
/** @group Universal Wallets */
export type LearnCardRawWallet = Wallet<
| 'DIDKit'
| 'DID Key'
| 'VC'
| 'VC Templates'
| 'VC Resolution'
| 'IDX'
| 'Expiration'
| 'Ethereum'
| 'Vpqr'
| 'CHAPI',
MergeObjects<
[
DidKeyPluginMethods<DidMethod>,
VCPluginMethods,
VCTemplatePluginMethods,
VCResolutionPluginMethods,
IDXPluginMethods,
EthereumPluginMethods,
VpqrPluginMethods,
CHAPIPluginMethods
]
>
>;
/**
* @group LearnCard
*/
export type LearnCard<
Methods extends keyof AllLearnCardMethods = keyof AllLearnCardMethods,
RawWallet extends Wallet<any, any> = LearnCardRawWallet
> = {
/** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
_wallet: RawWallet;
} & Pick<AllLearnCardMethods, Methods>;
/**
* @group LearnCard
*/
export type EmptyLearnCard = LearnCard<
| 'newCredential'
| 'newPresentation'
| 'verifyCredential'
| 'verifyPresentation'
| 'resolveDid'
| 'installChapiHandler'
| 'activateChapiHandler'
| 'receiveChapiEvent'
| 'storePresentationViaChapi'
| 'storeCredentialViaChapiDidAuth',
Wallet<
'DIDKit' | 'Expiration' | 'VC Templates' | 'CHAPI',
MergeObjects<
[DidkitPluginMethods, VerifyExtension, VCTemplatePluginMethods, CHAPIPluginMethods]
>
>
>;
/**
* @group LearnCard
*/
export type VCAPILearnCard = LearnCard<
| 'did'
| 'newCredential'
| 'newPresentation'
| 'issueCredential'
| 'verifyCredential'
| 'issuePresentation'
| 'verifyPresentation'
| 'getTestVc'
| 'getTestVp'
| 'installChapiHandler'
| 'activateChapiHandler'
| 'receiveChapiEvent'
| 'storePresentationViaChapi'
| 'storeCredentialViaChapiDidAuth',
Wallet<
'VC API' | 'Expiration' | 'VC Templates' | 'CHAPI',
MergeObjects<
[VCAPIPluginMethods, VerifyExtension, VCTemplatePluginMethods, CHAPIPluginMethods]
>
>
>;
/** @group LearnCard */
export type LearnCardConfig = {
ceramicIdx: CeramicIDXArgs;
didkit: InitInput | Promise<InitInput>;
defaultContents: any[];
ethereumConfig: EthereumConfig;
};
/** @group Init Functions */
export type EmptyWallet = InitFunction<{}, 'didkit', EmptyLearnCard>;
/** @group Init Functions */
export type WalletFromKey = InitFunction<{ seed: string }, keyof LearnCardConfig, LearnCard>;
/** @group Init Functions */
export type WalletFromVcApi = InitFunction<
{ vcApi: true | string; did?: string },
'defaultContents',
VCAPILearnCard
>;
/** @group Init Functions */
export type InitLearnCard = GenericInitFunction<[EmptyWallet, WalletFromKey, WalletFromVcApi]>;