@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.
@@ -4518,6 +4518,7 @@ var PaginatedEncryptedCredentialRecordsValidator = PaginationResponseValidator.e
4518
4518
  var LCNProfileValidator = mod.object({
4519
4519
  profileId: mod.string().min(3).max(40),
4520
4520
  displayName: mod.string().default(""),
4521
+ bio: mod.string().default(""),
4521
4522
  did: mod.string(),
4522
4523
  email: mod.string().optional(),
4523
4524
  image: mod.string().optional(),
@@ -4601,6 +4602,130 @@ var LCNSigningAuthorityForUserValidator = mod.object({
4601
4602
  did: mod.string()
4602
4603
  })
4603
4604
  });
4605
+ var ConsentFlowTermsStatusValidator = mod.enum(["live", "stale", "withdrawn"]);
4606
+ var ConsentFlowContractValidator = mod.object({
4607
+ read: mod.object({
4608
+ anonymize: mod.boolean().optional(),
4609
+ credentials: mod.object({ categories: mod.record(mod.object({ required: mod.boolean() })).default({}) }).default({}),
4610
+ personal: mod.record(mod.object({ required: mod.boolean() })).default({})
4611
+ }).default({}),
4612
+ write: mod.object({
4613
+ credentials: mod.object({ categories: mod.record(mod.object({ required: mod.boolean() })).default({}) }).default({}),
4614
+ personal: mod.record(mod.object({ required: mod.boolean() })).default({})
4615
+ }).default({})
4616
+ });
4617
+ var ConsentFlowContractDetailsValidator = mod.object({
4618
+ contract: ConsentFlowContractValidator,
4619
+ owner: LCNProfileValidator,
4620
+ name: mod.string(),
4621
+ subtitle: mod.string().optional(),
4622
+ description: mod.string().optional(),
4623
+ reasonForAccessing: mod.string().optional(),
4624
+ image: mod.string().optional(),
4625
+ uri: mod.string(),
4626
+ createdAt: mod.string(),
4627
+ updatedAt: mod.string(),
4628
+ expiresAt: mod.string().optional()
4629
+ });
4630
+ var PaginatedConsentFlowContractsValidator = PaginationResponseValidator.extend({
4631
+ records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
4632
+ });
4633
+ var ConsentFlowContractDataValidator = mod.object({
4634
+ credentials: mod.object({ categories: mod.record(mod.string().array()).default({}) }),
4635
+ personal: mod.record(mod.string()).default({}),
4636
+ date: mod.string()
4637
+ });
4638
+ var PaginatedConsentFlowDataValidator = PaginationResponseValidator.extend({
4639
+ records: ConsentFlowContractDataValidator.array()
4640
+ });
4641
+ var ConsentFlowTermsValidator = mod.object({
4642
+ read: mod.object({
4643
+ anonymize: mod.boolean().optional(),
4644
+ credentials: mod.object({
4645
+ shareAll: mod.boolean().optional(),
4646
+ sharing: mod.boolean().optional(),
4647
+ categories: mod.record(mod.object({
4648
+ sharing: mod.boolean().optional(),
4649
+ shared: mod.string().array().optional(),
4650
+ shareAll: mod.boolean().optional()
4651
+ })).default({})
4652
+ }).default({}),
4653
+ personal: mod.record(mod.string()).default({})
4654
+ }).default({}),
4655
+ write: mod.object({
4656
+ credentials: mod.object({ categories: mod.record(mod.boolean()).default({}) }).default({}),
4657
+ personal: mod.record(mod.boolean()).default({})
4658
+ }).default({})
4659
+ });
4660
+ var PaginatedConsentFlowTermsValidator = PaginationResponseValidator.extend({
4661
+ records: mod.object({
4662
+ expiresAt: mod.string().optional(),
4663
+ oneTime: mod.boolean().optional(),
4664
+ terms: ConsentFlowTermsValidator,
4665
+ contract: ConsentFlowContractDetailsValidator,
4666
+ uri: mod.string(),
4667
+ consenter: LCNProfileValidator,
4668
+ status: ConsentFlowTermsStatusValidator
4669
+ }).array()
4670
+ });
4671
+ var ConsentFlowContractQueryValidator = mod.object({
4672
+ read: mod.object({
4673
+ anonymize: mod.boolean().optional(),
4674
+ credentials: mod.object({
4675
+ categories: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4676
+ }).optional(),
4677
+ personal: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4678
+ }).optional(),
4679
+ write: mod.object({
4680
+ credentials: mod.object({
4681
+ categories: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4682
+ }).optional(),
4683
+ personal: mod.record(mod.object({ required: mod.boolean().optional() })).optional()
4684
+ }).optional()
4685
+ });
4686
+ var ConsentFlowTermsQueryValidator = mod.object({
4687
+ read: mod.object({
4688
+ anonymize: mod.boolean().optional(),
4689
+ credentials: mod.object({
4690
+ shareAll: mod.boolean().optional(),
4691
+ sharing: mod.boolean().optional(),
4692
+ categories: mod.record(mod.object({
4693
+ sharing: mod.boolean().optional(),
4694
+ shared: mod.string().array().optional(),
4695
+ shareAll: mod.boolean().optional()
4696
+ }).optional()).optional()
4697
+ }).optional(),
4698
+ personal: mod.record(mod.string()).optional()
4699
+ }).optional(),
4700
+ write: mod.object({
4701
+ credentials: mod.object({ categories: mod.record(mod.boolean()).optional() }).optional(),
4702
+ personal: mod.record(mod.boolean()).optional()
4703
+ }).optional()
4704
+ });
4705
+ var ConsentFlowTransactionActionValidator = mod.enum([
4706
+ "consent",
4707
+ "update",
4708
+ "sync",
4709
+ "withdraw"
4710
+ ]);
4711
+ var ConsentFlowTransactionsQueryValidator = mod.object({
4712
+ terms: ConsentFlowTermsQueryValidator.optional(),
4713
+ action: ConsentFlowTransactionActionValidator.or(ConsentFlowTransactionActionValidator.array()).optional(),
4714
+ date: mod.object({ $gt: mod.string() }).or(mod.object({ $lt: mod.string() })).or(mod.object({ $eq: mod.string() })).optional(),
4715
+ expiresAt: mod.object({ $gt: mod.string() }).or(mod.object({ $lt: mod.string() })).or(mod.object({ $eq: mod.string() })).optional(),
4716
+ oneTime: mod.boolean().optional()
4717
+ });
4718
+ var ConsentFlowTransactionValidator = mod.object({
4719
+ expiresAt: mod.string().optional(),
4720
+ oneTime: mod.boolean().optional(),
4721
+ terms: ConsentFlowTermsValidator.optional(),
4722
+ id: mod.string(),
4723
+ action: ConsentFlowTransactionActionValidator,
4724
+ date: mod.string()
4725
+ });
4726
+ var PaginatedConsentFlowTransactionsValidator = PaginationResponseValidator.extend({
4727
+ records: ConsentFlowTransactionValidator.array()
4728
+ });
4604
4729
 
