@cs3org/node-cs3apis

0.0.53 • Public • Published

CS3APIS for Node.js

Join the conversation Latest Version Drone CI Build Status License

API definitions can be found at https://github.com/cs3org/cs3apis

Install with npm

npm i @cs3org/node-cs3apis

Example usage

const grpc = require('grpc');
const { GatewayAPIClient } = require('@cs3org/node-cs3apis/cs3/gateway/v1beta1/gateway_api_grpc_pb');
const { AuthenticateRequest } = require('@cs3org/node-cs3apis/cs3/gateway/v1beta1/gateway_api_pb');

const TARGET = process.env.TARGET || 'localhost:19000';

const client = new GatewayAPIClient(TARGET, grpc.credentials.createInsecure());

function authenticate(authType, clientId, clientSecret) {
  const req = new AuthenticateRequest();
  req.setType(authType);
  req.setClientId(clientId);
  req.setClientSecret(clientSecret);
  return new Promise((resolve, reject) => {
    client.authenticate(req, (err, response) => {
      if (err) {
        reject(err);
      } else {
        resolve(response);
      }
    });
  });
}

async function example() {
  try {
    const res = await authenticate('basic', 'einstein', 'relativity');
    // See:
    // * AuthenticateResponse https://github.com/cs3org/cs3apis/blob/a86e5cb6ac360/cs3/gateway/v1beta1/gateway_api.proto#L415
    // * User https://github.com/cs3org/cs3apis/blob/a86e5cb6ac360/cs3/identity/user/v1beta1/resources.proto#L53
    console.log(res.getUser().getDisplayName());
  } catch (e) {
    console.error(e);
  }
}

// ...
example();

Package Sidebar

Install

npm i @cs3org/node-cs3apis

Weekly Downloads

1

Version

0.0.53

License

Apache-2.0

Unpacked Size

4.14 MB

Total Files

154

Last publish

Collaborators

  • glopresti
  • labkode
  • alfageme
  • cs3org-bot