@backstage/core-app-api 0.5.0 → 0.5.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/CHANGELOG.md +8 -0
- package/dist/index.esm.js +19 -24
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @backstage/core-app-api
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f959c22787: Asynchronous methods on the identity API can now reliably be called at any time, including early in the bootstrap process or prior to successful sign-in.
|
|
8
|
+
|
|
9
|
+
Previously in such situations, a `Tried to access IdentityApi before app was loaded` error would be thrown. Now, those methods will wait and resolve eventually (as soon as a concrete identity API is provided).
|
|
10
|
+
|
|
3
11
|
## 0.5.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/index.esm.js
CHANGED
|
@@ -2211,8 +2211,16 @@ function logDeprecation(thing) {
|
|
|
2211
2211
|
console.warn(`WARNING: Call to ${thing} is deprecated and will break in the future`);
|
|
2212
2212
|
}
|
|
2213
2213
|
class AppIdentityProxy {
|
|
2214
|
+
constructor() {
|
|
2215
|
+
this.resolveTarget = () => {
|
|
2216
|
+
};
|
|
2217
|
+
this.waitForTarget = new Promise((resolve) => {
|
|
2218
|
+
this.resolveTarget = resolve;
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2214
2221
|
setTarget(identityApi) {
|
|
2215
2222
|
this.target = identityApi;
|
|
2223
|
+
this.resolveTarget(identityApi);
|
|
2216
2224
|
}
|
|
2217
2225
|
getUserId() {
|
|
2218
2226
|
if (!this.target) {
|
|
@@ -2235,42 +2243,29 @@ class AppIdentityProxy {
|
|
|
2235
2243
|
return this.target.getProfile();
|
|
2236
2244
|
}
|
|
2237
2245
|
async getProfileInfo() {
|
|
2238
|
-
|
|
2239
|
-
throw mkError("getProfileInfo");
|
|
2240
|
-
}
|
|
2241
|
-
return this.target.getProfileInfo();
|
|
2246
|
+
return this.waitForTarget.then((target) => target.getProfileInfo());
|
|
2242
2247
|
}
|
|
2243
2248
|
async getBackstageIdentity() {
|
|
2244
|
-
|
|
2245
|
-
throw mkError("getBackstageIdentity");
|
|
2246
|
-
}
|
|
2247
|
-
const identity = await this.target.getBackstageIdentity();
|
|
2249
|
+
const identity = await this.waitForTarget.then((target) => target.getBackstageIdentity());
|
|
2248
2250
|
if (!identity.userEntityRef.match(/^.*:.*\/.*$/)) {
|
|
2249
2251
|
console.warn(`WARNING: The App IdentityApi provided an invalid userEntityRef, '${identity.userEntityRef}'. It must be a full Entity Reference of the form '<kind>:<namespace>/<name>'.`);
|
|
2250
2252
|
}
|
|
2251
2253
|
return identity;
|
|
2252
2254
|
}
|
|
2253
2255
|
async getCredentials() {
|
|
2254
|
-
|
|
2255
|
-
throw mkError("getCredentials");
|
|
2256
|
-
}
|
|
2257
|
-
return this.target.getCredentials();
|
|
2256
|
+
return this.waitForTarget.then((target) => target.getCredentials());
|
|
2258
2257
|
}
|
|
2259
2258
|
async getIdToken() {
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
return this.target.getIdToken();
|
|
2259
|
+
return this.waitForTarget.then((target) => {
|
|
2260
|
+
if (!target.getIdToken) {
|
|
2261
|
+
throw new Error("IdentityApi does not implement getIdToken");
|
|
2262
|
+
}
|
|
2263
|
+
logDeprecation("getIdToken");
|
|
2264
|
+
return target.getIdToken();
|
|
2265
|
+
});
|
|
2268
2266
|
}
|
|
2269
2267
|
async signOut() {
|
|
2270
|
-
|
|
2271
|
-
throw mkError("signOut");
|
|
2272
|
-
}
|
|
2273
|
-
await this.target.signOut();
|
|
2268
|
+
await this.waitForTarget.then((target) => target.signOut());
|
|
2274
2269
|
location.reload();
|
|
2275
2270
|
}
|
|
2276
2271
|
}
|