appstore-connect-sdk 1.0.0-beta.0 → 1.0.0
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 +8 -13
- package/dist/auth.js +3 -4
- package/dist/main.d.ts +2 -2
- package/dist/main.js +4 -3
- package/package.json +1 -1
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
55
|
-
.sign(
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
90
|
+
create(apiClass) {
|
|
90
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
92
|
return new apiClass(yield this.getConfiguration());
|
|
92
93
|
});
|