@learncard/learn-cloud-client 1.2.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @learncard/network-brain-client
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`93258d5`](https://github.com/learningeconomy/LearnCard/commit/93258d5af9071e6c0f6ed62c9ee0547d8bfbb7a6) Thanks [@TaylorBeeston](https://github.com/TaylorBeeston)! - Increase URL Limit for LearnCloud (This is a temporary fix)
8
+
3
9
  ## 1.2.0
4
10
 
5
11
  ### Minor Changes
@@ -70,7 +70,7 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
70
70
  links: [
71
71
  (0, import_client.httpBatchLink)({
72
72
  url,
73
- maxURLLength: 2048,
73
+ maxURLLength: 3072,
74
74
  headers: { Authorization: `Bearer ${await didAuthFunction()}` }
75
75
  })
76
76
  ]
@@ -86,7 +86,7 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
86
86
  }),
87
87
  (0, import_client.httpBatchLink)({
88
88
  url,
89
- maxURLLength: 2048,
89
+ maxURLLength: 3072,
90
90
  headers: async () => {
91
91
  if (challenges.length === 0)
92
92
  challenges.push(...await getChallenges());
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/callbackLink.ts"],
4
- "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
4
+ "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA4E;;;ACC5E,wBAA2C;AAGpC,IAAM,eAAe,wBAAC,aAAuD;AAChF,SAAO,MAAM;AACT,WAAO,CAAC,EAAE,MAAM,GAAG,MAAM;AACrB,iBAAO,8BAAW,cAAY;AAC1B,YAAI,UAAiC;AACrC,YAAI,WAAW;AACf,YAAI,SAAS;AAEb,cAAM,UAAU,6BAAM;AAClB,sBAAY;AACZ,mBAAS,YAAY;AACrB,oBAAU,KAAK,EAAE,EAAE,UAAU;AAAA,YACzB,OAAO,OAAM,UAAS;AAClB,kBAAI,WAAW,KAAK,MAAM,MAAM,eAAe,KAAK;AAChD,uBAAO,SAAS,MAAM,KAAK;AAAA,cAC/B;AAEA,oBAAM,SAAS;AAEf,sBAAQ;AAAA,YACZ;AAAA,YACA,MAAM,YAAU,SAAS,KAAK,MAAM;AAAA,YACpC,UAAU,MAAM;AACZ,kBAAI;AAAQ,yBAAS,SAAS;AAAA,YAClC;AAAA,UACJ,CAAC;AAAA,QACL,GAlBgB;AAoBhB,gBAAQ;AAER,eAAO,MAAM;AACT,mBAAS;AACT,mBAAS,YAAY;AAAA,QACzB;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ,GArC4B;;;AD4BrB,IAAM,YAAY,8BACrB,KACA,oBACC;AACD,MAAI,aAAuB,CAAC;AAE5B,QAAM,yBAAqB,qCAAiC;AAAA,IACxD,OAAO;AAAA,UACH,6BAAc;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,SAAS,EAAE,eAAe,UAAU,MAAM,gBAAgB,IAAI;AAAA,MAClE,CAAC;AAAA,IACL;AAAA,EACJ,CAAC;AAED,QAAM,gBAAgB,8BAClB,SAAS,KAAK,KAAK,OAAO,KAAK,OAAO,IAAI,OAAO,CAAC,MAC9B;AACpB,WAAO,mBAAmB,UAAU,cAAc,MAAM,EAAE,OAAO,CAAC;AAAA,EACtE,GAJsB;AAMtB,eAAa,MAAM,cAAc;AAEjC,QAAM,WAAO,qCAAiC;AAAA,IAC1C,OAAO;AAAA,MACH,aAAa,YAAY;AACrB,qBAAa,MAAM,cAAc;AAAA,MACrC,CAAC;AAAA,UACD,6BAAc;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,SAAS,YAAY;AACjB,cAAI,WAAW,WAAW;AAAG,uBAAW,KAAK,GAAI,MAAM,cAAc,CAAE;AAEvE,iBAAO,EAAE,eAAe,UAAU,MAAM,gBAAgB,WAAW,IAAI,CAAC,IAAI;AAAA,QAChF;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ,CAAC;AAED,SAAO;AACX,GA1CyB;AA4CzB,IAAO,cAAQ;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var i=(t,e)=>l(t,"name",{value:e,configurable:!0});var h=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},P=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of C(e))!R.call(t,r)&&r!==n&&l(t,r,{get:()=>e[r],enumerable:!(a=y(e,r))||a.enumerable});return t};var f=t=>P(l({},"__esModule",{value:!0}),t);var x={};h(x,{default:()=>b,getClient:()=>g});module.exports=f(x);var o=require("@trpc/client");var d=require("@trpc/server/observable");var m=i(t=>()=>({next:e,op:n})=>(0,d.observable)(a=>{let r=null,c=0,s=!1,u=i(()=>{c+=1,r?.unsubscribe(),r=e(n).subscribe({error:async p=>{if(c>5||p.data?.httpStatus!==401)return a.error(p);await t(),u()},next:p=>a.next(p),complete:()=>{s&&a.complete()}})},"attempt");return u(),()=>{s=!0,r?.unsubscribe()}}),"callbackLink");var g=i(async(t,e)=>{let n=[],a=(0,o.createTRPCProxyClient)({links:[(0,o.httpBatchLink)({url:t,maxURLLength:2048,headers:{Authorization:`Bearer ${await e()}`}})]}),r=i(async(s=95+Math.round((Math.random()-.5)*5))=>a.utilities.getChallenges.query({amount:s}),"getChallenges");return n=await r(),(0,o.createTRPCProxyClient)({links:[m(async()=>{n=await r()}),(0,o.httpBatchLink)({url:t,maxURLLength:2048,headers:async()=>(n.length===0&&n.push(...await r()),{Authorization:`Bearer ${await e(n.pop())}`})})]})},"getClient"),b=g;
1
+ var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var i=(t,e)=>l(t,"name",{value:e,configurable:!0});var h=(t,e)=>{for(var n in e)l(t,n,{get:e[n],enumerable:!0})},P=(t,e,n,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of C(e))!R.call(t,r)&&r!==n&&l(t,r,{get:()=>e[r],enumerable:!(a=y(e,r))||a.enumerable});return t};var f=t=>P(l({},"__esModule",{value:!0}),t);var x={};h(x,{default:()=>b,getClient:()=>g});module.exports=f(x);var o=require("@trpc/client");var d=require("@trpc/server/observable");var m=i(t=>()=>({next:e,op:n})=>(0,d.observable)(a=>{let r=null,c=0,s=!1,u=i(()=>{c+=1,r?.unsubscribe(),r=e(n).subscribe({error:async p=>{if(c>5||p.data?.httpStatus!==401)return a.error(p);await t(),u()},next:p=>a.next(p),complete:()=>{s&&a.complete()}})},"attempt");return u(),()=>{s=!0,r?.unsubscribe()}}),"callbackLink");var g=i(async(t,e)=>{let n=[],a=(0,o.createTRPCProxyClient)({links:[(0,o.httpBatchLink)({url:t,maxURLLength:3072,headers:{Authorization:`Bearer ${await e()}`}})]}),r=i(async(s=95+Math.round((Math.random()-.5)*5))=>a.utilities.getChallenges.query({amount:s}),"getChallenges");return n=await r(),(0,o.createTRPCProxyClient)({links:[m(async()=>{n=await r()}),(0,o.httpBatchLink)({url:t,maxURLLength:3072,headers:async()=>(n.length===0&&n.push(...await r()),{Authorization:`Bearer ${await e(n.pop())}`})})]})},"getClient"),b=g;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/callbackLink.ts"],
4
- "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
4
+ "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
5
5
  "mappings": "+cAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAA4E,wBCC5E,IAAAC,EAA2C,mCAGpC,IAAMC,EAAeC,EAACC,GAClB,IACI,CAAC,CAAE,KAAAC,EAAM,GAAAC,CAAG,OACR,cAAWC,GAAY,CAC1B,IAAIC,EAAiC,KACjCC,EAAW,EACXC,EAAS,GAEPC,EAAUR,EAAA,IAAM,CAClBM,GAAY,EACZD,GAAS,YAAY,EACrBA,EAAUH,EAAKC,CAAE,EAAE,UAAU,CACzB,MAAO,MAAMM,GAAS,CAClB,GAAIH,EAAW,GAAKG,EAAM,MAAM,aAAe,IAC3C,OAAOL,EAAS,MAAMK,CAAK,EAG/B,MAAMR,EAAS,EAEfO,EAAQ,CACZ,EACA,KAAME,GAAUN,EAAS,KAAKM,CAAM,EACpC,SAAU,IAAM,CACRH,GAAQH,EAAS,SAAS,CAClC,CACJ,CAAC,CACL,EAlBgB,WAoBhB,OAAAI,EAAQ,EAED,IAAM,CACTD,EAAS,GACTF,GAAS,YAAY,CACzB,CACJ,CAAC,EAlCe,gBD4BrB,IAAMM,EAAYC,EAAA,MACrBC,EACAC,IACC,CACD,IAAIC,EAAuB,CAAC,EAEtBC,KAAqB,yBAAiC,CACxD,MAAO,IACH,iBAAc,CACV,IAAAH,EACA,aAAc,KACd,QAAS,CAAE,cAAe,UAAU,MAAMC,EAAgB,GAAI,CAClE,CAAC,CACL,CACJ,CAAC,EAEKG,EAAgBL,EAAA,MAClBM,EAAS,GAAK,KAAK,OAAO,KAAK,OAAO,EAAI,IAAO,CAAC,IAE3CF,EAAmB,UAAU,cAAc,MAAM,CAAE,OAAAE,CAAO,CAAC,EAHhD,iBAMtB,OAAAH,EAAa,MAAME,EAAc,KAEpB,yBAAiC,CAC1C,MAAO,CACHE,EAAa,SAAY,CACrBJ,EAAa,MAAME,EAAc,CACrC,CAAC,KACD,iBAAc,CACV,IAAAJ,EACA,aAAc,KACd,QAAS,UACDE,EAAW,SAAW,GAAGA,EAAW,KAAK,GAAI,MAAME,EAAc,CAAE,EAEhE,CAAE,cAAe,UAAU,MAAMH,EAAgBC,EAAW,IAAI,CAAC,GAAI,EAEpF,CAAC,CACL,CACJ,CAAC,CAGL,EA1CyB,aA4ClBK,EAAQT",
6
6
  "names": ["src_exports", "__export", "src_default", "getClient", "__toCommonJS", "import_client", "import_observable", "callbackLink", "__name", "callback", "next", "op", "observer", "request", "attempts", "isDone", "attempt", "error", "result", "getClient", "__name", "url", "didAuthFunction", "challenges", "challengeRequester", "getChallenges", "amount", "callbackLink", "src_default"]
7
7
  }
@@ -48,7 +48,7 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
48
48
  links: [
49
49
  httpBatchLink({
50
50
  url,
51
- maxURLLength: 2048,
51
+ maxURLLength: 3072,
52
52
  headers: { Authorization: `Bearer ${await didAuthFunction()}` }
53
53
  })
54
54
  ]
@@ -64,7 +64,7 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
64
64
  }),
