@cloudflare/workers-auth 0.12.0 → 0.13.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/dist/cf/index.d.mts +3 -3
- package/dist/cf/index.mjs +2 -2
- package/dist/{chunk-FT2NMTJB.mjs → chunk-NDZDTP46.mjs} +5 -6
- package/dist/{chunk-VVLCNASF.mjs → chunk-PGZZHNWG.mjs} +16 -7
- package/dist/{file-format-hS8cJZA7.d.mts → file-format-DDVG6IGi.d.mts} +13 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{keyring-preference-dD49DWOI.d.mts → keyring-preference-DCQufwLw.d.mts} +8 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/wrangler/index.d.mts +2 -2
- package/dist/wrangler/index.mjs +2 -2
- package/package.json +2 -2
package/dist/cf/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as ConfigStorage, A as AuthConfigStorage, U as UserAuthConfig, f as OAuthFlowContext, g as ProfileStore } from '../file-format-
|
|
2
|
-
import { C as CliDescriptor, A as AuthContext, a as CloudflareAuth, U as UserPreferences, K as KeyringPreferenceContext, S as SetKeyringPreferenceResult } from '../keyring-preference-
|
|
3
|
-
export { b as CloudflareLoginProps } from '../keyring-preference-
|
|
1
|
+
import { a as ConfigStorage, A as AuthConfigStorage, U as UserAuthConfig, f as OAuthFlowContext, g as ProfileStore } from '../file-format-DDVG6IGi.mjs';
|
|
2
|
+
import { C as CliDescriptor, A as AuthContext, a as CloudflareAuth, U as UserPreferences, K as KeyringPreferenceContext, S as SetKeyringPreferenceResult } from '../keyring-preference-DCQufwLw.mjs';
|
|
3
|
+
export { b as CloudflareLoginProps } from '../keyring-preference-DCQufwLw.mjs';
|
|
4
4
|
import '@cloudflare/workers-utils';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/cf/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { createAuthConfigFileHelpers, createPreferences, createKeyringPreference, createFileStorage, createCloudflareAuth, createCloudflareProfileStore } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
2
|
+
import { createAuthConfigFileHelpers, createPreferences, createKeyringPreference, createFileStorage, createCloudflareAuth, createCloudflareProfileStore } from '../chunk-PGZZHNWG.mjs';
|
|
3
|
+
import '../chunk-NDZDTP46.mjs';
|
|
4
4
|
import { __name } from '../chunk-VAZEJK55.mjs';
|
|
5
5
|
import { getEnvironmentVariableFactory, getGlobalConfigPath, getCloudflareApiEnvironmentFromEnv } from '@cloudflare/workers-utils';
|
|
6
6
|
import path from 'node:path';
|
|
@@ -541,7 +541,7 @@ function getCachedTemporaryPreviewAccount(storage) {
|
|
|
541
541
|
return temporaryPreviewAccount;
|
|
542
542
|
}
|
|
543
543
|
__name(getCachedTemporaryPreviewAccount, "getCachedTemporaryPreviewAccount");
|
|
544
|
-
async function requestPowSolution(
|
|
544
|
+
async function requestPowSolution(temporaryAccountLogger) {
|
|
545
545
|
const response = await fetch(getTemporaryPreviewChallengeUrl(), {
|
|
546
546
|
method: "POST",
|
|
547
547
|
headers: { "Content-Type": "application/json" },
|
|
@@ -579,12 +579,12 @@ async function requestPowSolution(logger) {
|
|
|
579
579
|
}
|
|
580
580
|
);
|
|
581
581
|
}
|
|
582
|
-
|
|
582
|
+
temporaryAccountLogger.log("Solving proof-of-work challenge\u2026");
|
|
583
583
|
return solveChallenge({ challengeToken, seed, k, g });
|
|
584
584
|
}
|
|
585
585
|
__name(requestPowSolution, "requestPowSolution");
|
|
586
|
-
async function createTemporaryPreviewAccount(
|
|
587
|
-
const pow = await requestPowSolution(
|
|
586
|
+
async function createTemporaryPreviewAccount(temporaryAccountLogger, request) {
|
|
587
|
+
const pow = await requestPowSolution(temporaryAccountLogger);
|
|
588
588
|
const response = await fetch(getTemporaryPreviewUrl(), {
|
|
589
589
|
method: "POST",
|
|
590
590
|
headers: { "Content-Type": "application/json" },
|
|
@@ -679,7 +679,7 @@ async function getOrCreateTemporaryPreviewAccount(options) {
|
|
|
679
679
|
});
|
|
680
680
|
}
|
|
681
681
|
const temporaryPreviewAccount = await createTemporaryPreviewAccount(
|
|
682
|
-
options.
|
|
682
|
+
options.temporaryAccountLogger,
|
|
683
683
|
options.request
|
|
684
684
|
);
|
|
685
685
|
options.storage.write(temporaryPreviewAccount);
|
|
@@ -1957,7 +1957,6 @@ function createOAuthFlow(ctx) {
|
|
|
1957
1957
|
}
|
|
1958
1958
|
const result = await getOrCreateTemporaryPreviewAccount({
|
|
1959
1959
|
...ctx.temporary,
|
|
1960
|
-
logger: ctx.logger,
|
|
1961
1960
|
...temporaryRequest ? { request: temporaryRequest } : {}
|
|
1962
1961
|
});
|
|
1963
1962
|
activeTemporaryAccount = result.account;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, validateAccountId, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-
|
|
2
|
+
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, validateAccountId, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-NDZDTP46.mjs';
|
|
3
3
|
import { __name } from './chunk-VAZEJK55.mjs';
|
|
4
4
|
import { existsSync, rmSync, mkdirSync, writeFileSync, chmodSync, readFileSync as readFileSync$1, readdirSync } from 'node:fs';
|
|
5
5
|
import path3 from 'node:path';
|
|
@@ -737,10 +737,10 @@ function createFileStorage(format, getPath) {
|
|
|
737
737
|
}
|
|
738
738
|
__name(createFileStorage, "createFileStorage");
|
|
739
739
|
function createTemporaryTermsPrompt(deps) {
|
|
740
|
-
const {
|
|
740
|
+
const { temporaryAccountLogger, prompt } = deps;
|
|
741
741
|
return /* @__PURE__ */ __name(async function ensureTemporaryTermsAccepted(question, notice) {
|
|
742
742
|
if (isNonInteractiveOrCI()) {
|
|
743
|
-
|
|
743
|
+
temporaryAccountLogger.log(notice);
|
|
744
744
|
return true;
|
|
745
745
|
}
|
|
746
746
|
const answer = await prompt(question);
|
|
@@ -770,9 +770,9 @@ function notLoggedInErrorBodies(loginCommand) {
|
|
|
770
770
|
};
|
|
771
771
|
}
|
|
772
772
|
__name(notLoggedInErrorBodies, "notLoggedInErrorBodies");
|
|
773
|
-
function logTemporaryPreviewAccount(
|
|
773
|
+
function logTemporaryPreviewAccount(temporaryAccountLogger, temporaryPreviewAccount, cached) {
|
|
774
774
|
const claimExpiresAt = new Date(temporaryPreviewAccount.claim.expiresAt);
|
|
775
|
-
|
|
775
|
+
temporaryAccountLogger.log(
|
|
776
776
|
dedent`
|
|
777
777
|
Temporary account ready:
|
|
778
778
|
Account: ${temporaryPreviewAccount.account.name} (${cached ? "reused" : "created"})
|
|
@@ -784,6 +784,7 @@ function logTemporaryPreviewAccount(logger, temporaryPreviewAccount, cached) {
|
|
|
784
784
|
__name(logTemporaryPreviewAccount, "logTemporaryPreviewAccount");
|
|
785
785
|
function createCloudflareAuth(descriptor, ctx) {
|
|
786
786
|
const { logger } = ctx;
|
|
787
|
+
const temporaryAccountLogger = ctx.temporaryAccountLogger ?? logger;
|
|
787
788
|
const cliName = descriptor.cliName;
|
|
788
789
|
const NOT_LOGGED_IN_ERROR_BODIES = notLoggedInErrorBodies(
|
|
789
790
|
descriptor.commands.login
|
|
@@ -826,7 +827,11 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
826
827
|
descriptor.fileFormat,
|
|
827
828
|
descriptor.getTemporaryAccountConfigPath
|
|
828
829
|
),
|
|
829
|
-
prompt: createTemporaryTermsPrompt({
|
|
830
|
+
prompt: createTemporaryTermsPrompt({
|
|
831
|
+
temporaryAccountLogger,
|
|
832
|
+
prompt: ctx.prompt
|
|
833
|
+
}),
|
|
834
|
+
temporaryAccountLogger
|
|
830
835
|
}
|
|
831
836
|
});
|
|
832
837
|
function setProfile(profile) {
|
|
@@ -1094,7 +1099,11 @@ ${accounts.map(
|
|
|
1094
1099
|
);
|
|
1095
1100
|
}
|
|
1096
1101
|
const { account: temporaryPreviewAccount, cached } = await oauthFlow.activateTemporaryAccount();
|
|
1097
|
-
logTemporaryPreviewAccount(
|
|
1102
|
+
logTemporaryPreviewAccount(
|
|
1103
|
+
temporaryAccountLogger,
|
|
1104
|
+
temporaryPreviewAccount,
|
|
1105
|
+
cached
|
|
1106
|
+
);
|
|
1098
1107
|
return temporaryPreviewAccount.account.id;
|
|
1099
1108
|
}
|
|
1100
1109
|
const result = await loginOrRefreshIfRequired(config);
|
|
@@ -105,6 +105,11 @@ interface OAuthFlowTemporaryContext {
|
|
|
105
105
|
* always return true
|
|
106
106
|
*/
|
|
107
107
|
prompt: (question: string, notice: string) => Promise<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Where progress messages emitted while provisioning go (for example the
|
|
110
|
+
* proof-of-work notice).
|
|
111
|
+
*/
|
|
112
|
+
temporaryAccountLogger: TemporaryAccountLogger;
|
|
108
113
|
}
|
|
109
114
|
/** Optional provisioning inputs for a newly-created temporary account. */
|
|
110
115
|
interface TemporaryAccountRequest {
|
|
@@ -131,6 +136,13 @@ interface OAuthConsentPages {
|
|
|
131
136
|
* Consumers pass in an implementation that maps to their own logging surface.
|
|
132
137
|
*/
|
|
133
138
|
type OAuthFlowLogger = Logger;
|
|
139
|
+
/**
|
|
140
|
+
* Sink for temporary-account notices: the terms notice, the proof-of-work
|
|
141
|
+
* notice, and the claim details. They are not part of a command's output, so a
|
|
142
|
+
* CLI can route them to stderr to keep them out of output written to stdout
|
|
143
|
+
* (JSON, piped object contents, …).
|
|
144
|
+
*/
|
|
145
|
+
type TemporaryAccountLogger = Pick<OAuthFlowLogger, "log">;
|
|
134
146
|
/**
|
|
135
147
|
* Dependency-injection surface for {@link createOAuthFlow}.
|
|
136
148
|
*
|
|
@@ -497,4 +509,4 @@ interface CredentialStore extends AuthConfigStorage {
|
|
|
497
509
|
*/
|
|
498
510
|
type FileFormat = "toml" | "json";
|
|
499
511
|
|
|
500
|
-
export { type AuthConfigStorage as A, type CredentialStore as C, type DeactivateDirectoryResult as D, type FileFormat as F, type LoginOrRefreshFailureReason as L, type OAuthFlowLogger as O, type ProfileConfigOperations as P, type TemporaryAccountRequest as T, type UserAuthConfig as U, type ConfigStorage as a, type DirectoryBindingOperations as b, type DirectoryBindingsStorage as c, type LoginOrRefreshResult as d, type LoginProps as e, type OAuthFlowContext as f, type ProfileStore as g, type TemporaryPreviewAccount as h, createOAuthFlow as i, createProfileStore as j, generateAuthUrl as k, generateRandomState as l, type
|
|
512
|
+
export { type AuthConfigStorage as A, type CredentialStore as C, type DeactivateDirectoryResult as D, type FileFormat as F, type LoginOrRefreshFailureReason as L, type OAuthFlowLogger as O, type ProfileConfigOperations as P, type TemporaryAccountRequest as T, type UserAuthConfig as U, type ConfigStorage as a, type DirectoryBindingOperations as b, type DirectoryBindingsStorage as c, type LoginOrRefreshResult as d, type LoginProps as e, type OAuthFlowContext as f, type ProfileStore as g, type TemporaryPreviewAccount as h, createOAuthFlow as i, createProfileStore as j, generateAuthUrl as k, generateRandomState as l, type TemporaryAccountLogger as m, type OAuthConsentPages as n, validateProfileName as v };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as OAuthFlowLogger, U as UserAuthConfig, A as AuthConfigStorage, C as CredentialStore, F as FileFormat } from './file-format-
|
|
2
|
-
export { a as ConfigStorage, D as DeactivateDirectoryResult, b as DirectoryBindingOperations, c as DirectoryBindingsStorage, L as LoginOrRefreshFailureReason, d as LoginOrRefreshResult, e as LoginProps, f as OAuthFlowContext, P as ProfileConfigOperations, g as ProfileStore, T as TemporaryAccountRequest, h as TemporaryPreviewAccount, i as createOAuthFlow, j as createProfileStore, k as generateAuthUrl, l as generateRandomState, v as validateProfileName } from './file-format-
|
|
1
|
+
import { O as OAuthFlowLogger, U as UserAuthConfig, A as AuthConfigStorage, C as CredentialStore, F as FileFormat } from './file-format-DDVG6IGi.mjs';
|
|
2
|
+
export { a as ConfigStorage, D as DeactivateDirectoryResult, b as DirectoryBindingOperations, c as DirectoryBindingsStorage, L as LoginOrRefreshFailureReason, d as LoginOrRefreshResult, e as LoginProps, f as OAuthFlowContext, P as ProfileConfigOperations, g as ProfileStore, T as TemporaryAccountRequest, h as TemporaryPreviewAccount, i as createOAuthFlow, j as createProfileStore, k as generateAuthUrl, l as generateRandomState, v as validateProfileName } from './file-format-DDVG6IGi.mjs';
|
|
3
3
|
import { ApiCredentials } from '@cloudflare/workers-utils';
|
|
4
4
|
import { SpawnSyncReturns } from 'node:child_process';
|
|
5
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
export { EncryptedFileCredentialStore, FileCredentialStore, LinuxSecretToolKeyProvider, MacSecurityKeyProvider, NapiKeyringKeyProvider, PINNED_KEYRING_VERSION, PKCE_CHARSET, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_PROMPT, clearAccessCaches, clearCredentialStorageState, createCredentialStorageContext, createOAuthFlow, createProfileStore, decryptString, domainUsesAccess, encryptString, findKeyringBinding, generateAuthUrl, generateKey, generateRandomState, generateVerificationUrl, getAccessHeaders, getAuthConfigFilePath, getAuthFromEnv, getAuthUrlFromEnv, getCloudflareAPITokenFromEnv, getCloudflareAccountIdFromEnv, getCloudflareAuthUseKeyringFromEnv, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, getEncryptedAuthConfigFilePath, getKeyringAccountName, getKeyringInstallDir, installKeyringBindingSync, parseEncryptedEnvelope, probeSecretTool, readStoredAuthState, resetCredentialStorageState, resolveKeyProvider, scrubEncryptedCredentials, setKeyProviderFactoryForTesting, setKeyringEntryFactory, setLinuxSecretToolRunner, setMacSecurityCommandRunner, setNpmRunner, validateProfileName } from './chunk-
|
|
2
|
+
export { EncryptedFileCredentialStore, FileCredentialStore, LinuxSecretToolKeyProvider, MacSecurityKeyProvider, NapiKeyringKeyProvider, PINNED_KEYRING_VERSION, PKCE_CHARSET, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_PROMPT, clearAccessCaches, clearCredentialStorageState, createCredentialStorageContext, createOAuthFlow, createProfileStore, decryptString, domainUsesAccess, encryptString, findKeyringBinding, generateAuthUrl, generateKey, generateRandomState, generateVerificationUrl, getAccessHeaders, getAuthConfigFilePath, getAuthFromEnv, getAuthUrlFromEnv, getCloudflareAPITokenFromEnv, getCloudflareAccountIdFromEnv, getCloudflareAuthUseKeyringFromEnv, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, getEncryptedAuthConfigFilePath, getKeyringAccountName, getKeyringInstallDir, installKeyringBindingSync, parseEncryptedEnvelope, probeSecretTool, readStoredAuthState, resetCredentialStorageState, resolveKeyProvider, scrubEncryptedCredentials, setKeyProviderFactoryForTesting, setKeyringEntryFactory, setLinuxSecretToolRunner, setMacSecurityCommandRunner, setNpmRunner, validateProfileName } from './chunk-NDZDTP46.mjs';
|
|
3
3
|
import './chunk-VAZEJK55.mjs';
|
|
4
4
|
|
|
5
5
|
createRequire(import.meta.url || (typeof __filename === "string" ? __filename : "/"));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as OAuthFlowContext, m as OAuthConsentPages, F as FileFormat, C as CredentialStore, T as TemporaryAccountRequest, d as LoginOrRefreshResult, U as UserAuthConfig } from './file-format-
|
|
1
|
+
import { f as OAuthFlowContext, m as TemporaryAccountLogger, n as OAuthConsentPages, F as FileFormat, C as CredentialStore, T as TemporaryAccountRequest, d as LoginOrRefreshResult, U as UserAuthConfig } from './file-format-DDVG6IGi.mjs';
|
|
2
2
|
import { ApiCredentials, ComplianceConfig } from '@cloudflare/workers-utils';
|
|
3
3
|
|
|
4
4
|
/** Minimal shape of the interactive `select` prompt's options for account selection. */
|
|
@@ -20,6 +20,13 @@ interface AccountSelectOptions {
|
|
|
20
20
|
interface AuthContext {
|
|
21
21
|
/** The consumer's logger (drop-in for wrangler's logger singleton). */
|
|
22
22
|
logger: OAuthFlowContext["logger"];
|
|
23
|
+
/**
|
|
24
|
+
* Where temporary-account status messages go: the terms notice, the
|
|
25
|
+
* proof-of-work notice, and the "Temporary account ready" claim details.
|
|
26
|
+
* These are not command output, so a CLI whose commands write parseable
|
|
27
|
+
* output to stdout should send them to stderr. Defaults to {@link logger}.
|
|
28
|
+
*/
|
|
29
|
+
temporaryAccountLogger?: TemporaryAccountLogger;
|
|
23
30
|
/**
|
|
24
31
|
* User-Agent header sent with the account/membership REST calls
|
|
25
32
|
* (e.g. `wrangler/<version>` or `cf/<version>`).
|