Giter VIP home page Giter VIP logo

js-sdk's Introduction

JavaScript and Node.js SDK for OpenFGA

npm Release License FOSSA Status Join our community Twitter

This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper around the OpenFGA API definition, and includes TS typings.

Table of Contents

About

OpenFGA is an open source Fine-Grained Authorization solution inspired by Google's Zanzibar paper. It was created by the FGA team at Auth0 based on Auth0 Fine-Grained Authorization (FGA), available under a permissive license (Apache-2) and welcomes community contributions.

OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale.

Resources

Installation

Using npm:

npm install @openfga/sdk

Using yarn:

yarn add @openfga/sdk

Getting Started

Initializing the API Client

Learn how to initialize your SDK

We strongly recommend you initialize the OpenFgaClient only once and then re-use it throughout your app, otherwise you will incur the cost of having to re-initialize multiple times or at every request, the cost of reduced connection pooling and re-use, and would be particularly costly in the client credentials flow, as that flow will be preformed on every request.

The OpenFgaClient will by default retry API requests up to 15 times on 429 and 5xx errors.

No Credentials

const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
  apiUrl: process.env.FGA_API_URL, // required
  storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
  authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
});

API Token

const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
  apiUrl: process.env.FGA_API_URL, // required
  storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
  authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
  credentials: {
    method: CredentialsMethod.ApiToken,
    config: {
      token: process.env.FGA_API_TOKEN, // will be passed as the "Authorization: Bearer ${ApiToken}" request header
    }
  }
});

Client Credentials

const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
  apiUrl: process.env.FGA_API_URL, // required
  storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
  authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
  credentials: {
    method: CredentialsMethod.ClientCredentials,
    config: {
      apiTokenIssuer: process.env.FGA_API_TOKEN_ISSUER,
      apiAudience: process.env.FGA_API_AUDIENCE,
      clientId: process.env.FGA_CLIENT_ID,
      clientSecret: process.env.FGA_CLIENT_SECRET,
    }
  }
});

Get your Store ID

You need your store id to call the OpenFGA API (unless it is to call the CreateStore or ListStores methods).

If your server is configured with authentication enabled, you also need to have your credentials ready.

Calling the API

Note regarding casing in the OpenFgaClient: All input parameters are in camelCase, all response parameters will match the API and are in snake_case.

Note: The Client interface might see several changes over the next few months as we get more feedback before it stabilizes.

Stores

List Stores

Get a paginated list of stores.

API Documentation

const options = { pageSize: 10, continuationToken: "..." };

const { stores } = await fgaClient.listStores(options);

// stores = [{ "id": "01FQH7V8BEG3GPQW93KTRFR8JB", "name": "FGA Demo Store", "created_at": "2022-01-01T00:00:00.000Z", "updated_at": "2022-01-01T00:00:00.000Z" }]
Create Store

Initialize a store.

API Documentation

const { id: storeId } = await fgaClient.createStore({
  name: "FGA Demo Store",
});

// storeId = "01FQH7V8BEG3GPQW93KTRFR8JB"
Get Store

Get information about the current store.

API Documentation

const store = await fgaClient.getStore();

// store = { "id": "01FQH7V8BEG3GPQW93KTRFR8JB", "name": "FGA Demo Store", "created_at": "2022-01-01T00:00:00.000Z", "updated_at": "2022-01-01T00:00:00.000Z" }
Delete Store

Delete a store.

API Documentation

await fgaClient.deleteStore();

Authorization Models

Read Authorization Models

Read all authorization models in the store.

API Documentation

Requires a client initialized with a storeId

const options = { pageSize: 10, continuationToken: "..." };

const { authorization_models: authorizationModels } = await fgaClient.readAuthorizationModels(options);

/*
authorizationModels = [
 { id: "01GXSA8YR785C4FYS3C0RTG7B1", schema_version: "1.1", type_definitions: [...] },
 { id: "01GXSBM5PVYHCJNRNKXMB4QZTW", schema_version: "1.1", type_definitions: [...] }];
*/
Write Authorization Model

Create a new authorization model.

API Documentation

Note: To learn how to build your authorization model, check the Docs at https://openfga.dev/docs.

Learn more about the OpenFGA configuration language.

