@appshell/loader 1.0.0-alpha.85 → 1.0.0-alpha.87

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.
@@ -3,12 +3,46 @@ export type Credential = {
3
3
  refreshToken?: string;
4
4
  /** Epoch milliseconds. */
5
5
  expiresAt?: number;
6
+ /**
7
+ * Where this credential came from, so it can renew itself.
8
+ *
9
+ * A refresh token is useless without the issuer that minted it and the client it was
10
+ * minted for, and neither is derivable from the registry url — an operator is free to
11
+ * point several registries at one issuer, or one registry at an issuer that moves.
12
+ * Captured at login for that reason.
13
+ *
14
+ * Optional because a credential written before this existed has neither; such a
15
+ * credential simply cannot refresh, and the next login repairs it.
16
+ */
17
+ issuer?: string;
18
+ clientId?: string;
6
19
  };
7
20
  export declare const credentialsPath: () => string;
8
21
  export declare const saveCredential: (registry: string, credential: Credential) => void;
9
22
  export declare const clearCredential: (registry: string) => void;
10
23
  /**
24
+ * The stored access token, or nothing if it has expired.
25
+ *
11
26
  * APPSHELL_TOKEN wins so CI never depends on a writable home directory.
12
- * Expired tokens are treated as absent; refresh is the caller's concern.
27
+ *
28
+ * Deliberately synchronous and deliberately does not refresh: callers that can await
29
+ * should use `ensureToken`, which renews. This remains for the places that cannot —
30
+ * `resolveContext` among them, which the webpack plugin calls while building.
13
31
  */
14
32
  export declare const resolveToken: (registry: string) => string | undefined;
33
+ /**
34
+ * The stored access token, renewed first if it has expired.
35
+ *
36
+ * `appshell login` obtains a refresh token and, until this existed, nothing ever read it:
37
+ * every expiry meant a full device-authorization flow — open a browser, enter a code,
38
+ * approve — with the credential that would have avoided it sitting in the file.
39
+ *
40
+ * Renewal cannot widen what a caller may do. The issuer mints the new access token from
41
+ * the account as it stands now, so a revoked role or a disabled account produces a weaker
42
+ * token or none at all, never a stale stronger one.
43
+ *
44
+ * A failed renewal returns nothing rather than throwing. The caller's own 401 is the
45
+ * better place to explain what to do, and a network blip on the way to the issuer should
46
+ * not read as *you are logged out*.
47
+ */
48
+ export declare const ensureToken: (registry: string) => Promise<string | undefined>;
@@ -4,7 +4,7 @@
4
4
  export { default as configmap } from './configmap';
5
5
  export { persistedContext, resolveContext } from './context';
6
6
  export type { AppshellContext } from './context';
7
- export { clearCredential, credentialsPath, resolveToken, saveCredential } from './credentials';
7
+ export { clearCredential, credentialsPath, ensureToken, resolveToken, saveCredential, } from './credentials';
8
8
  export type { Credential } from './credentials';
9
9
  export { default as generateManifest, manifestFrom } from './generate.manifest';
10
10
  export { loaderOf } from './loader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appshell/loader",
3
- "version": "1.0.0-alpha.85",
3
+ "version": "1.0.0-alpha.87",
4
4
  "description": "Utility for loading Appshell components",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/loader/src/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  ],
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@appshell/runtime": "^1.0.0-alpha.85",
35
+ "@appshell/runtime": "^1.0.0-alpha.87",
36
36
  "@module-federation/enhanced": "^2.8.2"
37
37
  },
38
- "gitHead": "d95d9d171985f76655cdd4d527127942ecfff61b"
38
+ "gitHead": "ead57d4dfc9dd0987584028ccb20f85c80a419a4"
39
39
  }