@mspkapps/auth-client 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/AuthClient.js +6 -1
package/package.json
CHANGED
package/src/AuthClient.js
CHANGED
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
import { AuthError } from './errors.js';
|
|
3
3
|
|
|
4
4
|
export class AuthClient {
|
|
5
|
+
// Convenience: allow users to create with only key/secret
|
|
6
|
+
static create(apiKey, apiSecret, opts = {}) {
|
|
7
|
+
return new AuthClient({ apiKey, apiSecret, ...opts });
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
constructor({
|
|
6
11
|
apiKey,
|
|
7
12
|
apiSecret,
|
|
8
13
|
baseUrl = 'https://cpanel.backend.mspkapps.in/api/v1',
|
|
9
14
|
storage,
|
|
10
15
|
fetch: fetchFn,
|
|
11
|
-
keyInPath =
|
|
16
|
+
keyInPath = true, // default: use headers, not key in URL
|
|
12
17
|
} = {}) {
|
|
13
18
|
if (!apiKey) throw new Error('apiKey is required');
|
|
14
19
|
if (!apiSecret) throw new Error('apiSecret is required'); // do not expose in browsers for prod
|