You can use the OpenFGA Syntax Transformer to convert between the friendly DSL and the JSON authorization model.

const { authorization_model_id: id } = await fgaClient.writeAuthorizationModel({
  schema_version: "1.1",
  type_definitions: [{
      type: "user",
    }, {
    type: "document",
    relations: {
      "writer": { "this": {} },
      "viewer": {
        "union": {
          "child": [
            { "this": {} },
            { "computedUserset": {
               "object": "",
              "relation": "writer" }
            }
          ]
        }
      }
    } }],
});

// id = "01GXSA8YR785C4FYS3C0RTG7B1"
Read a Single Authorization Model

Read a particular authorization model.

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const { authorization_model: authorizationModel } = await fgaClient.readAuthorizationModel(options);

// authorizationModel = { id: "01GXSA8YR785C4FYS3C0RTG7B1", schema_version: "1.1", type_definitions: [...] }
Read the Latest Authorization Model

Reads the latest authorization model (note: this ignores the model id in configuration).

API Documentation

const { authorization_model: authorizationModel } = await fgaClient.readLatestAuthorizationModel();

// authorizationModel = { id: "01GXSA8YR785C4FYS3C0RTG7B1", schema_version: "1.1", type_definitions: [...] }

Relationship Tuples

Read Relationship Tuple Changes (Watch)

Reads the list of historical relationship tuple writes and deletes.

API Documentation

const type = 'document';
const options = {
  pageSize: 25,
  continuationToken: 'eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==',
};

const response = await fgaClient.readChanges({ type }, options);

// response.continuation_token = ...
// response.changes = [
//   { tuple_key: { user, relation, object }, operation: "writer", timestamp: ... },
//   { tuple_key: { user, relation, object }, operation: "viewer", timestamp: ... }
// ]
Read Relationship Tuples

Reads the relationship tuples stored in the database. It does not evaluate nor exclude invalid tuples according to the authorization model.

API Documentation

// Find if a relationship tuple stating that a certain user is a viewer of a certain document
const body = {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
};

// Find all relationship tuples where a certain user has any relation to a certain document
const body = {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  object: "document:roadmap",
};

// Find all relationship tuples where a certain user is a viewer of any document
const body = {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:",
};

// Find all relationship tuples where a certain user has any relation with any document
const body = {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  object: "document:",
};

// Find all relationship tuples where any user has any relation with a particular document
const body = {
  object: "document:roadmap",
};

// Read all stored relationship tuples
const body = {};

const { tuples } = await fgaClient.read(body);

// In all the above situations, the response will be of the form:
// tuples = [{ key: { user, relation, object }, timestamp: ... }]
Write (Create and Delete) Relationship Tuples

Create and/or delete relationship tuples to update the system state.

API Documentation

Transaction mode (default)

By default, write runs in a transaction mode where any invalid operation (deleting a non-existing tuple, creating an existing tuple, one of the tuples was invalid) or a server error will fail the entire operation.

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

await fgaClient.write({
  writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }],
  deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }],
}, options);

// Convenience functions are available
await fgaClient.writeTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }], options);
await fgaClient.deleteTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }], options);

// if any error is encountered in the transaction mode, an error will be thrown
Non-transaction mode

The SDK will split the writes into separate requests and send them in parallel chunks (default = 1 item per chunk, each chunk is a transaction).

// if you'd like to disable the transaction mode for writes (requests will be sent in parallel writes)
options.transaction = {
  disable: true,
  maxPerChunk: 1, // defaults to 1 - each chunk is a transaction (even in non-transaction mode)
  maxParallelRequests: 10, // max requests to issue in parallel
};

const response = await fgaClient.write({
  writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }],
  deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }],
}, options);

/*
response = {
  writes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap", status: "success" } }],
  deletes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap", status: "failure", err: <FgaError ...>  } }],
};
*/

Relationship Queries

Check

Check if a user has a particular relation with an object.

API Documentation

const options = {
  // if you'd like to override the authorization model id for this request
  authorizationModelId: "01GXSA8YR785C4FYS3C0RTG7B1",
};

const result = await fgaClient.check({
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
}, options);

// result = { allowed: true }
Batch Check

