appstore-connect-sdk 1.0.0-beta.0 → 1.0.0-beta.1

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
@@ -17,8 +17,7 @@ The `appstore-connect-sdk` module includes the following features:
17
17
  - [x] Configuration with API Key and JWT Logic to sign requests
18
18
  - [x] Support for custom network libraries for making requests, such as fetch/node-fetch/axios...
19
19
  - [x] Support for _all_ requests due to OpenAPI generated requests and entities
20
- - [x] Compatibility with both Node.js and **Deno** environments (_please note that certain features of the appstore-connect-sdk module that rely on the Node crypto module may not work as expected in Deno, as described in the "Deno Compatibility" section above_)
21
- - [] ESM Support
20
+ - [x] Compatibility with both Node.js and **Deno** environments
22
21
 
23
22
  ## Examples
24
23
 
@@ -57,7 +56,7 @@ nNdXXbA4
57
56
  Now use this `Private Key` together with the `isuer ID` and the `private key ID` to create your configuration:
58
57
 
59
58
  ```typescript
60
- const appStoreConnect = new AppStoreConnectAPI({
59
+ const client = new AppStoreConnectAPI({
61
60
  issuerId: "<YOUR ISSUER ID>",
62
61
  privateKeyId: "<YOUR PRIVATE KEY ID>",
63
62
  privateKey: "<YOUR PRIVATE KEY>",
@@ -75,7 +74,8 @@ For more information on how JWT works with the App Store Connect API, check out
75
74
  You can find all available APIs in [src/openapi/apis](https://github.com/isaced/appstore-connect-sdk/tree/main/src/openapi/apis), these classes are generated according to [App Store Connect API - OpenAPI specification](https://developer.apple.com/sample-code/app-store-connect/app-store-connect-openapi-specification.zip), If you encounter any problems, please open an [issue](https://github.com/isaced/appstore-connect-sdk/issues).
76
75
 
77
76
  ```typescript
78
- const res = await client.call(AppsApi).appsGetCollection();
77
+ const api = await client.create(AppsApi);
78
+ const res = await api.appsGetCollection();
79
79
  console.log(res);
80
80
  ```
81
81
 
@@ -88,13 +88,14 @@ import {
88
88
  AppEventLocalizationsApi,
89
89
  } from "appstore-connect-sdk/dist/openapi/apis";
90
90
 
91
- const appStoreConnect = new AppStoreConnectAPI({
91
+ const client = new AppStoreConnectAPI({
92
92
  issuerId: "<YOUR ISSUER ID>",
93
93
  privateKeyId: "<YOUR PRIVATE KEY ID>",
94
94
  privateKey: "<YOUR PRIVATE KEY>",
95
95
  });
96
96
 
97
- const res = await client.call(AppsApi).appsGetCollection();
97
+ const api = await client.create(AppsApi);
98
+ const res = await api.appsGetCollection();
98
99
  console.log(res);
99
100
  ```
100
101
 
