appstore-connect-sdk 0.0.4 → 0.0.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/dist/main.d.ts CHANGED
@@ -7,19 +7,23 @@ interface AppStoreConnectAPIOptions {
7
7
  /**
8
8
  * The issuer ID associated with the private key.
9
9
  */
10
- issuerId: string;
10
+ issuerId?: string;
11
11
  /**
12
12
  * The ID of the private key.
13
13
  */
14
- privateKeyId: string;
14
+ privateKeyId?: string;
15
15
  /**
16
16
  * The private key in PEM format.
17
17
  */
18
- privateKey: string;
18
+ privateKey?: string;
19
19
  /**
20
20
  * An optional FetchAPI instance to use for making HTTP requests.
21
21
  */
22
22
  fetchApi?: FetchAPI;
23
+ /**
24
+ * A bearer token can be provided directly, which will be used instead of generating a new token
25
+ */
26
+ bearerToken?: string;
23
27
  }
24
28
  /**
25
29
  * The App Store Connect SDK for Node.js is written in TypeScript and supports all APIs
@@ -37,6 +41,8 @@ export default class AppStoreConnectAPI {
37
41
  * @param options.privateKeyId - The ID of the private key used for generating JWT token.
38
42
  * @param options.privateKey - The content of the private key used for generating JWT token.
39
43
  * @param options.fetchApi - (Optional) The FetchAPI implementation to use for API requests.
44
+ * @param options.bearerToken - (Optional) A pre-generated bearer token to use for authentication.
45
+ * @throws {string} Will throw an error if no bearerToken or private key is provided
40
46
  */
41
47
  constructor(options: AppStoreConnectAPIOptions);
42
48
  /**
package/dist/main.js CHANGED
@@ -16,14 +16,24 @@ class AppStoreConnectAPI {
16
16
  * @param options.privateKeyId - The ID of the private key used for generating JWT token.
17
17
  * @param options.privateKey - The content of the private key used for generating JWT token.
18
18
  * @param options.fetchApi - (Optional) The FetchAPI implementation to use for API requests.
19
+ * @param options.bearerToken - (Optional) A pre-generated bearer token to use for authentication.
20
+ * @throws {string} Will throw an error if no bearerToken or private key is provided
19
21
  */
20
22
  constructor(options) {
21
23
  // Generate an authentication token using the provided options.
22
- this.bearerToken = (0, auth_1.generateAuthToken)({
23
- apiKeyId: options.privateKeyId,
24
- issuerId: options.issuerId,
25
- privateKey: options.privateKey,
26
- });
24
+ if (options.bearerToken) {
25
+ this.bearerToken = options.bearerToken;
26
+ }
27
+ else if (options.privateKeyId && options.issuerId && options.privateKey) {
28
+ this.bearerToken = (0, auth_1.generateAuthToken)({
29
+ apiKeyId: options.privateKeyId,
30
+ issuerId: options.issuerId,
31
+ privateKey: options.privateKey,
32
+ });
33
+ }
34
+ else {
35
+ throw 'No bearerToken!!!';
36
+ }
27
37
  // Create a Configuration object with the authentication token and any provided FetchAPI implementation.
28
38
  this.configuration = new openapi_1.Configuration({
29
39
  headers: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appstore-connect-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "An App Store Connect API client for Node.js",
5
5
  "keywords": [
6
6
  "appstore connect",