@salesforce/b2c-tooling-sdk 1.21.3 → 1.22.0

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.
Files changed (122) hide show
  1. package/data/guides/enrichment.json +294 -0
  2. package/data/guides/index.json +376 -16
  3. package/data/help/index.json +6 -1
  4. package/data/job-steps/index.json +1 -1
  5. package/data/job-steps/job-steps.json +1 -1
  6. package/data/script-api/index.json +49 -5
  7. package/data/tooling/index.json +2 -2
  8. package/data/xsd/commercefeaturestate.xsd +1 -0
  9. package/data/xsd/index.json +2 -1
  10. package/data/xsd/redirecturl.xsd +2 -0
  11. package/dist/esm/auth/index.d.ts +6 -3
  12. package/dist/esm/auth/index.js +4 -2
  13. package/dist/esm/auth/index.js.map +1 -1
  14. package/dist/esm/auth/oauth-implicit.d.ts +19 -0
  15. package/dist/esm/auth/oauth-implicit.js +103 -10
  16. package/dist/esm/auth/oauth-implicit.js.map +1 -1
  17. package/dist/esm/auth/oauth-pkce-fallback.d.ts +68 -0
  18. package/dist/esm/auth/oauth-pkce-fallback.js +128 -0
  19. package/dist/esm/auth/oauth-pkce-fallback.js.map +1 -0
  20. package/dist/esm/auth/oauth-pkce.d.ts +94 -0
  21. package/dist/esm/auth/oauth-pkce.js +579 -0
  22. package/dist/esm/auth/oauth-pkce.js.map +1 -0
  23. package/dist/esm/auth/resolve.d.ts +4 -3
  24. package/dist/esm/auth/resolve.js +17 -2
  25. package/dist/esm/auth/resolve.js.map +1 -1
  26. package/dist/esm/auth/session-store.d.ts +99 -0
  27. package/dist/esm/auth/session-store.js +242 -0
  28. package/dist/esm/auth/session-store.js.map +1 -0
  29. package/dist/esm/auth/stateful-oauth-strategy.d.ts +20 -24
  30. package/dist/esm/auth/stateful-oauth-strategy.js +16 -114
  31. package/dist/esm/auth/stateful-oauth-strategy.js.map +1 -1
  32. package/dist/esm/auth/types.d.ts +20 -4
  33. package/dist/esm/auth/types.js +1 -1
  34. package/dist/esm/auth/types.js.map +1 -1
  35. package/dist/esm/cli/am-command.d.ts +2 -2
  36. package/dist/esm/cli/am-command.js +13 -4
  37. package/dist/esm/cli/am-command.js.map +1 -1
  38. package/dist/esm/cli/base-command.js +3 -3
  39. package/dist/esm/cli/base-command.js.map +1 -1
  40. package/dist/esm/cli/config.js +3 -1
  41. package/dist/esm/cli/config.js.map +1 -1
  42. package/dist/esm/cli/lifecycle.d.ts +1 -1
  43. package/dist/esm/cli/lifecycle.js.map +1 -1
  44. package/dist/esm/cli/oauth-command.d.ts +12 -11
  45. package/dist/esm/cli/oauth-command.js +73 -41
  46. package/dist/esm/cli/oauth-command.js.map +1 -1
  47. package/dist/esm/cli/ods-command.d.ts +1 -1
  48. package/dist/esm/cli/ods-command.js +5 -3
  49. package/dist/esm/cli/ods-command.js.map +1 -1
  50. package/dist/esm/clients/ods.generated.d.ts +16 -0
  51. package/dist/esm/config/dw-json.d.ts +10 -0
  52. package/dist/esm/config/dw-json.js.map +1 -1
  53. package/dist/esm/config/index.d.ts +1 -0
  54. package/dist/esm/config/index.js +2 -0
  55. package/dist/esm/config/index.js.map +1 -1
  56. package/dist/esm/config/mapping.d.ts +13 -0
  57. package/dist/esm/config/mapping.js +66 -3
  58. package/dist/esm/config/mapping.js.map +1 -1
  59. package/dist/esm/config/redaction.d.ts +39 -0
  60. package/dist/esm/config/redaction.js +51 -0
  61. package/dist/esm/config/redaction.js.map +1 -0
  62. package/dist/esm/config/resolver.js +1 -0
  63. package/dist/esm/config/resolver.js.map +1 -1
  64. package/dist/esm/config/sources/env-source.js +2 -0
  65. package/dist/esm/config/sources/env-source.js.map +1 -1
  66. package/dist/esm/config/sources/package-json-source.js +1 -0
  67. package/dist/esm/config/sources/package-json-source.js.map +1 -1
  68. package/dist/esm/config/types.d.ts +14 -4
  69. package/dist/esm/defaults.d.ts +23 -4
  70. package/dist/esm/defaults.js +36 -4
  71. package/dist/esm/defaults.js.map +1 -1
  72. package/dist/esm/docs/content-cache.d.ts +1 -1
  73. package/dist/esm/docs/content-cache.js +1 -1
  74. package/dist/esm/docs/index.d.ts +1 -1
  75. package/dist/esm/docs/index.js.map +1 -1
  76. package/dist/esm/docs/types.d.ts +29 -0
  77. package/dist/esm/index.d.ts +6 -4
  78. package/dist/esm/index.js +3 -3
  79. package/dist/esm/index.js.map +1 -1
  80. package/dist/esm/instance/index.js +3 -3
  81. package/dist/esm/instance/index.js.map +1 -1
  82. package/dist/esm/operations/cap/index.d.ts +2 -2
  83. package/dist/esm/operations/cap/index.js +1 -1
  84. package/dist/esm/operations/cap/index.js.map +1 -1
  85. package/dist/esm/operations/cap/install.d.ts +17 -0
  86. package/dist/esm/operations/cap/install.js +29 -0
  87. package/dist/esm/operations/cap/install.js.map +1 -1
  88. package/dist/esm/operations/cap/package.js +36 -0
  89. package/dist/esm/operations/cap/package.js.map +1 -1
  90. package/dist/esm/operations/cap/validate.d.ts +9 -0
  91. package/dist/esm/operations/cap/validate.js +29 -0
  92. package/dist/esm/operations/cap/validate.js.map +1 -1
  93. package/dist/esm/operations/content/export.js +7 -3
  94. package/dist/esm/operations/content/export.js.map +1 -1
  95. package/dist/esm/operations/content/library.d.ts +26 -0
  96. package/dist/esm/operations/content/library.js +83 -2
  97. package/dist/esm/operations/content/library.js.map +1 -1
  98. package/dist/esm/operations/content/types.d.ts +10 -1
  99. package/dist/esm/operations/jobs/import-set.d.ts +170 -0
  100. package/dist/esm/operations/jobs/import-set.js +538 -0
  101. package/dist/esm/operations/jobs/import-set.js.map +1 -0
  102. package/dist/esm/operations/jobs/index.d.ts +3 -0
  103. package/dist/esm/operations/jobs/index.js +3 -0
  104. package/dist/esm/operations/jobs/index.js.map +1 -1
  105. package/dist/esm/operations/jobs/run.js +0 -11
  106. package/dist/esm/operations/jobs/run.js.map +1 -1
  107. package/dist/esm/operations/jobs/site-archive.js +13 -75
  108. package/dist/esm/operations/jobs/site-archive.js.map +1 -1
  109. package/dist/esm/operations/ods/index.d.ts +4 -0
  110. package/dist/esm/operations/ods/index.js +2 -0
  111. package/dist/esm/operations/ods/index.js.map +1 -1
  112. package/dist/esm/operations/ods/sandbox-settings.d.ts +51 -0
  113. package/dist/esm/operations/ods/sandbox-settings.js +63 -0
  114. package/dist/esm/operations/ods/sandbox-settings.js.map +1 -0
  115. package/dist/esm/operations/ods/wait-for-clones.d.ts +97 -0
  116. package/dist/esm/operations/ods/wait-for-clones.js +145 -0
  117. package/dist/esm/operations/ods/wait-for-clones.js.map +1 -0
  118. package/package.json +1 -1
  119. package/specs/ods-api-v1.json +43 -0
  120. package/dist/esm/auth/stateful-store.d.ts +0 -49
  121. package/dist/esm/auth/stateful-store.js +0 -166
  122. package/dist/esm/auth/stateful-store.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Transitional auth strategy that prefers Authorization Code + PKCE but
