@brokerize/client 1.3.1 → 1.3.2

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/dist/apiCtx.js CHANGED
@@ -54,6 +54,8 @@ export function createAuth({ authCfg, cfg, options, tokenRefreshCallback, }) {
54
54
  tokenType: responseJson.token_type,
55
55
  refreshTokenExpiresIn: responseJson.refresh_token_expires_in,
56
56
  idToken: responseJson.access_token,
57
+ refreshTokenWithoutTradingsession: responseJson.refresh_Token_without_tradingsession,
58
+ refreshTokenWithoutTradingsessionExpiresIn: responseJson.refresh_token_without_tradingsession_expires_in,
57
59
  },
58
60
  };
59
61
  if (tokenRefreshCallback) {
package/dist/client.d.ts CHANGED
@@ -1438,6 +1438,7 @@ export declare class Brokerize {
1438
1438
  private _cfg;
1439
1439
  private _defaultApi;
1440
1440
  constructor(cfg: BrokerizeConfig);
1441
+ refreshGuestUser(refreshToken: string): Promise<GuestAuthContextConfiguration>;
1441
1442
  createGuestUser(): Promise<AuthContextConfiguration>;
1442
1443
  /**
1443
1444
  * Create a context for making authorized API calls. This context will automatically take care of refreshing the access token
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthContextConfiguration, BrokerizeConfig, CognitoConfig, CognitoFacade, CognitoPoolConfig, Auth, RegisteredUserAuthContextConfiguration, TokenSet } from "./apiCtx";
1
+ import { AuthContextConfiguration, BrokerizeConfig, CognitoConfig, CognitoFacade, CognitoPoolConfig, Auth, RegisteredUserAuthContextConfiguration, TokenSet, GuestAuthContextConfiguration } from "./apiCtx";
2
2
  import { AuthorizedApiContext } from "./authorizedApiContext";
3
3
  import { BrokerizeError } from "./errors";
4
4
  import * as Models from "./modelExports";
@@ -12,6 +12,7 @@ export declare class Brokerize {
12
12
  private _cfg;
13
13
  private _defaultApi;
14
14
  constructor(cfg: BrokerizeConfig);
15
+ refreshGuestUser(refreshToken: string): Promise<GuestAuthContextConfiguration>;
15
16
  createGuestUser(): Promise<AuthContextConfiguration>;
16
17
  /**
17
18
  * Create a context for making authorized API calls. This context will automatically take care of refreshing the access token
package/dist/index.js CHANGED
@@ -37,6 +37,35 @@ export class Brokerize {
37
37
  this._cfg = cfg;
38
38
  this._defaultApi = new openApiClient.DefaultApi(createConfiguration(cfg));
39
39
  }
40
+ async refreshGuestUser(refreshToken) {
41
+ const response = await fetch(this._cfg.basePath + "/user/token", {
42
+ method: "POST",
43
+ headers: {
44
+ "x-brkrz-client-id": this._cfg.clientId,
45
+ "Content-Type": "application/x-www-form-urlencoded",
46
+ },
47
+ // XXX some runtimes do not have URLSearchParams, so just produce the body in the old-fashioned way
48
+ body: `grant_type=refresh_token&refresh_token=${encodeURIComponent(refreshToken)}`,
49
+ });
50
+ const responseJson = (await response.json());
51
+ return {
52
+ type: "guest",
53
+ idToken: responseJson.access_token,
54
+ tokens: {
55
+ updatedAt: Date.now(),
56
+ response: {
57
+ accessToken: responseJson.access_token,
58
+ refreshToken: responseJson.refresh_token,
59
+ expiresIn: responseJson.expires_in,
60
+ tokenType: responseJson.token_type,
61
+ refreshTokenExpiresIn: responseJson.refresh_token_expires_in,
62
+ idToken: responseJson.access_token,
63
+ refreshTokenWithoutTradingsession: responseJson.refresh_Token_without_tradingsession,
64
+ refreshTokenWithoutTradingsessionExpiresIn: responseJson.refresh_token_without_tradingsession_expires_in,
65
+ },
66
+ },
67
+ };
68
+ }
40
69
  async createGuestUser() {
41
70
  const updatedAt = Date.now();
42
71
  const user = await this._defaultApi.createGuestUser({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brokerize/client",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Client for the brokerize.com API",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/brokerize/client-js#readme",