@learncard/network-brain-client 2.5.27 → 2.5.31
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 +28 -0
- package/dist/brain-client.cjs.development.js +170 -13
- package/dist/brain-client.cjs.development.js.map +2 -2
- package/dist/brain-client.cjs.production.min.js +5 -5
- package/dist/brain-client.cjs.production.min.js.map +3 -3
- package/dist/brain-client.esm.js +170 -13
- package/dist/brain-client.esm.js.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TRPCClient } from '@trpc/client';
|
|
|
2
2
|
import type { AppRouter } from '@learncard/network-brain-service';
|
|
3
3
|
export type LCNClient = TRPCClient<AppRouter>;
|
|
4
4
|
export type GuardianApprovalGetter = () => string | undefined | Promise<string | undefined>;
|
|
5
|
-
export declare const getClient: (url: string, didAuthFunction: (challenge?: string) => Promise<string>, guardianApprovalGetter?: GuardianApprovalGetter) => Promise<LCNClient>;
|
|
6
|
-
export declare const getApiTokenClient: (url: string, apiToken: string, guardianApprovalGetter?: GuardianApprovalGetter) => Promise<LCNClient>;
|
|
5
|
+
export declare const getClient: (url: string, didAuthFunction: (challenge?: string) => Promise<string>, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
|
|
6
|
+
export declare const getApiTokenClient: (url: string, apiToken: string, guardianApprovalGetter?: GuardianApprovalGetter, extraHeaders?: Record<string, string>) => Promise<LCNClient>;
|
|
7
7
|
export default getClient;
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,QACb,MAAM,mBACM,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,2BAC/B,sBAAsB,
|
|
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,QACb,MAAM,mBACM,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,2BAC/B,sBAAsB,iBAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CAyDnB,CAAC;AAGF,eAAO,MAAM,iBAAiB,QACrB,MAAM,YACD,MAAM,2BACS,sBAAsB,iBAChC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACtC,OAAO,CAAC,SAAS,CA2BnB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/network-brain-client",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "./dist/brain-client.esm.js",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"dts-bundle-generator": "^6.10.0",
|
|
13
13
|
"esbuild": "^0.27.1",
|
|
14
|
-
"@learncard/helpers": "1.2.
|
|
15
|
-
"@learncard/types": "5.13.
|
|
14
|
+
"@learncard/helpers": "1.2.16",
|
|
15
|
+
"@learncard/types": "5.13.6"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@trpc/client": "11.3.0",
|
|
19
|
-
"@learncard/network-brain-service": "3.
|
|
19
|
+
"@learncard/network-brain-service": "3.14.3"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,8 @@ export type GuardianApprovalGetter = () => string | undefined | Promise<string |
|
|
|
11
11
|
export const getClient = async (
|
|
12
12
|
url: string,
|
|
13
13
|
didAuthFunction: (challenge?: string) => Promise<string>,
|
|
14
|
-
guardianApprovalGetter?: GuardianApprovalGetter
|
|
14
|
+
guardianApprovalGetter?: GuardianApprovalGetter,
|
|
15
|
+
extraHeaders?: Record<string, string>
|
|
15
16
|
): Promise<LCNClient> => {
|
|
16
17
|
let challenges: string[] = [];
|
|
17
18
|
|
|
@@ -21,7 +22,7 @@ export const getClient = async (
|
|
|
21
22
|
methodOverride: 'POST',
|
|
22
23
|
url,
|
|
23
24
|
maxURLLength: 3072,
|
|
24
|
-
headers: { Authorization: `Bearer ${await didAuthFunction()}
|
|
25
|
+
headers: { Authorization: `Bearer ${await didAuthFunction()}`, ...extraHeaders },
|
|
25
26
|
transformer: {
|
|
26
27
|
input: RegExpTransformer,
|
|
27
28
|
output: { serialize: o => o, deserialize: o => o },
|
|
@@ -57,6 +58,7 @@ export const getClient = async (
|
|
|
57
58
|
return {
|
|
58
59
|
Authorization: `Bearer ${await didAuthFunction(challenges.pop())}`,
|
|
59
60
|
...(guardianApproval ? { 'x-guardian-approval': guardianApproval } : {}),
|
|
61
|
+
...extraHeaders,
|
|
60
62
|
};
|
|
61
63
|
},
|
|
62
64
|
transformer: {
|
|
@@ -74,7 +76,8 @@ export const getClient = async (
|
|
|
74
76
|
export const getApiTokenClient = async (
|
|
75
77
|
url: string,
|
|
76
78
|
apiToken: string,
|
|
77
|
-
guardianApprovalGetter?: GuardianApprovalGetter
|
|
79
|
+
guardianApprovalGetter?: GuardianApprovalGetter,
|
|
80
|
+
extraHeaders?: Record<string, string>
|
|
78
81
|
): Promise<LCNClient> => {
|
|
79
82
|
const trpc = createTRPCClient<AppRouter>({
|
|
80
83
|
links: [
|
|
@@ -90,6 +93,7 @@ export const getApiTokenClient = async (
|
|
|
90
93
|
return {
|
|
91
94
|
Authorization: `Bearer ${apiToken}`,
|
|
92
95
|
...(guardianApproval ? { 'x-guardian-approval': guardianApproval } : {}),
|
|
96
|
+
...extraHeaders,
|
|
93
97
|
};
|
|
94
98
|
},
|
|
95
99
|
transformer: {
|