4605
4730
  // src/plugin.ts
4606
4731
  var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
@@ -4981,9 +5106,70 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
4981
5106
  throw new Error("Please make an account first!");
4982
5107
  return client.boost.claimBoostWithLink.mutate({ boostUri, challenge });
4983
5108
  },
5109
+ createContract: async (_learnCard, contract) => {
5110
+ if (!userData)
5111
+ throw new Error("Please make an account first!");
5112
+ return client.contracts.createConsentFlowContract.mutate(contract);
5113
+ },
5114
+ getContract: async (_learnCard, uri) => {
5115
+ return client.contracts.getConsentFlowContract.query({ uri });
5116
+ },
5117
+ getContracts: async (_learnCard, options) => {
5118
+ if (!userData)
5119
+ throw new Error("Please make an account first!");
5120
+ return client.contracts.getConsentFlowContracts.query(options);
5121
+ },
5122
+ deleteContract: async (_learnCard, uri) => {
5123
+ if (!userData)
5124
+ throw new Error("Please make an account first!");
5125
+ return client.contracts.deleteConsentFlowContract.mutate({ uri });
5126
+ },
5127
+ getConsentFlowData: async (_learnCard, uri, options) => {
5128
+ if (!userData)
5129
+ throw new Error("Please make an account first!");
5130
+ return client.contracts.getConsentedDataForContract.query({ uri, ...options });
5131
+ },
5132
+ consentToContract: async (_learnCard, contractUri, { terms, expiresAt, oneTime }) => {
5133
+ if (!userData)
5134
+ throw new Error("Please make an account first!");
5135
+ return client.contracts.consentToContract.mutate({
5136
+ contractUri,
5137
+ terms,
5138
+ expiresAt,
5139
+ oneTime
5140
+ });
5141
+ },
5142
+ getConsentedContracts: async (_learnCard, options) => {
5143
+ if (!userData)
5144
+ throw new Error("Please make an account first!");
5145
+ return client.contracts.getConsentedContracts.query(options);
5146
+ },
5147
+ updateContractTerms: async (_learnCard, uri, { terms, expiresAt, oneTime }) => {
5148
+ if (!userData)
5149
+ throw new Error("Please make an account first!");
5150
+ return client.contracts.updateConsentedContractTerms.mutate({
5151
+ uri,
5152
+ terms,
5153
+ expiresAt,
5154
+ oneTime
5155
+ });
5156
+ },
5157
+ withdrawConsent: async (_learnCard, uri) => {
5158
+ if (!userData)
5159
+ throw new Error("Please make an account first!");
5160
+ return client.contracts.withdrawConsent.mutate({ uri });
5161
+ },
5162
+ getConsentFlowTransactions: async (_learnCard, uri, options) => {
5163
+ if (!userData)
5164
+ throw new Error("Please make an account first!");
5165
+ return client.contracts.getTermsTransactionHistory.query({ uri, ...options });
5166
+ },
5167
+ verifyConsent: async (_learnCard, uri, profileId) => {
5168
+ return client.contracts.verifyConsent.query({ uri, profileId });
5169
+ },
4984
5170
  resolveFromLCN: async (_learnCard, uri) => {
4985
5171
  const result = await client.storage.resolve.query({ uri });
4986
- return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).parseAsync(result);
5172
+ return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).or(ConsentFlowContractValidator).or(ConsentFlowTermsValidator).parseAsync(result);
4987
5173
  }
4988
5174
  }
4989
5175
  };