theauthapi 1.0.15 → 1.0.17

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.
Files changed (34) hide show
  1. package/README.md +368 -366
  2. package/dist/index.cjs +15 -15
  3. package/dist/index.d.cts +200 -0
  4. package/dist/{index.d.ts → index.d.mts} +3 -3
  5. package/dist/index.mjs +15 -15
  6. package/dist/{types/index.d.ts → types.d.cts} +16 -14
  7. package/dist/types.d.ts +87 -0
  8. package/package.json +29 -6
  9. package/dist/endpoints/Accounts/Accounts.d.ts +0 -10
  10. package/dist/endpoints/Accounts/Accounts.js +0 -22
  11. package/dist/endpoints/Accounts/AccountsInterface.d.ts +0 -4
  12. package/dist/endpoints/Accounts/AccountsInterface.js +0 -1
  13. package/dist/endpoints/ApiKeys/ApiKeys.d.ts +0 -19
  14. package/dist/endpoints/ApiKeys/ApiKeys.js +0 -80
  15. package/dist/endpoints/ApiKeys/ApiKeysInterface.d.ts +0 -12
  16. package/dist/endpoints/ApiKeys/ApiKeysInterface.js +0 -1
  17. package/dist/endpoints/Projects/Projects.d.ts +0 -14
  18. package/dist/endpoints/Projects/Projects.js +0 -42
  19. package/dist/endpoints/Projects/ProjectsInterface.d.ts +0 -8
  20. package/dist/endpoints/Projects/ProjectsInterface.js +0 -1
  21. package/dist/index.js +0 -69
  22. package/dist/libraryMeta.d.ts +0 -1
  23. package/dist/libraryMeta.js +0 -1
  24. package/dist/services/ApiRequest/ApiCall.d.ts +0 -5
  25. package/dist/services/ApiRequest/ApiCall.js +0 -1
  26. package/dist/services/ApiRequest/ApiRequest.d.ts +0 -24
  27. package/dist/services/ApiRequest/ApiRequest.js +0 -110
  28. package/dist/services/ApiRequest/ApiRequestError.d.ts +0 -10
  29. package/dist/services/ApiRequest/ApiRequestError.js +0 -13
  30. package/dist/services/ApiRequest/ApiResponseError.d.ts +0 -12
  31. package/dist/services/ApiRequest/ApiResponseError.js +0 -15
  32. package/dist/services/ApiRequest/HttpMethod.d.ts +0 -7
  33. package/dist/services/ApiRequest/HttpMethod.js +0 -8
  34. package/dist/types/index.js +0 -10
package/dist/index.cjs CHANGED
@@ -32,7 +32,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
32
32
  });
33
33
  }
34
34
 
35
- const version = "1.0.11";
35
+ const version = '1.0.11';
36
36
 