Run a set of checks. Batch Check will return allowed: false if it encounters an error, and will return the error in the body. If 429s or 5xxs are encountered, the underlying check will retry up to 15 times before giving up.

const options = {
  // if you'd like to override the authorization model id for this request
  authorizationModelId: "01GXSA8YR785C4FYS3C0RTG7B1",
}
const { responses } = await fgaClient.batchCheck([{
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:budget",
}, {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "member",
  object: "document:budget",
}, {
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
  contextual_tuples: [{
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "writer",
    object: "document:roadmap"
  }],
}], options);

/*
responses = [{
  allowed: false,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "viewer",
    object: "document:budget",
  }
}, {
  allowed: false,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "member",
    object: "document:budget",
  },
  err: <FgaError ...>
}, {
  allowed: true,
  _request: {
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "viewer",
    object: "document:roadmap",
    contextual_tuples: [{
      user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      relation: "writer",
      object: "document:roadmap"
    }],
  }},
]
*/

Expand

Expands the relationships in userset tree format.

API Documentation

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const { tree } = await fgaClient.expand({
  relation: "viewer",
  object: "document:roadmap",
}, options);

// tree  = { root: { name: "document:roadmap#viewer", leaf: { users: { users: ["user:81684243-9356-4421-8fbf-a4f8d36aa31b", "user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"] } } } }
List Objects

List the objects of a particular type that the user has a certain relation to.

API Documentation

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const response = await fgaClient.listObjects({
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  type: "document",
  contextual_tuples: [{
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "writer",
    object: "document:budget"
  }],
}, options);

// response.objects = ["document:roadmap"]
List Relations

List the relations a user has with an object. This wraps around BatchCheck to allow checking multiple relationships at once.

Note: Any error encountered when checking any relation will be treated as allowed: false;

const options = {};

// To override the authorization model id for this request
options.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw";

const response = await fgaClient.listRelations({
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  object: "document:roadmap",
  relations: ["can_view", "can_edit", "can_delete"],
  contextual_tuples: [{
    user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    relation: "writer",
    object: "document:roadmap"
  }],
}, options);

// response.relations = ["can_view", "can_edit"]
List Users

List the users who have a certain relation to a particular type.

API Documentation

const options = {};

// To override the authorization model id for this request
options.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw";

// Only a single filter is allowed for the time being
const userFilters = [{type: "user"}];
// user filters can also be of the form
// const userFilters = [{type: "team", relation: "member"}];

const response = await fgaClient.listUsers({
  object: {
    type: "document",
    id: "roadmap"
  },
  relation: "can_read",
  user_filters: userFilters,
  context: {
    "view_count": 100
  },
  contextualTuples:
    [{
      user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
      relation: "editor",
      object: "folder:product"
    }, {
      user: "folder:product",
      relation: "parent",
      object: "document:roadmap"
    }]
}, options);

// response.users = [{object: {type: "user", id: "81684243-9356-4421-8fbf-a4f8d36aa31b"}}, {userset: { type: "user" }}, ...]
// response.excluded_users = [ {object: {type: "user", id: "4a455e27-d15a-4434-82e0-136f9c2aa4cf"}}, ... ]

Assertions

Read Assertions

Read assertions for a particular authorization model.

API Documentation

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const response = await fgaClient.readAssertions(options);

/*
response.assertions = [{
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
  expectation: true,
}];
*/
Write Assertions

Update the assertions for a particular authorization model.

API Documentation

const options = {};

// To override the authorization model id for this request
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const response = await fgaClient.writeAssertions([{
  user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
  relation: "viewer",
  object: "document:roadmap",
  expectation: true,
}], options);

Retries

If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to 15 times with a minimum wait time of 100 milliseconds between each attempt.

To customize this behavior, create an object with maxRetry and minWaitInMs properties. maxRetry determines the maximum number of retries (up to 15), while minWaitInMs sets the minimum wait time between retries in milliseconds.

Apply your custom retry values by setting to retryParams on the to the configuration object passed to the OpenFgaClient call.

const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
  apiUrl: process.env.FGA_API_URL, // required
  storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
  authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
  retryParams: {
    maxRetry: 3, // retry up to 3 times on API requests
    minWaitInMs: 250 // wait a minimum of 250 milliseconds between requests
  }
});

