UNPKG

2.44 kBTypeScriptView Raw
1/*! firebase-admin v10.0.0 */
2/*!
3 * Copyright 2019 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { App } from '../app';
18export interface Release {
19 readonly name: string;
20 readonly rulesetName: string;
21 readonly createTime?: string;
22 readonly updateTime?: string;
23}
24export interface RulesetContent {
25 readonly source: {
26 readonly files: Array<{
27 name: string;
28 content: string;
29 }>;
30 };
31}
32export interface RulesetResponse extends RulesetContent {
33 readonly name: string;
34 readonly createTime: string;
35}
36export interface ListRulesetsResponse {
37 readonly rulesets: Array<{
38 name: string;
39 createTime: string;
40 }>;
41 readonly nextPageToken?: string;
42}
43/**
44 * Class that facilitates sending requests to the Firebase security rules backend API.
45 *
46 * @private
47 */
48export declare class SecurityRulesApiClient {
49 private readonly app;
50 private readonly httpClient;
51 private projectIdPrefix?;
52 constructor(app: App);
53 getRuleset(name: string): Promise<RulesetResponse>;
54 createRuleset(ruleset: RulesetContent): Promise<RulesetResponse>;
55 deleteRuleset(name: string): Promise<void>;
56 listRulesets(pageSize?: number, pageToken?: string): Promise<ListRulesetsResponse>;
57 getRelease(name: string): Promise<Release>;
58 updateRelease(name: string, rulesetName: string): Promise<Release>;
59 private getUrl;
60 private getProjectIdPrefix;
61 /**
62 * Gets the specified resource from the rules API. Resource names must be the short names without project
63 * ID prefix (e.g. `rulesets/ruleset-name`).
64 *
65 * @param {string} name Full qualified name of the resource to get.
66 * @returns {Promise<T>} A promise that fulfills with the resource.
67 */
68 private getResource;
69 private getReleaseDescription;
70 private getRulesetName;
71 private sendRequest;
72 private toFirebaseError;
73}