Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
6
#include "nsISupports.idl"
7
8
interface nsIFile;
9
interface nsILoginInfo;
10
interface nsIPropertyBag;
11
12
/**
13
* NOTE: This interface is intended to be implemented by modules
14
* providing storage mechanisms for the login manager.
15
* Other code should use the login manager's interfaces
16
* (nsILoginManager), and should not call storage modules
17
* directly.
18
*/
19
[scriptable, uuid(5df81a93-25e6-4b45-a696-089479e15c7d)]
20
interface nsILoginManagerStorage : nsISupports {
21
/**
22
* Initialize the component.
23
*
24
* At present, other methods of this interface may be called before the
25
* returned promise is resolved or rejected.
26
*
27
* @return {Promise}
28
* @resolves When initialization is complete.
29
* @rejects JavaScript exception.
30
*/
31
Promise initialize();
32
33
34
/**
35
* Ensures that all data has been written to disk and all files are closed.
36
*
37
* At present, this method is called by regression tests only. Finalization
38
* on shutdown is done by observers within the component.
39
*
40
* @return {Promise}
41
* @resolves When finalization is complete.
42
* @rejects JavaScript exception.
43
*/
44
Promise terminate();
45
46
47
/**
48
* Store a new login in the storage module.
49
*
50
* @param aLogin
51
* The login to be added.
52
* @param aPreEncrypted
53
* Whether the login was already encrypted or not.
54
* @param aPlaintextUsername
55
* The plaintext username, if the login was already encrypted.
56
* @param aPlaintextPassword
57
* The plaintext password, if the login was already encrypted.
58
* @return a clone of the login info with the guid set (even if it was not provided).
59
*
60
* Default values for the login's nsILoginMetaInfo properties will be
61
* created. However, if the caller specifies non-default values, they will
62
* be used instead.
63
*/
64
nsILoginInfo addLogin(in nsILoginInfo aLogin, [optional] in boolean aPreEncrypted, [optional] in jsval aPlaintextUsername, [optional] in jsval aPlaintextPassword);
65
66
67
/**
68
* Remove a login from the storage module.
69
*
70
* @param aLogin
71
* The login to be removed.
72
*
73
* The specified login must exactly match a stored login. However, the
74
* values of any nsILoginMetaInfo properties are ignored.
75
*/
76
void removeLogin(in nsILoginInfo aLogin);
77
78
79
/**
80
* Modify an existing login in the storage module.
81
*
82
* @param oldLogin
83
* The login to be modified.
84
* @param newLoginData
85
* The new login values (either a nsILoginInfo or nsIProperyBag)
86
*
87
* If newLoginData is a nsILoginInfo, all of the old login's nsILoginInfo
88
* properties are changed to the values from newLoginData (but the old
89
* login's nsILoginMetaInfo properties are unmodified).
90
*
91
* If newLoginData is a nsIPropertyBag, only the specified properties
92
* will be changed. The nsILoginMetaInfo properties of oldLogin can be
93
* changed in this manner.
94
*
95
* If the propertybag contains an item named "timesUsedIncrement", the
96
* login's timesUsed property will be incremented by the item's value.
97
*/
98
void modifyLogin(in nsILoginInfo oldLogin, in nsISupports newLoginData);
99
100
101
/**
102
* Remove all stored logins.
103
*
104
* The browser sanitization feature allows the user to clear any stored
105
* passwords. This interface allows that to be done without getting each
106
* login first (which might require knowing the master password).
107
*/
108
void removeAllLogins();
109
110
111
/**
112
* Fetch all logins in the login manager. An array is always returned;
113
* if there are no logins the array is empty.
114
*
115
* @return An array of nsILoginInfo objects.
116
*/
117
Array<nsILoginInfo> getAllLogins();
118
119
/**
120
* Fetch all logins in the login manager. An array is always returned;
121
* if there are no logins the array is empty.
122
*
123
* @return An array of nsILoginInfo objects.
124
*/
125
Promise getAllLoginsAsync();
126
127
/**
128
* Asynchonously search for logins in the login manager. The Promise always
129
* resolves to an array; if there are no logins the array is empty.
130
*
131
* @param {object} matchData
132
* The data used to search as a JS object. This does not follow the same
133
* requirements as findLogins for those fields. Wildcard matches are
134
* simply not specified.
135
* @return A promise resolving to an array of nsILoginInfo objects.
136
*/
137
Promise searchLoginsAsync(in jsval matchData);
138
139
/**
140
* Search for logins in the login manager. An array is always returned;
141
* if there are no logins the array is empty.
142
* @deprecated New code should use `searchLoginsAsync`.
143
* Only autocomplete, prompt, and test code still use this.
144
*
145
* @param matchData
146
* The data used to search. This does not follow the same
147
* requirements as findLogins for those fields. Wildcard matches are
148
* simply not specified.
149
* @return An array of nsILoginInfo objects.
150
*/
151
Array<nsILoginInfo> searchLogins(in nsIPropertyBag matchData);
152
153
/**
154
* Search for logins matching the specified criteria. Called when looking
155
* for logins that might be applicable to a form or authentication request.
156
*
157
* @param aOrigin
158
* The origin to restrict searches to. For example: "http://www.site.com".
159
* @param aActionURL
160
* For form logins, this argument should be the origin to which the
161
* form will be submitted. For HTTP auth. logins, specify null.
162
* @param aHttpRealm
163
* For protocol logins, this argument should be the HTTP Realm
164
* for which the login applies. This is obtained from the
165
* WWW-Authenticate header. See RFC2617. For form logins,
166
* specify null.
167
* @return An array of nsILoginInfo objects.
168
*/
169
Array<nsILoginInfo> findLogins(in AString aOrigin, in AString aActionOrigin,
170
in AString aHttpRealm);
171
172
173
/**
174
* Search for logins matching the specified criteria, as with
175
* findLogins(). This interface only returns the number of matching
176
* logins (and not the logins themselves), which allows a caller to
177
* check for logins without causing the user to be prompted for a master
178
* password to decrypt the logins.
179
*
180
* @param aOrigin
181
* The origin to restrict searches to. Specify an empty string
182
* to match all origins. A null value will not match any logins, and
183
* will thus always return a count of 0.
184
* @param aActionOrigin
185
* The origin to which a form login will be submitted. To match any
186
* form login, specify an empty string. To not match any form
187
* login, specify null.
188
* @param aHttpRealm
189
* The HTTP Realm for which the login applies. To match logins for
190
* any realm, specify an empty string. To not match logins for any
191
* realm, specify null.
192
*/
193
unsigned long countLogins(in AString aOrigin, in AString aActionOrigin,
194
in AString aHttpRealm);
195
/**
196
* True when a master password prompt is being shown.
197
*/
198
readonly attribute boolean uiBusy;
199
200
/**
201
* True when the master password has already been entered, and so a caller
202
* can ask for decrypted logins without triggering a prompt.
203
*/
204
readonly attribute boolean isLoggedIn;
205
};