@learncard/core 8.4.2 → 8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/core.cjs.development.js +2949 -1722
  2. package/dist/core.cjs.development.js.map +4 -4
  3. package/dist/core.cjs.production.min.js +124 -118
  4. package/dist/core.cjs.production.min.js.map +4 -4
  5. package/dist/core.esm.js +2949 -1722
  6. package/dist/core.esm.js.map +4 -4
  7. package/dist/didkit/didkit_wasm.d.ts +15 -2
  8. package/dist/didkit/didkit_wasm.js +44 -19
  9. package/dist/didkit/didkit_wasm_bg.wasm +0 -0
  10. package/dist/didkit/didkit_wasm_bg.wasm.d.ts +4 -2
  11. package/dist/didkit/index.d.ts +4 -0
  12. package/dist/didkit_wasm.d.ts +15 -2
  13. package/dist/didkit_wasm.js +44 -19
  14. package/dist/didkit_wasm_bg.wasm +0 -0
  15. package/dist/didkit_wasm_bg.wasm.d.ts +4 -2
  16. package/dist/index.d.ts +7 -0
  17. package/dist/polyfills.d.ts +2 -0
  18. package/dist/types/LearnCard.d.ts +63 -0
  19. package/dist/types/helpers.d.ts +18 -0
  20. package/dist/types/planes.d.ts +77 -0
  21. package/dist/types/utilities.d.ts +14 -0
  22. package/dist/types/wallet.d.ts +52 -0
  23. package/dist/wallet/base/crypto.d.ts +2 -0
  24. package/dist/wallet/base/helpers.d.ts +16 -0
  25. package/dist/wallet/base/index.d.ts +2 -0
  26. package/dist/wallet/base/wallet.d.ts +15 -0
  27. package/dist/wallet/defaults.d.ts +5 -0
  28. package/dist/wallet/init.d.ts +29 -0
  29. package/dist/wallet/initializers/apiLearnCard.d.ts +14 -0
  30. package/dist/wallet/initializers/customLearnCard.d.ts +7 -0
  31. package/dist/wallet/initializers/emptyLearnCard.d.ts +7 -0
  32. package/dist/wallet/initializers/learnCardFromSeed.d.ts +7 -0
  33. package/dist/wallet/plugins/EthereumPlugin/hardcodedTokens.d.ts +22 -0
  34. package/dist/wallet/plugins/EthereumPlugin/helpers.d.ts +7 -0
  35. package/dist/wallet/plugins/EthereumPlugin/index.d.ts +7 -0
  36. package/dist/wallet/plugins/EthereumPlugin/types.d.ts +32 -0
  37. package/dist/wallet/plugins/ceramic/ceramic.d.ts +215 -0
  38. package/dist/wallet/plugins/ceramic/helpers.d.ts +3 -0
  39. package/dist/wallet/plugins/ceramic/index.d.ts +4 -0
  40. package/dist/wallet/plugins/ceramic/types.d.ts +43 -0
  41. package/dist/wallet/plugins/chapi/chapi.d.ts +5 -0
  42. package/dist/wallet/plugins/chapi/index.d.ts +2 -0
  43. package/dist/wallet/plugins/chapi/types.d.ts +88 -0
  44. package/dist/wallet/plugins/didkey/helpers.d.ts +4 -0
  45. package/dist/wallet/plugins/didkey/index.d.ts +217 -0
  46. package/dist/wallet/plugins/didkey/types.d.ts +18 -0
  47. package/dist/wallet/plugins/didkit/index.d.ts +8 -0
  48. package/dist/wallet/plugins/didkit/types.d.ts +40 -0
  49. package/dist/wallet/plugins/expiration/index.d.ts +7 -0
  50. package/dist/wallet/plugins/expiration/types.d.ts +3 -0
  51. package/dist/wallet/plugins/idx/idx.d.ts +6 -0
  52. package/dist/wallet/plugins/idx/index.d.ts +4 -0
  53. package/dist/wallet/plugins/idx/types.d.ts +54 -0
  54. package/dist/wallet/plugins/index.d.ts +14 -0
  55. package/dist/wallet/plugins/learn-card/index.d.ts +7 -0
  56. package/dist/wallet/plugins/learn-card/types.d.ts +17 -0
  57. package/dist/wallet/plugins/learn-card/verify.d.ts +215 -0
  58. package/dist/wallet/plugins/test-cache/index.d.ts +2 -0
  59. package/dist/wallet/plugins/test-cache/types.d.ts +2 -0
  60. package/dist/wallet/plugins/test-index/index.d.ts +2 -0
  61. package/dist/wallet/plugins/test-index/types.d.ts +2 -0
  62. package/dist/wallet/plugins/test-storage/index.d.ts +2 -0
  63. package/dist/wallet/plugins/test-storage/types.d.ts +2 -0
  64. package/dist/wallet/plugins/vc/index.d.ts +2 -0
  65. package/dist/wallet/plugins/vc/issueCredential.d.ts +98 -0
  66. package/dist/wallet/plugins/vc/issuePresentation.d.ts +220 -0
  67. package/dist/wallet/plugins/vc/types.d.ts +35 -0
  68. package/dist/wallet/plugins/vc/vc.d.ts +5 -0
  69. package/dist/wallet/plugins/vc/verifyCredential.d.ts +8 -0
  70. package/dist/wallet/plugins/vc/verifyPresentation.d.ts +8 -0
  71. package/dist/wallet/plugins/vc-api/helpers.d.ts +8 -0
  72. package/dist/wallet/plugins/vc-api/index.d.ts +8 -0
  73. package/dist/wallet/plugins/vc-api/types.d.ts +20 -0
  74. package/dist/wallet/plugins/vc-resolution/index.d.ts +6 -0
  75. package/dist/wallet/plugins/vc-resolution/types.d.ts +13 -0
  76. package/dist/wallet/plugins/vc-templates/index.d.ts +2 -0
  77. package/dist/wallet/plugins/vc-templates/templates.d.ts +6 -0
  78. package/dist/wallet/plugins/vc-templates/types.d.ts +40 -0
  79. package/dist/wallet/plugins/vc-templates/vc-templates.d.ts +5 -0
  80. package/dist/wallet/plugins/vpqr/index.d.ts +7 -0
  81. package/dist/wallet/plugins/vpqr/types.d.ts +12 -0
  82. package/package.json +13 -11
  83. package/dist/core.d.ts +0 -6009
