@learncard/core 6.3.1 → 7.0.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.cjs.development.js +85 -48
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +125 -125
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +115 -117
- package/dist/core.esm.js +85 -48
- package/dist/core.esm.js.map +3 -3
- package/package.json +2 -2
package/dist/core.d.ts
CHANGED
@@ -4645,23 +4645,12 @@ declare const VerificationItemValidator: z.ZodObject<{
|
|
4645
4645
|
check: string;
|
4646
4646
|
}>;
|
4647
4647
|
export declare type VerificationItem = z.infer<typeof VerificationItemValidator>;
|
4648
|
-
declare const IDXCredentialValidator: z.ZodObject<{
|
4649
|
-
id: z.ZodString;
|
4650
|
-
title: z.ZodString;
|
4651
|
-
storageType: z.ZodOptional<z.ZodEnum<[
|
4652
|
-
"ceramic"
|
4653
|
-
]>>;
|
4654
|
-
}, "strip", z.ZodTypeAny, {
|
4655
|
-
storageType?: "ceramic" | undefined;
|
4656
|
-
id: string;
|
4657
|
-
title: string;
|
4658
|
-
}, {
|
4659
|
-
storageType?: "ceramic" | undefined;
|
4660
|
-
id: string;
|
4661
|
-
title: string;
|
4662
|
-
}>;
|
4663
4648
|
/** @group IDXPlugin */
|
4664
|
-
export declare type IDXCredential =
|
4649
|
+
export declare type IDXCredential<Metadata extends Record<string, any> = Record<never, never>> = {
|
4650
|
+
id: string;
|
4651
|
+
uri: string;
|
4652
|
+
[key: string]: any;
|
4653
|
+
} & Metadata;
|
4665
4654
|
declare const JWKValidator: z.ZodObject<{
|
4666
4655
|
kty: z.ZodString;
|
4667
4656
|
crv: z.ZodString;
|
@@ -4755,55 +4744,16 @@ export declare type Token = {
|
|
4755
4744
|
};
|
4756
4745
|
/** @group Ethereum Plugin */
|
4757
4746
|
export declare type TokenList = Token[];
|
4758
|
-
/** @group
|
4759
|
-
export declare type
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
defaultContentFamily: string;
|
4747
|
+
/** @group VC Resolution Plugin */
|
4748
|
+
export declare type LC_URI<URI extends string = ""> = string | URI;
|
4749
|
+
/** @group VC Resolution Plugin */
|
4750
|
+
export declare type VCResolutionPluginMethods = {
|
4751
|
+
resolveCredential: (uri?: LC_URI) => Promise<VC | undefined>;
|
4764
4752
|
};
|
4765
|
-
/** @group
|
4766
|
-
export declare type
|
4767
|
-
|
4768
|
-
publishContentToCeramic: (cred: any) => Promise<string>;
|
4769
|
-
readContentFromCeramic: (streamId: string) => Promise<any>;
|
4770
|
-
getVerifiableCredentialFromIdx: (title: string) => Promise<VC>;
|
4771
|
-
getVerifiableCredentialsFromIdx: () => Promise<VC[]>;
|
4772
|
-
addVerifiableCredentialInIdx: (cred: IDXCredential) => Promise<StreamID>;
|
4773
|
-
removeVerifiableCredentialInIdx: (title: string) => Promise<StreamID>;
|
4753
|
+
/** @group VC Resolution Plugin */
|
4754
|
+
export declare type ResolutionExtension<URI extends string> = {
|
4755
|
+
resolveCredential: (uri?: LC_URI<URI>) => Promise<VC | undefined>;
|
4774
4756
|
};
|
4775
|
-
/** @group IDXPlugin */
|
4776
|
-
export declare const CredentialsListValidator: z.ZodObject<{
|
4777
|
-
credentials: z.ZodArray<z.ZodObject<{
|
4778
|
-
id: z.ZodString;
|
4779
|
-
title: z.ZodString;
|
4780
|
-
storageType: z.ZodOptional<z.ZodEnum<[
|
4781
|
-
"ceramic"
|
4782
|
-
]>>;
|
4783
|
-
}, "strip", z.ZodTypeAny, {
|
4784
|
-
storageType?: "ceramic" | undefined;
|
4785
|
-
id: string;
|
4786
|
-
title: string;
|
4787
|
-
}, {
|
4788
|
-
storageType?: "ceramic" | undefined;
|
4789
|
-
id: string;
|
4790
|
-
title: string;
|
4791
|
-
}>, "many">;
|
4792
|
-
}, "strict", z.ZodTypeAny, {
|
4793
|
-
credentials: {
|
4794
|
-
storageType?: "ceramic" | undefined;
|
4795
|
-
id: string;
|
4796
|
-
title: string;
|
4797
|
-
}[];
|
4798
|
-
}, {
|
4799
|
-
credentials: {
|
4800
|
-
storageType?: "ceramic" | undefined;
|
4801
|
-
id: string;
|
4802
|
-
title: string;
|
4803
|
-
}[];
|
4804
|
-
}>;
|
4805
|
-
/** @group IDXPlugin */
|
4806
|
-
export declare type CredentialsList = z.infer<typeof CredentialsListValidator>;
|
4807
4757
|
export declare type Last<T extends any[]> = T extends [
|
4808
4758
|
...any[],
|
4809
4759
|
infer R
|
@@ -4837,6 +4787,52 @@ export declare type Wallet<PluginNames extends string = "", PluginMethods extend
|
|
4837
4787
|
Methods
|
4838
4788
|
]>>>;
|
4839
4789
|
};
|
4790
|
+
/** @group IDXPlugin */
|
4791
|
+
export declare type CeramicIDXArgs = {
|
4792
|
+
modelData: ModelAliases;
|
4793
|
+
credentialAlias: string;
|
4794
|
+
ceramicEndpoint: string;
|
4795
|
+
defaultContentFamily: string;
|
4796
|
+
};
|
4797
|
+
/** @group IDXPlugin */
|
4798
|
+
export declare type CeramicURI = `lc:ceramic:${string}`;
|
4799
|
+
/** @group IDXPlugin */
|
4800
|
+
export declare const CeramicURIValidator: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
4801
|
+
/** @group IDXPlugin */
|
4802
|
+
export declare type IDXPluginMethods<URI extends string = ""> = {
|
4803
|
+
getCredentialsListFromIdx: <Metadata extends Record<string, any> = Record<never, never>>(alias?: string) => Promise<CredentialsList<Metadata>>;
|
4804
|
+
publishContentToCeramic: (cred: any) => Promise<CeramicURI>;
|
4805
|
+
readContentFromCeramic: (streamId: string) => Promise<any>;
|
4806
|
+
getVerifiableCredentialFromIdx: (id: string) => Promise<VC | undefined>;
|
4807
|
+
getVerifiableCredentialsFromIdx: () => Promise<VC[]>;
|
4808
|
+
addVerifiableCredentialInIdx: <Metadata extends Record<string, any> = Record<never, never>>(cred: IDXCredential<Metadata>) => Promise<CeramicURI>;
|
4809
|
+
removeVerifiableCredentialInIdx: (title: string) => Promise<StreamID>;
|
4810
|
+
} & ResolutionExtension<URI | CeramicURI>;
|
4811
|
+
/** @group IDXPlugin */
|
4812
|
+
export declare type IDXPluginDependentMethods<URI extends string = ""> = {
|
4813
|
+
getKey: () => string;
|
4814
|
+
} & ResolutionExtension<URI>;
|
4815
|
+
/** @group IDXPlugin */
|
4816
|
+
export declare type CredentialsList<Metadata extends Record<string, any> = Record<never, never>> = {
|
4817
|
+
credentials: Array<IDXCredential<Metadata>>;
|
4818
|
+
};
|
4819
|
+
/** @group IDXPlugin */
|
4820
|
+
export declare const CredentialsListValidator: z.ZodType<CredentialsList>;
|
4821
|
+
/** @group IDXPlugin */
|
4822
|
+
export declare type BackwardsCompatIDXCredential<Metadata extends Record<string, any> = Record<never, never>> = {
|
4823
|
+
[key: string]: any;
|
4824
|
+
id: string;
|
4825
|
+
title: string;
|
4826
|
+
storageType?: "ceramic";
|
4827
|
+
} & Metadata;
|
4828
|
+
/** @group IDXPlugin */
|
4829
|
+
export declare const BackwardsCompatIDXCredentialValidator: z.ZodType<BackwardsCompatIDXCredential>;
|
4830
|
+
/** @group IDXPlugin */
|
4831
|
+
export declare type BackwardsCompatCredentialsList<Metadata extends Record<string, any> = Record<never, never>> = {
|
4832
|
+
credentials: Array<IDXCredential<Metadata> | BackwardsCompatIDXCredential<Metadata>>;
|
4833
|
+
};
|
4834
|
+
/** @group IDXPlugin */
|
4835
|
+
export declare const BackwardsCompatCredentialsListValidator: z.ZodType<BackwardsCompatCredentialsList>;
|
4840
4836
|
/** @group VC Plugin */
|
4841
4837
|
export declare type VCPluginDependentMethods = {
|
4842
4838
|
getSubjectDid: (type: "key") => string;
|
@@ -5013,6 +5009,39 @@ export declare type VCAPIPluginMethods = {
|
|
5013
5009
|
getTestVc: (subject?: string) => UnsignedVC;
|
5014
5010
|
getTestVp: (credential?: VC) => Promise<UnsignedVP>;
|
5015
5011
|
};
|
5012
|
+
/**
|
5013
|
+
*
|
5014
|
+
* @group Plugins
|
5015
|
+
*/
|
5016
|
+
export declare const getDidKitPlugin: (input?: InitInput | Promise<InitInput>) => Promise<Plugin<"DIDKit", DidkitPluginMethods>>;
|
5017
|
+
/**
|
5018
|
+
*
|
5019
|
+
* @group Plugins
|
5020
|
+
*/
|
5021
|
+
export declare const getDidKeyPlugin: <DidMethod extends string>(wallet: Wallet<string, DependentMethods<DidMethod>>, key: string) => Promise<Plugin<"DID Key", DidKeyPluginMethods<DidMethod>, Record<never, never>>>;
|
5022
|
+
/**
|
5023
|
+
* @group Plugins
|
5024
|
+
*/
|
5025
|
+
export declare const getVCPlugin: (wallet: Wallet<string, VCPluginDependentMethods>) => Plugin<"VC", VCPluginMethods, VCPluginDependentMethods>;
|
5026
|
+
/**
|
5027
|
+
* @group Plugins
|
5028
|
+
*/
|
5029
|
+
export declare const getIDXPlugin: <URI extends string = "">(wallet: Wallet<any, IDXPluginDependentMethods<URI>>, { modelData, credentialAlias, ceramicEndpoint, defaultContentFamily }: CeramicIDXArgs) => Promise<Plugin<"IDX", IDXPluginMethods<URI>, Record<never, never>>>;
|
5030
|
+
/**
|
5031
|
+
* @group Plugins
|
5032
|
+
*/
|
5033
|
+
export declare const ExpirationPlugin: (wallet: Wallet<any, VerifyExtension>) => Plugin<"Expiration", VerifyExtension>;
|
5034
|
+
/**
|
5035
|
+
* @group Plugins
|
5036
|
+
*/
|
5037
|
+
export declare const getEthereumPlugin: (initWallet: Wallet<string, {
|
5038
|
+
getSubjectDid: (type: DidMethod) => string;
|
5039
|
+
getSubjectKeypair: (type?: Algorithm) => JWK;
|
5040
|
+
}>, config: EthereumConfig) => Plugin<"Ethereum", EthereumPluginMethods>;
|
5041
|
+
/**
|
5042
|
+
* @group Plugins
|
5043
|
+
*/
|
5044
|
+
export declare const getVpqrPlugin: (wallet: Wallet<string, VpqrPluginDependentMethods>) => Plugin<"Vpqr", VpqrPluginMethods>;
|
5016
5045
|
/**
|
5017
5046
|
* Wallet holder's did
|
5018
5047
|
*
|
@@ -5078,7 +5107,7 @@ export declare type VerifyPresentation = (presentation: VP, options?: Partial<Pr
|
|
5078
5107
|
*
|
5079
5108
|
* @group LearnCard Methods
|
5080
5109
|
*/
|
5081
|
-
export declare type GetCredential = (title: string) => Promise<VC>;
|
5110
|
+
export declare type GetCredential = (title: string) => Promise<VC | undefined>;
|
5082
5111
|
/**
|
5083
5112
|
* Returns all credentials from IDX
|
5084
5113
|
*
|
@@ -5090,37 +5119,33 @@ export declare type GetCredentials = () => Promise<VC[]>;
|
|
5090
5119
|
*
|
5091
5120
|
* @group LearnCard Methods
|
5092
5121
|
*/
|
5093
|
-
export declare type GetCredentialsList = () => Promise<IDXCredential[]>;
|
5122
|
+
export declare type GetCredentialsList = <Metadata extends Record<string, any> = Record<never, never>>() => Promise<IDXCredential<Metadata>[]>;
|
5094
5123
|
/**
|
5095
|
-
* Publishes a credential to Ceramic, returning the credential's
|
5124
|
+
* Publishes a credential to Ceramic, returning the credential's Ceramic URI
|
5096
5125
|
*
|
5097
|
-
* This
|
5126
|
+
* This URI may then be shared/persisted/resolved to gain access to the credential
|
5098
5127
|
*
|
5099
|
-
* Resolving a
|
5128
|
+
* Resolving a URI can be done by passing the URI to `resolveCredential`
|
5100
5129
|
*
|
5101
5130
|
* @group LearnCard Methods
|
5102
5131
|
*/
|
5103
|
-
export declare type PublishCredential = (credential: VC) => Promise<
|
5132
|
+
export declare type PublishCredential = (credential: VC) => Promise<CeramicURI>;
|
5104
5133
|
/**
|
5105
|
-
* Adds a
|
5106
|
-
* to IDX with a bespoke
|
5134
|
+
* Adds a URI pointing to a credential (such as the one returned by `publishCredential`)
|
5135
|
+
* to IDX with a bespoke ID
|
5107
5136
|
*
|
5108
|
-
* The credential may then be retrieved using `getCredential` and passing in that bespoke
|
5109
|
-
* or by using `getCredentials` to get a list of all credentials that have been added to IDX
|
5137
|
+
* The credential may then be retrieved using `getCredential` and passing in that bespoke ID,
|
5138
|
+
* or by using `getCredentials`/`getCredentialsList` to get a list of all credentials that have been added to IDX
|
5110
5139
|
*
|
5111
5140
|
* @group LearnCard Methods
|
5112
5141
|
*/
|
5113
|
-
export declare type AddCredential = (credential: IDXCredential) => Promise<void>;
|
5142
|
+
export declare type AddCredential = <Metadata extends Record<string, any> = Record<never, never>>(credential: IDXCredential<Metadata>) => Promise<void>;
|
5114
5143
|
/**
|
5115
|
-
*
|
5116
|
-
* to IDX with a bespoke title
|
5117
|
-
*
|
5118
|
-
* The credential may then be retrieved using `getCredential` and passing in that bespoke title,
|
5119
|
-
* or by using `getCredentials` to get a list of all credentials that have been added to IDX
|
5144
|
+
* Removes a credential from IDX by passing in its bespoke ID
|
5120
5145
|
*
|
5121
5146
|
* @group LearnCard Methods
|
5122
5147
|
*/
|
5123
|
-
export declare type RemoveCredential = (
|
5148
|
+
export declare type RemoveCredential = (id: string) => Promise<void>;
|
5124
5149
|
/**
|
5125
5150
|
* Resolves a did to its did document
|
5126
5151
|
*
|
@@ -5130,12 +5155,18 @@ export declare type ResolveDid = (did: string, inputMetadata?: InputMetadata) =>
|
|
5130
5155
|
/**
|
5131
5156
|
* Resolves a stream ID, returning its contents
|
5132
5157
|
*
|
5158
|
+
* @group LearnCard Methods
|
5159
|
+
*/
|
5160
|
+
export declare type ReadFromCeramic = (streamId: string) => Promise<any>;
|
5161
|
+
/**
|
5162
|
+
* Resolves a LearnCard URI (e.g. lc:ceramic:1234561)
|
5163
|
+
*
|
5133
5164
|
* This can be given the return value of `publishCredential` to gain access to the credential
|
5134
5165
|
* that was published
|
5135
5166
|
*
|
5136
5167
|
* @group LearnCard Methods
|
5137
5168
|
*/
|
5138
|
-
export declare type
|
5169
|
+
export declare type ResolveCredential = (URI?: string | "" | `lc:ceramic:${string}`) => Promise<VC | undefined>;
|
5139
5170
|
/**
|
5140
5171
|
* Returns an example credential, optionally allowing a subject's did to be passed in
|
5141
5172
|
*
|
@@ -5269,6 +5300,7 @@ export declare type AllLearnCardMethods = {
|
|
5269
5300
|
removeCredential: RemoveCredential;
|
5270
5301
|
resolveDid: ResolveDid;
|
5271
5302
|
readFromCeramic: ReadFromCeramic;
|
5303
|
+
resolveCredential: ResolveCredential;
|
5272
5304
|
getTestVc: GetTestVc;
|
5273
5305
|
getTestVp: GetTestVp;
|
5274
5306
|
getEthereumAddress: GetEthereumAddress;
|
@@ -5287,10 +5319,11 @@ export declare type AllLearnCardMethods = {
|
|
5287
5319
|
storeCredentialViaChapiDidAuth: StoreCredentialViaChapiDidAuth;
|
5288
5320
|
};
|
5289
5321
|
/** @group Universal Wallets */
|
5290
|
-
export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "VC Templates" | "IDX" | "Expiration" | "Ethereum" | "Vpqr" | "CHAPI", MergeObjects<[
|
5322
|
+
export declare type LearnCardRawWallet = Wallet<"DIDKit" | "DID Key" | "VC" | "VC Templates" | "VC Resolution" | "IDX" | "Expiration" | "Ethereum" | "Vpqr" | "CHAPI", MergeObjects<[
|
5291
5323
|
DidKeyPluginMethods<DidMethod>,
|
5292
5324
|
VCPluginMethods,
|
5293
5325
|
VCTemplatePluginMethods,
|
5326
|
+
VCResolutionPluginMethods,
|
5294
5327
|
IDXPluginMethods,
|
5295
5328
|
EthereumPluginMethods,
|
5296
5329
|
VpqrPluginMethods,
|
@@ -5383,41 +5416,6 @@ export declare function initLearnCard(config: WalletFromKey["args"]): Promise<Wa
|
|
5383
5416
|
export declare function initLearnCard(config: WalletFromVcApi["args"]): Promise<WalletFromVcApi["returnValue"]>;
|
5384
5417
|
/** @group Universal Wallets */
|
5385
5418
|
export declare const generateWallet: <PluginNames extends string, PluginMethods extends Record<string, (...args: any[]) => any> = Record<never, never>>(contents?: any[], _wallet?: Partial<Wallet<any, PluginMethods>>) => Promise<Wallet<PluginNames, PluginMethods>>;
|
5386
|
-
/**
|
5387
|
-
*
|
5388
|
-
* @group Plugins
|
5389
|
-
*/
|
5390
|
-
export declare const getDidKitPlugin: (input?: InitInput | Promise<InitInput>) => Promise<Plugin<"DIDKit", DidkitPluginMethods>>;
|
5391
|
-
/**
|
5392
|
-
*
|
5393
|
-
* @group Plugins
|
5394
|
-
*/
|
5395
|
-
export declare const getDidKeyPlugin: <DidMethod extends string>(wallet: Wallet<string, DependentMethods<DidMethod>>, key: string) => Promise<Plugin<"DID Key", DidKeyPluginMethods<DidMethod>, Record<never, never>>>;
|
5396
|
-
/**
|
5397
|
-
* @group Plugins
|
5398
|
-
*/
|
5399
|
-
export declare const getVCPlugin: (wallet: Wallet<string, VCPluginDependentMethods>) => Plugin<"VC", VCPluginMethods, VCPluginDependentMethods>;
|
5400
|
-
/**
|
5401
|
-
* @group Plugins
|
5402
|
-
*/
|
5403
|
-
export declare const getIDXPlugin: (wallet: Wallet<any, {
|
5404
|
-
getKey: () => string;
|
5405
|
-
}>, { modelData, credentialAlias, ceramicEndpoint, defaultContentFamily }: CeramicIDXArgs) => Promise<Plugin<"IDX", IDXPluginMethods>>;
|
5406
|
-
/**
|
5407
|
-
* @group Plugins
|
5408
|
-
*/
|
5409
|
-
export declare const ExpirationPlugin: (wallet: Wallet<any, VerifyExtension>) => Plugin<"Expiration", VerifyExtension>;
|
5410
|
-
/**
|
5411
|
-
* @group Plugins
|
5412
|
-
*/
|
5413
|
-
export declare const getEthereumPlugin: (initWallet: Wallet<string, {
|
5414
|
-
getSubjectDid: (type: DidMethod) => string;
|
5415
|
-
getSubjectKeypair: (type?: Algorithm) => JWK;
|
5416
|
-
}>, config: EthereumConfig) => Plugin<"Ethereum", EthereumPluginMethods>;
|
5417
|
-
/**
|
5418
|
-
* @group Plugins
|
5419
|
-
*/
|
5420
|
-
export declare const getVpqrPlugin: (wallet: Wallet<string, VpqrPluginDependentMethods>) => Plugin<"Vpqr", VpqrPluginMethods>;
|
5421
5419
|
export * from "@wallet/init";
|
5422
5420
|
export { Wallet, Plugin } from "types/wallet";
|
5423
5421
|
export * from "types/LearnCard";
|
package/dist/core.esm.js
CHANGED
@@ -42181,7 +42181,7 @@ var AlignmentValidator = mod.object({
|
|
42181
42181
|
targetType: AlignmentTargetTypeValidator.optional(),
|
42182
42182
|
targetUrl: mod.string()
|
42183
42183
|
});
|
42184
|
-
var
|
42184
|
+
var KnownAchievementTypeValidator = mod.enum([
|
42185
42185
|
"Achievement",
|
42186
42186
|
"ApprenticeshipCertificate",
|
42187
42187
|
"Assessment",
|
@@ -42213,7 +42213,8 @@ var AchievementTypeValidator = mod.enum([
|
|
42213
42213
|
"MicroCredential",
|
42214
42214
|
"ResearchDoctorate",
|
42215
42215
|
"SecondarySchoolDiploma"
|
42216
|
-
])
|
42216
|
+
]);
|
42217
|
+
var AchievementTypeValidator = KnownAchievementTypeValidator.or(mod.string());
|
42217
42218
|
var CriteriaValidator = mod.object({ id: mod.string().optional(), narrative: mod.string().optional() }).catchall(mod.any());
|
42218
42219
|
var EndorsementSubjectValidator = mod.object({
|
42219
42220
|
id: mod.string(),
|
@@ -42366,13 +42367,7 @@ var CredentialInfoValidator = mod.object({
|
|
42366
42367
|
issuee: ProfileValidator.optional(),
|
42367
42368
|
credentialSubject: CredentialSubjectValidator.optional()
|
42368
42369
|
});
|
42369
|
-
var
|
42370
|
-
var StorageTypeEnum = StorageTypeValidator.enum;
|
42371
|
-
var IDXCredentialValidator = mod.object({
|
42372
|
-
id: mod.string(),
|
42373
|
-
title: mod.string(),
|
42374
|
-
storageType: StorageTypeValidator.optional()
|
42375
|
-
});
|
42370
|
+
var IDXCredentialValidator = mod.object({ id: mod.string(), uri: mod.string() }).catchall(mod.any());
|
42376
42371
|
var JWKValidator = mod.object({
|
42377
42372
|
kty: mod.string(),
|
42378
42373
|
crv: mod.string(),
|
@@ -56700,8 +56695,16 @@ var CeramicClient = class {
|
|
56700
56695
|
};
|
56701
56696
|
__name(CeramicClient, "CeramicClient");
|
56702
56697
|
|
56698
|
+
// src/wallet/plugins/idx/helpers.ts
|
56699
|
+
var streamIdToCeramicURI = /* @__PURE__ */ __name((id) => `lc:ceramic:${id}`, "streamIdToCeramicURI");
|
56700
|
+
|
56703
56701
|
// src/wallet/plugins/idx/types.ts
|
56702
|
+
var CeramicURIValidator = mod.string().refine((string2) => string2.split(":").length === 3 && string2.split(":")[0] === "lc", "URI must be of the form lc:${storage}:${url}").refine((string2) => string2.split(":")[1] === "ceramic", "URI must use storage type ceramic (i.e. must be lc:ceramic:${streamID})");
|
56704
56703
|
var CredentialsListValidator = mod.object({ credentials: IDXCredentialValidator.array() }).strict();
|
56704
|
+
var BackwardsCompatIDXCredentialValidator = mod.object({ id: mod.string(), title: mod.string(), storageType: mod.literal("ceramic").optional() }).catchall(mod.any());
|
56705
|
+
var BackwardsCompatCredentialsListValidator = mod.object({
|
56706
|
+
credentials: IDXCredentialValidator.or(BackwardsCompatIDXCredentialValidator).array()
|
56707
|
+
}).strict();
|
56705
56708
|
|
56706
56709
|
// src/wallet/plugins/idx/idx.ts
|
56707
56710
|
var getCeramicClientFromWalletSuite = /* @__PURE__ */ __name((wallet, ceramicEndpoint) => __async(void 0, null, function* () {
|
@@ -56726,38 +56729,32 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
|
|
56726
56729
|
const validationResult = yield CredentialsListValidator.spa(list);
|
56727
56730
|
if (validationResult.success)
|
56728
56731
|
return validationResult.data;
|
56732
|
+
const backwardsCompatValidationResult = yield BackwardsCompatCredentialsListValidator.spa(list);
|
56733
|
+
if (backwardsCompatValidationResult.success) {
|
56734
|
+
const oldCreds = backwardsCompatValidationResult.data.credentials;
|
56735
|
+
const newCreds = oldCreds.map((cred) => {
|
56736
|
+
if ("uri" in cred)
|
56737
|
+
return cred;
|
56738
|
+
const _a = cred, { title, id, storageType } = _a, rest = __objRest(_a, ["title", "id", "storageType"]);
|
56739
|
+
return __spreadProps(__spreadValues({}, rest), {
|
56740
|
+
id: title,
|
56741
|
+
uri: `lc:ceramic:${id.replace("ceramic://", "")}`
|
56742
|
+
});
|
56743
|
+
});
|
56744
|
+
const credentialsList = { credentials: newCreds };
|
56745
|
+
yield dataStore.set(credentialAlias, credentialsList);
|
56746
|
+
return credentialsList;
|
56747
|
+
}
|
56729
56748
|
console.error(validationResult.error);
|
56730
56749
|
throw new Error("Invalid credentials list stored in IDX");
|
56731
56750
|
}), "getCredentialsListFromIdx");
|
56732
|
-
const
|
56733
|
-
|
56734
|
-
|
56735
|
-
throw new Error("record is required");
|
56736
|
-
if (!record.id)
|
56737
|
-
throw Error("No streamId provided");
|
56738
|
-
if (record.id.indexOf("ceramic://") === -1)
|
56739
|
-
record.id = "ceramic://" + record.id;
|
56740
|
-
if (!alias)
|
56741
|
-
alias = credentialAlias;
|
56742
|
-
const existing = yield getCredentialsListFromIdx(alias);
|
56743
|
-
const indexOfExistingCredential = existing.credentials.findIndex((credential) => {
|
56744
|
-
return credential.title === record.title;
|
56745
|
-
});
|
56746
|
-
if (indexOfExistingCredential > -1) {
|
56747
|
-
existing.credentials[indexOfExistingCredential] = __spreadValues({
|
56748
|
-
storageType: StorageTypeEnum.ceramic
|
56749
|
-
}, record);
|
56750
|
-
} else
|
56751
|
-
existing.credentials.push(__spreadValues({ storageType: StorageTypeEnum.ceramic }, record));
|
56752
|
-
return dataStore.set(alias, existing);
|
56753
|
-
}), "addCredentialStreamIdToIdx");
|
56754
|
-
const removeCredentialFromIdx = /* @__PURE__ */ __name((title, alias) => __async(void 0, null, function* () {
|
56755
|
-
if (!title)
|
56756
|
-
throw new Error("record is required");
|
56751
|
+
const removeCredentialFromIdx = /* @__PURE__ */ __name((id, alias) => __async(void 0, null, function* () {
|
56752
|
+
if (!id)
|
56753
|
+
throw new Error("Must provide id to remove");
|
56757
56754
|
if (!alias)
|
56758
56755
|
alias = credentialAlias;
|
56759
56756
|
const existing = yield getCredentialsListFromIdx(alias);
|
56760
|
-
existing.credentials = existing.credentials.filter((credential) => credential.
|
56757
|
+
existing.credentials = existing.credentials.filter((credential) => credential.id !== id);
|
56761
56758
|
return dataStore.set(alias, existing);
|
56762
56759
|
}), "removeCredentialFromIdx");
|
56763
56760
|
const publishContentToCeramic = /* @__PURE__ */ __name((_02, ..._12) => __async(void 0, [_02, ..._12], function* (content, metadata = {}, options = {}) {
|
@@ -56782,30 +56779,56 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
|
|
56782
56779
|
return getCredentialsListFromIdx(alias);
|
56783
56780
|
}),
|
56784
56781
|
publishContentToCeramic: (_wallet, cred) => __async(void 0, null, function* () {
|
56785
|
-
return publishContentToCeramic(cred);
|
56782
|
+
return streamIdToCeramicURI(yield publishContentToCeramic(cred));
|
56786
56783
|
}),
|
56787
56784
|
readContentFromCeramic: (_wallet, streamId) => __async(void 0, null, function* () {
|
56788
56785
|
return readContentFromCeramic(streamId);
|
56789
56786
|
}),
|
56790
|
-
getVerifiableCredentialFromIdx: (_wallet,
|
56787
|
+
getVerifiableCredentialFromIdx: (_wallet, id) => __async(void 0, null, function* () {
|
56791
56788
|
var _a;
|
56792
56789
|
const credentialList = yield getCredentialsListFromIdx();
|
56793
|
-
const credential = (_a = credentialList == null ? void 0 : credentialList.credentials) == null ? void 0 : _a.find((cred) => (cred == null ? void 0 : cred.
|
56794
|
-
return credential
|
56790
|
+
const credential = (_a = credentialList == null ? void 0 : credentialList.credentials) == null ? void 0 : _a.find((cred) => (cred == null ? void 0 : cred.id) === id);
|
56791
|
+
return (credential == null ? void 0 : credential.uri) ? _wallet.pluginMethods.resolveCredential(credential.uri) : void 0;
|
56795
56792
|
}),
|
56796
|
-
getVerifiableCredentialsFromIdx: () => __async(void 0, null, function* () {
|
56793
|
+
getVerifiableCredentialsFromIdx: (_wallet) => __async(void 0, null, function* () {
|
56797
56794
|
var _a, _b;
|
56798
56795
|
const credentialList = yield getCredentialsListFromIdx();
|
56799
|
-
const
|
56800
|
-
return Promise.all(
|
56801
|
-
return
|
56802
|
-
})));
|
56796
|
+
const uris = (_b = (_a = credentialList == null ? void 0 : credentialList.credentials) == null ? void 0 : _a.map((credential) => credential == null ? void 0 : credential.uri)) != null ? _b : [];
|
56797
|
+
return (yield Promise.all(uris.map((uri) => __async(void 0, null, function* () {
|
56798
|
+
return _wallet.pluginMethods.resolveCredential(uri);
|
56799
|
+
})))).filter((vc) => !!vc);
|
56803
56800
|
}),
|
56804
56801
|
addVerifiableCredentialInIdx: (_wallet, idxCredential) => __async(void 0, null, function* () {
|
56805
|
-
|
56802
|
+
const record = IDXCredentialValidator.parse(idxCredential);
|
56803
|
+
if (!record)
|
56804
|
+
throw new Error("record is required");
|
56805
|
+
if (!record.uri)
|
56806
|
+
throw Error("No URI provided");
|
56807
|
+
yield _wallet.pluginMethods.resolveCredential(record.uri);
|
56808
|
+
const existing = yield getCredentialsListFromIdx(credentialAlias);
|
56809
|
+
const indexOfExistingCredential = existing.credentials.findIndex((credential) => {
|
56810
|
+
return credential.id === record.id;
|
56811
|
+
});
|
56812
|
+
if (indexOfExistingCredential > -1) {
|
56813
|
+
existing.credentials[indexOfExistingCredential] = record;
|
56814
|
+
} else
|
56815
|
+
existing.credentials.push(record);
|
56816
|
+
return streamIdToCeramicURI(yield dataStore.set(credentialAlias, existing));
|
56806
56817
|
}),
|
56807
|
-
removeVerifiableCredentialInIdx: (_wallet,
|
56808
|
-
return removeCredentialFromIdx(
|
56818
|
+
removeVerifiableCredentialInIdx: (_wallet, id) => __async(void 0, null, function* () {
|
56819
|
+
return removeCredentialFromIdx(id);
|
56820
|
+
}),
|
56821
|
+
resolveCredential: (_wallet, uri) => __async(void 0, null, function* () {
|
56822
|
+
if (!uri)
|
56823
|
+
return void 0;
|
56824
|
+
if (uri.startsWith("ceramic://")) {
|
56825
|
+
return VCValidator.parseAsync(yield readContentFromCeramic(uri));
|
56826
|
+
}
|
56827
|
+
const verificationResult = yield CeramicURIValidator.spa(uri);
|
56828
|
+
if (!verificationResult.success)
|
56829
|
+
return wallet.pluginMethods.resolveCredential(uri);
|
56830
|
+
const streamId = verificationResult.data.split(":")[2];
|
56831
|
+
return VCValidator.parseAsync(yield readContentFromCeramic(streamId));
|
56809
56832
|
})
|
56810
56833
|
}
|
56811
56834
|
};
|
@@ -60296,6 +60319,15 @@ var defaultEthereumArgs = {
|
|
60296
60319
|
network: "mainnet"
|
60297
60320
|
};
|
60298
60321
|
|
60322
|
+
// src/wallet/plugins/vc-resolution/index.ts
|
60323
|
+
var VCResolutionPlugin = {
|
60324
|
+
pluginMethods: {
|
60325
|
+
resolveCredential: (_wallet, uri) => __async(void 0, null, function* () {
|
60326
|
+
throw new Error(`No Credential Resolution Plugins found that can resolve ${uri}`);
|
60327
|
+
})
|
60328
|
+
}
|
60329
|
+
};
|
60330
|
+
|
60299
60331
|
// src/wallet/initializers/walletFromKey.ts
|
60300
60332
|
var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, ..._1], function* (key2, {
|
60301
60333
|
ceramicIdx = defaultCeramicIDXArgs,
|
@@ -60307,7 +60339,8 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
|
|
60307
60339
|
const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
|
60308
60340
|
const didkeyAndVCWallet = yield didkeyWallet.addPlugin(getVCPlugin(didkeyWallet));
|
60309
60341
|
const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin());
|
60310
|
-
const
|
60342
|
+
const resolutionWallet = yield templateWallet.addPlugin(VCResolutionPlugin);
|
60343
|
+
const idxWallet = yield resolutionWallet.addPlugin(yield getIDXPlugin(resolutionWallet, ceramicIdx));
|
60311
60344
|
const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
|
60312
60345
|
const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
|
60313
60346
|
const vpqrWallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
|
@@ -60336,6 +60369,7 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
|
|
60336
60369
|
}),
|
60337
60370
|
resolveDid: wallet.pluginMethods.resolveDid,
|
60338
60371
|
readFromCeramic: wallet.pluginMethods.readContentFromCeramic,
|
60372
|
+
resolveCredential: wallet.pluginMethods.resolveCredential,
|
60339
60373
|
getTestVc: wallet.pluginMethods.getTestVc,
|
60340
60374
|
getTestVp: wallet.pluginMethods.getTestVp,
|
60341
60375
|
vpFromQrCode: wallet.pluginMethods.vpFromQrCode,
|
@@ -60487,6 +60521,9 @@ function initLearnCard() {
|
|
60487
60521
|
}
|
60488
60522
|
__name(initLearnCard, "initLearnCard");
|
60489
60523
|
export {
|
60524
|
+
BackwardsCompatCredentialsListValidator,
|
60525
|
+
BackwardsCompatIDXCredentialValidator,
|
60526
|
+
CeramicURIValidator,
|
60490
60527
|
CredentialsListValidator,
|
60491
60528
|
ExpirationPlugin,
|
60492
60529
|
emptyWallet,
|