@learncard/core 2.1.0 → 4.1.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.
package/dist/core.d.ts CHANGED
@@ -4602,6 +4602,16 @@ export declare type ProofOptions = {
4602
4602
  verificationMethod: string;
4603
4603
  proofPurpose: string;
4604
4604
  };
4605
+ export declare type DidkitPluginMethods = {
4606
+ generateEd25519KeyFromBytes: (bytes: Uint8Array) => KeyPair;
4607
+ generateSecp256k1KeyFromBytes: (bytes: Uint8Array) => KeyPair;
4608
+ keyToDid: (type: DidMethod, keypair: KeyPair) => string;
4609
+ keyToVerificationMethod: (type: string, keypair: KeyPair) => Promise<string>;
4610
+ issueCredential: (credential: UnsignedVC, options: ProofOptions, keypair: KeyPair) => Promise<VC>;
4611
+ verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4612
+ issuePresentation: (presentation: UnsignedVP, options: ProofOptions, keypair: KeyPair) => Promise<VP>;
4613
+ verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
4614
+ };
4605
4615
  export declare type Algorithm = "ed25519" | "secp256k1";
4606
4616
  export declare type DidKeyPluginMethods<DidMethod extends string> = {
4607
4617
  getSubjectDid: (type: DidMethod) => string;
@@ -4656,11 +4666,19 @@ export declare type DependentMethods = {
4656
4666
  export declare type VCPluginMethods = DependentMethods & {
4657
4667
  issueCredential: (credential: UnsignedVC) => Promise<VC>;
4658
4668
  verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4659
- issuePresentation: (credential: VC) => Promise<VP>;
4669
+ issuePresentation: (credential: UnsignedVP) => Promise<VP>;
4660
4670
  verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
4661
4671
  getTestVc: (subject?: string) => UnsignedVC;
4672
+ getTestVp: (credential?: VC) => Promise<UnsignedVP>;
4673
+ };
4674
+ export declare type VerifyExtension = {
4675
+ verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4662
4676
  };
4663
4677
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4678
+ export declare type InitFunction<Args extends Record<string, any> | undefined = Record<string, any>, Config extends keyof LearnCardConfig = keyof LearnCardConfig, ReturnValue extends LearnCard<any, any> = LearnCard<any, any>> = {
4679
+ args: undefined extends Args ? Partial<Pick<LearnCardConfig, Config>> : Args & Partial<Pick<LearnCardConfig, Config>>;
4680
+ returnValue: ReturnValue;
4681
+ };
4664
4682
  export declare type Plugin<Name extends string, PublicMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
4665
4683
  name?: Name;
4666
4684
  pluginMethods: {
@@ -4678,9 +4696,7 @@ export declare type Wallet<PluginNames extends string = "", PluginMethods extend
4678
4696
  addPlugin: <Name extends string, Methods extends Record<string, (...args: any[]) => any> = Record<never, never>>(plugin: Plugin<Name, Methods>) => Promise<Wallet<"" extends PluginNames ? Name : PluginNames | Name, Record<never, never> extends PluginMethods ? Methods : PluginMethods & Methods>>;
4679
4697
  };
4680
4698
  export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "IDX" | "Expiration" | "Ethereum", DidKeyPluginMethods<DidMethod> & VCPluginMethods & IDXPluginMethods & EthereumPluginMethods>;
4681
- export declare type LearnCardWallet = {
4682
- /** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
4683
- _wallet: LearnCardRawWallet;
4699
+ export declare type AllLearnCardMethods = {
4684
4700
  /** Wallet holder's did */
4685
4701
  did: (type?: DidMethod) => string;
4686
4702
  /** Wallet holder's ed25519 key pair */
@@ -4700,7 +4716,7 @@ export declare type LearnCardWallet = {
4700
4716
  */
4701
4717
  verifyCredential: (credential: VC) => Promise<VerificationItem[]>;
4702
4718
  /** Creates a signed Verifiable Presentation from a signed Verifiable Credential */
4703
- issuePresentation: (credential: VC) => Promise<VP>;
4719
+ issuePresentation: (presentation: UnsignedVP) => Promise<VP>;
4704
4720
  /**
4705
4721
  * Verifies a signed Verifiable Presentation
4706
4722
  *
@@ -4750,6 +4766,13 @@ export declare type LearnCardWallet = {
4750
4766
  * You can use this to test out implementations that use this library!
4751
4767
  */
4752
4768
  getTestVc: (subject?: string) => UnsignedVC;
4769
+ /**
4770
+ * Wraps a crednetial in an exmaple presentaion. If no credential is provided, a new one will be
4771
+ * generated using getTestVc
4772
+ *
4773
+ * You can use this to test out implementations that use this library!
4774
+ */
4775
+ getTestVp: (credential?: VC) => Promise<UnsignedVP>;
4753
4776
  /**
4754
4777
  * Returns your ETH balance
4755
4778
  */
@@ -4763,6 +4786,11 @@ export declare type LearnCardWallet = {
4763
4786
  */
4764
4787
  checkMyUsdc: () => Promise<string>;
4765
4788
  };
4789
+ export declare type LearnCard<Methods extends keyof AllLearnCardMethods = keyof AllLearnCardMethods, RawWallet extends Wallet<any, any> = LearnCardRawWallet> = {
4790
+ /** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
4791
+ _wallet: RawWallet;
4792
+ } & Pick<AllLearnCardMethods, Methods>;
4793
+ export declare type EmptyLearnCard = LearnCard<"verifyCredential" | "verifyPresentation", Wallet<"DIDKit" | "Expiration", DidkitPluginMethods & VerifyExtension>>;
4766
4794
  export declare type CeramicIDXArgs = {
4767
4795
  modelData: ModelAliases;
4768
4796
  credentialAlias: string;
@@ -4775,9 +4803,17 @@ export declare type LearnCardConfig = {
4775
4803
  defaultContents: any[];
4776
4804
  ethereumConfig: EthereumConfig;
4777
4805
  };
4806
+ export declare type EmptyWallet = InitFunction<undefined, "didkit", EmptyLearnCard>;
4807
+ export declare type WalletFromKey = InitFunction<{
4808
+ seed: string;
4809
+ }, keyof LearnCardConfig, LearnCard>;
4810
+ /** Generates an empty wallet with no key material */
4811
+ export declare const emptyWallet: ({ didkit }?: EmptyWallet["args"]) => Promise<EmptyWallet["returnValue"]>;
4778
4812
  /** Generates a LearnCard Wallet from a 64 character seed string */
4779
- export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, ethereumConfig, }?: Partial<LearnCardConfig>) => Promise<LearnCardWallet>;
4780
- export { walletFromKey } from "@wallet/init";
4813
+ export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, ethereumConfig, }?: Partial<LearnCardConfig>) => Promise<LearnCard>;
4814
+ export declare function initLearnCard(config?: EmptyWallet["args"]): Promise<EmptyWallet["returnValue"]>;
4815
+ export declare function initLearnCard(config: WalletFromKey["args"]): Promise<WalletFromKey["returnValue"]>;
4816
+ export * from "@wallet/init";
4781
4817
  export { Wallet, Plugin } from "types/wallet";
4782
4818
 
4783
4819
  export {};