1 | # Installation
|
2 | > `npm install --save @types/firebase-token-generator`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for firebase-token-generator (https://github.com/firebase/firebase-token-generator-node).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/firebase-token-generator.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/firebase-token-generator/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for firebase-token-generator v2.0.0
|
12 | // Project: https://github.com/firebase/firebase-token-generator-node
|
13 | // Definitions by: Hans Van den Keybus <https://github.com/dotdotcommadot>
|
14 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
15 |
|
16 | interface TokenOptions {
|
17 | expires?: number | undefined;
|
18 | notBefore?: number | undefined;
|
19 | admin?: boolean | undefined;
|
20 | debug?: boolean | undefined;
|
21 | simulate?: boolean | undefined;
|
22 | iat?: number | undefined;
|
23 | }
|
24 |
|
25 | declare class FirebaseTokenGenerator {
|
26 |
|
27 | /**
|
28 | * Builds a new object that can generate Firebase authentication tokens.
|
29 | * @constructor
|
30 | * @param { String } secret The secret for the Firebase being used (get yours from the Firebase Admin Console).
|
31 | */
|
32 | constructor(secret: string);
|
33 |
|
34 | /**
|
35 | * Creates a token that authenticates a client with arbitrary data "data", and the specified options.
|
36 | *
|
37 | * @param { any } data JSON data that will be passed to the Firebase Rules API once a client authenticates. Unless the
|
38 | * "admin" flag is set, it must contain a "uid" key, and if it does it must be a string of length
|
39 | * 256 or less.
|
40 | * @param { TokenOptions } options The developer-supplied options for this token. Supported options are:
|
41 | * a) "expires" -- A timestamp (as a number of seconds since the epoch) denoting a time after which
|
42 | * this token should no longer be valid.
|
43 | * b) "notBefore" -- A timestamp (as a number of seconds since the epoch) denoting a time before
|
44 | * which this token should be rejected by the server.
|
45 | * c) "admin" -- Set to true to bypass all security rules (use this for your trusted servers).
|
46 | * d) "debug" -- Set to true to enable debug mode (so you can see the results of Rules API operations)
|
47 | * e) "simulate" -- (internal-only for now) Set to true to neuter all API operations (listens / puts
|
48 | * will run security rules but not actually write or return data)
|
49 | * f) "iat" -- (Number) (internal-only, for testing) Set the issued at time for the generated token
|
50 | * @return {String} The authentication token
|
51 | */
|
52 | createToken(data: any, options?: TokenOptions): string;
|
53 | }
|
54 |
|
55 | declare module 'firebase-token-generator' {
|
56 | export = FirebaseTokenGenerator;
|
57 | }
|
58 |
|
59 | ````
|
60 |
|
61 | ### Additional Details
|
62 | * Last updated: Thu, 08 Jul 2021 12:01:38 GMT
|
63 | * Dependencies: none
|
64 | * Global values: `FirebaseTokenGenerator`
|
65 |
|
66 | # Credits
|
67 | These definitions were written by [Hans Van den Keybus](https://github.com/dotdotcommadot).
|
68 |
|
\ | No newline at end of file |