@@ -126,13 +127,7 @@ This will generate Typescript code through [OpenAPI Generator](https://openapi-g
126
127
 
127
128
  ## Deno Compatibility
128
129
 
129
- The appstore-connect-sdk module is mostly compatible with Deno, but there are some limitations to its usage in a Deno environment. Currently, Deno does not provide full support for the [Node crypto module](https://github.com/denoland/deno_std/issues/3149), which means that certain features of the appstore-connect-sdk module that rely on this module may not work as expected in Deno.
130
-
131
- One specific limitation is that the `jsonwebtoken` package, which is used by the appstore-connect-sdk module to generate JSON Web Tokens (JWTs), is not fully compatible with Deno. As a result, it is not possible to use `jsonwebtoken` in a Deno environment to generate JWTs for use with the App Store Connect API.
132
-
133
- To work around this limitation, you can manually generate JWTs using a library that is fully compatible with Deno, such as `djwt`. You can then pass the manually generated JWT to the `appstore-connect-sdk` module to authenticate with the App Store Connect API.
134
-
135
- An example of using the `appstore-connect-sdk` module in a Deno environment can be found in the [deno_example](https://github.com/isaced/appstore-connect-sdk/tree/deno_example).
130
+ The `appstore-connect-sdk` module is fully compatible with Deno, An example of using the `appstore-connect-sdk` module in a Deno environment can be found in the [deno_example](https://github.com/isaced/appstore-connect-sdk/tree/deno_example).
136
131
 
137
132
  We are committed to ensuring that the `appstore-connect-sdk` module remains fully compatible with both Node.js and Deno, and we will continue to work on improving its compatibility with Deno as the Deno runtime evolves.
138
133
 
package/dist/auth.js CHANGED
@@ -38,8 +38,7 @@ const jose = __importStar(require("jose"));
38
38
  function generateAuthToken({ apiKeyId, issuerId, privateKey, expirationTime }) {
39
39
  return __awaiter(this, void 0, void 0, function* () {
40
40
  const alg = "ES256";
41
- const privateKey1 = yield jose.importPKCS8(privateKey, alg);
42
- var nowSeconds = new Date().getTime() / 1000;
41
+ const key = yield jose.importPKCS8(privateKey, alg);
43
42
  const token = yield new jose.SignJWT({})
44
43
  .setProtectedHeader({
45
44
  // The algorithm used to sign the token (ECDSA with SHA-256)
@@ -51,8 +50,8 @@ function generateAuthToken({ apiKeyId, issuerId, privateKey, expirationTime }) {
51
50
  })
52
51
  .setIssuer(issuerId)
53
52
  .setAudience("appstoreconnect-v1")
54
- .setExpirationTime(nowSeconds)
55
- .sign(privateKey1);
53
+ .setExpirationTime(expirationTime !== null && expirationTime !== void 0 ? expirationTime : new Date().getTime() / 1000)
54
+ .sign(key);
56
55
  // Return the generated token
57
56
  return token;
58
57
  });
package/dist/main.d.ts CHANGED
@@ -64,10 +64,10 @@ export default class AppStoreConnectAPI {
64
64
  */
65
65
  getConfiguration(): Promise<Configuration | undefined>;
66
66
  /**
67
- * Calls the specified API class using the current Configuration object.
67
+ * Creates an instance of the specified API class.
68
68
  * @param apiClass - The API class to instantiate.
69
69
  * @returns An instance of the specified API class.
70
70
  */
71
- call<T extends BaseAPI>(apiClass: new (configuration?: Configuration) => T): Promise<T>;
71
+ create<T extends BaseAPI>(apiClass: new (configuration?: Configuration) => T): Promise<T>;
72
72
  }
73
73
  export {};
package/dist/main.js CHANGED
@@ -31,7 +31,8 @@ class AppStoreConnectAPI {
31
31
  */
32
32
  constructor(options) {
33
33
  this.bearerTokenGeneratedAt = 0;
34
- options.expirationTime = options.expirationTime || 60 * 10;
34
+ if (options.expirationTime)
35
+ options.expirationTime = options.expirationTime;
35
36
  this.options = options;
36
37
  }
37
38
  /**
@@ -82,11 +83,11 @@ class AppStoreConnectAPI {
82
83
  });
83
84
  }
84
85
  /**
85
- * Calls the specified API class using the current Configuration object.
86
+ * Creates an instance of the specified API class.
86
87
  * @param apiClass - The API class to instantiate.
87
88
  * @returns An instance of the specified API class.
88
89
  */
89
- call(apiClass) {
90
+ create(apiClass) {
90
91
  return __awaiter(this, void 0, void 0, function* () {
91
92
  return new apiClass(yield this.getConfiguration());
92
93
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appstore-connect-sdk",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "An App Store Connect API client for Node.js",
5
5
  "keywords": [
6
6
  "appstore connect",