37
37
  /**
38
38
  *
@@ -58,7 +58,7 @@ class ApiResponseError extends Error {
58
58
  constructor(statusCode, message) {
59
59
  super(`(${statusCode}): ${message}`);
60
60
  this.statusCode = statusCode;
61
- this.name = "ApiResponseError";
61
+ this.name = 'ApiResponseError';
62
62
  }
63
63
  }
64
64
 
@@ -78,10 +78,10 @@ class ApiRequest {
78
78
  var _a;
79
79
  const isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d*)?(?:[-+]\d{2}:?\d{2}|Z)?$/;
80
80
  function isIsoDateString(value) {
81
- return value && typeof value === "string" && isoDateFormat.test(value);
81
+ return value && typeof value === 'string' && isoDateFormat.test(value);
82
82
  }
83
83
  function handleDates(body) {
84
- if (body === null || body === undefined || typeof body !== "object") {
84
+ if (body === null || body === undefined || typeof body !== 'object') {
85
85
  return body;
86
86
  }
87
87
  for (const key of Object.keys(body)) {
@@ -89,7 +89,7 @@ class ApiRequest {
89
89
  if (isIsoDateString(value)) {
90
90
  body[key] = new Date(value);
91
91
  }
92
- else if (typeof value === "object") {
92
+ else if (typeof value === 'object') {
93
93
  handleDates(value);
94
94
  }
95
95
  }
@@ -132,9 +132,9 @@ class ApiRequest {
132
132
  }
133
133
  _generateDefaultHeaders() {
134
134
  return {
135
- "user-agent": `theauthapi-client-node/${version}`,
136
- "x-api-key": this.accessKey,
137
- "api-key": this.accessKey,
135
+ 'user-agent': `theauthapi-client-node/${version}`,
136
+ 'x-api-key': this.accessKey,
137
+ 'api-key': this.accessKey,
138
138
  };
139
139
  }
140
140
  _isErrorRetryable(error) {
@@ -170,7 +170,7 @@ var HttpMethod;
170
170
  class ApiKeys {
171
171
  constructor(apiService) {
172
172
  this.api = apiService;
173
- this.endpoint = "/api-keys/";
173
+ this.endpoint = '/api-keys/';
174
174
  }
175
175
  isValidKey(apikey) {
176
176
  return __awaiter(this, void 0, void 0, function* () {
@@ -204,7 +204,7 @@ class ApiKeys {
204
204
  }
205
205
  createKey(apiKey) {
206
206
  return __awaiter(this, void 0, void 0, function* () {
207
- return yield this.api.request(HttpMethod.POST, "/api-keys", apiKey);
207
+ return yield this.api.request(HttpMethod.POST, '/api-keys', apiKey);
208
208
  });
209
209
  }
210
210
  updateKey(apiKey, updatedKey) {
@@ -232,14 +232,14 @@ class ApiKeys {
232
232
  if (filter !== undefined) {
233
233
  filters = Object.entries(filter).map(([key, value]) => `${key}=${value}`);
234
234
  }
235
- return `${this.endpoint}${filter !== undefined ? "?" : ""}${filters.join("&")}`;
235
+ return `${this.endpoint}${filter !== undefined ? '?' : ''}${filters.join('&')}`;
236
236
  }
237
237
  }
238
238
 
239
239
  class Projects {
240
240
  constructor(apiService) {
241
241
  this.api = apiService;
242
- this.endpoint = "/projects";
242
+ this.endpoint = '/projects';
243
243
  }
244
244
  getProjects(accountId) {
245
245
  return __awaiter(this, void 0, void 0, function* () {
@@ -271,7 +271,7 @@ class Projects {
271
271
  class Accounts {
272
272
  constructor(apiService) {
273
273
  this.api = apiService;
274
- this.endpoint = "/accounts";
274
+ this.endpoint = '/accounts';
275
275
  }
276
276
  getAccount(accountId) {
277
277
  return __awaiter(this, void 0, void 0, function* () {
@@ -293,7 +293,7 @@ class TheAuthAPI {
293
293
  var _a;
294
294
  assert(accessKey, "You must pass your project's write key.");
295
295
  this.accessKey = accessKey;
296
- this.host = removeSlash((options === null || options === void 0 ? void 0 : options.host) || "https://api.theauthapi.com");
296
+ this.host = removeSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://api.theauthapi.com');
297
297
  this.api = new ApiRequest({
298
298
  accessKey: this.accessKey,
299
299
  host: this.host,
@@ -318,7 +318,7 @@ class TheAuthAPI {
318
318
  sentAt: new Date().getTime(),
319
319
  };
320
320
  try {
321
- const key = yield this.api.request(HttpMethod.POST, "/auth/authenticate", data);
321
+ const key = yield this.api.request(HttpMethod.POST, '/auth/authenticate', data);
322
322
  done(key);
323
323
  return key;
324
324
  }
@@ -0,0 +1,200 @@
1
+ declare enum HttpMethod {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ DELETE = "DELETE",
5
+ PATCH = "PATCH",
6
+ PUT = "PUT"
7
+ }
8
+
9
+ interface ApiCall {
10
+ request<T>(method: HttpMethod, endpoint: string, payload?: any): Promise<T>;
11
+ }
12
+
13
+ type Config = {
14
+ host: string;
15
+ accessKey: string;
16
+ headers?: object;
17
+ retryCount?: number;
18
+ };
19
+ declare class ApiRequest implements ApiCall {
20
+ host: string;
21
+ headers: object;
22
+ accessKey: string;
23
+ retryCount: number;
24
+ constructor(config: Config);
25
+ _init(): void;
26
+ request<T>(method: HttpMethod, endpoint: string, payload?: any): Promise<T>;
27
+ _generateDefaultHeaders(): {
28
+ 'user-agent': string;
29
+ 'x-api-key': string;
30
+ 'api-key': string;
31
+ };
32
+ _isErrorRetryable(error: any): boolean;
33
+ }
34
+
35
+ type ApiKey = {
36
+ key: string;
37
+ name: string;
38
+ customMetaData: AnyJson;
39
+ customAccountId: string;
40
+ customUserId: string;
41
+ env: Environment;
42
+ createdAt: Date;
43
+ updatedAt: Date;
44
+ isActive: boolean;
45
+ rateLimitConfigs: RateLimitConfiguration;
46
+ expiry: Date;
47
+ };
48
+ type RateLimitConfiguration = {
49
+ rateLimit: number;
50
+ rateLimitTtl: number;
51
+ };
52
+ type ApiKeyInput = {
53
+ name: string;
54
+ projectId?: string;
55
+ key?: string;
56
+ customMetaData?: AnyJson;
57
+ customAccountId?: string;
58
+ customUserId?: string;
59
+ rateLimitConfigs?: RateLimitConfiguration;
60
+ expiry?: Date;
61
+ };
62
+ type ApiKeyFilter = {
63
+ projectId?: string;
64
+ name?: string;
65
+ customAccountId?: string | null;
66
+ customUserId?: string | null;
67
+ isActive?: boolean;
68
+ };
69
+ type UpdateApiKeyInput = {
70
+ name: string;
71
+ key?: string;
72
+ customMetaData?: AnyJson;
73
+ customAccountId?: string;
74
+ customUserId?: string;
75
+ expiry?: Date | null;
76
+ rateLimitConfigs?: RateLimitConfiguration | null;
77
+ };
78
+ declare enum AuthedEntityType {
79
+ USER = "USER",
80
+ ACCESS_KEY = "ACCESS_KEY"
81
+ }
82
+ type AuthBaseEntity = {
83
+ isActive: boolean;
84
+ createdBy: string;
85
+ createdByType?: AuthedEntityType;
86
+ createdIn: string;
87
+ lastChangedBy: string;
88
+ lastChangedByType?: AuthedEntityType;
89
+ updatedAt: Date;
90
+ createdAt: Date;
91
+ };
92
+ type Project = AuthBaseEntity & {
93
+ id: string;
94
+ name: string;
95
+ accountId: string;
96
+ env: Environment;
97
+ };
98
+ declare enum Environment {
99
+ LIVE = "live",
100
+ TEST = "test"
101
+ }
102
+ type CreateProjectInput = {
103
+ name: string;
104
+ accountId: string;
105
+ env: Environment;
106
+ };
107
+ type UpdateProjectInput = {
108
+ name: string;
109
+ };
110
+ type Account = AuthBaseEntity & {
111
+ id: string;
112
+ name: string;
113
+ };
114
+ type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
115
+ type JsonMap = {
116
+ [key: string]: AnyJson;
117
+ };
118
+ type JsonArray = Array<AnyJson>;
119
+
120
+ interface ApiKeysInterface {
121
+ isValidKey(apiKey: string): Promise<boolean>;
122
+ getKey(apiKey: string): Promise<ApiKey>;
123
+ authenticateKey(apiKey: string): Promise<ApiKey>;
124
+ getKeys(filter?: ApiKeyFilter): Promise<ApiKey[]>;
125
+ createKey(apiKey: ApiKeyInput): Promise<ApiKey>;
126
+ updateKey(apiKey: string, updateTo: UpdateApiKeyInput): Promise<ApiKey>;
127
+ deleteKey(apiKey: string): Promise<boolean>;
128
+ reactivateKey(apiKey: string): Promise<ApiKey>;
129
+ rotateKey(apiKey: string): Promise<ApiKey>;
130
+ }
131
+
132
+ declare class ApiKeys implements ApiKeysInterface {
133
+ api: ApiRequest;
134
+ private readonly endpoint;
135
+ constructor(apiService: ApiRequest);
136
+ isValidKey(apikey: string): Promise<boolean>;
137
+ authenticateKey(apikey: string): Promise<ApiKey>;
138
+ getKeys(filter?: ApiKeyFilter): Promise<ApiKey[]>;
139
+ getKey(apikey: string): Promise<ApiKey>;
140
+ createKey(apiKey: ApiKeyInput): Promise<ApiKey>;
141
+ updateKey(apiKey: string, updatedKey: UpdateApiKeyInput): Promise<ApiKey>;
142
+ deleteKey(apiKey: string): Promise<boolean>;
143
+ reactivateKey(apiKey: string): Promise<ApiKey>;
144
+ rotateKey(apiKey: string): Promise<ApiKey>;
145
+ private getKeysFilterEndpoint;
146
+ }
147
+
148
+ interface ProjectsInterface {
149
+ getProjects(accountId: string): Promise<Project[]>;
150
+ getProject(projectId: string): Promise<Project>;
151
+ deleteProject(projectId: string): Promise<boolean>;
152
+ createProject(project: CreateProjectInput): Promise<Project>;
153
+ updateProject(name: string, updateTo: UpdateProjectInput): Promise<Project>;
154
+ }
155
+
156
+ declare class Projects implements ProjectsInterface {
157
+ api: ApiRequest;
158
+ endpoint: string;
159
+ constructor(apiService: ApiRequest);
160
+ getProjects(accountId: string): Promise<Project[]>;
161
+ getProject(projectId: string): Promise<Project>;
162
+ deleteProject(projectId: string): Promise<boolean>;
163
+ createProject(project: CreateProjectInput): Promise<Project>;
164
+ updateProject(projectId: string, project: UpdateProjectInput): Promise<Project>;
165
+ }
166
+
167
+ interface AccountsInterface {
168
+ getAccount(accountId: string): Promise<Account>;
169
+ }
170
+
171
+ declare class Accounts implements AccountsInterface {
172
+ api: ApiRequest;
173
+ endpoint: string;
174
+ constructor(apiService: ApiRequest);
175
+ getAccount(accountId: string): Promise<Account>;
176
+ }
177
+
178
+ type Options = {
179
+ host?: string;
180
+ retryCount?: number;
181
+ };
182
+ declare class TheAuthAPI {
183
+ accessKey: string;
184
+ host: string;
185
+ timeout: number | string | undefined;
186
+ api: ApiRequest;
187
+ apiKeys: ApiKeys;
188
+ projects: Projects;
189
+ accounts: Accounts;
190
+ /**
191
+ * @param {String} accessKey
192
+ * @param {Object} [options] (optional)
193
+ * @property {String} host (default: 'https://api.segment.io')
194
+ * @property {number} retryCount (default: 3)
195
+ */
196
+ constructor(accessKey: string, options?: Options);
197
+ authenticateAPIKey(key: string, callback?: (err: any, data: any) => any): Promise<unknown>;
198
+ }
199
+
200
+ export = TheAuthAPI;
@@ -25,9 +25,9 @@ declare class ApiRequest implements ApiCall {
25
25
  _init(): void;
26
26
  request<T>(method: HttpMethod, endpoint: string, payload?: any): Promise<T>;
27
27
  _generateDefaultHeaders(): {
28
- "user-agent": string;
29
- "x-api-key": string;
30
- "api-key": string;
28
+ 'user-agent': string;
29
+ 'x-api-key': string;
30
+ 'api-key': string;
31
31
  };
32
32
  _isErrorRetryable(error: any): boolean;
33
33
  }
