@learncard/network-brain-client 2.5.45 → 2.5.47

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.
@@ -25625,6 +25625,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
25625
25625
  getBitstringStatusListEntries: /* @__PURE__ */ __name(() => getBitstringStatusListEntries, "getBitstringStatusListEntries"),
25626
25626
  getBitstringStatusListEntryForPurpose: /* @__PURE__ */ __name(() => getBitstringStatusListEntryForPurpose, "getBitstringStatusListEntryForPurpose"),
25627
25627
  getCredentialStatusArray: /* @__PURE__ */ __name(() => getCredentialStatusArray, "getCredentialStatusArray"),
25628
+ getDidWeb: /* @__PURE__ */ __name(() => getDidWeb, "getDidWeb"),
25628
25629
  getProvider: /* @__PURE__ */ __name(() => getProvider, "getProvider"),
25629
25630
  getUrlsFromSrcSet: /* @__PURE__ */ __name(() => getUrlsFromSrcSet, "getUrlsFromSrcSet"),
25630
25631
  immerArraySlice: /* @__PURE__ */ __name(() => immerArraySlice, "immerArraySlice"),
@@ -26433,6 +26434,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26433
26434
  );
26434
26435
  return isV2 ? "w3c-vc-2.0" : "w3c-vc-1.1";
26435
26436
  }, "inferW3cVersionFromContext");
26437
+ var getDidWeb = /* @__PURE__ */ __name2((domain, profileId) => {
26438
+ let decodedDomain = domain;
26439
+ try {
26440
+ decodedDomain = decodeURIComponent(domain);
26441
+ } catch {
26442
+ }
26443
+ return `did:web:${encodeURIComponent(decodedDomain)}:users:${profileId}`;
26444
+ }, "getDidWeb");
26436
26445
  var isHex = /* @__PURE__ */ __name2((str) => /^[0-9a-f]+$/i.test(str), "isHex");
26437
26446
  var isEncrypted = /* @__PURE__ */ __name2((item) => {
26438
26447
  return import_types2.JWEValidator.safeParse(item).success;
@@ -26564,7 +26573,24 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction, guardianAppr
26564
26573
  const getChallenges = /* @__PURE__ */ __name(async (amount = 95 + Math.round((Math.random() - 0.5) * 5)) => {
26565
26574
  return challengeRequester.utilities.getChallenges.query({ amount });
26566
26575
  }, "getChallenges");
26567
- getChallenges().then((result) => challenges = result);
26576
+ let refillPromise;
26577
+ const refillChallenges = /* @__PURE__ */ __name(() => {
26578
+ refillPromise ??= getChallenges().then((result) => {
26579
+ if (result.length === 0) throw new Error("Challenge refill returned no challenges");
26580
+ challenges.push(...result);
26581
+ }).finally(() => {
26582
+ refillPromise = void 0;
26583
+ });
26584
+ return refillPromise;
26585
+ }, "refillChallenges");
26586
+ const takeChallenge = /* @__PURE__ */ __name(async () => {
26587
+ while (true) {
26588
+ const challenge = challenges.pop();
26589
+ if (challenge !== void 0) return challenge;
26590
+ await refillChallenges();
26591
+ }
26592
+ }, "takeChallenge");
26593
+ void refillChallenges().catch(() => void 0);
26568
26594
  const trpc = (0, import_client.createTRPCClient)({
26569
26595
  links: [
26570
26596
  callbackLink(async () => {
@@ -26575,10 +26601,10 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction, guardianAppr
26575
26601
  maxURLLength: 3072,
26576
26602
  url,
26577
26603
  headers: /* @__PURE__ */ __name(async () => {
26578
- if (challenges.length === 0) challenges.push(...await getChallenges());
26604
+ const challenge = await takeChallenge();
26579
26605
  const guardianApproval = guardianApprovalGetter ? await guardianApprovalGetter() : void 0;
26580
26606
  return {
26581
- Authorization: `Bearer ${await didAuthFunction(challenges.pop())}`,
26607
+ Authorization: `Bearer ${await didAuthFunction(challenge)}`,
26582
26608
  ...guardianApproval ? { "x-guardian-approval": guardianApproval } : {},
26583
26609
  ...extraHeaders
26584
26610
  };