API Endpoints

Method HTTP request Description
ListStores GET /stores List all stores
CreateStore POST /stores Create a store
GetStore GET /stores/{store_id} Get a store
DeleteStore DELETE /stores/{store_id} Delete a store
ReadAuthorizationModels GET /stores/{store_id}/authorization-models Return all the authorization models for a particular store
WriteAuthorizationModel POST /stores/{store_id}/authorization-models Create a new authorization model
ReadAuthorizationModel GET /stores/{store_id}/authorization-models/{id} Return a particular version of an authorization model
ReadChanges GET /stores/{store_id}/changes Return a list of all the tuple changes
Read POST /stores/{store_id}/read Get tuples from the store that matches a query, without following userset rewrite rules
Write POST /stores/{store_id}/write Add or delete tuples from the store
Check POST /stores/{store_id}/check Check whether a user is authorized to access an object
Expand POST /stores/{store_id}/expand Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship
ListObjects POST /stores/{store_id}/list-objects [EXPERIMENTAL] Get all objects of the given type that the user has a relation with
ReadAssertions GET /stores/{store_id}/assertions/{authorization_model_id} Read assertions for an authorization model ID
WriteAssertions PUT /stores/{store_id}/assertions/{authorization_model_id} Upsert assertions for an authorization model ID

Models

Models

Contributing

Issues

If you have found a bug or if you have a feature request, please report them on the sdk-generator repo issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.

Pull Requests

All changes made to this repo will be overwritten on the next generation, so we kindly ask that you send all pull requests related to the SDKs to the sdk-generator repo instead.

Author

OpenFGA

License

This project is licensed under the Apache-2.0 license. See the LICENSE file for more info.

The code in this repo was auto generated by OpenAPI Generator from a template based on the typescript-axios template and go template, licensed under the Apache License 2.0.

js-sdk's People

Contributors

aaguiarz avatar adriantam avatar dependabot[bot] avatar evansims avatar ewanharris avatar klausvii avatar rhamzeh avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-sdk's Issues

Support for Cloudflare Workers/Vercel Edge Runtime

Deploying Functions on the Cloudflare Workers/Vercel Edge Runtime to interact with the FGA SDK

Currently the SDK depends on the Node.js http module. This prevents us from leveraging the SDK in these newer javascript runtimes.

Describe the ideal solution

A clear and concise description of what you want to happen.

Alternatives and current workarounds

We would have to manually craft the requests to the FGA APIs to interact with the service.

Additional context

When calling an SDK function such as:

const result = await fgaClient.listObjects({ user, relation, type, });

we receive the following exception being thrown:

