@learncard/network-plugin 2.5.22 → 2.6.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.
@@ -6403,6 +6403,7 @@ var require_helpers_cjs_development = __commonJS({
6403
6403
  controller: z2.string(),
6404
6404
  publicKeyJwk: JWKValidator2.optional(),
6405
6405
  publicKeyBase58: z2.string().optional(),
6406
+ publicKeyMultibase: z2.string().optional(),
6406
6407
  blockChainAccountId: z2.string().optional()
6407
6408
  }).catchall(z2.any())
6408
6409
  );
@@ -6711,7 +6712,8 @@ var require_helpers_cjs_development = __commonJS({
6711
6712
  display: LCNProfileDisplayValidator2.optional().describe("Display settings for the profile."),
6712
6713
  highlightedCredentials: z2.array(z2.string()).max(5).optional().describe("Up to 5 unique boost URIs to highlight on the profile."),
6713
6714
  role: z2.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),
6714
- dob: z2.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".')
6715
+ dob: z2.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),
6716
+ country: z2.string().optional().describe("Country for the profile.")
6715
6717
  });
6716
6718
  var LCNProfileQueryValidator2 = z2.object({
6717
6719
  profileId: StringQuery2,
@@ -7398,6 +7400,23 @@ var getClient = /* @__PURE__ */ __name2(async (url, didAuthFunction) => {
7398
7400
  });
7399
7401
  return trpc;
7400
7402
  }, "getClient");
7403
+ var getApiTokenClient = /* @__PURE__ */ __name2(async (url, apiToken) => {
7404
+ const trpc = createTRPCClient({
7405
+ links: [
7406
+ httpBatchLink({
7407
+ methodOverride: "POST",
7408
+ url,
7409
+ maxURLLength: 3072,
7410
+ headers: { Authorization: `Bearer ${apiToken}` },
7411
+ transformer: {
7412
+ input: import_helpers.RegExpTransformer,
7413
+ output: { serialize: (o) => o, deserialize: (o) => o }
7414
+ }
7415
+ })
7416
+ ]
7417
+ });
7418
+ return trpc;
7419
+ }, "getApiTokenClient");
7401
7420
 
7402
7421
  // ../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
7403
7422
  var util;
@@ -11558,6 +11577,7 @@ var VerificationMethodValidator = z.string().or(
11558
11577
  controller: z.string(),
11559
11578
  publicKeyJwk: JWKValidator.optional(),
11560
11579
  publicKeyBase58: z.string().optional(),
11580
+ publicKeyMultibase: z.string().optional(),
11561
11581
  blockChainAccountId: z.string().optional()
11562
11582
  }).catchall(z.any())
11563
11583
  );
@@ -11866,7 +11886,8 @@ var LCNProfileValidator = z.object({
11866
11886
  display: LCNProfileDisplayValidator.optional().describe("Display settings for the profile."),
11867
11887
  highlightedCredentials: z.array(z.string()).max(5).optional().describe("Up to 5 unique boost URIs to highlight on the profile."),
11868
11888
  role: z.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),
11869
- dob: z.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".')
11889
+ dob: z.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),
11890
+ country: z.string().optional().describe("Country for the profile.")
11870
11891
  });
11871
11892
  var LCNProfileQueryValidator = z.object({
11872
11893
  profileId: StringQuery,
@@ -16784,6 +16805,7 @@ var require_types_cjs_development = __commonJS2({
16784
16805
  controller: z2.string(),
16785
16806
  publicKeyJwk: JWKValidator2.optional(),
16786
16807
  publicKeyBase58: z2.string().optional(),
16808
+ publicKeyMultibase: z2.string().optional(),
16787
16809
  blockChainAccountId: z2.string().optional()
16788
16810
  }).catchall(z2.any())
16789
16811
  );
@@ -17092,7 +17114,8 @@ var require_types_cjs_development = __commonJS2({
17092
17114
  display: LCNProfileDisplayValidator2.optional().describe("Display settings for the profile."),
17093
17115
  highlightedCredentials: z2.array(z2.string()).max(5).optional().describe("Up to 5 unique boost URIs to highlight on the profile."),
17094
17116
  role: z2.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),
17095
- dob: z2.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".')
17117
+ dob: z2.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),
17118
+ country: z2.string().optional().describe("Country for the profile.")
17096
17119
  });
