@cloudflare/workers-auth 0.5.0 → 0.5.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-WJE5I5WS.mjs → chunk-FVDIXAPS.mjs} +1 -1
- package/dist/{chunk-FX4KV7FS.mjs → chunk-N7JTI7BC.mjs} +9 -11
- package/dist/{file-format-CWtMNfzC.d.mts → file-format-B1KgHuUR.d.mts} +2 -8
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/{keyring-preference-DMsAtawt.d.mts → keyring-preference-CyZ9gPSe.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, b as OAuthFlowContext, k as ProfileStore } from '../file-format-
|
|
2
|
-
import { C as CliDescriptor, U as UserPreferences, A as AuthContext, a as CloudflareAuth, 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, b as OAuthFlowContext, k as ProfileStore } from '../file-format-B1KgHuUR.mjs';
|
|
2
|
+
import { C as CliDescriptor, U as UserPreferences, A as AuthContext, a as CloudflareAuth, K as KeyringPreferenceContext, S as SetKeyringPreferenceResult } from '../keyring-preference-CyZ9gPSe.mjs';
|
|
3
|
+
export { b as CloudflareLoginProps } from '../keyring-preference-CyZ9gPSe.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-FVDIXAPS.mjs';
|
|
2
|
+
import '../chunk-N7JTI7BC.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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-
|
|
1
|
+
import { stringifyFile, parseFile, dedent, createCredentialStorageContext, createOAuthFlow, getAuthFromEnv, createProfileStore, getCloudflareAccountIdFromEnv, getAuthConfigFilePath, getEncryptedAuthConfigFilePath, scrubEncryptedCredentials, validateProfileName, getCloudflareAuthUseKeyringFromEnv } from './chunk-N7JTI7BC.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';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __name } from './chunk-O6YSETKJ.mjs';
|
|
2
|
-
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, getBooleanEnvironmentVariableFactory, UserError, readFileSync, getCloudflareApiBaseUrl, COMPLIANCE_REGION_CONFIG_PUBLIC, FatalError, getCloudflareComplianceRegion, parseTOML } from '@cloudflare/workers-utils';
|
|
2
|
+
import { getEnvironmentVariableFactory, getCloudflareApiEnvironmentFromEnv, getBooleanEnvironmentVariableFactory, UserError, readFileSync, isNonInteractiveOrCI, getCloudflareApiBaseUrl, COMPLIANCE_REGION_CONFIG_PUBLIC, FatalError, getCloudflareComplianceRegion, parseTOML } from '@cloudflare/workers-utils';
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { fetch } from 'undici';
|
|
5
5
|
import { webcrypto, createHash, randomBytes, createCipheriv, createDecipheriv } from 'node:crypto';
|
|
@@ -173,7 +173,6 @@ async function domainUsesAccess(domain, logger) {
|
|
|
173
173
|
__name(domainUsesAccess, "domainUsesAccess");
|
|
174
174
|
async function getAccessHeaders(domain, options) {
|
|
175
175
|
const logger = options.logger;
|
|
176
|
-
const isNonInteractiveOrCI = options.isNonInteractiveOrCI;
|
|
177
176
|
const clientId = getAccessClientIdFromEnv();
|
|
178
177
|
const clientSecret = getAccessClientSecretFromEnv();
|
|
179
178
|
if (clientId && clientSecret) {
|
|
@@ -198,7 +197,7 @@ async function getAccessHeaders(domain, options) {
|
|
|
198
197
|
logger.debug("Using cached Access headers for domain:", domain);
|
|
199
198
|
return headersCache[domain];
|
|
200
199
|
}
|
|
201
|
-
if (isNonInteractiveOrCI()) {
|
|
200
|
+
if ((options.isNonInteractiveOrCI ?? isNonInteractiveOrCI)()) {
|
|
202
201
|
throw new UserError(
|
|
203
202
|
`The domain "${domain}" is behind Cloudflare Access, but no Access Service Token credentials were found and the current environment is non-interactive.
|
|
204
203
|
Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables to authenticate with an Access Service Token.
|
|
@@ -798,7 +797,7 @@ async function getAuthURL(scopes, clientId, redirectUri, state, generators) {
|
|
|
798
797
|
});
|
|
799
798
|
}
|
|
800
799
|
__name(getAuthURL, "getAuthURL");
|
|
801
|
-
async function exchangeRefreshTokenForAccessToken(logger,
|
|
800
|
+
async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI2, clientId, storage) {
|
|
802
801
|
const storedRefreshToken = readStoredAuthState({
|
|
803
802
|
warningLogger: logger,
|
|
804
803
|
storage
|
|
@@ -811,7 +810,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI,
|
|
|
811
810
|
refresh_token: storedRefreshToken?.value ?? "",
|
|
812
811
|
client_id: clientId
|
|
813
812
|
});
|
|
814
|
-
const response = await fetchAuthToken(params, logger,
|
|
813
|
+
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI2);
|
|
815
814
|
if (response.status >= 400) {
|
|
816
815
|
let tokenExchangeResErr = void 0;
|
|
817
816
|
try {
|
|
@@ -858,7 +857,7 @@ async function exchangeRefreshTokenForAccessToken(logger, isNonInteractiveOrCI,
|
|
|
858
857
|
}
|
|
859
858
|
}
|
|
860
859
|
__name(exchangeRefreshTokenForAccessToken, "exchangeRefreshTokenForAccessToken");
|
|
861
|
-
async function exchangeAuthCodeForAccessToken(state, logger,
|
|
860
|
+
async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrCI2, clientId, redirectUri) {
|
|
862
861
|
const { authorizationCode, codeVerifier = "" } = state;
|
|
863
862
|
if (!codeVerifier) {
|
|
864
863
|
logger.warn("No code verifier is being sent.");
|
|
@@ -872,7 +871,7 @@ async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrC
|
|
|
872
871
|
client_id: clientId,
|
|
873
872
|
code_verifier: codeVerifier
|
|
874
873
|
});
|
|
875
|
-
const response = await fetchAuthToken(params, logger,
|
|
874
|
+
const response = await fetchAuthToken(params, logger, isNonInteractiveOrCI2);
|
|
876
875
|
if (!response.ok) {
|
|
877
876
|
const { error } = await getJSONFromResponse(response, logger);
|
|
878
877
|
if (error === "invalid_grant") {
|
|
@@ -900,7 +899,7 @@ async function exchangeAuthCodeForAccessToken(state, logger, isNonInteractiveOrC
|
|
|
900
899
|
return accessContext;
|
|
901
900
|
}
|
|
902
901
|
__name(exchangeAuthCodeForAccessToken, "exchangeAuthCodeForAccessToken");
|
|
903
|
-
async function fetchAuthToken(body, logger,
|
|
902
|
+
async function fetchAuthToken(body, logger, isNonInteractiveOrCI2) {
|
|
904
903
|
const headers = {
|
|
905
904
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
906
905
|
};
|
|
@@ -914,7 +913,7 @@ async function fetchAuthToken(body, logger, isNonInteractiveOrCI) {
|
|
|
914
913
|
);
|
|
915
914
|
const accessHeaders = await getCloudflareAccessHeaders({
|
|
916
915
|
logger,
|
|
917
|
-
isNonInteractiveOrCI
|
|
916
|
+
isNonInteractiveOrCI: isNonInteractiveOrCI2
|
|
918
917
|
});
|
|
919
918
|
Object.assign(headers, accessHeaders);
|
|
920
919
|
}
|
|
@@ -2888,7 +2887,6 @@ function setKeyringEntryFactory(factory) {
|
|
|
2888
2887
|
entryFactoryOverride = factory;
|
|
2889
2888
|
}
|
|
2890
2889
|
__name(setKeyringEntryFactory, "setKeyringEntryFactory");
|
|
2891
|
-
var dynamicRequire = createRequire(__filename);
|
|
2892
2890
|
function resolveKeyringEntryFactory(installDir) {
|
|
2893
2891
|
if (entryFactoryOverride !== void 0) {
|
|
2894
2892
|
return entryFactoryOverride;
|
|
@@ -2899,7 +2897,7 @@ function resolveKeyringEntryFactory(installDir) {
|
|
|
2899
2897
|
"`@napi-rs/keyring` binding not found. Call `installKeyringBindingSync()` first."
|
|
2900
2898
|
);
|
|
2901
2899
|
}
|
|
2902
|
-
const mod =
|
|
2900
|
+
const mod = createRequire(bindingPath)(bindingPath);
|
|
2903
2901
|
return (service, account) => new mod.Entry(service, account);
|
|
2904
2902
|
}
|
|
2905
2903
|
__name(resolveKeyringEntryFactory, "resolveKeyringEntryFactory");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComplianceConfig, ApiCredentials } from '@cloudflare/workers-utils';
|
|
1
|
+
import { Logger, ComplianceConfig, ApiCredentials } from '@cloudflare/workers-utils';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Pluggable persistence for a typed config blob.
|
|
@@ -126,13 +126,7 @@ interface OAuthConsentPages {
|
|
|
126
126
|
* Subset of the wrangler `logger` singleton used by the OAuth flow.
|
|
127
127
|
* Consumers pass in an implementation that maps to their own logging surface.
|
|
128
128
|
*/
|
|
129
|
-
|
|
130
|
-
debug(...args: unknown[]): void;
|
|
131
|
-
info(...args: unknown[]): void;
|
|
132
|
-
log(...args: unknown[]): void;
|
|
133
|
-
warn(...args: unknown[]): void;
|
|
134
|
-
error(...args: unknown[]): void;
|
|
135
|
-
}
|
|
129
|
+
type OAuthFlowLogger = Logger;
|
|
136
130
|
/**
|
|
137
131
|
* Dependency-injection surface for {@link createOAuthFlow}.
|
|
138
132
|
*
|
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, i as DirectoryBindingOperations, j as DirectoryBindingsStorage, L as LoginOrRefreshFailureReason, d as LoginOrRefreshResult, e as LoginProps, b as OAuthFlowContext, P as ProfileConfigOperations, k as ProfileStore, T as TemporaryPreviewAccount, c as createOAuthFlow, h as createProfileStore, g as generateAuthUrl, f 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-B1KgHuUR.mjs';
|
|
2
|
+
export { a as ConfigStorage, D as DeactivateDirectoryResult, i as DirectoryBindingOperations, j as DirectoryBindingsStorage, L as LoginOrRefreshFailureReason, d as LoginOrRefreshResult, e as LoginProps, b as OAuthFlowContext, P as ProfileConfigOperations, k as ProfileStore, T as TemporaryPreviewAccount, c as createOAuthFlow, h as createProfileStore, g as generateAuthUrl, f as generateRandomState, v as validateProfileName } from './file-format-B1KgHuUR.mjs';
|
|
3
3
|
import { ApiCredentials } from '@cloudflare/workers-utils';
|
|
4
4
|
import { SpawnSyncReturns } from 'node:child_process';
|
|
5
5
|
|
|
@@ -61,7 +61,7 @@ declare function domainUsesAccess(domain: string, logger: OAuthFlowLogger): Prom
|
|
|
61
61
|
*/
|
|
62
62
|
declare function getAccessHeaders(domain: string, options: {
|
|
63
63
|
logger: OAuthFlowLogger;
|
|
64
|
-
isNonInteractiveOrCI
|
|
64
|
+
isNonInteractiveOrCI?: () => boolean;
|
|
65
65
|
}): Promise<Record<string, string>>;
|
|
66
66
|
|
|
67
67
|
/**
|
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, 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, 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-N7JTI7BC.mjs';
|
|
2
2
|
import './chunk-O6YSETKJ.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as OAuthConsentPages, F as FileFormat, b as OAuthFlowContext, C as CredentialStore, d as LoginOrRefreshResult, U as UserAuthConfig } from './file-format-
|
|
1
|
+
import { l as OAuthConsentPages, F as FileFormat, b as OAuthFlowContext, C as CredentialStore, d as LoginOrRefreshResult, U as UserAuthConfig } from './file-format-B1KgHuUR.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. */
|