88 *
99 * - {@link BasicAuthStrategy} - Username/password authentication for WebDAV operations
1010 * - {@link OAuthStrategy} - OAuth 2.0 client credentials for OCAPI and platform APIs
11+ * - {@link ImplicitOAuthStrategy} - Interactive browser-based OAuth for CLI/desktop apps
1112 * - {@link ApiKeyStrategy} - API key authentication for MRT services
1213 *
13- * ## Usage
14+ * ## Strategy Resolution
1415 *
15- * All strategies implement the {@link AuthStrategy} interface, allowing you to
16- * switch authentication methods without changing your code :
16+ * Use {@link resolveAuthStrategy} to automatically select the best strategy based on
17+ * available credentials and allowed methods :
1718 *
1819 * ```typescript
19- * import { BasicAuthStrategy, OAuthStrategy } from '@salesforce/b2c-tooling';
20+ * import { resolveAuthStrategy } from '@salesforce/b2c-tooling';
2021 *
21- * // For WebDAV operations (code upload)
22- * const basicAuth = new BasicAuthStrategy('username', 'access-key');
22+ * // Automatically picks client-credentials if secret available, otherwise implicit
23+ * const strategy = resolveAuthStrategy({
24+ * clientId: 'your-client-id',
25+ * clientSecret: process.env.CLIENT_SECRET, // may be undefined
26+ * });
27+ *
28+ * // Force a specific method
29+ * const implicitOnly = resolveAuthStrategy(
30+ * { clientId: 'your-client-id' },
31+ * { allowedMethods: ['implicit'] }
32+ * );
33+ * ```
34+ *
35+ * ## Direct Usage
36+ *
37+ * All strategies implement the {@link AuthStrategy} interface:
2338 *
24- * // For OCAPI operations (sites, jobs)
39+ * ```typescript
40+ * import { OAuthStrategy, ImplicitOAuthStrategy } from '@salesforce/b2c-tooling';
41+ *
42+ * // For automated/server usage (client credentials)
2543 * const oauthAuth = new OAuthStrategy({
2644 * clientId: 'your-client-id',
2745 * clientSecret: 'your-client-secret',
2846 * });
47+ *
48+ * // For interactive/CLI usage (opens browser)
49+ * const implicitAuth = new ImplicitOAuthStrategy({
50+ * clientId: 'your-client-id',
51+ * });
2952 * ```
3053 *
3154 * @module auth
3255 */
56+
57+ // Types
3358export type {
3459 AuthStrategy ,
3560 AccessTokenResponse ,
@@ -38,8 +63,19 @@ export type {
3863 BasicAuthConfig ,
3964 OAuthAuthConfig ,
4065 ApiKeyAuthConfig ,
66+ AuthMethod ,
67+ AuthCredentials ,
4168} from './types.js' ;
69+ export { ALL_AUTH_METHODS } from './types.js' ;
70+
71+ // Strategies
4272export { BasicAuthStrategy } from './basic.js' ;
4373export { OAuthStrategy , decodeJWT } from './oauth.js' ;
4474export type { OAuthConfig } from './oauth.js' ;
75+ export { ImplicitOAuthStrategy } from './oauth-implicit.js' ;
76+ export type { ImplicitOAuthConfig } from './oauth-implicit.js' ;
4577export { ApiKeyStrategy } from './api-key.js' ;
78+
79+ // Resolution helpers
80+ export { resolveAuthStrategy , checkAvailableAuthMethods } from './resolve.js' ;
81+ export type { ResolveAuthStrategyOptions , AvailableAuthMethods } from './resolve.js' ;
0 commit comments