theauthapi 1.0.8 → 1.0.11

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 CHANGED
@@ -6,11 +6,11 @@
6
6
  - [Installation](#installation)
7
7
  - [Configuration](#configuration)
8
8
  - [Usage](#usage)
9
- - [Example: Validating an api-key](#example-validating-an-api-key)
10
- - [Example: Listing API-keys](#example-listing-api-keys)
9
+ - [Example: Validating an API-Key](#example-validating-an-api-key)
10
+ - [Example: Listing API-Keys](#example-listing-api-keys)
11
11
  - [Example: Listing the projects of an account](#example-listing-the-projects-of-an-account)
12
- - [Example: Listing projects and associated API Keys](#example-listing-projects-and-associated-api-keys)
13
- - [Example: Creating an API Key](#example-creating-an-api-key)
12
+ - [Example: Listing projects and associated API-Keys](#example-listing-projects-and-associated-api-keys)
13
+ - [Example: Creating an API-Key](#example-creating-an-api-key)
14
14
  - [Handling Errors](#handling-errors)
15
15
  - [Typescript](#typescript)
16
16
  - [📙 Further Reading](#-further-reading)
@@ -31,9 +31,9 @@ yarn add theauthapi
31
31
 
32
32
  ## Configuration
33
33
 
34
- You'll need to configure the library with your `access key` and `account id`, you can grab these from [TheAuthAPI](https://app.theauthapi.com/dashboard) dashboard.
34
+ You'll need to configure the library with your `access key` and `account id`, you can grab these from [TheAuthAPI](https://app.theauthapi.com) dashboard.
35
35
 
36
- For further instructions on creating an account, check out our [how to guides](https://thatapicompany.notion.site/The-Auth-API-Knowledge-Base-21660cee84e640729714fad43d9ce546).
36
+ For further instructions on creating an account, check out our [how to guides](https://support.theauthapi.com/).
37
37
 
38
38
  ### Imports
39
39
 
@@ -59,7 +59,6 @@ You can also provide custom options:
59
59
 
60
60
  ```javascript
61
61
  const theAuthAPI = new TheAuthAPI("YOUR_ACCESS_KEY", {
62
- timeout: 3600,
63
62
  retryCount: 2,
64
63
  });
65
64
  ```
@@ -70,8 +69,6 @@ const theAuthAPI = new TheAuthAPI("YOUR_ACCESS_KEY", {
70
69
  type Options = {
71
70
  // server url
72
71
  host?: string;
73
- // request timeout in ms
74
- timeout?: string | number;
75
72
  // number of retries before failing
76
73
  retryCount?: number;
77
74
  };
@@ -104,7 +101,7 @@ All methods return a promise containing the returned JSON as a javascript object
104
101
  | DELETE | delete\* | `client.apiKeys.deleteKey("MY_KEY")` |
105
102
  | PATCH | update\* | `client.apiKeys.updateKey("MY_KEY", { name: "UPDATED_KEY_NAME" })` |
106
103
 
107
- #### Example: Validating an api-key
104
+ #### Example: Validating an API-Key
108
105
 
109
106
  You can easily validate an API key using `apiKeys.isValidKey` which returns `true` if the key is valid, `false` otherwise.
110
107
  `isValidKey` throws an `ApiRequestError` if there's a network issue, it's advised to wrap it in a `try/catch` to handle the potential error
@@ -139,6 +136,8 @@ try {
139
136
  }
140
137
  ```
141
138
 
139
+ **Note:** If you want to consume the API key and get the API key entity in return, you can use `apiKeys.authenticateKey` which returns an ApiKey.
140
+
142
141
  #### Example: Listing API-keys
143
142
 
144
143
  ```javascript
@@ -163,10 +162,12 @@ try {
163
162
  ```typescript
164
163
  type ApiKeyFilter = {
165
164
  projectId?: string;
166
- customAccountId?: string;
167
- customUserId?: string;
165
+ name?: string;
166
+ customAccountId?: string | null;
167
+ customUserId?: string | null;
168
168
  isActive?: boolean;
169
169
  };
170
+
170
171
  ```
171
172
 
172
173
  **Example**: filtering api-keys with a specific `projectId` where the keys are not active
@@ -182,6 +183,10 @@ try {
182
183
  }
183
184
  ```
184
185
 
186
+ **NOTE** that if your access key is at account level, you need to specify `projectId` when listing the API keys:
187
+ `getKeys({ projectId: "PROJECT_ID" })`, otherwise if your access key is created at project level, you don't have to specify `projectId`,
188
+ the access key's `projectId` will be used to get the API-keys (i.e. you'll see only the keys of the project your access key is created against)
189
+
185
190
  #### Example: Listing the projects of an account
186
191
 
187
192
  ```javascript
@@ -201,7 +206,7 @@ try {
201
206
  }
202
207
  ```
203
208
 
204
- #### Example: Listing projects and associated API Keys
209
+ #### Example: Listing projects and associated API-Keys
205
210
 
206
211
  ```javascript
207
212
  async function getProjectsWithKeys(accountId: string) {
@@ -218,7 +223,7 @@ async function getProjectsWithKeys(accountId: string) {
218
223
  }
219
224
  ```
220
225
 
221
- #### Example: Creating an API Key
226
+ #### Example: Creating an API-Key
222
227
 
223
228
  ```javascript
224
229
  theAuthAPI.apiKeys
@@ -324,5 +329,6 @@ async function getProjectsIds(accountId: string): Promise<string[]> {
324
329
 
325
330
  - Create your account [https://theauthapi.com](https://theauthapi.com)
326
331
  - View our [Knowledge Base](https://thatapicompany.notion.site/The-Auth-API-Knowledge-Base-21660cee84e640729714fad43d9ce546) help centre
332
+ - Read our [API docs](https://docs.theauthapi.com)
327
333
  - Articles on best Auth practice - [https://theauthapi.com/articles](https://theauthapi.com/articles)
328
334
  - Meet the team behind The Auth API - [That API Company](https://thatapicompany.com/)
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const HttpMethod_1 = require("../../services/ApiRequest/HttpMethod");
13
- const util_1 = require("../../util");
14
13
  class Accounts {
15
14
  constructor(apiService) {
16
15
  this.api = apiService;
@@ -18,7 +17,6 @@ class Accounts {
18
17
  }
19
18
  getAccount(accountId) {
20
19
  return __awaiter(this, void 0, void 0, function* () {
21
- (0, util_1.validateString)("accountId", accountId);
22
20
  return yield this.api.request(HttpMethod_1.HttpMethod.GET, `${this.endpoint}/${accountId}`);
23
21
  });
24
22
  }
@@ -6,14 +6,13 @@ declare class ApiKeys implements ApiKeysInterface {
6
6
  private readonly endpoint;
7
7
  constructor(apiService: ApiRequest);
8
8
  isValidKey(apikey: string): Promise<boolean>;
9
+ authenticateKey(apikey: string): Promise<ApiKey>;
9
10
  getKeys(filter?: ApiKeyFilter): Promise<ApiKey[]>;
10
11
  getKey(apikey: string): Promise<ApiKey>;
11
12
  createKey(apiKey: ApiKeyInput): Promise<ApiKey>;
12
13
  updateKey(apiKey: string, updatedKey: UpdateApiKeyInput): Promise<ApiKey>;
13
14
  deleteKey(apiKey: string): Promise<boolean>;
14
- private validateCreateKeyInput;
15
- private validateUpdateKeyInput;
16
- private validateFiltersInput;
15
+ reactivateKey(apiKey: string): Promise<ApiKey>;
17
16
  private getKeysFilterEndpoint;
18
17
  }
19
18
  export default ApiKeys;
@@ -13,8 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const HttpMethod_1 = require("../../services/ApiRequest/HttpMethod");
16
- const lodash_omit_1 = __importDefault(require("lodash.omit"));
17
- const util_1 = require("../../util");
18
16
  const ApiResponseError_1 = __importDefault(require("../../services/ApiRequest/ApiResponseError"));
19
17
  class ApiKeys {
20
18
  constructor(apiService) {
@@ -23,9 +21,8 @@ class ApiKeys {
23
21
  }
24
22
  isValidKey(apikey) {
25
23
  return __awaiter(this, void 0, void 0, function* () {
26
- (0, util_1.validateString)("apikey", apikey);
27
24
  try {
28
- const key = yield this.api.request(HttpMethod_1.HttpMethod.GET, `/api-keys/${apikey}`);
25
+ const key = yield this.authenticateKey(apikey);
29
26
  return key.key !== undefined;
30
27
  }
31
28
  catch (error) {
@@ -36,6 +33,11 @@ class ApiKeys {
36
33
  }
37
34
  });
38
35
  }
36
+ authenticateKey(apikey) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield this.api.request(HttpMethod_1.HttpMethod.POST, `/api-keys/auth/${apikey}`);
39
+ });
40
+ }
39
41
  getKeys(filter) {
40
42
  return __awaiter(this, void 0, void 0, function* () {
41
43
  const endpoint = this.getKeysFilterEndpoint(filter);
@@ -44,67 +46,35 @@ class ApiKeys {
44
46
  }
45
47
  getKey(apikey) {
46
48
  return __awaiter(this, void 0, void 0, function* () {
47
- (0, util_1.validateString)("apikey", apikey);
48
49
  return yield this.api.request(HttpMethod_1.HttpMethod.GET, `/api-keys/${apikey}`);
49
50
  });
50
51
  }
51
52
  createKey(apiKey) {
52
53
  return __awaiter(this, void 0, void 0, function* () {
53
- this.validateCreateKeyInput(apiKey);
54
54
  return yield this.api.request(HttpMethod_1.HttpMethod.POST, "/api-keys", apiKey);
55
55
  });
56
56
  }
57
57
  updateKey(apiKey, updatedKey) {
58
58
  return __awaiter(this, void 0, void 0, function* () {
59
- this.validateUpdateKeyInput(apiKey, updatedKey);
60
59
  return yield this.api.request(HttpMethod_1.HttpMethod.PATCH, `/api-keys/${apiKey}`, updatedKey);
61
60
  });
62
61
  }
63
62
  deleteKey(apiKey) {
64
63
  return __awaiter(this, void 0, void 0, function* () {
65
- (0, util_1.validateString)("apiKey", apiKey);
66
64
  return yield this.api.request(HttpMethod_1.HttpMethod.DELETE, `/api-keys/${apiKey}`);
67
65
  });
68
66
  }
69
- validateCreateKeyInput(apiKey) {
70
- if (!apiKey) {
71
- throw new TypeError("apiKey must be an object");
72
- }
73
- if (!apiKey.name) {
74
- throw TypeError("apiKey object must contain the property name");
75
- }
76
- // validate string properties only
77
- for (const [key, value] of Object.entries((0, lodash_omit_1.default)(apiKey, ["customMetaData", "rateLimitConfigs"]))) {
78
- (0, util_1.validateString)(key, value);
79
- }
80
- }
81
- validateUpdateKeyInput(apiKey, updatedKey) {
82
- if (!updatedKey) {
83
- throw new TypeError("updatedKey must be an object");
84
- }
85
- if (!updatedKey.name) {
86
- throw TypeError("updatedKey object must contain the property [name]");
87
- }
88
- (0, util_1.validateString)("apiKey", apiKey);
89
- (0, util_1.validateString)("name", updatedKey.name);
90
- }
91
- validateFiltersInput(filter) {
92
- if (filter) {
93
- if (filter.isActive && typeof filter.isActive !== "boolean") {
94
- throw TypeError("isActive must be a boolean");
95
- }
96
- Object.entries((0, lodash_omit_1.default)(filter, "isActive")).forEach(([key, value]) => {
97
- (0, util_1.validateString)(key, value);
98
- });
99
- }
67
+ reactivateKey(apiKey) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ return yield this.api.request(HttpMethod_1.HttpMethod.PATCH, `/api-keys/${apiKey}/reactivate`);
70
+ });
100
71
  }
101
72
  getKeysFilterEndpoint(filter) {
102
- this.validateFiltersInput(filter);
103
73
  let filters = [];
104
- if (filter) {
74
+ if (filter !== undefined) {
105
75
  filters = Object.entries(filter).map(([key, value]) => `${key}=${value}`);
106
76
  }
107
- return `${this.endpoint}${filter ? "?" : ""}${filters.join("&")}`;
77
+ return `${this.endpoint}${filter !== undefined ? "?" : ""}${filters.join("&")}`;
108
78
  }
109
79
  }
110
80
  exports.default = ApiKeys;
@@ -2,8 +2,10 @@ import { ApiKey, ApiKeyFilter, ApiKeyInput, UpdateApiKeyInput } from "../../type
2
2
  export interface ApiKeysInterface {
3
3
  isValidKey(apiKey: string): Promise<boolean>;
4
4
  getKey(apiKey: string): Promise<ApiKey>;
5
+ authenticateKey(apiKey: string): Promise<ApiKey>;
5
6
  getKeys(filter?: ApiKeyFilter): Promise<ApiKey[]>;
6
7
  createKey(apiKey: ApiKeyInput): Promise<ApiKey>;
7
8
  updateKey(apiKey: string, updateTo: UpdateApiKeyInput): Promise<ApiKey>;
8
9
  deleteKey(apiKey: string): Promise<boolean>;
10
+ reactivateKey(apiKey: string): Promise<ApiKey>;
9
11
  }
@@ -10,7 +10,5 @@ declare class Projects implements ProjectsInterface {
10
10
  deleteProject(projectId: string): Promise<boolean>;
11
11
  createProject(project: CreateProjectInput): Promise<Project>;
12
12
  updateProject(projectId: string, project: UpdateProjectInput): Promise<Project>;
13
- private validateCreateProjectInput;
14
- private validateUpdateProjectInput;
15
13
  }
16
14
  export default Projects;
@@ -9,9 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const types_1 = require("../../types");
13
12
  const HttpMethod_1 = require("../../services/ApiRequest/HttpMethod");
14
- const util_1 = require("../../util");
15
13
  class Projects {
16
14
  constructor(apiService) {
17
15
  this.api = apiService;
@@ -19,50 +17,28 @@ class Projects {
19
17
  }
20
18
  getProjects(accountId) {
21
19
  return __awaiter(this, void 0, void 0, function* () {
22
- (0, util_1.validateString)("accountId", accountId);
23
20
  return yield this.api.request(HttpMethod_1.HttpMethod.GET, `${this.endpoint}?accountId=${accountId}`);
24
21
  });
25
22
  }
26
23
  getProject(projectId) {
27
24
  return __awaiter(this, void 0, void 0, function* () {
28
- (0, util_1.validateString)("projectId", projectId);
29
25
  return yield this.api.request(HttpMethod_1.HttpMethod.GET, `${this.endpoint}/${projectId}`);
30
26
  });
31
27
  }
32
28
  deleteProject(projectId) {
33
29
  return __awaiter(this, void 0, void 0, function* () {
34
- (0, util_1.validateString)("projectId", projectId);
35
30
  return yield this.api.request(HttpMethod_1.HttpMethod.DELETE, `${this.endpoint}/${projectId}`);
36
31
  });
37
32
  }
38
33
  createProject(project) {
39
34
  return __awaiter(this, void 0, void 0, function* () {
40
- this.validateCreateProjectInput(project);
41
35
  return yield this.api.request(HttpMethod_1.HttpMethod.POST, this.endpoint, project);
42
36
  });
43
37
  }
44
38
  updateProject(projectId, project) {
45
39
  return __awaiter(this, void 0, void 0, function* () {
46
- this.validateUpdateProjectInput(projectId, project);
47
40
  return this.api.request(HttpMethod_1.HttpMethod.PATCH, `${this.endpoint}/${projectId}`, project);
48
41
  });
49
42
  }
50
- validateCreateProjectInput(project) {
51
- if (!project) {
52
- throw new TypeError("project must be an object");
53
- }
54
- (0, util_1.validateString)("name", project.name);
55
- (0, util_1.validateString)("accountId", project.accountId);
56
- if (!Object.values(types_1.Environment).includes(project.env)) {
57
- throw TypeError(`expected env to be one of [${Object.values(types_1.Environment).map((v) => `"${v}"`)}], got: ${project.env}`);
58
- }
59
- }
60
- validateUpdateProjectInput(projectId, project) {
61
- if (!project) {
62
- throw new TypeError("project must be an object");
63
- }
64
- (0, util_1.validateString)("projectId", projectId);
65
- (0, util_1.validateString)("name", project.name);
66
- }
67
43
  }
68
44
  exports.default = Projects;
package/dist/index.d.ts CHANGED
@@ -4,31 +4,21 @@ import Projects from "./endpoints/Projects/Projects";
4
4
  import Accounts from "./endpoints/Accounts/Accounts";
5
5
  declare type Options = {
6
6
  host?: string;
7
- timeout?: string | number;
8
- cacheTTL?: number;
9
- enable?: boolean;
10
7
  retryCount?: number;
11
8
  };
12
9
  declare class TheAuthAPI {
13
- queue: [];
14
10
  accessKey: string;
15
11
  host: string;
16
12
  timeout: number | string | undefined;
17
- cacheTTL: number;
18
13
  api: ApiRequest;
19
14
  apiKeys: ApiKeys;
20
15
  projects: Projects;
21
16
  accounts: Accounts;
22
17
  /**
23
- * Initialize a new `Analytics` with your Segment project's `writeKey` and an
24
- * optional dictionary of `options`.
25
- *
26
18
  * @param {String} accessKey
27
19
  * @param {Object} [options] (optional)
28
- * @property {Number} flushAt (default: 20)
29
- * @property {Number} flushInterval (default: 10000)
30
20
  * @property {String} host (default: 'https://api.segment.io')
31
- * @property {Boolean} enable (default: true)
21
+ * @property {number} retryCount (default: 3)
32
22
  */
33
23
  constructor(accessKey: string, options?: Options);
34
24
  authenticateAPIKey(key: string, callback?: (err: any, data: any) => any): Promise<unknown>;
package/dist/index.js CHANGED
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const assert_1 = __importDefault(require("assert"));
16
16
  const remove_trailing_slash_1 = __importDefault(require("remove-trailing-slash"));
17
17
  const ApiRequest_1 = __importDefault(require("./services/ApiRequest/ApiRequest"));
18
- const util_1 = require("./util");
19
18
  const ApiKeys_1 = __importDefault(require("./endpoints/ApiKeys/ApiKeys"));
20
19
  const HttpMethod_1 = require("./services/ApiRequest/HttpMethod");
21
20
  const Projects_1 = __importDefault(require("./endpoints/Projects/Projects"));
@@ -24,44 +23,30 @@ const Accounts_1 = __importDefault(require("./endpoints/Accounts/Accounts"));
24
23
  const noop = () => { };
25
24
  class TheAuthAPI {
26
25
  /**
27
- * Initialize a new `Analytics` with your Segment project's `writeKey` and an
28
- * optional dictionary of `options`.
29
- *
30
26
  * @param {String} accessKey
31
27
  * @param {Object} [options] (optional)
32
- * @property {Number} flushAt (default: 20)
33
- * @property {Number} flushInterval (default: 10000)
34
28
  * @property {String} host (default: 'https://api.segment.io')
35
- * @property {Boolean} enable (default: true)
29
+ * @property {number} retryCount (default: 3)
36
30
  */
37
31
  constructor(accessKey, options) {
38
32
  var _a;
39
33
  (0, assert_1.default)(accessKey, "You must pass your project's write key.");
40
- this.queue = [];
41
34
  this.accessKey = accessKey;
42
35
  this.host = (0, remove_trailing_slash_1.default)((options === null || options === void 0 ? void 0 : options.host) || "https://api.theauthapi.com");
43
- this.timeout = options === null || options === void 0 ? void 0 : options.timeout;
44
- this.cacheTTL = (_a = options === null || options === void 0 ? void 0 : options.cacheTTL) !== null && _a !== void 0 ? _a : 60;
45
36
  this.api = new ApiRequest_1.default({
46
37
  accessKey: this.accessKey,
47
38
  host: this.host,
39
+ retryCount: (_a = options === null || options === void 0 ? void 0 : options.retryCount) !== null && _a !== void 0 ? _a : 3,
48
40
  });
49
41
  this.apiKeys = new ApiKeys_1.default(this.api);
50
42
  this.projects = new Projects_1.default(this.api);
51
43
  this.accounts = new Accounts_1.default(this.api);
52
- Object.defineProperty(this, "enable", {
53
- configurable: false,
54
- writable: false,
55
- enumerable: true,
56
- value: typeof (options === null || options === void 0 ? void 0 : options.enable) === "boolean" ? options.enable : true,
57
- });
58
44
  }
59
45
  /*
60
46
  @deprecated
61
47
  */
62
48
  authenticateAPIKey(key, callback) {
63
49
  return __awaiter(this, void 0, void 0, function* () {
64
- (0, util_1.validateString)("key", key);
65
50
  const cb = callback || noop;
66
51
  const done = (err) => {
67
52
  cb(err, data);
@@ -1 +1 @@
1
- export declare const version = "1.0.6";
1
+ export declare const version = "1.0.11";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.0.6";
4
+ exports.version = "1.0.11";
@@ -5,13 +5,11 @@ declare type Config = {
5
5
  accessKey: string;
6
6
  headers?: object;
7
7
  retryCount?: number;
8
- timeout?: number | string;
9
8
  };
10
9
  declare class ApiRequest implements ApiCall {
11
10
  host: string;
12
11
  headers: object;
13
12
  accessKey: string;
14
- timeout: number;
15
13
  retryCount: number;
16
14
  constructor(config: Config);
17
15
  _init(): void;
@@ -16,15 +16,13 @@ const axios_1 = __importDefault(require("axios"));
16
16
  const libraryMeta_1 = require("../../libraryMeta");
17
17
  const ApiRequestError_1 = __importDefault(require("./ApiRequestError"));
18
18
  const axios_retry_1 = __importDefault(require("axios-retry"));
19
- const ms_1 = __importDefault(require("ms"));
20
19
  const ApiResponseError_1 = __importDefault(require("./ApiResponseError"));
21
20
  class ApiRequest {
22
21
  constructor(config) {
23
- const { host, accessKey, headers, retryCount, timeout } = config;
22
+ const { host, accessKey, headers, retryCount } = config;
24
23
  this.host = host;
25
24
  this.accessKey = accessKey;
26
25
  this.headers = this._generateDefaultHeaders();
27
- this.timeout = timeout ? (typeof timeout === "string" ? (0, ms_1.default)(timeout) : timeout) : 0;
28
26
  this.retryCount = retryCount !== null && retryCount !== void 0 ? retryCount : 3;
29
27
  if (headers) {
30
28
  this.headers = Object.assign(Object.assign({}, this.headers), { headers });
@@ -1,17 +1,17 @@
1
1
  export declare type ApiKey = {
2
2
  key: string;
3
3
  name: string;
4
- customMetaData: string;
4
+ customMetaData: AnyJson;
5
5
  customAccountId: string;
6
6
  customUserId: string;
7
- env: string;
7
+ env: Environment;
8
8
  createdAt: Date;
9
9
  updatedAt: Date;
10
10
  isActive: boolean;
11
+ rateLimitConfigs: RateLimitConfiguration;
12
+ expiry: Date;
11
13
  };
12
14
  export declare type RateLimitConfiguration = {
13
- rateLimitedEntity?: string;
14
- ratelimitedEnitityId?: any;
15
15
  rateLimit: number;
16
16
  rateLimitTtl: number;
17
17
  };
@@ -19,21 +19,27 @@ export declare type ApiKeyInput = {
19
19
  name: string;
20
20
  projectId?: string;
21
21
  key?: string;
22
- customMetaData?: object;
22
+ customMetaData?: AnyJson;
23
23
  customAccountId?: string;
24
- rateLimitConfigs?: RateLimitConfiguration;
25
24
  customUserId?: string;
25
+ rateLimitConfigs?: RateLimitConfiguration;
26
+ expiry?: Date;
26
27
  };
27
28
  export declare type ApiKeyFilter = {
28
29
  projectId?: string;
29
- customAccountId?: string;
30
- customUserId?: string;
30
+ name?: string;
31
+ customAccountId?: string | null;
32
+ customUserId?: string | null;
31
33
  isActive?: boolean;
32
34
  };
33
35
  export declare type UpdateApiKeyInput = {
34
36
  name: string;
35
- customMetaData?: object;
37
+ key?: string;
38
+ customMetaData?: AnyJson;
36
39
  customAccountId?: string;
40
+ customUserId?: string;
41
+ expiry?: Date | null;
42
+ rateLimitConfigs?: RateLimitConfiguration | null;
37
43
  };
38
44
  export declare enum AuthedEntityType {
39
45
  USER = "USER",
@@ -53,7 +59,7 @@ export declare type Project = AuthBaseEntity & {
53
59
  id: string;
54
60
  name: string;
55
61
  accountId: string;
56
- env: string;
62
+ env: Environment;
57
63
  };
58
64
  export declare enum Environment {
59
65
  LIVE = "live",
@@ -71,3 +77,9 @@ export declare type Account = AuthBaseEntity & {
71
77
  id: string;
72
78
  name: string;
73
79
  };
80
+ declare type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
81
+ declare type JsonMap = {
82
+ [key: string]: AnyJson;
83
+ };
84
+ declare type JsonArray = Array<AnyJson>;
85
+ export {};
package/dist/usage.js ADDED
@@ -0,0 +1,20 @@
1
+ const TheAuthAPI = require("./index").default;
2
+
3
+ const accessKey = "live_access_tXhV0mDbN81n7dGRuBPAVvfwsv5N4pmlaGLCELXOtFoWU2EGV6cN5UA3LhjrUg9B";
4
+ const theAuthAPI = new TheAuthAPI(accessKey, {
5
+ host: "http://localhost:8080",
6
+ });
7
+
8
+ async function getKeys() {
9
+ const keys = await theAuthAPI.apiKeys.getKeys();
10
+ return keys.map((k) => k.key);
11
+ }
12
+
13
+ const apikey =
14
+ "test_DdRU9zW8LSHGjzuDDHYqPcDm4ocacFJl6I6wtzBGKevgnAzy8GvqFEuZIj3ykqzS";
15
+ (async () => {
16
+ console.log(await theAuthAPI.apiKeys.createKey({
17
+ name: "Sheesh",
18
+ expiry: new Date("Sheesh"),
19
+ }));
20
+ })();
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "theauthapi",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "description": "Client library for TheAuthAPI.com",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
8
  "dist"
9
9
  ],
10
+ "keywords": [
11
+ "theauthapi",
12
+ "authapi"
13
+ ],
10
14
  "scripts": {
11
15
  "test": "jest --runInBand",
12
16
  "test:coverage": "jest --coverage --runInBand",
13
- "np": "np --no-publish",
14
- "release": "yarn run np",
15
17
  "build": "tsc",
16
18
  "prepublish": "npm run build"
17
19
  },
@@ -29,16 +31,11 @@
29
31
  "assert": "^2.0.0",
30
32
  "axios": "^0.21.4",
31
33
  "axios-retry": "^3.1.9",
32
- "lodash.isstring": "^4.0.1",
33
- "lodash.omit": "^4.5.0",
34
- "ms": "^2.1.3",
35
34
  "remove-trailing-slash": "^0.1.1"
36
35
  },
37
36
  "devDependencies": {
38
- "@size-limit/preset-small-lib": "^7.0.8",
39
- "@types/basic-auth": "^1.1.3",
40
37
  "@types/express": "^4.17.13",
41
- "@types/jest": "^27.4.1",
38
+ "@types/jest": "^27.5.2",
42
39
  "@types/lodash.isstring": "^4.0.6",
43
40
  "@types/lodash.omit": "^4.5.6",
44
41
  "@types/ms": "^0.7.31",
@@ -51,9 +48,7 @@
51
48
  "express": "^4.15.2",
52
49
  "jest": "^27.5.1",
53
50
  "prettier": "2.6.2",
54
- "size-limit": "^4.11.0",
55
- "ts-jest": "^27.1.4",
56
- "ts-node": "^10.7.0",
51
+ "ts-jest": "^28.0.8",
57
52
  "typescript": "^4.6.3"
58
53
  }
59
54
  }