[Error: The edge runtime does not support Node.js 'http' module.

Including js-sdk version in request headers

👋 hello! I would like to request that the OpenFGA js-sdk version is included in the request headers. This will allow us to properly route the requests to the right OpenFGA server based on the sdk-version (if there are breaking changes) using load balancers.

Support for migrations

Checklist

Describe the problem you'd like to have solved

I currently have the problem that an authorization model have to be migrated after a software rollout. The following guide explains how to do this manually:

https://openfga.dev/docs/modeling/migrating/migrating-relations

These changes are cumbersome and error-prone.

Describe the ideal solution

I would like to use an integrated functionality, such as a dedicated CLI application, to perform automated migrations.

As this is a known problem in the database world, I would like to use a similar solution. As an example I would like to mention the migrations of sequelize:

https://sequelize.org/v5/manual/migrations

Alternatives and current workarounds

No response

References

No response

Additional context

No response

Credentials expiry is broken

Description

When using ClientCredentials for auth, the token is not cached properly because the expires_in amount is treated as milliseconds instead of seconds

Version of SDK

0.2.6

Version of OpenFGA (if known)

N/A

Reproduction

Run the client with ClientCredentials enabled and observe how many requests are made to your auth token service.

The issue is (here)[https://github.com/openfga/js-sdk/blob/main/credentials/credentials.ts#L155]

this.accessTokenExpiryDate = new Date(Date.now() + response.data.expires_in);

Date.now() returns the time in milliseconds, expires_in is in seconds -> the expiry gets set 1000 times too soon!

Expected behavior

I do not DDOS my auth service because of openFGA

Additional context

Add any other context about the problem here.

HTTP connection pooling

Hey there,
methods like batchCheck and listRelations can potentially issue a lot of individual requests. We noticed some rather severe performance issues which we narrowed down to each of those requests doing a new DNS lookup and TCP connection setup.

Once we enabled connection re-use/pooling/keep alive (whatever you want to call it) we saw big improvements.

http.globalAgent = new http.Agent({ keepAlive: true });
https.globalAgent = new https.Agent({ keepAlive: true });

I think this should either be the default for the SDK's axios instance, a parameter for the OpenFgaClient or the very least mentioned in the docs.

What do you think?

Replace axios

Summary

axios v1 has brought a few breaking changes, so now's the time to reconsider whether it still is the best solution we have.

Motivation(s)

  • http2/http3 support
  • streaming support
  • reduce dependencies

Downsides

  • Breaking change - axios is very tied to our responses, anyone who currently depends on them will have some work to do before they can upgrade

Alternatives to consider

  • axios: it's working, stick to it, but update to a v1.x.x+ version (no http2 support yet)
  • fetch: built into recent browsers and node 18+
  • gaxios: close to the axios interface, supports http2, no browser support
  • got: Seems to satisfy a lot constraints. No browser support and has a lot of dependencies
  • ky: tiny, no dependencies, supports deno
  • undici: from the core node devs
  • ...

Criteria for success

  • Compatible license (required)
  • Node.js 18+ support (required)
  • Brings in a minimal set of dependencies (required)
  • Promise based (required)
  • Preferably not another dependency
  • Streaming support: allows us to expose the streaming ListObjects
  • http2/http3 support: reduces request overhead
  • Browser support: needed for the Playground
  • Deno support (#17)
  • Error handling and automated retries (bonus - lets us drop our own implementation)
  • Credential flow support (bonus - lets us drop our own implementation)
  • Built-in caching support (bonus)

Support for Deno

Currently, the axios dependency causes issues when attempting to run the SDK from Deno

Deno 1.41.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import {OpenFgaClient} from "https://dev.jspm.io/@openfga/sdk"
undefined
> const fgaClient = new OpenFgaClient({ apiUrl: "https://api.playground.fga.dev" })
undefined
> fgaClient.createStore({ name: "test-deno-store" })
Promise {
  <rejected> AxiosError: There is no suitable adapter to dispatch the request since :
- adapter xhr is not supported by the environment
- adapter http is not available in the build
    at Object.getAdapter (https://dev.jspm.io/npm:[email protected]!cjs:2123:13)
    at Axios.dispatchRequest (https://dev.jspm.io/npm:[email protected]!cjs:2162:28)
    at Axios.request (https://dev.jspm.io/npm:[email protected]!cjs:2470:33)
    at wrap (https://dev.jspm.io/npm:[email protected]!cjs:8:15)
    at https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:675:24
    at Generator.next (<anonymous>)
    at https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:572:69
    at new Promise (<anonymous>)
    at __awaiter (https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:554:12)
    at attemptHttpRequest (https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:670:12) {
    name: "FgaApiError",
    statusCode: undefined,
    statusText: undefined,
    requestData: undefined,
    requestURL: undefined,
    method: undefined,
    storeId: "",
    endpointCategory: "",
    apiErrorMessage: undefined,
    responseData: undefined,
    responseHeader: undefined,
    requestId: undefined
  }
}
Uncaught AxiosError: There is no suitable adapter to dispatch the request since :
- adapter xhr is not supported by the environment
- adapter http is not available in the build
    at Object.getAdapter (https://dev.jspm.io/npm:[email protected]!cjs:2123:13)
    at Axios.dispatchRequest (https://dev.jspm.io/npm:[email protected]!cjs:2162:28)
    at Axios.request (https://dev.jspm.io/npm:[email protected]!cjs:2470:33)
    at wrap (https://dev.jspm.io/npm:[email protected]!cjs:8:15)
    at https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:675:24
    at Generator.next (<anonymous>)
    at https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:572:69
    at new Promise (<anonymous>)
    at __awaiter (https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:554:12)
    at attemptHttpRequest (https://dev.jspm.io/npm:@openfga/[email protected]/_/F1S5_afg.js:670:12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.