@brokerize/client 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/apiCtx.d.ts +22 -0
- package/dist/apiCtx.js +25 -2
- package/dist/authorizedApiContext.js +7 -6
- package/dist/cjs/apiCtx.d.ts +22 -0
- package/dist/cjs/apiCtx.js +27 -2
- package/dist/cjs/authorizedApiContext.js +6 -5
- package/dist/cjs/index.js +9 -9
- package/dist/cjs/modelExports.d.ts +1 -0
- package/dist/cjs/modelExports.js +3 -1
- package/dist/cjs/swagger/models/PrepareOAuthRedirectParams.d.ts +15 -0
- package/dist/cjs/swagger/models/PrepareOAuthRedirectParams.js +11 -0
- package/dist/client.d.ts +30 -0
- package/dist/index.js +10 -10
- package/dist/modelExports.d.ts +1 -0
- package/dist/modelExports.js +1 -0
- package/dist/swagger/models/PrepareOAuthRedirectParams.d.ts +15 -0
- package/dist/swagger/models/PrepareOAuthRedirectParams.js +10 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -20,6 +20,9 @@ async function someBrokerizeActions() {
|
|
|
20
20
|
createWebSocket: (url, protocol) => new WebSocket(url, protocol),
|
|
21
21
|
// basePath: 'https://api-preview.brokerize.com', // this is the default value
|
|
22
22
|
// basePathCryptoService: 'https://crypto-service-api.com' // the optional external crypto service
|
|
23
|
+
// acceptLanguage: 'de', // optional `Accept-Language` header for localized responses (e.g. legal terms).
|
|
24
|
+
// // may also be a function `() => 'de'` that is evaluated on every request,
|
|
25
|
+
// // so runtime language changes are picked up without recreating the client.
|
|
23
26
|
})
|
|
24
27
|
|
|
25
28
|
/* create a guest user. the result contains the user's tokens and be stored, e.g. in a cookie or session storage */
|
package/dist/apiCtx.d.ts
CHANGED
|
@@ -19,7 +19,29 @@ export interface BrokerizeConfig {
|
|
|
19
19
|
* The AWS cognito configuration, if the application is supposed to be used with brokerize accounts.
|
|
20
20
|
*/
|
|
21
21
|
cognito?: CognitoConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Optional value for the `Accept-Language` header sent with API requests. Use this to request
|
|
24
|
+
* localized backend responses (e.g. legal terms) in the language selected in your application,
|
|
25
|
+
* overriding the language the browser would send by default.
|
|
26
|
+
*
|
|
27
|
+
* Accepts a static value (e.g. `"de"`, `"en"`, `"de-DE"`) or a function that returns the current
|
|
28
|
+
* language. The function is evaluated on every request, so runtime language changes are picked up
|
|
29
|
+
* without recreating the client. Return `undefined`/`null` (or provide no value) to omit the
|
|
30
|
+
* header and let the runtime/browser default apply.
|
|
31
|
+
*/
|
|
32
|
+
acceptLanguage?: string | (() => string | null | undefined | Promise<string | null | undefined>);
|
|
22
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the configured `Accept-Language` value (static or via a getter function) to a string,
|
|
36
|
+
* or `undefined` if none is configured / the getter yields an empty value.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveAcceptLanguage(cfg: BrokerizeConfig): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Adds the configured `Accept-Language` header to the given headers object (mutating and returning
|
|
41
|
+
* it) if a language is configured. No-op otherwise. Used to apply the configured language uniformly
|
|
42
|
+
* to authorized and unauthenticated requests.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withAcceptLanguage(cfg: BrokerizeConfig, headers: Record<string, string>): Promise<Record<string, string>>;
|
|
23
45
|
export type AuthContextConfiguration = GuestAuthContextConfiguration | RegisteredUserAuthContextConfiguration;
|
|
24
46
|
export type RegisteredUserAuthContextConfiguration = {
|
|
25
47
|
type: "registered";
|
package/dist/apiCtx.js
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
but reduced to the parts actually used by bg-trading. */
|
|
3
3
|
import { BrokerizeError } from "./index.js";
|
|
4
4
|
import { Configuration } from "./swagger/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the configured `Accept-Language` value (static or via a getter function) to a string,
|
|
7
|
+
* or `undefined` if none is configured / the getter yields an empty value.
|
|
8
|
+
*/
|
|
9
|
+
export async function resolveAcceptLanguage(cfg) {
|
|
10
|
+
const { acceptLanguage } = cfg;
|
|
11
|
+
const value = typeof acceptLanguage === "function"
|
|
12
|
+
? await acceptLanguage()
|
|
13
|
+
: acceptLanguage;
|
|
14
|
+
return value || undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Adds the configured `Accept-Language` header to the given headers object (mutating and returning
|
|
18
|
+
* it) if a language is configured. No-op otherwise. Used to apply the configured language uniformly
|
|
19
|
+
* to authorized and unauthenticated requests.
|
|
20
|
+
*/
|
|
21
|
+
export async function withAcceptLanguage(cfg, headers) {
|
|
22
|
+
const acceptLanguage = await resolveAcceptLanguage(cfg);
|
|
23
|
+
if (acceptLanguage) {
|
|
24
|
+
headers["Accept-Language"] = acceptLanguage;
|
|
25
|
+
}
|
|
26
|
+
return headers;
|
|
27
|
+
}
|
|
5
28
|
export function createConfiguration(cfg) {
|
|
6
29
|
if (!cfg.clientId) {
|
|
7
30
|
throw new Error("You must configure a clientId to use the brokerize API.");
|
|
@@ -33,10 +56,10 @@ export function createAuth({ authCfg, cfg, options, tokenRefreshCallback, }) {
|
|
|
33
56
|
}
|
|
34
57
|
const response = await fetch(cfg.basePath + "/user/token", {
|
|
35
58
|
method: "POST",
|
|
36
|
-
headers: {
|
|
59
|
+
headers: await withAcceptLanguage(cfg, {
|
|
37
60
|
"x-brkrz-client-id": cfg.clientId,
|
|
38
61
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
39
|
-
},
|
|
62
|
+
}),
|
|
40
63
|
// XXX some runtimes do not have URLSearchParams, so just produce the body in the old-fashioned way
|
|
41
64
|
body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(guestAuthCfg.tokens.response.refreshToken)}`,
|
|
42
65
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Subject } from "rxjs";
|
|
2
|
-
import { createConfiguration } from "./apiCtx.js";
|
|
2
|
+
import { createConfiguration, withAcceptLanguage, } from "./apiCtx.js";
|
|
3
3
|
import { BrokerizeError } from "./errors.js";
|
|
4
4
|
import { createPollingSubscription } from "./pollingSubscription.js";
|
|
5
5
|
import * as openApiClient from "./swagger/index.js";
|
|
@@ -74,13 +74,14 @@ export class AuthorizedApiContext {
|
|
|
74
74
|
throw new Error("AuthorizedApiContext is destroyed");
|
|
75
75
|
}
|
|
76
76
|
const tok = await this._auth.getToken();
|
|
77
|
+
const headers = await withAcceptLanguage(this._cfg, {
|
|
78
|
+
"x-brkrz-client-id": this._cfg.clientId,
|
|
79
|
+
Authorization: "Bearer " + tok.idToken,
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
});
|
|
77
82
|
return {
|
|
78
83
|
signal: this._abortController.signal,
|
|
79
|
-
headers
|
|
80
|
-
"x-brkrz-client-id": this._cfg.clientId,
|
|
81
|
-
Authorization: "Bearer " + tok.idToken,
|
|
82
|
-
"Content-Type": "application/json",
|
|
83
|
-
},
|
|
84
|
+
headers,
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
async getBrokers() {
|
package/dist/cjs/apiCtx.d.ts
CHANGED
|
@@ -19,7 +19,29 @@ export interface BrokerizeConfig {
|
|
|
19
19
|
* The AWS cognito configuration, if the application is supposed to be used with brokerize accounts.
|
|
20
20
|
*/
|
|
21
21
|
cognito?: CognitoConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Optional value for the `Accept-Language` header sent with API requests. Use this to request
|
|
24
|
+
* localized backend responses (e.g. legal terms) in the language selected in your application,
|
|
25
|
+
* overriding the language the browser would send by default.
|
|
26
|
+
*
|
|
27
|
+
* Accepts a static value (e.g. `"de"`, `"en"`, `"de-DE"`) or a function that returns the current
|
|
28
|
+
* language. The function is evaluated on every request, so runtime language changes are picked up
|
|
29
|
+
* without recreating the client. Return `undefined`/`null` (or provide no value) to omit the
|
|
30
|
+
* header and let the runtime/browser default apply.
|
|
31
|
+
*/
|
|
32
|
+
acceptLanguage?: string | (() => string | null | undefined | Promise<string | null | undefined>);
|
|
22
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the configured `Accept-Language` value (static or via a getter function) to a string,
|
|
36
|
+
* or `undefined` if none is configured / the getter yields an empty value.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveAcceptLanguage(cfg: BrokerizeConfig): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Adds the configured `Accept-Language` header to the given headers object (mutating and returning
|
|
41
|
+
* it) if a language is configured. No-op otherwise. Used to apply the configured language uniformly
|
|
42
|
+
* to authorized and unauthenticated requests.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withAcceptLanguage(cfg: BrokerizeConfig, headers: Record<string, string>): Promise<Record<string, string>>;
|
|
23
45
|
export type AuthContextConfiguration = GuestAuthContextConfiguration | RegisteredUserAuthContextConfiguration;
|
|
24
46
|
export type RegisteredUserAuthContextConfiguration = {
|
|
25
47
|
type: "registered";
|
package/dist/cjs/apiCtx.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAcceptLanguage = resolveAcceptLanguage;
|
|
4
|
+
exports.withAcceptLanguage = withAcceptLanguage;
|
|
3
5
|
exports.createConfiguration = createConfiguration;
|
|
4
6
|
exports.createAuth = createAuth;
|
|
5
7
|
/* Import/Export the DOM parts we rely on. Those are partial copies from the official TypeScript DOM library definitions (https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts),
|
|
6
8
|
but reduced to the parts actually used by bg-trading. */
|
|
7
9
|
const _1 = require(".");
|
|
8
10
|
const swagger_1 = require("./swagger");
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the configured `Accept-Language` value (static or via a getter function) to a string,
|
|
13
|
+
* or `undefined` if none is configured / the getter yields an empty value.
|
|
14
|
+
*/
|
|
15
|
+
async function resolveAcceptLanguage(cfg) {
|
|
16
|
+
const { acceptLanguage } = cfg;
|
|
17
|
+
const value = typeof acceptLanguage === "function"
|
|
18
|
+
? await acceptLanguage()
|
|
19
|
+
: acceptLanguage;
|
|
20
|
+
return value || undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Adds the configured `Accept-Language` header to the given headers object (mutating and returning
|
|
24
|
+
* it) if a language is configured. No-op otherwise. Used to apply the configured language uniformly
|
|
25
|
+
* to authorized and unauthenticated requests.
|
|
26
|
+
*/
|
|
27
|
+
async function withAcceptLanguage(cfg, headers) {
|
|
28
|
+
const acceptLanguage = await resolveAcceptLanguage(cfg);
|
|
29
|
+
if (acceptLanguage) {
|
|
30
|
+
headers["Accept-Language"] = acceptLanguage;
|
|
31
|
+
}
|
|
32
|
+
return headers;
|
|
33
|
+
}
|
|
9
34
|
function createConfiguration(cfg) {
|
|
10
35
|
if (!cfg.clientId) {
|
|
11
36
|
throw new Error("You must configure a clientId to use the brokerize API.");
|
|
@@ -37,10 +62,10 @@ function createAuth({ authCfg, cfg, options, tokenRefreshCallback, }) {
|
|
|
37
62
|
}
|
|
38
63
|
const response = await fetch(cfg.basePath + "/user/token", {
|
|
39
64
|
method: "POST",
|
|
40
|
-
headers: {
|
|
65
|
+
headers: await withAcceptLanguage(cfg, {
|
|
41
66
|
"x-brkrz-client-id": cfg.clientId,
|
|
42
67
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
43
|
-
},
|
|
68
|
+
}),
|
|
44
69
|
// XXX some runtimes do not have URLSearchParams, so just produce the body in the old-fashioned way
|
|
45
70
|
body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(guestAuthCfg.tokens.response.refreshToken)}`,
|
|
46
71
|
});
|
|
@@ -111,13 +111,14 @@ class AuthorizedApiContext {
|
|
|
111
111
|
throw new Error("AuthorizedApiContext is destroyed");
|
|
112
112
|
}
|
|
113
113
|
const tok = await this._auth.getToken();
|
|
114
|
+
const headers = await (0, apiCtx_1.withAcceptLanguage)(this._cfg, {
|
|
115
|
+
"x-brkrz-client-id": this._cfg.clientId,
|
|
116
|
+
Authorization: "Bearer " + tok.idToken,
|
|
117
|
+
"Content-Type": "application/json",
|
|
118
|
+
});
|
|
114
119
|
return {
|
|
115
120
|
signal: this._abortController.signal,
|
|
116
|
-
headers
|
|
117
|
-
"x-brkrz-client-id": this._cfg.clientId,
|
|
118
|
-
Authorization: "Bearer " + tok.idToken,
|
|
119
|
-
"Content-Type": "application/json",
|
|
120
|
-
},
|
|
121
|
+
headers,
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
async getBrokers() {
|
package/dist/cjs/index.js
CHANGED
|
@@ -88,10 +88,10 @@ class Brokerize {
|
|
|
88
88
|
async refreshGuestUser(refreshToken) {
|
|
89
89
|
const response = await fetch(this._cfg.basePath + "/user/token", {
|
|
90
90
|
method: "POST",
|
|
91
|
-
headers: {
|
|
91
|
+
headers: await (0, apiCtx_1.withAcceptLanguage)(this._cfg, {
|
|
92
92
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
93
93
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
94
|
-
},
|
|
94
|
+
}),
|
|
95
95
|
// XXX some runtimes do not have URLSearchParams, so just produce the body in the old-fashioned way
|
|
96
96
|
body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(refreshToken)}`,
|
|
97
97
|
});
|
|
@@ -123,10 +123,10 @@ class Brokerize {
|
|
|
123
123
|
async createGuestUser() {
|
|
124
124
|
const updatedAt = Date.now();
|
|
125
125
|
const user = await this._userApi.createGuestUser({
|
|
126
|
-
headers: {
|
|
126
|
+
headers: await (0, apiCtx_1.withAcceptLanguage)(this._cfg, {
|
|
127
127
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
128
128
|
"Content-Type": "application/json",
|
|
129
|
-
},
|
|
129
|
+
}),
|
|
130
130
|
});
|
|
131
131
|
return {
|
|
132
132
|
type: "guest",
|
|
@@ -173,24 +173,24 @@ class Brokerize {
|
|
|
173
173
|
},
|
|
174
174
|
});
|
|
175
175
|
}
|
|
176
|
-
checkRecoveryPhrase(recoveryPhrase) {
|
|
176
|
+
async checkRecoveryPhrase(recoveryPhrase) {
|
|
177
177
|
return this._userApi.checkRecoveryPhrase({
|
|
178
178
|
obtainTokenByRecoveryPhraseParams: { recoveryPhrase },
|
|
179
179
|
}, {
|
|
180
|
-
headers: {
|
|
180
|
+
headers: await (0, apiCtx_1.withAcceptLanguage)(this._cfg, {
|
|
181
181
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
182
182
|
"Content-Type": "application/json",
|
|
183
|
-
},
|
|
183
|
+
}),
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
async obtainTokenByRecoveryPhrase(recoveryPhrase) {
|
|
187
187
|
const tokResult = await this._userApi.obtainTokenByRecoveryPhrase({
|
|
188
188
|
obtainTokenByRecoveryPhraseParams: { recoveryPhrase },
|
|
189
189
|
}, {
|
|
190
|
-
headers: {
|
|
190
|
+
headers: await (0, apiCtx_1.withAcceptLanguage)(this._cfg, {
|
|
191
191
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
192
192
|
"Content-Type": "application/json",
|
|
193
|
-
},
|
|
193
|
+
}),
|
|
194
194
|
});
|
|
195
195
|
const updatedAt = Date.now();
|
|
196
196
|
return {
|
|
@@ -124,6 +124,7 @@ export { PortfoliosResponse } from "./swagger/models/PortfoliosResponse";
|
|
|
124
124
|
export { Position } from "./swagger/models/Position";
|
|
125
125
|
export { PositionValuation } from "./swagger/models/PositionValuation";
|
|
126
126
|
export { PrepareOAuthRedirectParams } from "./swagger/models/PrepareOAuthRedirectParams";
|
|
127
|
+
export { PrepareOAuthRedirectParamsAppearanceEnum } from "./swagger/models/PrepareOAuthRedirectParams";
|
|
127
128
|
export { PrepareOAuthRedirectResponse } from "./swagger/models/PrepareOAuthRedirectResponse";
|
|
128
129
|
export { PrepareTradeResponse } from "./swagger/models/PrepareTradeResponse";
|
|
129
130
|
export { PreparedTrade } from "./swagger/models/PreparedTrade";
|
package/dist/cjs/modelExports.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* tslint:disable */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.OrderIntent = exports.TrailingDistanceModeEnum = exports.SessionSyncInfoStatus = exports.PortfolioSyncInfoStatus = exports.OrderValidityType = exports.OrderStatus = exports.OrderModel = exports.OrderExtension = exports.LoginResponseState = exports.GenericTableRowValueType = exports.GenericTableRowValueLinkValueType = exports.GenericTableRowType = exports.EnableSessionTanParamsKind = exports.Direction = exports.DecoupledOperationState = exports.CashQuotation = exports.CancelOrderParamsMode = exports.BrokerEnvFilterType = exports.AuthMethodFlow = void 0;
|
|
4
|
+
exports.OrderIntent = exports.TrailingDistanceModeEnum = exports.SessionSyncInfoStatus = exports.PrepareOAuthRedirectParamsAppearanceEnum = exports.PortfolioSyncInfoStatus = exports.OrderValidityType = exports.OrderStatus = exports.OrderModel = exports.OrderExtension = exports.LoginResponseState = exports.GenericTableRowValueType = exports.GenericTableRowValueLinkValueType = exports.GenericTableRowType = exports.EnableSessionTanParamsKind = exports.Direction = exports.DecoupledOperationState = exports.CashQuotation = exports.CancelOrderParamsMode = exports.BrokerEnvFilterType = exports.AuthMethodFlow = void 0;
|
|
5
5
|
var AuthMethodFlow_1 = require("./swagger/models/AuthMethodFlow");
|
|
6
6
|
Object.defineProperty(exports, "AuthMethodFlow", { enumerable: true, get: function () { return AuthMethodFlow_1.AuthMethodFlow; } });
|
|
7
7
|
var BrokerEnvFilterType_1 = require("./swagger/models/BrokerEnvFilterType");
|
|
@@ -34,6 +34,8 @@ var OrderValidityType_1 = require("./swagger/models/OrderValidityType");
|
|
|
34
34
|
Object.defineProperty(exports, "OrderValidityType", { enumerable: true, get: function () { return OrderValidityType_1.OrderValidityType; } });
|
|
35
35
|
var PortfolioSyncInfoStatus_1 = require("./swagger/models/PortfolioSyncInfoStatus");
|
|
36
36
|
Object.defineProperty(exports, "PortfolioSyncInfoStatus", { enumerable: true, get: function () { return PortfolioSyncInfoStatus_1.PortfolioSyncInfoStatus; } });
|
|
37
|
+
var PrepareOAuthRedirectParams_1 = require("./swagger/models/PrepareOAuthRedirectParams");
|
|
38
|
+
Object.defineProperty(exports, "PrepareOAuthRedirectParamsAppearanceEnum", { enumerable: true, get: function () { return PrepareOAuthRedirectParams_1.PrepareOAuthRedirectParamsAppearanceEnum; } });
|
|
37
39
|
var SessionSyncInfoStatus_1 = require("./swagger/models/SessionSyncInfoStatus");
|
|
38
40
|
Object.defineProperty(exports, "SessionSyncInfoStatus", { enumerable: true, get: function () { return SessionSyncInfoStatus_1.SessionSyncInfoStatus; } });
|
|
39
41
|
var TrailingDistance_1 = require("./swagger/models/TrailingDistance");
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* @interface PrepareOAuthRedirectParams
|
|
15
15
|
*/
|
|
16
16
|
export interface PrepareOAuthRedirectParams {
|
|
17
|
+
/**
|
|
18
|
+
* Preferred appearance for login screens. Note that this can only be set explicitly for some selected brokers.
|
|
19
|
+
* If the broker does not support it, this is silently ignored and the default broker appearance is used.
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @memberof PrepareOAuthRedirectParams
|
|
22
|
+
*/
|
|
23
|
+
appearance?: PrepareOAuthRedirectParamsAppearanceEnum;
|
|
17
24
|
/**
|
|
18
25
|
*
|
|
19
26
|
* @type {string}
|
|
@@ -33,6 +40,14 @@ export interface PrepareOAuthRedirectParams {
|
|
|
33
40
|
*/
|
|
34
41
|
returnToUrl: string;
|
|
35
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @export
|
|
45
|
+
*/
|
|
46
|
+
export declare const PrepareOAuthRedirectParamsAppearanceEnum: {
|
|
47
|
+
readonly Light: "light";
|
|
48
|
+
readonly Dark: "dark";
|
|
49
|
+
};
|
|
50
|
+
export type PrepareOAuthRedirectParamsAppearanceEnum = (typeof PrepareOAuthRedirectParamsAppearanceEnum)[keyof typeof PrepareOAuthRedirectParamsAppearanceEnum];
|
|
36
51
|
export declare function PrepareOAuthRedirectParamsFromJSON(json: any): PrepareOAuthRedirectParams;
|
|
37
52
|
export declare function PrepareOAuthRedirectParamsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PrepareOAuthRedirectParams;
|
|
38
53
|
export declare function PrepareOAuthRedirectParamsToJSONRecursive(value?: PrepareOAuthRedirectParams | null, ignoreParent?: boolean): any;
|
|
@@ -12,10 +12,19 @@
|
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PrepareOAuthRedirectParamsAppearanceEnum = void 0;
|
|
15
16
|
exports.PrepareOAuthRedirectParamsFromJSON = PrepareOAuthRedirectParamsFromJSON;
|
|
16
17
|
exports.PrepareOAuthRedirectParamsFromJSONTyped = PrepareOAuthRedirectParamsFromJSONTyped;
|
|
17
18
|
exports.PrepareOAuthRedirectParamsToJSONRecursive = PrepareOAuthRedirectParamsToJSONRecursive;
|
|
18
19
|
exports.PrepareOAuthRedirectParamsToJSON = PrepareOAuthRedirectParamsToJSON;
|
|
20
|
+
const runtime_1 = require("../runtime");
|
|
21
|
+
/**
|
|
22
|
+
* @export
|
|
23
|
+
*/
|
|
24
|
+
exports.PrepareOAuthRedirectParamsAppearanceEnum = {
|
|
25
|
+
Light: "light",
|
|
26
|
+
Dark: "dark",
|
|
27
|
+
};
|
|
19
28
|
function PrepareOAuthRedirectParamsFromJSON(json) {
|
|
20
29
|
return PrepareOAuthRedirectParamsFromJSONTyped(json, false);
|
|
21
30
|
}
|
|
@@ -24,6 +33,7 @@ function PrepareOAuthRedirectParamsFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
24
33
|
return json;
|
|
25
34
|
}
|
|
26
35
|
return {
|
|
36
|
+
appearance: !(0, runtime_1.exists)(json, "appearance") ? undefined : json["appearance"],
|
|
27
37
|
brokerName: json["brokerName"],
|
|
28
38
|
env: json["env"],
|
|
29
39
|
returnToUrl: json["returnToUrl"],
|
|
@@ -37,6 +47,7 @@ function PrepareOAuthRedirectParamsToJSONRecursive(value, ignoreParent = false)
|
|
|
37
47
|
return null;
|
|
38
48
|
}
|
|
39
49
|
return {
|
|
50
|
+
appearance: value.appearance,
|
|
40
51
|
brokerName: value.brokerName,
|
|
41
52
|
env: value.env,
|
|
42
53
|
returnToUrl: value.returnToUrl,
|
package/dist/client.d.ts
CHANGED
|
@@ -1508,6 +1508,17 @@ export declare interface BrokerizeConfig {
|
|
|
1508
1508
|
* The AWS cognito configuration, if the application is supposed to be used with brokerize accounts.
|
|
1509
1509
|
*/
|
|
1510
1510
|
cognito?: CognitoConfig;
|
|
1511
|
+
/**
|
|
1512
|
+
* Optional value for the `Accept-Language` header sent with API requests. Use this to request
|
|
1513
|
+
* localized backend responses (e.g. legal terms) in the language selected in your application,
|
|
1514
|
+
* overriding the language the browser would send by default.
|
|
1515
|
+
*
|
|
1516
|
+
* Accepts a static value (e.g. `"de"`, `"en"`, `"de-DE"`) or a function that returns the current
|
|
1517
|
+
* language. The function is evaluated on every request, so runtime language changes are picked up
|
|
1518
|
+
* without recreating the client. Return `undefined`/`null` (or provide no value) to omit the
|
|
1519
|
+
* header and let the runtime/browser default apply.
|
|
1520
|
+
*/
|
|
1521
|
+
acceptLanguage?: string | (() => string | null | undefined | Promise<string | null | undefined>);
|
|
1511
1522
|
}
|
|
1512
1523
|
|
|
1513
1524
|
export declare class BrokerizeError extends Error {
|
|
@@ -7883,6 +7894,7 @@ declare namespace Models {
|
|
|
7883
7894
|
Position,
|
|
7884
7895
|
PositionValuation,
|
|
7885
7896
|
PrepareOAuthRedirectParams,
|
|
7897
|
+
PrepareOAuthRedirectParamsAppearanceEnum,
|
|
7886
7898
|
PrepareOAuthRedirectResponse,
|
|
7887
7899
|
PrepareTradeResponse,
|
|
7888
7900
|
PreparedTrade,
|
|
@@ -9243,6 +9255,7 @@ declare namespace openApiClient {
|
|
|
9243
9255
|
PrepareOAuthRedirectParamsToJSONRecursive,
|
|
9244
9256
|
PrepareOAuthRedirectParamsToJSON,
|
|
9245
9257
|
PrepareOAuthRedirectParams,
|
|
9258
|
+
PrepareOAuthRedirectParamsAppearanceEnum,
|
|
9246
9259
|
PrepareOAuthRedirectResponseFromJSON,
|
|
9247
9260
|
PrepareOAuthRedirectResponseFromJSONTyped,
|
|
9248
9261
|
PrepareOAuthRedirectResponseToJSONRecursive,
|
|
@@ -12098,6 +12111,13 @@ declare function PreparedTradeToJSONRecursive(value?: PreparedTrade | null, igno
|
|
|
12098
12111
|
* @interface PrepareOAuthRedirectParams
|
|
12099
12112
|
*/
|
|
12100
12113
|
declare interface PrepareOAuthRedirectParams {
|
|
12114
|
+
/**
|
|
12115
|
+
* Preferred appearance for login screens. Note that this can only be set explicitly for some selected brokers.
|
|
12116
|
+
* If the broker does not support it, this is silently ignored and the default broker appearance is used.
|
|
12117
|
+
* @type {string}
|
|
12118
|
+
* @memberof PrepareOAuthRedirectParams
|
|
12119
|
+
*/
|
|
12120
|
+
appearance?: PrepareOAuthRedirectParamsAppearanceEnum;
|
|
12101
12121
|
/**
|
|
12102
12122
|
*
|
|
12103
12123
|
* @type {string}
|
|
@@ -12118,6 +12138,16 @@ declare interface PrepareOAuthRedirectParams {
|
|
|
12118
12138
|
returnToUrl: string;
|
|
12119
12139
|
}
|
|
12120
12140
|
|
|
12141
|
+
/**
|
|
12142
|
+
* @export
|
|
12143
|
+
*/
|
|
12144
|
+
declare const PrepareOAuthRedirectParamsAppearanceEnum: {
|
|
12145
|
+
readonly Light: "light";
|
|
12146
|
+
readonly Dark: "dark";
|
|
12147
|
+
};
|
|
12148
|
+
|
|
12149
|
+
declare type PrepareOAuthRedirectParamsAppearanceEnum = (typeof PrepareOAuthRedirectParamsAppearanceEnum)[keyof typeof PrepareOAuthRedirectParamsAppearanceEnum];
|
|
12150
|
+
|
|
12121
12151
|
declare function PrepareOAuthRedirectParamsFromJSON(json: any): PrepareOAuthRedirectParams;
|
|
12122
12152
|
|
|
12123
12153
|
declare function PrepareOAuthRedirectParamsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PrepareOAuthRedirectParams;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Import/Export the DOM parts we rely on. Those are partial copies from the official TypeScript DOM library definitions (https://github.com/microsoft/TypeScript/blob/master/lib/lib.dom.d.ts),
|
|
2
2
|
but reduced to the parts actually used by bg-trading. */
|
|
3
|
-
import { createAuth, createConfiguration, } from "./apiCtx.js";
|
|
3
|
+
import { createAuth, createConfiguration, withAcceptLanguage, } from "./apiCtx.js";
|
|
4
4
|
import { AuthorizedApiContext, getWebSocketURLByBasePath, } from "./authorizedApiContext.js";
|
|
5
5
|
import { BrokerizeError } from "./errors.js";
|
|
6
6
|
import * as openApiClient from "./swagger/index.js";
|
|
@@ -48,10 +48,10 @@ export class Brokerize {
|
|
|
48
48
|
async refreshGuestUser(refreshToken) {
|
|
49
49
|
const response = await fetch(this._cfg.basePath + "/user/token", {
|
|
50
50
|
method: "POST",
|
|
51
|
-
headers: {
|
|
51
|
+
headers: await withAcceptLanguage(this._cfg, {
|
|
52
52
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
53
53
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
54
|
-
},
|
|
54
|
+
}),
|
|
55
55
|
// XXX some runtimes do not have URLSearchParams, so just produce the body in the old-fashioned way
|
|
56
56
|
body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(refreshToken)}`,
|
|
57
57
|
});
|
|
@@ -83,10 +83,10 @@ export class Brokerize {
|
|
|
83
83
|
async createGuestUser() {
|
|
84
84
|
const updatedAt = Date.now();
|
|
85
85
|
const user = await this._userApi.createGuestUser({
|
|
86
|
-
headers: {
|
|
86
|
+
headers: await withAcceptLanguage(this._cfg, {
|
|
87
87
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
88
88
|
"Content-Type": "application/json",
|
|
89
|
-
},
|
|
89
|
+
}),
|
|
90
90
|
});
|
|
91
91
|
return {
|
|
92
92
|
type: "guest",
|
|
@@ -133,24 +133,24 @@ export class Brokerize {
|
|
|
133
133
|
},
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
checkRecoveryPhrase(recoveryPhrase) {
|
|
136
|
+
async checkRecoveryPhrase(recoveryPhrase) {
|
|
137
137
|
return this._userApi.checkRecoveryPhrase({
|
|
138
138
|
obtainTokenByRecoveryPhraseParams: { recoveryPhrase },
|
|
139
139
|
}, {
|
|
140
|
-
headers: {
|
|
140
|
+
headers: await withAcceptLanguage(this._cfg, {
|
|
141
141
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
142
142
|
"Content-Type": "application/json",
|
|
143
|
-
},
|
|
143
|
+
}),
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
async obtainTokenByRecoveryPhrase(recoveryPhrase) {
|
|
147
147
|
const tokResult = await this._userApi.obtainTokenByRecoveryPhrase({
|
|
148
148
|
obtainTokenByRecoveryPhraseParams: { recoveryPhrase },
|
|
149
149
|
}, {
|
|
150
|
-
headers: {
|
|
150
|
+
headers: await withAcceptLanguage(this._cfg, {
|
|
151
151
|
"x-brkrz-client-id": this._cfg.clientId,
|
|
152
152
|
"Content-Type": "application/json",
|
|
153
|
-
},
|
|
153
|
+
}),
|
|
154
154
|
});
|
|
155
155
|
const updatedAt = Date.now();
|
|
156
156
|
return {
|
package/dist/modelExports.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export { PortfoliosResponse } from "./swagger/models/PortfoliosResponse";
|
|
|
124
124
|
export { Position } from "./swagger/models/Position";
|
|
125
125
|
export { PositionValuation } from "./swagger/models/PositionValuation";
|
|
126
126
|
export { PrepareOAuthRedirectParams } from "./swagger/models/PrepareOAuthRedirectParams";
|
|
127
|
+
export { PrepareOAuthRedirectParamsAppearanceEnum } from "./swagger/models/PrepareOAuthRedirectParams";
|
|
127
128
|
export { PrepareOAuthRedirectResponse } from "./swagger/models/PrepareOAuthRedirectResponse";
|
|
128
129
|
export { PrepareTradeResponse } from "./swagger/models/PrepareTradeResponse";
|
|
129
130
|
export { PreparedTrade } from "./swagger/models/PreparedTrade";
|
package/dist/modelExports.js
CHANGED
|
@@ -15,6 +15,7 @@ export { OrderModel } from "./swagger/models/OrderModel.js";
|
|
|
15
15
|
export { OrderStatus } from "./swagger/models/OrderStatus.js";
|
|
16
16
|
export { OrderValidityType } from "./swagger/models/OrderValidityType.js";
|
|
17
17
|
export { PortfolioSyncInfoStatus } from "./swagger/models/PortfolioSyncInfoStatus.js";
|
|
18
|
+
export { PrepareOAuthRedirectParamsAppearanceEnum } from "./swagger/models/PrepareOAuthRedirectParams.js";
|
|
18
19
|
export { SessionSyncInfoStatus } from "./swagger/models/SessionSyncInfoStatus.js";
|
|
19
20
|
export { TrailingDistanceModeEnum, } from "./swagger/models/TrailingDistance.js";
|
|
20
21
|
export { OrderIntent } from "./swagger/models/OrderIntent.js";
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* @interface PrepareOAuthRedirectParams
|
|
15
15
|
*/
|
|
16
16
|
export interface PrepareOAuthRedirectParams {
|
|
17
|
+
/**
|
|
18
|
+
* Preferred appearance for login screens. Note that this can only be set explicitly for some selected brokers.
|
|
19
|
+
* If the broker does not support it, this is silently ignored and the default broker appearance is used.
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @memberof PrepareOAuthRedirectParams
|
|
22
|
+
*/
|
|
23
|
+
appearance?: PrepareOAuthRedirectParamsAppearanceEnum;
|
|
17
24
|
/**
|
|
18
25
|
*
|
|
19
26
|
* @type {string}
|
|
@@ -33,6 +40,14 @@ export interface PrepareOAuthRedirectParams {
|
|
|
33
40
|
*/
|
|
34
41
|
returnToUrl: string;
|
|
35
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @export
|
|
45
|
+
*/
|
|
46
|
+
export declare const PrepareOAuthRedirectParamsAppearanceEnum: {
|
|
47
|
+
readonly Light: "light";
|
|
48
|
+
readonly Dark: "dark";
|
|
49
|
+
};
|
|
50
|
+
export type PrepareOAuthRedirectParamsAppearanceEnum = (typeof PrepareOAuthRedirectParamsAppearanceEnum)[keyof typeof PrepareOAuthRedirectParamsAppearanceEnum];
|
|
36
51
|
export declare function PrepareOAuthRedirectParamsFromJSON(json: any): PrepareOAuthRedirectParams;
|
|
37
52
|
export declare function PrepareOAuthRedirectParamsFromJSONTyped(json: any, ignoreDiscriminator: boolean): PrepareOAuthRedirectParams;
|
|
38
53
|
export declare function PrepareOAuthRedirectParamsToJSONRecursive(value?: PrepareOAuthRedirectParams | null, ignoreParent?: boolean): any;
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
* https://openapi-generator.tech
|
|
11
11
|
* Do not edit the class manually.
|
|
12
12
|
*/
|
|
13
|
+
import { exists } from "../runtime.js";
|
|
14
|
+
/**
|
|
15
|
+
* @export
|
|
16
|
+
*/
|
|
17
|
+
export const PrepareOAuthRedirectParamsAppearanceEnum = {
|
|
18
|
+
Light: "light",
|
|
19
|
+
Dark: "dark",
|
|
20
|
+
};
|
|
13
21
|
export function PrepareOAuthRedirectParamsFromJSON(json) {
|
|
14
22
|
return PrepareOAuthRedirectParamsFromJSONTyped(json, false);
|
|
15
23
|
}
|
|
@@ -18,6 +26,7 @@ export function PrepareOAuthRedirectParamsFromJSONTyped(json, ignoreDiscriminato
|
|
|
18
26
|
return json;
|
|
19
27
|
}
|
|
20
28
|
return {
|
|
29
|
+
appearance: !exists(json, "appearance") ? undefined : json["appearance"],
|
|
21
30
|
brokerName: json["brokerName"],
|
|
22
31
|
env: json["env"],
|
|
23
32
|
returnToUrl: json["returnToUrl"],
|
|
@@ -31,6 +40,7 @@ export function PrepareOAuthRedirectParamsToJSONRecursive(value, ignoreParent =
|
|
|
31
40
|
return null;
|
|
32
41
|
}
|
|
33
42
|
return {
|
|
43
|
+
appearance: value.appearance,
|
|
34
44
|
brokerName: value.brokerName,
|
|
35
45
|
env: value.env,
|
|
36
46
|
returnToUrl: value.returnToUrl,
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brokerize/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Client for the brokerize.com API",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/brokerize/client-js#readme",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"package.json": "sort-package-json"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@microsoft/api-extractor": "7.58.
|
|
65
|
-
"@openapitools/openapi-generator-cli": "2.
|
|
66
|
-
"@types/node": "24.
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
68
|
-
"eslint": "10.
|
|
64
|
+
"@microsoft/api-extractor": "7.58.11",
|
|
65
|
+
"@openapitools/openapi-generator-cli": "2.39.1",
|
|
66
|
+
"@types/node": "24.13.3",
|
|
67
|
+
"@typescript-eslint/eslint-plugin": "8.64.0",
|
|
68
|
+
"eslint": "10.7.0",
|
|
69
69
|
"eslint-config-prettier": "10.1.8",
|
|
70
70
|
"husky": "9.1.7",
|
|
71
|
-
"lint-staged": "17.0.
|
|
72
|
-
"prettier": "3.
|
|
71
|
+
"lint-staged": "17.0.8",
|
|
72
|
+
"prettier": "3.9.5",
|
|
73
73
|
"sort-package-json": "4.0.0",
|
|
74
74
|
"typescript": "6.0.3"
|
|
75
75
|
},
|