stellar-sdk
Advanced tools
Comparing version 2.0.0-beta.9 to 2.0.0-rc.2
{ | ||
"source": { | ||
"include": ["lib", "node_modules/stellar-base/src"], | ||
"include": ["libdocs", "node_modules/stellar-base/src"], | ||
"exclude": "node_modules/stellar-base/src/generated" | ||
@@ -5,0 +5,0 @@ }, |
@@ -10,5 +10,5 @@ # Changelog | ||
some type definitions have changed: | ||
- The `Server` namespace has been broken up into `Server`, the `Server` class, | ||
and `ServerApi`, which handles all the types not defined by the class. So, | ||
for example, `Server.AccountRecord` -> `ServerApi.AccountRecord`. | ||
- Types that were once in the `Server` namespace but didn't actually deal with | ||
the `Server` class have been broken out into a new namespace, `ServerApi`. | ||
So, for example, `Server.AccountRecord` -> `ServerApi.AccountRecord`. | ||
- `Server.AccountResponse` is out of the `Server` namespace -> | ||
@@ -19,2 +19,3 @@ `AccountResponse` | ||
- Upgrade Webpack to v4. | ||
- Add support for providing app name and version to request headers. | ||
@@ -21,0 +22,0 @@ Many thanks to @Ffloriel and @Akuukis for their help with this release! |
@@ -41,3 +41,2 @@ 'use strict'; | ||
gulp.series( | ||
// TODO: output directly to "lib" folder (see tsconfig.json). | ||
function buildNode(done) { | ||
@@ -58,3 +57,2 @@ // TODO: Gulp-ify using `gulp-typescript`. | ||
gulp.series( | ||
// TODO: output directly to "lib" folder (see tsconfig.json). | ||
function buildNode(done) { | ||
@@ -68,10 +66,2 @@ // TODO: Gulp-ify using `gulp-typescript`. | ||
} | ||
}, | ||
function flatten() { | ||
return gulp.src('libdocs/src/**') | ||
.pipe(gulp.dest('libdocs')) | ||
}, | ||
function flattenClean() { | ||
return gulp.src('libdocs/src') | ||
.pipe(plugins.rimraf()); | ||
} | ||
@@ -78,0 +68,0 @@ ) |
@@ -40,3 +40,5 @@ "use strict"; | ||
timeout = setTimeout(function () { | ||
es.close(); | ||
if (es) { | ||
es.close(); | ||
} | ||
es = createEventSource(); | ||
@@ -43,0 +45,0 @@ }, options.reconnectTimeout || 15 * 1000); |
@@ -5,2 +5,3 @@ /// <reference path="../src/types/dom-monkeypatch.d.ts" /> | ||
export * from "./server_api"; | ||
export * from "./account_response"; | ||
export * from "./errors"; | ||
@@ -7,0 +8,0 @@ export { Config } from "./config"; |
@@ -8,2 +8,3 @@ "use strict"; | ||
tslib_1.__exportStar(require("./horizon_api"), exports); | ||
tslib_1.__exportStar(require("./account_response"), exports); | ||
tslib_1.__exportStar(require("./errors"), exports); | ||
@@ -10,0 +11,0 @@ var config_1 = require("./config"); |
@@ -44,2 +44,4 @@ /// <reference types="urijs" /> | ||
allowHttp?: boolean; | ||
appName?: string; | ||
appVersion?: string; | ||
} | ||
@@ -46,0 +48,0 @@ interface Timebounds { |
@@ -5,4 +5,8 @@ "use strict"; | ||
var bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js")); | ||
var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty")); | ||
var merge_1 = tslib_1.__importDefault(require("lodash/merge")); | ||
var stellar_base_1 = require("stellar-base"); | ||
var urijs_1 = tslib_1.__importDefault(require("urijs")); | ||
var call_builder_1 = require("./call_builder"); | ||
var config_1 = require("./config"); | ||
var errors_1 = require("./errors"); | ||
@@ -12,7 +16,4 @@ var account_call_builder_1 = require("./account_call_builder"); | ||
var assets_call_builder_1 = require("./assets_call_builder"); | ||
var call_builder_1 = require("./call_builder"); | ||
var config_1 = require("./config"); | ||
var effect_call_builder_1 = require("./effect_call_builder"); | ||
var friendbot_builder_1 = require("./friendbot_builder"); | ||
var horizon_axios_client_1 = tslib_1.__importStar(require("./horizon_axios_client")); | ||
var ledger_call_builder_1 = require("./ledger_call_builder"); | ||
@@ -27,2 +28,3 @@ var offer_call_builder_1 = require("./offer_call_builder"); | ||
var transaction_call_builder_1 = require("./transaction_call_builder"); | ||
var horizon_axios_client_1 = tslib_1.__importStar(require("./horizon_axios_client")); | ||
exports.SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; | ||
@@ -40,2 +42,15 @@ var STROOPS_IN_LUMEN = 10000000; | ||
: opts.allowHttp; | ||
var customHeaders = {}; | ||
if (opts.appName) { | ||
customHeaders["X-App-Name"] = opts.appName; | ||
} | ||
if (opts.appVersion) { | ||
customHeaders["X-App-Version"] = opts.appVersion; | ||
} | ||
if (!isEmpty_1.default(customHeaders)) { | ||
horizon_axios_client_1.default.interceptors.request.use(function (config) { | ||
config.headers = merge_1.default(customHeaders, config.headers); | ||
return config; | ||
}); | ||
} | ||
if (this.serverURL.protocol() !== "https" && !allowHttp) { | ||
@@ -42,0 +57,0 @@ throw new Error("Cannot connect to insecure horizon server"); |
{ | ||
"name": "stellar-sdk", | ||
"version": "2.0.0-beta.9", | ||
"version": "2.0.0-rc.2", | ||
"description": "stellar-sdk is a library for working with the Stellar Horizon server.", | ||
@@ -132,5 +132,5 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"@types/eventsource": "^1.1.0", | ||
"@types/eventsource": "^1.1.2", | ||
"@types/node": ">= 8", | ||
"@types/urijs": "^1.19.1", | ||
"@types/urijs": "^1.19.2", | ||
"axios": "^0.19.0", | ||
@@ -137,0 +137,0 @@ "bignumber.js": "^4.0.0", |
@@ -107,3 +107,5 @@ import isNode from "detect-node"; | ||
timeout = setTimeout(() => { | ||
es.close(); | ||
if (es) { | ||
es.close(); | ||
} | ||
/* tslint:disable-next-line:no-use-before-declare */ | ||
@@ -110,0 +112,0 @@ es = createEventSource(); |
@@ -13,2 +13,3 @@ // tslint:disable-next-line: no-reference | ||
// stellar-sdk classes to expose | ||
export * from "./account_response"; | ||
export * from "./errors"; | ||
@@ -15,0 +16,0 @@ export { Config } from "./config"; |
/* tslint:disable:variable-name no-namespace */ | ||
import BigNumber from "bignumber.js"; | ||
import isEmpty from "lodash/isEmpty"; | ||
import merge from "lodash/merge"; | ||
import { Asset, StrKey, Transaction, xdr } from "stellar-base"; | ||
import URI from "urijs"; | ||
import { CallBuilder } from "./call_builder"; | ||
import { Config } from "./config"; | ||
import { BadResponseError } from "./errors"; | ||
@@ -11,9 +16,4 @@ | ||
import { AssetsCallBuilder } from "./assets_call_builder"; | ||
import { CallBuilder } from "./call_builder"; | ||
import { Config } from "./config"; | ||
import { EffectCallBuilder } from "./effect_call_builder"; | ||
import { FriendbotBuilder } from "./friendbot_builder"; | ||
import HorizonAxiosClient, { | ||
getCurrentServerTime, | ||
} from "./horizon_axios_client"; | ||
import { LedgerCallBuilder } from "./ledger_call_builder"; | ||
@@ -30,2 +30,6 @@ import { OfferCallBuilder } from "./offer_call_builder"; | ||
import HorizonAxiosClient, { | ||
getCurrentServerTime, | ||
} from "./horizon_axios_client"; | ||
export const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; | ||
@@ -46,2 +50,4 @@ | ||
* @param {boolean} [opts.allowHttp] - Allow connecting to http servers, default: `false`. This must be set to false in production deployments! You can also use {@link Config} class to set this globally. | ||
* @param {string} [opts.appName] - Allow set custom header `X-App-Name`, default: `undefined`. | ||
* @param {string} [opts.appVersion] - Allow set custom header `X-App-Version`, default: `undefined`. | ||
*/ | ||
@@ -64,2 +70,19 @@ export class Server { | ||
const customHeaders: any = {}; | ||
if (opts.appName) { | ||
customHeaders["X-App-Name"] = opts.appName; | ||
} | ||
if (opts.appVersion) { | ||
customHeaders["X-App-Version"] = opts.appVersion; | ||
} | ||
if (!isEmpty(customHeaders)) { | ||
HorizonAxiosClient.interceptors.request.use((config) => { | ||
// merge the custom headers with an existing headers | ||
config.headers = merge(customHeaders, config.headers); | ||
return config; | ||
}); | ||
} | ||
if (this.serverURL.protocol() !== "https" && !allowHttp) { | ||
@@ -620,2 +643,4 @@ throw new Error("Cannot connect to insecure horizon server"); | ||
allowHttp?: boolean; | ||
appName?: string; | ||
appVersion?: string; | ||
} | ||
@@ -622,0 +647,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2906522
56932
Updated@types/eventsource@^1.1.2
Updated@types/urijs@^1.19.2