@sap-ux/axios-extension 0.8.0 → 0.9.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.
@@ -11,6 +11,11 @@ export interface ProviderConfiguration {
11
11
  * Ignore certificate verification errors
12
12
  */
13
13
  ignoreCertErrors: boolean;
14
+ /**
15
+ * Value to be passed into the `Cookie` request header
16
+ * https://datatracker.ietf.org/doc/html/rfc6265#section-4.2
17
+ */
18
+ cookies: string;
14
19
  }
15
20
  export interface ServiceProviderExtension {
16
21
  service(path: string): Service;
package/dist/factory.d.ts CHANGED
@@ -54,12 +54,12 @@ export declare function createForAbapOnCloud(options: AbapCloudOptions & Partial
54
54
  /**
55
55
  * Create an instance of a service provider for the given destination.
56
56
  *
57
- * @param config axios config with additional extension specific properties
57
+ * @param options axios config with additional extension specific properties
58
58
  * @param destination destination config
59
59
  * @param destinationServiceInstance optional id of a destination service instance providing the destination
60
60
  * @returns instance of a service provider
61
61
  */
62
- export declare function createForDestination(config: AxiosRequestConfig, destination: Destination, destinationServiceInstance?: string): ServiceProvider;
62
+ export declare function createForDestination(options: AxiosRequestConfig & Partial<ProviderConfiguration>, destination: Destination, destinationServiceInstance?: string): ServiceProvider;
63
63
  /**
64
64
  * Create an instance of a basic service provider and then generate an extension for a service based on the given url.
65
65
  *
package/dist/factory.js CHANGED
@@ -61,6 +61,11 @@ function createInstance(ProviderType, config) {
61
61
  if ((_b = providerConfig.auth) === null || _b === void 0 ? void 0 : _b.password) {
62
62
  auth_1.attachBasicAuthInterceptor(instance);
63
63
  }
64
+ if (config.cookies) {
65
+ config.cookies.split(';').forEach((singleCookieStr) => {
66
+ instance.cookies.addCookie(singleCookieStr.trim());
67
+ });
68
+ }
64
69
  return instance;
65
70
  }
66
71
  /**
@@ -106,15 +111,19 @@ function createForAbapOnCloud(options) {
106
111
  let provider;
107
112
  switch (options.environment) {
108
113
  case AbapCloudEnvironment.Standalone: {
109
- const { service, refreshToken, refreshTokenChangedCb } = options, config = __rest(options, ["service", "refreshToken", "refreshTokenChangedCb"]);
110
- provider = createInstance(abap_1.AbapServiceProvider, Object.assign({ baseURL: service.url }, config));
111
- auth_1.attachUaaAuthInterceptor(provider, service, refreshToken, refreshTokenChangedCb);
114
+ const { service, refreshToken, refreshTokenChangedCb, cookies } = options, config = __rest(options, ["service", "refreshToken", "refreshTokenChangedCb", "cookies"]);
115
+ provider = createInstance(abap_1.AbapServiceProvider, Object.assign({ baseURL: service.url, cookies }, config));
116
+ if (!cookies) {
117
+ auth_1.attachUaaAuthInterceptor(provider, service, refreshToken, refreshTokenChangedCb);
118
+ }
112
119
  break;
113
120
  }
114
121
  case AbapCloudEnvironment.EmbeddedSteampunk: {
115
- const { url } = options, config = __rest(options, ["url"]);
122
+ const { url, cookies } = options, config = __rest(options, ["url", "cookies"]);
116
123
  provider = createInstance(abap_1.AbapServiceProvider, Object.assign({ baseURL: url }, config));
117
- auth_1.attachReentranceTicketAuthInterceptor({ provider });
124
+ if (!cookies) {
125
+ auth_1.attachReentranceTicketAuthInterceptor({ provider });
126
+ }
118
127
  break;
119
128
  }
120
129
  default:
@@ -127,14 +136,15 @@ exports.createForAbapOnCloud = createForAbapOnCloud;
127
136
  /**
128
137
  * Create an instance of a service provider for the given destination.
129
138
  *
130
- * @param config axios config with additional extension specific properties
139
+ * @param options axios config with additional extension specific properties
131
140
  * @param destination destination config
132
141
  * @param destinationServiceInstance optional id of a destination service instance providing the destination
133
142
  * @returns instance of a service provider
134
143
  */
135
- function createForDestination(config, destination, destinationServiceInstance) {
144
+ function createForDestination(options, destination, destinationServiceInstance) {
136
145
  var _a;
137
- const providerConfig = Object.assign(Object.assign({}, config), { baseURL: btp_utils_1.getDestinationUrlForAppStudio(destination.Name, new URL(destination.Host).pathname) });
146
+ const { cookies } = options, config = __rest(options, ["cookies"]);
147
+ const providerConfig = Object.assign(Object.assign({}, config), { baseURL: btp_utils_1.getDestinationUrlForAppStudio(destination.Name, new URL(destination.Host).pathname), cookies: cookies });
138
148
  // SAML in AppStudio is not yet supported
139
149
  providerConfig.params = (_a = providerConfig.params) !== null && _a !== void 0 ? _a : {};
140
150
  providerConfig.params.saml2 = 'disabled';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/axios-extension",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Extension of the Axios module adding convinience methods to interact with SAP systems especially with OData services.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "private": false,
15
15
  "main": "dist/index.js",
16
16
  "dependencies": {
17
- "@sap-ux/btp-utils": "0.10.2",
18
- "@sap-ux/logger": "0.2.1",
17
+ "@sap-ux/btp-utils": "0.10.4",
18
+ "@sap-ux/logger": "0.2.2",
19
19
  "axios": "0.24.0",
20
20
  "detect-content-type": "1.2.0",
21
21
  "express": "4.17.1",