@learncard/core 9.0.2 → 9.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/core.cjs.development.js +531 -642
- package/dist/core.cjs.development.js.map +4 -4
- package/dist/core.cjs.production.min.js +1 -1
- package/dist/core.cjs.production.min.js.map +4 -4
- package/dist/core.esm.js +531 -641
- package/dist/core.esm.js.map +4 -4
- package/dist/types/LearnCard.d.ts +2 -2
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/planes.d.ts +22 -22
- package/dist/types/utilities.d.ts +8 -8
- package/dist/types/wallet.d.ts +5 -5
- package/dist/wallet/plugins/test-cache/types.d.ts +1 -1
- package/dist/wallet/plugins/test-index/types.d.ts +1 -1
- package/dist/wallet/plugins/test-storage/types.d.ts +1 -1
- package/package.json +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
import { LearnCard, Plugin } from './wallet';
|
2
|
-
export type GetPlugins<LC extends LearnCard<any, any, any>> = LC['plugins'];
|
3
|
-
export type AddPlugin<LC extends LearnCard<any, any, any>, P extends Plugin> = LearnCard<[
|
2
|
+
export declare type GetPlugins<LC extends LearnCard<any, any, any>> = LC['plugins'];
|
3
|
+
export declare type AddPlugin<LC extends LearnCard<any, any, any>, P extends Plugin> = LearnCard<[
|
4
4
|
...GetPlugins<LC>,
|
5
5
|
P
|
6
6
|
]>;
|
package/dist/types/helpers.d.ts
CHANGED
package/dist/types/planes.d.ts
CHANGED
@@ -3,22 +3,22 @@ import { Query } from 'sift';
|
|
3
3
|
import { Plugin } from './wallet';
|
4
4
|
import { OmitNevers } from './helpers';
|
5
5
|
import { DeepPartial } from './utilities';
|
6
|
-
export type CacheStrategy = 'cache-only' | 'cache-first' | 'skip-cache';
|
7
|
-
export type PlaneOptions = {
|
6
|
+
export declare type CacheStrategy = 'cache-only' | 'cache-first' | 'skip-cache';
|
7
|
+
export declare type PlaneOptions = {
|
8
8
|
cache?: CacheStrategy;
|
9
9
|
};
|
10
|
-
export type ControlPlane = 'read' | 'store' | 'index' | 'cache' | 'id';
|
11
|
-
export type FilterForPlane<Plugins extends Plugin[], Plane extends ControlPlane> = [
|
10
|
+
export declare type ControlPlane = 'read' | 'store' | 'index' | 'cache' | 'id';
|
11
|
+
export declare type FilterForPlane<Plugins extends Plugin[], Plane extends ControlPlane> = [
|
12
12
|
Plugins
|
13
13
|
] extends [1 & Plugins] ? any : {
|
14
14
|
[Index in keyof Plugins]: undefined extends Plugins[Index][Plane] ? never : Plugins[Index]['name'];
|
15
15
|
}[number];
|
16
|
-
export type GetPlanesForPlugins<Plugins extends Plugin[]> = any[] extends Plugins ? never : {
|
16
|
+
export declare type GetPlanesForPlugins<Plugins extends Plugin[]> = any[] extends Plugins ? never : {
|
17
17
|
[Index in keyof Plugins]: {
|
18
18
|
[Key in ControlPlane]: undefined extends Plugins[Index][Key] ? never : Key;
|
19
19
|
}[ControlPlane];
|
20
20
|
}[number];
|
21
|
-
export type GetPlaneProviders<Plugins extends Plugin[], Plane extends ControlPlane> = any[] extends Plugins ? any : {
|
21
|
+
export declare type GetPlaneProviders<Plugins extends Plugin[], Plane extends ControlPlane> = any[] extends Plugins ? any : {
|
22
22
|
[Index in keyof Plugins]: undefined extends Plugins[Index][Plane] ? never : OmitNevers<{
|
23
23
|
[Name in Plugins[number]['name']]: Name extends Plugins[Index]['name'] ? {
|
24
24
|
name: Name;
|
@@ -27,26 +27,26 @@ export type GetPlaneProviders<Plugins extends Plugin[], Plane extends ControlPla
|
|
27
27
|
} : never;
|
28
28
|
}>;
|
29
29
|
}[number];
|
30
|
-
export type ReadPlane = {
|
30
|
+
export declare type ReadPlane = {
|
31
31
|
get: (uri?: string, options?: PlaneOptions) => Promise<VC | VP | undefined>;
|
32
32
|
};
|
33
|
-
export type PluginReadPlane = ReadPlane;
|
34
|
-
export type LearnCardReadPlane<Plugins extends Plugin[]> = ReadPlane & {
|
33
|
+
export declare type PluginReadPlane = ReadPlane;
|
34
|
+
export declare type LearnCardReadPlane<Plugins extends Plugin[]> = ReadPlane & {
|
35
35
|
providers: GetPlaneProviders<Plugins, 'read'>;
|
36
36
|
};
|
37
|
-
export type EncryptionParams = {
|
37
|
+
export declare type EncryptionParams = {
|
38
38
|
recipients: string[];
|
39
39
|
};
|
40
|
-
export type StorePlane = {
|
40
|
+
export declare type StorePlane = {
|
41
41
|
upload: (vc: VC | VP, options?: PlaneOptions) => Promise<string>;
|
42
42
|
uploadMany?: (vcs: (VC | VP)[], options?: PlaneOptions) => Promise<string[]>;
|
43
43
|
uploadEncrypted?: (vc: VC | VP, params?: EncryptionParams, options?: PlaneOptions) => Promise<string>;
|
44
44
|
};
|
45
|
-
export type PluginStorePlane = StorePlane;
|
46
|
-
export type LearnCardStorePlane<Plugins extends Plugin[]> = Record<FilterForPlane<Plugins, 'store'>, StorePlane> & {
|
45
|
+
export declare type PluginStorePlane = StorePlane;
|
46
|
+
export declare type LearnCardStorePlane<Plugins extends Plugin[]> = Record<FilterForPlane<Plugins, 'store'>, StorePlane> & {
|
47
47
|
providers: GetPlaneProviders<Plugins, 'store'>;
|
48
48
|
};
|
49
|
-
export type IndexPlane = {
|
49
|
+
export declare type IndexPlane = {
|
50
50
|
get: <Metadata extends Record<string, any> = Record<never, never>>(query?: Partial<Query<CredentialRecord<Metadata>>>, options?: PlaneOptions) => Promise<CredentialRecord<Metadata>[]>;
|
51
51
|
getPage?: <Metadata extends Record<string, any> = Record<never, never>>(query?: Partial<Query<CredentialRecord<Metadata>>>, paginationOptions?: {
|
52
52
|
limit?: number;
|
@@ -63,12 +63,12 @@ export type IndexPlane = {
|
|
63
63
|
remove: (id: string, options?: PlaneOptions) => Promise<boolean>;
|
64
64
|
removeAll?: (options?: PlaneOptions) => Promise<boolean>;
|
65
65
|
};
|
66
|
-
export type PluginIndexPlane = IndexPlane;
|
67
|
-
export type LearnCardIndexPlane<Plugins extends Plugin[]> = {
|
66
|
+
export declare type PluginIndexPlane = IndexPlane;
|
67
|
+
export declare type LearnCardIndexPlane<Plugins extends Plugin[]> = {
|
68
68
|
all: Pick<IndexPlane, 'get'>;
|
69
69
|
providers: GetPlaneProviders<Plugins, 'index'>;
|
70
70
|
} & Record<FilterForPlane<Plugins, 'index'>, IndexPlane>;
|
71
|
-
export type CachePlane = {
|
71
|
+
export declare type CachePlane = {
|
72
72
|
getIndex: <Metadata extends Record<string, any> = Record<never, never>>(name: string, query: Partial<Query<CredentialRecord<Metadata>>>) => Promise<CredentialRecord<Metadata>[] | undefined>;
|
73
73
|
setIndex: <Metadata extends Record<string, any> = Record<never, never>>(name: string, query: Partial<Query<CredentialRecord<Metadata>>>, value: CredentialRecord<Metadata>[]) => Promise<boolean>;
|
74
74
|
getIndexPage: <Metadata extends Record<string, any> = Record<never, never>>(name: string, query: Partial<Query<CredentialRecord<Metadata>>>, paginationOptions?: {
|
@@ -94,15 +94,15 @@ export type CachePlane = {
|
|
94
94
|
setVc: (uri: string, value: VC | VP | undefined) => Promise<boolean>;
|
95
95
|
flushVc: () => Promise<boolean>;
|
96
96
|
};
|
97
|
-
export type PluginCachePlane = CachePlane;
|
98
|
-
export type LearnCardCachePlane<Plugins extends Plugin[]> = CachePlane & {
|
97
|
+
export declare type PluginCachePlane = CachePlane;
|
98
|
+
export declare type LearnCardCachePlane<Plugins extends Plugin[]> = CachePlane & {
|
99
99
|
providers: GetPlaneProviders<Plugins, 'cache'>;
|
100
100
|
};
|
101
|
-
export type IdPlane = {
|
101
|
+
export declare type IdPlane = {
|
102
102
|
did: (method?: string, options?: PlaneOptions) => string;
|
103
103
|
keypair: (algorithm?: string, options?: PlaneOptions) => JWK;
|
104
104
|
};
|
105
|
-
export type PluginIdPlane = IdPlane;
|
106
|
-
export type LearnCardIdPlane<Plugins extends Plugin[]> = IdPlane & {
|
105
|
+
export declare type PluginIdPlane = IdPlane;
|
106
|
+
export declare type LearnCardIdPlane<Plugins extends Plugin[]> = IdPlane & {
|
107
107
|
providers: GetPlaneProviders<Plugins, 'id'>;
|
108
108
|
};
|
@@ -1,18 +1,18 @@
|
|
1
1
|
/** @group Utility Types */
|
2
|
-
export type Tail<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
2
|
+
export declare type Tail<T extends any[]> = T extends [any, ...infer R] ? R : never;
|
3
3
|
/** @group Utility Types */
|
4
|
-
export type Last<T extends any[]> = T extends [...any[], infer R] ? R : never;
|
4
|
+
export declare type Last<T extends any[]> = T extends [...any[], infer R] ? R : never;
|
5
5
|
/** @group Utility Types */
|
6
|
-
export type RemoveLast<T extends any[]> = T extends [...infer R, any] ? R : [];
|
6
|
+
export declare type RemoveLast<T extends any[]> = T extends [...infer R, any] ? R : [];
|
7
7
|
/** @group Utility Types */
|
8
|
-
export type RemoveFirstArg<T extends (...args: any[]) => any> = (args: Tail<Parameters<T>>) => ReturnType<T>;
|
8
|
+
export declare type RemoveFirstArg<T extends (...args: any[]) => any> = (args: Tail<Parameters<T>>) => ReturnType<T>;
|
9
9
|
/** @group Utility Types */
|
10
|
-
export type RemoveLastArg<T extends (...args: any[]) => any> = (args: RemoveLast<Parameters<T>>) => ReturnType<T>;
|
10
|
+
export declare type RemoveLastArg<T extends (...args: any[]) => any> = (args: RemoveLast<Parameters<T>>) => ReturnType<T>;
|
11
11
|
/** @group Utility Types */
|
12
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
12
|
+
export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
13
13
|
/** @group Utility Types */
|
14
|
-
export type MergeObjects<Objects extends Record<string, any>[]> = undefined extends Objects[2] ? Omit<Objects[0], keyof Objects[1]> & Objects[1] : Omit<MergeObjects<RemoveLast<Objects>>, keyof Last<Objects>> & Last<Objects>;
|
14
|
+
export declare type MergeObjects<Objects extends Record<string, any>[]> = undefined extends Objects[2] ? Omit<Objects[0], keyof Objects[1]> & Objects[1] : Omit<MergeObjects<RemoveLast<Objects>>, keyof Last<Objects>> & Last<Objects>;
|
15
15
|
/** @group Utility Types */
|
16
|
-
export type DeepPartial<T> = T extends object ? {
|
16
|
+
export declare type DeepPartial<T> = T extends object ? {
|
17
17
|
[P in keyof T]?: DeepPartial<T[P]>;
|
18
18
|
} : T;
|
package/dist/types/wallet.d.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
import { ControlPlane, GetPlanesForPlugins, PluginReadPlane, PluginStorePlane, PluginIndexPlane, PluginCachePlane, PluginIdPlane, LearnCardReadPlane, LearnCardStorePlane, LearnCardIndexPlane, LearnCardCachePlane, LearnCardIdPlane } from './planes';
|
2
2
|
import { UnionToIntersection, MergeObjects } from './utilities';
|
3
|
-
export type GenerateLearnCard<NewControlPlanes extends ControlPlane = never, NewMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, ControlPlanes extends ControlPlane = never, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>> = LearnCard<any, [
|
3
|
+
export declare type GenerateLearnCard<NewControlPlanes extends ControlPlane = never, NewMethods extends Record<string, (...args: any[]) => any> = Record<never, never>, ControlPlanes extends ControlPlane = never, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>> = LearnCard<any, [
|
4
4
|
ControlPlanes
|
5
5
|
] extends [1 & ControlPlanes] ? NewControlPlanes : [NewControlPlanes] extends [1 & NewControlPlanes] ? ControlPlanes : ControlPlanes | NewControlPlanes, NewMethods & Methods>;
|
6
|
-
export type AddImplicitLearnCardArgument<Functions extends Record<string, (...args: any[]) => any> = Record<never, never>, ControlPlanes extends ControlPlane = never, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>, DependentControlPlanes extends ControlPlane = never, DependentMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
6
|
+
export declare type AddImplicitLearnCardArgument<Functions extends Record<string, (...args: any[]) => any> = Record<never, never>, ControlPlanes extends ControlPlane = never, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>, DependentControlPlanes extends ControlPlane = never, DependentMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
7
7
|
[Key in keyof Functions]: <T extends GenerateLearnCard<ControlPlanes, Methods, DependentControlPlanes, DependentMethods>>(learnCard: T, ...args: Parameters<Functions[Key]>) => ReturnType<Functions[Key]>;
|
8
8
|
};
|
9
9
|
/** @group Universal Wallets */
|
10
|
-
export type GetPluginMethods<Plugins extends Plugin[]> = undefined extends Plugins[1] ? NonNullable<Plugins[0]['_methods']> : UnionToIntersection<NonNullable<MergeObjects<{
|
10
|
+
export declare type GetPluginMethods<Plugins extends Plugin[]> = undefined extends Plugins[1] ? NonNullable<Plugins[0]['_methods']> : UnionToIntersection<NonNullable<MergeObjects<{
|
11
11
|
[Key in keyof Plugins]: NonNullable<Plugins[Key]['_methods']>;
|
12
12
|
}>>>;
|
13
13
|
/** @group Universal Wallets */
|
14
|
-
export type Plugin<Name extends string = string, ControlPlanes extends ControlPlane = any, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>, DependentControlPlanes extends ControlPlane = never, DependentMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
14
|
+
export declare type Plugin<Name extends string = string, ControlPlanes extends ControlPlane = any, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>, DependentControlPlanes extends ControlPlane = never, DependentMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
|
15
15
|
name: Name;
|
16
16
|
displayName?: string;
|
17
17
|
description?: string;
|
@@ -34,7 +34,7 @@ export type Plugin<Name extends string = string, ControlPlanes extends ControlPl
|
|
34
34
|
id: AddImplicitLearnCardArgument<PluginIdPlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
|
35
35
|
} : {}));
|
36
36
|
/** @group Universal Wallets */
|
37
|
-
export type LearnCard<Plugins extends Plugin[] = [], ControlPlanes extends ControlPlane = GetPlanesForPlugins<Plugins>, PluginMethods = GetPluginMethods<Plugins>> = {
|
37
|
+
export declare type LearnCard<Plugins extends Plugin[] = [], ControlPlanes extends ControlPlane = GetPlanesForPlugins<Plugins>, PluginMethods = GetPluginMethods<Plugins>> = {
|
38
38
|
plugins: Plugins;
|
39
39
|
invoke: PluginMethods;
|
40
40
|
addPlugin: <NewPlugin extends Plugin>(plugin: NewPlugin) => Promise<LearnCard<[...Plugins, NewPlugin]>>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Plugin } from '../../../types/wallet';
|
2
|
-
export type TestCachePlugin = Plugin<'Test Cache', 'cache'>;
|
2
|
+
export declare type TestCachePlugin = Plugin<'Test Cache', 'cache'>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Plugin } from '../../../types/wallet';
|
2
|
-
export type TestIndexPlugin = Plugin<'Test Index', 'index'>;
|
2
|
+
export declare type TestIndexPlugin = Plugin<'Test Index', 'index'>;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { Plugin } from '../../../types/wallet';
|
2
|
-
export type TestStoragePlugin = Plugin<'Test Storage', 'read' | 'store' | 'index'>;
|
2
|
+
export declare type TestStoragePlugin = Plugin<'Test Storage', 'read' | 'store' | 'index'>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@learncard/core",
|
3
|
-
"version": "9.0.
|
3
|
+
"version": "9.0.3",
|
4
4
|
"description": "",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/core.esm.js",
|
@@ -40,7 +40,7 @@
|
|
40
40
|
"isomorphic-fetch": "^3.0.0",
|
41
41
|
"isomorphic-webcrypto": "^2.3.8",
|
42
42
|
"zod": "^3.20.2",
|
43
|
-
"@learncard/helpers": "1.0.
|
43
|
+
"@learncard/helpers": "1.0.7"
|
44
44
|
},
|
45
45
|
"scripts": {
|
46
46
|
"build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.build.json && tsc-alias",
|