@fastify/cookie 7.3.0 → 7.3.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/package.json +1 -1
- package/plugin.d.ts +67 -40
package/package.json
CHANGED
package/plugin.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types='node' />
|
|
2
2
|
|
|
3
|
-
import { FastifyPluginCallback } from
|
|
3
|
+
import { FastifyPluginCallback } from "fastify";
|
|
4
4
|
|
|
5
|
-
declare module
|
|
5
|
+
declare module "fastify" {
|
|
6
6
|
interface FastifyInstance {
|
|
7
7
|
/**
|
|
8
8
|
* Unsigns the specified cookie using the secret provided.
|
|
@@ -49,7 +49,7 @@ declare module 'fastify' {
|
|
|
49
49
|
export type setCookieWrapper = (
|
|
50
50
|
name: string,
|
|
51
51
|
value: string,
|
|
52
|
-
options?: CookieSerializeOptions
|
|
52
|
+
options?: fastifyCookie.CookieSerializeOptions
|
|
53
53
|
) => FastifyReply;
|
|
54
54
|
|
|
55
55
|
interface FastifyReply {
|
|
@@ -63,20 +63,27 @@ declare module 'fastify' {
|
|
|
63
63
|
setCookie(
|
|
64
64
|
name: string,
|
|
65
65
|
value: string,
|
|
66
|
-
options?: CookieSerializeOptions
|
|
66
|
+
options?: fastifyCookie.CookieSerializeOptions
|
|
67
67
|
): this;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* @alias setCookie
|
|
71
71
|
*/
|
|
72
|
-
cookie(
|
|
72
|
+
cookie(
|
|
73
|
+
name: string,
|
|
74
|
+
value: string,
|
|
75
|
+
options?: fastifyCookie.CookieSerializeOptions
|
|
76
|
+
): this;
|
|
73
77
|
|
|
74
78
|
/**
|
|
75
79
|
* clear response cookie
|
|
76
80
|
* @param name Cookie name
|
|
77
81
|
* @param options Serialize options
|
|
78
82
|
*/
|
|
79
|
-
clearCookie(
|
|
83
|
+
clearCookie(
|
|
84
|
+
name: string,
|
|
85
|
+
options?: fastifyCookie.CookieSerializeOptions
|
|
86
|
+
): this;
|
|
80
87
|
|
|
81
88
|
/**
|
|
82
89
|
* Unsigns the specified cookie using the secret provided.
|
|
@@ -90,44 +97,64 @@ declare module 'fastify' {
|
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
expires?: Date;
|
|
97
|
-
httpOnly?: boolean;
|
|
98
|
-
maxAge?: number;
|
|
99
|
-
path?: string;
|
|
100
|
-
priority?: 'low' | 'medium' | 'high';
|
|
101
|
-
sameSite?: boolean | 'lax' | 'strict' | 'none';
|
|
102
|
-
secure?: boolean | 'auto';
|
|
103
|
-
signed?: boolean;
|
|
104
|
-
}
|
|
100
|
+
type FastifyCookiePlugin = FastifyPluginCallback<
|
|
101
|
+
NonNullable<fastifyCookie.FastifyCookieOptions>
|
|
102
|
+
>;
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
104
|
+
declare namespace fastifyCookie {
|
|
105
|
+
export interface Signer {
|
|
106
|
+
sign: (input: string) => string;
|
|
107
|
+
unsign: (input: string) => {
|
|
108
|
+
valid: boolean;
|
|
109
|
+
renew: boolean;
|
|
110
|
+
value: string | null;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
114
113
|
|
|
115
|
-
export interface
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
export interface CookieSerializeOptions {
|
|
115
|
+
domain?: string;
|
|
116
|
+
encode?(val: string): string;
|
|
117
|
+
expires?: Date;
|
|
118
|
+
httpOnly?: boolean;
|
|
119
|
+
maxAge?: number;
|
|
120
|
+
path?: string;
|
|
121
|
+
priority?: "low" | "medium" | "high";
|
|
122
|
+
sameSite?: boolean | "lax" | "strict" | "none";
|
|
123
|
+
secure?: boolean;
|
|
124
|
+
signed?: boolean;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface FastifyCookieOptions {
|
|
128
|
+
secret?: string | string[] | Signer;
|
|
129
|
+
parseOptions?: fastifyCookie.CookieSerializeOptions;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type Sign = (value: string, secret: string) => string;
|
|
133
|
+
export type Unsign = (input: string, secret: string) => string | false;
|
|
134
|
+
export type SignerFactory = (secret: string) => Signer;
|
|
119
135
|
|
|
120
|
-
export
|
|
121
|
-
export
|
|
122
|
-
export
|
|
136
|
+
export const signerFactory: SignerFactory;
|
|
137
|
+
export const sign: Sign;
|
|
138
|
+
export const unsign: Unsign;
|
|
139
|
+
|
|
140
|
+
export interface FastifyCookie extends FastifyCookiePlugin {
|
|
141
|
+
signerFactory: SignerFactory;
|
|
142
|
+
sign: Sign;
|
|
143
|
+
unsign: Unsign;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const fastifyCookie: FastifyCookie;
|
|
147
|
+
|
|
148
|
+
export interface FastifyCookieOptions {
|
|
149
|
+
secret?: string | string[] | Signer;
|
|
150
|
+
parseOptions?: CookieSerializeOptions;
|
|
151
|
+
}
|
|
123
152
|
|
|
124
|
-
export
|
|
125
|
-
signerFactory: SignerFactory;
|
|
126
|
-
sign: Sign;
|
|
127
|
-
unsign: Unsign;
|
|
153
|
+
export { fastifyCookie as default };
|
|
128
154
|
}
|
|
129
155
|
|
|
130
|
-
declare
|
|
156
|
+
declare function fastifyCookie(
|
|
157
|
+
...params: Parameters<FastifyCookiePlugin>
|
|
158
|
+
): ReturnType<FastifyCookiePlugin>;
|
|
131
159
|
|
|
132
|
-
export
|
|
133
|
-
export { fastifyCookie };
|
|
160
|
+
export = fastifyCookie;
|