@learncard/network-brain-client 2.5.53 → 2.5.55

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.
@@ -1 +1 @@
1
- {"version":3,"file":"callbackLink.d.ts","sourceRoot":"","sources":["../src/callbackLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,QAAQ,CAAC,SAAS,CAqC9E,CAAC"}
1
+ {"version":3,"file":"callbackLink.d.ts","sourceRoot":"","sources":["../src/callbackLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,QAAQ,CAAC,SAAS,CA8C9E,CAAC"}
package/dist/index.d.cts CHANGED
@@ -4,5 +4,6 @@ export type LCNClient = TRPCClient<AppRouter>;
4
4
  export type GuardianApprovalGetter = () => string | undefined | Promise<string | undefined>;
5
5
  export declare const getClient: (url: string, didAuthFunction: (challenge?: string) => Promise<string>, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
6
6
  export declare const getApiTokenClient: (url: string, apiToken: string, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
7
+ export declare const getAnonymousClient: (url: string) => LCNClient;
7
8
  export default getClient;
8
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export type LCNClient = TRPCClient<AppRouter>;
4
4
  export type GuardianApprovalGetter = () => string | undefined | Promise<string | undefined>;
5
5
  export declare const getClient: (url: string, didAuthFunction: (challenge?: string) => Promise<string>, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
6
6
  export declare const getApiTokenClient: (url: string, apiToken: string, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
7
+ export declare const getAnonymousClient: (url: string) => LCNClient;
7
8
  export default getClient;
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,UAAU,EAAiB,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG,MAAM,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5F,eAAO,MAAM,SAAS,GAClB,KAAK,MAAM,EACX,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EACxD,yBAAyB,sBAAsB,EAC/C,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CAoFnB,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAC1B,KAAK,MAAM,EACX,UAAU,MAAM,EAChB,yBAAyB,sBAAsB,EAC/C,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CA2BnB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,UAAU,EAAiB,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAIlE,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAE9C,MAAM,MAAM,sBAAsB,GAAG,MAAM,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAE5F,eAAO,MAAM,SAAS,GAClB,KAAK,MAAM,EACX,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,EACxD,yBAAyB,sBAAsB,EAC/C,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CAgFnB,CAAC;AAGF,eAAO,MAAM,iBAAiB,GAC1B,KAAK,MAAM,EACX,UAAU,MAAM,EAChB,yBAAyB,sBAAsB,EAC/C,eAAe,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CA2BnB,CAAC;AAGF,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,SAa3C,CAAC;AAEP,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@learncard/network-brain-client",
3
- "version": "2.5.53",
3
+ "version": "2.5.55",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -33,14 +33,14 @@
33
33
  "author": "Learning Economy Foundation (www.learningeconomy.io)",
34
34
  "license": "MIT",
35
35
  "devDependencies": {
36
- "@learncard/helpers": "1.4.0",
37
- "@learncard/types": "5.18.3",
36
+ "@learncard/helpers": "1.5.0",
37
+ "@learncard/types": "5.19.0",
38
38
  "dts-bundle-generator": "^6.10.0",
39
39
  "esbuild": "^0.27.1",
40
40
  "vitest": "4.1.10"
41
41
  },
42
42
  "dependencies": {
43
- "@learncard/network-brain-service": "3.16.16",
43
+ "@learncard/network-brain-service": "3.17.0",
44
44
  "@trpc/client": "11.8.0"
45
45
  },
46
46
  "repository": {
@@ -14,18 +14,27 @@ export const callbackLink = (callback: () => Promise<void>): TRPCLink<AppRouter>
14
14
  attempts += 1;
15
15
  request?.unsubscribe();
16
16
  request = next(op).subscribe({
17
- error: async error => {
17
+ error: error => {
18
+ if (isDone) return;
19
+
18
20
  if (attempts > 5 || error.data?.httpStatus !== 401) {
19
- return observer.error(error);
21
+ observer.error(error);
22
+ return;
20
23
  }
21
24
 
22
- await callback();
23
-
24
- attempt();
25
+ void callback().then(
26
+ () => {
27
+ if (!isDone) attempt();
28
+ },
29
+ () => {
30
+ // Forward the original request error if refreshing auth fails.
31
+ if (!isDone) observer.error(error);
32
+ }
33
+ );
25
34
  },
26
35
  next: result => observer.next(result),
27
36
  complete: () => {
28
- if (isDone) observer.complete();
37
+ if (!isDone) observer.complete();
29
38
  },
30
39
  });
31
40
  };
package/src/index.ts CHANGED
@@ -62,10 +62,6 @@ export const getClient = async (
62
62
  }
63
63
  };
64
64
 
65
- // Pre-warm the pool while the caller continues client/plugin setup. Requests
66
- // arriving before this settles await the same single-flight refill.
67
- void refillChallenges().catch(() => undefined);
68
-
69
65
  const trpc = createTRPCClient<AppRouter>({
70
66
  links: [
71
67
  callbackLink(async () => {
@@ -134,4 +130,20 @@ export const getApiTokenClient = async (
134
130
  return trpc;
135
131
  };
136
132
 
133
+ /** Public routes only: no DID challenges, API tokens, or authority headers. */
134
+ export const getAnonymousClient = (url: string): LCNClient =>
135
+ createTRPCClient<AppRouter>({
136
+ links: [
137
+ httpBatchLink({
138
+ methodOverride: 'POST',
139
+ url,
140
+ maxURLLength: 3072,
141
+ transformer: {
142
+ input: RegExpTransformer,
143
+ output: { serialize: o => o, deserialize: o => o },
144
+ },
145
+ }),
146
+ ],
147
+ });
148
+
137
149
  export default getClient;