@cloudflare/workers-auth 0.6.3 → 0.6.5
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-7AYQ2BAF.mjs → chunk-EGLFJKUK.mjs} +29 -7
- package/dist/{chunk-AEOSGWMT.mjs → chunk-X7ZLU22G.mjs} +5 -1
- package/dist/{file-format-Dbmn5hhd.d.mts → file-format-Bpmgm2Po.d.mts} +1 -1
- package/dist/index.d.mts +11 -5
- package/dist/index.mjs +1 -1
- package/dist/{keyring-preference-CeP6MLyb.d.mts → keyring-preference-CdaCHp2c.d.mts} +1 -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 +4 -4
package/dist/cf/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as ConfigStorage, A as AuthConfigStorage, U as UserAuthConfig,
|
|
2
|
-
import { C as CliDescriptor,
|
|
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-Bpmgm2Po.mjs';
|
|
2
|
+
import { C as CliDescriptor, A as AuthContext, a as CloudflareAuth, U as UserPreferences, K as KeyringPreferenceContext, S as SetKeyringPreferenceResult } from '../keyring-preference-CdaCHp2c.mjs';
|
|
3
|
+
export { b as CloudflareLoginProps } from '../keyring-preference-CdaCHp2c.mjs';
|
|
4
4
|
import '@cloudflare/workers-utils';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/cf/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createAuthConfigFileHelpers, createPreferences, createKeyringPreference, createFileStorage, createCloudflareAuth, createCloudflareProfileStore } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
import { createAuthConfigFileHelpers, createPreferences, createKeyringPreference, createFileStorage, createCloudflareAuth, createCloudflareProfileStore } from '../chunk-X7ZLU22G.mjs';
|
|
2
|
+
import '../chunk-EGLFJKUK.mjs';
|
|
3
3
|
import { __name } from '../chunk-O6YSETKJ.mjs';
|
|
4
4
|
import { getEnvironmentVariableFactory, getGlobalConfigPath, getCloudflareApiEnvironmentFromEnv } from '@cloudflare/workers-utils';
|
|
5
5
|
import path from 'node:path';
|
|
@@ -206,12 +206,10 @@ async function getAccessHeaders(domain, options) {
|
|
|
206
206
|
const clientSecret = getAccessClientSecretFromEnv();
|
|
207
207
|
if (clientId && clientSecret) {
|
|
208
208
|
logger.debug("Using Access Service Token headers for domain:", domain);
|
|
209
|
-
|
|
209
|
+
return {
|
|
210
210
|
"CF-Access-Client-Id": clientId,
|
|
211
211
|
"CF-Access-Client-Secret": clientSecret
|
|
212
212
|
};
|
|
213
|
-
headersCache[domain] = headers;
|
|
214
|
-
return headers;
|
|
215
213
|
}
|
|
216
214
|
if (clientId !== void 0 || clientSecret !== void 0) {
|
|
217
215
|
logger.warn(
|
|
@@ -3220,13 +3218,22 @@ function getInstalledBindingPath(installDir) {
|
|
|
3220
3218
|
return path4.join(installDir, "node_modules", "@napi-rs", "keyring");
|
|
3221
3219
|
}
|
|
3222
3220
|
__name(getInstalledBindingPath, "getInstalledBindingPath");
|
|
3221
|
+
function canLoadKeyringBinding(candidate) {
|
|
3222
|
+
try {
|
|
3223
|
+
createRequire(candidate)(candidate);
|
|
3224
|
+
return true;
|
|
3225
|
+
} catch {
|
|
3226
|
+
return false;
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
__name(canLoadKeyringBinding, "canLoadKeyringBinding");
|
|
3223
3230
|
function findKeyringBinding(installDir) {
|
|
3224
3231
|
const cached = cachedBindingPathByDir.get(installDir);
|
|
3225
3232
|
if (cached !== void 0) {
|
|
3226
3233
|
return cached;
|
|
3227
3234
|
}
|
|
3228
3235
|
const lazy = getInstalledBindingPath(installDir);
|
|
3229
|
-
if (existsSync(path4.join(lazy, "index.js"))) {
|
|
3236
|
+
if (existsSync(path4.join(lazy, "index.js")) && canLoadKeyringBinding(lazy)) {
|
|
3230
3237
|
cachedBindingPathByDir.set(installDir, lazy);
|
|
3231
3238
|
return lazy;
|
|
3232
3239
|
}
|
|
@@ -3234,7 +3241,7 @@ function findKeyringBinding(installDir) {
|
|
|
3234
3241
|
const r = npmRunner(["root", "-g"]);
|
|
3235
3242
|
if (r.status === 0) {
|
|
3236
3243
|
const global = path4.join(r.stdout.trim(), "@napi-rs", "keyring");
|
|
3237
|
-
if (existsSync(path4.join(global, "index.js"))) {
|
|
3244
|
+
if (existsSync(path4.join(global, "index.js")) && canLoadKeyringBinding(global)) {
|
|
3238
3245
|
cachedBindingPathByDir.set(installDir, global);
|
|
3239
3246
|
return global;
|
|
3240
3247
|
}
|
|
@@ -3293,6 +3300,17 @@ Retry once the underlying issue is fixed, or install the binding globally:
|
|
|
3293
3300
|
);
|
|
3294
3301
|
}
|
|
3295
3302
|
cachedBindingPathByDir.delete(installDir);
|
|
3303
|
+
if (findKeyringBinding(installDir) === null) {
|
|
3304
|
+
throw new UserError(
|
|
3305
|
+
`\`npm\` reported success but the \`@napi-rs/keyring\` native binding still cannot be loaded.
|
|
3306
|
+
|
|
3307
|
+
Its platform-specific binary ships as a separate optional package, so a download that was skipped or interrupted leaves the binding unusable.
|
|
3308
|
+
|
|
3309
|
+
Retry once the underlying issue is fixed, or install the binding globally:
|
|
3310
|
+
npm install -g @napi-rs/keyring@${PINNED_KEYRING_VERSION}`,
|
|
3311
|
+
{ telemetryMessage: "workers-auth keyring install incomplete" }
|
|
3312
|
+
);
|
|
3313
|
+
}
|
|
3296
3314
|
}
|
|
3297
3315
|
__name(installKeyringBindingSync, "installKeyringBindingSync");
|
|
3298
3316
|
var entryFactoryOverride;
|
|
@@ -3306,8 +3324,12 @@ function resolveKeyringEntryFactory(installDir) {
|
|
|
3306
3324
|
}
|
|
3307
3325
|
const bindingPath = findKeyringBinding(installDir);
|
|
3308
3326
|
if (bindingPath === null) {
|
|
3309
|
-
throw new
|
|
3310
|
-
|
|
3327
|
+
throw new UserError(
|
|
3328
|
+
`The \`@napi-rs/keyring\` native binding is not available.
|
|
3329
|
+
|
|
3330
|
+
Retry the command, or install the binding globally:
|
|
3331
|
+
npm install -g @napi-rs/keyring@${PINNED_KEYRING_VERSION}`,
|
|
3332
|
+
{ telemetryMessage: "workers-auth keyring binding not loadable" }
|
|
3311
3333
|
);
|
|
3312
3334
|
}
|
|
3313
3335
|
const mod = createRequire(bindingPath)(bindingPath);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, validateAccountId, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-
|
|
1
|
+
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, validateAccountId, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-EGLFJKUK.mjs';
|
|
2
2
|
import { __name } from './chunk-O6YSETKJ.mjs';
|
|
3
3
|
import { existsSync, rmSync, mkdirSync, writeFileSync, chmodSync, readFileSync as readFileSync$1, readdirSync } from 'node:fs';
|
|
4
4
|
import path3 from 'node:path';
|
|
@@ -1077,6 +1077,10 @@ ${accounts.map(
|
|
|
1077
1077
|
}
|
|
1078
1078
|
);
|
|
1079
1079
|
}
|
|
1080
|
+
const latchedTemporaryAccount = oauthFlow.getActiveTemporaryAccount();
|
|
1081
|
+
if (latchedTemporaryAccount) {
|
|
1082
|
+
return latchedTemporaryAccount.account.id;
|
|
1083
|
+
}
|
|
1080
1084
|
if (getAPIToken()) {
|
|
1081
1085
|
throw new UserError(
|
|
1082
1086
|
"You're already authenticated with Cloudflare, so `--temporary` can't be used. Temporary preview accounts are only for unauthenticated use. Either remove `--temporary` to use your existing account, or log out (and unset CLOUDFLARE_API_TOKEN) first.",
|
|
@@ -491,4 +491,4 @@ interface CredentialStore extends AuthConfigStorage {
|
|
|
491
491
|
*/
|
|
492
492
|
type FileFormat = "toml" | "json";
|
|
493
493
|
|
|
494
|
-
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 TemporaryPreviewAccount as T, type UserAuthConfig as U, type ConfigStorage as a, type
|
|
494
|
+
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 TemporaryPreviewAccount 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, createOAuthFlow as h, createProfileStore as i, generateAuthUrl as j, generateRandomState as k, type OAuthConsentPages as l, 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,
|
|
1
|
+
import { O as OAuthFlowLogger, U as UserAuthConfig, A as AuthConfigStorage, C as CredentialStore, F as FileFormat } from './file-format-Bpmgm2Po.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 TemporaryPreviewAccount, h as createOAuthFlow, i as createProfileStore, j as generateAuthUrl, k as generateRandomState, v as validateProfileName } from './file-format-Bpmgm2Po.mjs';
|
|
3
3
|
import { ApiCredentials } from '@cloudflare/workers-utils';
|
|
4
4
|
import { SpawnSyncReturns } from 'node:child_process';
|
|
5
5
|
|
|
@@ -663,6 +663,11 @@ declare function getKeyringInstallDir(configPath: string): string;
|
|
|
663
663
|
* @napi-rs/keyring` works in CI environments where the lazy install
|
|
664
664
|
* path is unavailable.
|
|
665
665
|
*
|
|
666
|
+
* A candidate only counts when it actually loads (see
|
|
667
|
+
* {@link canLoadKeyringBinding}) — a half-installed binding is reported as
|
|
668
|
+
* absent so the caller reinstalls it, rather than being trusted forever on the
|
|
669
|
+
* strength of an `index.js` that cannot be required.
|
|
670
|
+
*
|
|
666
671
|
* Returns `null` when no binding is available; callers handle the missing
|
|
667
672
|
* binding case explicitly so they can surface remediation instructions.
|
|
668
673
|
*
|
|
@@ -677,9 +682,10 @@ declare function findKeyringBinding(installDir: string): string | null;
|
|
|
677
682
|
* Install `@napi-rs/keyring` into the private install dir using the user's
|
|
678
683
|
* `npm`.
|
|
679
684
|
*
|
|
680
|
-
* Throws a {@link UserError} when `npm` cannot be spawned
|
|
681
|
-
*
|
|
682
|
-
* rather than a raw stack
|
|
685
|
+
* Throws a {@link UserError} when `npm` cannot be spawned, returns a non-zero
|
|
686
|
+
* exit code, or exits cleanly without leaving a loadable binding behind, so
|
|
687
|
+
* callers can surface actionable remediation hints rather than a raw stack
|
|
688
|
+
* trace.
|
|
683
689
|
*/
|
|
684
690
|
declare function installKeyringBindingSync(installDir: string): void;
|
|
685
691
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
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-
|
|
1
|
+
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-EGLFJKUK.mjs';
|
|
2
2
|
import './chunk-O6YSETKJ.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as OAuthFlowContext, l as OAuthConsentPages, F as FileFormat, C as CredentialStore, d as LoginOrRefreshResult, U as UserAuthConfig } from './file-format-Bpmgm2Po.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. */
|