@@ -0,0 +1,52 @@
1
+ import { ControlPlane, GetPlanesForPlugins, PluginReadPlane, PluginStorePlane, PluginIndexPlane, PluginCachePlane, PluginIdPlane, LearnCardReadPlane, LearnCardStorePlane, LearnCardIndexPlane, LearnCardCachePlane, LearnCardIdPlane } from './planes';
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, [
4
+ ControlPlanes
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>> = {
7
+ [Key in keyof Functions]: <T extends GenerateLearnCard<ControlPlanes, Methods, DependentControlPlanes, DependentMethods>>(learnCard: T, ...args: Parameters<Functions[Key]>) => ReturnType<Functions[Key]>;
8
+ };
9
+ /** @group Universal Wallets */
10
+ export type GetPluginMethods<Plugins extends Plugin[]> = undefined extends Plugins[1] ? NonNullable<Plugins[0]['_methods']> : UnionToIntersection<NonNullable<MergeObjects<{
11
+ [Key in keyof Plugins]: NonNullable<Plugins[Key]['_methods']>;
12
+ }>>>;
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>> = {
15
+ name: Name;
16
+ displayName?: string;
17
+ description?: string;
18
+ methods: AddImplicitLearnCardArgument<Methods, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
19
+ _methods?: Methods;
20
+ read?: {};
21
+ store?: {};
22
+ index?: {};
23
+ cache?: {};
24
+ id?: {};
25
+ } & ([ControlPlanes] extends [1 & ControlPlanes] ? {} : ('read' extends ControlPlanes ? {
26
+ read: AddImplicitLearnCardArgument<PluginReadPlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
27
+ } : {}) & ('store' extends ControlPlanes ? {
28
+ store: AddImplicitLearnCardArgument<PluginStorePlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
29
+ } : {}) & ('index' extends ControlPlanes ? {
30
+ index: AddImplicitLearnCardArgument<PluginIndexPlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
31
+ } : {}) & ('cache' extends ControlPlanes ? {
32
+ cache: AddImplicitLearnCardArgument<PluginCachePlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
33
+ } : {}) & ('id' extends ControlPlanes ? {
34
+ id: AddImplicitLearnCardArgument<PluginIdPlane, ControlPlanes, Methods, DependentControlPlanes, DependentMethods>;
35
+ } : {}));
36
+ /** @group Universal Wallets */
37
+ export type LearnCard<Plugins extends Plugin[] = [], ControlPlanes extends ControlPlane = GetPlanesForPlugins<Plugins>, PluginMethods = GetPluginMethods<Plugins>> = {
38
+ plugins: Plugins;
39
+ invoke: PluginMethods;
40
+ addPlugin: <NewPlugin extends Plugin>(plugin: NewPlugin) => Promise<LearnCard<[...Plugins, NewPlugin]>>;
41
+ debug?: typeof console.log;
42
+ } & ([ControlPlanes] extends [1 & ControlPlanes] ? {} : ('read' extends ControlPlanes ? {
43
+ read: LearnCardReadPlane<Plugins>;
44
+ } : {}) & ('store' extends ControlPlanes ? {
45
+ store: LearnCardStorePlane<Plugins>;
46
+ } : {}) & ('index' extends ControlPlanes ? {
47
+ index: LearnCardIndexPlane<Plugins>;
48
+ } : {}) & ('cache' extends ControlPlanes ? {
49
+ cache: LearnCardCachePlane<Plugins>;
50
+ } : {}) & ('id' extends ControlPlanes ? {
51
+ id: LearnCardIdPlane<Plugins>;
52
+ } : {}));
@@ -0,0 +1,2 @@
1
+ import crypto from 'isomorphic-webcrypto';
2
+ export default crypto;
@@ -0,0 +1,16 @@
1
+ import { LearnCard, Plugin } from '../../types/wallet';
2
+ import { ControlPlane } from '../../types/planes';
3
+ /** Type guard for removing null/undefined */
4
+ export declare const isNotNull: <T>(item?: T | null | undefined) => item is T;
5
+ /** Removes null/undefined from items in an array */
6
+ export declare const filterNulls: <T>(array: (T | null | undefined)[]) => T[];
7
+ /**
8
+ * Loops through an array, running a callback over it until that callback returns a value. Once the
9
+ * first value is found, it is returned. If no value is found, undefined is returned instead
10
+ */
11
+ export declare const findFirstResult: <T, U>(array: T[], callback: (item: T) => U | undefined) => U | undefined;
12
+ export declare const pluginImplementsPlane: <Plane extends ControlPlane>(plugin: Plugin, plane: Plane) => plugin is Plugin<any, Plane, Record<never, never>, never, Record<never, never>>;
13
+ export declare const learnCardImplementsPlane: <Plane extends ControlPlane>(learnCard: LearnCard<any, any, any>, plane: Plane) => learnCard is LearnCard<any, Plane, any>;
14
+ export declare const mapObject: <T extends string, U, V>(obj: Record<T, U>, callback: (value: U, index: number) => V) => Record<T, V>;
15
+ export declare const isFulfilledAndNotEmpty: <T>(input: PromiseSettledResult<T>) => input is PromiseFulfilledResult<T>;
16
+ export declare const uniqBy: <Obj extends Record<string, any>>(array: Obj[], key: keyof Obj | ((obj: Obj) => any)) => Obj[];
@@ -0,0 +1,2 @@
1
+ export * from './wallet';
2
+ export * from './crypto';
@@ -0,0 +1,15 @@
1
+ import { LearnCard, GetPluginMethods, AddImplicitLearnCardArgument } from '../../types/wallet';
2
+ import { GetPlanesForPlugins } from '../../types/planes';
3
+ /** @group Universal Wallets */
4
+ export declare const generateLearnCard: <Plugins extends {
5
+ name: string;
6
+ displayName?: string | undefined;
7
+ description?: string | undefined;
8
+ methods: AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
9
+ _methods?: Record<never, never> | undefined;
10
+ read?: {} | undefined;
11
+ store?: {} | undefined;
12
+ index?: {} | undefined;
13
+ cache?: {} | undefined;
14
+ id?: {} | undefined;
15
+ }[] = [], ControlPlanes extends GetPlanesForPlugins<Plugins> = GetPlanesForPlugins<Plugins>, PluginMethods extends GetPluginMethods<Plugins> = GetPluginMethods<Plugins>>(_learnCard?: Partial<LearnCard<Plugins, ControlPlanes, PluginMethods>>) => Promise<LearnCard<Plugins, ControlPlanes, PluginMethods>>;
@@ -0,0 +1,5 @@
1
+ import { CeramicArgs } from './plugins/ceramic/types';
2
+ import { IDXArgs } from './plugins/idx/types';
3
+ import { EthereumConfig } from './plugins/EthereumPlugin/types';
4
+ export declare const defaultCeramicIDXArgs: CeramicArgs & IDXArgs;
5
+ export declare const defaultEthereumArgs: EthereumConfig;
@@ -0,0 +1,29 @@
1
+ import { EmptyLearnCard, LearnCardFromSeed, LearnCardFromVcApi, CustomLearnCard } from '../types/LearnCard';
2
+ export * from './initializers/customLearnCard';
3
+ export * from './initializers/emptyLearnCard';
4
+ export * from './initializers/learnCardFromSeed';
5
+ export * from './initializers/apiLearnCard';
6
+ /**
7
+ * Generates an Empty Wallet
8
+ *
9
+ * @group Init Functions
10
+ */
11
+ export declare function initLearnCard(config?: EmptyLearnCard['args']): Promise<EmptyLearnCard['returnValue']>;
12
+ /**
13
+ * Generates a full wallet from a 32 byte seed
14
+ *
15
+ * @group Init Functions
16
+ */
17
+ export declare function initLearnCard(config: LearnCardFromSeed['args']): Promise<LearnCardFromSeed['returnValue']>;
18
+ /**
19
+ * Generates a wallet that can sign VCs/VPs from a VC API
20
+ *
21
+ * @group Init Functions
22
+ */
23
+ export declare function initLearnCard(config: LearnCardFromVcApi['args']): Promise<LearnCardFromVcApi['returnValue']>;
24
+ /**
25
+ * Generates a custom wallet with no plugins added
26
+ *
27
+ * @group Init Functions
28
+ */
29
+ export declare function initLearnCard(config: CustomLearnCard['args']): Promise<CustomLearnCard['returnValue']>;
@@ -0,0 +1,14 @@
1
+ import { LearnCardFromVcApi } from '../../types/LearnCard';
2
+ /**
3
+ * Generates a LearnCard Wallet from a 64 character seed string
4
+ *
5
+ * @group Init Functions
6
+ */
7
+ export declare const learnCardFromApiUrl: ({ url, did, debug, }: {
8
+ url: string;
9
+ did?: string | undefined;
10
+ debug?: {
11
+ (...data: any[]): void;
12
+ (message?: any, ...optionalParams: any[]): void;
13
+ } | undefined;
14
+ }) => Promise<LearnCardFromVcApi['returnValue']>;
@@ -0,0 +1,7 @@
1
+ import { CustomLearnCard } from '../../types/LearnCard';
2
+ /**
3
+ * Generates a custom LearnCard with no plugins added
4
+ *
5
+ * @group Init Functions
6
+ */
7
+ export declare const customLearnCard: ({ debug }?: Partial<CustomLearnCard['args']>) => Promise<CustomLearnCard['returnValue']>;
@@ -0,0 +1,7 @@
1
+ import { EmptyLearnCard } from '../../types/LearnCard';
2
+ /**
3
+ * Generates an empty wallet with no key material
4
+ *
5
+ * @group Init Functions
6
+ */
7
+ export declare const emptyLearnCard: ({ didkit, debug }?: EmptyLearnCard['args']) => Promise<EmptyLearnCard['returnValue']>;
@@ -0,0 +1,7 @@
1
+ import { LearnCardConfig, LearnCardFromSeed } from '../../types/LearnCard';
2
+ /**
3
+ * Generates a LearnCard Wallet from a 64 character seed string
4
+ *
5
+ * @group Init Functions
6
+ */
7
+ export declare const learnCardFromSeed: (seed: string, { ceramicIdx, didkit, ethereumConfig, debug, }?: Partial<LearnCardConfig>) => Promise<LearnCardFromSeed['returnValue']>;
@@ -0,0 +1,22 @@
1
+ export declare const hardcodedTokens: {
2
+ name: string;
3
+ address: string;
4
+ symbol: string;
5
+ decimals: number;
6
+ chainId: number;
7
+ logoURI: string;
8
+ extensions: {
9
+ bridgeInfo: {
10
+ '10': {
11
+ tokenAddress: string;
12
+ };
13
+ '137': {
14
+ tokenAddress: string;
15
+ };
16
+ '42161': {
17
+ tokenAddress: string;
18
+ };
19
+ };
20
+ };
21
+ }[];
22
+ export default hardcodedTokens;
@@ -0,0 +1,7 @@
1
+ import { ethers } from 'ethers';
2
+ import { Token, TokenList } from './types';
3
+ export declare const isAddress: (maybeAddress: string) => boolean;
4
+ export declare const formatUnits: (units: ethers.BigNumberish, symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<string>;
5
+ export declare const parseUnits: (units: string, symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<ethers.BigNumber>;
6
+ export declare const getTokenFromSymbolOrAddress: (symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<Token | undefined>;
7
+ export declare const getChainIdFromProvider: (provider: ethers.providers.Provider) => Promise<number>;
@@ -0,0 +1,7 @@
1
+ import { LearnCard } from '../../../types/wallet';
2
+ import { EthereumConfig, EthereumPlugin } from './types';
3
+ export * from './types';
4
+ /**
5
+ * @group Plugins
6
+ */
7
+ export declare const getEthereumPlugin: (initLearnCard: LearnCard<any, 'id'>, config: EthereumConfig) => EthereumPlugin;
@@ -0,0 +1,32 @@
1
+ import { providers } from 'ethers';
2
+ import { Plugin } from '../../../types/wallet';
3
+ /** @group Ethereum Plugin */
4
+ export type EthereumPluginMethods = {
5
+ getEthereumAddress: () => string;
6
+ getBalance: (symbolOrAddress?: string) => Promise<string>;
7
+ getBalanceForAddress: (walletAddress: string, symbolOrAddress?: string) => Promise<string>;
8
+ transferTokens: (tokenSymbolOrAddress: string, amount: number, toAddress: string) => Promise<string>;
9
+ getGasPrice: () => Promise<string>;
10
+ getCurrentNetwork: () => providers.Networkish;
11
+ changeNetwork: (network: providers.Networkish) => void;
12
+ addInfuraProjectId: (infuraProjectIdToAdd: string) => void;
13
+ };
14
+ /** @group Ethereum Plugin */
15
+ export type EthereumConfig = {
16
+ infuraProjectId?: string;
17
+ network?: providers.Networkish;
18
+ };
19
+ /** @group Ethereum Plugin */
20
+ export type Token = {
21
+ chainId: number;
22
+ address: string;
23
+ name: string;
24
+ symbol: string;
25
+ decimals: number;
26
+ logoURI: string;
27
+ extensions: any;
28
+ };
29
+ /** @group Ethereum Plugin */
30
+ export type TokenList = Token[];
31
+ /** @group Ethereum Plugin */
32
+ export type EthereumPlugin = Plugin<'Ethereum', any, EthereumPluginMethods, 'id'>;
@@ -0,0 +1,215 @@
1
+ import { CeramicPlugin, CeramicPluginDependentMethods, CeramicArgs } from './types';
2
+ import { LearnCard } from '../../../types/wallet';
3
+ /**
4
+ * @group Plugins
5
+ */
6
+ export declare const getCeramicPlugin: <URI extends string = "">(learnCard: {
7
+ plugins: any;
8
+ invoke: CeramicPluginDependentMethods<URI>;
9
+ addPlugin: <NewPlugin extends {
10
+ name: string;
11
+ displayName?: string | undefined;
12
+ description?: string | undefined;
13
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
14
+ _methods?: Record<never, never> | undefined;
15
+ read?: {} | undefined;
16
+ store?: {} | undefined;
17
+ index?: {} | undefined;
18
+ cache?: {} | undefined;
19
+ id?: {} | undefined;
20
+ }>(plugin: NewPlugin) => Promise<{
21
+ plugins: [...any[], NewPlugin];
22
+ invoke: any;
23
+ addPlugin: <NewPlugin_1 extends {
24
+ name: string;
25
+ displayName?: string | undefined;
26
+ description?: string | undefined;
27
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
28
+ _methods?: Record<never, never> | undefined;
29
+ read?: {} | undefined;
30
+ store?: {} | undefined;
31
+ index?: {} | undefined;
32
+ cache?: {} | undefined;
33
+ id?: {} | undefined;
34
+ }>(plugin: NewPlugin_1) => Promise<{
35
+ plugins: [...any[], NewPlugin, NewPlugin_1];
36
+ invoke: any;
37
+ addPlugin: <NewPlugin_2 extends {
38
+ name: string;
39
+ displayName?: string | undefined;
40
+ description?: string | undefined;
41
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
42
+ _methods?: Record<never, never> | undefined;
43
+ read?: {} | undefined;
44
+ store?: {} | undefined;
45
+ index?: {} | undefined;
46
+ cache?: {} | undefined;
47
+ id?: {} | undefined;
48
+ }>(plugin: NewPlugin_2) => Promise<{
49
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2];
50
+ invoke: any;
51
+ addPlugin: <NewPlugin_3 extends {
52
+ name: string;
53
+ displayName?: string | undefined;
54
+ description?: string | undefined;
55
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
56
+ _methods?: Record<never, never> | undefined;
57
+ read?: {} | undefined;
58
+ store?: {} | undefined;
59
+ index?: {} | undefined;
60
+ cache?: {} | undefined;
61
+ id?: {} | undefined;
62
+ }>(plugin: NewPlugin_3) => Promise<{
63
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3];
64
+ invoke: any;
65
+ addPlugin: <NewPlugin_4 extends {
66
+ name: string;
67
+ displayName?: string | undefined;
68
+ description?: string | undefined;
69
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
70
+ _methods?: Record<never, never> | undefined;
71
+ read?: {} | undefined;
72
+ store?: {} | undefined;
73
+ index?: {} | undefined;
74
+ cache?: {} | undefined;
75
+ id?: {} | undefined;
76
+ }>(plugin: NewPlugin_4) => Promise<{
77
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4];
78
+ invoke: any;
79
+ addPlugin: <NewPlugin_5 extends {
80
+ name: string;
81
+ displayName?: string | undefined;
82
+ description?: string | undefined;
83
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
84
+ _methods?: Record<never, never> | undefined;
85
+ read?: {} | undefined;
86
+ store?: {} | undefined;
87
+ index?: {} | undefined;
88
+ cache?: {} | undefined;
89
+ id?: {} | undefined;
90
+ }>(plugin: NewPlugin_5) => Promise<{
91
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4, NewPlugin_5];
92
+ invoke: any;
93
+ addPlugin: <NewPlugin_6 extends {
94
+ name: string;
95
+ displayName?: string | undefined;
96
+ description?: string | undefined;
97
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
98
+ _methods?: Record<never, never> | undefined;
99
+ read?: {} | undefined;
100
+ store?: {} | undefined;
101
+ index?: {} | undefined;
102
+ cache?: {} | undefined;
103
+ id?: {} | undefined;
104
+ }>(plugin: NewPlugin_6) => Promise<{
105
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4, NewPlugin_5, NewPlugin_6];
106
+ invoke: any;
107
+ addPlugin: <NewPlugin_7 extends {
108
+ name: string;
109
+ displayName?: string | undefined;
110
+ description?: string | undefined;
111
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
112
+ _methods?: Record<never, never> | undefined;
113
+ read?: {} | undefined;
114
+ store?: {} | undefined;
115
+ index?: {} | undefined;
116
+ cache?: {} | undefined;
117
+ id?: {} | undefined;
118
+ }>(plugin: NewPlugin_7) => Promise<{
119
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4, NewPlugin_5, NewPlugin_6, NewPlugin_7];
120
+ invoke: any;
121
+ addPlugin: <NewPlugin_8 extends {
122
+ name: string;
123
+ displayName?: string | undefined;
124
+ description?: string | undefined;
125
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
126
+ _methods?: Record<never, never> | undefined;
127
+ read?: {} | undefined;
128
+ store?: {} | undefined;
129
+ index?: {} | undefined;
130
+ cache?: {} | undefined;
131
+ id?: {} | undefined;
132
+ }>(plugin: NewPlugin_8) => Promise<{
133
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4, NewPlugin_5, NewPlugin_6, NewPlugin_7, NewPlugin_8];
134
+ invoke: any;
135
+ addPlugin: <NewPlugin_9 extends {
136
+ name: string;
137
+ displayName?: string | undefined;
138
+ description?: string | undefined;
139
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
140
+ _methods?: Record<never, never> | undefined;
141
+ read?: {} | undefined;
142
+ store?: {} | undefined;
143
+ index?: {} | undefined;
144
+ cache?: {} | undefined;
145
+ id?: {} | undefined;
146
+ }>(plugin: NewPlugin_9) => Promise<{
147
+ plugins: [...any[], NewPlugin, NewPlugin_1, NewPlugin_2, NewPlugin_3, NewPlugin_4, NewPlugin_5, NewPlugin_6, NewPlugin_7, NewPlugin_8, NewPlugin_9];
148
+ invoke: any;
149
+ addPlugin: <NewPlugin_10 extends {
150
+ name: string;
151
+ displayName?: string | undefined;
152
+ description?: string | undefined;
153
+ methods: import("../../../types/wallet").AddImplicitLearnCardArgument<Record<never, never>, any, Record<never, never>, never, Record<never, never>>;
154
+ _methods?: Record<never, never> | undefined;
155
+ read?: {} | undefined;
156
+ store?: {} | undefined;
157
+ index?: {} | undefined;
158
+ cache?: {} | undefined;
159
+ id?: {} | undefined;
160
+ }>(plugin: NewPlugin_10) => Promise<any>;
161
+ debug?: {
162
+ (...data: any[]): void;
163
+ (message?: any, ...optionalParams: any[]): void;
164
+ } | undefined;
165
+ }>;
166
+ debug?: {
167
+ (...data: any[]): void;
168
+ (message?: any, ...optionalParams: any[]): void;
169
+ } | undefined;
170
+ }>;
171
+ debug?: {
172
+ (...data: any[]): void;
173
+ (message?: any, ...optionalParams: any[]): void;
174
+ } | undefined;
175
+ }>;
176
+ debug?: {
177
+ (...data: any[]): void;
178
+ (message?: any, ...optionalParams: any[]): void;
179
+ } | undefined;
180
+ }>;
181
+ debug?: {
182
+ (...data: any[]): void;
183
+ (message?: any, ...optionalParams: any[]): void;
184
+ } | undefined;
185
+ }>;
186
+ debug?: {
187
+ (...data: any[]): void;
188
+ (message?: any, ...optionalParams: any[]): void;
189
+ } | undefined;
190
+ }>;
191
+ debug?: {
192
+ (...data: any[]): void;
193
+ (message?: any, ...optionalParams: any[]): void;
194
+ } | undefined;
195
+ }>;
196
+ debug?: {
197
+ (...data: any[]): void;
198
+ (message?: any, ...optionalParams: any[]): void;
199
+ } | undefined;
200
+ }>;
201
+ debug?: {
202
+ (...data: any[]): void;
203
+ (message?: any, ...optionalParams: any[]): void;
204
+ } | undefined;
205
+ }>;
206
+ debug?: {
207
+ (...data: any[]): void;
208
+ (message?: any, ...optionalParams: any[]): void;
209
+ } | undefined;
210
+ }>;
211
+ debug?: {
212
+ (...data: any[]): void;
213
+ (message?: any, ...optionalParams: any[]): void;
214
+ } | undefined;
215
+ }, { ceramicEndpoint, defaultContentFamily }: CeramicArgs) => Promise<CeramicPlugin>;
@@ -0,0 +1,3 @@
1
+ import { StreamID } from '@ceramicnetwork/streamid';
2
+ import { CeramicURI } from './types';
3
+ export declare const streamIdToCeramicURI: (id: string | StreamID) => CeramicURI;
@@ -0,0 +1,4 @@
1
+ import { getCeramicPlugin } from './ceramic';
2
+ export { getCeramicPlugin } from './ceramic';
3
+ export * from './types';
4
+ export default getCeramicPlugin;
@@ -0,0 +1,43 @@
1
+ import type { DID, CreateJWEOptions, DIDResolutionResult } from 'dids';
2
+ import { z } from 'zod';
3
+ import { CeramicClient } from '@ceramicnetwork/http-client';
4
+ import { Plugin } from '../../../types/wallet';
5
+ import { ResolutionExtension } from '../vc-resolution';
6
+ import { InputMetadata } from '../didkit';
7
+ /** @group CeramicPlugin */
8
+ export type CeramicArgs = {
9
+ ceramicEndpoint: string;
10
+ defaultContentFamily: string;
11
+ };
12
+ /** @group CeramicPlugin */
13
+ export type CeramicURI = `lc:ceramic:${string}`;
14
+ /** @group CeramicPlugin */
15
+ export declare const CeramicURIValidator: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
16
+ /**
17
+ * Settings for toggling JWE Encryption before uploading to Ceramic.
18
+ * @group CeramicPlugin
19
+ * @param encrypt enable JWE encryption on upload.
20
+ * @param controllersCanDecrypt helper to add Ceramic controller DIDs to recipients who can decrypt the JWE credential.
21
+ * @param recipients DIDs who can decrypt the JWE credential.
22
+ * @param options additional CreateJWEOptions for encryption.
23
+ */
24
+ export type CeramicEncryptionParams = {
25
+ encrypt: boolean;
26
+ controllersCanDecrypt?: boolean;
27
+ recipients?: string[] | undefined;
28
+ options?: CreateJWEOptions | undefined;
29
+ };
30
+ /** @group CeramicPlugin */
31
+ export type CeramicPluginMethods<URI extends string = ''> = {
32
+ publishContentToCeramic: (cred: any, encryption: CeramicEncryptionParams | undefined) => Promise<CeramicURI>;
33
+ readContentFromCeramic: (streamId: string) => Promise<any>;
34
+ getCeramicClient: () => CeramicClient;
35
+ getDIDObject: () => DID;
36
+ } & ResolutionExtension<URI | CeramicURI>;
37
+ /** @group CeramicPlugin */
38
+ export type CeramicPluginDependentMethods<URI extends string = ''> = {
39
+ getKey: () => string;
40
+ didResolver: (did: string, inputMetadata?: InputMetadata) => Promise<DIDResolutionResult>;
41
+ } & ResolutionExtension<URI>;
42
+ /** @group CeramicPlugin */
43
+ export type CeramicPlugin = Plugin<'Ceramic', 'read' | 'store', CeramicPluginMethods>;
@@ -0,0 +1,5 @@
1
+ import { CHAPIPlugin } from './types';
2
+ /**
3
+ * @group Plugins
4
+ */
5
+ export declare const getCHAPIPlugin: () => Promise<CHAPIPlugin>;
@@ -0,0 +1,2 @@
1
+ export { getCHAPIPlugin } from './chapi';
2
+ export * from './types';
@@ -0,0 +1,88 @@
1
+ import { UnsignedVC, VC, UnsignedVP, VP, VerificationCheck } from '@learncard/types';
2
+ import { Plugin } from '../../../types/wallet';
3
+ import { ProofOptions } from '../didkit/types';
4
+ /** @group CHAPI Plugin */
5
+ export type WebCredential = {
6
+ new (dataType: string, data: VP, options?: {
7
+ recommendedHandlerOrigins: string[];
8
+ }): WebCredential;
9
+ type: string;
10
+ dataType: string;
11
+ data: VP;
12
+ options: {
13
+ recommendedHandlerOrigins: string[];
14
+ };
15
+ };
16
+ /** @group CHAPI Plugin */
17
+ export type CredentialRequestEvent = {
18
+ new (args: {
19
+ credentialHandler: any;
20
+ credentialRequestOrigin: string;
21
+ credentialRequestOptions: any;
22
+ hintKey: string;
23
+ }): CredentialRequestEvent;
24
+ type: string;
25
+ _credentialHandler: any;
26
+ credentialRequestOrigin: string;
27
+ credentialRequestOptions: any;
28
+ hintKey: string;
29
+ openWindow: (url: string) => Promise<any>;
30
+ respondWith: (handlerResponse: Promise<null | {
31
+ dataType: string;
32
+ data: any;
33
+ }>) => void;
34
+ };
35
+ /** @group CHAPI Plugin */
36
+ export type CredentialStoreEvent = {
37
+ new (args: {
38
+ credentialHandler: any;
39
+ credentialRequestOrigin: string;
40
+ credential: WebCredential;
41
+ hintKey: string;
42
+ }): CredentialStoreEvent;
43
+ type: string;
44
+ _credentialHandler: any;
45
+ credentialRequestOrigin: string;
46
+ credential: WebCredential;
47
+ hintKey: string;
48
+ openWindow: (url: string) => Promise<any>;
49
+ respondWith: (handlerResponse: Promise<null | {
50
+ dataType: string;
51
+ data: any;
52
+ }>) => void;
53
+ };
54
+ /** @group CHAPI Plugin */
55
+ export type HandlerResponse = {
56
+ type: 'redirect';
57
+ url: string;
58
+ } | {
59
+ type: 'response';
60
+ dataType: string;
61
+ data: any;
62
+ };
63
+ /** @group CHAPI Plugin */
64
+ export type CHAPIPluginDependentMethods = {
65
+ issueCredential: (credential: UnsignedVC, signingOptions?: Partial<ProofOptions>) => Promise<VC>;
66
+ issuePresentation: (credential: UnsignedVP, signingOptions?: Partial<ProofOptions>) => Promise<VP>;
67
+ verifyPresentation: (presentation: VP, options?: Partial<ProofOptions>) => Promise<VerificationCheck>;
68
+ getTestVp: (credential?: VC) => Promise<UnsignedVP>;
69
+ };
70
+ /** @group CHAPI Plugin */
71
+ export type CHAPIPluginMethods = {
72
+ installChapiHandler: () => Promise<void>;
73
+ activateChapiHandler: (args: {
74
+ mediatorOrigin?: string;
75
+ get?: (event: CredentialRequestEvent) => Promise<HandlerResponse>;
76
+ store?: (event: CredentialStoreEvent) => Promise<HandlerResponse>;
77
+ }) => Promise<void>;
78
+ receiveChapiEvent: () => Promise<CredentialRequestEvent | CredentialStoreEvent>;
79
+ storeCredentialViaChapiDidAuth: (credential: UnsignedVC) => Promise<{
80
+ success: true;
81
+ } | {
82
+ success: false;
83
+ reason: 'did not auth' | 'auth failed verification' | 'did not store';
84
+ }>;
85
+ storePresentationViaChapi: (presentation: UnsignedVP | VP) => Promise<Credential | undefined>;
86
+ };
87
+ /** @group CHAPI Plugin */
88
+ export type CHAPIPlugin = Plugin<'CHAPI', any, CHAPIPluginMethods, any, CHAPIPluginDependentMethods>;
@@ -0,0 +1,4 @@
1
+ import { Algorithm } from './types';
2
+ export declare const ED25519_METHODS: string[];
3
+ export declare const SECP256K1_METHODS: string[];
4
+ export declare const getAlgorithmForDidMethod: <DidMethod extends string>(didMethod: DidMethod) => Algorithm;