2.0.5 • Published 7 months ago

task.json-client v2.0.5

Weekly downloads
8
License
AGPL-3.0
Repository
-
Last release
7 months ago

task.json-client

npm version license

TypeScript library to interact with task.json-server.

Installation

npm i task.json-client

Usage

import { setupClient } from "task.json-client";

async function main() {
  const client = await setupClient({
    server: "http://localhost:3000"
  });
  await client.login("admin");
  const tj1 = await client.download();
  const tj2 = await client.sync(tj1);
  await client.upload(tj2);
  await client.logout();
}

For a self-signed certificate, the browser will handle it directly. If used in Node.js, verify and ca flags can be used:

// Use verify flag
import { setupClient } from "task.json-client";

async function main() {
  const client = await setupClient({
    server: "https://localhost:3000",
    // Do not verify the certificate
    // (less secure than trusting the certificate)
    verify: false
  });
  await client.login("admin");
}
// Use ca flag (only works in Node.js)
import { setupClient, getCertificate } from "task.json-client";

async function main() {
  const server = "https://localhost:3000";
  const cert = await getCertificate(server);
  // Verify the certificate (e.g. by fingerprint)
  // ...

  const client = await setupClient({
    server,
    // Trust this certificate
    ca: cert.toString()
  });
  await client.login("admin");
}

License

All code licensed under AGPL-3.0. Full copyright notice:

Copyright (C) 2021-2023  DCsunset

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
2.0.5

7 months ago

2.0.3

8 months ago

2.0.2

9 months ago

2.0.4

8 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago