@learncard/core 2.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
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;
@@ -4625,12 +4635,13 @@ export declare type EthereumConfig = {
4625
4635
  network?: providers.Networkish;
4626
4636
  };
4627
4637
  export declare type IDXPluginMethods = {
4628
- getCredentialsListFromIndex: (alias?: string) => Promise<CredentialsList>;
4638
+ getCredentialsListFromIdx: (alias?: string) => Promise<CredentialsList>;
4629
4639
  publishContentToCeramic: (cred: any) => Promise<string>;
4630
4640
  readContentFromCeramic: (streamId: string) => Promise<any>;
4631
- getVerifiableCredentialFromIndex: (title: string) => Promise<any>;
4632
- getVerifiableCredentialsFromIndex: () => Promise<any>;
4641
+ getVerifiableCredentialFromIdx: (title: string) => Promise<VC>;
4642
+ getVerifiableCredentialsFromIdx: () => Promise<VC[]>;
4633
4643
  addVerifiableCredentialInIdx: (cred: IDXCredential) => Promise<StreamID>;
4644
+ removeVerifiableCredentialInIdx: (title: string) => Promise<StreamID>;
4634
4645
  };
4635
4646
  declare enum StorageType {
4636
4647
  ceramic = "ceramic"
@@ -4655,9 +4666,13 @@ export declare type DependentMethods = {
4655
4666
  export declare type VCPluginMethods = DependentMethods & {
4656
4667
  issueCredential: (credential: UnsignedVC) => Promise<VC>;
4657
4668
  verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4658
- issuePresentation: (credential: VC) => Promise<VP>;
4669
+ issuePresentation: (credential: UnsignedVP) => Promise<VP>;
4659
4670
  verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
4660
4671
  getTestVc: (subject?: string) => UnsignedVC;
4672
+ getTestVp: (credential?: VC) => Promise<UnsignedVP>;
4673
+ };
4674
+ export declare type VerifyExtension = {
4675
+ verifyCredential: (credential: VC) => Promise<VerificationCheck>;
4661
4676
  };
4662
4677
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
4663
4678
  export declare type Plugin<Name extends string, PublicMethods extends Record<string, (...args: any[]) => any> = Record<never, never>> = {
@@ -4677,9 +4692,7 @@ export declare type Wallet<PluginNames extends string = "", PluginMethods extend
4677
4692
  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>>;
4678
4693
  };
4679
4694
  export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "IDX" | "Expiration" | "Ethereum", DidKeyPluginMethods<DidMethod> & VCPluginMethods & IDXPluginMethods & EthereumPluginMethods>;
4680
- export declare type LearnCardWallet = {
4681
- /** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
4682
- _wallet: LearnCardRawWallet;
4695
+ export declare type AllLearnCardMethods = {
4683
4696
  /** Wallet holder's did */
4684
4697
  did: (type?: DidMethod) => string;
4685
4698
  /** Wallet holder's ed25519 key pair */
@@ -4699,7 +4712,7 @@ export declare type LearnCardWallet = {
4699
4712
  */
4700
4713
  verifyCredential: (credential: VC) => Promise<VerificationItem[]>;
4701
4714
  /** Creates a signed Verifiable Presentation from a signed Verifiable Credential */
4702
- issuePresentation: (credential: VC) => Promise<VP>;
4715
+ issuePresentation: (presentation: UnsignedVP) => Promise<VP>;
4703
4716
  /**
4704
4717
  * Verifies a signed Verifiable Presentation
4705
4718
  *
@@ -4707,9 +4720,11 @@ export declare type LearnCardWallet = {
4707
4720
  */
4708
4721
  verifyPresentation: (presentation: VP) => Promise<VerificationCheck>;
4709
4722
  /** Returns the credential marked with `title` from IDX */
4710
- getCredential: (title: string) => Promise<any>;
4723
+ getCredential: (title: string) => Promise<VC>;
4711
4724
  /** Returns all credentials from IDX */
4712
- getCredentials: () => Promise<any[]>;
4725
+ getCredentials: () => Promise<VC[]>;
4726
+ /** Returns all credentials from IDX */
4727
+ getCredentialsList: () => Promise<IDXCredential[]>;
4713
4728
  /**
4714
4729
  * Publishes a credential to Ceramic, returning the credential's stream ID
4715
4730
  *
@@ -4717,7 +4732,7 @@ export declare type LearnCardWallet = {
4717
4732
  *
4718
4733
  * Resolving a stream ID can be done by passing the stream ID to `readFromCeramic`
4719
4734
  */
4720
- publishCredential: (credential: any) => Promise<string>;
4735
+ publishCredential: (credential: VC) => Promise<string>;
4721
4736
  /**
4722
4737
  * Adds a stream ID pointing to a credential (such as the one returned by `publishCredential`)
4723
4738
  * to IDX with a bespoke title
@@ -4726,6 +4741,14 @@ export declare type LearnCardWallet = {
4726
4741
  * or by using `getCredentials` to get a list of all credentials that have been added to IDX
4727
4742
  */
4728
4743
  addCredential: (credential: IDXCredential) => Promise<void>;
4744
+ /**
4745
+ * Adds a stream ID pointing to a credential (such as the one returned by `publishCredential`)
4746
+ * to IDX with a bespoke title
4747
+ *
4748
+ * The credential may then be retrieved using `getCredential` and passing in that bespoke title,
4749
+ * or by using `getCredentials` to get a list of all credentials that have been added to IDX
4750
+ */
4751
+ removeCredential: (title: string) => Promise<void>;
4729
4752
  /**
4730
4753
  * Resolves a stream ID, returning its contents
4731
4754
  *
@@ -4739,6 +4762,13 @@ export declare type LearnCardWallet = {
4739
4762
  * You can use this to test out implementations that use this library!
4740
4763
  */
4741
4764
  getTestVc: (subject?: string) => UnsignedVC;
4765
+ /**
4766
+ * Wraps a crednetial in an exmaple presentaion. If no credential is provided, a new one will be
4767
+ * generated using getTestVc
4768
+ *
4769
+ * You can use this to test out implementations that use this library!
4770
+ */
4771
+ getTestVp: (credential?: VC) => Promise<UnsignedVP>;
4742
4772
  /**
4743
4773
  * Returns your ETH balance
4744
4774
  */
@@ -4752,6 +4782,11 @@ export declare type LearnCardWallet = {
4752
4782
  */
4753
4783
  checkMyUsdc: () => Promise<string>;
4754
4784
  };
4785
+ export declare type LearnCard<Methods extends keyof AllLearnCardMethods = keyof AllLearnCardMethods, RawWallet extends Wallet<any, any> = LearnCardRawWallet> = {
4786
+ /** Raw IoE wallet instance. You shouldn't need to drop down to this level! */
4787
+ _wallet: RawWallet;
4788
+ } & Pick<AllLearnCardMethods, Methods>;
4789
+ export declare type EmptyLearnCard = LearnCard<"verifyCredential" | "verifyPresentation", Wallet<"DIDKit" | "Expiration", DidkitPluginMethods & VerifyExtension>>;
4755
4790
  export declare type CeramicIDXArgs = {
4756
4791
  modelData: ModelAliases;
4757
4792
  credentialAlias: string;
@@ -4764,9 +4799,11 @@ export declare type LearnCardConfig = {
4764
4799
  defaultContents: any[];
4765
4800
  ethereumConfig: EthereumConfig;
4766
4801
  };
4802
+ /** Generates an empty wallet with no key material */
4803
+ export declare const emptyWallet: ({ didkit, }?: Partial<Pick<LearnCardConfig, "didkit">>) => Promise<EmptyLearnCard>;
4767
4804
  /** Generates a LearnCard Wallet from a 64 character seed string */
4768
- export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, ethereumConfig, }?: Partial<LearnCardConfig>) => Promise<LearnCardWallet>;
4769
- export { walletFromKey } from "@wallet/init";
4805
+ export declare const walletFromKey: (key: string, { ceramicIdx, didkit, defaultContents, ethereumConfig, }?: Partial<LearnCardConfig>) => Promise<LearnCard>;
4806
+ export * from "@wallet/init";
4770
4807
  export { Wallet, Plugin } from "types/wallet";
4771
4808
 
4772
4809
  export {};