@cloudflare/workers-auth 0.6.4 → 0.6.6
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-LXNXA7SZ.mjs → chunk-LQW53VED.mjs} +29 -5
- package/dist/{chunk-5EWNHNLD.mjs → chunk-YCVYA5LL.mjs} +5 -1
- package/dist/{file-format-Dbmn5hhd.d.mts → file-format-Bpmgm2Po.d.mts} +1 -1
- package/dist/index.d.mts +16 -6
- 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 +2 -2
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-YCVYA5LL.mjs';
|
|
2
|
+
import '../chunk-LQW53VED.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';
|
|
@@ -3218,13 +3218,22 @@ function getInstalledBindingPath(installDir) {
|
|
|
3218
3218
|
return path4.join(installDir, "node_modules", "@napi-rs", "keyring");
|
|
3219
3219
|
}
|
|
3220
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");
|
|
3221
3230
|
function findKeyringBinding(installDir) {
|
|
3222
3231
|
const cached = cachedBindingPathByDir.get(installDir);
|
|
3223
3232
|
if (cached !== void 0) {
|
|
3224
3233
|
return cached;
|
|
3225
3234
|
}
|
|
3226
3235
|
const lazy = getInstalledBindingPath(installDir);
|
|
3227
|
-
if (existsSync(path4.join(lazy, "index.js"))) {
|
|
3236
|
+
if (existsSync(path4.join(lazy, "index.js")) && canLoadKeyringBinding(lazy)) {
|
|
3228
3237
|
cachedBindingPathByDir.set(installDir, lazy);
|
|
3229
3238
|
return lazy;
|
|
3230
3239
|
}
|
|
@@ -3232,7 +3241,7 @@ function findKeyringBinding(installDir) {
|
|
|
3232
3241
|
const r = npmRunner(["root", "-g"]);
|
|
3233
3242
|
if (r.status === 0) {
|
|
3234
3243
|
const global = path4.join(r.stdout.trim(), "@napi-rs", "keyring");
|
|
3235
|
-
if (existsSync(path4.join(global, "index.js"))) {
|
|
3244
|
+
if (existsSync(path4.join(global, "index.js")) && canLoadKeyringBinding(global)) {
|
|
3236
3245
|
cachedBindingPathByDir.set(installDir, global);
|
|
3237
3246
|
return global;
|
|
3238
3247
|
}
|
|
@@ -3291,6 +3300,17 @@ Retry once the underlying issue is fixed, or install the binding globally:
|
|
|
3291
3300
|
);
|
|
3292
3301
|
}
|
|
3293
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
|
+
}
|
|
3294
3314
|
}
|
|
3295
3315
|
__name(installKeyringBindingSync, "installKeyringBindingSync");
|
|
3296
3316
|
var entryFactoryOverride;
|
|
@@ -3304,8 +3324,12 @@ function resolveKeyringEntryFactory(installDir) {
|
|
|
3304
3324
|
}
|
|
3305
3325
|
const bindingPath = findKeyringBinding(installDir);
|
|
3306
3326
|
if (bindingPath === null) {
|
|
3307
|
-
throw new
|
|
3308
|
-
|
|
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" }
|
|
3309
3333
|
);
|
|
3310
3334
|
}
|
|
3311
3335
|
const mod = createRequire(bindingPath)(bindingPath);
|
|
@@ -3372,7 +3396,7 @@ function probeSecretTool() {
|
|
|
3372
3396
|
let result;
|
|
3373
3397
|
try {
|
|
3374
3398
|
const r = runner(["--version"]);
|
|
3375
|
-
result = r.
|
|
3399
|
+
result = r.error === void 0;
|
|
3376
3400
|
} catch {
|
|
3377
3401
|
result = false;
|
|
3378
3402
|
}
|
|
@@ -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-LQW53VED.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
|
|
|
@@ -557,7 +557,11 @@ declare function setLinuxSecretToolRunner(fn: LinuxSecretToolRunner | undefined)
|
|
|
557
557
|
/**
|
|
558
558
|
* Probe whether `secret-tool` is callable in the current environment.
|
|
559
559
|
*
|
|
560
|
-
* Returns `true` when `secret-tool
|
|
560
|
+
* Returns `true` when `secret-tool` could be spawned at all, whatever its
|
|
561
|
+
* exit status. libsecret's `secret-tool` has no `--version` flag: it prints
|
|
562
|
+
* its usage and exits 2, so the exit status says nothing about whether the
|
|
563
|
+
* tool is installed. Only a failure to spawn the process (e.g. `ENOENT`
|
|
564
|
+
* when it is not on `PATH`) means it is missing. The probe does not
|
|
561
565
|
* exercise the keyring backend itself — a missing D-Bus session surfaces
|
|
562
566
|
* on the first real read/write rather than every consumer invocation, so
|
|
563
567
|
* we avoid the extra latency on every command for users whose desktop
|
|
@@ -663,6 +667,11 @@ declare function getKeyringInstallDir(configPath: string): string;
|
|
|
663
667
|
* @napi-rs/keyring` works in CI environments where the lazy install
|
|
664
668
|
* path is unavailable.
|
|
665
669
|
*
|
|
670
|
+
* A candidate only counts when it actually loads (see
|
|
671
|
+
* {@link canLoadKeyringBinding}) — a half-installed binding is reported as
|
|
672
|
+
* absent so the caller reinstalls it, rather than being trusted forever on the
|
|
673
|
+
* strength of an `index.js` that cannot be required.
|
|
674
|
+
*
|
|
666
675
|
* Returns `null` when no binding is available; callers handle the missing
|
|
667
676
|
* binding case explicitly so they can surface remediation instructions.
|
|
668
677
|
*
|
|
@@ -677,9 +686,10 @@ declare function findKeyringBinding(installDir: string): string | null;
|
|
|
677
686
|
* Install `@napi-rs/keyring` into the private install dir using the user's
|
|
678
687
|
* `npm`.
|
|
679
688
|
*
|
|
680
|
-
* Throws a {@link UserError} when `npm` cannot be spawned
|
|
681
|
-
*
|
|
682
|
-
* rather than a raw stack
|
|
689
|
+
* Throws a {@link UserError} when `npm` cannot be spawned, returns a non-zero
|
|
690
|
+
* exit code, or exits cleanly without leaving a loadable binding behind, so
|
|
691
|
+
* callers can surface actionable remediation hints rather than a raw stack
|
|
692
|
+
* trace.
|
|
683
693
|
*/
|
|
684
694
|
declare function installKeyringBindingSync(installDir: string): void;
|
|
685
695
|
/**
|
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-LQW53VED.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. */
|