wapi-client 0.8.2 → 0.8.4

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.
@@ -61,7 +61,7 @@ var import_base_client = require('./base-client.cjs');
61
61
  var import_connection = require('./connection/connection.enums.cjs');
62
62
  var import__ = require('../index.cjs');
63
63
  var _a;
64
- var CLIENT_VERSION = (_a = '0.8.2') != null ? _a : "";
64
+ var CLIENT_VERSION = (_a = '0.8.4') != null ? _a : "";
65
65
  function createWsClient(opts) {
66
66
  const initialConnection = createConnection(opts);
67
67
  return new WsClient(initialConnection, opts);
@@ -35,7 +35,7 @@ import {
35
35
  } from "./connection/connection.enums";
36
36
  import { WapiClientType } from "../index";
37
37
  var _a;
38
- var CLIENT_VERSION = (_a = '0.8.2') != null ? _a : "";
38
+ var CLIENT_VERSION = (_a = '0.8.4') != null ? _a : "";
39
39
  function createWsClient(opts) {
40
40
  const initialConnection = createConnection(opts);
41
41
  return new WsClient(initialConnection, opts);
package/dist/client.cjs CHANGED
@@ -66,7 +66,7 @@ var import_errors = require('./lib/errors.cjs');
66
66
  var import_fns = require('./fns/index.cjs');
67
67
  var import_import_data = require('./fns/import-data/import-data.guards.cjs');
68
68
  var _a;
69
- var CLIENT_VERSION = (_a = '0.8.2') != null ? _a : "";
69
+ var CLIENT_VERSION = (_a = '0.8.4') != null ? _a : "";
70
70
  var Client = class {
71
71
  /**
72
72
  * @internal
package/dist/client.js CHANGED
@@ -50,7 +50,7 @@ import {
50
50
  isImportDataFnInput
51
51
  } from "./fns/import-data/import-data.guards";
52
52
  var _a;
53
- var CLIENT_VERSION = (_a = '0.8.2') != null ? _a : "";
53
+ var CLIENT_VERSION = (_a = '0.8.4') != null ? _a : "";
54
54
  var Client = class {
55
55
  /**
56
56
  * @internal
@@ -25,8 +25,19 @@ __export(create_access_token_exports, {
25
25
  module.exports = __toCommonJS(create_access_token_exports);
26
26
  var import_utils = require('../../lib/utils.cjs');
27
27
  var import_validator = require('../../lib/validator.cjs');
28
+ var clientFnToTxMap = new Map(
29
+ Object.entries({
30
+ aggregateTransfers: "aggregateTransferMany",
31
+ findBalances: "findBalanceMany",
32
+ findTokens: "findTokenMany",
33
+ findTransferGroups: "findTransferGroupMany",
34
+ findTransfers: "findTransferMany",
35
+ findWallets: "findWalletMany"
36
+ })
37
+ );
28
38
  var validate = (0, import_validator.getValidator)(import_validator.SchemaNames.CreateAccessTokenFnInput);
29
39
  function createAccessToken(options, input, fnOptions) {
40
+ var _a;
30
41
  const { client } = options;
31
42
  const { inputCopy, error } = (0, import_utils.validateClientFnInput)({
32
43
  input,
@@ -36,8 +47,20 @@ function createAccessToken(options, input, fnOptions) {
36
47
  if (error) {
37
48
  throw error;
38
49
  }
50
+ if (inputCopy.token && "scopes" in inputCopy.token) {
51
+ inputCopy.token.scopes = Array.from(
52
+ new Set(
53
+ (_a = inputCopy.token) == null ? void 0 : _a.scopes.map(
54
+ (scope) => {
55
+ var _a2;
56
+ return (_a2 = clientFnToTxMap.get(scope)) != null ? _a2 : scope;
57
+ }
58
+ )
59
+ )
60
+ );
61
+ }
39
62
  return client.api.createAccessToken({
40
63
  token: inputCopy.token,
41
- options
64
+ options: fnOptions
42
65
  });
43
66
  }
@@ -1,8 +1,19 @@
1
1
  // src/fns/create-access-token/create-access-token.ts
2
2
  import { validateClientFnInput } from "../../lib/utils.browser.js";
3
3
  import { getValidator, SchemaNames } from "../../lib/validator.browser.js";
4
+ var clientFnToTxMap = new Map(
5
+ Object.entries({
6
+ aggregateTransfers: "aggregateTransferMany",
7
+ findBalances: "findBalanceMany",
8
+ findTokens: "findTokenMany",
9
+ findTransferGroups: "findTransferGroupMany",
10
+ findTransfers: "findTransferMany",
11
+ findWallets: "findWalletMany"
12
+ })
13
+ );
4
14
  var validate = getValidator(SchemaNames.CreateAccessTokenFnInput);
5
15
  function createAccessToken(options, input, fnOptions) {
16
+ var _a;
6
17
  const { client } = options;
7
18
  const { inputCopy, error } = validateClientFnInput({
8
19
  input,
@@ -12,9 +23,21 @@ function createAccessToken(options, input, fnOptions) {
12
23
  if (error) {
13
24
  throw error;
14
25
  }
26
+ if (inputCopy.token && "scopes" in inputCopy.token) {
27
+ inputCopy.token.scopes = Array.from(
28
+ new Set(
29
+ (_a = inputCopy.token) == null ? void 0 : _a.scopes.map(
30
+ (scope) => {
31
+ var _a2;
32
+ return (_a2 = clientFnToTxMap.get(scope)) != null ? _a2 : scope;
33
+ }
34
+ )
35
+ )
36
+ );
37
+ }
15
38
  return client.api.createAccessToken({
16
39
  token: inputCopy.token,
17
- options
40
+ options: fnOptions
18
41
  });
19
42
  }
20
43
  export {
@@ -25,8 +25,19 @@ __export(create_access_token_exports, {
25
25
  module.exports = __toCommonJS(create_access_token_exports);
26
26
  var import_utils = require('../../lib/utils.cjs');
27
27
  var import_validator = require('../../lib/validator.cjs');
28
+ var clientFnToTxMap = new Map(
29
+ Object.entries({
30
+ aggregateTransfers: "aggregateTransferMany",
31
+ findBalances: "findBalanceMany",
32
+ findTokens: "findTokenMany",
33
+ findTransferGroups: "findTransferGroupMany",
34
+ findTransfers: "findTransferMany",
35
+ findWallets: "findWalletMany"
36
+ })
37
+ );
28
38
  var validate = (0, import_validator.getValidator)(import_validator.SchemaNames.CreateAccessTokenFnInput);
29
39
  function createAccessToken(options, input, fnOptions) {
40
+ var _a;
30
41
  const { client } = options;
31
42
  const { inputCopy, error } = (0, import_utils.validateClientFnInput)({
32
43
  input,
@@ -36,9 +47,21 @@ function createAccessToken(options, input, fnOptions) {
36
47
  if (error) {
37
48
  throw error;
38
49
  }
50
+ if (inputCopy.token && "scopes" in inputCopy.token) {
51
+ inputCopy.token.scopes = Array.from(
52
+ new Set(
53
+ (_a = inputCopy.token) == null ? void 0 : _a.scopes.map(
54
+ (scope) => {
55
+ var _a2;
56
+ return (_a2 = clientFnToTxMap.get(scope)) != null ? _a2 : scope;
57
+ }
58
+ )
59
+ )
60
+ );
61
+ }
39
62
  return client.api.createAccessToken({
40
63
  token: inputCopy.token,
41
- options
64
+ options: fnOptions
42
65
  });
43
66
  }
44
67
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,16 @@
1
- import { CreateAccessTokenLimited, CreateAccessTokenAdmin, CreateAccessTokenTxOptions, CreateAccessTokenTxOutput } from '../../txs/create-access-token/create-access-token.enums';
1
+ import { CreateAccessTokenAdmin, CreateAccessTokenTxOptions, CreateAccessTokenForcedFilters, CreateAccessTokenTxOutput } from '../../txs/create-access-token/create-access-token.enums';
2
+ export interface CreateAccessTokenFnLimited {
3
+ type: 'limited';
4
+ scopes: ('aggregateTransfers' | 'findBalances' | 'findTokens' | 'findTransferGroups' | 'findTransfers' | 'findWallets' | 'aggregateTransferMany' | 'findBalanceMany' | 'findTokenMany' | 'findTransferGroupMany' | 'findTransferMany' | 'findWalletMany' | 'getBalance' | 'getBalanceHistory' | 'getStatistics' | 'getToken' | 'getTokenMany' | 'getTransfer' | 'getTransferGroup' | 'getWallet' | 'getWalletMany')[];
5
+ /**
6
+ * JWT expiration time in minutes
7
+ */
8
+ expiresIn: number;
9
+ /**
10
+ * Forced filters for requests
11
+ */
12
+ filters?: CreateAccessTokenForcedFilters;
13
+ }
2
14
  /**
3
15
  * Optional flags for input
4
16
  */
@@ -12,7 +24,7 @@ export interface CreateAccessTokenFnInput {
12
24
  /**
13
25
  * Properties of the token to create
14
26
  */
15
- token?: CreateAccessTokenLimited | CreateAccessTokenAdmin;
27
+ token?: CreateAccessTokenFnLimited | CreateAccessTokenAdmin;
16
28
  options?: CreateAccessTokenFnOptions;
17
29
  }
18
30
  /**
@@ -1,8 +1,19 @@
1
1
  // src/fns/create-access-token/create-access-token.ts
2
2
  import { validateClientFnInput } from "../../lib/utils";
3
3
  import { getValidator, SchemaNames } from "../../lib/validator";
4
+ var clientFnToTxMap = new Map(
5
+ Object.entries({
6
+ aggregateTransfers: "aggregateTransferMany",
7
+ findBalances: "findBalanceMany",
8
+ findTokens: "findTokenMany",
9
+ findTransferGroups: "findTransferGroupMany",
10
+ findTransfers: "findTransferMany",
11
+ findWallets: "findWalletMany"
12
+ })
13
+ );
4
14
  var validate = getValidator(SchemaNames.CreateAccessTokenFnInput);
5
15
  function createAccessToken(options, input, fnOptions) {
16
+ var _a;
6
17
  const { client } = options;
7
18
  const { inputCopy, error } = validateClientFnInput({
8
19
  input,
@@ -12,9 +23,21 @@ function createAccessToken(options, input, fnOptions) {
12
23
  if (error) {
13
24
  throw error;
14
25
  }
26
+ if (inputCopy.token && "scopes" in inputCopy.token) {
27
+ inputCopy.token.scopes = Array.from(
28
+ new Set(
29
+ (_a = inputCopy.token) == null ? void 0 : _a.scopes.map(
30
+ (scope) => {
31
+ var _a2;
32
+ return (_a2 = clientFnToTxMap.get(scope)) != null ? _a2 : scope;
33
+ }
34
+ )
35
+ )
36
+ );
37
+ }
15
38
  return client.api.createAccessToken({
16
39
  token: inputCopy.token,
17
- options
40
+ options: fnOptions
18
41
  });
19
42
  }
20
43
  export {
@@ -9,7 +9,7 @@
9
9
  "description": "Properties of the token to create",
10
10
  "anyOf": [
11
11
  {
12
- "$ref": "/txs/create-access-token/create-access-token.schema.input.json#/definitions/create_access_token_limited"
12
+ "$ref": "#/definitions/create_access_token_fn_limited"
13
13
  },
14
14
  {
15
15
  "$ref": "/txs/create-access-token/create-access-token.schema.input.json#/definitions/create_access_token_admin"
@@ -29,6 +29,55 @@
29
29
  "$ref": "/txs/create-access-token/create-access-token.schema.input.json#/definitions/create_access_token_tx_options"
30
30
  }
31
31
  ]
32
+ },
33
+ "create_access_token_fn_limited": {
34
+ "type": "object",
35
+ "properties": {
36
+ "type": {
37
+ "enum": ["limited"]
38
+ },
39
+ "scopes": {
40
+ "type": "array",
41
+ "items": {
42
+ "type": "string",
43
+ "enum": [
44
+ "aggregateTransfers",
45
+ "findBalances",
46
+ "findTokens",
47
+ "findTransferGroups",
48
+ "findTransfers",
49
+ "findWallets",
50
+
51
+ "aggregateTransferMany",
52
+ "findBalanceMany",
53
+ "findTokenMany",
54
+ "findTransferGroupMany",
55
+ "findTransferMany",
56
+ "findWalletMany",
57
+ "getBalance",
58
+ "getBalanceHistory",
59
+ "getStatistics",
60
+ "getToken",
61
+ "getTokenMany",
62
+ "getTransfer",
63
+ "getTransferGroup",
64
+ "getWallet",
65
+ "getWalletMany"
66
+ ]
67
+ }
68
+ },
69
+ "filters": {
70
+ "description": "Forced filters for requests",
71
+ "type": "object",
72
+ "$ref": "/txs/create-access-token/create-access-token.schema.input.json#/definitions/create_access_token_forced_filters"
73
+ },
74
+ "expiresIn": {
75
+ "description": "JWT expiration time in minutes",
76
+ "type": "number"
77
+ }
78
+ },
79
+ "required": ["scopes", "type", "expiresIn"],
80
+ "additionalProperties": false
32
81
  }
33
82
  },
34
83
  "additionalProperties": false
@@ -57,9 +57,6 @@
57
57
  "expiresIn": {
58
58
  "description": "JWT expiration time in minutes",
59
59
  "type": "number"
60
- },
61
- "options": {
62
- "$ref": "#/definitions/create_access_token_tx_options"
63
60
  }
64
61
  },
65
62
  "required": ["scopes", "type", "expiresIn"],
@@ -74,9 +71,6 @@
74
71
  "expiresIn": {
75
72
  "description": "JWT expiration time in minutes",
76
73
  "type": "number"
77
- },
78
- "options": {
79
- "$ref": "#/definitions/create_access_token_tx_options"
80
74
  }
81
75
  },
82
76
  "required": ["type", "expiresIn"],
@@ -1,4 +1,4 @@
1
- /// <reference types="ws" />
1
+
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
4
  declare module 'wapi-client/lib/ws-types' {
@@ -2947,7 +2947,19 @@ declare module 'wapi-client/txs/create-access-token/create-access-token.enums' {
2947
2947
  }
2948
2948
  }
2949
2949
  declare module 'wapi-client/fns/create-access-token/create-access-token.enums' {
2950
- import { CreateAccessTokenLimited, CreateAccessTokenAdmin, CreateAccessTokenTxOptions, CreateAccessTokenTxOutput } from 'wapi-client/txs/create-access-token/create-access-token.enums';
2950
+ import { CreateAccessTokenAdmin, CreateAccessTokenTxOptions, CreateAccessTokenForcedFilters, CreateAccessTokenTxOutput } from 'wapi-client/txs/create-access-token/create-access-token.enums';
2951
+ export interface CreateAccessTokenFnLimited {
2952
+ type: 'limited';
2953
+ scopes: ('aggregateTransfers' | 'findBalances' | 'findTokens' | 'findTransferGroups' | 'findTransfers' | 'findWallets' | 'aggregateTransferMany' | 'findBalanceMany' | 'findTokenMany' | 'findTransferGroupMany' | 'findTransferMany' | 'findWalletMany' | 'getBalance' | 'getBalanceHistory' | 'getStatistics' | 'getToken' | 'getTokenMany' | 'getTransfer' | 'getTransferGroup' | 'getWallet' | 'getWalletMany')[];
2954
+ /**
2955
+ * JWT expiration time in minutes
2956
+ */
2957
+ expiresIn: number;
2958
+ /**
2959
+ * Forced filters for requests
2960
+ */
2961
+ filters?: CreateAccessTokenForcedFilters;
2962
+ }
2951
2963
  /**
2952
2964
  * Optional flags for input
2953
2965
  */
@@ -2961,7 +2973,7 @@ declare module 'wapi-client/fns/create-access-token/create-access-token.enums' {
2961
2973
  /**
2962
2974
  * Properties of the token to create
2963
2975
  */
2964
- token?: CreateAccessTokenLimited | CreateAccessTokenAdmin;
2976
+ token?: CreateAccessTokenFnLimited | CreateAccessTokenAdmin;
2965
2977
  options?: CreateAccessTokenFnOptions;
2966
2978
  }
2967
2979
  /**