@learncard/core 1.1.4 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -5
- package/dist/core.cjs.development.js +3855 -12007
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +204 -290
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +4756 -0
- package/dist/core.esm.js +3857 -12007
- package/dist/core.esm.js.map +3 -3
- package/package.json +22 -17
- package/dist/didkit/index.d.ts +0 -4
- package/dist/index.d.ts +0 -3
- package/dist/types/LearnCard.d.ts +0 -77
- package/dist/types/wallet.d.ts +0 -27
- package/dist/wallet/base/crypto.d.ts +0 -3
- package/dist/wallet/base/functions/index.d.ts +0 -2
- package/dist/wallet/base/functions/passwordToKey.d.ts +0 -1
- package/dist/wallet/base/functions/seedToId.d.ts +0 -1
- package/dist/wallet/base/index.d.ts +0 -2
- package/dist/wallet/base/wallet.d.ts +0 -2
- package/dist/wallet/defaults.d.ts +0 -2
- package/dist/wallet/init.d.ts +0 -3
- package/dist/wallet/plugins/didkey/index.d.ts +0 -3
- package/dist/wallet/plugins/didkey/types.d.ts +0 -19
- package/dist/wallet/plugins/expiration/index.d.ts +0 -3
- package/dist/wallet/plugins/idx/idx.d.ts +0 -6
- package/dist/wallet/plugins/idx/index.d.ts +0 -4
- package/dist/wallet/plugins/idx/types.d.ts +0 -20
- package/dist/wallet/plugins/vc/index.d.ts +0 -2
- package/dist/wallet/plugins/vc/issueCredential.d.ts +0 -5
- package/dist/wallet/plugins/vc/issuePresentation.d.ts +0 -6
- package/dist/wallet/plugins/vc/types.d.ts +0 -18
- package/dist/wallet/plugins/vc/vc.d.ts +0 -6
- package/dist/wallet/plugins/vc/verifyCredential.d.ts +0 -2
- package/dist/wallet/plugins/vc/verifyPresentation.d.ts +0 -2
- package/dist/wallet/verify.d.ts +0 -3
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@learncard/core",
|
3
|
-
"version": "1.1
|
3
|
+
"version": "1.3.1",
|
4
4
|
"description": "",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/core.esm.js",
|
7
7
|
"files": [
|
8
8
|
"dist"
|
9
9
|
],
|
10
|
-
"author": "
|
10
|
+
"author": "Learning Economy Foundation (www.learningeconomy.io)",
|
11
11
|
"license": "MIT",
|
12
12
|
"homepage": "https://github.com/WeLibraryOS/LearnCard#readme",
|
13
13
|
"repository": {
|
@@ -19,37 +19,42 @@
|
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
21
|
"@glazed/types": "^0.2.0",
|
22
|
-
"@learncard/types": "2.1.
|
22
|
+
"@learncard/types": "2.1.2",
|
23
|
+
"@types/jest": "^27.5.0",
|
23
24
|
"@types/node": "^17.0.31",
|
24
25
|
"aqu": "0.3.2",
|
25
26
|
"esbuild": "^0.14.38",
|
27
|
+
"esbuild-jest": "^0.5.0",
|
26
28
|
"esbuild-plugin-copy": "^1.3.0",
|
29
|
+
"jest": "27",
|
30
|
+
"ts-jest": "^28.0.5",
|
27
31
|
"tsc-alias": "^1.6.9",
|
28
32
|
"typescript": "^4.6.4"
|
29
33
|
},
|
30
|
-
"types": "./dist/
|
34
|
+
"types": "./dist/core.d.ts",
|
31
35
|
"dependencies": {
|
32
|
-
"@ceramicnetwork/common": "^2.
|
33
|
-
"@ceramicnetwork/http-client": "2.0
|
34
|
-
"@ceramicnetwork/stream-tile": "^2.
|
35
|
-
"@ceramicnetwork/streamid": "^2.0
|
36
|
-
"@glazed/did-datastore": "^0.3.
|
37
|
-
"@glazed/tile-loader": "^0.2.
|
38
|
-
"
|
36
|
+
"@ceramicnetwork/common": "^2.2.1",
|
37
|
+
"@ceramicnetwork/http-client": "2.3.0",
|
38
|
+
"@ceramicnetwork/stream-tile": "^2.2.2",
|
39
|
+
"@ceramicnetwork/streamid": "^2.1.0",
|
40
|
+
"@glazed/did-datastore": "^0.3.2",
|
41
|
+
"@glazed/tile-loader": "^0.2.1",
|
42
|
+
"abort-controller": "^3.0.0",
|
39
43
|
"date-fns": "^2.28.0",
|
40
|
-
"dids": "^3.
|
44
|
+
"dids": "^3.2.0",
|
41
45
|
"hex-lite": "^1.5.0",
|
46
|
+
"isomorphic-fetch": "^3.0.0",
|
47
|
+
"isomorphic-webcrypto": "^2.3.8",
|
42
48
|
"key-did-provider-ed25519": "^2.0.0",
|
43
|
-
"key-did-resolver": "1.
|
49
|
+
"key-did-resolver": "1.4.4"
|
44
50
|
},
|
45
51
|
"scripts": {
|
46
52
|
"build": "aqu build && tsc-alias",
|
47
53
|
"start": "aqu watch",
|
48
54
|
"lint": "aqu lint",
|
49
55
|
"lint:fix": "aqu lint --fix",
|
50
|
-
"test": "
|
51
|
-
"test:watch": "
|
52
|
-
"test:coverage": "
|
53
|
-
"release": "np"
|
56
|
+
"test": "jest",
|
57
|
+
"test:watch": "jest --watch",
|
58
|
+
"test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
|
54
59
|
}
|
55
60
|
}
|
package/dist/didkit/index.d.ts
DELETED
package/dist/index.d.ts
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
import { ModelAliases } from '@glazed/types';
|
2
|
-
import { VerificationItem, UnsignedVC, VC, VP } from '@learncard/types';
|
3
|
-
import { DidKeyPluginMethods } from '../wallet/plugins/didkey/types';
|
4
|
-
import { IDXCredential, IDXPluginMethods } from '../wallet/plugins/idx/types';
|
5
|
-
import { VCPluginMethods, VerificationCheck } from '../wallet/plugins/vc/types';
|
6
|
-
import { InitInput } from '../didkit';
|
7
|
-
import { UnlockedWallet } from './wallet';
|
8
|
-
export * from '@learncard/types';
|
9
|
-
export declare type LearnCardRawWallet = UnlockedWallet<'DID Key' | 'VC' | 'IDX' | 'Expiration', DidKeyPluginMethods & VCPluginMethods & IDXPluginMethods>;
|
10
|
-
export declare type LearnCardWallet = {
|
11
|
-
/** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
|
12
|
-
_wallet: LearnCardRawWallet;
|
13
|
-
/** Wallet holder's did */
|
14
|
-
did: string;
|
15
|
-
/** Wallet holder's ed25519 key pair */
|
16
|
-
keypair: Record<string, string>;
|
17
|
-
/** Signs an unsigned Verifiable Credential, returning the signed VC */
|
18
|
-
issueCredential: (credential: UnsignedVC) => Promise<VC>;
|
19
|
-
/**
|
20
|
-
* Verifies a signed Verifiable Credential
|
21
|
-
*
|
22
|
-
* Empty error/warnings arrays means verification was successful
|
23
|
-
*/
|
24
|
-
verifyCredential: (credential: VC) => Promise<VerificationItem[]>;
|
25
|
-
/** Creates a signed Verifiable Presentation from a signed Verifiable Credential */
|
26
|
-
issuePresentation: (credential: VC) => Promise<VP>;
|
27
|
-
/**
|
28
|
-
* Verifies a signed Verifiable Presentation
|
29
|
-
*
|
30
|
-
* Empry error/warnings arrays means verification was successful
|
31
|
-
*/
|
32
|
-
verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
|
33
|
-
/** Returns the credential marked with `title` from IDX */
|
34
|
-
getCredential: (title: string) => Promise<any>;
|
35
|
-
/** Returns all credentials from IDX */
|
36
|
-
getCredentials: () => Promise<any[]>;
|
37
|
-
/**
|
38
|
-
* Publishes a credential to Ceramic, returning the credential's stream ID
|
39
|
-
*
|
40
|
-
* This stream ID may then be shared/persisted/resolved to gain access to the credential
|
41
|
-
*
|
42
|
-
* Resolving a stream ID can be done by passing the stream ID to `readFromCeramic`
|
43
|
-
*/
|
44
|
-
publishCredential: (credential: any) => Promise<string>;
|
45
|
-
/**
|
46
|
-
* Adds a stream ID pointing to a credential (such as the one returned by `publishCredential`)
|
47
|
-
* to IDX with a bespoke title
|
48
|
-
*
|
49
|
-
* The credential may then be retrieved using `getCredential` and passing in that bespoke title,
|
50
|
-
* or by using `getCredentials` to get a list of all credentials that have been added to IDX
|
51
|
-
*/
|
52
|
-
addCredential: (credential: IDXCredential) => Promise<void>;
|
53
|
-
/**
|
54
|
-
* Resolves a stream ID, returning its contents
|
55
|
-
*
|
56
|
-
* This can be given the return value of `publishCredential` to gain access to the credential
|
57
|
-
* that was published
|
58
|
-
*/
|
59
|
-
readFromCeramic: (streamId: string) => Promise<any>;
|
60
|
-
/**
|
61
|
-
* Returns an example credential, optionally allowing a subject's did to be passed in
|
62
|
-
*
|
63
|
-
* You can use this to test out implementations that use this library!
|
64
|
-
*/
|
65
|
-
getTestVc: (subject?: string) => UnsignedVC;
|
66
|
-
};
|
67
|
-
export declare type CeramicIDXArgs = {
|
68
|
-
modelData: ModelAliases;
|
69
|
-
credentialAlias: string;
|
70
|
-
ceramicEndpoint: string;
|
71
|
-
defaultContentFamily: string;
|
72
|
-
};
|
73
|
-
export declare type LearnCardConfig = {
|
74
|
-
ceramicIdx: CeramicIDXArgs;
|
75
|
-
didkit: InitInput | Promise<InitInput>;
|
76
|
-
defaultContents: any[];
|
77
|
-
};
|
package/dist/types/wallet.d.ts
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
export declare type Plugin<Name extends string, PublicMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
2
|
-
name?: Name;
|
3
|
-
pluginMethods: {
|
4
|
-
[Key in keyof PublicMethods]: <T extends UnlockedWallet<any, PublicMethods>>(wallet: T, ...args: Parameters<PublicMethods[Key]>) => ReturnType<PublicMethods[Key]>;
|
5
|
-
};
|
6
|
-
};
|
7
|
-
export declare type PublicFieldsObj<PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
8
|
-
pluginMethods: PluginMethods;
|
9
|
-
};
|
10
|
-
export declare enum WalletStatus {
|
11
|
-
Locked = "LOCKED",
|
12
|
-
Unlocked = "UNLOCKED"
|
13
|
-
}
|
14
|
-
export declare type BaseWallet<PluginNames extends string = '', PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = PublicFieldsObj<PluginMethods> & {
|
15
|
-
contents: any[];
|
16
|
-
plugins: Plugin<PluginNames, Record<string, (...args: any[]) => any>>[];
|
17
|
-
};
|
18
|
-
export declare type LockedWallet<PluginNames extends string = '', PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = BaseWallet<PluginNames, PluginMethods> & {
|
19
|
-
status: WalletStatus.Locked;
|
20
|
-
};
|
21
|
-
export declare type UnlockedWallet<PluginNames extends string = '', PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = BaseWallet<PluginNames, PluginMethods> & {
|
22
|
-
status: WalletStatus.Unlocked;
|
23
|
-
add: (content: any) => Promise<UnlockedWallet<PluginNames, PluginMethods>>;
|
24
|
-
remove: (contentId: string) => Promise<UnlockedWallet<PluginNames, PluginMethods>>;
|
25
|
-
addPlugin: <Name extends string, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>>(plugin: Plugin<Name, Methods>) => Promise<UnlockedWallet<'' extends PluginNames ? Name : PluginNames | Name, Record<never, never> extends PluginMethods ? Methods : PluginMethods & Methods>>;
|
26
|
-
};
|
27
|
-
export declare type Wallet<PluginNames extends string = '', PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = LockedWallet<PluginNames, PluginMethods> | UnlockedWallet<PluginNames, PluginMethods>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const passwordToKey: (password: string, salt?: string, iterations?: number, digest?: string) => Promise<Uint8Array>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const seedToId: (seed: Uint8Array) => Promise<string>;
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import { UnlockedWallet } from '../../types/wallet';
|
2
|
-
export declare const generateWallet: <PluginNames extends string, PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>>(contents?: any[], _wallet?: Partial<UnlockedWallet<any, PluginMethods>>) => Promise<UnlockedWallet<PluginNames, PluginMethods>>;
|
package/dist/wallet/init.d.ts
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
import { LearnCardConfig, LearnCardWallet } from '../types/LearnCard';
|
2
|
-
/** Generates a LearnCard Wallet from a 64 character seed string */
|
3
|
-
export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, }?: Partial<LearnCardConfig>) => Promise<LearnCardWallet>;
|
@@ -1,19 +0,0 @@
|
|
1
|
-
export declare type JWK = {
|
2
|
-
id: string;
|
3
|
-
type: string | string[];
|
4
|
-
controller?: string;
|
5
|
-
publicKeyJwk?: any;
|
6
|
-
privateKeyJwk?: any;
|
7
|
-
'@context': string[];
|
8
|
-
name: string;
|
9
|
-
image: string;
|
10
|
-
description: string;
|
11
|
-
tags: string[];
|
12
|
-
value?: string;
|
13
|
-
generatedFrom?: [string];
|
14
|
-
};
|
15
|
-
export declare type DidKeyPluginMethods = {
|
16
|
-
getSubjectDid: () => string;
|
17
|
-
getSubjectKeypair: () => Record<string, string>;
|
18
|
-
getKey: () => string;
|
19
|
-
};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { IDXPluginMethods } from './types';
|
2
|
-
import { Plugin, UnlockedWallet } from '../../../types/wallet';
|
3
|
-
import { CeramicIDXArgs } from '../../../types/LearnCard';
|
4
|
-
export declare const getIDXPlugin: (wallet: UnlockedWallet<any, {
|
5
|
-
getKey: () => string;
|
6
|
-
}>, { modelData, credentialAlias, ceramicEndpoint, defaultContentFamily }: CeramicIDXArgs) => Promise<Plugin<'IDX', IDXPluginMethods>>;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { StreamID } from '@ceramicnetwork/streamid';
|
2
|
-
export declare type IDXPluginMethods = {
|
3
|
-
getCredentialsListFromIndex: (alias?: string) => Promise<CredentialsList>;
|
4
|
-
publishContentToCeramic: (cred: any) => Promise<string>;
|
5
|
-
readContentFromCeramic: (streamId: string) => Promise<any>;
|
6
|
-
getVerifiableCredentialFromIndex: (title: string) => Promise<any>;
|
7
|
-
getVerifiableCredentialsFromIndex: () => Promise<any>;
|
8
|
-
addVerifiableCredentialInIdx: (cred: IDXCredential) => Promise<StreamID>;
|
9
|
-
};
|
10
|
-
export declare enum StorageType {
|
11
|
-
ceramic = "ceramic"
|
12
|
-
}
|
13
|
-
export declare type IDXCredential = {
|
14
|
-
id: string;
|
15
|
-
title: string;
|
16
|
-
storageType?: StorageType;
|
17
|
-
};
|
18
|
-
export declare type CredentialsList = {
|
19
|
-
credentials: IDXCredential[];
|
20
|
-
};
|
@@ -1,5 +0,0 @@
|
|
1
|
-
import { UnsignedVC } from '@learncard/types';
|
2
|
-
import { UnlockedWallet } from '../../../types/wallet';
|
3
|
-
export declare const issueCredential: (wallet: UnlockedWallet<any, {
|
4
|
-
getSubjectKeypair: () => Record<string, string>;
|
5
|
-
}>, credential: UnsignedVC) => Promise<any>;
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { VC } from '@learncard/types';
|
2
|
-
import { UnlockedWallet } from '../../../types/wallet';
|
3
|
-
export declare const issuePresentation: (wallet: UnlockedWallet<any, {
|
4
|
-
getSubjectDid: () => string;
|
5
|
-
getSubjectKeypair: () => Record<string, string>;
|
6
|
-
}>, credential: VC) => Promise<any>;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { UnsignedVC, VC, VP } from '@learncard/types';
|
2
|
-
export declare type VerificationCheck = {
|
3
|
-
checks: string[];
|
4
|
-
warnings: string[];
|
5
|
-
errors: string[];
|
6
|
-
};
|
7
|
-
export declare type VCPluginMethods = {
|
8
|
-
issueCredential: (credential: UnsignedVC) => Promise<VC>;
|
9
|
-
verifyCredential: (credential: VC) => Promise<VerificationCheck>;
|
10
|
-
issuePresentation: (credential: VC) => Promise<VP>;
|
11
|
-
verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
|
12
|
-
getTestVc: (subject?: string) => UnsignedVC;
|
13
|
-
getSubjectDid: () => string;
|
14
|
-
getSubjectKeypair: () => Record<string, string>;
|
15
|
-
};
|
16
|
-
export declare type VerifyExtension = {
|
17
|
-
verifyCredential: (credential: VC) => Promise<VerificationCheck>;
|
18
|
-
};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { VCPluginMethods } from './types';
|
2
|
-
import { Plugin, UnlockedWallet } from '../../../types/wallet';
|
3
|
-
export declare const getVCPlugin: (wallet: UnlockedWallet<any, {
|
4
|
-
getSubjectDid: () => string;
|
5
|
-
getSubjectKeypair: () => Record<string, string>;
|
6
|
-
}>) => Promise<Plugin<'VC', VCPluginMethods>>;
|
package/dist/wallet/verify.d.ts
DELETED