Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@itarius-ug/docuware-api-client

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@itarius-ug/docuware-api-client - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

6

dist/contracts.d.ts

@@ -103,2 +103,8 @@ export interface Link {

}
export interface TokenResponse {
access_token: string;
expires_in: number;
token_type: string;
scope: string;
}
export interface QueryResponse extends HasLinks {

@@ -105,0 +111,0 @@ Count: {

2

dist/docuware.d.ts

@@ -5,3 +5,3 @@ /// <reference types="node" resolution-mode="require"/>

#private;
constructor(configuration: DocuWareConfiguration);
constructor(configuration: DocuWareConfiguration, userAgent?: string);
getIdentityServiceUrl(): Promise<string>;

@@ -8,0 +8,0 @@ getOpenIdConfiguration(): Promise<any>;

@@ -21,9 +21,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
var _DocuWare_instances, _DocuWare_username, _DocuWare_password, _DocuWare_impersonateName, _DocuWare_baseUrl, _DocuWare_token, _DocuWare_send, _DocuWare_get, _DocuWare_post, _DocuWare_put;
var _DocuWare_instances, _DocuWare_username, _DocuWare_password, _DocuWare_impersonateName, _DocuWare_baseUrl, _DocuWare_token, _DocuWare_expiration, _DocuWare_userAgent, _DocuWare_send, _DocuWare_get, _DocuWare_post, _DocuWare_put, _DocuWare_isExpired;
import { readFile } from "fs/promises";
import got from "got";
import ky from "ky";
import { basename } from "path";
import { transformData } from "./utils.js";
export class DocuWare {
constructor(configuration) {
constructor(configuration, userAgent) {
_DocuWare_instances.add(this);

@@ -34,3 +34,5 @@ _DocuWare_username.set(this, void 0);

_DocuWare_baseUrl.set(this, void 0);
_DocuWare_token.set(this, void 0);
_DocuWare_token.set(this, null);
_DocuWare_expiration.set(this, null);
_DocuWare_userAgent.set(this, "itarius/docuware-api-client");
__classPrivateFieldSet(this, _DocuWare_baseUrl, `${configuration.baseUrl}/DocuWare/Platform`, "f");

@@ -40,3 +42,5 @@ __classPrivateFieldSet(this, _DocuWare_username, configuration.username, "f");

__classPrivateFieldSet(this, _DocuWare_impersonateName, configuration.impersonateName, "f");
__classPrivateFieldSet(this, _DocuWare_token, null, "f");
if (userAgent) {
__classPrivateFieldSet(this, _DocuWare_userAgent, `itarius/docuware-api-client - ${userAgent}`, "f");
}
}

@@ -62,15 +66,15 @@ getIdentityServiceUrl() {

const configuration = yield this.getOpenIdConfiguration();
const options = {
form: {
grant_type: "trusted",
scope: "docuware.platform",
client_id: "docuware.platform.net.client",
username: __classPrivateFieldGet(this, _DocuWare_username, "f"),
password: __classPrivateFieldGet(this, _DocuWare_password, "f"),
impersonateName: __classPrivateFieldGet(this, _DocuWare_impersonateName, "f"),
},
};
const searchParams = new URLSearchParams();
searchParams.set("grant_type", "trusted");
searchParams.set("scope", "docuware.platform");
searchParams.set("client_id", "docuware.platform.net.client");
searchParams.set("username", __classPrivateFieldGet(this, _DocuWare_username, "f"));
searchParams.set("password", __classPrivateFieldGet(this, _DocuWare_password, "f"));
if (__classPrivateFieldGet(this, _DocuWare_impersonateName, "f")) {
searchParams.set("impersonateName", __classPrivateFieldGet(this, _DocuWare_impersonateName, "f"));
}
try {
const response = yield __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_post).call(this, configuration.token_endpoint, options, false);
const response = yield __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_post).call(this, configuration.token_endpoint, { body: searchParams }, false);
__classPrivateFieldSet(this, _DocuWare_token, response.access_token, "f");
__classPrivateFieldSet(this, _DocuWare_expiration, Math.floor(Date.now() / 1000) + response.expires_in, "f");
}

@@ -85,11 +89,9 @@ catch (error) {

const configuration = yield this.getOpenIdConfiguration();
const options = {
form: {
token: __classPrivateFieldGet(this, _DocuWare_token, "f"),
token_type_hint: "access_token",
},
};
const searchParams = new URLSearchParams();
searchParams.set("token", __classPrivateFieldGet(this, _DocuWare_token, "f"));
searchParams.set("token_type_hint", "access_token");
try {
yield __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_post).call(this, configuration.revocation_endpoint, options);
yield __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_post).call(this, configuration.revocation_endpoint, { body: searchParams });
__classPrivateFieldSet(this, _DocuWare_token, null, "f");
__classPrivateFieldSet(this, _DocuWare_expiration, null, "f");
}

@@ -211,4 +213,3 @@ catch (error) {

}
_DocuWare_username = new WeakMap(), _DocuWare_password = new WeakMap(), _DocuWare_impersonateName = new WeakMap(), _DocuWare_baseUrl = new WeakMap(), _DocuWare_token = new WeakMap(), _DocuWare_instances = new WeakSet(), _DocuWare_send = function _DocuWare_send(options, requireAuthentication = true) {
var _a;
_DocuWare_username = new WeakMap(), _DocuWare_password = new WeakMap(), _DocuWare_impersonateName = new WeakMap(), _DocuWare_baseUrl = new WeakMap(), _DocuWare_token = new WeakMap(), _DocuWare_expiration = new WeakMap(), _DocuWare_userAgent = new WeakMap(), _DocuWare_instances = new WeakSet(), _DocuWare_send = function _DocuWare_send(url, options, requireAuthentication = true) {
return __awaiter(this, void 0, void 0, function* () {

@@ -218,9 +219,12 @@ if (requireAuthentication && !__classPrivateFieldGet(this, _DocuWare_token, "f")) {

}
const headers = Object.assign({ Accept: "application/json" }, options.headers);
const headers = Object.assign({ "User-Agent": __classPrivateFieldGet(this, _DocuWare_userAgent, "f"), Accept: "application/json" }, options.headers);
if (requireAuthentication) {
if (__classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_isExpired).call(this)) {
yield this.authenticate();
}
headers.Authorization = `Bearer ${__classPrivateFieldGet(this, _DocuWare_token, "f")}`;
}
try {
const response = yield got(Object.assign(Object.assign({}, options), { headers }));
return JSON.parse((_a = response.body) !== null && _a !== void 0 ? _a : {});
const response = yield ky(url, Object.assign(Object.assign({}, options), { headers })).json();
return response;
}

@@ -233,12 +237,14 @@ catch (error) {

return __awaiter(this, void 0, void 0, function* () {
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, Object.assign(Object.assign({}, options), { url, method: "GET" }), requireAuthentication);
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, url, Object.assign(Object.assign({}, options), { method: "GET" }), requireAuthentication);
});
}, _DocuWare_post = function _DocuWare_post(url, options = {}, requireAuthentication = true) {
return __awaiter(this, void 0, void 0, function* () {
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, Object.assign(Object.assign({}, options), { url, method: "POST" }), requireAuthentication);
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, url, Object.assign(Object.assign({}, options), { method: "POST" }), requireAuthentication);
});
}, _DocuWare_put = function _DocuWare_put(url, options = {}, requireAuthentication = true) {
return __awaiter(this, void 0, void 0, function* () {
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, Object.assign(Object.assign({}, options), { url, method: "PUT" }), requireAuthentication);
return __classPrivateFieldGet(this, _DocuWare_instances, "m", _DocuWare_send).call(this, url, Object.assign(Object.assign({}, options), { method: "PUT" }), requireAuthentication);
});
}, _DocuWare_isExpired = function _DocuWare_isExpired() {
return !__classPrivateFieldGet(this, _DocuWare_expiration, "f") || __classPrivateFieldGet(this, _DocuWare_expiration, "f") < Date.now() / 1000;
};
{
"name": "@itarius-ug/docuware-api-client",
"version": "2.1.1",
"version": "2.1.2",
"description": "A TypeScript wrapper for the DocuWare REST API",

@@ -26,3 +26,3 @@ "main": "dist/index.js",

"dependencies": {
"got": "^14.2.1"
"ky": "^1.2.4"
},

@@ -29,0 +29,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc