-
Notifications
You must be signed in to change notification settings - Fork 16
/
deno_cookie.deno.txt
87 lines (66 loc) · 4.89 KB
/
deno_cookie.deno.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
DENO_COOKIE
ALTERNATIVES ==> #See js-cookie
VERSION ==> #Part of Deno
#Browser compatible
/=+===============================+=\
/ : : \
)==: PARSE SERIALIZE :==(
\ :_______________________________: /
\=+===============================+=/
std/http/cookie.ts
getCookies(HEADERS)->OBJ #Parse cookies from Cookie [C]
#OBJ key is 'VAR', value is 'VAL'
getSetCookies(HEADERS)->COOKIE_ARR#Parse cookies from Set-Cookie [S]
setCookie(HEADERS, COOKIE) #Add cookies to Set-Cookie [S]
deleteCookie
(HEADERS, 'VAR'[, COOKIE]) #Like setCookie(), but set "expires" to past date
COOKIE.name #'VAR'
COOKIE.value #'VAL'
COOKIE.domain #STR
COOKIE.path #STR
COOKIE.expires #DATE[_NUM]
COOKIE.maxAge #NUM
COOKIE.secure #BOOL
COOKIE.httpOnly #BOOL
COOKIE.sameSite #'Strict|Lax|None'
COOKIE.unparsed #'SVAR=VAL'_ARR. Additional non-standard cookie options
ANY_HEADERS #HEADERS or { headers: HEADERS } (e.g. REQ|RES)
/=+===============================+=\
/ : : \
)==: HEADERS :==(
\ :_______________________________: /
\=+===============================+=/
std/http/cookie_map.ts
new CookieMap(ANY_HEADERS[, OPTS])#Child of MAP:
# - key is cookie 'VAR'
# - value is 'VAL'
# - get methods:
# - i.e. iteration|get|has|size()
# - use request headers (from constructor)
# - Cookie [C]
# - set methods:
# - i.e. set|delete|clear()
# - use response headers (from OPTS.response)
# - Set-Cookie [S]
# - can use SCOOKIE as last argument
OPTS.response #ANY_HEADERS (def: new Headers())
OPTS.secure #BOOL (def: false). Whether current connection is secure (e.g. using SSL)
SCOOKIE.domain #STR
SCOOKIE.path #STR (def: '/')
SCOOKIE.expires #DATE
SCOOKIE.maxAge #NUM
SCOOKIE.secure #BOOL (def: false)
SCOOKIE.httpOnly #BOOL (def: true)
SCOOKIE.sameSite #'Strict'|true, 'Lax', 'None' or false (def, not set)
SCOOKIE.ignoreInsecure #BOOL. If false, error when signing|validating unless OPTS.secure
SCOOKIE.overwrite #BOOL. If false (def), noop if cookie 'VAR' already exists
/=+===============================+=\
/ : : \
)==: MERGE :==(
\ :_______________________________: /
\=+===============================+=/
mergeHeaders
(ANY_HEADERS|COOKIE_MAP...)
->HEADERS #Merge all Set-Cookie [S]