Skip to content

Commit

Permalink
package-lock.json
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Oct 11, 2021
2 parents 42d3633 + 2981c1f commit 35fc0f6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
13 changes: 7 additions & 6 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const client = new services.GatewayAPIClient(
grpc.credentials.createInsecure()
);

let metadata = new grpc.Metadata();

async function authenticate() {
const req = new messages.AuthenticateRequest();
req.setType('basic');
Expand All @@ -37,7 +35,6 @@ async function authenticate() {

// add the token to the metadata for subsequent client calls
const token = res.getToken();
metadata.add(TOKEN_HEADER, token);
// one exception is the 'WhoAmI' method, which takes the token as a request parameter
return token;
}
Expand All @@ -55,10 +52,10 @@ async function whoAmI(token) {
console.log('DisplayName from WhoAmIResponse:', user? user.getDisplayName() : '?');
}

async function listReceivedOCMShares(token) {
async function listReceivedOCMShares(metadata) {
const req = new ListReceivedOCMSharesRequest();
// req.setToken(token);
const shares = await new Promise((resolve, reject) => client.listReceivedOCMShares(req, (err, res) => {
const shares = await new Promise((resolve, reject) => client.listReceivedOCMShares(req, metadata, (err, res) => {
if (err) {
reject(err);
}
Expand All @@ -70,7 +67,11 @@ async function listReceivedOCMShares(token) {
async function example() {
const token = await authenticate();
await whoAmI(token);
await listReceivedOCMShares(token);

const metadata = new grpc.Metadata();
metadata.add(TOKEN_HEADER, token);

await listReceivedOCMShares(metadata);
}

// ...
Expand Down
13 changes: 7 additions & 6 deletions examples/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const client = new GatewayAPIClient(
credentials.createInsecure()
);

let metadata = new Metadata();

async function authenticate() {
const req = new AuthenticateRequest();
req.setType('basic');
Expand All @@ -44,7 +42,6 @@ async function authenticate() {

// add the token to the metadata for subsequent client calls
const token = res.getToken();
metadata.add(TOKEN_HEADER, token);
// one exception is the 'WhoAmI' method, which takes the token as a request parameter
return token;
}
Expand All @@ -64,11 +61,11 @@ async function whoAmI(token: string) {
console.log('DisplayName from WhoAmIResponse:', user? user.getDisplayName() : '?');
}

async function listReceivedOCMShares() {
async function listReceivedOCMShares(metadata: Metadata) {
const req = new ListReceivedOCMSharesRequest();
// req.setToken(token);
const shares: ListReceivedOCMSharesResponse = await new Promise((resolve, reject) => {
client.listReceivedOCMShares(req, (err: ServiceError | null, res: ListReceivedOCMSharesResponse) => {
client.listReceivedOCMShares(req, metadata, (err: ServiceError | null, res: ListReceivedOCMSharesResponse) => {
if (err) {
reject(err);
}
Expand All @@ -81,7 +78,11 @@ async function listReceivedOCMShares() {
async function example() {
const token = await authenticate();
await whoAmI(token);
await listReceivedOCMShares();

const metadata = new Metadata();
metadata.add(TOKEN_HEADER, token);

await listReceivedOCMShares(metadata);
}

// ...
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cs3org/node-cs3apis",
"version": "0.0.18",
"version": "0.0.25",
"description": "Node.js bindings for the CS3APIs to connect Storage and Application Providers ",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit 35fc0f6

Please sign in to comment.