forked from oskca/gopherjs-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw_cookies.go
70 lines (62 loc) · 2.53 KB
/
raw_cookies.go
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
package electron
import "github.com/oskca/gopherjs-nodejs/events"
import "github.com/gopherjs/gopherjs/js"
// events
const (
// Emitted when a cookie is changed because it was added, edited, removed, or expired.
EvtCookiesChanged = "changed"
)
// Cookies version@1.4.15
//
// Query and modify a session's cookies.
type Cookies struct {
*events.Emitter
// Sends a request to get all cookies matching details, callback will be called with callback(error, cookies) on complete. cookies is an Array of cookie objects.
Get func(Filter *CookiesGetFilter, Callback CookiesGetCallback) `js:"get"`
// Sets a cookie with details, callback will be called with callback(error) on complete.
Set func(Details *CookiesSetDetails, Callback CookiesSetCallback) `js:"set"`
// Removes the cookies matching url and name, callback will called with callback() on complete.
Remove func(URL string, Name string, Callback CookiesRemoveCallback) `js:"remove"`
}
func WrapCookies(o *js.Object) *Cookies {
return &Cookies{
Emitter: events.New(o),
}
}
type CookiesSetDetails struct {
*js.Object
// The url to associate the cookie with.
URL string `js:"url"`
// The name of the cookie. Empty by default if omitted.
Name string `js:"name"`
// The value of the cookie. Empty by default if omitted.
Value string `js:"value"`
// The domain of the cookie. Empty by default if omitted.
Domain string `js:"domain"`
// The path of the cookie. Empty by default if omitted.
Path string `js:"path"`
// Whether the cookie should be marked as Secure. Defaults to false.
Secure bool `js:"secure"`
// Whether the cookie should be marked as HTTP only. Defaults to false.
HttpOnly bool `js:"httpOnly"`
// The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted then the cookie becomes a session cookie and will not be retained between sessions.
ExpirationDate float64 `js:"expirationDate"`
}
type CookiesSetCallback func(Error *js.Object)
type CookiesRemoveCallback func()
type CookiesGetFilter struct {
*js.Object
// Retrieves cookies which are associated with . Empty implies retrieving cookies of all urls.
URL string `js:"url"`
// Filters cookies by name.
Name string `js:"name"`
// Retrieves cookies whose domains match or are subdomains of
Domain string `js:"domain"`
// Retrieves cookies whose path matches .
Path string `js:"path"`
// Filters cookies by their Secure property.
Secure bool `js:"secure"`
// Filters out session or persistent cookies.
Session bool `js:"session"`
}
type CookiesGetCallback func(Error *js.Object, Cookies *js.Object)