17097
17120
  var LCNProfileQueryValidator2 = z2.object({
17098
17121
  profileId: StringQuery2,
@@ -17652,21 +17675,56 @@ var isVC2Format = /* @__PURE__ */ __name4((credential) => {
17652
17675
  }, "isVC2Format");
17653
17676
 
17654
17677
  // src/plugin.ts
17655
- var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
17656
- let did = learnCard.id.did();
17678
+ async function getLearnCardNetworkPlugin(learnCard, url, apiToken) {
17679
+ let did = "";
17680
+ try {
17681
+ const idPlane = learnCard?.id;
17682
+ if (idPlane && typeof idPlane.did === "function") {
17683
+ did = idPlane.did();
17684
+ }
17685
+ } catch {
17686
+ learnCard?.debug?.("LCN: no local DID available at init; will fetch from profile");
17687
+ }
17657
17688
  learnCard?.debug?.("Adding LearnCardNetwork Plugin");
17658
- const client = await getClient(url, async (challenge) => {
17689
+ const client = apiToken ? await getApiTokenClient(url, apiToken) : await getClient(url, async (challenge) => {
17659
17690
  const jwt = await learnCard.invoke.getDidAuthVp({ proofFormat: "jwt", challenge });
17660
17691
  if (typeof jwt !== "string")
17661
17692
  throw new Error("Error getting DID-Auth-JWT!");
17662
17693
  return jwt;
17663
17694
  });
17664
17695
  let userData;
17696
+ learnCard?.debug?.("LCN: initial getProfile query starting", { apiToken: !!apiToken });
17665
17697
  const initialQuery = client.profile.getProfile.query().then((result) => {
17666
17698
  userData = result;
17667
17699
  if (userData?.did)
17668
17700
  did = userData.did;
17701
+ learnCard?.debug?.("LCN: initial getProfile success", { did });
17702
+ return result;
17703
+ }).catch((error) => {
17704
+ learnCard?.debug?.("LCN: getProfile failed (non-fatal)", error);
17705
+ return void 0;
17669
17706
  });
17707
+ const ensureUser = /* @__PURE__ */ __name(async () => {
17708
+ try {
17709
+ await initialQuery;
17710
+ } catch {
17711
+ }
17712
+ if (!userData && apiToken) {
17713
+ try {
17714
+ learnCard?.debug?.("LCN ensureUser: retrying getProfile with apiToken");
17715
+ const res = await client.profile.getProfile.query();
17716
+ userData = res;
17717
+ if (userData?.did)
17718
+ did = userData.did;
17719
+ learnCard?.debug?.("LCN ensureUser: retry success", { did });
17720
+ } catch (e) {
17721
+ learnCard?.debug?.("LCN ensureUser: retry failed", e);
17722
+ }
17723
+ }
17724
+ if (!userData)
17725
+ throw new Error("Please make an account first!");
17726
+ return userData;
17727
+ }, "ensureUser");
17670
17728
  return {
17671
17729
  name: "LearnCard Network",
17672
17730
  displayName: "LearnCard Network",
@@ -17675,9 +17733,9 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17675
17733
  did: (_learnCard, method) => {
17676
17734
  if (!method || method === "web")
17677
17735
  return did;
17678
- return learnCard.id.did(method);
17736
+ return learnCard.id?.did?.(method);
17679
17737
  },
17680
- keypair: (_learnCard, algorithm) => learnCard.id.keypair(algorithm)
17738
+ keypair: (_learnCard, algorithm) => learnCard.id?.keypair?.(algorithm)
17681
17739
  },
17682
17740
  read: {
17683
17741
  get: async (_learnCard, vcUri) => {
@@ -17693,9 +17751,16 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17693
17751
  try {
17694
17752
  let result = await client.storage.resolve.query({ uri: vcUri });
17695
17753
  if ("ciphertext" in result) {
17696
- result = await _learnCard.invoke.decryptDagJwe(result, [
17697
- _learnCard.id.keypair()
17698
- ]);
17754
+ try {
17755
+ const kp = _learnCard.id.keypair();
17756
+ result = await _learnCard.invoke.decryptDagJwe(result, [kp]);
17757
+ } catch (e) {
17758
+ _learnCard.debug?.(
17759
+ "LCN read.get: skipping decryption (no keypair?)",
17760
+ e
17761
+ );
17762
+ return void 0;
17763
+ }
17699
17764
  }
17700
17765
  return await VCValidator.or(VPValidator).parseAsync(result);
17701
17766
  } catch (error) {
@@ -17711,15 +17776,24 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17711
17776
  },
17712
17777
  uploadEncrypted: async (_learnCard, credential, { recipients = [] } = { recipients: [] }) => {
17713
17778
  _learnCard.debug?.("learnCard.store['LearnCard Network'].upload");
17714
- const jwe = await _learnCard.invoke.createDagJwe(credential, [
17715
- _learnCard.id.did(),
17716
- ...recipients
17717
- ]);
17779
+ await ensureUser();
17780
+ const selfDid = did || userData?.did || "";
17781
+ const recipientsList = [selfDid, ...recipients].filter(Boolean);
17782
+ if (recipientsList.length === 0) {
17783
+ throw new Error(
17784
+ "No recipients specified for encrypted upload; provide at least one DID"
17785
+ );
17786
+ }
17787
+ const jwe = await _learnCard.invoke.createDagJwe(credential, recipientsList);
17718
17788
  return client.storage.store.mutate({ item: jwe });
17719
17789
  }
17720
17790
  },
17721
17791
  methods: {
17722
17792
  createProfile: async (_learnCard, profile) => {
17793
+ try {
17794
+ await ensureUser();
17795
+ } catch {
17796
+ }
17723
17797
  if (userData)
17724
17798
  throw new Error("Account already exists!");
17725
17799
  const newDid = await client.profile.createProfile.mutate(profile);
@@ -17728,8 +17802,10 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17728
17802
  return newDid;
17729
17803
  },
17730
17804
  createServiceProfile: async (_learnCard, profile) => {
17731
- if (userData)
17732
- throw new Error("Account already exists!");
17805
+ try {
17806
+ await ensureUser();
17807
+ } catch {
17808
+ }
17733
17809
  const newDid = await client.profile.createServiceProfile.mutate(profile);
17734
17810
  userData = await client.profile.getProfile.query();
17735
17811
  did = newDid;
@@ -17740,14 +17816,12 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17740
17816
  return newDid;
17741
17817
  },
17742
17818
  createProfileManager: async (_learnCard, profile) => {
17743
- if (!userData)
17744
- throw new Error("Please make an account first!");
17819
+ await ensureUser();
17745
17820
  const newDid = await client.profileManager.createProfileManager.mutate(profile);
17746
17821
  return newDid;
17747
17822
  },
17748
17823
  createChildProfileManager: async (_learnCard, parentUri, profile) => {
17749
- if (!userData)
17750
- throw new Error("Please make an account first!");
17824
+ await ensureUser();
17751
17825
  const newDid = await client.profileManager.createChildProfileManager.mutate({
17752
17826
  parentUri,
17753
17827
  profile
@@ -17755,27 +17829,23 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17755
17829
  return newDid;
17756
17830
  },
17757
17831
  createManagedServiceProfile: async (_learnCard, profile) => {
17758
- if (!userData)
17759
- throw new Error("Please make an account first!");
17832
+ await ensureUser();
17760
17833
  const newDid = await client.profile.createManagedServiceProfile.mutate(profile);
17761
17834
  return newDid;
17762
17835
  },
17763
17836
  getAvailableProfiles: async (_learnCard, options = {}) => {
17764
- if (!userData)
17765
- throw new Error("Please make an account first!");
17837
+ await ensureUser();
17766
17838
  return client.profile.getAvailableProfiles.query(options);
17767
17839
  },
17768
17840
  getManagedProfiles: async (_learnCard, options = {}) => {
17769
17841
  return client.profileManager.getManagedProfiles.query(options);
17770
17842
  },
17771
17843
  getManagedServiceProfiles: async (_learnCard, options = {}) => {
17772
- if (!userData)
17773
- throw new Error("Please make an account first!");
17844
+ await ensureUser();
17774
17845
  return client.profile.getManagedServiceProfiles.query(options);
17775
17846
  },
17776
17847
  updateProfile: async (_learnCard, profile) => {
17777
- if (!userData)
17778
- throw new Error("Please make an account first!");
17848
+ await ensureUser();
17779
17849
  const result = await client.profile.updateProfile.mutate(profile);
17780
17850
  if (result) {
17781
17851
  userData = await client.profile.getProfile.query();
@@ -17797,9 +17867,12 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17797
17867
  return false;
17798
17868
  },
17799
17869
  getProfile: async (_learnCard, profileId) => {
17800
- await initialQuery;
17870
+ try {
17871
+ await ensureUser();
17872
+ } catch {
17873
+ }
17801
17874
  if (!profileId)
17802
- return client.profile.getProfile.query();
17875
+ return userData;
17803
17876
  return client.profile.getOtherProfile.query({ profileId });
17804
17877
  },
17805
17878
  getProfileManagerProfile: async (_learnCard, id) => {
@@ -17822,102 +17895,84 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17822
17895
  });
17823
17896
  },
17824
17897
  connectWith: async (_learnCard, profileId) => {
17825
- if (!userData)
17826
- throw new Error("Please make an account first!");
17898
+ await ensureUser();
17827
17899
  return client.profile.connectWith.mutate({ profileId });
17828
17900
  },
17829
17901
  cancelConnectionRequest: async (_learnCard, profileId) => {
17830
- if (!userData)
17831
- throw new Error("Please make an account first!");
17902
+ await ensureUser();
17832
17903
  return client.profile.cancelConnectionRequest.mutate({ profileId });
17833
17904
  },
17834
17905
  connectWithInvite: async (_learnCard, profileId, challenge) => {
17835
- if (!userData)
17836
- throw new Error("Please make an account first!");
17906
+ await ensureUser();
17837
17907
  return client.profile.connectWithInvite.mutate({ profileId, challenge });
17838
17908
  },
17839
17909
  disconnectWith: async (_learnCard, profileId) => {
17840
- if (!userData)
17841
- throw new Error("Please make an account first!");
17910
+ await ensureUser();
17842
17911
  return client.profile.disconnectWith.mutate({ profileId });
17843
17912
  },
17844
17913
  acceptConnectionRequest: async (_learnCard, profileId) => {
17845
- if (!userData)
17846
- throw new Error("Please make an account first!");
17914
+ await ensureUser();
17847
17915
  return client.profile.acceptConnectionRequest.mutate({ profileId });
17848
17916
  },
17849
17917
  getConnections: async (_learnCard) => {
17850
17918
  console.warn(
17851
17919
  "The getConnections method is deprecated! Please use getPaginatedConnections instead!"
17852
17920
  );
17853
- if (!userData)
17854
- throw new Error("Please make an account first!");
17921
+ await ensureUser();
17855
17922
  return client.profile.connections.query();
17856
17923
  },
17857
17924
  getPaginatedConnections: async (_learnCard, options) => {
17858
- if (!userData)
17859
- throw new Error("Please make an account first!");
17925
+ await ensureUser();
17860
17926
  return client.profile.paginatedConnections.query(options);
17861
17927
  },
17862
17928
  getPendingConnections: async (_learnCard) => {
17863
17929
  console.warn(
17864
17930
  "The getPendingConnections method is deprecated! Please use getPaginatedPendingConnections instead!"
17865
17931
  );
17866
- if (!userData)
17867
- throw new Error("Please make an account first!");
17932
+ await ensureUser();
17868
17933
  return client.profile.pendingConnections.query();
17869
17934
  },
17870
17935
  getPaginatedPendingConnections: async (_learnCard, options) => {
17871
- if (!userData)
17872
- throw new Error("Please make an account first!");
17936
+ await ensureUser();
17873
17937
  return client.profile.paginatedPendingConnections.query(options);
17874
17938
  },
17875
17939
  getConnectionRequests: async (_learnCard) => {
17876
17940
  console.warn(
17877
17941
  "The getConnectionRequests method is deprecated! Please use getPaginatedConnectionRequests instead!"
17878
17942
  );
17879
- if (!userData)
17880
- throw new Error("Please make an account first!");
17943
+ await ensureUser();
17881
17944
  return client.profile.connectionRequests.query();
17882
17945
  },
17883
17946
  getPaginatedConnectionRequests: async (_learnCard, options) => {
17884
- if (!userData)
17885
- throw new Error("Please make an account first!");
17947
+ await ensureUser();
17886
17948
  return client.profile.paginatedConnectionRequests.query(options);
17887
17949
  },
17888
17950
  generateInvite: async (_learnCard, challenge, expiration, maxUses) => {
17889
- if (!userData)
17890
- throw new Error("Please make an account first!");
17951
+ await ensureUser();
17891
17952
  return client.profile.generateInvite.mutate({ challenge, expiration, maxUses });
17892
17953
  },
17893
17954
  listInvites: async () => {
17894
- if (!userData)
17895
- throw new Error("Please make an account first!");
17955
+ await ensureUser();
17896
17956
  return client.profile.listInvites.query();
17897
17957
  },
17898
17958
  invalidateInvite: async (_learnCard, challenge) => {
17899
- if (!userData)
17900
- throw new Error("Please make an account first!");
17959
+ await ensureUser();
17901
17960
  return client.profile.invalidateInvite.mutate({ challenge });
17902
17961
  },
17903
17962
  blockProfile: async (_learnCard, profileId) => {
17904
- if (!userData)
17905
- throw new Error("Please make an account first!");
17963
+ await ensureUser();
17906
17964
  return client.profile.blockProfile.mutate({ profileId });
17907
17965
  },
17908
17966
  unblockProfile: async (_learnCard, profileId) => {
17909
- if (!userData)
17910
- throw new Error("Please make an account first!");
17967
+ await ensureUser();
17911
17968
  return client.profile.unblockProfile.mutate({ profileId });
17912
17969
  },
17913
17970
  getBlockedProfiles: async () => {
17914
- if (!userData)
17915
- throw new Error("Please make an account first!");
17971
+ await ensureUser();
17916
17972
  return client.profile.blocked.query();
17917
17973
  },
17918
17974
  sendCredential: async (_learnCard, profileId, vc, encrypt = true) => {
17919
- if (!userData)
17920
- throw new Error("Please make an account first!");
17975
+ await ensureUser();
17921
17976
  if (!encrypt) {
17922
17977
  return client.credential.sendCredential.mutate({ profileId, credential: vc });
17923
17978
  }
@@ -17925,39 +17980,33 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17925
17980
  if (!target)
17926
17981
  throw new Error("Could not find target account");
17927
17982
  const credential = await _learnCard.invoke.createDagJwe(vc, [
17928
- userData.did,
17983
+ _learnCard.id.did(),
17929
17984
  target.did
17930
17985
  ]);
17931
17986
  return client.credential.sendCredential.mutate({ profileId, credential });
17932
17987
  },
17933
17988
  acceptCredential: async (_learnCard, uri, options) => {
17934
- if (!userData)
17935
- throw new Error("Please make an account first!");
17989
+ await ensureUser();
17936
17990
  return client.credential.acceptCredential.mutate({ uri, options });
17937
17991
  },
17938
17992
  getReceivedCredentials: async (_learnCard, from) => {
17939
- if (!userData)
17940
- throw new Error("Please make an account first!");
17993
+ await ensureUser();
17941
17994
  return client.credential.receivedCredentials.query({ from });
17942
17995
  },
17943
17996
  getSentCredentials: async (_learnCard, to) => {
17944
- if (!userData)
17945
- throw new Error("Please make an account first!");
17997
+ await ensureUser();
17946
17998
  return client.credential.sentCredentials.query({ to });
17947
17999
  },
17948
18000
  getIncomingCredentials: async (_learnCard, from) => {
17949
- if (!userData)
17950
- throw new Error("Please make an account first!");
18001
+ await ensureUser();
17951
18002
  return client.credential.incomingCredentials.query({ from });
17952
18003
  },
17953
18004
  deleteCredential: async (_learnCard, uri) => {
17954
- if (!userData)
17955
- throw new Error("Please make an account first!");
18005
+ await ensureUser();
17956
18006
  return client.credential.deleteCredential.mutate({ uri });
17957
18007
  },
17958
18008
  sendPresentation: async (_learnCard, profileId, vp, encrypt = true) => {
17959
- if (!userData)
17960
- throw new Error("Please make an account first!");
18009
+ await ensureUser();
17961
18010
  if (!encrypt) {
17962
18011
  return client.presentation.sendPresentation.mutate({
17963
18012
  profileId,
@@ -17968,128 +18017,106 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
17968
18017
  if (!target)
17969
18018
  throw new Error("Could not find target account");
17970
18019
  const presentation = await _learnCard.invoke.createDagJwe(vp, [
17971
- userData.did,
18020
+ _learnCard.id.did(),
17972
18021
  target.did
17973
18022
  ]);
17974
18023
  return client.presentation.sendPresentation.mutate({ profileId, presentation });
17975
18024
  },
17976
18025
  acceptPresentation: async (_learnCard, uri) => {
17977
- if (!userData)
17978
- throw new Error("Please make an account first!");
18026
+ await ensureUser();
17979
18027
  return client.presentation.acceptPresentation.mutate({ uri });
17980
18028
  },
17981
18029
  getReceivedPresentations: async (_learnCard, from) => {
17982
- if (!userData)
17983
- throw new Error("Please make an account first!");
18030
+ await ensureUser();
17984
18031
  return client.presentation.receivedPresentations.query({ from });
17985
18032
  },
17986
18033
  getSentPresentations: async (_learnCard, to) => {
17987
- if (!userData)
17988
- throw new Error("Please make an account first!");
18034
+ await ensureUser();
17989
18035
  return client.presentation.sentPresentations.query({ to });
17990
18036
  },
17991
18037
  getIncomingPresentations: async (_learnCard, from) => {
17992
- if (!userData)
17993
- throw new Error("Please make an account first!");
18038
+ await ensureUser();
17994
18039
  return client.presentation.incomingPresentations.query({ from });
17995
18040
  },
17996
18041
  deletePresentation: async (_learnCard, uri) => {
17997
- if (!userData)
17998
- throw new Error("Please make an account first!");
18042
+ await ensureUser();
17999
18043
  return client.presentation.deletePresentation.mutate({ uri });
18000
18044
  },
18001
18045
  createBoost: async (_learnCard, credential, metadata) => {
18002
- if (!userData)
18003
- throw new Error("Please make an account first!");
18046
+ await ensureUser();
18004
18047
  return client.boost.createBoost.mutate({ credential, ...metadata });
18005
18048
  },
18006
18049
  createChildBoost: async (_learnCard, parentUri, credential, metadata) => {
18007
- if (!userData)
18008
- throw new Error("Please make an account first!");
18050
+ await ensureUser();
18009
18051
  return client.boost.createChildBoost.mutate({
18010
18052
  parentUri,
18011
18053
  boost: { credential, ...metadata }
18012
18054
  });
18013
18055
  },
18014
18056
  getBoost: async (_learnCard, uri) => {
18015
- if (!userData)
18016
- throw new Error("Please make an account first!");
18057
+ await ensureUser();
18017
18058
  return client.boost.getBoost.query({ uri });
18018
18059
  },
18019
18060
  getBoosts: async (_learnCard, query) => {
18020
18061
  console.warn(
18021
18062
  "The getBoosts method is deprecated! Please use getPaginatedBoosts instead!"
18022
18063
  );
18023
- if (!userData)
18024
- throw new Error("Please make an account first!");
18064
+ await ensureUser();
18025
18065
  return client.boost.getBoosts.query({ query });
18026
18066
  },
18027
18067
  countBoosts: async (_learnCard, query) => {
18028
- if (!userData)
18029
- throw new Error("Please make an account first!");
18068
+ await ensureUser();
18030
18069
  return client.boost.countBoosts.query({ query });
18031
18070
  },
18032
18071
  getPaginatedBoosts: async (_learnCard, options) => {
18033
- if (!userData)
18034
- throw new Error("Please make an account first!");
18072
+ await ensureUser();
18035
18073
  return client.boost.getPaginatedBoosts.query(options);
18036
18074
  },
18037
18075
  getBoostChildren: async (_learnCard, uri, options) => {
18038
- if (!userData)
18039
- throw new Error("Please make an account first!");
18076
+ await ensureUser();
18040
18077
  return client.boost.getBoostChildren.query({ uri, ...options });
18041
18078
  },
18042
18079
  countBoostChildren: async (_learnCard, uri, options) => {
18043
- if (!userData)
18044
- throw new Error("Please make an account first!");
18080
+ await ensureUser();
18045
18081
  return client.boost.countBoostChildren.query({ uri, ...options });
18046
18082
  },
18047
18083
  getBoostSiblings: async (_learnCard, uri, options) => {
18048
- if (!userData)
18049
- throw new Error("Please make an account first!");
18084
+ await ensureUser();
18050
18085
  return client.boost.getBoostSiblings.query({ uri, ...options });
18051
18086
  },
18052
18087
  countBoostSiblings: async (_learnCard, uri, options) => {
18053
- if (!userData)
18054
- throw new Error("Please make an account first!");
18088
+ await ensureUser();
18055
18089
  return client.boost.countBoostSiblings.query({ uri, ...options });
18056
18090
  },
18057
18091
  getFamilialBoosts: async (_learnCard, uri, options) => {
18058
- if (!userData)
18059
- throw new Error("Please make an account first!");
18092
+ await ensureUser();
18060
18093
  return client.boost.getFamilialBoosts.query({ uri, ...options });
18061
18094
  },
18062
18095
  countFamilialBoosts: async (_learnCard, uri, options) => {
18063
- if (!userData)
18064
- throw new Error("Please make an account first!");
18096
+ await ensureUser();
18065
18097
  return client.boost.countFamilialBoosts.query({ uri, ...options });
18066
18098
  },
18067
18099
  getBoostParents: async (_learnCard, uri, options) => {
18068
- if (!userData)
18069
- throw new Error("Please make an account first!");
18100
+ await ensureUser();
18070
18101
  return client.boost.getBoostParents.query({ uri, ...options });
18071
18102
  },
18072
18103
  countBoostParents: async (_learnCard, uri, options) => {
18073
- if (!userData)
18074
- throw new Error("Please make an account first!");
18104
+ await ensureUser();
18075
18105
  return client.boost.countBoostParents.query({ uri, ...options });
18076
18106
  },
18077
18107
  makeBoostParent: async (_learnCard, uris) => {
18078
- if (!userData)
18079
- throw new Error("Please make an account first!");
18108
+ await ensureUser();
18080
18109
  return client.boost.makeBoostParent.mutate(uris);
18081
18110
  },
18082
18111
  removeBoostParent: async (_learnCard, uris) => {
18083
- if (!userData)
18084
- throw new Error("Please make an account first!");
18112
+ await ensureUser();
18085
18113
  return client.boost.removeBoostParent.mutate(uris);
18086
18114
  },
18087
18115
  getBoostRecipients: async (_learnCard, uri, limit = 25, skip = void 0, includeUnacceptedBoosts = true) => {
18088
18116
  console.warn(
18089
18117
  "The getBoostRecipients method is deprecated! Please use getPaginatedBoostRecipients instead!"
18090
18118
  );
18091
- if (!userData)
18092
- throw new Error("Please make an account first!");
18119
+ await ensureUser();
18093
18120
  return client.boost.getBoostRecipients.query({
18094
18121
  uri,
18095
18122
  limit,
@@ -18098,8 +18125,7 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18098
18125
  });
18099
18126
  },
18100
18127
  getPaginatedBoostRecipients: async (_learnCard, uri, limit = 25, cursor = void 0, includeUnacceptedBoosts = true, query) => {
18101
- if (!userData)
18102
- throw new Error("Please make an account first!");
18128
+ await ensureUser();
18103
18129
  return client.boost.getPaginatedBoostRecipients.query({
18104
18130
  uri,
18105
18131
  limit,
@@ -18109,8 +18135,7 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18109
18135
  });
18110
18136
  },
18111
18137
  getPaginatedBoostRecipientsWithChildren: async (_learnCard, uri, limit = 25, cursor = void 0, includeUnacceptedBoosts = true, boostQuery, profileQuery, numberOfGenerations = 1) => {
18112
- if (!userData)
18113
- throw new Error("Please make an account first!");
18138
+ await ensureUser();
18114
18139
  return client.boost.getPaginatedBoostRecipientsWithChildren.query({
18115
18140
  uri,
18116
18141
  limit,
@@ -18133,13 +18158,11 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18133
18158
  });
18134
18159
  },
18135
18160
  countBoostRecipients: async (_learnCard, uri, includeUnacceptedBoosts = true) => {
18136
- if (!userData)
18137
- throw new Error("Please make an account first!");
18161
+ await ensureUser();
18138
18162
  return client.boost.getBoostRecipientCount.query({ uri, includeUnacceptedBoosts });
18139
18163
  },
18140
18164
  getConnectedBoostRecipients: async (_learnCard, uri, { limit = 25, cursor = void 0, includeUnacceptedBoosts = true, query } = {}) => {
18141
- if (!userData)
18142
- throw new Error("Please make an account first!");
18165
+ await ensureUser();
18143
18166
  return client.boost.getConnectedBoostRecipients.query({
18144
18167
  uri,
18145
18168
  limit,
@@ -18149,41 +18172,35 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18149
18172
  });
18150
18173
  },
18151
18174
  countConnectedBoostRecipients: async (_learnCard, uri, includeUnacceptedBoosts = true) => {
18152
- if (!userData)
18153
- throw new Error("Please make an account first!");
18175
+ await ensureUser();
18154
18176
  return client.boost.getConnectedBoostRecipientCount.query({
18155
18177
  uri,
18156
18178
  includeUnacceptedBoosts
18157
18179
  });
18158
18180
  },
18159
18181
  getBoostChildrenProfileManagers: async (_learnCard, uri, options) => {
18160
- if (!userData)
18161
- throw new Error("Please make an account first!");
18182
+ await ensureUser();
18162
18183
  return client.boost.getChildrenProfileManagers.query({ uri, ...options });
18163
18184
  },
18164
18185
  updateBoost: async (_learnCard, uri, updates, credential) => {
18165
- if (!userData)
18166
- throw new Error("Please make an account first!");
18186
+ await ensureUser();
18167
18187
  return client.boost.updateBoost.mutate({
18168
18188
  uri,
18169
18189
  updates: { ...credential && { credential }, ...updates }
18170
18190
  });
18171
18191
  },
18172
18192
  getBoostAdmins: async (_learnCard, uri, options = {}) => {
18173
- if (!userData)
18174
- throw new Error("Please make an account first!");
18193
+ await ensureUser();
18175
18194
  return client.boost.getBoostAdmins.query({ uri, ...options });
18176
18195
  },
18177
18196
  getBoostPermissions: async (_learnCard, uri, profileId) => {
18178
- if (!userData)
18179
- throw new Error("Please make an account first!");
18197
+ await ensureUser();
18180
18198
  if (!profileId)
18181
18199
  return client.boost.getBoostPermissions.query({ uri });
18182
18200
  return client.boost.getOtherBoostPermissions.query({ uri, profileId });
18183
18201
  },
18184
18202
  updateBoostPermissions: async (_learnCard, uri, updates, profileId) => {
18185
- if (!userData)
18186
- throw new Error("Please make an account first!");
18203
+ await ensureUser();
18187
18204
  if (!profileId)
18188
18205
  return client.boost.updateBoostPermissions.query({ uri, updates });
18189
18206
  const result = await client.boost.updateOtherBoostPermissions.query({
@@ -18196,29 +18213,25 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18196
18213
  return result;
18197
18214
  },
18198
18215
  addBoostAdmin: async (_learnCard, uri, profileId) => {
18199
- if (!userData)
18200
- throw new Error("Please make an account first!");
18216
+ await ensureUser();
18201
18217
  const result = await client.boost.addBoostAdmin.mutate({ uri, profileId });
18202
18218
  if (result)
18203
18219
  await _learnCard.invoke.clearDidWebCache?.();
18204
18220
  return result;
18205
18221
  },
18206
18222
  removeBoostAdmin: async (_learnCard, uri, profileId) => {
18207
- if (!userData)
18208
- throw new Error("Please make an account first!");
18223
+ await ensureUser();
18209
18224
  const result = await client.boost.removeBoostAdmin.mutate({ uri, profileId });
18210
18225
  if (result)
18211
18226
  await _learnCard.invoke.clearDidWebCache?.();
18212
18227
  return result;
18213
18228
  },
18214
18229
  deleteBoost: async (_learnCard, uri) => {
18215
- if (!userData)
18216
- throw new Error("Please make an account first!");
18230
+ await ensureUser();
18217
18231
  return client.boost.deleteBoost.mutate({ uri });
18218
18232
  },
18219
18233
  sendBoost: async (_learnCard, profileId, boostUri, options = { encrypt: true, skipNotification: false }) => {
18220
- if (!userData)
18221
- throw new Error("Please make an account first!");
18234
+ await ensureUser();
18222
18235
  const result = await _learnCard.invoke.resolveFromLCN(boostUri);
18223
18236
  const data = await UnsignedVCValidator.spa(result);
18224
18237
  if (!data.success)
@@ -18259,7 +18272,7 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18259
18272
  }
18260
18273
  const lcnDid = await client.utilities.getDid.query();
18261
18274
  const credential = await _learnCard.invoke.createDagJwe(vc, [
18262
- userData.did,
18275
+ _learnCard.id.did(),
18263
18276
  targetProfile.did,
18264
18277
  lcnDid
18265
18278
  ]);
@@ -18273,37 +18286,31 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18273
18286
  });
18274
18287
  },
18275
18288
  registerSigningAuthority: async (_learnCard, endpoint, name, _did) => {
18276
- if (!userData)
18277
- throw new Error("Please make an account first!");
18289
+ await ensureUser();
18278
18290
  return client.profile.registerSigningAuthority.mutate({
18279
18291
  endpoint,
18280
18292
  name,
18281
18293
  did: _did
18282
18294
  });
18283
18295
  },
18284
- getRegisteredSigningAuthorities: async (_learnCard, _endpoint, _name, _did) => {
18285
- if (!userData)
18286
- throw new Error("Please make an account first!");
18296
+ getRegisteredSigningAuthorities: async (_learnCard) => {
18297
+ await ensureUser();
18287
18298
  return client.profile.signingAuthorities.query();
18288
18299
  },
18289
18300
  getRegisteredSigningAuthority: async (_learnCard, endpoint, name) => {
18290
- if (!userData)
18291
- throw new Error("Please make an account first!");
18301
+ await ensureUser();
18292
18302
  return client.profile.signingAuthority.query({ endpoint, name });
18293
18303
  },
18294
18304
  setPrimaryRegisteredSigningAuthority: async (_learnCard, endpoint, name) => {
18295
- if (!userData)
18296
- throw new Error("Please make an account first!");
18305
+ await ensureUser();
18297
18306
  return client.profile.setPrimarySigningAuthority.mutate({ endpoint, name });
18298
18307
  },
18299
18308
  getPrimaryRegisteredSigningAuthority: async (_learnCard) => {
18300
- if (!userData)
18301
- throw new Error("Please make an account first!");
18309
+ await ensureUser();
18302
18310
  return client.profile.primarySigningAuthority.query();
18303
18311
  },
18304
18312
  generateClaimLink: async (_learnCard, boostUri, claimLinkSA, options, challenge) => {
18305
- if (!userData)
18306
- throw new Error("Please make an account first!");
18313
+ await ensureUser();
18307
18314
  return client.boost.generateClaimLink.mutate({
18308
18315
  boostUri,
18309
18316
  claimLinkSA,
@@ -18312,23 +18319,19 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18312
18319
  });
18313
18320
  },
18314
18321
  claimBoostWithLink: async (_learnCard, boostUri, challenge) => {
18315
- if (!userData)
18316
- throw new Error("Please make an account first!");
18322
+ await ensureUser();
18317
18323
  return client.boost.claimBoostWithLink.mutate({ boostUri, challenge });
18318
18324
  },
18319
18325
  createContract: async (_learnCard, contract) => {
18320
- if (!userData)
18321
- throw new Error("Please make an account first!");
18326
+ await ensureUser();
18322
18327
  return client.contracts.createConsentFlowContract.mutate(contract);
18323
18328
  },
18324
18329
  addAutoBoostsToContract: async (_learnCard, contractUri, autoboosts) => {
18325
- if (!userData)
18326
- throw new Error("Please make an account first!");
18330
+ await ensureUser();
18327
18331
  return client.contracts.addAutoBoostsToContract.mutate({ contractUri, autoboosts });
18328
18332
  },
18329
18333
  removeAutoBoostsFromContract: async (_learnCard, contractUri, boostUris) => {
18330
- if (!userData)
18331
- throw new Error("Please make an account first!");
18334
+ await ensureUser();
18332
18335
  return client.contracts.removeAutoBoostsFromContract.mutate({
18333
18336
  contractUri,
18334
18337
  boostUris
@@ -18338,33 +18341,27 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18338
18341
  return client.contracts.getConsentFlowContract.query({ uri });
18339
18342
  },
18340
18343
  getContracts: async (_learnCard, options) => {
18341
- if (!userData)
18342
- throw new Error("Please make an account first!");
18344
+ await ensureUser();
18343
18345
  return client.contracts.getConsentFlowContracts.query(options);
18344
18346
  },
18345
18347
  deleteContract: async (_learnCard, uri) => {
18346
- if (!userData)
18347
- throw new Error("Please make an account first!");
18348
+ await ensureUser();
18348
18349
  return client.contracts.deleteConsentFlowContract.mutate({ uri });
18349
18350
  },
18350
18351
  getConsentFlowData: async (_learnCard, uri, options = {}) => {
18351
- if (!userData)
18352
- throw new Error("Please make an account first!");
18352
+ await ensureUser();
18353
18353
  return client.contracts.getConsentedDataForContract.query({ uri, ...options });
18354
18354
  },
18355
18355
  getConsentFlowDataForDid: async (_learnCard, did2, options = {}) => {
18356
- if (!userData)
18357
- throw new Error("Please make an account first!");
18356
+ await ensureUser();
18358
18357
  return client.contracts.getConsentedDataForDid.query({ did: did2, ...options });
18359
18358
  },
18360
18359
  getAllConsentFlowData: async (_learnCard, query = {}, options = {}) => {
18361
- if (!userData)
18362
- throw new Error("Please make an account first!");
18360
+ await ensureUser();
18363
18361
  return client.contracts.getConsentedData.query({ query, ...options });
18364
18362
  },
18365
18363
  writeCredentialToContract: async (_learnCard, did2, contractUri, credential, boostUri) => {
18366
- if (!userData)
18367
- throw new Error("Please make an account first!");
18364
+ await ensureUser();
18368
18365
  return client.contracts.writeCredentialToContract.mutate({
18369
18366
  did: did2,
18370
18367
  contractUri,
@@ -18373,8 +18370,7 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18373
18370
  });
18374
18371
  },
18375
18372
  consentToContract: async (_learnCard, contractUri, { terms, expiresAt, oneTime }, recipientToken) => {
18376
- if (!userData)
18377
- throw new Error("Please make an account first!");
18373
+ await ensureUser();
18378
18374
  return client.contracts.consentToContract.mutate({
18379
18375
  contractUri,
18380
18376
  terms,
@@ -18384,13 +18380,11 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18384
18380
  });
18385
18381
  },
18386
18382
  getConsentedContracts: async (_learnCard, options) => {
18387
- if (!userData)
18388
- throw new Error("Please make an account first!");
18383
+ await ensureUser();
18389
18384
  return client.contracts.getConsentedContracts.query(options);
18390
18385
  },
18391
18386
  updateContractTerms: async (_learnCard, uri, { terms, expiresAt, oneTime }) => {
18392
- if (!userData)
18393
- throw new Error("Please make an account first!");
18387
+ await ensureUser();
18394
18388
  return client.contracts.updateConsentedContractTerms.mutate({
18395
18389
  uri,
18396
18390
  terms,
@@ -18399,118 +18393,99 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18399
18393
  });
18400
18394
  },
18401
18395
  withdrawConsent: async (_learnCard, uri) => {
18402
- if (!userData)
18403
- throw new Error("Please make an account first!");
18396
+ await ensureUser();
18404
18397
  return client.contracts.withdrawConsent.mutate({ uri });
18405
18398
  },
18406
18399
  getConsentFlowTransactions: async (_learnCard, uri, options) => {
18407
- if (!userData)
18408
- throw new Error("Please make an account first!");
18400
+ await ensureUser();
18409
18401
  return client.contracts.getTermsTransactionHistory.query({ uri, ...options });
18410
18402
  },
18411
18403
  getCredentialsForContract: async (_learnCard, termsUri, options = {}) => {
18412
- if (!userData)
18413
- throw new Error("Please make an account first!");
18404
+ await ensureUser();
18414
18405
  return client.contracts.getCredentialsForContract.query({ termsUri, ...options });
18415
18406
  },
18416
18407
  getConsentFlowCredentials: async (_learnCard, options = {}) => {
18417
- if (!userData)
18418
- throw new Error("Please make an account first!");
18408
+ await ensureUser();
18419
18409
  return client.contracts.getAllCredentialsForTerms.query(options);
18420
18410
  },
18421
18411
  verifyConsent: async (_learnCard, uri, profileId) => {
18412
+ await ensureUser();
18422
18413
  return client.contracts.verifyConsent.query({ uri, profileId });
18423
18414
  },
18424
18415
  syncCredentialsToContract: async (_learnCard, termsUri, categories) => {
18425
- if (!userData)
18426
- throw new Error("Please make an account first!");
18416
+ await ensureUser();
18427
18417
  return client.contracts.syncCredentialsToContract.mutate({
18428
18418
  termsUri,
18429
18419
  categories
18430
18420
  });
18431
18421
  },
18432
18422
  addDidMetadata: async (_learnCard, metadata) => {
18433
- if (!userData)
18434
- throw new Error("Please make an account first!");
18423
+ await ensureUser();
18435
18424
  const result = await client.didMetadata.addDidMetadata.mutate(metadata);
18436
18425
  if (result)
18437
18426
  await _learnCard.invoke.clearDidWebCache?.();
18438
18427
  return result;
18439
18428
  },
18440
18429
  getDidMetadata: async (_learnCard, id) => {
18441
- if (!userData)
18442
- throw new Error("Please make an account first!");
18430
+ await ensureUser();
18443
18431
  return client.didMetadata.getDidMetadata.query({ id });
18444
18432
  },
18445
18433
  getMyDidMetadata: async () => {
18446
- if (!userData)
18447
- throw new Error("Please make an account first!");
18434
+ await ensureUser();
18448
18435
  return client.didMetadata.getMyDidMetadata.query();
18449
18436
  },
18450
18437
  updateDidMetadata: async (_learnCard, id, updates) => {
18451
- if (!userData)
18452
- throw new Error("Please make an account first!");
18438
+ await ensureUser();
18453
18439
  const result = await client.didMetadata.updateDidMetadata.mutate({ id, updates });
18454
18440
  if (result)
18455
18441
  await _learnCard.invoke.clearDidWebCache?.();
18456
18442
  return result;
18457
18443
  },
18458
18444
  deleteDidMetadata: async (_learnCard, id) => {
18459
- if (!userData)
18460
- throw new Error("Please make an account first!");
18445
+ await ensureUser();
18461
18446
  const result = await client.didMetadata.deleteDidMetadata.mutate({ id });
18462
18447
  if (result)
18463
18448
  await _learnCard.invoke.clearDidWebCache?.();
18464
18449
  return result;
18465
18450
  },
18466
18451
  createClaimHook: async (_learnCard, hook) => {
18467
- if (!userData)
18468
- throw new Error("Please make an account first!");
18452
+ await ensureUser();
18469
18453
  return client.claimHook.createClaimHook.mutate({ hook });
18470
18454
  },
18471
18455
  getClaimHooksForBoost: async (_learnCard, options) => {
18472
- if (!userData)
18473
- throw new Error("Please make an account first!");
18456
+ await ensureUser();
18474
18457
  return client.claimHook.getClaimHooksForBoost.query(options);
18475
18458
  },
18476
18459
  deleteClaimHook: async (_learnCard, id) => {
18477
- if (!userData)
18478
- throw new Error("Please make an account first!");
18460
+ await ensureUser();
18479
18461
  return client.claimHook.deleteClaimHook.mutate({ id });
18480
18462
  },
18481
18463
  addAuthGrant: async (_learnCard, authGrant) => {
18482
- if (!userData)
18483
- throw new Error("Please make an account first!");
18464
+ await ensureUser();
18484
18465
  return client.authGrants.addAuthGrant.mutate(authGrant);
18485
18466
  },
18486
18467
  revokeAuthGrant: async (_learnCard, id) => {
18487
- if (!userData)
18488
- throw new Error("Please make an account first!");
18468
+ await ensureUser();
18489
18469
  return client.authGrants.revokeAuthGrant.mutate({ id });
18490
18470
  },
18491
18471
  deleteAuthGrant: async (_learnCard, id) => {
18492
- if (!userData)
18493
- throw new Error("Please make an account first!");
18472
+ await ensureUser();
18494
18473
  return client.authGrants.deleteAuthGrant.mutate({ id });
18495
18474
  },
18496
18475
  updateAuthGrant: async (_learnCard, id, updates) => {
18497
- if (!userData)
18498
- throw new Error("Please make an account first!");
18476
+ await ensureUser();
18499
18477
  return client.authGrants.updateAuthGrant.mutate({ id, updates });
18500
18478
  },
18501
18479
  getAuthGrant: async (_learnCard, id) => {
18502
- if (!userData)
18503
- throw new Error("Please make an account first!");
18480
+ await ensureUser();
18504
18481
  return client.authGrants.getAuthGrant.query({ id });
18505
18482
  },
18506
18483
  getAuthGrants: async (_learnCard, options) => {
18507
- if (!userData)
18508
- throw new Error("Please make an account first!");
18484
+ await ensureUser();
18509
18485
  return client.authGrants.getAuthGrants.query(options);
18510
18486
  },
18511
18487
  getAPITokenForAuthGrant: async (_learnCard, id) => {
18512
- if (!userData)
18513
- throw new Error("Please make an account first!");
18488
+ await ensureUser();
18514
18489
  const authGrant = await client.authGrants.getAuthGrant.query({ id });
18515
18490
  if (!authGrant)
18516
18491
  throw new Error("Auth grant not found");
@@ -18522,52 +18497,44 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18522
18497
  throw new Error("Auth grant has no scope");
18523
18498
  if (authGrant.expiresAt && new Date(authGrant.expiresAt) < new Date())
18524
18499
  throw new Error("Auth grant is expired");
18525
- const apiToken = await _learnCard.invoke.getDidAuthVp({
18500
+ const apiToken2 = await _learnCard.invoke.getDidAuthVp({
18526
18501
  challenge: authGrant.challenge,
18527
18502
  proofFormat: "jwt"
18528
18503
  });
18529
- if (!apiToken)
18504
+ if (!apiToken2)
18530
18505
  throw new Error("Failed to get API Token for auth grant");
18531
- return apiToken;
18506
+ return apiToken2;
18532
18507
  },
18533
18508
  sendCredentialViaInbox: async (_learnCard, issueInboxCredential) => {
18534
- if (!userData)
18535
- throw new Error("Please make an account first!");
18509
+ await ensureUser();
18536
18510
  return client.inbox.issue.mutate(issueInboxCredential);
18537
18511
  },
18538
18512
  getMySentInboxCredentials: async (_learnCard, options) => {
18539
- if (!userData)
18540
- throw new Error("Please make an account first!");
18513
+ await ensureUser();
18541
18514
  return client.inbox.getMyIssuedCredentials.query(options);
18542
18515
  },
18543
18516
  getInboxCredential: async (_learnCard, id) => {
18544
- if (!userData)
18545
- throw new Error("Please make an account first!");
18517
+ await ensureUser();
18546
18518
  return client.inbox.getInboxCredential.query({ credentialId: id });
18547
18519
  },
18548
18520
  addContactMethod: async (_learnCard, contactMethod) => {
18549
- if (!userData)
18550
- throw new Error("Please make an account first!");
18521
+ await ensureUser();
18551
18522
  return client.contactMethods.addContactMethod.mutate(contactMethod);
18552
18523
  },
18553
18524
  getMyContactMethods: async (_learnCard) => {
18554
- if (!userData)
18555
- throw new Error("Please make an account first!");
18525
+ await ensureUser();
18556
18526
  return client.contactMethods.getMyContactMethods.query();
18557
18527
  },
18558
18528
  setPrimaryContactMethod: async (_learnCard, contactMethodId) => {
18559
- if (!userData)
18560
- throw new Error("Please make an account first!");
18529
+ await ensureUser();
18561
18530
  return client.contactMethods.setPrimaryContactMethod.mutate({ contactMethodId });
18562
18531
  },
18563
18532
  verifyContactMethod: async (_learnCard, token) => {
18564
- if (!userData)
18565
- throw new Error("Please make an account first!");
18533
+ await ensureUser();
18566
18534
  return client.contactMethods.verifyContactMethod.mutate({ token });
18567
18535
  },
18568
18536
  removeContactMethod: async (_learnCard, id) => {
18569
- if (!userData)
18570
- throw new Error("Please make an account first!");
18537
+ await ensureUser();
18571
18538
  return client.contactMethods.removeContactMethod.mutate({ id });
18572
18539
  },
18573
18540
  resolveFromLCN: async (_learnCard, uri) => {
@@ -18577,7 +18544,8 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
18577
18544
  getLCNClient: () => client
18578
18545
  }
18579
18546
  };
18580
- }, "getLearnCardNetworkPlugin");
18547
+ }
18548
+ __name(getLearnCardNetworkPlugin, "getLearnCardNetworkPlugin");
18581
18549
  var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoostRegistryUrl) => {
18582
18550
  const DEFAULT_TRUSTED_BOOST_REGISTRY = [
18583
18551
  {