@cloudflare/workers-auth 0.14.0 → 0.15.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.
- package/dist/{file-format-DLf_MRuS.d.mts → authentication-error-DcqALFv6.d.mts} +10 -2
- package/dist/cf/index.d.mts +4 -3
- package/dist/cf/index.mjs +3 -2
- package/dist/{chunk-F2REEYJC.mjs → chunk-EOVD3NS2.mjs} +7 -4
- package/dist/{chunk-2K52M2W5.mjs → chunk-XVBBSNW2.mjs} +15 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{keyring-preference-DIwv0hwY.d.mts → keyring-preference-DGkctqNO.d.mts} +4 -2
- package/dist/metafile-esm.json +1 -1
- package/dist/wrangler/index.d.mts +3 -2
- package/dist/wrangler/index.mjs +3 -2
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger, ComplianceConfig, ApiCredentials } from '@cloudflare/workers-utils';
|
|
1
|
+
import { Logger, ComplianceConfig, ApiCredentials, UserError } from '@cloudflare/workers-utils';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Pluggable persistence for a typed config blob.
|
|
@@ -99,6 +99,8 @@ interface OAuthFlowTemporaryContext {
|
|
|
99
99
|
storage: TemporaryAccountStorage;
|
|
100
100
|
/** Consumer name used in temporary-account errors. */
|
|
101
101
|
cliDisplayName?: string;
|
|
102
|
+
/** Consumer temporary-account flag spelling. Defaults to `--temporary-account`. */
|
|
103
|
+
temporaryAccountFlag?: string;
|
|
102
104
|
/** Consumer command used to clear a cached temporary account. */
|
|
103
105
|
logoutCommand?: string;
|
|
104
106
|
/**
|
|
@@ -513,4 +515,10 @@ interface CredentialStore extends AuthConfigStorage {
|
|
|
513
515
|
*/
|
|
514
516
|
type FileFormat = "toml" | "json";
|
|
515
517
|
|
|
516
|
-
|
|
518
|
+
/** Authentication failed before an API request, with a machine-readable reason. */
|
|
519
|
+
declare class AuthenticationError extends UserError {
|
|
520
|
+
readonly reason: LoginOrRefreshFailureReason;
|
|
521
|
+
constructor(message: string, reason: LoginOrRefreshFailureReason, telemetryMessage: string);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
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, AuthenticationError as a, type ConfigStorage as b, type DirectoryBindingOperations as c, type DirectoryBindingsStorage as d, type LoginOrRefreshResult as e, type LoginProps as f, type OAuthFlowContext as g, type ProfileStore as h, type TemporaryPreviewAccount as i, createOAuthFlow as j, createProfileStore as k, generateAuthUrl as l, generateRandomState as m, type TemporaryAccountLogger as n, type OAuthConsentPages as o, validateProfileName as v };
|
package/dist/cf/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { b as ConfigStorage, A as AuthConfigStorage, U as UserAuthConfig, g as OAuthFlowContext, h as ProfileStore } from '../authentication-error-DcqALFv6.mjs';
|
|
2
|
+
export { a as AuthenticationError } from '../authentication-error-DcqALFv6.mjs';
|
|
3
|
+
import { C as CliDescriptor, A as AuthContext, a as CloudflareAuth, U as UserPreferences, K as KeyringPreferenceContext, S as SetKeyringPreferenceResult } from '../keyring-preference-DGkctqNO.mjs';
|
|
4
|
+
export { b as CloudflareLoginProps } from '../keyring-preference-DGkctqNO.mjs';
|
|
4
5
|
import '@cloudflare/workers-utils';
|
|
5
6
|
|
|
6
7
|
/**
|
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
|
-
|
|
2
|
+
import { createAuthConfigFileHelpers, createPreferences, createKeyringPreference, createFileStorage, createCloudflareAuth, createCloudflareProfileStore } from '../chunk-EOVD3NS2.mjs';
|
|
3
|
+
export { AuthenticationError } from '../chunk-XVBBSNW2.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';
|
|
@@ -581,6 +581,7 @@ var {
|
|
|
581
581
|
var CF_CLI = {
|
|
582
582
|
cliName: CF_CLI_NAME,
|
|
583
583
|
displayName: CF_DISPLAY_NAME,
|
|
584
|
+
temporaryAccountFlag: "--temporary-account",
|
|
584
585
|
commands: {
|
|
585
586
|
login: "cf auth login",
|
|
586
587
|
logout: "cf auth logout",
|
|
@@ -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, DEFAULT_TEMPORARY_ACCOUNT_FLAG, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, AuthenticationError, validateAccountId, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-XVBBSNW2.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';
|
|
@@ -786,6 +786,7 @@ function createCloudflareAuth(descriptor, ctx) {
|
|
|
786
786
|
const { logger } = ctx;
|
|
787
787
|
const temporaryAccountLogger = ctx.temporaryAccountLogger ?? logger;
|
|
788
788
|
const cliName = descriptor.cliName;
|
|
789
|
+
const temporaryAccountFlag = descriptor.temporaryAccountFlag ?? DEFAULT_TEMPORARY_ACCOUNT_FLAG;
|
|
789
790
|
const NOT_LOGGED_IN_ERROR_BODIES = notLoggedInErrorBodies(
|
|
790
791
|
descriptor.commands.login
|
|
791
792
|
);
|
|
@@ -829,6 +830,7 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
829
830
|
),
|
|
830
831
|
cliDisplayName: descriptor.displayName,
|
|
831
832
|
logoutCommand: descriptor.commands.logout,
|
|
833
|
+
temporaryAccountFlag,
|
|
832
834
|
prompt: createTemporaryTermsPrompt({
|
|
833
835
|
temporaryAccountLogger,
|
|
834
836
|
prompt: ctx.prompt
|
|
@@ -962,9 +964,10 @@ Run \`${descriptor.commands.whoami}\` to check your current authentication statu
|
|
|
962
964
|
const { throwOnEmpty = true } = options;
|
|
963
965
|
const loginResult = await loginOrRefreshIfRequired(complianceConfig);
|
|
964
966
|
if (!loginResult.loggedIn) {
|
|
965
|
-
throw new
|
|
967
|
+
throw new AuthenticationError(
|
|
966
968
|
`Not logged in. ${NOT_LOGGED_IN_ERROR_BODIES[loginResult.reason]}${NOT_LOGGED_IN_WHOAMI_TIP}`,
|
|
967
|
-
|
|
969
|
+
loginResult.reason,
|
|
970
|
+
"cfetch auth login required"
|
|
968
971
|
);
|
|
969
972
|
}
|
|
970
973
|
const credentials = requireApiToken();
|
|
@@ -1094,7 +1097,7 @@ ${accounts.map(
|
|
|
1094
1097
|
}
|
|
1095
1098
|
if (getAPIToken()) {
|
|
1096
1099
|
throw new UserError(
|
|
1097
|
-
|
|
1100
|
+
`You're already authenticated with Cloudflare, so \`${temporaryAccountFlag}\` can't be used. Temporary preview accounts are only for unauthenticated use. Either remove \`${temporaryAccountFlag}\` to use your existing account, or log out (and unset CLOUDFLARE_API_TOKEN) first.`,
|
|
1098
1101
|
{
|
|
1099
1102
|
telemetryMessage: "user temporary account already authenticated"
|
|
1100
1103
|
}
|
|
@@ -421,13 +421,13 @@ function solveChallenge(challenge) {
|
|
|
421
421
|
__name(solveChallenge, "solveChallenge");
|
|
422
422
|
|
|
423
423
|
// src/temporary.ts
|
|
424
|
+
var DEFAULT_TEMPORARY_ACCOUNT_FLAG = "--temporary-account";
|
|
424
425
|
var TEMPORARY_TERMS_URLS = {
|
|
425
426
|
termsOfService: "https://www.cloudflare.com/terms/",
|
|
426
427
|
privacyPolicy: "https://www.cloudflare.com/privacypolicy/"
|
|
427
428
|
};
|
|
428
429
|
var TEMPORARY_TERMS_PROMPT = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) in order to continue. By typing "yes", you agree to these terms. Type "yes" to continue.`;
|
|
429
430
|
var TEMPORARY_TERMS_NOTICE = `Continuing means you accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}).`;
|
|
430
|
-
var TEMPORARY_TERMS_ERROR = `You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) to use --temporary.`;
|
|
431
431
|
var EVENT_ACCOUNT_ERRORS = /* @__PURE__ */ new Map([
|
|
432
432
|
[
|
|
433
433
|
1035,
|
|
@@ -674,9 +674,10 @@ async function getOrCreateTemporaryPreviewAccount(options) {
|
|
|
674
674
|
TEMPORARY_TERMS_NOTICE
|
|
675
675
|
);
|
|
676
676
|
if (!termsAccepted) {
|
|
677
|
-
throw new UserError(
|
|
678
|
-
|
|
679
|
-
|
|
677
|
+
throw new UserError(
|
|
678
|
+
`You must accept Cloudflare's Terms of Service (${TEMPORARY_TERMS_URLS.termsOfService}) and Privacy Policy (${TEMPORARY_TERMS_URLS.privacyPolicy}) to use ${options.temporaryAccountFlag ?? DEFAULT_TEMPORARY_ACCOUNT_FLAG}.`,
|
|
679
|
+
{ telemetryMessage: "user temporary terms not accepted" }
|
|
680
|
+
);
|
|
680
681
|
}
|
|
681
682
|
const temporaryPreviewAccount = await createTemporaryPreviewAccount(
|
|
682
683
|
options.temporaryAccountLogger,
|
|
@@ -3372,6 +3373,15 @@ function scrubEncryptedCredentials(options) {
|
|
|
3372
3373
|
return { backendAvailable: false, encryptedFileExisted };
|
|
3373
3374
|
}
|
|
3374
3375
|
__name(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
3376
|
+
var AuthenticationError = class extends UserError {
|
|
3377
|
+
constructor(message, reason, telemetryMessage) {
|
|
3378
|
+
super(message, { telemetryMessage });
|
|
3379
|
+
this.reason = reason;
|
|
3380
|
+
}
|
|
3381
|
+
static {
|
|
3382
|
+
__name(this, "AuthenticationError");
|
|
3383
|
+
}
|
|
3384
|
+
};
|
|
3375
3385
|
/*! Bundled license information:
|
|
3376
3386
|
|
|
3377
3387
|
smol-toml/dist/error.js:
|
|
@@ -3636,4 +3646,4 @@ smol-toml/dist/index.js:
|
|
|
3636
3646
|
*)
|
|
3637
3647
|
*/
|
|
3638
3648
|
|
|
3639
|
-
export { EncryptedFileCredentialStore, FileCredentialStore, LinuxSecretToolKeyProvider, MacSecurityKeyProvider, NapiKeyringKeyProvider, PINNED_KEYRING_VERSION, PKCE_CHARSET, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_PROMPT, clearAccessCaches, clearCredentialStorageState, createCredentialStorageContext, createOAuthFlow, createProfileStore, decryptString, dedent, domainUsesAccess, encryptString, findKeyringBinding, generateAuthUrl, generateKey, generateRandomState, generateVerificationUrl, getAccessHeaders, getAuthConfigFilePath, getAuthFromEnv, getAuthUrlFromEnv, getCloudflareAPITokenFromEnv, getCloudflareAccountIdFromEnv, getCloudflareAuthUseKeyringFromEnv, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, getEncryptedAuthConfigFilePath, getKeyringAccountName, getKeyringInstallDir, installKeyringBindingSync, parseEncryptedEnvelope, parseFile, probeSecretTool, readStoredAuthState, resetCredentialStorageState, resolveKeyProvider, scrubEncryptedCredentials, setKeyProviderFactoryForTesting, setKeyringEntryFactory, setLinuxSecretToolRunner, setMacSecurityCommandRunner, setNpmRunner, stringifyFile, validateAccountId, validateProfileName };
|
|
3649
|
+
export { AuthenticationError, DEFAULT_TEMPORARY_ACCOUNT_FLAG, EncryptedFileCredentialStore, FileCredentialStore, LinuxSecretToolKeyProvider, MacSecurityKeyProvider, NapiKeyringKeyProvider, PINNED_KEYRING_VERSION, PKCE_CHARSET, TEMPORARY_TERMS_NOTICE, TEMPORARY_TERMS_PROMPT, clearAccessCaches, clearCredentialStorageState, createCredentialStorageContext, createOAuthFlow, createProfileStore, decryptString, dedent, domainUsesAccess, encryptString, findKeyringBinding, generateAuthUrl, generateKey, generateRandomState, generateVerificationUrl, getAccessHeaders, getAuthConfigFilePath, getAuthFromEnv, getAuthUrlFromEnv, getCloudflareAPITokenFromEnv, getCloudflareAccountIdFromEnv, getCloudflareAuthUseKeyringFromEnv, getCloudflareGlobalAuthEmailFromEnv, getCloudflareGlobalAuthKeyFromEnv, getEncryptedAuthConfigFilePath, getKeyringAccountName, getKeyringInstallDir, installKeyringBindingSync, parseEncryptedEnvelope, parseFile, probeSecretTool, readStoredAuthState, resetCredentialStorageState, resolveKeyProvider, scrubEncryptedCredentials, setKeyProviderFactoryForTesting, setKeyringEntryFactory, setLinuxSecretToolRunner, setMacSecurityCommandRunner, setNpmRunner, stringifyFile, validateAccountId, validateProfileName };
|
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 './
|
|
2
|
-
export { a as ConfigStorage, D as DeactivateDirectoryResult,
|
|
1
|
+
import { O as OAuthFlowLogger, U as UserAuthConfig, A as AuthConfigStorage, C as CredentialStore, F as FileFormat } from './authentication-error-DcqALFv6.mjs';
|
|
2
|
+
export { a as AuthenticationError, b as ConfigStorage, D as DeactivateDirectoryResult, c as DirectoryBindingOperations, d as DirectoryBindingsStorage, L as LoginOrRefreshFailureReason, e as LoginOrRefreshResult, f as LoginProps, g as OAuthFlowContext, P as ProfileConfigOperations, h as ProfileStore, T as TemporaryAccountRequest, i as TemporaryPreviewAccount, j as createOAuthFlow, k as createProfileStore, l as generateAuthUrl, m as generateRandomState, v as validateProfileName } from './authentication-error-DcqALFv6.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 { AuthenticationError, 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-XVBBSNW2.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 {
|
|
1
|
+
import { g as OAuthFlowContext, n as TemporaryAccountLogger, o as OAuthConsentPages, F as FileFormat, C as CredentialStore, T as TemporaryAccountRequest, e as LoginOrRefreshResult, U as UserAuthConfig } from './authentication-error-DcqALFv6.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. */
|
|
@@ -60,6 +60,8 @@ interface CliDescriptor {
|
|
|
60
60
|
* {@link CliDescriptor.cliName}, which names the executable.
|
|
61
61
|
*/
|
|
62
62
|
displayName: string;
|
|
63
|
+
/** Temporary-account flag spelling in user guidance. Defaults to `--temporary-account`. */
|
|
64
|
+
temporaryAccountFlag?: string;
|
|
63
65
|
/** Commands surfaced in auth guidance. */
|
|
64
66
|
commands: {
|
|
65
67
|
login: string;
|
|
@@ -156,7 +158,7 @@ interface CloudflareAuth {
|
|
|
156
158
|
getActiveProfile: () => string;
|
|
157
159
|
/** The currently-active credential store for the active profile. */
|
|
158
160
|
getCredentialStore: () => CredentialStore;
|
|
159
|
-
/** Mark whether
|
|
161
|
+
/** Mark whether temporary-account mode is permitted for the current invocation. */
|
|
160
162
|
setTemporaryAllowed: (allowed: boolean, request?: TemporaryAccountRequest) => void;
|
|
161
163
|
/** Resolve API credentials (env / temporary account / stored OAuth token). */
|
|
162
164
|
getAPIToken: () => ApiCredentials | undefined;
|