@blossm/forwarded-token 0.0.0-stage → 0.0.2
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/README.md +12 -2
- package/index.js +5 -0
- package/package.json +18 -4
- package/test/index.js +13 -0
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
The header that carries a caller's token from one service to the next, and how to read it from a request.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```js
|
|
4
|
+
import forwardedToken, { header } from "@blossm/forwarded-token";
|
|
5
|
+
|
|
6
|
+
// Sending
|
|
7
|
+
request.get(url, { headers: { [header]: token } });
|
|
8
|
+
|
|
9
|
+
// Receiving
|
|
10
|
+
const token = forwardedToken(req);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The token travels in a header because query strings are written to request logs.
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blossm/forwarded-token",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "The header that carries a caller's token between services, and how to read it from a request.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"author": "blossm.network",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">= 24.22.1"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "mocha --recursive"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"mocha": "^12.0.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/test/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
|
|
3
|
+
import forwardedToken, { header } from "../index.js";
|
|
4
|
+
|
|
5
|
+
describe("Forwarded token", () => {
|
|
6
|
+
it("should read the token from its header", () => {
|
|
7
|
+
assert.equal(
|
|
8
|
+
forwardedToken({ headers: { [header]: "some-token" } }),
|
|
9
|
+
"some-token",
|
|
10
|
+
);
|
|
11
|
+
assert.equal(forwardedToken({ headers: {} }), undefined);
|
|
12
|
+
});
|
|
13
|
+
});
|