@learncard/network-plugin 1.6.0 → 1.7.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.
@@ -4542,6 +4542,7 @@ var PaginatedEncryptedCredentialRecordsValidator = PaginationResponseValidator.e
4542
4542
  var LCNProfileValidator = mod.object({
4543
4543
  profileId: mod.string().min(3).max(40),
4544
4544
  displayName: mod.string().default(""),
4545
+ bio: mod.string().default(""),
4545
4546
  did: mod.string(),
4546
4547
  email: mod.string().optional(),
4547
4548
  image: mod.string().optional(),
@@ -4625,6 +4626,130 @@ var LCNSigningAuthorityForUserValidator = mod.object({
4625
4626
  did: mod.string()
4626
4627
  })
4627
4628
  });
4629
+ var ConsentFlowTermsStatusValidator = mod.enum(["live", "stale", "withdrawn"]);
4630
+ var ConsentFlowContractValidator = mod.object({
4631
+ read: mod.object({
4632
+ anonymize: mod.boolean().optional(),
4633
+ credentials: mod.object({ categories: mod.record(mod.object({ required: mod.boolean() })).default({}) }).default({}),
4634
+ personal: mod.record(mod.object({ required: mod.boolean() })).default({})
4635
+ }).default({}),
4636
+ write: mod.object({
4637
+ credentials: mod.object({ categories: mod.record(mod.object({ required: mod.boolean() })).default({}) }).default({}),
4638
+ personal: mod.record(mod.object({ required: mod.boolean() })).default({})
4639
+ }).default({})
4640
+ });
4641
+ var ConsentFlowContractDetailsValidator = mod.object({
4642
+ contract: ConsentFlowContractValidator,
4643
+ owner: LCNProfileValidator,
4644
+ name: mod.string(),
4645
+ subtitle: mod.string().optional(),
4646
+ description: mod.string().optional(),
4647
+ reasonForAccessing: mod.string().optional(),
4648
+ image: mod.string().optional(),
4649
+ uri: mod.string(),
4650
+ createdAt: mod.string(),
4651
+ updatedAt: mod.string(),
4652
+ expiresAt: mod.string().optional()
4653
+ });
4654
+ var PaginatedConsentFlowContractsValidator = PaginationResponseValidator.extend({
4655
+ records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
4656
+ });
4657
+ var ConsentFlowContractDataValidator = mod.object({
4658
+ credentials: mod.object({ categories: mod.record(mod.string().array()).default({}) }),
4659
+ personal: mod.record(mod.string()).default({}),
4660
+ date: mod.string()
4661
+ });
4662
+ var PaginatedConsentFlowDataValidator = PaginationResponseValidator.extend({
4663
+ records: ConsentFlowContractDataValidator.array()
4664
+ });
4665
+ var ConsentFlowTermsValidator = mod.object({
4666
+ read: mod.object({
4667
+ anonymize: mod.boolean().optional(),
4668
+ credentials: mod.object({
4669
+ shareAll: mod.boolean().optional(),
4670
+ sharing: mod.boolean().optional(),
4671
+ categories: mod.record(mod.object({
4672
+ sharing: mod.boolean().optional(),
4673
+ shared: mod.string().array().optional(),
4674
+ shareAll: mod.boolean().optional()
4675
+ })).default({})
4676
+ }).default({}),
4677
+ personal: mod.record(mod.string()).default({})
4678
+ }).default({}),
4679
+ write: mod.object({
4680
+ credentials: mod.object({ categories: mod.record(mod.boolean()).default({}) }).default({}),
4681
+ personal: mod.record(mod.boolean()).default({})
4682
+ }).default({})
4683
+ });
4684
+ var PaginatedConsentFlowTermsValidator = PaginationResponseValidator.extend({
4685
+ records: mod.object({
4686
+ expiresAt: mod.string().optional(),
4687
+ oneTime: mod.boolean().optional(),
4688
+ terms: ConsentFlowTermsValidator,
4689
+ contract: ConsentFlowContractDetailsValidator,
4690
+ uri: mod.string(),
4691
+ consenter: LCNProfileValidator,
4692
+ status: ConsentFlowTermsStatusValidator
4693
+ }).array()
4694
+ });
4695
+ var ConsentFlowContractQueryValidator = mod.object({
4696
+ read: mod.object({
4697
+ anonymize: mod.boolean().optional(),
4698
+ credentials: mod.object({
4699
+ categories: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4700
+ }).optional(),
4701
+ personal: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4702
+ }).optional(),
4703
+ write: mod.object({
4704
+ credentials: mod.object({
4705
+ categories: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4706
+ }).optional(),
4707
+ personal: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4708
+ }).optional()
4709
+ });
4710
+ var ConsentFlowTermsQueryValidator = mod.object({
4711
+ read: mod.object({
4712
+ anonymize: mod.boolean().optional(),
4713
+ credentials: mod.object({
4714
+ shareAll: mod.boolean().optional(),
4715
+ sharing: mod.boolean().optional(),
4716
+ categories: mod.record(mod.object({
4717
+ sharing: mod.boolean().optional(),
4718
+ shared: mod.string().array().optional(),
4719
+ shareAll: mod.boolean().optional()
4720
+ }).optional()).optional()
4721
+ }).optional(),
4722
+ personal: mod.record(mod.string()).optional()
4723
+ }).optional(),
4724
+ write: mod.object({
4725
+ credentials: mod.object({ categories: mod.record(mod.boolean()).optional() }).optional(),
4726
+ personal: mod.record(mod.boolean()).optional()
4727
+ }).optional()
4728
+ });
4729
+ var ConsentFlowTransactionActionValidator = mod.enum([
4730
+ "consent",
4731
+ "update",
4732
+ "sync",
4733
+ "withdraw"
4734
+ ]);
4735
+ var ConsentFlowTransactionsQueryValidator = mod.object({
4736
+ terms: ConsentFlowTermsQueryValidator.optional(),
4737
+ action: ConsentFlowTransactionActionValidator.or(ConsentFlowTransactionActionValidator.array()).optional(),
4738
+ date: mod.object({ $gt: mod.string() }).or(mod.object({ $lt: mod.string() })).or(mod.object({ $eq: mod.string() })).optional(),
4739
+ expiresAt: mod.object({ $gt: mod.string() }).or(mod.object({ $lt: mod.string() })).or(mod.object({ $eq: mod.string() })).optional(),
4740
+ oneTime: mod.boolean().optional()
4741
+ });
4742
+ var ConsentFlowTransactionValidator = mod.object({
4743
+ expiresAt: mod.string().optional(),
4744
+ oneTime: mod.boolean().optional(),
4745
+ terms: ConsentFlowTermsValidator.optional(),
4746
+ id: mod.string(),
4747
+ action: ConsentFlowTransactionActionValidator,
4748
+ date: mod.string()
4749
+ });
4750
+ var PaginatedConsentFlowTransactionsValidator = PaginationResponseValidator.extend({
4751
+ records: ConsentFlowTransactionValidator.array()
4752
+ });
4628
4753
 
