0.0.20241021 • Published 9 months ago

@maxim_mazurok/gapi.client.firebaserules-v1 v0.0.20241021

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

TypeScript typings for Firebase Rules API v1

Creates and manages rules that determine when a Firebase Rules-enabled service should permit a request. For detailed description please check documentation.

Installing

Install typings for Firebase Rules API:

npm install @types/gapi.client.firebaserules-v1 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://firebaserules.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.firebaserules
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('firebaserules', 'v1', () => {
  // now we can use:
  // gapi.client.firebaserules
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
    'https://www.googleapis.com/auth/cloud-platform',

    // View and administer all your Firebase data and settings
    'https://www.googleapis.com/auth/firebase',

    // View all your Firebase data and settings
    'https://www.googleapis.com/auth/firebase.readonly',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Firebase Rules API resources:

/*
Test `Source` for syntactic and semantic correctness. Issues present, if any, will be returned to the caller with a description, severity, and source location. The test method may be executed with `Source` or a `Ruleset` name. Passing `Source` is useful for unit testing new rules. Passing a `Ruleset` name is useful for regression testing an existing rule. The following is an example of `Source` that permits users to upload images to a bucket bearing their user id and matching the correct metadata: _*Example*_ // Users are allowed to subscribe and unsubscribe to the blog. service firebase.storage { match /users/{userId}/images/{imageName} { allow write: if userId == request.auth.uid && (imageName.matches('*.png$') || imageName.matches('*.jpg$')) && resource.mimeType.matches('^image/') } }
*/
await gapi.client.firebaserules.projects.test({name: 'name'});
0.0.20241021

9 months ago

0.0.20241014

9 months ago

0.0.20241008

10 months ago

0.0.20240923

10 months ago

0.0.20240919

10 months ago

0.0.20240909

11 months ago

0.0.20240904

11 months ago

0.0.20240827

11 months ago

0.0.20240807

12 months ago

0.0.20240701

1 year ago

0.0.20240603

1 year ago

0.0.20240802

12 months ago

0.0.20240528

1 year ago

0.0.20240623

1 year ago

0.0.20240819

11 months ago

0.0.20240715

1 year ago

0.0.20240610

1 year ago

0.0.20240513

1 year ago

0.0.20240429

1 year ago

0.0.20240415

1 year ago

0.0.20240410

1 year ago

0.0.20240311

1 year ago

0.0.20240214

1 year ago

0.0.20240129

1 year ago

0.0.20240116

2 years ago

0.0.20231226

2 years ago

0.0.20231120

2 years ago

0.0.20230731

2 years ago

0.0.20230710

2 years ago

0.0.20230827

2 years ago

0.0.20230921

2 years ago

0.0.20230626

2 years ago

0.0.20231023

2 years ago

0.0.20230608

2 years ago

0.0.20230507

2 years ago

0.0.20230421

2 years ago

0.0.20230304

2 years ago

0.0.20230329

2 years ago

0.0.20230221

2 years ago

0.0.20230130

2 years ago

0.0.20230111

3 years ago

0.0.20221228

3 years ago

0.0.20221128

3 years ago

0.0.20220921

3 years ago

0.0.20221025

3 years ago

0.0.20221013

3 years ago

0.0.20220825

3 years ago

0.0.20220904

3 years ago

0.0.20220810

3 years ago

0.0.20220712

3 years ago