privnote

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 10 Imported by: 0

README

go-privnote

go-privnote is a Go client library for creating and reading notes on Privnote. It bypasses Cloudflare bot detection by using a TLS client for TLS fingerprinting.

Reference Linter Build status

client := privnote.NewClient()

noteLink, err := client.CreateNote(privnote.CreateNoteData{
    Data: "Hello, World!",
})

noteContent, err := client.ReadNoteFromLink("https://privnote.com/note-id#password")

noteContent, err := client.ReadNoteFromID("note-id", "password")

Installation

go get github.com/LightningDev1/go-privnote

Usage

See example/main.go for a complete example program.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidNote is returned when the note is invalid.
	// This is usually because the note has been destroyed or
	// does not exist.
	ErrInvalidNote = errors.New("note is invalid")

	// ErrEmptyNoteID is returned when the note ID is empty.
	ErrEmptyNoteID = errors.New("note ID cannot be empty")

	// ErrInvalidPassword is returned when the password is invalid.
	ErrInvalidPassword = errors.New("note password is invalid")
)
View Source
var Headers = http.Header{
	"accept":           {"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"},
	"accept-encoding":  {""},
	"accept-language":  {"en-US,en;q=0.5"},
	"referer":          {"https://privnote.com/"},
	"origin":           {"https://privnote.com"},
	"sec-fetch-dest":   {"empty"},
	"sec-fetch-mode":   {"cors"},
	"sec-fetch-site":   {"same-origin"},
	"user-agent":       {"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"},
	"x-requested-with": {"XMLHttpRequest"},
}

Headers are the default headers used by the Privnote client.

TLSClientOptions are the default TLS client options used by the Privnote client.

Functions

This section is empty.

Types

type Client

type Client struct {
	// BaseURL is the base URL for the Privnote API.
	// Defaults to "https://privnote.com".
	BaseURL string

	// HTTPClient is the client used to make HTTP requests to the Privnote API.
	HTTPClient tls_client.HttpClient
}

Client is a Privnote client for creating and opening notes.

func NewClient

func NewClient() *Client

NewClient creates a new Privnote client for creating and opening notes.

func (*Client) CreateNote

func (c *Client) CreateNote(noteData CreateNoteData) (string, error)

CreateNote creates a new note and returns the URL.

func (*Client) ReadNoteFromID

func (c *Client) ReadNoteFromID(noteID, password string) (string, error)

ReadNoteFromID opens and decrypts a note from its ID and password.

func (c *Client) ReadNoteFromLink(noteLink string) (string, error)

ReadNoteFromLink opens and decrypts a note from its link.

type CreateNoteData

type CreateNoteData struct {
	// Data is the content of the note.
	Data string

	// Password is the password for the note. Will be generated if empty.
	Password string

	// Duration is the time until the note expires. Defaults to 24 hours.
	// Maximum duration is 30 days or 720 hours.
	Duration time.Duration

	// NoConfirmation determines whether the user should be asked for confirmation
	// before destroying the note.
	NoConfirmation bool

	// NotifyEmail is the email address to notify when the note is read.
	NotifyEmail string

	// EmailRefName is a reference name of the note to include in the email.
	EmailRefName string
}

CreateNoteData is the data required for creating a note.

type Note

type Note struct {
	// Data is the encrypted content of the note.
	Data string `json:"data"`

	// HasManualPass is whether the note has a manual password.
	HasManualPass bool `json:"has_manual_pass"`

	// NoteLink is the URL of the note.
	NoteLink string `json:"note_link"`

	// DontAsk is whether the user should be asked for confirmation before
	// destroying the note.
	DontAsk bool `json:"dont_ask"`

	// Unknown fields
	Policy    int    `json:"policy"`
	ExpiresJS string `json:"expires_js"`
}

Note is how a private note is represented in the Privnote API.

func (*Note) UnmarshalJSON

func (n *Note) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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