cookie-prefs 0.2.1 → 0.2.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/dist/index.cjs +10 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/{types-C5uwWL7s.d.cts → types-DHcC7bDq.d.cts} +3 -1
- package/dist/{types-C5uwWL7s.d.ts → types-DHcC7bDq.d.ts} +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -146,6 +146,7 @@ var bind = (key, def, prefix, options) => {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
let rejected = false;
|
|
149
|
+
let insecure = false;
|
|
149
150
|
const write = (value) => {
|
|
150
151
|
try {
|
|
151
152
|
document.cookie = serialize(attrs, value);
|
|
@@ -188,7 +189,15 @@ var bind = (key, def, prefix, options) => {
|
|
|
188
189
|
};
|
|
189
190
|
},
|
|
190
191
|
read,
|
|
191
|
-
toCookie: (value) =>
|
|
192
|
+
toCookie: (value) => {
|
|
193
|
+
if (typeof process == "object" && process.env.NODE_ENV != "production" && typeof document == "undefined" && !insecure && !attrs.secure && (attrs.sameSite == "none" || /^__(Host|Secure)-/i.test(name))) {
|
|
194
|
+
insecure = true;
|
|
195
|
+
console.warn(
|
|
196
|
+
`cookie-prefs: ${key}.toCookie() builds a cookie that browsers drop: SameSite=None and the __Host- and __Secure- name prefixes need Secure. Set secure: true in .options() or definePrefs().`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return { ...attrs, value: def.s(value) };
|
|
200
|
+
}
|
|
192
201
|
};
|
|
193
202
|
if (targets)
|
|
194
203
|
Object.defineProperty(handle, REFLECTION, {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EnumPrefBuilder, S as ScalarPrefBuilder, P as PrefBuilder, a as PrefCodec, b as PrefShape, c as PrefsOptions, d as Prefs, e as PrefsRecord, C as CookieSource, f as PrefValues, g as PrefsSnapshot } from './types-
|
|
2
|
-
export { A as AnyPref, h as AnyPrefBuilder, i as CookieGetter, j as CookieInit, k as CookieOptions, l as CookieSameSite, m as EnumReflectTarget, n as Pref, o as PrefOptions, p as PrefSetter, q as PrefTypes, r as PrefValue, R as ReflectTarget } from './types-
|
|
1
|
+
import { E as EnumPrefBuilder, S as ScalarPrefBuilder, P as PrefBuilder, a as PrefCodec, b as PrefShape, c as PrefsOptions, d as Prefs, e as PrefsRecord, C as CookieSource, f as PrefValues, g as PrefsSnapshot } from './types-DHcC7bDq.cjs';
|
|
2
|
+
export { A as AnyPref, h as AnyPrefBuilder, i as CookieGetter, j as CookieInit, k as CookieOptions, l as CookieSameSite, m as EnumReflectTarget, n as Pref, o as PrefOptions, p as PrefSetter, q as PrefTypes, r as PrefValue, R as ReflectTarget } from './types-DHcC7bDq.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Structural copy of the Standard Schema v1 interface (https://standardschema.dev, MIT).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EnumPrefBuilder, S as ScalarPrefBuilder, P as PrefBuilder, a as PrefCodec, b as PrefShape, c as PrefsOptions, d as Prefs, e as PrefsRecord, C as CookieSource, f as PrefValues, g as PrefsSnapshot } from './types-
|
|
2
|
-
export { A as AnyPref, h as AnyPrefBuilder, i as CookieGetter, j as CookieInit, k as CookieOptions, l as CookieSameSite, m as EnumReflectTarget, n as Pref, o as PrefOptions, p as PrefSetter, q as PrefTypes, r as PrefValue, R as ReflectTarget } from './types-
|
|
1
|
+
import { E as EnumPrefBuilder, S as ScalarPrefBuilder, P as PrefBuilder, a as PrefCodec, b as PrefShape, c as PrefsOptions, d as Prefs, e as PrefsRecord, C as CookieSource, f as PrefValues, g as PrefsSnapshot } from './types-DHcC7bDq.js';
|
|
2
|
+
export { A as AnyPref, h as AnyPrefBuilder, i as CookieGetter, j as CookieInit, k as CookieOptions, l as CookieSameSite, m as EnumReflectTarget, n as Pref, o as PrefOptions, p as PrefSetter, q as PrefTypes, r as PrefValue, R as ReflectTarget } from './types-DHcC7bDq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Structural copy of the Standard Schema v1 interface (https://standardschema.dev, MIT).
|
package/dist/index.js
CHANGED
|
@@ -144,6 +144,7 @@ var bind = (key, def, prefix, options) => {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
let rejected = false;
|
|
147
|
+
let insecure = false;
|
|
147
148
|
const write = (value) => {
|
|
148
149
|
try {
|
|
149
150
|
document.cookie = serialize(attrs, value);
|
|
@@ -186,7 +187,15 @@ var bind = (key, def, prefix, options) => {
|
|
|
186
187
|
};
|
|
187
188
|
},
|
|
188
189
|
read,
|
|
189
|
-
toCookie: (value) =>
|
|
190
|
+
toCookie: (value) => {
|
|
191
|
+
if (typeof process == "object" && process.env.NODE_ENV != "production" && typeof document == "undefined" && !insecure && !attrs.secure && (attrs.sameSite == "none" || /^__(Host|Secure)-/i.test(name))) {
|
|
192
|
+
insecure = true;
|
|
193
|
+
console.warn(
|
|
194
|
+
`cookie-prefs: ${key}.toCookie() builds a cookie that browsers drop: SameSite=None and the __Host- and __Secure- name prefixes need Secure. Set secure: true in .options() or definePrefs().`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
return { ...attrs, value: def.s(value) };
|
|
198
|
+
}
|
|
190
199
|
};
|
|
191
200
|
if (targets)
|
|
192
201
|
Object.defineProperty(handle, REFLECTION, {
|
package/dist/react/index.d.cts
CHANGED
package/dist/react/index.d.ts
CHANGED
|
@@ -18,7 +18,9 @@ interface CookieOptions {
|
|
|
18
18
|
sameSite?: CookieSameSite | undefined;
|
|
19
19
|
/**
|
|
20
20
|
* Send only over HTTPS. When unset, browser writes add `Secure` on `https:` pages
|
|
21
|
-
* and `toCookie()` omits it.
|
|
21
|
+
* and `toCookie()` omits it. Set it for `sameSite: 'none'` and for a `__Host-` or
|
|
22
|
+
* `__Secure-` name written on the server: browsers drop those cookies without it
|
|
23
|
+
* (`toCookie()` warns in development).
|
|
22
24
|
*/
|
|
23
25
|
secure?: boolean | undefined;
|
|
24
26
|
/** CHIPS partitioned cookie. @default false */
|
|
@@ -18,7 +18,9 @@ interface CookieOptions {
|
|
|
18
18
|
sameSite?: CookieSameSite | undefined;
|
|
19
19
|
/**
|
|
20
20
|
* Send only over HTTPS. When unset, browser writes add `Secure` on `https:` pages
|
|
21
|
-
* and `toCookie()` omits it.
|
|
21
|
+
* and `toCookie()` omits it. Set it for `sameSite: 'none'` and for a `__Host-` or
|
|
22
|
+
* `__Secure-` name written on the server: browsers drop those cookies without it
|
|
23
|
+
* (`toCookie()` warns in development).
|
|
22
24
|
*/
|
|
23
25
|
secure?: boolean | undefined;
|
|
24
26
|
/** CHIPS partitioned cookie. @default false */
|