@devite/shopware-client 1.1.2 → 1.1.3
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/index.cjs +20 -6
- package/dist/index.mjs +20 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -206,7 +206,7 @@ class OAuthEntry {
|
|
|
206
206
|
return AuthenticationType.OAUTH;
|
|
207
207
|
}
|
|
208
208
|
isSaved() {
|
|
209
|
-
return this.accessToken !== null && this.
|
|
209
|
+
return this.accessToken !== null && this.expiresAt !== null;
|
|
210
210
|
}
|
|
211
211
|
save(response) {
|
|
212
212
|
const jsonBody = response.body.data;
|
|
@@ -12872,8 +12872,9 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
12872
12872
|
async withOAuth(options = {}) {
|
|
12873
12873
|
const entry = this.authStore.getEntry(AuthenticationType.OAUTH);
|
|
12874
12874
|
if (!entry) throw new Error("Not authenticated");
|
|
12875
|
+
let entryHeaders;
|
|
12875
12876
|
try {
|
|
12876
|
-
|
|
12877
|
+
entryHeaders = entry.load().headers;
|
|
12877
12878
|
} catch (error) {
|
|
12878
12879
|
if (error instanceof ExpiredError && entry.refreshToken) {
|
|
12879
12880
|
const refreshResponse = await super.doRequest("/oauth/token", {
|
|
@@ -12885,10 +12886,16 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
12885
12886
|
})
|
|
12886
12887
|
});
|
|
12887
12888
|
entry.save(refreshResponse);
|
|
12888
|
-
|
|
12889
|
-
}
|
|
12890
|
-
throw error;
|
|
12889
|
+
entryHeaders = entry.load().headers;
|
|
12890
|
+
} else throw error;
|
|
12891
12891
|
}
|
|
12892
|
+
return {
|
|
12893
|
+
...options,
|
|
12894
|
+
headers: {
|
|
12895
|
+
...options.headers,
|
|
12896
|
+
...entryHeaders
|
|
12897
|
+
}
|
|
12898
|
+
};
|
|
12892
12899
|
}
|
|
12893
12900
|
forApp() {
|
|
12894
12901
|
return new AppClient(this);
|
|
@@ -14009,6 +14016,7 @@ class StoreShopwareClient extends ShopwareClient {
|
|
|
14009
14016
|
return super.doRequest(path, {
|
|
14010
14017
|
...options,
|
|
14011
14018
|
headers: {
|
|
14019
|
+
...options?.headers,
|
|
14012
14020
|
"sw-access-key": this.apiKey
|
|
14013
14021
|
}
|
|
14014
14022
|
});
|
|
@@ -14018,7 +14026,13 @@ class StoreShopwareClient extends ShopwareClient {
|
|
|
14018
14026
|
AuthenticationType.CONTEXT_TOKEN
|
|
14019
14027
|
);
|
|
14020
14028
|
if (!entry) throw new Error("Not authenticated");
|
|
14021
|
-
return {
|
|
14029
|
+
return {
|
|
14030
|
+
...options,
|
|
14031
|
+
headers: {
|
|
14032
|
+
...options.headers,
|
|
14033
|
+
...entry.load().headers
|
|
14034
|
+
}
|
|
14035
|
+
};
|
|
14022
14036
|
}
|
|
14023
14037
|
forAccount() {
|
|
14024
14038
|
return new AccountClient(this);
|
package/dist/index.mjs
CHANGED
|
@@ -204,7 +204,7 @@ class OAuthEntry {
|
|
|
204
204
|
return AuthenticationType.OAUTH;
|
|
205
205
|
}
|
|
206
206
|
isSaved() {
|
|
207
|
-
return this.accessToken !== null && this.
|
|
207
|
+
return this.accessToken !== null && this.expiresAt !== null;
|
|
208
208
|
}
|
|
209
209
|
save(response) {
|
|
210
210
|
const jsonBody = response.body.data;
|
|
@@ -12870,8 +12870,9 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
12870
12870
|
async withOAuth(options = {}) {
|
|
12871
12871
|
const entry = this.authStore.getEntry(AuthenticationType.OAUTH);
|
|
12872
12872
|
if (!entry) throw new Error("Not authenticated");
|
|
12873
|
+
let entryHeaders;
|
|
12873
12874
|
try {
|
|
12874
|
-
|
|
12875
|
+
entryHeaders = entry.load().headers;
|
|
12875
12876
|
} catch (error) {
|
|
12876
12877
|
if (error instanceof ExpiredError && entry.refreshToken) {
|
|
12877
12878
|
const refreshResponse = await super.doRequest("/oauth/token", {
|
|
@@ -12883,10 +12884,16 @@ class AdminShopwareClient extends ShopwareClient {
|
|
|
12883
12884
|
})
|
|
12884
12885
|
});
|
|
12885
12886
|
entry.save(refreshResponse);
|
|
12886
|
-
|
|
12887
|
-
}
|
|
12888
|
-
throw error;
|
|
12887
|
+
entryHeaders = entry.load().headers;
|
|
12888
|
+
} else throw error;
|
|
12889
12889
|
}
|
|
12890
|
+
return {
|
|
12891
|
+
...options,
|
|
12892
|
+
headers: {
|
|
12893
|
+
...options.headers,
|
|
12894
|
+
...entryHeaders
|
|
12895
|
+
}
|
|
12896
|
+
};
|
|
12890
12897
|
}
|
|
12891
12898
|
forApp() {
|
|
12892
12899
|
return new AppClient(this);
|
|
@@ -14007,6 +14014,7 @@ class StoreShopwareClient extends ShopwareClient {
|
|
|
14007
14014
|
return super.doRequest(path, {
|
|
14008
14015
|
...options,
|
|
14009
14016
|
headers: {
|
|
14017
|
+
...options?.headers,
|
|
14010
14018
|
"sw-access-key": this.apiKey
|
|
14011
14019
|
}
|
|
14012
14020
|
});
|
|
@@ -14016,7 +14024,13 @@ class StoreShopwareClient extends ShopwareClient {
|
|
|
14016
14024
|
AuthenticationType.CONTEXT_TOKEN
|
|
14017
14025
|
);
|
|
14018
14026
|
if (!entry) throw new Error("Not authenticated");
|
|
14019
|
-
return {
|
|
14027
|
+
return {
|
|
14028
|
+
...options,
|
|
14029
|
+
headers: {
|
|
14030
|
+
...options.headers,
|
|
14031
|
+
...entry.load().headers
|
|
14032
|
+
}
|
|
14033
|
+
};
|
|
14020
14034
|
}
|
|
14021
14035
|
forAccount() {
|
|
14022
14036
|
return new AccountClient(this);
|