4629
4754
  // src/plugin.ts
4630
4755
  var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
@@ -5005,9 +5130,70 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
5005
5130
  throw new Error("Please make an account first!");
5006
5131
  return client.boost.claimBoostWithLink.mutate({ boostUri, challenge });
5007
5132
  },
5133
+ createContract: async (_learnCard, contract) => {
5134
+ if (!userData)
5135
+ throw new Error("Please make an account first!");
5136
+ return client.contracts.createConsentFlowContract.mutate(contract);
5137
+ },
5138
+ getContract: async (_learnCard, uri) => {
5139
+ return client.contracts.getConsentFlowContract.query({ uri });
5140
+ },
5141
+ getContracts: async (_learnCard, options) => {
5142
+ if (!userData)
5143
+ throw new Error("Please make an account first!");
5144
+ return client.contracts.getConsentFlowContracts.query(options);
5145
+ },
5146
+ deleteContract: async (_learnCard, uri) => {
5147
+ if (!userData)
5148
+ throw new Error("Please make an account first!");
5149
+ return client.contracts.deleteConsentFlowContract.mutate({ uri });
5150
+ },
5151
+ getConsentFlowData: async (_learnCard, uri, options) => {
5152
+ if (!userData)
5153
+ throw new Error("Please make an account first!");
5154
+ return client.contracts.getConsentedDataForContract.query({ uri, ...options });
5155
+ },
5156
+ consentToContract: async (_learnCard, contractUri, { terms, expiresAt, oneTime }) => {
5157
+ if (!userData)
5158
+ throw new Error("Please make an account first!");
5159
+ return client.contracts.consentToContract.mutate({
5160
+ contractUri,
5161
+ terms,
5162
+ expiresAt,
5163
+ oneTime
5164
+ });
5165
+ },
5166
+ getConsentedContracts: async (_learnCard, options) => {
5167
+ if (!userData)
5168
+ throw new Error("Please make an account first!");
5169
+ return client.contracts.getConsentedContracts.query(options);
5170
+ },
5171
+ updateContractTerms: async (_learnCard, uri, { terms, expiresAt, oneTime }) => {
5172
+ if (!userData)
5173
+ throw new Error("Please make an account first!");
5174
+ return client.contracts.updateConsentedContractTerms.mutate({
5175
+ uri,
5176
+ terms,
5177
+ expiresAt,
5178
+ oneTime
5179
+ });
5180
+ },
5181
+ withdrawConsent: async (_learnCard, uri) => {
5182
+ if (!userData)
5183
+ throw new Error("Please make an account first!");
5184
+ return client.contracts.withdrawConsent.mutate({ uri });
5185
+ },
5186
+ getConsentFlowTransactions: async (_learnCard, uri, options) => {
5187
+ if (!userData)
5188
+ throw new Error("Please make an account first!");
5189
+ return client.contracts.getTermsTransactionHistory.query({ uri, ...options });
5190
+ },
5191
+ verifyConsent: async (_learnCard, uri, profileId) => {
5192
+ return client.contracts.verifyConsent.query({ uri, profileId });
5193
+ },
5008
5194
  resolveFromLCN: async (_learnCard, uri) => {
5009
5195
  const result = await client.storage.resolve.query({ uri });
5010
- return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).parseAsync(result);
5196
+ return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).or(ConsentFlowContractValidator).or(ConsentFlowTermsValidator).parseAsync(result);
5011
5197
  }
5012
5198
  }
5013
5199
  };