mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as Ably from 'ably';
|
||||
|
||||
declare var console: { log(message: any): void };
|
||||
declare const console: { log(message: any): void };
|
||||
|
||||
const ApiKey = 'appId.keyId:secret';
|
||||
const client = new Ably.Realtime(ApiKey);
|
||||
@@ -19,10 +19,9 @@ client.connection.on('failed', () => {
|
||||
// failed connection
|
||||
});
|
||||
|
||||
|
||||
// Subscribing to a channel
|
||||
|
||||
var channel = client.channels.get('test');
|
||||
const channel = client.channels.get('test');
|
||||
channel.subscribe(message => {
|
||||
message.name; // 'greeting'
|
||||
message.data; // 'Hello World!'
|
||||
@@ -68,7 +67,6 @@ channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direct
|
||||
console.log(messagesPage.items.length);
|
||||
});
|
||||
|
||||
|
||||
// Presence on a channel
|
||||
// Getting presence:
|
||||
|
||||
@@ -118,7 +116,7 @@ channel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direct
|
||||
// Generate a random 256-bit key for demonstration purposes (in
|
||||
// practice you need to create one and distribute it to clients yourselves)
|
||||
Ably.Realtime.Crypto.generateRandomKey((err, key) => {
|
||||
var channel = client.channels.get('channelName', { cipher: { key } });
|
||||
const channel = client.channels.get('channelName', { cipher: { key } });
|
||||
|
||||
channel.subscribe(message => {
|
||||
message.name; // 'name is not encrypted'
|
||||
@@ -136,7 +134,7 @@ channel.setOptions({cipher: {key: '<KEY>'}}, () => {
|
||||
|
||||
// Using the REST API
|
||||
|
||||
var restChannel = restClient.channels.get('test');
|
||||
const restChannel = restClient.channels.get('test');
|
||||
|
||||
// Publishing to a channel
|
||||
|
||||
@@ -195,7 +193,6 @@ restChannel.presence.history((err, messagesPage) => { // PaginatedResult
|
||||
// Can optionally take an options param, see https://www.ably.io/documentation/rest-api/#message-history
|
||||
restChannel.history({ start: Date.now() - 10000, end: Date.now(), limit: 100, direction: 'forwards' }, (err, messagesPage) => {});
|
||||
|
||||
|
||||
// Generate Token and Token Request
|
||||
// See https://www.ably.io/documentation/general/authentication for an explanation of Ably's authentication mechanism.
|
||||
|
||||
@@ -206,7 +203,7 @@ client.auth.requestToken((err, tokenDetails) => {
|
||||
// see https://www.ably.io/documentation/rest/authentication/#token-details for its properties
|
||||
|
||||
// Now we have the token, we can send it to someone who can instantiate a client with it:
|
||||
var clientUsingToken = new Ably.Realtime(tokenDetails.token);
|
||||
const clientUsingToken = new Ably.Realtime(tokenDetails.token);
|
||||
});
|
||||
|
||||
// requestToken can take two optional params
|
||||
@@ -242,15 +239,15 @@ client.stats({ limit: 50 }, (err, statsPage) => { // statsPage as Paginat
|
||||
client.time({}, (err, time) => {}); // time is in ms since epoch
|
||||
|
||||
// Getting decoded Message objects from JSON
|
||||
var messages = Ably.Realtime.Message.fromEncodedArray([{ id: 'foo' }]);
|
||||
const messages = Ably.Realtime.Message.fromEncodedArray([{ id: 'foo' }]);
|
||||
console.log(messages[0].id);
|
||||
|
||||
var message = Ably.Rest.Message.fromEncoded({ id: 'foo' });
|
||||
const message = Ably.Rest.Message.fromEncoded({ id: 'foo' });
|
||||
console.log(message.id);
|
||||
|
||||
// Getting decoded PresenceMessage objects from JSON
|
||||
var presenceMessages = Ably.Realtime.PresenceMessage.fromEncodedArray([{ id: 'foo' }]);
|
||||
const presenceMessages = Ably.Realtime.PresenceMessage.fromEncodedArray([{ id: 'foo' }]);
|
||||
console.log(presenceMessages[0].action);
|
||||
|
||||
var presenceMessage = Ably.Rest.PresenceMessage.fromEncoded({ id: 'foo' });
|
||||
const presenceMessage = Ably.Rest.PresenceMessage.fromEncoded({ id: 'foo' });
|
||||
console.log(presenceMessage.action);
|
||||
|
||||
Vendored
+8
-8
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Ably <https://github.com/ably/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace ablyLib {
|
||||
export namespace ablyLib {
|
||||
namespace ChannelState {
|
||||
type INITIALIZED = 'initialized';
|
||||
type ATTACHING = 'attaching';
|
||||
@@ -130,15 +130,15 @@ declare namespace ablyLib {
|
||||
* A function which is called when a new token is required.
|
||||
* The role of the callback is to either generate a signed TokenRequest which may then be submitted automatically
|
||||
* by the library to the Ably REST API requestToken; or to provide a valid token in as a TokenDetails object.
|
||||
**/
|
||||
authCallback?: (data: TokenParams, callback: (error: ErrorInfo | string, tokenRequestOrDetails: TokenDetails | TokenRequest | string) => void) => void;
|
||||
*/
|
||||
authCallback?(data: TokenParams, callback: (error: ErrorInfo | string, tokenRequestOrDetails: TokenDetails | TokenRequest | string) => void): void;
|
||||
authHeaders?: { [index: string]: string };
|
||||
authMethod?: HTTPMethods;
|
||||
authParams?: { [index: string]: string };
|
||||
|
||||
/**
|
||||
* A URL that the library may use to obtain a token string (in plain text format), or a signed TokenRequest or TokenDetails (in JSON format).
|
||||
**/
|
||||
*/
|
||||
authUrl?: string;
|
||||
key?: string;
|
||||
queryTime?: boolean;
|
||||
@@ -259,13 +259,13 @@ declare namespace ablyLib {
|
||||
/**
|
||||
* A number controlling the verbosity of the output. Valid values are: 0 (no logs), 1 (errors only),
|
||||
* 2 (errors plus connection and channel state changes), 3 (high-level debug output), and 4 (full debug output).
|
||||
**/
|
||||
*/
|
||||
level?: number;
|
||||
|
||||
/**
|
||||
* A function to handle each line of log output. If handler is not specified, console.log is used.
|
||||
**/
|
||||
handler?: (...args: any[]) => void;
|
||||
*/
|
||||
handler?(...args: any[]): void;
|
||||
}
|
||||
|
||||
interface ChannelEvent {
|
||||
@@ -398,7 +398,7 @@ declare namespace ablyLib {
|
||||
}
|
||||
|
||||
interface Crypto {
|
||||
generateRandomKey: (callback: (error: ErrorInfo, key: string) => void) => void;
|
||||
generateRandomKey(callback: (error: ErrorInfo, key: string) => void): void;
|
||||
}
|
||||
|
||||
class Connection extends EventEmitter<connectionEventCallback> {
|
||||
|
||||
@@ -27,8 +27,6 @@ accounting.formatMoney(5318008, {
|
||||
// Will recursively format an array of values:
|
||||
accounting.formatMoney([123, 456, [78, 9]], "$", 0); // ["$123", "$456", ["$78", "$9"]]
|
||||
|
||||
|
||||
|
||||
// formatColumn
|
||||
|
||||
// Format list of numbers for display:
|
||||
@@ -40,8 +38,6 @@ accounting.formatColumn([123, 12345], "$ ", 0); // ["$ 123", "$ 12,345"]
|
||||
// List of numbers can be a multi-dimensional array (formatColumn is applied recursively):
|
||||
accounting.formatColumn([[1, 100], [900, 9]]); // [["$ 1.00", "$100.00"], ["$900.00", "$ 9.00"]]
|
||||
|
||||
|
||||
|
||||
// formatNumber
|
||||
|
||||
// Example usage:
|
||||
@@ -58,16 +54,11 @@ accounting.formatNumber(5318008, {
|
||||
// Will recursively format an array of values:
|
||||
accounting.formatNumber([123456, [7890, 123]]); // ["123,456", ["7,890", "123"]]
|
||||
|
||||
|
||||
|
||||
// toFixed
|
||||
|
||||
(0.615).toFixed(2); // "0.61"
|
||||
accounting.toFixed(0.615, 2); // "0.62"
|
||||
|
||||
|
||||
|
||||
|
||||
// unformat
|
||||
|
||||
// Example usage:
|
||||
|
||||
@@ -155,15 +155,11 @@ amplify.request("twitter-search", { term: "amplifyjs" } );
|
||||
|
||||
// Similarly, we can create a request that searches for mentions, by accepting a username:
|
||||
|
||||
amplify.request.define("twitter-mentions", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: data => {
|
||||
return {
|
||||
q: "@" + data.user
|
||||
};
|
||||
}
|
||||
});
|
||||
amplify.request.define("twitter-mentions", "ajax", {
|
||||
url: "http://search.twitter.com/search.json",
|
||||
dataType: "jsonp",
|
||||
dataMap: data => ({ q: "@" + data.user }),
|
||||
});
|
||||
|
||||
amplify.request("twitter-mentions", { user: "amplifyjs" });
|
||||
|
||||
@@ -241,11 +237,11 @@ amplify.request({
|
||||
|
||||
// amplify.request comes with built in support for status.The status parameter appears in the default success or error callbacks when using an ajax definition.
|
||||
|
||||
amplify.request.define("statusExample1", "ajax", {
|
||||
// ...
|
||||
});
|
||||
amplify.request.define("statusExample1", "ajax", {
|
||||
// ...
|
||||
});
|
||||
|
||||
amplify.request({
|
||||
amplify.request({
|
||||
resourceId: "statusExample1",
|
||||
success: (data, status) => {
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// promise api tests
|
||||
import amqp = require('amqplib');
|
||||
|
||||
var msg = 'Hello World';
|
||||
const msg = 'Hello World';
|
||||
|
||||
// test promise api
|
||||
amqp.connect('amqp://localhost')
|
||||
@@ -21,11 +21,10 @@ amqp.connect('amqp://localhost')
|
||||
});
|
||||
|
||||
// test promise api properties
|
||||
var amqpMessage: amqp.Message;
|
||||
let amqpMessage: amqp.Message;
|
||||
amqpMessage.properties.contentType = 'application/json';
|
||||
var amqpAssertExchangeOptions: amqp.Options.AssertExchange;
|
||||
var anqpAssertExchangeReplies: amqp.Replies.AssertExchange;
|
||||
|
||||
let amqpAssertExchangeOptions: amqp.Options.AssertExchange;
|
||||
let anqpAssertExchangeReplies: amqp.Replies.AssertExchange;
|
||||
|
||||
// callback api tests
|
||||
import amqpcb = require('amqplib/callback_api');
|
||||
@@ -59,7 +58,7 @@ amqpcb.connect('amqp://localhost', (err, connection) => {
|
||||
});
|
||||
|
||||
// test callback api properties
|
||||
var amqpcbMessage: amqpcb.Message;
|
||||
let amqpcbMessage: amqpcb.Message;
|
||||
amqpcbMessage.properties.contentType = 'application/json';
|
||||
var amqpcbAssertExchangeOptions: amqpcb.Options.AssertExchange;
|
||||
var anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange;
|
||||
let amqpcbAssertExchangeOptions: amqpcb.Options.AssertExchange;
|
||||
let anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange;
|
||||
|
||||
@@ -820,8 +820,8 @@ angular.module('docsTimeDirective', [])
|
||||
.directive('myCurrentTime', ['$interval', 'dateFilter', ($interval: any, dateFilter: any) => {
|
||||
return {
|
||||
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
|
||||
let format: any,
|
||||
timeoutId: any;
|
||||
let format: any;
|
||||
let timeoutId: any;
|
||||
|
||||
function updateTime() {
|
||||
element.text(dateFilter(new Date(), format));
|
||||
@@ -896,7 +896,10 @@ angular.module('docsIsoFnBindExample', [])
|
||||
angular.module('dragModule', [])
|
||||
.directive('myDraggable', ['$document', ($document: any) => {
|
||||
return (scope: any, element: any, attr: any) => {
|
||||
let startX = 0, startY = 0, x = 0, y = 0;
|
||||
let startX = 0;
|
||||
let startY = 0;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
element.css({
|
||||
position: 'relative',
|
||||
|
||||
Vendored
+2
-1
@@ -875,7 +875,8 @@ declare namespace angular {
|
||||
* @param identifierStart The function that will decide whether the given character is a valid identifier start character.
|
||||
* @param identifierContinue The function that will decide whether the given character is a valid identifier continue character.
|
||||
**/
|
||||
setIdentifierFns(identifierStart?: (character: string, codePoint: number) => boolean,
|
||||
setIdentifierFns(
|
||||
identifierStart?: (character: string, codePoint: number) => boolean,
|
||||
identifierContinue?: (character: string, codePoint: number) => boolean): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
"quotemark": [true, "single"],
|
||||
"variable-name": [true, "check-format"],
|
||||
|
||||
// Below are all TODOs
|
||||
"callable-types": false,
|
||||
"ban-types": false,
|
||||
"interface-name": false,
|
||||
"no-empty-interface": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"no-empty-interface": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ describe("ApplePaySession", () => {
|
||||
}
|
||||
});
|
||||
it("can create a new instance", () => {
|
||||
|
||||
const version = 1;
|
||||
const paymentRequest = {
|
||||
countryCode: "US",
|
||||
@@ -42,7 +41,6 @@ describe("ApplePaySession", () => {
|
||||
const session = new ApplePaySession(version, paymentRequest);
|
||||
});
|
||||
it("can call static methods", () => {
|
||||
|
||||
const merchantIdentifier = "MyMerchantId";
|
||||
|
||||
let canMakePayments: boolean = ApplePaySession.canMakePayments();
|
||||
@@ -59,7 +57,6 @@ describe("ApplePaySession", () => {
|
||||
});
|
||||
});
|
||||
it("can call instance methods", () => {
|
||||
|
||||
const version = 1;
|
||||
const paymentRequest = {
|
||||
countryCode: "US",
|
||||
@@ -171,7 +168,6 @@ describe("ApplePaySession", () => {
|
||||
});
|
||||
describe("ApplePayPaymentRequest", () => {
|
||||
it("can create a new instance", () => {
|
||||
|
||||
let paymentRequest: ApplePayJS.ApplePayPaymentRequest = {
|
||||
applicationData: "ApplicationData",
|
||||
countryCode: "GB",
|
||||
|
||||
Vendored
-16
@@ -7,7 +7,6 @@
|
||||
* A session object for managing the payment process on the web.
|
||||
*/
|
||||
declare class ApplePaySession extends EventTarget {
|
||||
|
||||
/**
|
||||
* Creates a new instance of the ApplePaySession class.
|
||||
* @param version - The version of the ApplePay JS API you are using.
|
||||
@@ -164,12 +163,10 @@ declare class ApplePaySession extends EventTarget {
|
||||
}
|
||||
|
||||
declare namespace ApplePayJS {
|
||||
|
||||
/**
|
||||
* Defines a line item in a payment request - for example, total, tax, discount, or grand total.
|
||||
*/
|
||||
interface ApplePayLineItem {
|
||||
|
||||
/**
|
||||
* A short, localized description of the line item.
|
||||
*/
|
||||
@@ -190,7 +187,6 @@ declare namespace ApplePayJS {
|
||||
* Represents the result of authorizing a payment request and contains encrypted payment information.
|
||||
*/
|
||||
interface ApplePayPayment {
|
||||
|
||||
/**
|
||||
* The encrypted token for an authorized payment.
|
||||
*/
|
||||
@@ -211,7 +207,6 @@ declare namespace ApplePayJS {
|
||||
* The ApplePayPaymentAuthorizedEvent class defines the attributes contained by the ApplePaySession.onpaymentauthorized callback function.
|
||||
*/
|
||||
abstract class ApplePayPaymentAuthorizedEvent extends Event {
|
||||
|
||||
/**
|
||||
* The payment token used to authorize a payment.
|
||||
*/
|
||||
@@ -222,7 +217,6 @@ declare namespace ApplePayJS {
|
||||
* Encapsulates contact information needed for billing and shipping.
|
||||
*/
|
||||
interface ApplePayPaymentContact {
|
||||
|
||||
/**
|
||||
* An email address for the contact.
|
||||
*/
|
||||
@@ -278,7 +272,6 @@ declare namespace ApplePayJS {
|
||||
* Contains information about an Apple Pay payment card.
|
||||
*/
|
||||
interface ApplePayPaymentMethod {
|
||||
|
||||
/**
|
||||
* A string, suitable for display, that describes the card.
|
||||
*/
|
||||
@@ -305,7 +298,6 @@ declare namespace ApplePayJS {
|
||||
* The ApplePayPaymentMethodSelectedEvent class defines the attributes contained by the ApplePaySession.onpaymentmethodselected callback function.
|
||||
*/
|
||||
abstract class ApplePayPaymentMethodSelectedEvent extends Event {
|
||||
|
||||
/**
|
||||
* The card used to complete a payment.
|
||||
*/
|
||||
@@ -316,7 +308,6 @@ declare namespace ApplePayJS {
|
||||
* Represents a provisioned payment card for Apple Pay payments.
|
||||
*/
|
||||
interface ApplePayPaymentPass {
|
||||
|
||||
/**
|
||||
* The unique identifier for the primary account number for the payment card.
|
||||
*/
|
||||
@@ -347,7 +338,6 @@ declare namespace ApplePayJS {
|
||||
* Encapsulates a request for payment, including information about payment processing capabilities, the payment amount, and shipping information.
|
||||
*/
|
||||
interface ApplePayPaymentRequest {
|
||||
|
||||
/**
|
||||
* The merchant's two-letter ISO 3166 country code.
|
||||
*/
|
||||
@@ -419,7 +409,6 @@ declare namespace ApplePayJS {
|
||||
* Contains the user's payment credentials.
|
||||
*/
|
||||
interface ApplePayPaymentToken {
|
||||
|
||||
/**
|
||||
* An object containing the encrypted payment data.
|
||||
*/
|
||||
@@ -440,7 +429,6 @@ declare namespace ApplePayJS {
|
||||
* The ApplePayShippingContactSelectedEvent class defines the attributes contained by the ApplePaySession.onshippingcontactselected callback function.
|
||||
*/
|
||||
abstract class ApplePayShippingContactSelectedEvent extends Event {
|
||||
|
||||
/**
|
||||
* The shipping address selected by the user.
|
||||
*/
|
||||
@@ -451,7 +439,6 @@ declare namespace ApplePayJS {
|
||||
* Defines a shipping method for delivering physical goods.
|
||||
*/
|
||||
interface ApplePayShippingMethod {
|
||||
|
||||
/**
|
||||
* A short description of the shipping method.
|
||||
*/
|
||||
@@ -477,7 +464,6 @@ declare namespace ApplePayJS {
|
||||
* The ApplePayShippingMethodSelectedEvent class defines the attribute contained by the ApplePaySession.onshippingmethodselected callback function.
|
||||
*/
|
||||
abstract class ApplePayShippingMethodSelectedEvent extends Event {
|
||||
|
||||
/**
|
||||
* The shipping method selected by the user.
|
||||
*/
|
||||
@@ -488,7 +474,6 @@ declare namespace ApplePayJS {
|
||||
* The ApplePayValidateMerchantEvent class defines the attributes contained by the ApplePaySession.onvalidatemerchant callback function.
|
||||
*/
|
||||
abstract class ApplePayValidateMerchantEvent extends Event {
|
||||
|
||||
/**
|
||||
* The URL used to validate the merchant server.
|
||||
*/
|
||||
@@ -496,7 +481,6 @@ declare namespace ApplePayJS {
|
||||
}
|
||||
|
||||
abstract class Event {
|
||||
|
||||
readonly bubbles: boolean;
|
||||
|
||||
cancelBubble: boolean;
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
{ "extends": "../tslint.json" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// More samples on: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md
|
||||
|
||||
var config: Microsoft.ApplicationInsights.IConfig = {
|
||||
const config: Microsoft.ApplicationInsights.IConfig = {
|
||||
instrumentationKey: "<your iKey>",
|
||||
endpointUrl: "endpointUrl",
|
||||
emitLineDelimitedJson: false,
|
||||
@@ -30,7 +30,7 @@ var config: Microsoft.ApplicationInsights.IConfig = {
|
||||
isStorageUseDisabled: true
|
||||
};
|
||||
|
||||
var appInsights: Microsoft.ApplicationInsights.IAppInsights = {
|
||||
appInsights = {
|
||||
config,
|
||||
context: null,
|
||||
queue: null,
|
||||
@@ -91,9 +91,8 @@ appInsights.setAuthenticatedUserContext("userId", "accountId");
|
||||
// set config dynamically
|
||||
appInsights.config.instrumentationKey = "<new key>";
|
||||
|
||||
|
||||
// TelementryContext
|
||||
var context: Microsoft.ApplicationInsights.ITelemetryContext = appInsights.context;
|
||||
const context: Microsoft.ApplicationInsights.ITelemetryContext = appInsights.context;
|
||||
|
||||
context.application.ver = "v0.0.0";
|
||||
context.application.build = "1.1.1";
|
||||
@@ -113,54 +112,54 @@ context.operation.id = "1";
|
||||
context.operation.syntheticSource = "testAgent";
|
||||
|
||||
// track
|
||||
var data = new Microsoft.Telemetry.Base();
|
||||
var envelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(data, "name");
|
||||
const data = new Microsoft.Telemetry.Base();
|
||||
const envelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(data, "name");
|
||||
|
||||
context.track(envelope);
|
||||
|
||||
context.addTelemetryInitializer((envelope) => false);
|
||||
context.addTelemetryInitializer(telemetryEnvelope => false);
|
||||
|
||||
// track event
|
||||
var eventObj = new Microsoft.ApplicationInsights.Telemetry.Event("test", null, null);
|
||||
var eventData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Event>(Microsoft.ApplicationInsights.Telemetry.Event.dataType, eventObj);
|
||||
var eventEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(eventData, Microsoft.ApplicationInsights.Telemetry.Event.envelopeType);
|
||||
const eventObj = new Microsoft.ApplicationInsights.Telemetry.Event("test", null, null);
|
||||
const eventData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Event>(Microsoft.ApplicationInsights.Telemetry.Event.dataType, eventObj);
|
||||
const eventEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(eventData, Microsoft.ApplicationInsights.Telemetry.Event.envelopeType);
|
||||
context.track(eventEnvelope);
|
||||
|
||||
// track exception
|
||||
var exceptionObj = new Microsoft.ApplicationInsights.Telemetry.Exception(new Error(), "handledAt", null, null, AI.SeverityLevel.Critical);
|
||||
var exceptionData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Exception>(
|
||||
const exceptionObj = new Microsoft.ApplicationInsights.Telemetry.Exception(new Error(), "handledAt", null, null, AI.SeverityLevel.Critical);
|
||||
const exceptionData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Exception>(
|
||||
Microsoft.ApplicationInsights.Telemetry.Exception.dataType, exceptionObj);
|
||||
var exceptionEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(exceptionData, Microsoft.ApplicationInsights.Telemetry.Exception.envelopeType);
|
||||
const exceptionEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(exceptionData, Microsoft.ApplicationInsights.Telemetry.Exception.envelopeType);
|
||||
context.track(exceptionEnvelope);
|
||||
|
||||
// track metric
|
||||
var metricObj = new Microsoft.ApplicationInsights.Telemetry.Metric("name", 1234, 1, 0, 100, null);
|
||||
var metricData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Metric>(Microsoft.ApplicationInsights.Telemetry.Metric.dataType, metricObj);
|
||||
var metricEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(metricData, Microsoft.ApplicationInsights.Telemetry.Metric.envelopeType);
|
||||
const metricObj = new Microsoft.ApplicationInsights.Telemetry.Metric("name", 1234, 1, 0, 100, null);
|
||||
const metricData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Metric>(Microsoft.ApplicationInsights.Telemetry.Metric.dataType, metricObj);
|
||||
const metricEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(metricData, Microsoft.ApplicationInsights.Telemetry.Metric.envelopeType);
|
||||
context.track(metricEnvelope);
|
||||
|
||||
// track page view
|
||||
var pageViewObj = new Microsoft.ApplicationInsights.Telemetry.PageView("page name", "url", 999, null, null);
|
||||
var pageViewData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageView>(Microsoft.ApplicationInsights.Telemetry.PageView.dataType, pageViewObj);
|
||||
var pageViewEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewData, Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType);
|
||||
const pageViewObj = new Microsoft.ApplicationInsights.Telemetry.PageView("page name", "url", 999, null, null);
|
||||
const pageViewData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageView>(Microsoft.ApplicationInsights.Telemetry.PageView.dataType, pageViewObj);
|
||||
const pageViewEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewData, Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType);
|
||||
context.track(pageViewEnvelope);
|
||||
|
||||
// track page view performance
|
||||
var pageViewPerfObj = new Microsoft.ApplicationInsights.Telemetry.PageViewPerformance("page name", "url", 999, null, null);
|
||||
var pageViewPerfData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageViewPerformance>(
|
||||
const pageViewPerfObj = new Microsoft.ApplicationInsights.Telemetry.PageViewPerformance("page name", "url", 999, null, null);
|
||||
const pageViewPerfData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageViewPerformance>(
|
||||
Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.dataType, pageViewPerfObj);
|
||||
var pageViewPerfEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewPerfData, Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.envelopeType);
|
||||
const pageViewPerfEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewPerfData, Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.envelopeType);
|
||||
context.track(pageViewPerfEnvelope);
|
||||
|
||||
// track remote dependency
|
||||
var remoteDepObj = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData("id", "url", "command", 1, true, 1234, "GET");
|
||||
var remoteDepData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData>(
|
||||
const remoteDepObj = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData("id", "url", "command", 1, true, 1234, "GET");
|
||||
const remoteDepData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData>(
|
||||
Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.dataType, remoteDepObj);
|
||||
var remoteDepEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(remoteDepData, Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType);
|
||||
const remoteDepEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(remoteDepData, Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType);
|
||||
context.track(pageViewPerfEnvelope);
|
||||
|
||||
// track trace
|
||||
var traceObj = new Microsoft.ApplicationInsights.Telemetry.Trace("message", null);
|
||||
var traceData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Trace>(Microsoft.ApplicationInsights.Telemetry.Trace.dataType, traceObj);
|
||||
var traceEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(traceData, Microsoft.ApplicationInsights.Telemetry.Trace.envelopeType);
|
||||
context.track(traceEnvelope);
|
||||
const traceObj = new Microsoft.ApplicationInsights.Telemetry.Trace("message", null);
|
||||
const traceData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Trace>(Microsoft.ApplicationInsights.Telemetry.Trace.dataType, traceObj);
|
||||
const traceEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(traceData, Microsoft.ApplicationInsights.Telemetry.Trace.envelopeType);
|
||||
context.track(traceEnvelope);
|
||||
|
||||
+85
-84
@@ -195,8 +195,8 @@ declare module Microsoft.ApplicationInsights.Context {
|
||||
|
||||
interface IInternal {
|
||||
/**
|
||||
* The SDK version used to create this telemetry item.
|
||||
*/
|
||||
* The SDK version used to create this telemetry item.
|
||||
*/
|
||||
sdkVersion: string;
|
||||
/**
|
||||
* The SDK agent version.
|
||||
@@ -206,15 +206,15 @@ declare module Microsoft.ApplicationInsights.Context {
|
||||
|
||||
interface ISample {
|
||||
/**
|
||||
* Sample rate
|
||||
*/
|
||||
* Sample rate
|
||||
*/
|
||||
sampleRate: number;
|
||||
}
|
||||
|
||||
interface ISession {
|
||||
/**
|
||||
* The session ID.
|
||||
*/
|
||||
* The session ID.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The true if this is the first session
|
||||
@@ -258,8 +258,8 @@ declare module Microsoft.ApplicationInsights.Context {
|
||||
|
||||
interface IUser {
|
||||
/**
|
||||
* The telemetry configuration.
|
||||
*/
|
||||
* The telemetry configuration.
|
||||
*/
|
||||
config: any;
|
||||
/**
|
||||
* The user ID.
|
||||
@@ -345,12 +345,12 @@ declare module Microsoft.ApplicationInsights.Telemetry {
|
||||
measurements: Microsoft.ApplicationInsights.FieldType;
|
||||
};
|
||||
/**
|
||||
* Constructs a new isntance of the ExceptionTelemetry object
|
||||
*/
|
||||
* Constructs a new isntance of the ExceptionTelemetry object
|
||||
*/
|
||||
constructor(exception: Error, handledAt?: string, properties?: any, measurements?: any, severityLevel?: AI.SeverityLevel);
|
||||
/**
|
||||
* Creates a simple exception with 1 stack frame. Useful for manual constracting of exception.
|
||||
*/
|
||||
* Creates a simple exception with 1 stack frame. Useful for manual constracting of exception.
|
||||
*/
|
||||
static CreateSimpleException(message: string, typeName: string, assembly: string, fileName: string, details: string, line: number, handledAt?: string): Telemetry.Exception;
|
||||
}
|
||||
|
||||
@@ -414,8 +414,8 @@ declare module Microsoft.ApplicationInsights.Telemetry {
|
||||
getIsValid(): boolean;
|
||||
private durationMs;
|
||||
/**
|
||||
* Gets the total duration (PLT) in milliseconds. Check getIsValid() before using this method.
|
||||
*/
|
||||
* Gets the total duration (PLT) in milliseconds. Check getIsValid() before using this method.
|
||||
*/
|
||||
getDurationMs(): number;
|
||||
/**
|
||||
* Constructs a new instance of the PageEventTelemetry object
|
||||
@@ -423,8 +423,8 @@ declare module Microsoft.ApplicationInsights.Telemetry {
|
||||
constructor(name: string, url: string, unused: number, properties?: any, measurements?: any);
|
||||
static getPerformanceTiming(): PerformanceTiming;
|
||||
/**
|
||||
* Returns true is window performance timing API is supported, false otherwise.
|
||||
*/
|
||||
* Returns true is window performance timing API is supported, false otherwise.
|
||||
*/
|
||||
static isPerformanceTimingSupported(): PerformanceTiming;
|
||||
/**
|
||||
* As page loads different parts of performance timing numbers get set. When all of them are set we can report it.
|
||||
@@ -615,16 +615,16 @@ declare module Microsoft.ApplicationInsights {
|
||||
|
||||
interface ITelemetryContext {
|
||||
/**
|
||||
* The object describing a component tracked by this object.
|
||||
*/
|
||||
* The object describing a component tracked by this object.
|
||||
*/
|
||||
application: Context.IApplication;
|
||||
/**
|
||||
* The object describing a device tracked by this object.
|
||||
*/
|
||||
device: Context.IDevice;
|
||||
/**
|
||||
* The object describing internal settings.
|
||||
*/
|
||||
* The object describing internal settings.
|
||||
*/
|
||||
internal: Context.IInternal;
|
||||
/**
|
||||
* The object describing a location tracked by this object.
|
||||
@@ -635,8 +635,8 @@ declare module Microsoft.ApplicationInsights {
|
||||
*/
|
||||
operation: Context.IOperation;
|
||||
/**
|
||||
* The object describing sampling settings.
|
||||
*/
|
||||
* The object describing sampling settings.
|
||||
*/
|
||||
sample: Context.ISample;
|
||||
/**
|
||||
* The object describing a user tracked by this object.
|
||||
@@ -647,13 +647,13 @@ declare module Microsoft.ApplicationInsights {
|
||||
*/
|
||||
session: Context.ISession;
|
||||
/**
|
||||
* Adds telemetry initializer to the collection. Telemetry initializers will be called one by one
|
||||
* before telemetry item is pushed for sending and in the order they were added.
|
||||
*/
|
||||
* Adds telemetry initializer to the collection. Telemetry initializers will be called one by one
|
||||
* before telemetry item is pushed for sending and in the order they were added.
|
||||
*/
|
||||
addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.ApplicationInsights.IEnvelope) => boolean): any;
|
||||
/**
|
||||
* Tracks telemetry object.
|
||||
*/
|
||||
* Tracks telemetry object.
|
||||
*/
|
||||
track(envelope: Microsoft.ApplicationInsights.IEnvelope): any;
|
||||
}
|
||||
|
||||
@@ -662,23 +662,23 @@ declare module Microsoft.ApplicationInsights {
|
||||
context: ITelemetryContext;
|
||||
queue: Array<() => void>;
|
||||
/**
|
||||
* Starts timing how long the user views a page or other item. Call this when the page opens.
|
||||
* This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
|
||||
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
||||
*/
|
||||
* Starts timing how long the user views a page or other item. Call this when the page opens.
|
||||
* This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
|
||||
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
||||
*/
|
||||
startTrackPage(name?: string): any;
|
||||
/**
|
||||
* Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
stopTrackPage(name?: string, url?: string, properties?: {
|
||||
[name: string]: string;
|
||||
}, measurements?: {
|
||||
[name: string]: number;
|
||||
}): any;
|
||||
* Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
stopTrackPage(
|
||||
name?: string,
|
||||
url?: string,
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Logs that a page or other item was viewed.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
@@ -687,11 +687,11 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
* @param duration number - the number of milliseconds it took to load the page. Defaults to undefined. If set to default value, page load time is calculated internally.
|
||||
*/
|
||||
trackPageView(name?: string, url?: string, properties?: {
|
||||
[name: string]: string;
|
||||
}, measurements?: {
|
||||
[name: string]: number;
|
||||
}, duration?: number): any;
|
||||
trackPageView(
|
||||
name?: string,
|
||||
url?: string,
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }, duration?: number): any;
|
||||
/**
|
||||
* Start timing an extended event. Call {@link stopTrackEvent} to log the event when it ends.
|
||||
* @param name A string that identifies this event uniquely within the document.
|
||||
@@ -703,22 +703,20 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
stopTrackEvent(name: string, properties?: {
|
||||
[name: string]: string;
|
||||
}, measurements?: {
|
||||
[name: string]: number;
|
||||
}): any;
|
||||
stopTrackEvent(
|
||||
name: string,
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Log a user action or other occurrence.
|
||||
* @param name A string to identify this event in the portal.
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
trackEvent(name: string, properties?: {
|
||||
[name: string]: string;
|
||||
}, measurements?: {
|
||||
[name: string]: number;
|
||||
}): any;
|
||||
* Log a user action or other occurrence.
|
||||
* @param name A string to identify this event in the portal.
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
trackEvent(
|
||||
name: string,
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Log a dependency call
|
||||
* @param id unique id, this is used by the backend o correlate server requests. Use Util.newId() to generate a unique Id.
|
||||
@@ -737,11 +735,12 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
* @param severityLevel AI.SeverityLevel - severity level
|
||||
*/
|
||||
trackException(exception: Error, handledAt?: string, properties?: {
|
||||
[name: string]: string;
|
||||
}, measurements?: {
|
||||
[name: string]: number;
|
||||
}, severityLevel?: AI.SeverityLevel): any;
|
||||
trackException(
|
||||
exception: Error,
|
||||
handledAt?: string,
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number },
|
||||
severityLevel?: AI.SeverityLevel): any;
|
||||
/**
|
||||
* Log a numeric value that is not associated with a specific event. Typically used to send regular reports of performance indicators.
|
||||
* To send a single measurement, use just the first two parameters. If you take measurements very frequently, you can reduce the
|
||||
@@ -752,28 +751,30 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param min The smallest measurement in the sample. Defaults to the average.
|
||||
* @param max The largest measurement in the sample. Defaults to the average.
|
||||
*/
|
||||
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: {
|
||||
[name: string]: string;
|
||||
}): any;
|
||||
trackMetric(
|
||||
name: string,
|
||||
average: number,
|
||||
sampleCount?: number,
|
||||
min?: number,
|
||||
max?: number,
|
||||
properties?: { [name: string]: string }): any;
|
||||
/**
|
||||
* Log a diagnostic message.
|
||||
* @param message A message string
|
||||
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
|
||||
*/
|
||||
trackTrace(message: string, properties?: {
|
||||
[name: string]: string;
|
||||
}): any;
|
||||
* Log a diagnostic message.
|
||||
* @param message A message string
|
||||
* @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
|
||||
*/
|
||||
trackTrace(message: string, properties?: { [name: string]: string }): any;
|
||||
/**
|
||||
* Immediately send all queued telemetry.
|
||||
*/
|
||||
flush(): any;
|
||||
/**
|
||||
* Sets the autheticated user id and the account id in this session.
|
||||
* User auth id and account id should be of type string. They should not contain commas, semi-colons, equal signs, spaces, or vertical-bars.
|
||||
*
|
||||
* @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
|
||||
* @param accountId {string} - An optional string to represent the account associated with the authenticated user.
|
||||
*/
|
||||
* Sets the autheticated user id and the account id in this session.
|
||||
* User auth id and account id should be of type string. They should not contain commas, semi-colons, equal signs, spaces, or vertical-bars.
|
||||
*
|
||||
* @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
|
||||
* @param accountId {string} - An optional string to represent the account associated with the authenticated user.
|
||||
*/
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string): any;
|
||||
/**
|
||||
* Clears the authenticated user id and the account id from the user context.
|
||||
@@ -796,4 +797,4 @@ declare module 'applicationinsights-js' {
|
||||
const AppInsights: Microsoft.ApplicationInsights.IAppInsights;
|
||||
}
|
||||
|
||||
declare var appInsights: Microsoft.ApplicationInsights.IAppInsights;
|
||||
declare var appInsights: Microsoft.ApplicationInsights.IAppInsights;
|
||||
|
||||
@@ -8,4 +8,4 @@ point = {
|
||||
spatialReference: {
|
||||
wkid: 4326
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Vendored
+1
-4
@@ -65,7 +65,6 @@ export interface BezierCurve {
|
||||
|
||||
export type JsonCurve = CircularArc | Arc | OldCircularArc | BezierCurve;
|
||||
|
||||
|
||||
export interface SpatialReferenceWkid {
|
||||
wkid?: number;
|
||||
latestWkid?: number;
|
||||
@@ -131,7 +130,6 @@ export interface Envelope extends Geometry {
|
||||
|
||||
export type esriGeometryType = "esriGeometryPoint" | "esriGeometryMultipoint" | "esriGeometryPolyline" | "esriGeometryPolygon" | "esriGeometryEnvelope";
|
||||
|
||||
|
||||
export type Color = [number, number, number, number];
|
||||
export type SimpleMarkerSymbolStyle = "esriSMSCircle" | "esriSMSCross" | "esriSMSDiamond" | "esriSMSSquare" | "esriSMSX" | "esriSMSTriangle";
|
||||
export type SimpleLineSymbolStyle = "esriSLSDash" | "esriSLSDashDot" | "esriSLSDashDotDot" | "esriSLSDot" | "esriSLSNull" | "esriSLSSolid";
|
||||
@@ -181,7 +179,6 @@ export interface PictureSourced {
|
||||
"angle"?: number;
|
||||
"xoffset"?: number;
|
||||
"yoffset"?: number;
|
||||
|
||||
}
|
||||
|
||||
export interface PictureMarkerSymbol extends MarkerSymbol, PictureSourced {
|
||||
@@ -217,4 +214,4 @@ export interface TextSymbol extends MarkerSymbol {
|
||||
"kerning"?: boolean;
|
||||
"font"?: Font;
|
||||
"text"?: string; // only applicable when specified as a client-side graphic.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ const geojsonPoint: GeoJSON.Point = {
|
||||
};
|
||||
|
||||
// parse ArcGIS JSON, convert it to GeoJSON
|
||||
var geojson = utils.arcgisToGeoJSON(arcgisPoint);
|
||||
const geojson = utils.arcgisToGeoJSON(arcgisPoint);
|
||||
|
||||
// take GeoJSON and convert it to ArcGIS JSON
|
||||
var arcgis = utils.geojsonToArcGIS(geojsonPoint);
|
||||
const arcgis = utils.geojsonToArcGIS(geojsonPoint);
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ export function arcgisToGeoJSON<T extends ArcGis.Geometry>(arcgis: T): GeoJSON.G
|
||||
/**
|
||||
* Converts a GeoJSON geometry into a ArcGIS geometry.
|
||||
*/
|
||||
export function geojsonToArcGIS(geojson: GeoJSON.GeometryObject): ArcGis.Geometry;
|
||||
export function geojsonToArcGIS(geojson: GeoJSON.GeometryObject): ArcGis.Geometry;
|
||||
|
||||
@@ -2,4 +2,4 @@ import arrayUniq = require("array-uniq");
|
||||
|
||||
arrayUniq([1, 1, 2, 3, 3]);
|
||||
|
||||
arrayUniq(["foo", "foo", "bar", "foo"]);
|
||||
arrayUniq(["foo", "foo", "bar", "foo"]);
|
||||
|
||||
Vendored
+1
-1
@@ -5,4 +5,4 @@
|
||||
|
||||
declare function arrayUniq<T>(arr: T[]): T[];
|
||||
|
||||
export = arrayUniq;
|
||||
export = arrayUniq;
|
||||
|
||||
Vendored
+169
-351
@@ -7,7 +7,7 @@
|
||||
* @module braintree-web/american-express
|
||||
* @description This module is for use with Amex Express Checkout. To accept American Express cards, use Hosted Fields.
|
||||
*/
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
export interface AmericanExpress {
|
||||
/**
|
||||
* @static
|
||||
@@ -24,22 +24,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options Options
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/american-express.create|braintree.american-express.create} instead.</strong>
|
||||
* @classdesc This class allows you use a nonce to interact with American Express Checkout. To accept American Express cards, use Hosted Fields.
|
||||
*/
|
||||
export class AmericanExpress {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options Options
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/american-express.create|braintree.american-express.create} instead.</strong>
|
||||
* @classdesc This class allows you use a nonce to interact with American Express Checkout. To accept American Express cards, use Hosted Fields.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
/**
|
||||
* Gets the rewards balance associated with a Braintree nonce.
|
||||
@@ -63,7 +47,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* });
|
||||
*/
|
||||
public getRewardsBalance(options: { nonce: string }, callback: callback): void;
|
||||
getRewardsBalance(options: { nonce: string }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Gets the Express Checkout nonce profile given a nonce from American Express.
|
||||
@@ -87,121 +71,123 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* });
|
||||
*/
|
||||
public getExpressCheckoutProfile(options: { nonce: string }, callback: callback): void;
|
||||
getExpressCheckoutProfile(options: { nonce: string }, callback: callback): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest
|
||||
declare namespace braintree {
|
||||
// more info https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types/paymentrequest
|
||||
|
||||
// billingContact
|
||||
// Billing contact information for the user.
|
||||
// countryCode
|
||||
//Required.The merchant’s two- letter ISO 3166 country code.
|
||||
// currencyCode
|
||||
// Required.The three- letter ISO 4217 currency code for the payment.
|
||||
// lineItems
|
||||
//A set of line items that explain recurring payments and additional charges.
|
||||
// merchantCapabilities
|
||||
// Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
|
||||
// requiredBillingContactFields
|
||||
// The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
|
||||
// requiredShippingContactFields
|
||||
// The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
|
||||
// shippingContact
|
||||
// Shipping contact information for the user.
|
||||
// shippingMethods
|
||||
//A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
|
||||
// shippingType
|
||||
// How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
|
||||
// supportedNetworks
|
||||
// Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
|
||||
// total
|
||||
// Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
|
||||
interface ApplePayPaymentRequest {
|
||||
total: {
|
||||
label: string;
|
||||
amount: string;
|
||||
};
|
||||
countryCode: string;
|
||||
currencyCode: string;
|
||||
supportedNetworks: string[];
|
||||
merchantCapabilities: string[];
|
||||
// billingContact
|
||||
// Billing contact information for the user.
|
||||
// countryCode
|
||||
//Required.The merchant’s two- letter ISO 3166 country code.
|
||||
// currencyCode
|
||||
// Required.The three- letter ISO 4217 currency code for the payment.
|
||||
// lineItems
|
||||
//A set of line items that explain recurring payments and additional charges.
|
||||
// merchantCapabilities
|
||||
// Required.The payment capabilities supported by the merchant.The value must be one or more of supports3DS, supportsEMV, supportsCredit, or supportsDebit.
|
||||
// requiredBillingContactFields
|
||||
// The billing information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
|
||||
// requiredShippingContactFields
|
||||
// The shipping information that is required from the user.The value must be one or more of postalAddress, phone, email, or name.
|
||||
// shippingContact
|
||||
// Shipping contact information for the user.
|
||||
// shippingMethods
|
||||
//A set of available shipping methods.Totals for all shipping methods must be non- negative to pass validation.
|
||||
// shippingType
|
||||
// How the items are to be shipped.This property is optional.If specified, it must be one or more of shipping, delivery, storePickup, or servicePickup.The default value is shipping.
|
||||
// supportedNetworks
|
||||
// Required.The payment networks supported by the merchant.The value must be one or more of amex, discover, interac, masterCard, privateLabel, or visa.
|
||||
// total
|
||||
// Required.The total amount for the payment.The total must be greater than zero and have a label to pass validation.
|
||||
interface ApplePayPaymentRequest {
|
||||
total: {
|
||||
label: string;
|
||||
amount: string;
|
||||
};
|
||||
countryCode: string;
|
||||
currencyCode: string;
|
||||
supportedNetworks: string[];
|
||||
merchantCapabilities: string[];
|
||||
|
||||
billingContact?: any;
|
||||
shippingContact?: any;
|
||||
shippingMethods?: any;
|
||||
shippingType?: any;
|
||||
requiredBillingContactFields?: any;
|
||||
requiredShippingContactFields?: any;
|
||||
}
|
||||
billingContact?: any;
|
||||
shippingContact?: any;
|
||||
shippingMethods?: any;
|
||||
shippingType?: any;
|
||||
requiredBillingContactFields?: any;
|
||||
requiredShippingContactFields?: any;
|
||||
}
|
||||
|
||||
declare enum ApplePayStatusCodes {
|
||||
// The requested action succeeded.
|
||||
STATUS_SUCCESS = 1,
|
||||
// The requested action failed.
|
||||
STATUS_FAILURE,
|
||||
// The billing address is not valid.
|
||||
STATUS_INVALID_BILLING_POSTAL_ADDRESS,
|
||||
// The shipping address is not valid.
|
||||
STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
|
||||
// The shipping contact information is not valid.
|
||||
STATUS_INVALID_SHIPPING_CONTACT,
|
||||
// The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
|
||||
STATUS_PIN_REQUIRED,
|
||||
// The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
|
||||
STATUS_PIN_INCORRECT,
|
||||
// The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
|
||||
STATUS_PIN_LOCKOUT,
|
||||
}
|
||||
export enum ApplePayStatusCodes {
|
||||
// The requested action succeeded.
|
||||
STATUS_SUCCESS = 1,
|
||||
// The requested action failed.
|
||||
STATUS_FAILURE,
|
||||
// The billing address is not valid.
|
||||
STATUS_INVALID_BILLING_POSTAL_ADDRESS,
|
||||
// The shipping address is not valid.
|
||||
STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,
|
||||
// The shipping contact information is not valid.
|
||||
STATUS_INVALID_SHIPPING_CONTACT,
|
||||
// The required PIN information was not provided. Cards on the China Union Pay payment network may require a PIN to authenticate the transaction.
|
||||
STATUS_PIN_REQUIRED,
|
||||
// The PIN information is not valid.Cards on the China Union Pay network may require a PIN.
|
||||
STATUS_PIN_INCORRECT,
|
||||
// The maximum number of tries for a PIN has been reached and the user has been locked out. Cards on the China Union Pay network may require a PIN.
|
||||
STATUS_PIN_LOCKOUT,
|
||||
}
|
||||
|
||||
interface ApplePayPayload {
|
||||
merchantIdentifier: string;
|
||||
domainName: string;
|
||||
displayName: string;
|
||||
}
|
||||
interface ApplePayPayload {
|
||||
merchantIdentifier: string;
|
||||
domainName: string;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
declare class ApplePaySession {
|
||||
constructor(version: number, request: ApplePayPaymentRequest);
|
||||
export class ApplePaySession {
|
||||
constructor(version: number, request: ApplePayPaymentRequest);
|
||||
|
||||
canMakePayments(): boolean;
|
||||
canMakePayments(): boolean;
|
||||
|
||||
canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;
|
||||
canMakePaymentsWithActiveCard(merchantIdentifier: string): boolean;
|
||||
|
||||
completeMerchantValidation(merchantSession: any): void;
|
||||
completeMerchantValidation(merchantSession: any): void;
|
||||
|
||||
abort(): void;
|
||||
abort(): void;
|
||||
|
||||
begin(): void;
|
||||
begin(): void;
|
||||
|
||||
completePayment(status: ApplePayStatusCodes): void;
|
||||
completePayment(status: ApplePayStatusCodes): void;
|
||||
|
||||
completePaymentMethodSelection(newTotal: any, newLineItems: any): void;
|
||||
completePaymentMethodSelection(newTotal: any, newLineItems: any): void;
|
||||
|
||||
completeShippingContactSelection(status: ApplePayStatusCodes, newShippingMethods: any, newTotal: any, newLineItems: any): void;
|
||||
completeShippingContactSelection(status: ApplePayStatusCodes, newShippingMethods: any, newTotal: any, newLineItems: any): void;
|
||||
|
||||
completeShippingMethodSelection(status: ApplePayStatusCodes, newTotal: any, newLineItems: any): void;
|
||||
completeShippingMethodSelection(status: ApplePayStatusCodes, newTotal: any, newLineItems: any): void;
|
||||
|
||||
supportsVersion(version: number): boolean;
|
||||
supportsVersion(version: number): boolean;
|
||||
|
||||
oncancel: (event: any) => void;
|
||||
oncancel: (event: any) => void;
|
||||
|
||||
onpaymentauthorized: (event: any) => void;
|
||||
onpaymentauthorized: (event: any) => void;
|
||||
|
||||
onpaymentmethodselected: (event: any) => void;
|
||||
onpaymentmethodselected: (event: any) => void;
|
||||
|
||||
onshippingcontactselected: (event: any) => void;
|
||||
onshippingcontactselected: (event: any) => void;
|
||||
|
||||
onshippingmethodselected: (event: any) => void;
|
||||
onshippingmethodselected: (event: any) => void;
|
||||
|
||||
onvalidatemerchant: (event: any) => void;
|
||||
onvalidatemerchant: (event: any) => void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @module braintree-web/apple-pay
|
||||
* @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.*
|
||||
*/
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
export interface ApplePay {
|
||||
/**
|
||||
* @static
|
||||
@@ -218,22 +204,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options Options
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/apple-pay.create|braintree.apple-pay.create} instead.</strong>
|
||||
* @classdesc This class represents an Apple Pay component. Instances of this class have methods for validating the merchant server and tokenizing payments.
|
||||
*/
|
||||
export class ApplePay {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options Options
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/apple-pay.create|braintree.apple-pay.create} instead.</strong>
|
||||
* @classdesc This class represents an Apple Pay component. Instances of this class have methods for validating the merchant server and tokenizing payments.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
/**
|
||||
* Merges a payment request with Braintree defaults
|
||||
@@ -260,7 +230,7 @@ declare namespace BraintreeWeb {
|
||||
* // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
|
||||
*
|
||||
*/
|
||||
public createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest
|
||||
createPaymentRequest(paymentRequest: ApplePayPaymentRequest): ApplePayPaymentRequest
|
||||
|
||||
/**
|
||||
* Validates the merchant website, as required by ApplePaySession before payment can be authorized.
|
||||
@@ -302,7 +272,7 @@ declare namespace BraintreeWeb {
|
||||
* };
|
||||
* });
|
||||
*/
|
||||
public performValidation(options: { validationURL: string, displayName?: string, merchantIdentifier?: string }, callback: callback): void;
|
||||
performValidation(options: { validationURL: string, displayName?: string, merchantIdentifier?: string }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Tokenizes an Apple Pay payment.
|
||||
@@ -332,16 +302,14 @@ declare namespace BraintreeWeb {
|
||||
* };
|
||||
* });
|
||||
*/
|
||||
public tokenize(options: { token: any }, callback: callback): void;
|
||||
|
||||
tokenize(options: { token: any }, callback: callback): void;
|
||||
}
|
||||
}
|
||||
|
||||
/** @module braintree-web/client */
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
/**
|
||||
* This object is returned by {@link Client#getConfiguration|getConfiguration}. This information is used extensively by other Braintree modules to properly configure themselves.
|
||||
* @typedef {object} Client~configuration
|
||||
* @property {object} client The braintree-web/client parameters.
|
||||
* @property {string} client.authorization A tokenizationKey or clientToken.
|
||||
* @property {object} gatewayConfiguration Gateway-supplied configuration.
|
||||
@@ -398,30 +366,13 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {Client~configuration} configuration Options
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/client.create|braintree.client.create} instead.</strong>
|
||||
* @classdesc This class is required by many other Braintree components. It serves as the base API layer that communicates with our servers. It is also capable of being used to formulate direct calls to our servers, such as direct credit card tokenization. See {@link Client#request}.
|
||||
*/
|
||||
export class Client {
|
||||
/**
|
||||
* @class
|
||||
* @param {Client~configuration} configuration Options
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/client.create|braintree.client.create} instead.</strong>
|
||||
* @classdesc This class is required by many other Braintree components. It serves as the base API layer that communicates with our servers. It is also capable of being used to formulate direct calls to our servers, such as direct credit card tokenization. See {@link Client#request}.
|
||||
*/
|
||||
constructor(configuration: Configuration);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a copy of the configuration values.
|
||||
* @public
|
||||
* @returns {Client~configuration} configuration
|
||||
*/
|
||||
public getConfiguration(): Configuration;
|
||||
getConfiguration(): Configuration;
|
||||
|
||||
/**
|
||||
* Used by other modules to formulate all network requests to the Braintree gateway. It is also capable of being used directly from your own form to tokenize credit card information. However, be sure to satisfy PCI compliance if you use direct card tokenization.
|
||||
@@ -470,13 +421,12 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public request(options: { method: string, endpoint: string, data: any, timeout?: number }, callback: callback): void;
|
||||
|
||||
request(options: { method: string, endpoint: string, data: any, timeout?: number }, callback: callback): void;
|
||||
}
|
||||
}
|
||||
|
||||
/** @module braintree-web/data-collector */
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
export interface DataCollector {
|
||||
/**
|
||||
* @static
|
||||
@@ -496,24 +446,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @global
|
||||
* @name DataCollector
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/data-collector.create|braintree-web.data-collector.create} instead.</strong>
|
||||
* @classdesc This class is used for advanced fraud integration with PayPal and Kount. Instances of this class have {@link DataCollector#deviceData|deviceData} which is used to correlate user sessions with server transactions. Before using DataCollector, make sure you have enabled advanced fraud protection in the Braintree gateway. To use your own Kount ID, contact our support team ([support@braintreepayments.com](mailto:support@braintreepayments.com) or [877.434.2894](tel:877.434.2894)).
|
||||
*/
|
||||
export class DataCollector {
|
||||
/**
|
||||
* @class
|
||||
* @global
|
||||
* @name DataCollector
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/data-collector.create|braintree-web.data-collector.create} instead.</strong>
|
||||
* @classdesc This class is used for advanced fraud integration with PayPal and Kount. Instances of this class have {@link DataCollector#deviceData|deviceData} which is used to correlate user sessions with server transactions.
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* @memberof DataCollector
|
||||
@@ -534,12 +466,11 @@ declare namespace BraintreeWeb {
|
||||
* @returns {void}
|
||||
*/
|
||||
teardown(callback?: callback): void;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** @module braintree-web/hosted-fields */
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
/**
|
||||
* Fields used in {@link module:braintree-web/hosted-fields~fieldOptions fields options}
|
||||
* @typedef {object} field
|
||||
@@ -578,7 +509,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} HostedFields~hostedFieldsCard
|
||||
* @description Information about the card type, sent in {@link HostedFields~stateObject|stateObjects}.
|
||||
* @property {string} type The code-friendly representation of the card type. It will be one of the following strings:
|
||||
* - `american-express`
|
||||
@@ -618,7 +548,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} HostedFields~hostedFieldsFieldData
|
||||
* @description Data about Hosted Fields fields, sent in {@link HostedFields~stateObject|stateObjects}.
|
||||
* @property {HTMLElement} container Reference to the container DOM element on your page associated with the current event.
|
||||
* @property {boolean} isFocused Whether or not the input is currently focused.
|
||||
@@ -641,7 +570,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} HostedFields~stateObject
|
||||
* @description The event payload sent from {@link HostedFields#on|on} or {@link HostedFields#getState|getState}.
|
||||
* @property {HostedFields~hostedFieldsCard[]} cards
|
||||
* This will return an array of potential {@link HostedFields~hostedFieldsCard|cards}. If the card type has been determined, the array will contain only one card.
|
||||
@@ -679,7 +607,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} HostedFields~tokenizePayload
|
||||
* @property {string} nonce The payment method nonce.
|
||||
* @property {object} details Additional account details.
|
||||
* @property {string} details.cardType Type of card, ex: Visa, MasterCard.
|
||||
@@ -781,22 +708,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class HostedFields
|
||||
* @param {object} options The Hosted Fields {@link module:braintree-web/hosted-fields.create create} options.
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/hosted-fields.create|braintree-web.hosted-fields.create} instead.</strong>
|
||||
* @classdesc This class represents a Hosted Fields component produced by {@link module:braintree-web/hosted-fields.create|braintree-web/hosted-fields.create}. Instances of this class have methods for interacting with the input fields within Hosted Fields' iframes.
|
||||
*/
|
||||
export class HostedFields {
|
||||
/**
|
||||
* @class HostedFields
|
||||
* @param {object} options The Hosted Fields {@link module:braintree-web/hosted-fields.create create} options.
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/hosted-fields.create|braintree-web.hosted-fields.create} instead.</strong>
|
||||
* @classdesc This class represents a Hosted Fields component produced by {@link module:braintree-web/hosted-fields.create|braintree-web/hosted-fields.create}. Instances of this class have methods for interacting with the input fields within Hosted Fields' iframes.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
/**
|
||||
* @name HostedFields#on
|
||||
@@ -829,7 +740,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public teardown(callback?: callback): void;
|
||||
teardown(callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Tokenizes fields and returns a nonce payload.
|
||||
@@ -872,7 +783,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public tokenize(options?: { vault: boolean }, callback?: callback): void;
|
||||
tokenize(options?: { vault: boolean }, callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Add a class to a {@link module:braintree-web/hosted-fields~field field}. Useful for updating field styles when events occur elsewhere in your checkout.
|
||||
@@ -889,7 +800,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public addClass(field: string, classname: string, callback?: callback): void;
|
||||
addClass(field: string, classname: string, callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Removes a class to a {@link module:braintree-web/hosted-fields~field field}. Useful for updating field styles when events occur elsewhere in your checkout.
|
||||
@@ -910,7 +821,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public removeClass(field: string, classname: string, callback?: callback): void;
|
||||
removeClass(field: string, classname: string, callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Sets the placeholder of a {@link module:braintree-web/hosted-fields~field field}.
|
||||
@@ -940,7 +851,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public setPlaceholder(field: string, placeholder: string, callback?: callback): void;
|
||||
setPlaceholder(field: string, placeholder: string, callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Clear the value of a {@link module:braintree-web/hosted-fields~field field}.
|
||||
@@ -960,7 +871,7 @@ declare namespace BraintreeWeb {
|
||||
* hostedFieldsInstance.clear('cvv');
|
||||
* hostedFieldsInstance.clear('expirationDate');
|
||||
*/
|
||||
public clear(field: string, callback?: callback): void;
|
||||
clear(field: string, callback?: callback): void;
|
||||
|
||||
/**
|
||||
* Returns an {@link HostedFields~stateObject|object} that includes the state of all fields and possible card types.
|
||||
@@ -973,14 +884,13 @@ declare namespace BraintreeWeb {
|
||||
* return state.fields[key].isValid;
|
||||
* });
|
||||
*/
|
||||
public getState(): any;
|
||||
getState(): any;
|
||||
}
|
||||
}
|
||||
|
||||
/** @module braintree-web/paypal */
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
/**
|
||||
* @typedef {object} PayPal~tokenizeReturn
|
||||
* @property {Function} close A handle to close the PayPal checkout flow.
|
||||
*/
|
||||
interface PayPalTokenizeReturn {
|
||||
@@ -988,7 +898,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} PayPal~tokenizePayload
|
||||
* @property {string} nonce The payment method nonce.
|
||||
* @property {string} type The payment method type, always `PayPalAccount`.
|
||||
* @property {object} details Additional PayPal account details.
|
||||
@@ -1082,20 +991,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options see {@link module:braintree-web/paypal.create|paypal.create}
|
||||
* @classdesc This class represents a PayPal component. Instances of this class have methods for launching auth dialogs and other programmatic interactions with the PayPal component.
|
||||
*/
|
||||
export class PayPal {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options see {@link module:braintree-web/paypal.create|paypal.create}
|
||||
* @classdesc This class represents a PayPal component. Instances of this class have methods for launching auth dialogs and other programmatic interactions with the PayPal component.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
/**
|
||||
* Launches the PayPal login flow and returns a nonce payload. Only one PayPal login flow should be active at a time. One way to achieve this is to disable your PayPal button while the flow is open.
|
||||
@@ -1192,7 +1087,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {PayPal~tokenizeReturn} A handle to close the PayPal checkout frame.
|
||||
*/
|
||||
public tokenize(options: { flow: string, intent: string, offerCredit: boolean, useraction: string, amount: (string | number), currency: string, displayName: string, locale: string, enableShippingAddress: boolean, shippingAddressOverride: PayPalShippingAddress, shippingAddressEditable: boolean, billingAgreementDescription: string }, callback: callback): PayPalTokenizeReturn;
|
||||
tokenize(options: { flow: string, intent: string, offerCredit: boolean, useraction: string, amount: (string | number), currency: string, displayName: string, locale: string, enableShippingAddress: boolean, shippingAddressOverride: PayPalShippingAddress, shippingAddressEditable: boolean, billingAgreementDescription: string }, callback: callback): PayPalTokenizeReturn;
|
||||
|
||||
/**
|
||||
* Cleanly tear down anything set up by {@link module:braintree-web/paypal.create|create}.
|
||||
@@ -1200,15 +1095,13 @@ declare namespace BraintreeWeb {
|
||||
* @param {callback} [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
|
||||
* @returns {void}
|
||||
*/
|
||||
public teardown(callback?: () => void): void;
|
||||
|
||||
teardown(callback?: () => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
/** @module braintree-web/three-d-secure */
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
/**
|
||||
* @typedef {object} ThreeDSecure~verifyPayload
|
||||
* @property {string} nonce The new payment method nonce produced by the 3D Secure lookup. The original nonce passed into {@link ThreeDSecure#verifyCard|verifyCard} was consumed. This new nonce should be used to transact on your server.
|
||||
* @property {object} details Additional account details.
|
||||
* @property {string} details.cardType Type of card, ex: Visa, MasterCard.
|
||||
@@ -1250,23 +1143,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options 3D Secure {@link module:braintree-web/three-d-secure.create create} options
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/three-d-secure.create|braintree.threeDSecure.create} instead.</strong>
|
||||
* @classdesc This class represents a ThreeDSecure component produced by {@link module:braintree-web/three-d-secure.create|braintree.threeDSecure.create}. Instances of this class have a method for launching a 3D Secure authentication flow.
|
||||
*/
|
||||
export class ThreeDSecure {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options 3D Secure {@link module:braintree-web/three-d-secure.create create} options
|
||||
* @description <strong>Do not use this constructor directly. Use {@link module:braintree-web/three-d-secure.create|braintree.threeDSecure.create} instead.</strong>
|
||||
* @classdesc This class represents a ThreeDSecure component produced by {@link module:braintree-web/three-d-secure.create|braintree.threeDSecure.create}. Instances of this class have a method for launching a 3D Secure authentication flow.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
|
||||
/**
|
||||
* @callback ThreeDSecure~addFrameCallback
|
||||
@@ -1329,7 +1205,7 @@ declare namespace BraintreeWeb {
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
public verifyCard(options: { nonce: string, amount: number, addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void, removeFrame: () => void }, callback: callback): void;
|
||||
verifyCard(options: { nonce: string, amount: number, addFrame: (err?: BraintreeError, iframe?: HTMLIFrameElement) => void, removeFrame: () => void }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Cancel the 3DS flow and return the verification payload if available.
|
||||
@@ -1349,7 +1225,7 @@ declare namespace BraintreeWeb {
|
||||
* verifyPayload.liabilityShiftPossible; // boolean
|
||||
* });
|
||||
*/
|
||||
public cancelVerifyCard(callback: callback): void;
|
||||
cancelVerifyCard(callback: callback): void;
|
||||
|
||||
/**
|
||||
* Cleanly tear down anything set up by {@link module:braintree-web/three-d-secure.create|create}
|
||||
@@ -1357,7 +1233,7 @@ declare namespace BraintreeWeb {
|
||||
* @param {errback} [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
|
||||
* @returns {void}
|
||||
*/
|
||||
public teardown(callback?: callback): void;
|
||||
teardown(callback?: callback): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1365,9 +1241,8 @@ declare namespace BraintreeWeb {
|
||||
* @module braintree-web/unionpay
|
||||
* @description This module allows you to accept UnionPay payments. *It is currently in beta and is subject to change.*
|
||||
*/
|
||||
declare namespace BraintreeWeb {
|
||||
declare namespace braintree {
|
||||
/**
|
||||
* @typedef {object} UnionPay~tokenizePayload
|
||||
* @property {string} nonce The payment method nonce.
|
||||
* @property {string} type Always <code>CreditCard</code>.
|
||||
* @property {object} details Additional account details:
|
||||
@@ -1388,7 +1263,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} UnionPay~enrollPayload
|
||||
* @property {string} enrollmentId UnionPay enrollment ID. This value should be passed to `tokenize`.
|
||||
* @property {boolean} smsCodeRequired UnionPay `smsCodeRequired` flag.
|
||||
* </p><b>true</b> - the user will receive an SMS code that needs to be supplied for tokenization.
|
||||
@@ -1400,7 +1274,6 @@ declare namespace BraintreeWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} UnionPay~fetchCapabilitiesPayload
|
||||
* @property {boolean} isUnionPay Determines if this card is a UnionPay card.
|
||||
* @property {boolean} isDebit Determines if this card is a debit card. This property is only present if `isUnionPay` is `true`.
|
||||
* @property {object} unionPay UnionPay specific properties. This property is only present if `isUnionPay` is `true`.
|
||||
@@ -1443,22 +1316,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options See {@link module:braintree-web/unionpay.create|unionpay.create}.
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/unionpay.create|braintree-web.unionpay.create} instead.</strong>
|
||||
* @classdesc This class represents a UnionPay component. Instances of this class have methods for {@link UnionPay#fetchCapabilities fetching capabilities} of UnionPay cards, {@link UnionPay#enroll enrolling} a UnionPay card, and {@link UnionPay#tokenize tokenizing} a UnionPay card.
|
||||
*/
|
||||
export class UnionPay {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options See {@link module:braintree-web/unionpay.create|unionpay.create}.
|
||||
* @description <strong>You cannot use this constructor directly. Use {@link module:braintree-web/unionpay.create|braintree-web.unionpay.create} instead.</strong>
|
||||
* @classdesc This class represents a UnionPay component. Instances of this class have methods for {@link UnionPay#fetchCapabilities fetching capabilities} of UnionPay cards, {@link UnionPay#enroll enrolling} a UnionPay card, and {@link UnionPay#tokenize tokenizing} a UnionPay card.
|
||||
*/
|
||||
constructor(options: any);
|
||||
|
||||
/**
|
||||
* Fetches the capabilities of a card, including whether or not the SMS enrollment process is required.
|
||||
@@ -1531,7 +1388,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public fetchCapabilities(options: { card: any, hostedFields: HostedFields }, callback: callback): void;
|
||||
fetchCapabilities(options: { card: any, hostedFields: HostedFields }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Enrolls a UnionPay card. Use {@link UnionPay#fetchCapabilities|fetchCapabilities} to determine if the SMS enrollment process is required.
|
||||
@@ -1594,7 +1451,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public enroll(options: { card: any, hostedFields: HostedFields, mobile: any }, callback: callback): void;
|
||||
enroll(options: { card: any, hostedFields: HostedFields, mobile: any }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Tokenizes a UnionPay card and returns a nonce payload.
|
||||
@@ -1643,7 +1500,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public tokenize(options: { card: any, hostedFields: HostedFields, enrollmentId: string, smsCode: string }, callback: callback): void;
|
||||
tokenize(options: { card: any, hostedFields: HostedFields, enrollmentId: string, smsCode: string }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Cleanly tear down anything set up by {@link module:braintree-web/unionpay.create|create}. This only needs to be called when using UnionPay with Hosted Fields.
|
||||
@@ -1659,8 +1516,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* @returns {void}
|
||||
*/
|
||||
public teardown(callback?: callback): void;
|
||||
|
||||
teardown(callback?: callback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1683,21 +1539,6 @@ declare namespace BraintreeWeb {
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options See {@link module:braintree-web/us-bank-account.create|us-bank-account.create}.
|
||||
* @classdesc This class represents a US Bank Account component. Instances of this class can tokenize raw bank details or present a bank login. <strong>You cannot use this constructor directly. Use {@link module:braintree-web/us-bank-account.create|braintree.us-bank-account.create} instead.</strong>
|
||||
*/
|
||||
export class USBankAccount {
|
||||
/**
|
||||
* @class
|
||||
* @param {object} options See {@link module:braintree-web/us-bank-account.create|us-bank-account.create}.
|
||||
* @classdesc This class represents a US Bank Account component. Instances of this class can tokenize raw bank details or present a bank login. <strong>You cannot use this constructor directly. Use {@link module:braintree-web/us-bank-account.create|braintree.us-bank-account.create} instead.</strong>
|
||||
*/
|
||||
constructor(options: any)
|
||||
|
||||
|
||||
/**
|
||||
* Tokenizes bank information to return a payment method nonce. You can tokenize bank details by providing information like account and routing numbers. You can also tokenize with a bank login UI that prompts the customer to log into their bank account.
|
||||
@@ -1778,7 +1619,7 @@ declare namespace BraintreeWeb {
|
||||
* });
|
||||
* });
|
||||
*/
|
||||
public tokenize(options: { mandateText: string, bankDetails: any, bankLogin: any }, callback: callback): void;
|
||||
tokenize(options: { mandateText: string, bankDetails: any, bankLogin: any }, callback: callback): void;
|
||||
|
||||
/**
|
||||
* Cleanly tear down anything set up by {@link module:braintree-web/us-bank-account.create|create}.
|
||||
@@ -1786,77 +1627,53 @@ declare namespace BraintreeWeb {
|
||||
* @param {callback} [callback] Called once teardown is complete. No data is returned if teardown completes successfully.
|
||||
* @returns {void}
|
||||
*/
|
||||
public teardown(callback?: callback): void;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare namespace BraintreeError {
|
||||
/**
|
||||
* Enum for {@link BraintreeError} types.
|
||||
* @name BraintreeError.types
|
||||
* @enum
|
||||
* @readonly
|
||||
* @memberof BraintreeError
|
||||
* @property {string} CUSTOMER An error caused by the customer.
|
||||
* @property {string} MERCHANT An error that is actionable by the merchant.
|
||||
* @property {string} NETWORK An error due to a network problem.
|
||||
* @property {string} INTERNAL An error caused by Braintree code.
|
||||
* @property {string} UNKNOWN An error where the origin is unknown.
|
||||
*/
|
||||
export enum Types {
|
||||
CUSTOMER,
|
||||
MERCHANT,
|
||||
NETWORK,
|
||||
INTERNAL,
|
||||
UNKNOWN
|
||||
teardown(callback?: callback): void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @class
|
||||
* @global
|
||||
* @param {object} options Construction options
|
||||
* @classdesc This class is used to report error conditions, frequently as the first parameter to callbacks throughout the Braintree SDK.
|
||||
* @description <strong>You cannot use this constructor directly. Interact with instances of this class through {@link callback callbacks}.</strong>
|
||||
*/
|
||||
declare class BraintreeError {
|
||||
/**
|
||||
* @class
|
||||
* @global
|
||||
* @param {object} options Construction options
|
||||
* @classdesc This class is used to report error conditions, frequently as the first parameter to callbacks throughout the Braintree SDK.
|
||||
* @description <strong>You cannot use this constructor directly. Interact with instances of this class through {@link callback callbacks}.</strong>
|
||||
*/
|
||||
constructor(options: any);
|
||||
declare namespace braintree {
|
||||
export namespace BraintreeError {
|
||||
/**
|
||||
* Enum for {@link BraintreeError} types.
|
||||
* @name BraintreeError.types
|
||||
* @enum
|
||||
* @readonly
|
||||
* @memberof BraintreeError
|
||||
* @property {string} CUSTOMER An error caused by the customer.
|
||||
* @property {string} MERCHANT An error that is actionable by the merchant.
|
||||
* @property {string} NETWORK An error due to a network problem.
|
||||
* @property {string} INTERNAL An error caused by Braintree code.
|
||||
* @property {string} UNKNOWN An error where the origin is unknown.
|
||||
*/
|
||||
export type Types = "CUSTOMER" | "MERCHANT" | "NETWORK" | "INTERNAL" | "UNKNOWN";
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @description A code that corresponds to specific errors.
|
||||
*/
|
||||
code: string;
|
||||
export interface BraintreeError {
|
||||
/**
|
||||
* @type {string}
|
||||
* @description A code that corresponds to specific errors.
|
||||
*/
|
||||
code: string;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @description A short description of the error.
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
* @type {string}
|
||||
* @description A short description of the error.
|
||||
*/
|
||||
message: string;
|
||||
|
||||
/**
|
||||
* @type {BraintreeError.types}
|
||||
* @description The type of error.
|
||||
*/
|
||||
type: BraintreeError.Types;
|
||||
/**
|
||||
* @type {BraintreeError.types}
|
||||
* @description The type of error.
|
||||
*/
|
||||
type: BraintreeError.Types;
|
||||
|
||||
/**
|
||||
* @type {object=}
|
||||
* @description Additional information about the error, such as an underlying network error response.
|
||||
*/
|
||||
details: any;
|
||||
}
|
||||
/**
|
||||
* @type {object=}
|
||||
* @description Additional information about the error, such as an underlying network error response.
|
||||
*/
|
||||
details: any;
|
||||
}
|
||||
|
||||
declare namespace BraintreeWeb {
|
||||
/**
|
||||
* @global
|
||||
* @callback callback
|
||||
@@ -1895,39 +1712,40 @@ declare namespace BraintreeWeb {
|
||||
* braintreeClient.create(...);
|
||||
* });
|
||||
*/
|
||||
interface BraintreeStatic {
|
||||
declare namespace braintree {
|
||||
/** @type {module:braintree-web/client} */
|
||||
client: BraintreeWeb.Client;
|
||||
export var client: braintree.Client;
|
||||
|
||||
/** @type {module:braintree-web/paypal} */
|
||||
paypal: BraintreeWeb.PayPal;
|
||||
export var paypal: braintree.PayPal;
|
||||
|
||||
/** @type {module:braintree-web/hosted-fields} */
|
||||
hostedFields: BraintreeWeb.HostedFields;
|
||||
export var hostedFields: braintree.HostedFields;
|
||||
|
||||
/** @type {module:braintree-web/three-d-secure} */
|
||||
threeDSecure: BraintreeWeb.ThreeDSecure;
|
||||
export var threeDSecure: braintree.ThreeDSecure;
|
||||
|
||||
/** @type {module:braintree-web/data-collector} */
|
||||
dataCollector: BraintreeWeb.DataCollector;
|
||||
export var dataCollector: braintree.DataCollector;
|
||||
|
||||
/** @type {module:braintree-web/american-express} */
|
||||
americanExpress: BraintreeWeb.AmericanExpress;
|
||||
export var americanExpress: braintree.AmericanExpress;
|
||||
|
||||
/** @type {module:braintree-web/unionpay} */
|
||||
unionpay: BraintreeWeb.UnionPay;
|
||||
export var unionpay: braintree.UnionPay;
|
||||
|
||||
/** @type {module:braintree-web/apple-pay} */
|
||||
applePay: BraintreeWeb.ApplePay;
|
||||
export var applePay: braintree.ApplePay;
|
||||
|
||||
/** @type {module:braintree-web/us-bank-account} */
|
||||
usBankAccount: BraintreeWeb.USBankAccount;
|
||||
/** @type {module:braintree-web/us-bank-account} */
|
||||
export var usBankAccount: braintree.USBankAccount;
|
||||
|
||||
/**
|
||||
* @description The current version of the SDK, i.e. `3.0.2`.
|
||||
* @type {string}
|
||||
*/
|
||||
VERSION: string;
|
||||
export var VERSION: string;
|
||||
}
|
||||
|
||||
declare var braintree: BraintreeStatic;
|
||||
export = braintree;
|
||||
export as namespace braintree;
|
||||
|
||||
@@ -0,0 +1,440 @@
|
||||
import * as braintree from 'braintree-web';
|
||||
|
||||
let version: string = braintree.VERSION;
|
||||
|
||||
let clientToken: string = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiOiI0YjlhYzVmYmI4ZTNkYzQzMmFkZjJhNzBlNjZlMWNjY2M5ODRkYzE4ZTM4YmY4NjYzZTM5NjM3NWZjYmQzY2U5fGNyZWF0ZWRfYXQ9MjAxNi0wOS0wOFQwNTowMzo0MC4xNjk1NTUwMzUrMDAwMFx1MDAyNm1lcmNoYW50X2lkPTM0OHBrOWNnZjNiZ3l3MmJcdTAwMjZwdWJsaWNfa2V5PTJuMjQ3ZHY4OWJxOXZtcHIiLCJjb25maWdVcmwiOiJodHRwczovL2FwaS5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tOjQ0My9tZXJjaGFudHMvMzQ4cGs5Y2dmM2JneXcyYi9jbGllbnRfYXBpL3YxL2NvbmZpZ3VyYXRpb24iLCJjaGFsbGVuZ2VzIjpbXSwiZW52aXJvbm1lbnQiOiJzYW5kYm94IiwiY2xpZW50QXBpVXJsIjoiaHR0cHM6Ly9hcGkuc2FuZGJveC5icmFpbnRyZWVnYXRld2F5LmNvbTo0NDMvbWVyY2hhbnRzLzM0OHBrOWNnZjNiZ3l3MmIvY2xpZW50X2FwaSIsImFzc2V0c1VybCI6Imh0dHBzOi8vYXNzZXRzLmJyYWludHJlZWdhdGV3YXkuY29tIiwiYXV0aFVybCI6Imh0dHBzOi8vYXV0aC52ZW5tby5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tIiwiYW5hbHl0aWNzIjp7InVybCI6Imh0dHBzOi8vY2xpZW50LWFuYWx5dGljcy5zYW5kYm94LmJyYWludHJlZWdhdGV3YXkuY29tLzM0OHBrOWNnZjNiZ3l3MmIifSwidGhyZWVEU2VjdXJlRW5hYmxlZCI6dHJ1ZSwicGF5cGFsRW5hYmxlZCI6dHJ1ZSwicGF5cGFsIjp7ImRpc3BsYXlOYW1lIjoiQWNtZSBXaWRnZXRzLCBMdGQuIChTYW5kYm94KSIsImNsaWVudElkIjpudWxsLCJwcml2YWN5VXJsIjoiaHR0cDovL2V4YW1wbGUuY29tL3BwIiwidXNlckFncmVlbWVudFVybCI6Imh0dHA6Ly9leGFtcGxlLmNvbS90b3MiLCJiYXNlVXJsIjoiaHR0cHM6Ly9hc3NldHMuYnJhaW50cmVlZ2F0ZXdheS5jb20iLCJhc3NldHNVcmwiOiJodHRwczovL2NoZWNrb3V0LnBheXBhbC5jb20iLCJkaXJlY3RCYXNlVXJsIjpudWxsLCJhbGxvd0h0dHAiOnRydWUsImVudmlyb25tZW50Tm9OZXR3b3JrIjp0cnVlLCJlbnZpcm9ubWVudCI6Im9mZmxpbmUiLCJ1bnZldHRlZE1lcmNoYW50IjpmYWxzZSwiYnJhaW50cmVlQ2xpZW50SWQiOiJtYXN0ZXJjbGllbnQzIiwiYmlsbGluZ0FncmVlbWVudHNFbmFibGVkIjp0cnVlLCJtZXJjaGFudEFjY291bnRJZCI6ImFjbWV3aWRnZXRzbHRkc2FuZGJveCIsImN1cnJlbmN5SXNvQ29kZSI6IlVTRCJ9LCJjb2luYmFzZUVuYWJsZWQiOmZhbHNlLCJtZXJjaGFudElkIjoiMzQ4cGs5Y2dmM2JneXcyYiIsInZlbm1vIjoib2ZmIn0=";
|
||||
|
||||
braintree.client.create({
|
||||
authorization: clientToken
|
||||
}, function (error: braintree.BraintreeError, clientInstance: any) {
|
||||
|
||||
var form: HTMLFormElement = document.getElementById('my-form-id') as HTMLFormElement;
|
||||
var data: { creditCard: braintree.CreditCardInfo } = {
|
||||
creditCard: {
|
||||
number: form['cc-number'].value,
|
||||
cvv: form['cc-cvv'].value,
|
||||
expirationDate: form['cc-date'].value,
|
||||
billingAddress: {
|
||||
postalCode: form['cc-postal'].value
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
clientInstance.request({
|
||||
endpoint: 'payment_methods/credit_cards',
|
||||
method: 'post',
|
||||
data: data
|
||||
}, function (requestErr: braintree.BraintreeError, response: { creditCards: any[]; }) {
|
||||
if (requestErr) { throw new Error(requestErr.message); }
|
||||
|
||||
console.log('Got nonce:', response.creditCards[0].nonce);
|
||||
});
|
||||
|
||||
braintree.hostedFields.create({
|
||||
client: clientInstance,
|
||||
styles: {
|
||||
'input': {
|
||||
'font-size': '16pt',
|
||||
'color': '#3A3A3A'
|
||||
},
|
||||
|
||||
'.number': {
|
||||
'font-family': 'monospace'
|
||||
},
|
||||
'.valid': {
|
||||
'color': 'green'
|
||||
}
|
||||
},
|
||||
fields: {
|
||||
number: {
|
||||
selector: '#card-number'
|
||||
},
|
||||
cvv: {
|
||||
selector: '#cvv',
|
||||
type: 'password'
|
||||
},
|
||||
expirationMonth: {
|
||||
selector: '#expiration-month',
|
||||
select: {
|
||||
options: ["01 - Jan", "02 - Feb", "03 - Mar", "04 - Apr", "05 - May", "06 - Jun", "07 - Jul", "08 - Aug", "09 - Sep", "10 - Oct", "11 - Nov", "12 - Dec"]
|
||||
}
|
||||
},
|
||||
expirationYear: {
|
||||
selector: '#expiration-year',
|
||||
select: true
|
||||
}
|
||||
}
|
||||
}, function (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: any) {
|
||||
|
||||
if (hostedFieldsErr) {
|
||||
// Handle error in Hosted Fields creation
|
||||
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let form = new HTMLFormElement();
|
||||
|
||||
form.addEventListener('submit', function (event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
hostedFieldsInstance.tokenize(function (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
// Handle error in Hosted Fields tokenization
|
||||
switch (tokenizeErr.code) {
|
||||
case 'HOSTED_FIELDS_FIELDS_EMPTY':
|
||||
console.error('All fields are empty! Please fill out the form.');
|
||||
break;
|
||||
case 'HOSTED_FIELDS_FIELDS_INVALID':
|
||||
console.error('Some fields are invalid:', tokenizeErr.details.invalidFieldKeys);
|
||||
break;
|
||||
case 'HOSTED_FIELDS_FAILED_TOKENIZATION':
|
||||
console.error('Tokenization failed server side. Is the card valid?');
|
||||
break;
|
||||
case 'HOSTED_FIELDS_TOKENIZATION_NETWORK_ERROR':
|
||||
console.error('Network error occurred when tokenizing.');
|
||||
break;
|
||||
default:
|
||||
console.error('Something bad happened!', tokenizeErr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Put `payload.nonce` into the `payment-method-nonce` input, and then
|
||||
// submit the form. Alternatively, you could send the nonce to your server
|
||||
// with AJAX.
|
||||
(document.querySelector('input[name="payment-method-nonce"]') as HTMLInputElement).value = payload.nonce;
|
||||
form.submit();
|
||||
});
|
||||
}, false);
|
||||
|
||||
hostedFieldsInstance.on('focus', function (event: braintree.HostedFieldsStateObject) {
|
||||
console.log(event.emittedBy, 'has been focused');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.teardown(function (teardownErr: braintree.BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down Hosted Fields!');
|
||||
} else {
|
||||
console.info('Hosted Fields has been torn down!');
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.tokenize({
|
||||
vault: true
|
||||
}, function (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
} else {
|
||||
console.log('Got nonce:', payload.nonce);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: braintree.BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: braintree.BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
return;
|
||||
}
|
||||
|
||||
// some time later...
|
||||
hostedFieldsInstance.removeClass('number', 'custom-class');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (placeholderErr: braintree.BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
console.error(placeholderErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.on('cardTypeChange', function (event: braintree.HostedFieldsStateObject) {
|
||||
// Update the placeholder value if there is only one possible card type
|
||||
if (event.cards.length === 1) {
|
||||
braintree.hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (placeholderErr: braintree.BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
// Handle errors, such as invalid field name
|
||||
console.error(placeholderErr);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.clear('number', function (clearErr: braintree.BraintreeError) {
|
||||
if (clearErr) {
|
||||
console.error(clearErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.clear('number');
|
||||
hostedFieldsInstance.clear('cvv');
|
||||
hostedFieldsInstance.clear('expirationDate');
|
||||
|
||||
var state = braintree.hostedFields.getState();
|
||||
|
||||
var formValid = Object.keys(state.fields).every(function (key) {
|
||||
return state.fields[key].isValid;
|
||||
});
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr?: braintree.BraintreeError, applePayInstance?: any) {
|
||||
if (createErr) {
|
||||
// Handle error in client creation
|
||||
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var paymentRequest = braintree.applePay.createPaymentRequest(request);
|
||||
|
||||
console.log(paymentRequest);
|
||||
// { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] }
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr, applePayInstance) {
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new braintree.ApplePaySession(1, request);
|
||||
|
||||
session.onvalidatemerchant = function (event: { validationURL: string }) {
|
||||
braintree.applePay.performValidation({
|
||||
validationURL: event.validationURL
|
||||
}, function (err, validationData) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
session.abort();
|
||||
return;
|
||||
}
|
||||
session.completeMerchantValidation(validationData);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr, applePayInstance) {
|
||||
let request = {
|
||||
countryCode: 'US',
|
||||
currencyCode: 'USD',
|
||||
supportedNetworks: ['visa', 'masterCard'],
|
||||
merchantCapabilities: ['supports3DS'],
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new braintree.ApplePaySession(1, request);
|
||||
|
||||
session.onpaymentauthorized = function (event) {
|
||||
braintree.applePay.tokenize({
|
||||
token: event.payment.token
|
||||
}, function (err, tokenizedPayload) {
|
||||
if (err) {
|
||||
session.completePayment(braintree.ApplePayStatusCodes.STATUS_FAILURE);
|
||||
return;
|
||||
}
|
||||
session.completePayment(braintree.ApplePayStatusCodes.STATUS_SUCCESS);
|
||||
|
||||
// Send the tokenizedPayload to your server.
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
braintree.paypal.create({
|
||||
client: clientInstance
|
||||
}, function (createErr, paypalInstance) {
|
||||
if (createErr) {
|
||||
if (createErr.code === 'PAYPAL_BROWSER_NOT_SUPPORTED') {
|
||||
console.error('This browser is not supported.');
|
||||
} else {
|
||||
console.error('Error!', createErr);
|
||||
}
|
||||
}
|
||||
|
||||
let button = new HTMLButtonElement();
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
// Disable the button so that we don't attempt to open multiple popups.
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
|
||||
// Because PayPal tokenization opens a popup, this must be called
|
||||
// as a result of a user action, such as a button click.
|
||||
paypalInstance.tokenize({
|
||||
flow: 'vault' // Required
|
||||
// Any other tokenization options
|
||||
}, function (tokenizeErr: braintree.BraintreeError, payload: braintree.PayPalTokenizePayload) {
|
||||
button.removeAttribute('disabled');
|
||||
|
||||
if (tokenizeErr) {
|
||||
// Handle tokenization errors or premature flow closure
|
||||
|
||||
switch (tokenizeErr.code) {
|
||||
case 'PAYPAL_POPUP_CLOSED':
|
||||
console.error('Customer closed PayPal popup.');
|
||||
break;
|
||||
case 'PAYPAL_ACCOUNT_TOKENIZATION_FAILED':
|
||||
console.error('PayPal tokenization failed. See details:', tokenizeErr.details);
|
||||
break;
|
||||
case 'PAYPAL_FLOW_FAILED':
|
||||
console.error('Unable to initialize PayPal flow. Are your options correct?', tokenizeErr.details);
|
||||
break;
|
||||
default:
|
||||
console.error('Error!', tokenizeErr);
|
||||
}
|
||||
} else {
|
||||
// Submit payload.nonce to your server
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
braintree.unionpay.create({ client: clientInstance }, function (createErr, unionpayInstance) {
|
||||
if (createErr) {
|
||||
console.error(createErr);
|
||||
return;
|
||||
}
|
||||
|
||||
unionpayInstance.fetchCapabilities({
|
||||
card: {
|
||||
number: '4111111111111111'
|
||||
}
|
||||
}, function (fetchErr: braintree.BraintreeError, cardCapabilities: braintree.UnionPayFetchCapabilitiesPayload) {
|
||||
if (fetchErr) {
|
||||
console.error(fetchErr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardCapabilities.isUnionPay) {
|
||||
if (cardCapabilities.unionPay && !cardCapabilities.unionPay.isSupported) {
|
||||
// Braintree cannot process this UnionPay card.
|
||||
// Ask the user for a different card.
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardCapabilities.isDebit) {
|
||||
// CVV and expiration date are not required
|
||||
} else {
|
||||
// CVV and expiration date are required
|
||||
}
|
||||
|
||||
// Show mobile phone number field for enrollment
|
||||
}
|
||||
});
|
||||
|
||||
unionpayInstance.enroll({
|
||||
card: {
|
||||
number: '4111111111111111',
|
||||
expirationMonth: '12',
|
||||
expirationYear: '2038'
|
||||
},
|
||||
mobile: {
|
||||
countryCode: '62',
|
||||
number: '111111111111'
|
||||
}
|
||||
}, function (enrollErr: braintree.BraintreeError, response: braintree.UnionPayEnrollPayload) {
|
||||
if (enrollErr) {
|
||||
console.error(enrollErr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.smsCodeRequired) {
|
||||
// If smsCodeRequired, wait for SMS auth code from customer
|
||||
// Then use response.enrollmentId during {@link UnionPay#tokenize}
|
||||
} else {
|
||||
// SMS code is not required from the user.
|
||||
// {@link UnionPay#tokenize} can be called immediately
|
||||
}
|
||||
});
|
||||
|
||||
let enrollResponse: {
|
||||
enrollmentId: string
|
||||
};
|
||||
|
||||
unionpayInstance.tokenize({
|
||||
card: {
|
||||
number: '4111111111111111',
|
||||
expirationMonth: '12',
|
||||
expirationYear: '2038',
|
||||
cvv: '123'
|
||||
},
|
||||
enrollmentId: enrollResponse.enrollmentId, // Returned from enroll
|
||||
smsCode: '11111' // Received by customer's phone, if SMS enrollment was required. Otherwise it should be omitted
|
||||
}, function (tokenizeErr: braintree.BraintreeError, response: braintree.UnionPayTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send response.nonce to your server
|
||||
});
|
||||
|
||||
unionpayInstance.teardown(function (teardownErr: braintree.BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down UnionPay.');
|
||||
} else {
|
||||
console.log('UnionPay has been torn down.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
let existingNonce = "fake-valid-nonce";
|
||||
let submitNonceToServer: (nonce: string) => void;
|
||||
|
||||
braintree.threeDSecure.verifyCard({
|
||||
nonce: existingNonce,
|
||||
amount: 123.45,
|
||||
addFrame: function (err, iframe) {
|
||||
// Set up your UI and add the iframe.
|
||||
let my3DSContainer = document.createElement('div');
|
||||
my3DSContainer.appendChild(iframe);
|
||||
document.body.appendChild(my3DSContainer);
|
||||
},
|
||||
removeFrame: function () {
|
||||
let my3DSContainer = document.createElement('div');
|
||||
|
||||
// Remove UI that you added in addFrame.
|
||||
document.body.removeChild(my3DSContainer);
|
||||
}
|
||||
}, function (err: braintree.BraintreeError, payload: braintree.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (payload.liabilityShifted) {
|
||||
// Liablity has shifted
|
||||
submitNonceToServer(payload.nonce);
|
||||
} else if (payload.liabilityShiftPossible) {
|
||||
// Liablity may still be shifted
|
||||
// Decide if you want to submit the nonce
|
||||
} else {
|
||||
// Liablity has not shifted and will not shift
|
||||
// Decide if you want to submit the nonce
|
||||
}
|
||||
});
|
||||
|
||||
braintree.threeDSecure.cancelVerifyCard(function (err: braintree.BraintreeError, verifyPayload: braintree.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
// Handle error
|
||||
console.log(err.message); // No verification payload available
|
||||
return;
|
||||
}
|
||||
|
||||
verifyPayload.nonce; // The nonce returned from the 3ds lookup call
|
||||
verifyPayload.liabilityShifted; // boolean
|
||||
verifyPayload.liabilityShiftPossible; // boolean
|
||||
});
|
||||
@@ -4,10 +4,10 @@ let clientToken: string = "eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmluZ2VycHJpbnQiO
|
||||
|
||||
braintree.client.create({
|
||||
authorization: clientToken
|
||||
}, function (error: BraintreeError, clientInstance: any) {
|
||||
}, function (error: braintree.BraintreeError, clientInstance: any) {
|
||||
|
||||
var form: HTMLFormElement = document.getElementById('my-form-id') as HTMLFormElement;
|
||||
var data: { creditCard: BraintreeWeb.CreditCardInfo } = {
|
||||
var data: { creditCard: braintree.CreditCardInfo } = {
|
||||
creditCard: {
|
||||
number: form['cc-number'].value,
|
||||
cvv: form['cc-cvv'].value,
|
||||
@@ -22,7 +22,7 @@ braintree.client.create({
|
||||
endpoint: 'payment_methods/credit_cards',
|
||||
method: 'post',
|
||||
data: data
|
||||
}, function (requestErr: BraintreeError, response: { creditCards: any[]; }) {
|
||||
}, function (requestErr: braintree.BraintreeError, response: { creditCards: any[]; }) {
|
||||
if (requestErr) { throw new Error(requestErr.message); }
|
||||
|
||||
console.log('Got nonce:', response.creditCards[0].nonce);
|
||||
@@ -62,7 +62,7 @@ braintree.client.create({
|
||||
select: true
|
||||
}
|
||||
}
|
||||
}, function (hostedFieldsErr?: BraintreeError, hostedFieldsInstance?: any) {
|
||||
}, function (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: any) {
|
||||
|
||||
if (hostedFieldsErr) {
|
||||
// Handle error in Hosted Fields creation
|
||||
@@ -75,7 +75,7 @@ braintree.client.create({
|
||||
form.addEventListener('submit', function (event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
hostedFieldsInstance.tokenize(function (tokenizeErr: BraintreeError, payload: BraintreeWeb.HostedFieldsTokenizePayload) {
|
||||
hostedFieldsInstance.tokenize(function (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
// Handle error in Hosted Fields tokenization
|
||||
switch (tokenizeErr.code) {
|
||||
@@ -105,11 +105,11 @@ braintree.client.create({
|
||||
});
|
||||
}, false);
|
||||
|
||||
hostedFieldsInstance.on('focus', function (event: BraintreeWeb.HostedFieldsStateObject) {
|
||||
hostedFieldsInstance.on('focus', function (event: braintree.HostedFieldsStateObject) {
|
||||
console.log(event.emittedBy, 'has been focused');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.teardown(function (teardownErr: BraintreeError) {
|
||||
hostedFieldsInstance.teardown(function (teardownErr: braintree.BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down Hosted Fields!');
|
||||
} else {
|
||||
@@ -119,7 +119,7 @@ braintree.client.create({
|
||||
|
||||
hostedFieldsInstance.tokenize({
|
||||
vault: true
|
||||
}, function (tokenizeErr: BraintreeError, payload: BraintreeWeb.HostedFieldsTokenizePayload) {
|
||||
}, function (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
} else {
|
||||
@@ -127,13 +127,13 @@ braintree.client.create({
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: BraintreeError) {
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: braintree.BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: BraintreeError) {
|
||||
hostedFieldsInstance.addClass('number', 'custom-class', function (addClassErr: braintree.BraintreeError) {
|
||||
if (addClassErr) {
|
||||
console.error(addClassErr);
|
||||
return;
|
||||
@@ -143,16 +143,16 @@ braintree.client.create({
|
||||
hostedFieldsInstance.removeClass('number', 'custom-class');
|
||||
});
|
||||
|
||||
hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (placeholderErr: BraintreeError) {
|
||||
hostedFieldsInstance.setPlaceholder('number', '4111 1111 1111 1111', function (placeholderErr: braintree.BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
console.error(placeholderErr);
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.on('cardTypeChange', function (event: BraintreeWeb.HostedFieldsStateObject) {
|
||||
hostedFieldsInstance.on('cardTypeChange', function (event: braintree.HostedFieldsStateObject) {
|
||||
// Update the placeholder value if there is only one possible card type
|
||||
if (event.cards.length === 1) {
|
||||
braintree.hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (placeholderErr: BraintreeError) {
|
||||
braintree.hostedFields.setPlaceholder('cvv', event.cards[0].code.name, function (placeholderErr: braintree.BraintreeError) {
|
||||
if (placeholderErr) {
|
||||
// Handle errors, such as invalid field name
|
||||
console.error(placeholderErr);
|
||||
@@ -161,7 +161,7 @@ braintree.client.create({
|
||||
}
|
||||
});
|
||||
|
||||
hostedFieldsInstance.clear('number', function (clearErr: BraintreeError) {
|
||||
hostedFieldsInstance.clear('number', function (clearErr: braintree.BraintreeError) {
|
||||
if (clearErr) {
|
||||
console.error(clearErr);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ braintree.client.create({
|
||||
});
|
||||
});
|
||||
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr?: BraintreeError, applePayInstance?: any) {
|
||||
braintree.applePay.create({ client: clientInstance }, function (createErr?: braintree.BraintreeError, applePayInstance?: any) {
|
||||
if (createErr) {
|
||||
// Handle error in client creation
|
||||
console.log(`Error Code: ${error.code}, Type: ${error.type}, Message: ${error.message}, Details: ${error.details}`);
|
||||
@@ -209,7 +209,7 @@ braintree.client.create({
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new ApplePaySession(1, request);
|
||||
var session = new braintree.ApplePaySession(1, request);
|
||||
|
||||
session.onvalidatemerchant = function (event: { validationURL: string }) {
|
||||
braintree.applePay.performValidation({
|
||||
@@ -234,17 +234,17 @@ braintree.client.create({
|
||||
total: { label: 'Your Label', amount: '10.00' },
|
||||
};
|
||||
|
||||
var session = new ApplePaySession(1, request);
|
||||
var session = new braintree.ApplePaySession(1, request);
|
||||
|
||||
session.onpaymentauthorized = function (event) {
|
||||
braintree.applePay.tokenize({
|
||||
token: event.payment.token
|
||||
}, function (err, tokenizedPayload) {
|
||||
if (err) {
|
||||
session.completePayment(ApplePayStatusCodes.STATUS_FAILURE);
|
||||
session.completePayment(braintree.ApplePayStatusCodes.STATUS_FAILURE);
|
||||
return;
|
||||
}
|
||||
session.completePayment(ApplePayStatusCodes.STATUS_SUCCESS);
|
||||
session.completePayment(braintree.ApplePayStatusCodes.STATUS_SUCCESS);
|
||||
|
||||
// Send the tokenizedPayload to your server.
|
||||
});
|
||||
@@ -273,7 +273,7 @@ braintree.client.create({
|
||||
paypalInstance.tokenize({
|
||||
flow: 'vault' // Required
|
||||
// Any other tokenization options
|
||||
}, function (tokenizeErr: BraintreeError, payload: BraintreeWeb.PayPalTokenizePayload) {
|
||||
}, function (tokenizeErr: braintree.BraintreeError, payload: braintree.PayPalTokenizePayload) {
|
||||
button.removeAttribute('disabled');
|
||||
|
||||
if (tokenizeErr) {
|
||||
@@ -309,7 +309,7 @@ braintree.client.create({
|
||||
card: {
|
||||
number: '4111111111111111'
|
||||
}
|
||||
}, function (fetchErr: BraintreeError, cardCapabilities: BraintreeWeb.UnionPayFetchCapabilitiesPayload) {
|
||||
}, function (fetchErr: braintree.BraintreeError, cardCapabilities: braintree.UnionPayFetchCapabilitiesPayload) {
|
||||
if (fetchErr) {
|
||||
console.error(fetchErr);
|
||||
return;
|
||||
@@ -342,7 +342,7 @@ braintree.client.create({
|
||||
countryCode: '62',
|
||||
number: '111111111111'
|
||||
}
|
||||
}, function (enrollErr: BraintreeError, response: BraintreeWeb.UnionPayEnrollPayload) {
|
||||
}, function (enrollErr: braintree.BraintreeError, response: braintree.UnionPayEnrollPayload) {
|
||||
if (enrollErr) {
|
||||
console.error(enrollErr);
|
||||
return;
|
||||
@@ -370,7 +370,7 @@ braintree.client.create({
|
||||
},
|
||||
enrollmentId: enrollResponse.enrollmentId, // Returned from enroll
|
||||
smsCode: '11111' // Received by customer's phone, if SMS enrollment was required. Otherwise it should be omitted
|
||||
}, function (tokenizeErr: BraintreeError, response: BraintreeWeb.UnionPayTokenizePayload) {
|
||||
}, function (tokenizeErr: braintree.BraintreeError, response: braintree.UnionPayTokenizePayload) {
|
||||
if (tokenizeErr) {
|
||||
console.error(tokenizeErr);
|
||||
return;
|
||||
@@ -379,7 +379,7 @@ braintree.client.create({
|
||||
// Send response.nonce to your server
|
||||
});
|
||||
|
||||
unionpayInstance.teardown(function (teardownErr: BraintreeError) {
|
||||
unionpayInstance.teardown(function (teardownErr: braintree.BraintreeError) {
|
||||
if (teardownErr) {
|
||||
console.error('Could not tear down UnionPay.');
|
||||
} else {
|
||||
@@ -407,7 +407,7 @@ braintree.threeDSecure.verifyCard({
|
||||
// Remove UI that you added in addFrame.
|
||||
document.body.removeChild(my3DSContainer);
|
||||
}
|
||||
}, function (err: BraintreeError, payload: BraintreeWeb.ThreeDSecureVerifyPayload) {
|
||||
}, function (err: braintree.BraintreeError, payload: braintree.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
@@ -425,7 +425,7 @@ braintree.threeDSecure.verifyCard({
|
||||
}
|
||||
});
|
||||
|
||||
braintree.threeDSecure.cancelVerifyCard(function (err: BraintreeError, verifyPayload: BraintreeWeb.ThreeDSecureVerifyPayload) {
|
||||
braintree.threeDSecure.cancelVerifyCard(function (err: braintree.BraintreeError, verifyPayload: braintree.ThreeDSecureVerifyPayload) {
|
||||
if (err) {
|
||||
// Handle error
|
||||
console.log(err.message); // No verification payload available
|
||||
@@ -435,4 +435,4 @@ braintree.threeDSecure.cancelVerifyCard(function (err: BraintreeError, verifyPay
|
||||
verifyPayload.nonce; // The nonce returned from the 3ds lookup call
|
||||
verifyPayload.liabilityShifted; // boolean
|
||||
verifyPayload.liabilityShiftPossible; // boolean
|
||||
});
|
||||
});
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"braintree-web-tests.ts"
|
||||
"test/web.ts",
|
||||
"test/node.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ const c = new Croppie(document.getElementById('item'), {
|
||||
enableOrientation: false,
|
||||
});
|
||||
|
||||
|
||||
c.bind({
|
||||
url: 'demo/demo-2.jpg',
|
||||
orientation: 4,
|
||||
|
||||
Vendored
-1
@@ -27,7 +27,6 @@ export default class Croppie {
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
|
||||
export type CropType = 'square' | 'circle';
|
||||
|
||||
export type Format = 'jpeg' | 'png' | 'webp';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Dragster = require("dragster");
|
||||
|
||||
var dropzone = document.getElementById("my-dropzone") as HTMLElement;
|
||||
var dragster = new Dragster(dropzone);
|
||||
const dropzone = document.getElementById("my-dropzone") as HTMLElement;
|
||||
const dragster = new Dragster(dropzone);
|
||||
|
||||
dragster.removeListeners();
|
||||
dragster.reset();
|
||||
dragster.reset();
|
||||
|
||||
Vendored
+1
-1
@@ -20,4 +20,4 @@ declare var Dragster: Dragster.DragsterStatic;
|
||||
export = Dragster;
|
||||
|
||||
// Support as a global
|
||||
export as namespace Dragster;
|
||||
export as namespace Dragster;
|
||||
|
||||
@@ -32,7 +32,8 @@ describe('createSpy', () => {
|
||||
});
|
||||
|
||||
describe('A spy', () => {
|
||||
let targetContext: any, targetArguments: any;
|
||||
let targetContext: any;
|
||||
let targetArguments: any;
|
||||
const target = {
|
||||
method() {
|
||||
targetContext = this;
|
||||
@@ -88,7 +89,8 @@ describe('A spy', () => {
|
||||
});
|
||||
|
||||
describe('that calls some other function', () => {
|
||||
let otherContext: any, otherArguments: any;
|
||||
let otherContext: any;
|
||||
let otherArguments: any;
|
||||
function otherFn() {
|
||||
otherContext = this;
|
||||
otherArguments = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
import isRoot = require('is-root');
|
||||
|
||||
isRoot();
|
||||
// => true
|
||||
// => true
|
||||
|
||||
Vendored
+1
-1
@@ -12,4 +12,4 @@ export interface Configuration {
|
||||
|
||||
export function init(element: string, config: Configuration): void;
|
||||
|
||||
export as namespace ityped;
|
||||
export as namespace ityped;
|
||||
|
||||
@@ -15,4 +15,4 @@ init("#anotherSelector", {
|
||||
loop: false
|
||||
});
|
||||
|
||||
init("#anotherOne", {});
|
||||
init("#anotherOne", {});
|
||||
|
||||
Vendored
-1
@@ -50,7 +50,6 @@ declare namespace jimp {
|
||||
}
|
||||
} | PresetFont;
|
||||
|
||||
|
||||
class JimpImage {
|
||||
constructor(width: number, height: number, callback?: Callback<JimpImage>);
|
||||
constructor(width: number, height: number, initialColor: number, callback?: Callback<JimpImage>);
|
||||
|
||||
+38
-40
@@ -36,20 +36,20 @@ Jimp.read("http://www.example.com/path/to/lenna.jpg", (err, image) => {
|
||||
// do stuff with the image (if no exception)
|
||||
});
|
||||
|
||||
var image = new Jimp(1, 2);
|
||||
var w = 0;
|
||||
var h = 0;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var f = 0;
|
||||
var src = '';
|
||||
var horz = Jimp.HORIZONTAL_ALIGN_CENTER;
|
||||
var vert = Jimp.VERTICAL_ALIGN_BOTTOM;
|
||||
var deg = 90;
|
||||
var val = 0.5;
|
||||
var hex = 0xFFFFFFFF;
|
||||
var r = 0;
|
||||
var n = 1;
|
||||
let image = new Jimp(1, 2);
|
||||
const w = 0;
|
||||
const h = 0;
|
||||
const x = 0;
|
||||
const y = 0;
|
||||
const f = 0;
|
||||
const src = '';
|
||||
const horz = Jimp.HORIZONTAL_ALIGN_CENTER;
|
||||
const vert = Jimp.VERTICAL_ALIGN_BOTTOM;
|
||||
const deg = 90;
|
||||
const val = 0.5;
|
||||
const hex = 0xFFFFFFFF;
|
||||
const r = 0;
|
||||
const n = 1;
|
||||
/* Resize */
|
||||
image.contain(w, h); // scale the image to the given width and height, some parts of the image may be letter boxed
|
||||
image.cover(w, h); // scale the image to the given width and height, some parts of the image may be clipped
|
||||
@@ -112,15 +112,15 @@ image.resize(250, 250, Jimp.RESIZE_BEZIER);
|
||||
|
||||
image.contain(250, 250, Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP);
|
||||
|
||||
var path = '';
|
||||
var str = '';
|
||||
var width = 0;
|
||||
const path = '';
|
||||
const str = '';
|
||||
const width = 0;
|
||||
Jimp.loadFont(path).then(font => { // load font from .fnt file
|
||||
image.print(font, x, y, str); // print a message on an image
|
||||
image.print(font, x, y, str, width); // print a message on an image with text wrapped at width
|
||||
});
|
||||
|
||||
var cb = (err: Error, data: any) => {};
|
||||
const cb = (err: Error, data: any) => {};
|
||||
Jimp.loadFont(path, cb); // using a callback pattern
|
||||
|
||||
Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => {
|
||||
@@ -129,17 +129,16 @@ Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => {
|
||||
|
||||
image.write(path, cb); // Node-style callback will be fired when write is successful
|
||||
|
||||
var file = "new_name." + image.getExtension();
|
||||
const file = "new_name." + image.getExtension();
|
||||
image.write(file);
|
||||
|
||||
|
||||
var mime = 'image/png';
|
||||
const mime = 'image/png';
|
||||
image.getBuffer(mime, cb); // Node-style callback will be fired with result
|
||||
image.getBase64(mime, cb); // Node-style callback will be fired with result
|
||||
image.quality(n); // set the quality of saved JPEG, 0 - 100
|
||||
|
||||
var bool = true;
|
||||
var number = 0;
|
||||
const bool = true;
|
||||
const number = 0;
|
||||
image.rgba(bool); // set whether PNGs are saved as RGBA (true, default) or RGB (false)
|
||||
image.filterType(number); // set the filter type for the saved PNG
|
||||
image.deflateLevel(number); // set the deflate level for the saved PNG
|
||||
@@ -160,10 +159,10 @@ image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) {
|
||||
// idx is the position start position of this rgba tuple in the bitmap Buffer
|
||||
// this is the image
|
||||
|
||||
var red = this.bitmap.data[ idx + 0 ];
|
||||
var green = this.bitmap.data[ idx + 1 ];
|
||||
var blue = this.bitmap.data[ idx + 2 ];
|
||||
var alpha = this.bitmap.data[ idx + 3 ];
|
||||
const red = this.bitmap.data[ idx + 0 ];
|
||||
const green = this.bitmap.data[ idx + 1 ];
|
||||
const blue = this.bitmap.data[ idx + 2 ];
|
||||
const alpha = this.bitmap.data[ idx + 3 ];
|
||||
|
||||
// rgba values run from 0 - 255
|
||||
// e.g. this.bitmap.data[idx] = 0; // removes red from this pixel
|
||||
@@ -171,35 +170,34 @@ image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) {
|
||||
image.getPixelColor(x, y); // returns the colour of that pixel e.g. 0xFFFFFFFF
|
||||
image.setPixelColor(hex, x, y); // sets the colour of that pixel
|
||||
|
||||
var g = 0;
|
||||
var b = 0;
|
||||
var a = 0;
|
||||
const g = 0;
|
||||
const b = 0;
|
||||
const a = 0;
|
||||
Jimp.rgbaToInt(r, g, b, a); // e.g. converts 255, 255, 255, 255 to 0xFFFFFFFF
|
||||
Jimp.intToRGBA(hex); // e.g. converts 0xFFFFFFFF to {r: 255, g: 255, b: 255, a:255}
|
||||
|
||||
var image = new Jimp(256, 256, (err, image) => {
|
||||
image = new Jimp(256, 256, (err, image) => {
|
||||
// this image is 256 x 256, every pixel is set to 0x00000000
|
||||
});
|
||||
|
||||
var image = new Jimp(256, 256, 0xFF0000FF, (err, image) => {
|
||||
image = new Jimp(256, 256, 0xFF0000FF, (err, image) => {
|
||||
// this image is 256 x 256, every pixel is set to 0xFF0000FF
|
||||
});
|
||||
|
||||
image.hash(); // aHgG4GgoFjA
|
||||
image.hash(2); // 1010101011010000101010000100101010010000011001001001010011100100
|
||||
|
||||
var image1 = new Jimp(0, 1);
|
||||
var image2 = new Jimp(0, 1);
|
||||
const image1 = new Jimp(0, 1);
|
||||
const image2 = new Jimp(0, 1);
|
||||
Jimp.distance(image1, image2); // returns a number 0-1, where 0 means the two images are perceived to be identical
|
||||
|
||||
var threshold = 0;
|
||||
var diff = Jimp.diff(image1, image2, threshold); // threshold ranges 0-1 (default: 0.1)
|
||||
const threshold = 0;
|
||||
let diff = Jimp.diff(image1, image2, threshold); // threshold ranges 0-1 (default: 0.1)
|
||||
diff.image; // a Jimp image showing differences
|
||||
diff.percent; // the proportion of different pixels (0-1), where 0 means the images are pixel identical
|
||||
|
||||
|
||||
var distance = Jimp.distance(image, image2); // perceived distance
|
||||
var diff = Jimp.diff(image, image2); // pixel difference
|
||||
const distance = Jimp.distance(image, image2); // perceived distance
|
||||
diff = Jimp.diff(image, image2); // pixel difference
|
||||
|
||||
if (distance < 0.15 || diff.percent < 0.15) {
|
||||
// images match
|
||||
@@ -217,4 +215,4 @@ Jimp.read("lenna.png", (err, image) => {
|
||||
image.write("lena-half-bw.png");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+8
-7
@@ -5,14 +5,15 @@
|
||||
|
||||
/// <reference types="jquery"/>
|
||||
|
||||
declare var jui: JuiStatic;
|
||||
export const jui: JuiStatic;
|
||||
|
||||
interface UtilBase {
|
||||
/**
|
||||
* @property browser check browser agent
|
||||
* @property {Boolean} browser.webkit Webkit 브라우저 체크
|
||||
* @property {Boolean} browser.mozilla Mozilla 브라우저 체크
|
||||
* @property {Boolean} browser.msie IE 브라우저 체크 */
|
||||
* @property {Boolean} browser.msie IE 브라우저 체크
|
||||
*/
|
||||
browser: {
|
||||
webkit: boolean,
|
||||
mozilla: boolean,
|
||||
@@ -389,11 +390,11 @@ interface JuiStatic {
|
||||
includeAll(): any[];
|
||||
|
||||
/**
|
||||
* @method add
|
||||
* Adds a component object created
|
||||
*
|
||||
* @param {Object} ui UI instance
|
||||
*/
|
||||
* @method add
|
||||
* Adds a component object created
|
||||
*
|
||||
* @param {Object} ui UI instance
|
||||
*/
|
||||
add(uiIns: any): void;
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,9 +40,9 @@ jui.ready([ "grid.table" ], (table: GridTable) => {
|
||||
]);
|
||||
|
||||
const table_3_submit: Function = (index: number) => {
|
||||
const name = $(table_3.root).find(".name").val(),
|
||||
age = $(table_3.root).find(".age").val(),
|
||||
location = $(table_3.root).find(".location").val();
|
||||
const name = $(table_3.root).find(".name").val();
|
||||
const age = $(table_3.root).find(".age").val();
|
||||
const location = $(table_3.root).find(".location").val();
|
||||
|
||||
//noinspection TypeScriptValidateTypes
|
||||
table_3.update(index, { name, age, location });
|
||||
|
||||
Vendored
+1
-1
@@ -5,4 +5,4 @@
|
||||
|
||||
declare function leftPad(str: string|number, len: number, ch?: string|number): string;
|
||||
|
||||
export = leftPad;
|
||||
export = leftPad;
|
||||
|
||||
@@ -12,4 +12,4 @@ leftPad(1, 2, "0");
|
||||
// => "01"
|
||||
|
||||
leftPad(17, 5, 0);
|
||||
// => "00017"
|
||||
// => "00017"
|
||||
|
||||
Vendored
+1
-1
@@ -102,7 +102,7 @@ declare class Libpq extends EventEmitter {
|
||||
* @returns {boolean} true if data was read; false if there was an error. You can access
|
||||
* error details with [[Libpq.errorMessage]].
|
||||
*/
|
||||
consumeInput(): boolean
|
||||
consumeInput(): boolean;
|
||||
|
||||
/**
|
||||
* Retrieves the last error message from the connection. This is intended to be used after most
|
||||
|
||||
Vendored
+1
-1
@@ -67,5 +67,5 @@ interface XmppOptions {
|
||||
|
||||
interface Bosh {
|
||||
url?: string;
|
||||
prebind?: (error: any, data: any) => void;
|
||||
prebind?(error: any, data: any): void;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -66,17 +66,17 @@ export class JID {
|
||||
|
||||
/**
|
||||
* Convenience method to distinguish users
|
||||
**/
|
||||
*/
|
||||
bare(): JID;
|
||||
|
||||
/**
|
||||
* Comparison function
|
||||
**/
|
||||
*/
|
||||
equals(other: JID): boolean;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-localpart
|
||||
**/
|
||||
*/
|
||||
setLocal(local: string, escape?: any): void;
|
||||
|
||||
getLocal(unescape?: any): string;
|
||||
|
||||
@@ -55,4 +55,4 @@ ns.storingen({}, (err, data) => {
|
||||
} else {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,5 +7,5 @@ opener('./my-file.txt');
|
||||
opener('firefox');
|
||||
opener('npm run lint');
|
||||
|
||||
var editor = opener('documentation.odt');
|
||||
const editor = opener('documentation.odt');
|
||||
editor.unref();
|
||||
|
||||
@@ -3,4 +3,4 @@ import pad = require('pad');
|
||||
pad('pad', 5); // "pad "
|
||||
pad(5, 'pad'); // " pad"
|
||||
pad('pad', 5, '+'); // "pad++"
|
||||
pad(5, 'pad', '+'); // "++pad"
|
||||
pad(5, 'pad', '+'); // "++pad"
|
||||
|
||||
Vendored
+25
-25
@@ -144,9 +144,9 @@ type Callback<T> = (error: any, result: T) => any;
|
||||
* @param {PrivateKeyCreationOptions} [options] private key encryption settings, defaults to empty object (no enryption)
|
||||
* @param {Callback<{ key: string }>} callback Callback function with an error object and {key}
|
||||
*/
|
||||
declare function createPrivateKey(keyBitsize: number, options: PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void;
|
||||
declare function createPrivateKey(optionsOrKeyBitsize: number | PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void;
|
||||
declare function createPrivateKey(callback: Callback<{ key: string }>): void;
|
||||
export function createPrivateKey(keyBitsize: number, options: PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void;
|
||||
export function createPrivateKey(optionsOrKeyBitsize: number | PrivateKeyCreationOptions, callback: Callback<{ key: string }>): void;
|
||||
export function createPrivateKey(callback: Callback<{ key: string }>): void;
|
||||
|
||||
/**
|
||||
* Creates a dhparam key
|
||||
@@ -154,8 +154,8 @@ declare function createPrivateKey(callback: Callback<{ key: string }>): void;
|
||||
* @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit
|
||||
* @param {Callback<{ dhparam: any }>} callback Callback function with an error object and {dhparam}
|
||||
*/
|
||||
declare function createDhparam(keyBitsize: number, callback: Callback<{ dhparam: any }>): void;
|
||||
declare function createDhparam(callback: Callback<{ dhparam: any }>): void;
|
||||
export function createDhparam(keyBitsize: number, callback: Callback<{ dhparam: any }>): void;
|
||||
export function createDhparam(callback: Callback<{ dhparam: any }>): void;
|
||||
|
||||
/**
|
||||
* Creates a Certificate Signing Request
|
||||
@@ -166,8 +166,8 @@ declare function createDhparam(callback: Callback<{ dhparam: any }>): void;
|
||||
* @param {CSRCreationOptions} [options] Optional options object
|
||||
* @param {Callback<{ csr: string, clientKey: string }>} callback Callback function with an error object and {csr, clientKey}
|
||||
*/
|
||||
declare function createCSR(options: CSRCreationOptions, callback: Callback<{ csr: string, clientKey: string }>): void;
|
||||
declare function createCSR(callback: Callback<{ csr: string, clientKey: string }>): void;
|
||||
export function createCSR(options: CSRCreationOptions, callback: Callback<{ csr: string, clientKey: string }>): void;
|
||||
export function createCSR(callback: Callback<{ csr: string, clientKey: string }>): void;
|
||||
|
||||
/**
|
||||
* Creates a certificate based on a CSR. If CSR is not defined, a new one
|
||||
@@ -177,8 +177,8 @@ declare function createCSR(callback: Callback<{ csr: string, clientKey: string }
|
||||
* @param {Object} [CertificateCreationOptions] Optional options object
|
||||
* @param {Callback<CertificateCreationResult>} callback Callback function with an error object and {certificate, csr, clientKey, serviceKey}
|
||||
*/
|
||||
declare function createCertificate(options: CertificateCreationOptions, callback: Callback<CertificateCreationResult>): void;
|
||||
declare function createCertificate(callback: Callback<CertificateCreationResult>): void;
|
||||
export function createCertificate(options: CertificateCreationOptions, callback: Callback<CertificateCreationResult>): void;
|
||||
export function createCertificate(callback: Callback<CertificateCreationResult>): void;
|
||||
|
||||
/**
|
||||
* Reads subject data from a certificate or a CSR
|
||||
@@ -186,8 +186,8 @@ declare function createCertificate(callback: Callback<CertificateCreationResult>
|
||||
* @param {String} certificate PEM encoded CSR or certificate
|
||||
* @param {Callback<CertificateSubjectReadResult>} callback Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress}
|
||||
*/
|
||||
declare function readCertificateInfo(certificate: string, callback: Callback<CertificateSubjectReadResult>): void;
|
||||
declare function readCertificateInfo(callback: Callback<CertificateSubjectReadResult>): void;
|
||||
export function readCertificateInfo(certificate: string, callback: Callback<CertificateSubjectReadResult>): void;
|
||||
export function readCertificateInfo(callback: Callback<CertificateSubjectReadResult>): void;
|
||||
|
||||
/**
|
||||
* Exports a public key from a private key, CSR or certificate
|
||||
@@ -195,8 +195,8 @@ declare function readCertificateInfo(callback: Callback<CertificateSubjectReadRe
|
||||
* @param {String} certificate PEM encoded private key, CSR or certificate
|
||||
* @param {Callback<{ publicKey: string }>} callback Callback function with an error object and {publicKey}
|
||||
*/
|
||||
declare function getPublicKey(certificate: string, callback: Callback<{ publicKey: string }>): void;
|
||||
declare function getPublicKey(callback: Callback<{ publicKey: string }>): void;
|
||||
export function getPublicKey(certificate: string, callback: Callback<{ publicKey: string }>): void;
|
||||
export function getPublicKey(callback: Callback<{ publicKey: string }>): void;
|
||||
|
||||
/**
|
||||
* Gets the fingerprint for a certificate
|
||||
@@ -205,9 +205,9 @@ declare function getPublicKey(callback: Callback<{ publicKey: string }>): void;
|
||||
* @param {HashFunction} hash Hash function to use (either md5 sha1 or sha256, defaults to sha256)
|
||||
* @param {Callback<{ fingerprint: string }>} callback Callback function with an error object and {fingerprint}
|
||||
*/
|
||||
declare function getFingerprint(certificate: string, hash: HashFunction, callback: Callback<{ fingerprint: string }>): void;
|
||||
declare function getFingerprint(certificate: string, callback: Callback<{ fingerprint: string }>): void;
|
||||
declare function getFingerprint(callback: Callback<{ fingerprint: string }>): void;
|
||||
export function getFingerprint(certificate: string, hash: HashFunction, callback: Callback<{ fingerprint: string }>): void;
|
||||
export function getFingerprint(certificate: string, callback: Callback<{ fingerprint: string }>): void;
|
||||
export function getFingerprint(callback: Callback<{ fingerprint: string }>): void;
|
||||
|
||||
/**
|
||||
* Gets the modulus from a certificate, a CSR or a private key
|
||||
@@ -216,8 +216,8 @@ declare function getFingerprint(callback: Callback<{ fingerprint: string }>): vo
|
||||
* @param {String} password password for the certificate
|
||||
* @param {Callback<{ modulus: any }>} callback Callback function with an error object and {modulus}
|
||||
*/
|
||||
declare function getModulus(certificate: string, password: string, callback: Callback<{ modulus: any }>): void;
|
||||
declare function getModulus(certificate: string, callback: Callback<{ modulus: any }>): void;
|
||||
export function getModulus(certificate: string, password: string, callback: Callback<{ modulus: any }>): void;
|
||||
export function getModulus(certificate: string, callback: Callback<{ modulus: any }>): void;
|
||||
|
||||
/**
|
||||
* Gets the size and prime of DH parameters
|
||||
@@ -225,7 +225,7 @@ declare function getModulus(certificate: string, callback: Callback<{ modulus: a
|
||||
* @param {String} dh DH parameters PEM encoded
|
||||
* @param {Callback<{ size: any, prime: any }>} callback Callback function with an error object and {size, prime}
|
||||
*/
|
||||
declare function getDhparamInfo(dh: string, callback: Callback<{ size: any, prime: any }>): void;
|
||||
export function getDhparamInfo(dh: string, callback: Callback<{ size: any, prime: any }>): void;
|
||||
|
||||
/**
|
||||
* Exports private key and certificate to a PKCS12 keystore
|
||||
@@ -236,8 +236,8 @@ declare function getDhparamInfo(dh: string, callback: Callback<{ size: any, prim
|
||||
* @param {Pkcs12CreationOptions} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'}
|
||||
* @param {Callback<{ pkcs12: any }>} callback Callback function with an error object and {pkcs12}
|
||||
*/
|
||||
declare function createPkcs12(key: string, certificate: string, password: string, options: Pkcs12CreationOptions, callback: Callback<{ pkcs12: any }>): void;
|
||||
declare function createPkcs12(key: string, certificate: string, password: string, callback: Callback<{ pkcs12: any }>): void;
|
||||
export function createPkcs12(key: string, certificate: string, password: string, options: Pkcs12CreationOptions, callback: Callback<{ pkcs12: any }>): void;
|
||||
export function createPkcs12(key: string, certificate: string, password: string, callback: Callback<{ pkcs12: any }>): void;
|
||||
|
||||
/**
|
||||
* Reads private key and certificate from a PKCS12 keystore
|
||||
@@ -246,8 +246,8 @@ declare function createPkcs12(key: string, certificate: string, password: string
|
||||
* @param {Function} callback Callback function with an error object and {pkcs12}
|
||||
* @returns the result of the callback
|
||||
*/
|
||||
declare function readPkcs12(bufferOrPath: string, options: Pkcs12ReadOptions, callback: Callback<{ pkcs12: any }>): any;
|
||||
declare function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: any }>): any;
|
||||
export function readPkcs12(bufferOrPath: string, options: Pkcs12ReadOptions, callback: Callback<{ pkcs12: any }>): any;
|
||||
export function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: any }>): any;
|
||||
|
||||
/**
|
||||
* Verifies the signing chain of the passed certificate
|
||||
@@ -256,10 +256,10 @@ declare function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: a
|
||||
* @param {string[]} ca List of CA certificates
|
||||
* @param {Function} callback Callback function with an error object and a boolean valid
|
||||
*/
|
||||
declare function verifySigningChain(certificate: string, ca: string[], callback: Callback<boolean>): void;
|
||||
export function verifySigningChain(certificate: string, ca: string[], callback: Callback<boolean>): void;
|
||||
|
||||
/**
|
||||
* config the pem module
|
||||
* @param {ModuleConfiguration} options
|
||||
*/
|
||||
declare function config(options: ModuleConfiguration): void;
|
||||
export function config(options: ModuleConfiguration): void;
|
||||
|
||||
+43
-47
@@ -1,10 +1,9 @@
|
||||
import * as pem from 'pem';
|
||||
|
||||
const tests = {
|
||||
|
||||
'Create default sized dhparam key': (test: any) => {
|
||||
pem.createDhparam((error: any, data: any) => {
|
||||
var dhparam = (data && data.dhparam || '').toString();
|
||||
const dhparam = (data && data.dhparam || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(dhparam);
|
||||
test.ok(dhparam.match(/^\n*\-\-\-\-\-BEGIN DH PARAMETERS\-\-\-\-\-\n/));
|
||||
@@ -17,7 +16,7 @@ const tests = {
|
||||
|
||||
'Create 2048bit dhparam key': (test: any) => {
|
||||
pem.createDhparam(2048, (error: any, data: any) => {
|
||||
var dhparam = (data && data.dhparam || '').toString();
|
||||
const dhparam = (data && data.dhparam || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(dhparam);
|
||||
test.ok(dhparam.match(/^\n*\-\-\-\-\-BEGIN DH PARAMETERS\-\-\-\-\-\n/));
|
||||
@@ -30,7 +29,7 @@ const tests = {
|
||||
|
||||
'Create default sized Private key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
|
||||
@@ -43,7 +42,7 @@ const tests = {
|
||||
|
||||
'Create 2048bit Private key': (test: any) => {
|
||||
pem.createPrivateKey(2048, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
|
||||
@@ -56,7 +55,7 @@ const tests = {
|
||||
|
||||
'Create 2048bit Private key with Password': (test: any) => {
|
||||
pem.createPrivateKey(2048, {cipher: 'des', password: 'TestMe'}, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/ENCRYPTED\n/));
|
||||
@@ -70,7 +69,7 @@ const tests = {
|
||||
|
||||
'Create default CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
@@ -83,7 +82,7 @@ const tests = {
|
||||
},
|
||||
|
||||
'Create CSR using config file': (test: any) => {
|
||||
var certInfo = {
|
||||
const certInfo = {
|
||||
issuer : {},
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
@@ -95,7 +94,7 @@ const tests = {
|
||||
};
|
||||
|
||||
pem.createCSR({ csrConfigFile: './test/fixtures/test.cnf' }, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
@@ -115,12 +114,12 @@ const tests = {
|
||||
|
||||
'Create CSR with own key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCSR({
|
||||
clientKey: key
|
||||
}, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
@@ -136,15 +135,15 @@ const tests = {
|
||||
},
|
||||
|
||||
'Create CSR with own encrypted key': (test: any) => {
|
||||
var password = 'my:secure! "password\'s\nawesome';
|
||||
const password = 'my:secure! "password\'s\nawesome';
|
||||
pem.createPrivateKey(2048, { cipher: 'des3', password }, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCSR({
|
||||
clientKey: key,
|
||||
clientKeyPassword: password
|
||||
}, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
@@ -161,7 +160,7 @@ const tests = {
|
||||
|
||||
'Create default certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
test.ok(certificate.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-\n/));
|
||||
@@ -181,7 +180,7 @@ const tests = {
|
||||
pem.createCertificate({
|
||||
selfSigned: true
|
||||
}, (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
test.ok(certificate.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-\n/));
|
||||
@@ -199,7 +198,7 @@ const tests = {
|
||||
|
||||
'Read default cert data from CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
@@ -222,7 +221,7 @@ const tests = {
|
||||
},
|
||||
|
||||
'Read edited cert data from CSR': (test: any) => {
|
||||
var certInfo = {
|
||||
const certInfo = {
|
||||
issuer : {},
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
@@ -233,7 +232,7 @@ const tests = {
|
||||
emailAddress: 'andris@node.ee'
|
||||
};
|
||||
pem.createCSR(Object.create(certInfo), (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
const csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
@@ -248,7 +247,7 @@ const tests = {
|
||||
|
||||
'Read default cert data from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
@@ -286,7 +285,7 @@ const tests = {
|
||||
},
|
||||
|
||||
'Read edited cert data from certificate': (test: any) => {
|
||||
var certInfo = {
|
||||
const certInfo = {
|
||||
issuer : {
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
@@ -304,7 +303,7 @@ const tests = {
|
||||
emailAddress: 'andris@node.ee'
|
||||
};
|
||||
pem.createCertificate(Object.create(certInfo), (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
@@ -327,13 +326,13 @@ const tests = {
|
||||
|
||||
'Get public key from private key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
const pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
@@ -348,13 +347,13 @@ const tests = {
|
||||
|
||||
'Get public key from CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var key = (data && data.clientKey || '').toString();
|
||||
const key = (data && data.clientKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
const pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
@@ -369,13 +368,13 @@ const tests = {
|
||||
|
||||
'Get public key from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var key = (data && data.clientKey || '').toString();
|
||||
const key = (data && data.clientKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
const pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
@@ -390,13 +389,13 @@ const tests = {
|
||||
|
||||
'Get fingerprint from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getFingerprint(certificate, (error: any, data: any) => {
|
||||
var fingerprint = (data && data.fingerprint || '').toString();
|
||||
const fingerprint = (data && data.fingerprint || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(fingerprint);
|
||||
test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
|
||||
@@ -409,19 +408,19 @@ const tests = {
|
||||
|
||||
'Get modulus from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var certmodulus = (data && data.modulus || '').toString();
|
||||
const certmodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certmodulus);
|
||||
test.ok(certmodulus.match(/^[0-9A-F]*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var keymodulus = (data && data.modulus || '').toString();
|
||||
const keymodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(keymodulus);
|
||||
test.ok(keymodulus.match(/^[0-9A-F]*$/));
|
||||
@@ -434,17 +433,17 @@ const tests = {
|
||||
},
|
||||
|
||||
'Get modulus from a protected key': (test: any) => {
|
||||
var certificate = ''; // fs.readFileSync('./test/fixtures/test.crt').toString();
|
||||
var key = ''; // fs.readFileSync('./test/fixtures/test.key').toString();
|
||||
const certificate = ''; // fs.readFileSync('./test/fixtures/test.crt').toString();
|
||||
const key = ''; // fs.readFileSync('./test/fixtures/test.key').toString();
|
||||
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var certmodulus = (data && data.modulus || '').toString();
|
||||
const certmodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certmodulus);
|
||||
test.ok(certmodulus.match(/^[0-9A-F]*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
pem.getModulus(key, 'password', (error: any, data: any) => {
|
||||
var keymodulus = (data && data.modulus || '').toString();
|
||||
const keymodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(keymodulus);
|
||||
test.ok(keymodulus.match(/^[0-9A-F]*$/));
|
||||
@@ -453,15 +452,14 @@ const tests = {
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
'Get DH param info': (test: any) => {
|
||||
var dh = ''; // fs.readFileSync('./test/fixtures/test.dh').toString();
|
||||
const dh = ''; // fs.readFileSync('./test/fixtures/test.dh').toString();
|
||||
|
||||
pem.getDhparamInfo(dh, (error: any, data: any) => {
|
||||
var size = data && data.size || 0;
|
||||
var prime = (data && data.prime || '').toString();
|
||||
const size = data && data.size || 0;
|
||||
const prime = (data && data.prime || '').toString();
|
||||
test.ifError(error);
|
||||
test.equal(size, 1024);
|
||||
test.ok(prime);
|
||||
@@ -473,11 +471,11 @@ const tests = {
|
||||
},
|
||||
|
||||
'Create and verify wildcard certificate': (test: any) => {
|
||||
var certInfo = {
|
||||
const certInfo = {
|
||||
commonName: '*.node.ee'
|
||||
};
|
||||
pem.createCertificate(Object.create(certInfo), (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
const certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
@@ -507,13 +505,12 @@ const tests = {
|
||||
},
|
||||
'Create PKCS12 without key password': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCertificate({
|
||||
clientKey: key,
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', (err: any, pkcs12: any) => {
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
@@ -526,13 +523,12 @@ const tests = {
|
||||
},
|
||||
'Create PKCS12 with key password': (test: any) => {
|
||||
pem.createPrivateKey({cipher: 'aes128', password: 'xxx'}, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
const key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCertificate({
|
||||
clientKey: key,
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', {cipher: 'aes256', clientKeyPassword: 'xxx'}, (err: any, pkcs12: any) => {
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
|
||||
Vendored
+25
-25
@@ -3,20 +3,19 @@
|
||||
// Definitions by: Brice Theurillat <https://github.com/BNedry/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
declare namespace PlugAPI {
|
||||
|
||||
export interface PlugLogin {
|
||||
interface PlugLogin {
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
interface Notification {
|
||||
action: string;
|
||||
id: number;
|
||||
timestamp: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface RawChatMessage {
|
||||
interface RawChatMessage {
|
||||
cid: string;
|
||||
message: string;
|
||||
sub: number;
|
||||
@@ -24,7 +23,7 @@ declare namespace PlugAPI {
|
||||
un: string;
|
||||
}
|
||||
|
||||
export interface Media {
|
||||
interface Media {
|
||||
author: string;
|
||||
format: number;
|
||||
image: string;
|
||||
@@ -34,7 +33,7 @@ declare namespace PlugAPI {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export interface Score {
|
||||
interface Score {
|
||||
positive: number;
|
||||
listeners: number;
|
||||
grabs: number;
|
||||
@@ -42,23 +41,23 @@ declare namespace PlugAPI {
|
||||
skipped: number;
|
||||
}
|
||||
|
||||
export interface LastPlay {
|
||||
interface LastPlay {
|
||||
dj: User.DJ;
|
||||
media: Media;
|
||||
score: Score;
|
||||
}
|
||||
|
||||
export interface FollowJoinData {
|
||||
interface FollowJoinData {
|
||||
r: number;
|
||||
un: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface LogObject {
|
||||
log: () => void;
|
||||
interface LogObject {
|
||||
log(): void;
|
||||
}
|
||||
|
||||
export namespace User {
|
||||
namespace User {
|
||||
interface Default {
|
||||
username: string;
|
||||
language: string;
|
||||
@@ -110,7 +109,7 @@ declare namespace PlugAPI {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Enum {
|
||||
namespace Enum {
|
||||
interface RoomRole {
|
||||
NONE: number;
|
||||
RESIDENTDJ: number;
|
||||
@@ -217,7 +216,7 @@ declare namespace PlugAPI {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Event {
|
||||
namespace Event {
|
||||
interface BoothCycle {
|
||||
moderator: string;
|
||||
cycle: boolean;
|
||||
@@ -339,21 +338,21 @@ declare namespace PlugAPI {
|
||||
interface Command extends Event.Chat {
|
||||
command: string;
|
||||
args: string[];
|
||||
respond: (...args: any[]) => any;
|
||||
respondTimeout: (...args: any[]) => any;
|
||||
havePermission: (...args: any[]) => boolean;
|
||||
isFrom: (...args: any[]) => boolean;
|
||||
respond(...args: any[]): any;
|
||||
respondTimeout(...args: any[]): any;
|
||||
havePermission(...args: any[]): boolean;
|
||||
isFrom(...args: any[]): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export var ROOM_ROLE: Enum.RoomRole;
|
||||
export var GLOBAL_ROLES: Enum.GlobalRole;
|
||||
export var STATUS: Enum.Status;
|
||||
export var BAN: Enum.Ban;
|
||||
export var BAN_REASON: Enum.BanReason;
|
||||
export var MUTE: Enum.Mute;
|
||||
export var MUTE_REASON: Enum.MuteReason;
|
||||
export var events: Enum.Events;
|
||||
const ROOM_ROLE: Enum.RoomRole;
|
||||
const GLOBAL_ROLES: Enum.GlobalRole;
|
||||
const STATUS: Enum.Status;
|
||||
const BAN: Enum.Ban;
|
||||
const BAN_REASON: Enum.BanReason;
|
||||
const MUTE: Enum.Mute;
|
||||
const MUTE_REASON: Enum.MuteReason;
|
||||
const events: Enum.Events;
|
||||
}
|
||||
|
||||
declare class PlugAPI {
|
||||
@@ -412,4 +411,5 @@ declare class PlugAPI {
|
||||
on(event: "command", callback: (data: PlugAPI.Event.Command) => void): void;
|
||||
on(event: string, callback: (data: any) => void): void;
|
||||
}
|
||||
|
||||
export = PlugAPI;
|
||||
|
||||
@@ -7,7 +7,7 @@ ps.run('my_script.py', err => {
|
||||
console.log('finished');
|
||||
});
|
||||
|
||||
var options = {
|
||||
const options = {
|
||||
mode: 'text',
|
||||
pythonPath: 'path/to/python',
|
||||
pythonOptions: ['-u'],
|
||||
@@ -21,7 +21,7 @@ ps.run('my_script.py', options, (err, results) => {
|
||||
console.log('results: %j', results);
|
||||
});
|
||||
|
||||
var pyshell = new PythonShell('my_script.py');
|
||||
const pyshell = new PythonShell('my_script.py');
|
||||
|
||||
// sends a message to the Python script via stdin
|
||||
pyshell.send('hello');
|
||||
@@ -35,4 +35,4 @@ pyshell.on('message', message => {
|
||||
pyshell.end(err => {
|
||||
if (err) throw err;
|
||||
console.log('finished');
|
||||
});
|
||||
});
|
||||
|
||||
+16
-16
@@ -654,12 +654,12 @@ declare namespace BackendAPI {
|
||||
|
||||
interface INxPatch {
|
||||
/**
|
||||
* Operation to perform.
|
||||
* One of:
|
||||
* # Add
|
||||
* # Remove
|
||||
* # Replace
|
||||
*/
|
||||
* Operation to perform.
|
||||
* One of:
|
||||
* # Add
|
||||
* # Remove
|
||||
* # Replace
|
||||
*/
|
||||
qOp: PatchType;
|
||||
|
||||
/**
|
||||
@@ -1182,7 +1182,7 @@ declare namespace AppAPI {
|
||||
field(field?: string, state?: string): FieldAPI.IQField;
|
||||
|
||||
/**
|
||||
* Step forward in list of selections.
|
||||
* Step forward in list of selections.
|
||||
* @return {Promise} - A promise of a Qlik engine reply.
|
||||
*/
|
||||
forward(): ng.IPromise<any>;
|
||||
@@ -2178,7 +2178,7 @@ declare namespace VisualizationAPI {
|
||||
* # treemap
|
||||
* # extension
|
||||
* @param {array} [cols] - Optional. Column definitions, dimensions and measures.
|
||||
Each entry can be of the following structures:
|
||||
* Each entry can be of the following structures:
|
||||
* # String
|
||||
* # NxDimension
|
||||
* # NxMeasure
|
||||
@@ -2481,14 +2481,14 @@ interface IQVAngular {
|
||||
filter(object: { [name: string]: ng.Injectable<Function> }): void;
|
||||
|
||||
/**
|
||||
* Register a service constructor, which will be invoked with new to create
|
||||
* the service instance. This is short for registering a service where its
|
||||
* provider's $get property is a factory function that returns an instance
|
||||
* instantiated by the injector from the service constructor function.
|
||||
* @param name The name of the instance.
|
||||
* @param serviceConstructor An injectable class (constructor function) that will be instantiated.
|
||||
* @return Returns the constructed singleton of the service class/function.
|
||||
*/
|
||||
* Register a service constructor, which will be invoked with new to create
|
||||
* the service instance. This is short for registering a service where its
|
||||
* provider's $get property is a factory function that returns an instance
|
||||
* instantiated by the injector from the service constructor function.
|
||||
* @param name The name of the instance.
|
||||
* @param serviceConstructor An injectable class (constructor function) that will be instantiated.
|
||||
* @return Returns the constructed singleton of the service class/function.
|
||||
*/
|
||||
service<T>(name: string, serviceConstructor: ng.Injectable<Function>): T;
|
||||
service<T>(object: { [name: string]: ng.Injectable<Function> }): T;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -48,7 +48,7 @@ interface RequireError extends Error {
|
||||
/**
|
||||
* Required modules.
|
||||
**/
|
||||
requireModules: string[];
|
||||
requireModules: string[] | null;
|
||||
|
||||
/**
|
||||
* The original error, if there is one (might be null).
|
||||
|
||||
Vendored
+47
-48
@@ -19,9 +19,9 @@ declare module "rrule" {
|
||||
|
||||
declare namespace RRule {
|
||||
/**
|
||||
* see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
|
||||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
|
||||
*/
|
||||
* see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
|
||||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
|
||||
*/
|
||||
interface Options {
|
||||
freq: RRule.Frequency;
|
||||
dtstart?: Date;
|
||||
@@ -55,10 +55,10 @@ declare namespace RRule {
|
||||
|
||||
declare class RRule {
|
||||
/**
|
||||
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
|
||||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
|
||||
* @constructor
|
||||
*/
|
||||
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
|
||||
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options: RRule.Options, noCache?: boolean);
|
||||
|
||||
options: RRule.Options;
|
||||
@@ -66,55 +66,55 @@ declare class RRule {
|
||||
origOptions: RRule.Options;
|
||||
|
||||
/**
|
||||
* Returns the first recurrence after the given datetime instance.
|
||||
* The inc keyword defines what happens if dt is an occurrence.
|
||||
* With inc == True, if dt itself is an occurrence, it will be returned.
|
||||
* @return Date or null
|
||||
*/
|
||||
* Returns the first recurrence after the given datetime instance.
|
||||
* The inc keyword defines what happens if dt is an occurrence.
|
||||
* With inc == True, if dt itself is an occurrence, it will be returned.
|
||||
* @return Date or null
|
||||
*/
|
||||
after(dt: Date, inc?: boolean): Date;
|
||||
|
||||
/**
|
||||
* @param {Function} iterator - optional function that will be called
|
||||
* on each date that is added. It can return false
|
||||
* to stop the iteration.
|
||||
* @return Array containing all recurrences.
|
||||
*/
|
||||
* @param {Function} iterator - optional function that will be called
|
||||
* on each date that is added. It can return false
|
||||
* to stop the iteration.
|
||||
* @return Array containing all recurrences.
|
||||
*/
|
||||
all(iterator?: (date: Date, index?: number) => void): Date[];
|
||||
|
||||
/**
|
||||
* Returns all the occurrences of the rrule between after and before.
|
||||
* The inc keyword defines what happens if after and/or before are
|
||||
* themselves occurrences. With inc == True, they will be included in the
|
||||
* list, if they are found in the recurrence set.
|
||||
* @return Array
|
||||
*/
|
||||
* Returns all the occurrences of the rrule between after and before.
|
||||
* The inc keyword defines what happens if after and/or before are
|
||||
* themselves occurrences. With inc == True, they will be included in the
|
||||
* list, if they are found in the recurrence set.
|
||||
* @return Array
|
||||
*/
|
||||
between(a: Date, b: Date, inc?: boolean, iterator?: (date: Date, index: number) => void): Date[];
|
||||
|
||||
/**
|
||||
* Returns the last recurrence before the given datetime instance.
|
||||
* The inc keyword defines what happens if dt is an occurrence.
|
||||
* With inc == True, if dt itself is an occurrence, it will be returned.
|
||||
* @return Date or null
|
||||
*/
|
||||
* Returns the last recurrence before the given datetime instance.
|
||||
* The inc keyword defines what happens if dt is an occurrence.
|
||||
* With inc == True, if dt itself is an occurrence, it will be returned.
|
||||
* @return Date or null
|
||||
*/
|
||||
before(dt: Date, inc?: boolean): Date;
|
||||
|
||||
/**
|
||||
* Returns the number of recurrences in this set. It will have go trough
|
||||
* the whole recurrence, if this hasn't been done before.
|
||||
*/
|
||||
* Returns the number of recurrences in this set. It will have go trough
|
||||
* the whole recurrence, if this hasn't been done before.
|
||||
*/
|
||||
count(): number;
|
||||
|
||||
/**
|
||||
* Converts the rrule into its string representation
|
||||
* @see <http://www.ietf.org/rfc/rfc2445.txt>
|
||||
* @return String
|
||||
*/
|
||||
* Converts the rrule into its string representation
|
||||
* @see <http://www.ietf.org/rfc/rfc2445.txt>
|
||||
* @return String
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* Will convert all rules described in nlp:ToText
|
||||
* to text.
|
||||
*/
|
||||
* Will convert all rules described in nlp:ToText
|
||||
* to text.
|
||||
*/
|
||||
toText(gettext?: (str: string) => string, language?: any): string;
|
||||
|
||||
isFullyConvertibleToText(): boolean;
|
||||
@@ -165,11 +165,10 @@ declare namespace RRule {
|
||||
|
||||
class RRuleSet extends RRule {
|
||||
/**
|
||||
*
|
||||
* @param {Boolean?} noCache
|
||||
* The same stratagy as RRule on cache, default to false
|
||||
* @constructor
|
||||
*/
|
||||
* @param {Boolean?} noCache
|
||||
* The same stratagy as RRule on cache, default to false
|
||||
* @constructor
|
||||
*/
|
||||
constructor(noCache?: boolean);
|
||||
rrule(rrule: RRule): void;
|
||||
rdate(date: Date): void;
|
||||
@@ -177,13 +176,13 @@ declare namespace RRule {
|
||||
exdate(date: Date): void;
|
||||
valueOf(): string[];
|
||||
/**
|
||||
* to generate recurrence field sush as:
|
||||
* ["RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU;DTSTART=19970902T010000Z","RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH;DTSTART=19970902T010000Z"]
|
||||
*/
|
||||
* to generate recurrence field sush as:
|
||||
* ["RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU;DTSTART=19970902T010000Z","RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH;DTSTART=19970902T010000Z"]
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Create a new RRuleSet Object completely base on current instance
|
||||
*/
|
||||
* Create a new RRuleSet Object completely base on current instance
|
||||
*/
|
||||
clone(): RRuleSet;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+9
-7
@@ -1549,7 +1549,7 @@ declare namespace SPAnimation {
|
||||
class State {
|
||||
SetAttribute(attributeId: Attribute, value: number): void;
|
||||
GetAttribute(attributeId: Attribute): number;
|
||||
GetDataIndex(attributeId: Attribute): number
|
||||
GetDataIndex(attributeId: Attribute): number;
|
||||
}
|
||||
|
||||
class Object {
|
||||
@@ -5134,7 +5134,8 @@ declare namespace Microsoft.SharePoint.Client.Search {
|
||||
get_uiLanguage: () => number;
|
||||
set_uiLanguage: (value: number) => void;
|
||||
|
||||
getQuerySuggestionsWithResults: (iNumberOfQuerySuggestions: number,
|
||||
getQuerySuggestionsWithResults: (
|
||||
iNumberOfQuerySuggestions: number,
|
||||
iNumberOfResultSuggestions: number,
|
||||
fPreQuerySuggestions: boolean,
|
||||
fHitHighlighting: boolean,
|
||||
@@ -5493,7 +5494,8 @@ declare namespace Microsoft.SharePoint.Client.Search {
|
||||
namespace Administration {
|
||||
class DocumentCrawlLog extends SP.ClientObject {
|
||||
constructor(context: SP.ClientContext, site: SP.Site);
|
||||
getCrawledUrls: (getCountOnly: boolean,
|
||||
getCrawledUrls: (
|
||||
getCountOnly: boolean,
|
||||
maxRows: { High: number; Low: number; },
|
||||
queryString: string,
|
||||
isLike: boolean,
|
||||
@@ -9299,7 +9301,7 @@ declare class SPClientPeoplePicker {
|
||||
WebApplicationID: SP.Guid; // '{00000000-0000-0000-0000-000000000000}',
|
||||
GetAllUserInfo(): ISPClientPeoplePickerEntity[];
|
||||
|
||||
SetInitialValue(entities: ISPClientPeoplePickerEntity[], initialErrorMsg?: string): void
|
||||
SetInitialValue(entities: ISPClientPeoplePickerEntity[], initialErrorMsg?: string): void;
|
||||
AddUserKeys(userKeys: string, bSearch: boolean): void;
|
||||
BatchAddUserKeysOperation(allKeys: string[], numProcessed: number): void;
|
||||
ResolveAllUsers(fnContinuation: () => void): void;
|
||||
@@ -9331,7 +9333,7 @@ declare class SPClientPeoplePicker {
|
||||
IterateEachProcessedUser(fnCallback: (index: number, user: SPClientPeoplePickerProcessedUser) => void): void;
|
||||
HasResolvedUsers(): boolean;
|
||||
Validate(): void;
|
||||
ValidateCurrentState(): void
|
||||
ValidateCurrentState(): void;
|
||||
GetUnresolvedEntityErrorMessage(): string;
|
||||
ShowErrorMessage(msg: string): void;
|
||||
ClearServerError(): void;
|
||||
@@ -11652,7 +11654,7 @@ declare namespace Srch {
|
||||
/** Same as $addHandler with safety checks */
|
||||
static addHandler(element: Element, eventName: string, handler: (instance: any, eventArgs: any) => void): void;
|
||||
/** Same as $removeHandler with safety checks */
|
||||
static removeHandler(element: Element, eventName: string, handler: (instance: any, eventArgs: any) => void): void
|
||||
static removeHandler(element: Element, eventName: string, handler: (instance: any, eventArgs: any) => void): void;
|
||||
|
||||
/** Returns true if the specified element is a descendant of the container element */
|
||||
static isDescendant(element: Element, container: Element): boolean;
|
||||
@@ -11670,7 +11672,7 @@ declare namespace Srch {
|
||||
static findResultObjectFromDOM(e: Element, type: string): any;
|
||||
|
||||
/** Appends specified parameter key and value string to the specified URL */
|
||||
static appendUrlParameter(url: string, keyAndValue: string): string
|
||||
static appendUrlParameter(url: string, keyAndValue: string): string;
|
||||
|
||||
/** Ensures that the given URL protocol value is allowed. Returns the specified URL value if the protocol is allowed; empty string otherwise. */
|
||||
static ensureAllowedProtocol(value: string): string;
|
||||
|
||||
@@ -1728,7 +1728,7 @@ namespace spdevlab {
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2156,7 +2156,7 @@ namespace _ {
|
||||
$('#report').children().remove();
|
||||
$('#report').append("Failed to get session. Error: " + args.get_message());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// publishing.ts
|
||||
// Variables used in various callbacks
|
||||
@@ -2349,7 +2349,6 @@ namespace App {
|
||||
.then(l => this.lists = l)
|
||||
.catch((e: string) => this.$n.show(e, true))
|
||||
.finally(() => this.$n.remove(loading));
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
interface Options {
|
||||
duration?: number;
|
||||
easing?: (currentTime: number, beginningTime: number, changeInValue: number, duration: number) => number;
|
||||
easing?(currentTime: number, beginningTime: number, changeInValue: number, duration: number): number;
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const tweezer = new Tweezer({
|
||||
});
|
||||
|
||||
tweezer
|
||||
.on('tick', (foo) => {foo.toFixed()})
|
||||
.on('tick', (foo) => { foo.toFixed(); })
|
||||
.on('done', () => {})
|
||||
.begin()
|
||||
.stop();
|
||||
|
||||
Vendored
+2
-2
@@ -93,8 +93,8 @@ declare module 'angular' {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sticky state
|
||||
*/
|
||||
* Sticky state
|
||||
*/
|
||||
interface IStickyState extends angular.ui.IState {
|
||||
/*
|
||||
* When marking a state sticky, the state must target its own unique named ui-view.
|
||||
|
||||
Vendored
+73
-73
@@ -25,17 +25,17 @@ interface SrcOptions extends globStream.Options {
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Specifies the folder relative to the cwd
|
||||
* This is used to determine the file names when saving in .dest()
|
||||
* Default: where the glob begins
|
||||
*/
|
||||
* Specifies the folder relative to the cwd
|
||||
* This is used to determine the file names when saving in .dest()
|
||||
* Default: where the glob begins
|
||||
*/
|
||||
base?: string;
|
||||
|
||||
/**
|
||||
* Setting this to false will make file.contents a paused stream
|
||||
* If true it will buffer the file contents
|
||||
* Default: true
|
||||
*/
|
||||
* Setting this to false will make file.contents a paused stream
|
||||
* If true it will buffer the file contents
|
||||
* Default: true
|
||||
*/
|
||||
buffer?: boolean;
|
||||
|
||||
/**
|
||||
@@ -59,10 +59,10 @@ interface SrcOptions extends globStream.Options {
|
||||
followSymlinks?: boolean;
|
||||
|
||||
/**
|
||||
* Setting this to false will ignore the contents of the file and disable
|
||||
* writing to disk to speed up operations
|
||||
* Default: true
|
||||
*/
|
||||
* Setting this to false will ignore the contents of the file and disable
|
||||
* writing to disk to speed up operations
|
||||
* Default: true
|
||||
*/
|
||||
read?: boolean;
|
||||
|
||||
/**
|
||||
@@ -95,30 +95,30 @@ interface SrcOptions extends globStream.Options {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets files that match the glob and converts them into the vinyl format
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
* @param opt Options Vinyl source options, changes the way the files are read, found, or stored in the vinyl stream
|
||||
*/
|
||||
* Gets files that match the glob and converts them into the vinyl format
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
* @param opt Options Vinyl source options, changes the way the files are read, found, or stored in the vinyl stream
|
||||
*/
|
||||
export function src(globs: string|string[], opt?: SrcOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* This is just a glob-watcher
|
||||
*
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
*/
|
||||
* This is just a glob-watcher
|
||||
*
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
*/
|
||||
export function watch(globs: string|string[], cb?: (outEvt: { type: any; path: any; old: any; }) => void): _events.EventEmitter;
|
||||
|
||||
/**
|
||||
* This is just a glob-watcher
|
||||
*
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
*/
|
||||
* This is just a glob-watcher
|
||||
*
|
||||
* @param globs Takes a glob string or an array of glob strings as the first argument
|
||||
* Globs are executed in order, so negations should follow positive globs
|
||||
* fs.src(['!b*.js', '*.js']) would not exclude any files, but this would: fs.src(['*.js', '!b*.js'])
|
||||
*/
|
||||
export function watch(
|
||||
globs: string|string[],
|
||||
opt?: {
|
||||
@@ -130,24 +130,24 @@ export function watch(
|
||||
cb?: (outEvt: { type: any; path: any; old: any; }) => void): _events.EventEmitter;
|
||||
|
||||
/**
|
||||
* On write the stream will save the vinyl File to disk at the folder/cwd specified.
|
||||
* After writing the file to disk, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
* stat.mode will be overwritten if you used a mode parameter
|
||||
* contents will have it's position reset to the beginning if it is a stream
|
||||
* @param folder destination folder
|
||||
*/
|
||||
* On write the stream will save the vinyl File to disk at the folder/cwd specified.
|
||||
* After writing the file to disk, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
* stat.mode will be overwritten if you used a mode parameter
|
||||
* contents will have it's position reset to the beginning if it is a stream
|
||||
* @param folder destination folder
|
||||
*/
|
||||
export function dest(folder: string, opt?: {
|
||||
/** Specify the working directory the folder is relative to
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/** Specify the mode the files should be created with
|
||||
* Default is the mode of the input file (file.stat.mode)
|
||||
* or the process mode if the input file has no mode property
|
||||
*/
|
||||
* Default is the mode of the input file (file.stat.mode)
|
||||
* or the process mode if the input file has no mode property
|
||||
*/
|
||||
mode?: number|string;
|
||||
|
||||
/** Specify the mode the directory should be created with. Default is the process mode */
|
||||
@@ -158,56 +158,56 @@ export function dest(folder: string, opt?: {
|
||||
}): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* On write the stream will save the vinyl File to disk at the folder/cwd specified.
|
||||
* After writing the file to disk, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
* stat.mode will be overwritten if you used a mode parameter
|
||||
* contents will have it's position reset to the beginning if it is a stream
|
||||
* @param getFolderPath function that takes in a file and returns a folder path
|
||||
*/
|
||||
* On write the stream will save the vinyl File to disk at the folder/cwd specified.
|
||||
* After writing the file to disk, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
* stat.mode will be overwritten if you used a mode parameter
|
||||
* contents will have it's position reset to the beginning if it is a stream
|
||||
* @param getFolderPath function that takes in a file and returns a folder path
|
||||
*/
|
||||
export function dest(getFolderPath: (file: File) => string): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd specified.
|
||||
* After creating the symbolic link, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
*/
|
||||
* On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd specified.
|
||||
* After creating the symbolic link, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
*/
|
||||
export function symlink(folder: string, opts?: {
|
||||
/**
|
||||
* Specify the working directory the folder is relative to
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
* Specify the working directory the folder is relative to
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/** Specify the mode the directory should be created with. Default is the process mode */
|
||||
mode?: number|string;
|
||||
|
||||
/**
|
||||
* Specify the mode the directory should be created with
|
||||
* Default is the process mode
|
||||
*/
|
||||
* Specify the mode the directory should be created with
|
||||
* Default is the process mode
|
||||
*/
|
||||
dirMode?: number
|
||||
}): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd generated from getFolderPath.
|
||||
* After creating the symbolic link, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
*/
|
||||
* On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd generated from getFolderPath.
|
||||
* After creating the symbolic link, it will be emitted from the stream so you can keep piping these around.
|
||||
* The file will be modified after being written to this stream:
|
||||
* cwd, base, and path will be overwritten to match the folder
|
||||
*/
|
||||
export function symlink(getFolderPath: (File: File) => string, opts?:
|
||||
{
|
||||
/**
|
||||
* Specify the working directory the folder is relative to
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
* Specify the working directory the folder is relative to
|
||||
* Default is process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Specify the mode the directory should be created with
|
||||
* Default is the process mode
|
||||
*/
|
||||
* Specify the mode the directory should be created with
|
||||
* Default is the process mode
|
||||
*/
|
||||
dirMode?: number
|
||||
}): NodeJS.ReadWriteStream;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
const tracks: string[] = ['chapter1.mp3', 'chapter2.mp3', 'chapter3.mp3'];
|
||||
let trackId = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// adapted from `cat wu.js/test/* |sed '/= require/d'> wu-tests.ts`
|
||||
|
||||
declare var describe: any, it: any, mocha: any, assert: {
|
||||
declare const describe: any;
|
||||
declare const it: any;
|
||||
declare const mocha: any;
|
||||
declare const assert: {
|
||||
iterable: any;
|
||||
eqSet<T>(expected: Set<T>, actual: Iterable<T>): any;
|
||||
ok: any;
|
||||
|
||||
@@ -7,13 +7,12 @@ interface Tester {
|
||||
same(a: any, b: any): void;
|
||||
plan(id: number): void;
|
||||
ok(a: any): void;
|
||||
};
|
||||
}
|
||||
|
||||
function test(c: string, f: (t: Tester) => void) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
test('no elements', t => {
|
||||
t.is(xml(), '');
|
||||
t.is(xml([]), '');
|
||||
@@ -162,4 +161,4 @@ test('xml declaration options', t => {
|
||||
t.is(xml([{a: 'test'}], {declaration: false}), '<a>test</a>');
|
||||
t.is(xml([{a: 'test'}], {declaration: true, indent: '\n'}), '<?xml version="1.0" encoding="UTF-8"?>\n<a>test</a>');
|
||||
t.is(xml([{a: 'test'}], {}), '<a>test</a>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import * as parser from 'xml2json';
|
||||
|
||||
var xml = "<foo attr=\"value\">bar</foo>";
|
||||
let xml = "<foo attr=\"value\">bar</foo>";
|
||||
|
||||
// xml to json
|
||||
var jsonString: string = parser.toJson(xml);
|
||||
const jsonString: string = parser.toJson(xml);
|
||||
|
||||
// json to xml
|
||||
var xml: string = parser.toXml(jsonString);
|
||||
xml = parser.toXml(jsonString);
|
||||
|
||||
// xml to json in object mode and JsonOptions
|
||||
var jsonObject: {} = parser.toJson(xml, {
|
||||
const jsonObject: {} = parser.toJson(xml, {
|
||||
object: true,
|
||||
reversible: false,
|
||||
coerce: false,
|
||||
@@ -19,6 +19,6 @@ var jsonObject: {} = parser.toJson(xml, {
|
||||
});
|
||||
|
||||
// json to xml with XmlOptions
|
||||
var xml: string = parser.toXml(jsonObject, {
|
||||
xml = parser.toXml(jsonObject, {
|
||||
sanitize: true
|
||||
});
|
||||
|
||||
Vendored
+7
-7
@@ -10,14 +10,14 @@
|
||||
// Remove the `declare module` wrapper.
|
||||
// tslint:disable-next-line no-single-declare-module
|
||||
declare module "@xmpp/jid" {
|
||||
export function createJID(local: string, domain: string, resource: string): JID;
|
||||
export function equal(a: JID, b: JID): boolean;
|
||||
export function is(a: any): boolean;
|
||||
function createJID(local: string, domain: string, resource: string): JID;
|
||||
function equal(a: JID, b: JID): boolean;
|
||||
function is(a: any): boolean;
|
||||
|
||||
/**
|
||||
* Created by marcneumann on 17.02.17.
|
||||
*/
|
||||
export class JID {
|
||||
class JID {
|
||||
local: string;
|
||||
domain: string;
|
||||
resource: string;
|
||||
@@ -30,17 +30,17 @@ declare module "@xmpp/jid" {
|
||||
|
||||
/**
|
||||
* Convenience method to distinguish users
|
||||
**/
|
||||
*/
|
||||
bare(): JID;
|
||||
|
||||
/**
|
||||
* Comparison function
|
||||
**/
|
||||
*/
|
||||
equals(other: JID): boolean;
|
||||
|
||||
/**
|
||||
* http://xmpp.org/rfcs/rfc6122.html#addressing-localpart
|
||||
**/
|
||||
*/
|
||||
setLocal(local: string, escape?: any): void;
|
||||
|
||||
getLocal(unescape?: any): string;
|
||||
|
||||
+1
-1
@@ -9,4 +9,4 @@ export function validateXML(xml: string|NodeJS.ReadableStream|{file: string}, pa
|
||||
valid: boolean;
|
||||
messages: string[];
|
||||
result: string;
|
||||
}) => void): void;
|
||||
}) => void): void;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs = require("fs");
|
||||
import validator = require("xsd-schema-validator");
|
||||
|
||||
|
||||
validator.validateXML("<foo:bar />", 'resources/foo.xsd', (err, result) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
@@ -12,4 +11,4 @@ validator.validateXML(fs.createReadStream('some.xml'), "schema.xsd", (err) => {
|
||||
});
|
||||
validator.validateXML({ file: "some.xml" }, "schema.xsd", (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user