beer-network 1.2.5 → 1.2.7
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/api.d.ts +0 -1
- package/api.js +16 -9
- package/package.json +1 -1
package/api.d.ts
CHANGED
package/api.js
CHANGED
|
@@ -2,7 +2,6 @@ import { Session } from './session';
|
|
|
2
2
|
export default class Fetch {
|
|
3
3
|
constructor(pathPrefix) {
|
|
4
4
|
this.isNextJS = undefined;
|
|
5
|
-
this.nodeHeaders = undefined;
|
|
6
5
|
this.pathPrefix = pathPrefix || '';
|
|
7
6
|
this.isNode = typeof process !== 'undefined' && !!process.versions?.node;
|
|
8
7
|
}
|
|
@@ -293,16 +292,24 @@ export default class Fetch {
|
|
|
293
292
|
if (index > 2) {
|
|
294
293
|
return undefined;
|
|
295
294
|
}
|
|
296
|
-
if (this.isNextJS
|
|
297
|
-
return this.nodeHeaders.get('AccessToken') ?? this.nodeHeaders.get('Authorization') ?? '';
|
|
298
|
-
}
|
|
299
|
-
try {
|
|
295
|
+
if (this.isNextJS === true) {
|
|
300
296
|
const nextModule = await import('next/headers');
|
|
301
|
-
|
|
302
|
-
|
|
297
|
+
const nodeHeaders = await nextModule.headers();
|
|
298
|
+
return nodeHeaders.get('x-access-token')
|
|
299
|
+
?? nodeHeaders.get('access-token')
|
|
300
|
+
?? nodeHeaders.get('authorization')
|
|
301
|
+
?? nodeHeaders.get('AccessToken')
|
|
302
|
+
?? nodeHeaders.get('Authorization')
|
|
303
|
+
?? '';
|
|
303
304
|
}
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
if (this.isNextJS === undefined) {
|
|
306
|
+
try {
|
|
307
|
+
await import('next/headers');
|
|
308
|
+
this.isNextJS = true;
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
this.isNextJS = false;
|
|
312
|
+
}
|
|
306
313
|
}
|
|
307
314
|
return this.tryAuthorization(index + 1);
|
|
308
315
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beer-network",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.7",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"pub-w": "tsc && copy package.json .\\dist\\package.json && npm publish ./dist",
|
|
7
7
|
"pub-m": "tsc && cp package.json ./dist/package.json && npm publish ./dist"
|