3
+ * automatically falls back to the deprecated implicit flow when the configured
4
+ * Account Manager client is not (yet) registered for the PKCE grant.
5
+ *
6
+ * ## Why this exists
7
+ *
8
+ * Switching the default browser-based flow from implicit to PKCE requires a
9
+ * PKCE-capable "public client" in Account Manager. An AM client's type cannot be
10
+ * changed after creation, so a legacy implicit-only client must be replaced by a
11
+ * newly-created public client. Until that migration is complete, a user whose
12
+ * client is still implicit-only would hit a hard failure on the first request.
13
+ * This wrapper catches that specific failure ({@link PkceGrantUnsupportedError}),
14
+ * logs a deprecation WARN, and transparently retries with the implicit flow so
15
+ * those users keep working.
16
+ *
17
+ * ## Scope of the fallback
18
+ *
19
+ * The implicit flow uses the SAME authorize endpoint and redirect URI as PKCE,
20
+ * so this only rescues clients that are implicit-enabled but not PKCE-enabled.
21
+ * A client missing the redirect URI entirely fails under both flows — those
22
+ * users must fix their Account Manager registration.
23
+ *
24
+ * ## Removal
25
+ *
26
+ * This is a temporary migration aid. Once all public clients are PKCE-capable,
27
+ * delete this file, stop constructing it from {@link resolveAuthStrategy} /
28
+ * `getOAuthStrategy()`, and drop {@link PkceGrantUnsupportedError}. The
29
+ * {@link SFCC_DISABLE_PKCE_FALLBACK} env var can disable it in the meantime.
30
+ *
31
+ * @module auth/oauth-pkce-fallback
32
+ */
33
+ import type { UserAuthStrategy, AccessTokenResponse, DecodedJWT, FetchInit } from './types.js';
34
+ import { type PkceOAuthConfig } from './oauth-pkce.js';
35
+ /**
36
+ * Returns true when the automatic PKCE→implicit fallback is disabled via the
37
+ * `SFCC_DISABLE_PKCE_FALLBACK` environment variable (any non-empty value).
38
+ */
39
+ export declare function isPkceFallbackDisabled(): boolean;
40
+ /**
41
+ * Wraps a {@link PkceOAuthStrategy} and, on a {@link PkceGrantUnsupportedError},
42
+ * falls back to an {@link ImplicitOAuthStrategy} for the same client. The
43
+ * fallback is attempted at most once and then sticks for the lifetime of this
44
+ * instance, so subsequent calls go straight to implicit without re-attempting
45
+ * the failing PKCE flow.
46
+ */
47
+ export declare class PkceWithImplicitFallbackStrategy implements UserAuthStrategy {
48
+ private readonly config;
49
+ private readonly pkce;
50
+ private implicit;
51
+ /** Once PKCE has failed with a grant error, route everything to implicit. */
52
+ private useImplicit;
53
+ constructor(config: PkceOAuthConfig);
54
+ fetch(url: string, init?: FetchInit): Promise<Response>;
55
+ getAuthorizationHeader(): Promise<string>;
56
+ getJWT(): Promise<DecodedJWT>;
57
+ getTokenResponse(): Promise<AccessTokenResponse>;
58
+ invalidateToken(): void;
59
+ private warnAndSwitch;
60
+ private getImplicit;
61
+ }
62
+ /**
63
+ * Builds the browser-based "user" auth strategy. Returns a plain
64
+ * {@link PkceOAuthStrategy} when the fallback is disabled
65
+ * (`SFCC_DISABLE_PKCE_FALLBACK`), otherwise a
66
+ * {@link PkceWithImplicitFallbackStrategy}.
67
+ */
68
+ export declare function createUserAuthStrategy(config: PkceOAuthConfig): UserAuthStrategy;
@@ -0,0 +1,128 @@
1
+ import { getLogger } from '../logging/logger.js';
2
+ import { PkceOAuthStrategy, PkceGrantUnsupportedError } from './oauth-pkce.js';
3
+ import { ImplicitOAuthStrategy } from './oauth-implicit.js';
4
+ /**
5
+ * Returns true when the automatic PKCE→implicit fallback is disabled via the
6
+ * `SFCC_DISABLE_PKCE_FALLBACK` environment variable (any non-empty value).
7
+ */
8
+ export function isPkceFallbackDisabled() {
9
+ const value = process.env.SFCC_DISABLE_PKCE_FALLBACK;
10
+ return value !== undefined && value !== '' && value !== '0' && value.toLowerCase() !== 'false';
11
+ }
12
+ /**
13
+ * Wraps a {@link PkceOAuthStrategy} and, on a {@link PkceGrantUnsupportedError},
14
+ * falls back to an {@link ImplicitOAuthStrategy} for the same client. The
15
+ * fallback is attempted at most once and then sticks for the lifetime of this
16
+ * instance, so subsequent calls go straight to implicit without re-attempting
17
+ * the failing PKCE flow.
18
+ */
19
+ export class PkceWithImplicitFallbackStrategy {
20
+ config;
21
+ pkce;
22
+ implicit = null;
23
+ /** Once PKCE has failed with a grant error, route everything to implicit. */
24
+ useImplicit = false;
25
+ constructor(config) {
26
+ this.config = config;
27
+ this.pkce = new PkceOAuthStrategy(config);
28
+ }
29
+ async fetch(url, init = {}) {
30
+ if (this.useImplicit) {
31
+ return this.getImplicit().fetch(url, init);
32
+ }
33
+ try {
34
+ return await this.pkce.fetch(url, init);
35
+ }
36
+ catch (error) {
37
+ if (error instanceof PkceGrantUnsupportedError) {
38
+ this.warnAndSwitch(error);
39
+ return this.getImplicit().fetch(url, init);
40
+ }
41
+ throw error;
42
+ }
43
+ }
44
+ async getAuthorizationHeader() {
45
+ if (this.useImplicit) {
46
+ return this.getImplicit().getAuthorizationHeader();
47
+ }
48
+ try {
49
+ return await this.pkce.getAuthorizationHeader();
50
+ }
51
+ catch (error) {
52
+ if (error instanceof PkceGrantUnsupportedError) {
53
+ this.warnAndSwitch(error);
54
+ return this.getImplicit().getAuthorizationHeader();
55
+ }
56
+ throw error;
57
+ }
58
+ }
59
+ async getJWT() {
60
+ if (this.useImplicit) {
61
+ return this.getImplicit().getJWT();
62
+ }
63
+ try {
64
+ return await this.pkce.getJWT();
65
+ }
66
+ catch (error) {
67
+ if (error instanceof PkceGrantUnsupportedError) {
68
+ this.warnAndSwitch(error);
69
+ return this.getImplicit().getJWT();
70
+ }
71
+ throw error;
72
+ }
73
+ }
74
+ async getTokenResponse() {
75
+ if (this.useImplicit) {
76
+ return this.getImplicit().getTokenResponse();
77
+ }
78
+ try {
79
+ return await this.pkce.getTokenResponse();
80
+ }
81
+ catch (error) {
82
+ if (error instanceof PkceGrantUnsupportedError) {
83
+ this.warnAndSwitch(error);
84
+ return this.getImplicit().getTokenResponse();
85
+ }
86
+ throw error;
87
+ }
88
+ }
89
+ invalidateToken() {
90
+ this.pkce.invalidateToken();
91
+ this.implicit?.invalidateToken();
92
+ }
93
+ warnAndSwitch(error) {
94
+ this.useImplicit = true;
95
+ getLogger().warn({ clientId: this.config.clientId, stage: error.stage, oauthError: error.oauthError }, `[Auth] Authorization Code + PKCE failed for client ${this.config.clientId} ` +
96
+ `(${error.oauthError ?? error.message}). Falling back to the deprecated implicit flow. ` +
97
+ 'Recommend creating a new public (PKCE) client in Account Manager and using it to remove this warning. ' +
98
+ 'See https://salesforcecommercecloud.github.io/b2c-developer-tooling/guide/authentication.html#implicit-flow-deprecation');
99
+ }
100
+ getImplicit() {
101
+ if (!this.implicit) {
102
+ const implicitConfig = {
103
+ clientId: this.config.clientId,
104
+ scopes: this.config.scopes,
105
+ accountManagerHost: this.config.accountManagerHost,
106
+ localPort: this.config.localPort,
107
+ redirectUri: this.config.redirectUri,
108
+ openBrowser: this.config.openBrowser,
109
+ persistSession: this.config.persistSession,
110
+ };
111
+ this.implicit = new ImplicitOAuthStrategy(implicitConfig);
112
+ }
113
+ return this.implicit;
114
+ }
115
+ }
116
+ /**
117
+ * Builds the browser-based "user" auth strategy. Returns a plain
118
+ * {@link PkceOAuthStrategy} when the fallback is disabled
119
+ * (`SFCC_DISABLE_PKCE_FALLBACK`), otherwise a
120
+ * {@link PkceWithImplicitFallbackStrategy}.
121
+ */
122
+ export function createUserAuthStrategy(config) {
123
+ if (isPkceFallbackDisabled()) {
124
+ return new PkceOAuthStrategy(config);
125
+ }
126
+ return new PkceWithImplicitFallbackStrategy(config);
127
+ }
128
+ //# sourceMappingURL=oauth-pkce-fallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-pkce-fallback.js","sourceRoot":"","sources":["../../../src/auth/oauth-pkce-fallback.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAE,yBAAyB,EAAuB,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAC,qBAAqB,EAA2B,MAAM,qBAAqB,CAAC;AAEpF;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACrD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;AACjG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,OAAO,gCAAgC;IAMd;IALZ,IAAI,CAAoB;IACjC,QAAQ,GAAiC,IAAI,CAAC;IACtD,6EAA6E;IACrE,WAAW,GAAG,KAAK,CAAC;IAE5B,YAA6B,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,OAAkB,EAAE;QAC3C,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,Y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BAChC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACpC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACpC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;aAC3C,CAAC;YACF,IAAI,CAAC,QAAQ,GAAG,IAAI,qBAAqB,CAAC,cAAc,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAuB;IAC5D,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,gCAAgC,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,94 @@
1
+ import type { AuthStrategy, AccessTokenResponse, DecodedJWT, FetchInit } from './types.js';
2
+ /**
3
+ * Thrown when the Authorization Code + PKCE flow fails in a way that indicates
4
+ * the Account Manager client is not registered for this grant (e.g. an old
5
+ * implicit-only public client, or a missing/mismatched redirect URI) rather
6
+ * than a transient or user-driven failure.
7
+ *
8
+ * {@link PkceWithImplicitFallbackStrategy} keys its automatic fallback off this
9
+ * type so it retries with the legacy implicit flow ONLY for grant/registration
10
+ * failures — never for user-cancel, state mismatch, or a port-in-use error.
11
+ *
12
+ * @remarks Part of the implicit→PKCE migration safety net. Remove together with
13
+ * the fallback strategy once all public clients are PKCE-capable.
14
+ */
15
+ export declare class PkceGrantUnsupportedError extends Error {
16
+ /** The OAuth 2.0 `error` code from the authorize redirect or token response, when available. */
17
+ readonly oauthError?: string;
18
+ /** The OAuth stage at which the failure occurred. */
19
+ readonly stage: 'authorize' | 'token';
20
+ constructor(message: string, stage: 'authorize' | 'token', oauthError?: string);
21
+ }
22
+ /**
23
+ * Configuration for the OAuth Authorization Code + PKCE flow.
24
+ */
25
+ export interface PkceOAuthConfig {
26
+ clientId: string;
27
+ scopes?: string[];
28
+ accountManagerHost?: string;
29
+ /** Local port for the redirect server (default 8080 or SFCC_OAUTH_LOCAL_PORT). */
30
+ localPort?: number;
31
+ /** Override redirect URI (default `http://localhost:${localPort}` or SFCC_REDIRECT_URI). */
32
+ redirectUri?: string;
33
+ /** Custom browser opener. Receives the authorization URL. */
34
+ openBrowser?: (url: string) => Promise<void>;
35
+ /**
36
+ * Persist tokens (access + refresh) to disk between CLI invocations,
37
+ * keyed by clientId. When a refresh token is available it is used to
38
+ * silently obtain a new access token instead of opening the browser.
39
+ * Defaults to `true`.
40
+ */
41
+ persistSession?: boolean;
42
+ }
43
+ /**
44
+ * OAuth 2.0 Authorization Code Flow with PKCE.
45
+ *
46
+ * Used for public clients (no client secret). Replaces the legacy implicit flow,
47
+ * which is deprecated for public clients per OAuth 2.1.
48
+ *
49
+ * Flow:
50
+ * 1. Generate PKCE verifier + S256 challenge.
51
+ * 2. Open browser to `/dwsso/oauth2/authorize?response_type=code&code_challenge=...`.
52
+ * 3. Capture redirect with `?code=...` on a localhost listener.
53
+ * 4. POST `grant_type=authorization_code` + `code_verifier` to `/dwsso/oauth2/access_token`.
54
+ *
55
+ * Tokens may include a refresh_token (depends on client registration in Account Manager).
56
+ */
57
+ export declare class PkceOAuthStrategy implements AuthStrategy {
58
+ private config;
59
+ private accountManagerHost;
60
+ private localPort;
61
+ private redirectUri;
62
+ private persistSession;
63
+ private _hasHadSuccess;
64
+ private _refreshToken;
65
+ private _sub;
66
+ private _hydrated;
67
+ constructor(config: PkceOAuthConfig);
68
+ /**
69
+ * Load any persisted session for this clientId. Idempotent.
70
+ */
71
+ private hydrate;
72
+ fetch(url: string, init?: FetchInit): Promise<Response>;
73
+ getAuthorizationHeader(): Promise<string>;
74
+ getJWT(): Promise<DecodedJWT>;
75
+ getTokenResponse(): Promise<AccessTokenResponse>;
76
+ invalidateToken(): void;
77
+ private isCachedTokenUsable;
78
+ private getAccessToken;
79
+ /**
80
+ * Exchange a stored refresh_token for a new access token. Returns null if no
81
+ * refresh token is available or the exchange fails (e.g. revoked / expired).
82
+ * On failure, the refresh token is forgotten so the next request triggers
83
+ * the browser flow.
84
+ */
85
+ private tryRefresh;
86
+ /**
87
+ * Persist the current token + refresh token. No-op when `persistSession`
88
+ * is disabled. Updates `_sub` from the JWT when available so the persisted
89
+ * record carries the authenticated user identity for diagnostics.
90
+ */
91
+ private persistTokens;
92
+ private runFlow;
93
+ private waitForAuthCode;
94
+ }