@tramvai/module-cookie 6.66.1 → 6.67.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/README.md +28 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Implements interface `CookieManager` and adds provider `COOKIE_MANAGER_TOKEN` fr
|
|
|
18
18
|
|
|
19
19
|
## How to
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### Working with cookies
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
24
|
import { Module, provide } from '@tramvai/core';
|
|
@@ -29,6 +29,7 @@ import { COOKIE_MANAGER_TOKEN } from '@tramvai/module-common';
|
|
|
29
29
|
provide({
|
|
30
30
|
provide: 'my_module',
|
|
31
31
|
useFactory: ({ cookie }) => {
|
|
32
|
+
cookie.set('sid', 'ads.api3');
|
|
32
33
|
cookie.get('sid'); // > ads.api3
|
|
33
34
|
},
|
|
34
35
|
deps: {
|
|
@@ -40,6 +41,32 @@ import { COOKIE_MANAGER_TOKEN } from '@tramvai/module-common';
|
|
|
40
41
|
class MyModule {}
|
|
41
42
|
```
|
|
42
43
|
|
|
44
|
+
### Set multiple cookies with the same key
|
|
45
|
+
|
|
46
|
+
By default, cookies with the same key are deduplicated on the server-side. To set multiple cookies with the same key, you can use a unique identifier for each cookie with the `ResponseManager.setCookie` method:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Module, provide } from '@tramvai/core';
|
|
50
|
+
import { RESPONSE_MANAGER_TOKEN } from '@tramvai/module-common';
|
|
51
|
+
|
|
52
|
+
@Module({
|
|
53
|
+
providers: [
|
|
54
|
+
provide({
|
|
55
|
+
provide: 'my_module',
|
|
56
|
+
useFactory: ({ responseManager }) => {
|
|
57
|
+
responseManager.setCookie('b', `b=b; Path=/; SameSite=Strict`);
|
|
58
|
+
// different identifier 'b-subpath' to avoid deduplication, will not affect the cookie name
|
|
59
|
+
responseManager.setCookie('b-subpath', `b=b; Path=/foo/bar/; SameSite=Strict`);
|
|
60
|
+
},
|
|
61
|
+
deps: {
|
|
62
|
+
responseManager: RESPONSE_MANAGER_TOKEN,
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
class MyModule {}
|
|
68
|
+
```
|
|
69
|
+
|
|
43
70
|
## Exported tokens
|
|
44
71
|
|
|
45
72
|
### COOKIE_MANAGER_TOKEN
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-cookie",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.67.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@tinkoff/browser-cookies": "6.0.0",
|
|
22
|
-
"@tramvai/module-client-hints": "6.
|
|
23
|
-
"@tramvai/tokens-cookie": "6.
|
|
22
|
+
"@tramvai/module-client-hints": "6.67.1",
|
|
23
|
+
"@tramvai/tokens-cookie": "6.67.1",
|
|
24
24
|
"cookie": "^0.5.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@tinkoff/dippy": "0.12.3",
|
|
28
28
|
"@tinkoff/utils": "^2.1.2",
|
|
29
|
-
"@tramvai/core": "6.
|
|
30
|
-
"@tramvai/state": "6.
|
|
31
|
-
"@tramvai/tokens-common": "6.
|
|
29
|
+
"@tramvai/core": "6.67.1",
|
|
30
|
+
"@tramvai/state": "6.67.1",
|
|
31
|
+
"@tramvai/tokens-common": "6.67.1",
|
|
32
32
|
"tslib": "^2.4.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|