keychain

package
v0.0.0-...-986d24e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

README

Package cloudeng.io/macos/keychain

import cloudeng.io/macos/keychain

Package keychain provides a simple interface for reading and writing secure notes to the macOS keychain.

Constants

AccessibleDefault, AccessibleWhenUnlocked, AccessibleAfterFirstUnlock, AccessibleAlways, AccessibleWhenPasscodeSetThisDeviceOnly, AccessibleWhenUnlockedThisDeviceOnly, AccessibleAfterFirstUnlockThisDeviceOnly, AccessibleAccessibleAlwaysThisDeviceOnly
AccessibleDefault = Accessibility(keychain.AccessibleDefault)
AccessibleWhenUnlocked = Accessibility(keychain.AccessibleWhenUnlocked)
AccessibleAfterFirstUnlock = Accessibility(keychain.AccessibleAfterFirstUnlock)
AccessibleAlways = Accessibility(keychain.AccessibleAlways)
AccessibleWhenPasscodeSetThisDeviceOnly = Accessibility(keychain.AccessibleWhenPasscodeSetThisDeviceOnly)
AccessibleWhenUnlockedThisDeviceOnly = Accessibility(keychain.AccessibleWhenUnlockedThisDeviceOnly)
AccessibleAfterFirstUnlockThisDeviceOnly = Accessibility(keychain.AccessibleAfterFirstUnlockThisDeviceOnly)
AccessibleAccessibleAlwaysThisDeviceOnly = Accessibility(keychain.AccessibleAccessibleAlwaysThisDeviceOnly)

Types

Type Accessibility
type Accessibility int

Accessibility is the items accessibility

Functions
func ParseAccessibility(s string) (Accessibility, error)

ParseAccessibility parses a string into an Accessibility.

Methods
func (a Accessibility) String() string
Type Option
type Option func(o *options)

Option represents an option for configuring a keychain.T

Functions
func WithAccessibility(v Accessibility) Option

WithAccessibility sets the accessibility option for a keychain.T.

func WithUpdateInPlace(v bool) Option

WithUpdateInPlace sets the updateInPlace option for a keychain.T.

Type SecureNoteReader
type SecureNoteReader interface {
	ReadSecureNote(service string) (data []byte, err error)
}

SecureNoteReader defines the interface for reading secure notes from the keychain.

Functions
func NewReadonly(typ Type, account string, opts ...Option) SecureNoteReader

NewReadonly creates a new readonly Keychain.

Type T
type T struct {
	// contains filtered or unexported fields
}

T represents a keychain that can be used to read and write secure notes.

Functions
func New(typ Type, account string, opts ...Option) *T

New creates a new Keychain.

Methods
func (kc T) ReadFileCtx(_ context.Context, service string) ([]byte, error)
func (kc T) ReadSecureNote(service string) ([]byte, error)

ReadSecureNote reads a secure note from the keychain.

func (kc T) UpdateSecureNote(service string, data []byte) error

UpdateSecureNote updates an existing secure note in the keychain.

func (kc T) WriteFileCtx(_ context.Context, service string, data []byte) error
func (kc T) WriteSecureNote(service string, data []byte) error

WriteSecureNote writes a secure note to the keychain. It will update an existing note if it WithUpdateInPlace was set to true.

Type Type
type Type int

Type represents the type of keychain to use.

Constants
KeychainFileBased, KeychainDataProtectionLocal, KeychainICloud
// KeychainFileBased represents the file-based keychain.
// This is the legacy, local only, file based keychain.
KeychainFileBased Type = iota
// KeychainDataProtectionLocal represents the data protection
// keychain which is local, but integrated with the system's secure
// enclave. Applications that use must be signed and have
// appropriate entitlements.
KeychainDataProtectionLocal
// KeychainICloud represents the iCloud keychain that can be synced
// across devices.
// Applications that use must be signed and have appropriate
// entitlements.
KeychainICloud

Functions
func ParseType(s string) (Type, error)

ParseType parses a string into a KeychainType.

Methods
func (t Type) String() string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(o *options)

Option represents an option for configuring a keychain.T

type SecureNoteReader

type SecureNoteReader interface {
	ReadSecureNote(service string) (data []byte, err error)
}

SecureNoteReader defines the interface for reading secure notes from the keychain.

func NewReadonly

func NewReadonly(typ Type, account string, opts ...Option) SecureNoteReader

NewReadonly creates a new readonly Keychain.

type T

type T struct{}

func New

func New(typ Type, account string, opts ...Option) *T

New creates a new Keychain.

func (T) ReadSecureNote

func (u T) ReadSecureNote(service string) ([]byte, error)

func (T) UpdateSecureNote

func (u T) UpdateSecureNote(service string, data []byte) error

func (T) WriteSecureNote

func (u T) WriteSecureNote(service, account string, data []byte) error

type Type

type Type int

Type represents the type of keychain to use.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL