@configura/web-api 1.4.0-alpha.1 → 1.4.0-alpha.2
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/CatalogueAPI.d.ts +2 -1
- package/dist/CatalogueAPI.js +33 -25
- package/package.json +3 -3
package/dist/CatalogueAPI.d.ts
CHANGED
|
@@ -485,7 +485,8 @@ export declare class APIError<T> extends Error {
|
|
|
485
485
|
}
|
|
486
486
|
export declare class CatalogueAPI {
|
|
487
487
|
auth: AuthorizeResponse | undefined;
|
|
488
|
-
|
|
488
|
+
constructor();
|
|
489
|
+
private _alternativeReferer;
|
|
489
490
|
hasFeature(feature: string): boolean;
|
|
490
491
|
fetch<T>(url: string, options: RequestOptions): Promise<T>;
|
|
491
492
|
postPublicAccessTokenAuthorize(params: PostPublicAccessTokenAuthorizeParams, endpoint: string): Promise<AuthorizeResponse>;
|
package/dist/CatalogueAPI.js
CHANGED
|
@@ -12,8 +12,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
export class APIError extends Error {
|
|
13
13
|
}
|
|
14
14
|
export class CatalogueAPI {
|
|
15
|
+
constructor() {
|
|
16
|
+
const parts = /^(http[s]?:\/\/[^:\/\s]+)/i.exec(document.referrer);
|
|
17
|
+
if (parts !== null) {
|
|
18
|
+
this._alternativeReferer = parts[1] + "/";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
hasFeature(feature) {
|
|
16
|
-
return this.auth !== undefined &&
|
|
22
|
+
return (this.auth !== undefined &&
|
|
23
|
+
this.auth.apiSession.features !== undefined &&
|
|
24
|
+
this.auth.apiSession.features.indexOf(feature) > -1);
|
|
17
25
|
}
|
|
18
26
|
fetch(url, options) {
|
|
19
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,8 +62,8 @@ export class CatalogueAPI {
|
|
|
54
62
|
method: "POST",
|
|
55
63
|
headers: {},
|
|
56
64
|
};
|
|
57
|
-
if (this.
|
|
58
|
-
options.headers["Alternative-Referer"] = this.
|
|
65
|
+
if (this._alternativeReferer) {
|
|
66
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
59
67
|
}
|
|
60
68
|
return this.fetch(endpoint + url, options);
|
|
61
69
|
});
|
|
@@ -70,8 +78,8 @@ export class CatalogueAPI {
|
|
|
70
78
|
method: "GET",
|
|
71
79
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
72
80
|
};
|
|
73
|
-
if (this.
|
|
74
|
-
options.headers["Alternative-Referer"] = this.
|
|
81
|
+
if (this._alternativeReferer) {
|
|
82
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
75
83
|
}
|
|
76
84
|
return this.fetch(this.auth.endpoint + url, options);
|
|
77
85
|
});
|
|
@@ -87,8 +95,8 @@ export class CatalogueAPI {
|
|
|
87
95
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
88
96
|
body: JSON.stringify(body),
|
|
89
97
|
};
|
|
90
|
-
if (this.
|
|
91
|
-
options.headers["Alternative-Referer"] = this.
|
|
98
|
+
if (this._alternativeReferer) {
|
|
99
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
92
100
|
}
|
|
93
101
|
return this.fetch(this.auth.endpoint + url, options);
|
|
94
102
|
});
|
|
@@ -103,8 +111,8 @@ export class CatalogueAPI {
|
|
|
103
111
|
method: "GET",
|
|
104
112
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
105
113
|
};
|
|
106
|
-
if (this.
|
|
107
|
-
options.headers["Alternative-Referer"] = this.
|
|
114
|
+
if (this._alternativeReferer) {
|
|
115
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
108
116
|
}
|
|
109
117
|
return this.fetch(this.auth.endpoint + url, options);
|
|
110
118
|
});
|
|
@@ -119,8 +127,8 @@ export class CatalogueAPI {
|
|
|
119
127
|
method: "GET",
|
|
120
128
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
121
129
|
};
|
|
122
|
-
if (this.
|
|
123
|
-
options.headers["Alternative-Referer"] = this.
|
|
130
|
+
if (this._alternativeReferer) {
|
|
131
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
124
132
|
}
|
|
125
133
|
return this.fetch(this.auth.endpoint + url, options);
|
|
126
134
|
});
|
|
@@ -136,8 +144,8 @@ export class CatalogueAPI {
|
|
|
136
144
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
137
145
|
body: JSON.stringify(body),
|
|
138
146
|
};
|
|
139
|
-
if (this.
|
|
140
|
-
options.headers["Alternative-Referer"] = this.
|
|
147
|
+
if (this._alternativeReferer) {
|
|
148
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
141
149
|
}
|
|
142
150
|
return this.fetch(this.auth.endpoint + url, options);
|
|
143
151
|
});
|
|
@@ -153,8 +161,8 @@ export class CatalogueAPI {
|
|
|
153
161
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
154
162
|
body: JSON.stringify(body),
|
|
155
163
|
};
|
|
156
|
-
if (this.
|
|
157
|
-
options.headers["Alternative-Referer"] = this.
|
|
164
|
+
if (this._alternativeReferer) {
|
|
165
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
158
166
|
}
|
|
159
167
|
return this.fetch(this.auth.endpoint + url, options);
|
|
160
168
|
});
|
|
@@ -169,8 +177,8 @@ export class CatalogueAPI {
|
|
|
169
177
|
method: "GET",
|
|
170
178
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
171
179
|
};
|
|
172
|
-
if (this.
|
|
173
|
-
options.headers["Alternative-Referer"] = this.
|
|
180
|
+
if (this._alternativeReferer) {
|
|
181
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
174
182
|
}
|
|
175
183
|
return this.fetch(this.auth.endpoint + url, options);
|
|
176
184
|
});
|
|
@@ -185,8 +193,8 @@ export class CatalogueAPI {
|
|
|
185
193
|
method: "GET",
|
|
186
194
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
187
195
|
};
|
|
188
|
-
if (this.
|
|
189
|
-
options.headers["Alternative-Referer"] = this.
|
|
196
|
+
if (this._alternativeReferer) {
|
|
197
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
190
198
|
}
|
|
191
199
|
return this.fetch(this.auth.endpoint + url, options);
|
|
192
200
|
});
|
|
@@ -201,8 +209,8 @@ export class CatalogueAPI {
|
|
|
201
209
|
method: "GET",
|
|
202
210
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
203
211
|
};
|
|
204
|
-
if (this.
|
|
205
|
-
options.headers["Alternative-Referer"] = this.
|
|
212
|
+
if (this._alternativeReferer) {
|
|
213
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
206
214
|
}
|
|
207
215
|
return this.fetch(this.auth.endpoint + url, options);
|
|
208
216
|
});
|
|
@@ -217,8 +225,8 @@ export class CatalogueAPI {
|
|
|
217
225
|
method: "GET",
|
|
218
226
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
219
227
|
};
|
|
220
|
-
if (this.
|
|
221
|
-
options.headers["Alternative-Referer"] = this.
|
|
228
|
+
if (this._alternativeReferer) {
|
|
229
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
222
230
|
}
|
|
223
231
|
return this.fetch(this.auth.endpoint + url, options);
|
|
224
232
|
});
|
|
@@ -233,8 +241,8 @@ export class CatalogueAPI {
|
|
|
233
241
|
method: "POST",
|
|
234
242
|
headers: { "X-API-Key": this.auth.secretToken || "" },
|
|
235
243
|
};
|
|
236
|
-
if (this.
|
|
237
|
-
options.headers["Alternative-Referer"] = this.
|
|
244
|
+
if (this._alternativeReferer) {
|
|
245
|
+
options.headers["Alternative-Referer"] = this._alternativeReferer;
|
|
238
246
|
}
|
|
239
247
|
return this.fetch(this.auth.endpoint + url, options);
|
|
240
248
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-api",
|
|
3
|
-
"version": "1.4.0-alpha.
|
|
3
|
+
"version": "1.4.0-alpha.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@configura/web-utilities": "^1.4.0-alpha.
|
|
26
|
+
"@configura/web-utilities": "^1.4.0-alpha.2"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b0d5dbdefc93b2c87298b36d82f6dd32cc2c14e9"
|
|
29
29
|
}
|