internal.go

 1//go:build go1.18
 2// +build go1.18
 3
 4// Copyright (c) Microsoft Corporation. All rights reserved.
 5// Licensed under the MIT License.
 6
 7package internal
 8
 9import (
10	"errors"
11
12	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/cache"
13)
14
15var errMissingImport = errors.New("import github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache to enable persistent caching")
16
17// NewCache constructs a persistent token cache when "o" isn't nil. Applications that intend to
18// use a persistent cache must first import the cache module, which will replace this function
19// with a platform-specific implementation.
20var NewCache = func(o *TokenCachePersistenceOptions, enableCAE bool) (cache.ExportReplace, error) {
21	if o == nil {
22		return nil, nil
23	}
24	return nil, errMissingImport
25}
26
27// CacheFilePath returns the path to the cache file for the given name.
28// Defining it in this package makes it available to azidentity tests.
29var CacheFilePath = func(name string) (string, error) {
30	return "", errMissingImport
31}