@learncard/core 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/README.md +89 -0
- package/dist/core.cjs.development.js +48753 -0
- package/dist/core.cjs.development.js.map +7 -0
- package/dist/core.cjs.production.min.js +896 -0
- package/dist/core.cjs.production.min.js.map +7 -0
- package/dist/core.d.ts +232 -0
- package/dist/core.esm.js +48756 -0
- package/dist/core.esm.js.map +7 -0
- package/dist/didkit/README.md +89 -0
- package/dist/didkit/didkit_wasm.d.ts +222 -0
- package/dist/didkit/didkit_wasm.js +1070 -0
- package/dist/didkit/didkit_wasm_bg.wasm +0 -0
- package/dist/didkit/didkit_wasm_bg.wasm.d.ts +48 -0
- package/dist/didkit/package.json +15 -0
- package/dist/didkit_wasm.d.ts +222 -0
- package/dist/didkit_wasm.js +1070 -0
- package/dist/didkit_wasm_bg.wasm +0 -0
- package/dist/didkit_wasm_bg.wasm.d.ts +48 -0
- package/dist/index.js +7 -0
- package/dist/package.json +15 -0
- package/package.json +54 -0
package/dist/core.d.ts
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
// Generated by dts-bundle-generator v5.9.0
|
2
|
+
|
3
|
+
/// <reference types="node" />
|
4
|
+
|
5
|
+
import { StreamID } from '@ceramicnetwork/streamid';
|
6
|
+
import { ModelAliases } from '@glazed/types';
|
7
|
+
|
8
|
+
declare enum VerificationStatus {
|
9
|
+
Success = "Success",
|
10
|
+
Failed = "Failed",
|
11
|
+
Error = "Error"
|
12
|
+
}
|
13
|
+
export declare type VerificationItem = {
|
14
|
+
check: string;
|
15
|
+
status: VerificationStatus;
|
16
|
+
message?: string;
|
17
|
+
details?: string;
|
18
|
+
};
|
19
|
+
export declare type AchievementCriteria = {
|
20
|
+
type?: string;
|
21
|
+
narrative?: string;
|
22
|
+
};
|
23
|
+
export declare type CredentialSubjectAchievement = {
|
24
|
+
type?: string;
|
25
|
+
name?: string;
|
26
|
+
description?: string;
|
27
|
+
criteria?: AchievementCriteria;
|
28
|
+
image?: string;
|
29
|
+
};
|
30
|
+
export declare type CredentialSubject = {
|
31
|
+
type?: string;
|
32
|
+
id?: string;
|
33
|
+
achievement?: CredentialSubjectAchievement;
|
34
|
+
};
|
35
|
+
export declare type Issuer = string | {
|
36
|
+
type?: string;
|
37
|
+
id?: string;
|
38
|
+
name?: string;
|
39
|
+
url?: string;
|
40
|
+
image?: string;
|
41
|
+
};
|
42
|
+
export declare type Proof = {
|
43
|
+
type: string;
|
44
|
+
proofPurpose: string;
|
45
|
+
verificationMethod: string;
|
46
|
+
jws: string;
|
47
|
+
created: string;
|
48
|
+
};
|
49
|
+
export declare type UnsignedVC = {
|
50
|
+
[key: string]: any;
|
51
|
+
"@context": string | string[];
|
52
|
+
credentialSubject: CredentialSubject;
|
53
|
+
id: string;
|
54
|
+
issuanceDate: string;
|
55
|
+
expirationDate?: string;
|
56
|
+
issuer: Issuer;
|
57
|
+
type: string[];
|
58
|
+
};
|
59
|
+
export declare type VC = UnsignedVC & {
|
60
|
+
proof: Proof;
|
61
|
+
};
|
62
|
+
export declare type UnsignedVP = {
|
63
|
+
[key: string]: any;
|
64
|
+
"@context": string | string[];
|
65
|
+
holder: string;
|
66
|
+
type: string[];
|
67
|
+
verifiableCredential: VC;
|
68
|
+
};
|
69
|
+
export declare type VP = UnsignedVP & {
|
70
|
+
proof: Proof;
|
71
|
+
};
|
72
|
+
export declare type JWK = {
|
73
|
+
id: string;
|
74
|
+
type: string | string[];
|
75
|
+
controller?: string;
|
76
|
+
publicKeyJwk?: any;
|
77
|
+
privateKeyJwk?: any;
|
78
|
+
"@context": string[];
|
79
|
+
name: string;
|
80
|
+
image: string;
|
81
|
+
description: string;
|
82
|
+
tags: string[];
|
83
|
+
value?: string;
|
84
|
+
generatedFrom?: [
|
85
|
+
string
|
86
|
+
];
|
87
|
+
};
|
88
|
+
export declare type DidKeyPluginMethods = {
|
89
|
+
getSubjectDid: () => string;
|
90
|
+
getSubjectKeypair: () => Record<string, string>;
|
91
|
+
};
|
92
|
+
export declare type DidKeyPluginConstants = {
|
93
|
+
generateContentFromSeed: (seed: Uint8Array) => Promise<JWK[]>;
|
94
|
+
};
|
95
|
+
export declare type IDXPluginMethods = {
|
96
|
+
getCredentialsListFromIndex: (alias?: string) => Promise<CredentialsList>;
|
97
|
+
publishContentToCeramic: (cred: any) => Promise<string>;
|
98
|
+
readContentFromCeramic: (streamId: string) => Promise<any>;
|
99
|
+
getVerifiableCredentialFromIndex: (title: string) => Promise<any>;
|
100
|
+
getVerifiableCredentialsFromIndex: () => Promise<any>;
|
101
|
+
addVerifiableCredentialInIdx: (cred: IDXCredential) => Promise<StreamID>;
|
102
|
+
};
|
103
|
+
declare enum StorageType {
|
104
|
+
ceramic = "ceramic"
|
105
|
+
}
|
106
|
+
export declare type IDXCredential = {
|
107
|
+
id: string;
|
108
|
+
title: string;
|
109
|
+
storageType?: StorageType;
|
110
|
+
};
|
111
|
+
export declare type CredentialsList = {
|
112
|
+
credentials: IDXCredential[];
|
113
|
+
};
|
114
|
+
export declare type VerificationCheck = {
|
115
|
+
checks: string[];
|
116
|
+
warnings: string[];
|
117
|
+
errors: string[];
|
118
|
+
};
|
119
|
+
export declare type VCPluginMethods = {
|
120
|
+
issueCredential: (credential: UnsignedVC) => Promise<VC>;
|
121
|
+
verifyCredential: (credential: VC) => Promise<VerificationCheck>;
|
122
|
+
issuePresentation: (credential: VC) => Promise<VP>;
|
123
|
+
verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
|
124
|
+
getTestVc: (subject?: string) => UnsignedVC;
|
125
|
+
getSubjectDid: () => string;
|
126
|
+
getSubjectKeypair: () => Record<string, string>;
|
127
|
+
};
|
128
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
129
|
+
export declare type Plugin<Name extends string, PublicMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PublicConstants extends Record<string, any> = Record<never, never>> = {
|
130
|
+
name?: Name;
|
131
|
+
pluginMethods: {
|
132
|
+
[Key in keyof PublicMethods]: <T extends UnlockedWallet<any, PublicMethods, PublicConstants>>(wallet: T, ...args: Parameters<PublicMethods[Key]>) => ReturnType<PublicMethods[Key]>;
|
133
|
+
};
|
134
|
+
pluginConstants: PublicConstants;
|
135
|
+
};
|
136
|
+
export declare type PublicFieldsObj<PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PluginConstants extends Record<string, any> = Record<never, never>> = {
|
137
|
+
pluginMethods: PluginMethods;
|
138
|
+
pluginConstants: PluginConstants;
|
139
|
+
};
|
140
|
+
declare enum WalletStatus {
|
141
|
+
Locked = "LOCKED",
|
142
|
+
Unlocked = "UNLOCKED"
|
143
|
+
}
|
144
|
+
export declare type BaseWallet<PluginNames extends string = "", PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PluginConstants extends Record<string, any> = Record<never, never>> = PublicFieldsObj<PluginMethods, PluginConstants> & {
|
145
|
+
contents: any[];
|
146
|
+
plugins: Plugin<PluginNames, Record<string, (...args: any[]) => any>, Record<string, any>>[];
|
147
|
+
};
|
148
|
+
export declare type LockedWallet<PluginNames extends string = "", PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PluginConstants extends Record<string, any> = Record<never, never>> = BaseWallet<PluginNames, PluginMethods, PluginConstants> & {
|
149
|
+
status: WalletStatus.Locked;
|
150
|
+
};
|
151
|
+
export declare type UnlockedWallet<PluginNames extends string = "", PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PluginConstants extends Record<string, any> = Record<never, never>> = BaseWallet<PluginNames, PluginMethods, PluginConstants> & {
|
152
|
+
status: WalletStatus.Unlocked;
|
153
|
+
add: (content: any) => Promise<UnlockedWallet<PluginNames, PluginMethods, PluginConstants>>;
|
154
|
+
remove: (contentId: string) => Promise<UnlockedWallet<PluginNames, PluginMethods, PluginConstants>>;
|
155
|
+
addPlugin: <Name extends string, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>, Constants extends Record<string, any> = Record<never, never>>(plugin: Plugin<Name, Methods, Constants>) => Promise<UnlockedWallet<"" extends PluginNames ? Name : PluginNames | Name, Record<never, never> extends PluginMethods ? Methods : PluginMethods & Methods, Record<never, never> extends PluginConstants ? Constants : PluginConstants & Constants>>;
|
156
|
+
};
|
157
|
+
export declare type Wallet<PluginNames extends string = "", PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, PluginConstants extends Record<string, any> = Record<never, never>> = LockedWallet<PluginNames, PluginMethods, PluginConstants> | UnlockedWallet<PluginNames, PluginMethods, PluginConstants>;
|
158
|
+
export declare type LearnCardRawWallet = UnlockedWallet<"DID Key" | "VC" | "IDX" | "Expiration", DidKeyPluginMethods & VCPluginMethods & IDXPluginMethods, DidKeyPluginConstants>;
|
159
|
+
export declare type LearnCardWallet = {
|
160
|
+
/** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
|
161
|
+
_wallet: LearnCardRawWallet;
|
162
|
+
/** Wallet holder's did */
|
163
|
+
did: string;
|
164
|
+
/** Wallet holder's ed25519 key pair */
|
165
|
+
keypair: Record<string, string>;
|
166
|
+
/** Signs an unsigned Verifiable Credential, returning the signed VC */
|
167
|
+
issueCredential: (credential: UnsignedVC) => Promise<VC>;
|
168
|
+
/**
|
169
|
+
* Verifies a signed Verifiable Credential
|
170
|
+
*
|
171
|
+
* Empty error/warnings arrays means verification was successful
|
172
|
+
*/
|
173
|
+
verifyCredential: (credential: VC) => Promise<VerificationItem[]>;
|
174
|
+
/** Creates a signed Verifiable Presentation from a signed Verifiable Credential */
|
175
|
+
issuePresentation: (credential: VC) => Promise<VP>;
|
176
|
+
/**
|
177
|
+
* Verifies a signed Verifiable Presentation
|
178
|
+
*
|
179
|
+
* Empry error/warnings arrays means verification was successful
|
180
|
+
*/
|
181
|
+
verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
|
182
|
+
/** Returns the credential marked with `title` from IDX */
|
183
|
+
getCredential: (title: string) => Promise<any>;
|
184
|
+
/** Returns all credentials from IDX */
|
185
|
+
getCredentials: () => Promise<any[]>;
|
186
|
+
/**
|
187
|
+
* Publishes a credential to Ceramic, returning the credential's stream ID
|
188
|
+
*
|
189
|
+
* This stream ID may then be shared/persisted/resolved to gain access to the credential
|
190
|
+
*
|
191
|
+
* Resolving a stream ID can be done by passing the stream ID to `readFromCeramic`
|
192
|
+
*/
|
193
|
+
publishCredential: (credential: any) => Promise<string>;
|
194
|
+
/**
|
195
|
+
* Adds a stream ID pointing to a credential (such as the one returned by `publishCredential`)
|
196
|
+
* to IDX with a bespoke title
|
197
|
+
*
|
198
|
+
* The credential may then be retrieved using `getCredential` and passing in that bespoke title,
|
199
|
+
* or by using `getCredentials` to get a list of all credentials that have been added to IDX
|
200
|
+
*/
|
201
|
+
addCredential: (credential: IDXCredential) => Promise<void>;
|
202
|
+
/**
|
203
|
+
* Resolves a stream ID, returning its contents
|
204
|
+
*
|
205
|
+
* This can be given the return value of `publishCredential` to gain access to the credential
|
206
|
+
* that was published
|
207
|
+
*/
|
208
|
+
readFromCeramic: (streamId: string) => Promise<any>;
|
209
|
+
/**
|
210
|
+
* Returns an example credential, optionally allowing a subject's did to be passed in
|
211
|
+
*
|
212
|
+
* You can use this to test out implementations that use this library!
|
213
|
+
*/
|
214
|
+
getTestVc: (subject?: string) => UnsignedVC;
|
215
|
+
};
|
216
|
+
export declare type CeramicIDXArgs = {
|
217
|
+
modelData: ModelAliases;
|
218
|
+
credentialAlias: string;
|
219
|
+
ceramicEndpoint: string;
|
220
|
+
defaultContentFamily: string;
|
221
|
+
};
|
222
|
+
export declare type LearnCardConfig = {
|
223
|
+
ceramicIdx: CeramicIDXArgs;
|
224
|
+
didkit: InitInput | Promise<InitInput>;
|
225
|
+
};
|
226
|
+
export declare const createWallet: (defaultContents: any[], { ceramicIdx, didkit }?: Partial<LearnCardConfig>) => Promise<LearnCardWallet>;
|
227
|
+
/** Generates did documents from key and returns default wallet */
|
228
|
+
export declare const walletFromKey: (key: string, { ceramicIdx, didkit }?: Partial<LearnCardConfig>) => Promise<LearnCardWallet>;
|
229
|
+
export { createWallet, walletFromKey } from "@wallet/init";
|
230
|
+
export { Wallet, UnlockedWallet, LockedWallet, Plugin } from "types/wallet";
|
231
|
+
|
232
|
+
export {};
|