Skip to content

Commit

Permalink
Fixed TypeScript definitions for optional fields
Browse files Browse the repository at this point in the history
Fixed bogus node-fetch dependency in rollup's config
  • Loading branch information
verifalia committed Mar 2, 2023
1 parent ec3cf54 commit a6ba894
Show file tree
Hide file tree
Showing 30 changed files with 153 additions and 51 deletions.
2 changes: 1 addition & 1 deletion browser/amd/verifalia.js
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ define('verifalia', ['exports', 'tslib'], function (exports, tslib) { 'use stric
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down
2 changes: 1 addition & 1 deletion browser/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@ var MultiplexedRestClient = /** @class */ (function () {
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down
10 changes: 5 additions & 5 deletions browser/esm/VerifaliaRestClientConfiguration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export interface VerifaliaRestClientConfiguration {
* (formerly known as sub-accounts) with just the required permissions, for improved security.
* To create a new user or manage existing ones, please visit https://verifalia.com/client-area#/users
*/
password: string;
password?: string;
/**
* The base API endpoints for the Verifalia service: do NOT set these unless you are instructed
* to do so by the Verifalia support team.
*/
baseUris: string[];
baseUris?: string[];
/**
* This field is used only for client-certificate authentication.
* Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should
Expand All @@ -61,7 +61,7 @@ export interface VerifaliaRestClientConfiguration {
* same order as their private keys in key. If the intermediate certificates are not provided, the peer
* will not be able to validate the certificate, and the handshake will fail.
*/
cert: string | Buffer | (string | Buffer)[];
cert?: string | Buffer | (string | Buffer)[];
/**
* This field is used only for client-certificate authentication.
* Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will
Expand All @@ -70,11 +70,11 @@ export interface VerifaliaRestClientConfiguration {
* The object form can only occur in an array. object.passphrase is optional. Encrypted keys will be
* decrypted with object.passphrase if provided, or options.passphrase if it is not.
*/
key: string | Buffer | (Buffer | KeyObject)[];
key?: string | Buffer | (Buffer | KeyObject)[];
/**
* This field is used only for client-certificate authentication.
* Shared passphrase used for a single private key and/or a PFX.
*/
passphrase: string;
passphrase?: string;
}
//# sourceMappingURL=VerifaliaRestClientConfiguration.d.ts.map
2 changes: 1 addition & 1 deletion browser/esm/VerifaliaRestClientConfiguration.d.ts.map

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

2 changes: 1 addition & 1 deletion browser/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ class MultiplexedRestClient {
}

// generated by genversion
const version = '3.2.1';
const version = '3.2.2';

/**
* @license
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { KeyObject } from "tls";
*/
export declare class ClientCertificateAuthenticator implements Authenticator {
private _agent;
constructor(cert: string | Buffer | (string | Buffer)[], key: string | Buffer | (Buffer | KeyObject)[], passphrase: string);
constructor(cert: string | Buffer | (string | Buffer)[], key: string | Buffer | (Buffer | KeyObject)[], passphrase?: string);
decorateRequest(restClient: MultiplexedRestClient, requestInit: NodeRequestInit | // HACK: Make the IDE's background compiler happy
RequestInit): Promise<void>;
}
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { Authenticator } from "./Authenticator";
export declare class UsernamePasswordAuthenticator implements Authenticator {
private _username;
private _password;
constructor(username: string, password: string);
constructor(username: string, password?: string);
decorateRequest(restClient: MultiplexedRestClient, requestInit: RequestInit): Promise<void>;
}
//# sourceMappingURL=UsernamePasswordAuthenticator.d.ts.map

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

2 changes: 1 addition & 1 deletion browser/esm/version.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export declare const version = "3.2.1";
export declare const version = "3.2.2";
//# sourceMappingURL=version.d.ts.map
6 changes: 5 additions & 1 deletion browser/iife/verifalia.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var Verifalia = (function (exports) {
};

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
Expand Down Expand Up @@ -92,13 +94,15 @@ var Verifalia = (function (exports) {
}
}

/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}

function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
Expand Down Expand Up @@ -1893,7 +1897,7 @@ var Verifalia = (function (exports) {
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down
6 changes: 3 additions & 3 deletions browser/iife/verifalia.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion browser/system/verifalia.js
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ System.register('verifalia', ['tslib'], function (exports) {
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down
2 changes: 1 addition & 1 deletion browser/umd/verifalia.js
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,7 @@
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down
62 changes: 55 additions & 7 deletions node/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var FormData = _interopDefault(require('form-data'));
var Stream = _interopDefault(require('stream'));
var http = _interopDefault(require('http'));
var Url = _interopDefault(require('url'));
var whatwgUrl = _interopDefault(require('whatwg-url'));
var https = require('https');
var https__default = _interopDefault(https);
var zlib = _interopDefault(require('zlib'));
Expand Down Expand Up @@ -3719,11 +3720,32 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
});

const INTERNALS$2 = Symbol('Request internals');
const URL = Url.URL || whatwgUrl.URL;

// fix an issue where "format", "parse" aren't a named export for node <10
const parse_url = Url.parse;
const format_url = Url.format;

/**
* Wrapper around `new URL` to handle arbitrary URLs
*
* @param {string} urlStr
* @return {void}
*/
function parseURL(urlStr) {
/*
Check whether the URL is absolute or not
Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
*/
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
urlStr = new URL(urlStr).toString();
}

// Fallback to old implementation for arbitrary URLs
return parse_url(urlStr);
}

const streamDestructionSupported = 'destroy' in Stream.Readable.prototype;

/**
Expand Down Expand Up @@ -3760,14 +3782,14 @@ class Request {
// in order to support Node.js' Url objects; though WHATWG's URL objects
// will fall into this branch also (since their `toString()` will return
// `href` property anyway)
parsedURL = parse_url(input.href);
parsedURL = parseURL(input.href);
} else {
// coerce input to a string before attempting to parse
parsedURL = parse_url(`${input}`);
parsedURL = parseURL(`${input}`);
}
input = {};
} else {
parsedURL = parse_url(input.url);
parsedURL = parseURL(input.url);
}

let method = init.method || input.method || 'GET';
Expand Down Expand Up @@ -3961,9 +3983,17 @@ AbortError.prototype = Object.create(Error.prototype);
AbortError.prototype.constructor = AbortError;
AbortError.prototype.name = 'AbortError';

const URL$1 = Url.URL || whatwgUrl.URL;

// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
const PassThrough$1 = Stream.PassThrough;
const resolve_url = Url.resolve;

const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
const orig = new URL$1(original).hostname;
const dest = new URL$1(destination).hostname;

return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
};

/**
* Fetch function
Expand Down Expand Up @@ -4051,7 +4081,19 @@ function fetch(url, opts) {
const location = headers.get('Location');

// HTTP fetch step 5.3
const locationURL = location === null ? null : resolve_url(request.url, location);
let locationURL = null;
try {
locationURL = location === null ? null : new URL$1(location, request.url).toString();
} catch (err) {
// error here can only be invalid URL in Location: header
// do not throw when options.redirect == manual
// let the user extract the errorneous redirect URL
if (request.redirect !== 'manual') {
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
finalize();
return;
}
}

// HTTP fetch step 5.5
switch (request.redirect) {
Expand Down Expand Up @@ -4099,6 +4141,12 @@ function fetch(url, opts) {
size: request.size
};

if (!isDomainOrSubdomain(request.url, locationURL)) {
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
requestOpts.headers.delete(name);
}
}

// HTTP-redirect fetch step 9
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
Expand Down Expand Up @@ -4402,7 +4450,7 @@ var MultiplexedRestClient = /** @class */ (function () {
}());

// generated by genversion
var version = '3.2.1';
var version = '3.2.2';

/**
* @license
Expand Down Expand Up @@ -4701,7 +4749,7 @@ var VerifaliaRestClient = /** @class */ (function () {
authenticator = new UsernamePasswordAuthenticator(config.username, config.password);
baseUris = (_a = config.baseUris) !== null && _a !== void 0 ? _a : this._baseUris;
}
else if (config.cert) {
else if (config.cert && config.key) {
// X.509 client certificate authentication (Node.js only)
authenticator = new ClientCertificateAuthenticator(config.cert, config.key, config.passphrase);
baseUris = (_b = config.baseUris) !== null && _b !== void 0 ? _b : this._baseCcaUris;
Expand Down
10 changes: 5 additions & 5 deletions node/esm/VerifaliaRestClientConfiguration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export interface VerifaliaRestClientConfiguration {
* (formerly known as sub-accounts) with just the required permissions, for improved security.
* To create a new user or manage existing ones, please visit https://verifalia.com/client-area#/users
*/
password: string;
password?: string;
/**
* The base API endpoints for the Verifalia service: do NOT set these unless you are instructed
* to do so by the Verifalia support team.
*/
baseUris: string[];
baseUris?: string[];
/**
* This field is used only for client-certificate authentication.
* Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should
Expand All @@ -61,7 +61,7 @@ export interface VerifaliaRestClientConfiguration {
* same order as their private keys in key. If the intermediate certificates are not provided, the peer
* will not be able to validate the certificate, and the handshake will fail.
*/
cert: string | Buffer | (string | Buffer)[];
cert?: string | Buffer | (string | Buffer)[];
/**
* This field is used only for client-certificate authentication.
* Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will
Expand All @@ -70,11 +70,11 @@ export interface VerifaliaRestClientConfiguration {
* The object form can only occur in an array. object.passphrase is optional. Encrypted keys will be
* decrypted with object.passphrase if provided, or options.passphrase if it is not.
*/
key: string | Buffer | (Buffer | KeyObject)[];
key?: string | Buffer | (Buffer | KeyObject)[];
/**
* This field is used only for client-certificate authentication.
* Shared passphrase used for a single private key and/or a PFX.
*/
passphrase: string;
passphrase?: string;
}
//# sourceMappingURL=VerifaliaRestClientConfiguration.d.ts.map
2 changes: 1 addition & 1 deletion node/esm/VerifaliaRestClientConfiguration.d.ts.map

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

Loading

0 comments on commit a6ba894

Please sign in to comment.