1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | interface TokenOptions {
|
7 | expires?: number | undefined;
|
8 | notBefore?: number | undefined;
|
9 | admin?: boolean | undefined;
|
10 | debug?: boolean | undefined;
|
11 | simulate?: boolean | undefined;
|
12 | iat?: number | undefined;
|
13 | }
|
14 |
|
15 | declare class FirebaseTokenGenerator {
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 | constructor(secret: string);
|
22 |
|
23 | /**
|
24 | * Creates a token that authenticates a client with arbitrary data "data", and the specified options.
|
25 | *
|
26 | * @param { any } data JSON data that will be passed to the Firebase Rules API once a client authenticates. Unless the
|
27 | * "admin" flag is set, it must contain a "uid" key, and if it does it must be a string of length
|
28 | * 256 or less.
|
29 | * @param { TokenOptions } options The developer-supplied options for this token. Supported options are:
|
30 | * a) "expires" -- A timestamp (as a number of seconds since the epoch) denoting a time after which
|
31 | * this token should no longer be valid.
|
32 | * b) "notBefore" -- A timestamp (as a number of seconds since the epoch) denoting a time before
|
33 | * which this token should be rejected by the server.
|
34 | * c) "admin" -- Set to true to bypass all security rules (use this for your trusted servers).
|
35 | * d) "debug" -- Set to true to enable debug mode (so you can see the results of Rules API operations)
|
36 | * e) "simulate" -- (internal-only for now) Set to true to neuter all API operations (listens / puts
|
37 | * will run security rules but not actually write or return data)
|
38 | * f) "iat" -- (Number) (internal-only, for testing) Set the issued at time for the generated token
|
39 | * @return {String} The authentication token
|
40 | */
|
41 | createToken(data: any, options?: TokenOptions): string;
|
42 | }
|
43 |
|
44 | declare module 'firebase-token-generator' {
|
45 | export = FirebaseTokenGenerator;
|
46 | }
|