温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/secrets
点击访问原文链接

Bun.secrets property | API Reference | Bun

Bun.secrets property | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/Bun/secretsVsecrets

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/secretsVsecrets

variable

secretsconst secrets: { delete(options: { name: string; service: string }): Promiseboolean>; get(options: { name: string; service: string }): Promisenull | string>; set(options: { allowUnrestrictedAccess: boolean; name: string; service: string; value: string }): Promisevoid> }

Securely store and retrieve sensitive credentials using the operating system's native credential storage.

Uses platform-specific secure storage:

macOS: Keychain ServicesLinux: libsecret (GNOME Keyring, KWallet, etc.)Windows: Windows Credential Manager
import { secrets } from "bun";

// Store a credential
await secrets.set({
service: "my-cli-tool",
name: "github-token",
value: "ghp_xxxxxxxxxxxxxxxxxxxx"
});

// Retrieve a credential
const token = await secrets.get({
service: "my-cli-tool",
name: "github-token"
});

if (token) {
console.log("Token found:", token);
} else {
console.log("Token not found");
}

// Delete a credential
const deleted = await secrets.delete({
service: "my-cli-tool",
name: "github-token"
});
console.log("Deleted:", deleted); // true if deleted, false if not found

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Bun.secrets property | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    Securely store and retrieve sensitive credentials using the operating system