package/dist/index.mjs CHANGED
@@ -30,7 +30,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
30
30
  });
31
31
  }
32
32
 
33
- const version = "1.0.11";
33
+ const version = '1.0.11';
34
34
 
35
35
  /**
36
36
  *
@@ -56,7 +56,7 @@ class ApiResponseError extends Error {
56
56
  constructor(statusCode, message) {
57
57
  super(`(${statusCode}): ${message}`);
58
58
  this.statusCode = statusCode;
59
- this.name = "ApiResponseError";
59
+ this.name = 'ApiResponseError';
60
60
  }
61
61
  }
62
62
 
@@ -76,10 +76,10 @@ class ApiRequest {
76
76
  var _a;
77
77
  const isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d*)?(?:[-+]\d{2}:?\d{2}|Z)?$/;
78
78
  function isIsoDateString(value) {
79
- return value && typeof value === "string" && isoDateFormat.test(value);
79
+ return value && typeof value === 'string' && isoDateFormat.test(value);
80
80
  }
81
81
  function handleDates(body) {
82
- if (body === null || body === undefined || typeof body !== "object") {
82
+ if (body === null || body === undefined || typeof body !== 'object') {
83
83
  return body;
84
84
  }
85
85
  for (const key of Object.keys(body)) {
@@ -87,7 +87,7 @@ class ApiRequest {
87
87
  if (isIsoDateString(value)) {
88
88
  body[key] = new Date(value);
89
89
  }
90
- else if (typeof value === "object") {
90
+ else if (typeof value === 'object') {
91
91
  handleDates(value);
92
92
  }
93
93
  }
@@ -130,9 +130,9 @@ class ApiRequest {
130
130
  }
131
131
  _generateDefaultHeaders() {
132
132
  return {
133
- "user-agent": `theauthapi-client-node/${version}`,
134
- "x-api-key": this.accessKey,
135
- "api-key": this.accessKey,
133
+ 'user-agent': `theauthapi-client-node/${version}`,
134
+ 'x-api-key': this.accessKey,
135
+ 'api-key': this.accessKey,
136
136
  };
137
137
  }
138
138
  _isErrorRetryable(error) {
@@ -168,7 +168,7 @@ var HttpMethod;
168
168
  class ApiKeys {
169
169
  constructor(apiService) {
170
170
  this.api = apiService;
171
- this.endpoint = "/api-keys/";
171
+ this.endpoint = '/api-keys/';
172
172
  }
173
173
  isValidKey(apikey) {
174
174
  return __awaiter(this, void 0, void 0, function* () {
@@ -202,7 +202,7 @@ class ApiKeys {
202
202
  }
203
203
  createKey(apiKey) {
204
204
  return __awaiter(this, void 0, void 0, function* () {
205
- return yield this.api.request(HttpMethod.POST, "/api-keys", apiKey);
205
+ return yield this.api.request(HttpMethod.POST, '/api-keys', apiKey);
206
206
  });
207
207
  }
208
208
  updateKey(apiKey, updatedKey) {
@@ -230,14 +230,14 @@ class ApiKeys {
230
230
  if (filter !== undefined) {
231
231
  filters = Object.entries(filter).map(([key, value]) => `${key}=${value}`);
232
232
  }
233
- return `${this.endpoint}${filter !== undefined ? "?" : ""}${filters.join("&")}`;
233
+ return `${this.endpoint}${filter !== undefined ? '?' : ''}${filters.join('&')}`;
234
234
  }
235
235
  }
236
236
 
237
237
  class Projects {
238
238
  constructor(apiService) {
239
239
  this.api = apiService;
240
- this.endpoint = "/projects";
240
+ this.endpoint = '/projects';
241
241
  }
242
242
  getProjects(accountId) {
243
243
  return __awaiter(this, void 0, void 0, function* () {
@@ -269,7 +269,7 @@ class Projects {
269
269
  class Accounts {
270
270
  constructor(apiService) {
271
271
  this.api = apiService;
272
- this.endpoint = "/accounts";
272
+ this.endpoint = '/accounts';
273
273
  }
274
274
  getAccount(accountId) {
275
275
  return __awaiter(this, void 0, void 0, function* () {
@@ -291,7 +291,7 @@ class TheAuthAPI {
291
291
  var _a;
292
292
  assert(accessKey, "You must pass your project's write key.");
293
293
  this.accessKey = accessKey;
294
- this.host = removeSlash((options === null || options === void 0 ? void 0 : options.host) || "https://api.theauthapi.com");
294
+ this.host = removeSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://api.theauthapi.com');
295
295
  this.api = new ApiRequest({
296
296
  accessKey: this.accessKey,
297
297
  host: this.host,
@@ -316,7 +316,7 @@ class TheAuthAPI {
316
316
  sentAt: new Date().getTime(),
317
317
  };
318
318
  try {
319
- const key = yield this.api.request(HttpMethod.POST, "/auth/authenticate", data);
319
+ const key = yield this.api.request(HttpMethod.POST, '/auth/authenticate', data);
320
320
  done(key);
321
321
  return key;
322
322
  }
@@ -1,4 +1,4 @@
1
- export type ApiKey = {
1
+ type ApiKey = {
2
2
  key: string;
3
3
  name: string;
4
4
  customMetaData: AnyJson;
@@ -11,11 +11,11 @@ export type ApiKey = {
11
11
  rateLimitConfigs: RateLimitConfiguration;
12
12
  expiry: Date;
13
13
  };
14
- export type RateLimitConfiguration = {
14
+ type RateLimitConfiguration = {
15
15
  rateLimit: number;
16
16
  rateLimitTtl: number;
17
17
  };
18
- export type ApiKeyInput = {
18
+ type ApiKeyInput = {
19
19
  name: string;
20
20
  projectId?: string;
21
21
  key?: string;
@@ -25,14 +25,14 @@ export type ApiKeyInput = {
25
25
  rateLimitConfigs?: RateLimitConfiguration;
26
26
  expiry?: Date;
27
27
  };
28
- export type ApiKeyFilter = {
28
+ type ApiKeyFilter = {
29
29
  projectId?: string;
30
30
  name?: string;
31
31
  customAccountId?: string | null;
32
32
  customUserId?: string | null;
33
33
  isActive?: boolean;
34
34
  };
35
- export type UpdateApiKeyInput = {
35
+ type UpdateApiKeyInput = {
36
36
  name: string;
37
37
  key?: string;
38
38
  customMetaData?: AnyJson;
@@ -41,11 +41,11 @@ export type UpdateApiKeyInput = {
41
41
  expiry?: Date | null;
42
42
  rateLimitConfigs?: RateLimitConfiguration | null;
43
43
  };
44
- export declare enum AuthedEntityType {
44
+ declare enum AuthedEntityType {
45
45
  USER = "USER",
46
46
  ACCESS_KEY = "ACCESS_KEY"
47
47
  }
48
- export type AuthBaseEntity = {
48
+ type AuthBaseEntity = {
49
49
  isActive: boolean;
50
50
  createdBy: string;
51
51
  createdByType?: AuthedEntityType;
@@ -55,25 +55,25 @@ export type AuthBaseEntity = {
55
55
  updatedAt: Date;
56
56
  createdAt: Date;
57
57
  };
58
- export type Project = AuthBaseEntity & {
58
+ type Project = AuthBaseEntity & {
59
59
  id: string;
60
60
  name: string;
61
61
  accountId: string;
62
62
  env: Environment;
63
63
  };
64
- export declare enum Environment {
64
+ declare enum Environment {
65
65
  LIVE = "live",
66
66
  TEST = "test"
67
67
  }
68
- export type CreateProjectInput = {
68
+ type CreateProjectInput = {
69
69
  name: string;
70
70
  accountId: string;
71
71
  env: Environment;
72
72
  };
73
- export type UpdateProjectInput = {
73
+ type UpdateProjectInput = {
74
74
  name: string;
75
75
  };
76
- export type Account = AuthBaseEntity & {
76
+ type Account = AuthBaseEntity & {
77
77
  id: string;
78
78
  name: string;
79
79
  };
@@ -81,5 +81,7 @@ type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
81
81
  type JsonMap = {
82
82
  [key: string]: AnyJson;
83
83
  };
84
- type JsonArray = Array<AnyJson>;
85
- export {};
84
+ type JsonArray = Array<AnyJson>;
85
+
86
+ export { AuthedEntityType, Environment };
87
+ export type { Account, ApiKey, ApiKeyFilter, ApiKeyInput, AuthBaseEntity, CreateProjectInput, Project, RateLimitConfiguration, UpdateApiKeyInput, UpdateProjectInput };
@@ -0,0 +1,87 @@
1
+ type ApiKey = {
2
+ key: string;
3
+ name: string;
4
+ customMetaData: AnyJson;
5
+ customAccountId: string;
6
+ customUserId: string;
7
+ env: Environment;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ isActive: boolean;
11
+ rateLimitConfigs: RateLimitConfiguration;
12
+ expiry: Date;
13
+ };
14
+ type RateLimitConfiguration = {
15
+ rateLimit: number;
16
+ rateLimitTtl: number;
17
+ };
18
+ type ApiKeyInput = {
19
+ name: string;
20
+ projectId?: string;
21
+ key?: string;
22
+ customMetaData?: AnyJson;
23
+ customAccountId?: string;
24
+ customUserId?: string;
25
+ rateLimitConfigs?: RateLimitConfiguration;
26
+ expiry?: Date;
27
+ };
28
+ type ApiKeyFilter = {
29
+ projectId?: string;
30
+ name?: string;
31
+ customAccountId?: string | null;
32
+ customUserId?: string | null;
33
+ isActive?: boolean;
34
+ };
35
+ type UpdateApiKeyInput = {
36
+ name: string;
37
+ key?: string;
38
+ customMetaData?: AnyJson;
39
+ customAccountId?: string;
40
+ customUserId?: string;
41
+ expiry?: Date | null;
42
+ rateLimitConfigs?: RateLimitConfiguration | null;
43
+ };
44
+ declare enum AuthedEntityType {
45
+ USER = "USER",
46
+ ACCESS_KEY = "ACCESS_KEY"
47
+ }
48
+ type AuthBaseEntity = {
49
+ isActive: boolean;
50
+ createdBy: string;
51
+ createdByType?: AuthedEntityType;
52
+ createdIn: string;
53
+ lastChangedBy: string;
54
+ lastChangedByType?: AuthedEntityType;
55
+ updatedAt: Date;
56
+ createdAt: Date;
57
+ };
58
+ type Project = AuthBaseEntity & {
59
+ id: string;
60
+ name: string;
61
+ accountId: string;
62
+ env: Environment;
63
+ };
64
+ declare enum Environment {
65
+ LIVE = "live",
66
+ TEST = "test"
67
+ }
68
+ type CreateProjectInput = {
69
+ name: string;
70
+ accountId: string;
71
+ env: Environment;
72
+ };
73
+ type UpdateProjectInput = {
74
+ name: string;
75
+ };
76
+ type Account = AuthBaseEntity & {
77
+ id: string;
78
+ name: string;
79
+ };
80
+ type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
81
+ type JsonMap = {
82
+ [key: string]: AnyJson;
83
+ };
84
+ type JsonArray = Array<AnyJson>;
85
+
86
+ export { AuthedEntityType, Environment };
87
+ export type { Account, ApiKey, ApiKeyFilter, ApiKeyInput, AuthBaseEntity, CreateProjectInput, Project, RateLimitConfiguration, UpdateApiKeyInput, UpdateProjectInput };
package/package.json CHANGED
@@ -1,10 +1,25 @@
1
1
  {
2
2
  "name": "theauthapi",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Client library for TheAuthAPI.com",
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
6
+ "types": "dist/index.d.cts",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "./types": {
19
+ "require": "./dist/types.d.cts",
20
+ "types": "./dist/types.d.ts"
21
+ }
22
+ },
8
23
  "type": "module",
9
24
  "files": [
10
25
  "dist"
@@ -16,11 +31,18 @@
16
31
  "scripts": {
17
32
  "test": "jest --runInBand",
18
33
  "test:coverage": "jest --coverage --runInBand",
19
- "build": "rollup -c",
20
- "ci": "npm run build && npm run test",
34
+ "build": "npm run build:rollup && npm run fix-cts",
35
+ "build:rollup": "rollup -c",
36
+ "fix-cts": "node scripts/convert-cts.js",
37
+ "ci": "npm run build && npm run check-format && npm run check-exports && npm run test",
21
38
  "changeset": "npx changeset",
22
39
  "prepublishOnly": "npm run ci",
23
- "local-release": "changeset version && changeset publish"
40
+ "local-release": "npm run ci && changeset version && changeset publish",
41
+ "format": "prettier --write .",
42
+ "check-format": "prettier --check .",
43
+ "check-exports": "npm run check-exports:all && npm run check-exports:types",
44
+ "check-exports:all": "npx attw --pack . --exclude-entrypoints ./types",
45
+ "check-exports:types": "npx attw --pack . --entrypoints ./types --profile node16"
24
46
  },
25
47
  "repository": {
26
48
  "type": "git",
@@ -39,6 +61,7 @@
39
61
  "remove-trailing-slash": "^0.1.1"
40
62
  },
41
63
  "devDependencies": {
64
+ "@arethetypeswrong/cli": "^0.17.4",
42
65
  "@changesets/cli": "^2.28.1",
43
66
  "@rollup/plugin-commonjs": "^28.0.3",
44
67
  "@rollup/plugin-node-resolve": "^16.0.1",
@@ -1,10 +0,0 @@
1
- import { AccountsInterface } from "./AccountsInterface";
2
- import ApiRequest from "../../services/ApiRequest/ApiRequest";
3
- import { Account } from "../../types";
4
- declare class Accounts implements AccountsInterface {
5
- api: ApiRequest;
6
- endpoint: string;
7
- constructor(apiService: ApiRequest);
8
- getAccount(accountId: string): Promise<Account>;
9
- }
10
- export default Accounts;