65
65
  httpBatchLink({
66
66
  url,
67
- maxURLLength: 2048,
67
+ maxURLLength: 3072,
68
68
  headers: async () => {
69
69
  if (challenges.length === 0)
70
70
  challenges.push(...await getChallenges());
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/callbackLink.ts"],
4
- "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 2048,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
4
+ "sourcesContent": ["import { createTRPCProxyClient, CreateTRPCProxyClient, httpBatchLink } from '@trpc/client';\nimport type { inferRouterInputs } from '@trpc/server';\nimport type {\n JWE,\n PaginatedEncryptedRecordsType,\n PaginatedEncryptedCredentialRecordsType,\n} from '@learncard/types';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nimport { callbackLink } from './callbackLink';\n\ntype Inputs = inferRouterInputs<AppRouter>;\n\ntype Client = CreateTRPCProxyClient<AppRouter>;\n\ntype OverriddenClient = Omit<Client, 'index' | 'customStorage'> & {\n index: Client['index'] & {\n get: {\n query: (\n args: Inputs['index']['get']\n ) => Promise<PaginatedEncryptedCredentialRecordsType | JWE>;\n };\n };\n customStorage: Omit<Client['customStorage'], 'read'> & {\n read: {\n query: (\n args: Inputs['customStorage']['read']\n ) => Promise<PaginatedEncryptedRecordsType>;\n };\n };\n};\n\nexport const getClient = async (\n url: string,\n didAuthFunction: (challenge?: string) => Promise<string>\n) => {\n let challenges: string[] = [];\n\n const challengeRequester = createTRPCProxyClient<AppRouter>({\n links: [\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: { Authorization: `Bearer ${await didAuthFunction()}` },\n }),\n ],\n }) as OverriddenClient;\n\n const getChallenges = async (\n amount = 95 + Math.round((Math.random() - 0.5) * 5)\n ): Promise<string[]> => {\n return challengeRequester.utilities.getChallenges.query({ amount });\n };\n\n challenges = await getChallenges();\n\n const trpc = createTRPCProxyClient<AppRouter>({\n links: [\n callbackLink(async () => {\n challenges = await getChallenges();\n }),\n httpBatchLink({\n url,\n maxURLLength: 3072,\n headers: async () => {\n if (challenges.length === 0) challenges.push(...(await getChallenges()));\n\n return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };\n },\n }),\n ],\n }) as OverriddenClient;\n\n return trpc;\n};\n\nexport default getClient;\n", "import { TRPCLink } from '@trpc/client';\nimport { observable, Unsubscribable } from '@trpc/server/observable';\nimport type { AppRouter } from '@learncard/learn-cloud-service';\n\nexport const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter> => {\n return () => {\n return ({ next, op }) => {\n return observable(observer => {\n let request: Unsubscribable | null = null;\n let attempts = 0;\n let isDone = false;\n\n const attempt = () => {\n attempts += 1;\n request?.unsubscribe();\n request = next(op).subscribe({\n error: async error => {\n if (attempts > 5 || error.data?.httpStatus !== 401) {\n return observer.error(error);\n }\n\n await callback();\n\n attempt();\n },\n next: result => observer.next(result),\n complete: () => {\n if (isDone) observer.complete();\n },\n });\n };\n\n attempt();\n\n return () => {\n isDone = true;\n request?.unsubscribe();\n };\n });\n };\n };\n};\n"],
5
5
  "mappings": ";;;;AAAA,SAAS,uBAA8C,qBAAqB;;;ACC5E,SAAS,kBAAkC;AAGpC,IAAM,eAAe,wBAAC,aAAuD;AAChF,SAAO,MAAM;AACT,WAAO,CAAC,EAAE,MAAM,GAAG,MAAM;AACrB,aAAO,WAAW,cAAY;AAC1B,YAAI,UAAiC;AACrC,YAAI,WAAW;AACf,YAAI,SAAS;AAEb,cAAM,UAAU,6BAAM;AAClB,sBAAY;AACZ,mBAAS,YAAY;AACrB,oBAAU,KAAK,EAAE,EAAE,UAAU;AAAA,YACzB,OAAO,OAAM,UAAS;AAClB,kBAAI,WAAW,KAAK,MAAM,MAAM,eAAe,KAAK;AAChD,uBAAO,SAAS,MAAM,KAAK;AAAA,cAC/B;AAEA,oBAAM,SAAS;AAEf,sBAAQ;AAAA,YACZ;AAAA,YACA,MAAM,YAAU,SAAS,KAAK,MAAM;AAAA,YACpC,UAAU,MAAM;AACZ,kBAAI;AAAQ,yBAAS,SAAS;AAAA,YAClC;AAAA,UACJ,CAAC;AAAA,QACL,GAlBgB;AAoBhB,gBAAQ;AAER,eAAO,MAAM;AACT,mBAAS;AACT,mBAAS,YAAY;AAAA,QACzB;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ;AACJ,GArC4B;;;AD4BrB,IAAM,YAAY,8BACrB,KACA,oBACC;AACD,MAAI,aAAuB,CAAC;AAE5B,QAAM,qBAAqB,sBAAiC;AAAA,IACxD,OAAO;AAAA,MACH,cAAc;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,SAAS,EAAE,eAAe,UAAU,MAAM,gBAAgB,IAAI;AAAA,MAClE,CAAC;AAAA,IACL;AAAA,EACJ,CAAC;AAED,QAAM,gBAAgB,8BAClB,SAAS,KAAK,KAAK,OAAO,KAAK,OAAO,IAAI,OAAO,CAAC,MAC9B;AACpB,WAAO,mBAAmB,UAAU,cAAc,MAAM,EAAE,OAAO,CAAC;AAAA,EACtE,GAJsB;AAMtB,eAAa,MAAM,cAAc;AAEjC,QAAM,OAAO,sBAAiC;AAAA,IAC1C,OAAO;AAAA,MACH,aAAa,YAAY;AACrB,qBAAa,MAAM,cAAc;AAAA,MACrC,CAAC;AAAA,MACD,cAAc;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,SAAS,YAAY;AACjB,cAAI,WAAW,WAAW;AAAG,uBAAW,KAAK,GAAI,MAAM,cAAc,CAAE;AAEvE,iBAAO,EAAE,eAAe,UAAU,MAAM,gBAAgB,WAAW,IAAI,CAAC,IAAI;AAAA,QAChF;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,EACJ,CAAC;AAED,SAAO;AACX,GA1CyB;AA4CzB,IAAO,cAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@learncard/learn-cloud-client",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/learn-cloud-client.esm.js",
package/src/index.ts CHANGED
@@ -40,7 +40,7 @@ export const getClient = async (
40
40
  links: [
41
41
  httpBatchLink({
42
42
  url,
43
- maxURLLength: 2048,
43
+ maxURLLength: 3072,
44
44
  headers: { Authorization: `Bearer ${await didAuthFunction()}` },
45
45
  }),
46
46
  ],
@@ -61,7 +61,7 @@ export const getClient = async (
61
61
  }),
62
62
  httpBatchLink({
63
63
  url,
64
- maxURLLength: 2048,
64
+ maxURLLength: 3072,
65
65
  headers: async () => {
66
66
  if (challenges.length === 0) challenges.push(...(await getChallenges()));
67
67