package buffer
import "github.com/open-policy-agent/opa/internal/jwx/buffer"
Package buffer provides a very thin wrapper around []byte buffer called `Buffer`, to provide functionalities that are often used within the jwx related packages
Index ¶
- type Buffer
- func FromBase64(v []byte) (Buffer, error)
- func FromNData(v []byte) (Buffer, error)
- func FromUint(v uint64) Buffer
- func (b *Buffer) Base64Decode(v []byte) error
- func (b Buffer) Base64Encode() ([]byte, error)
- func (b Buffer) Bytes() []byte
- func (b Buffer) Len() int
- func (b Buffer) MarshalJSON() ([]byte, error)
- func (b Buffer) NData() []byte
- func (b *Buffer) UnmarshalJSON(data []byte) error
Types ¶
type Buffer ¶
type Buffer []byte
Buffer wraps `[]byte` and provides functions that are often used in the jwx related packages. One notable difference is that while encoding/json marshalls `[]byte` using base64.StdEncoding, this module uses base64.RawURLEncoding as mandated by the spec
func FromBase64 ¶
FromBase64 constructs a new Buffer from a base64 encoded data
func FromNData ¶
FromNData constructs a new Buffer from a "n:data" format (I made that name up)
func FromUint ¶
FromUint creates a `Buffer` from an unsigned int
func (*Buffer) Base64Decode ¶
Base64Decode decodes the contents of the Buffer using base64.RawURLEncoding
func (Buffer) Base64Encode ¶
Base64Encode encodes the contents of the Buffer using base64.RawURLEncoding
func (Buffer) Bytes ¶
Bytes returns the raw bytes that comprises the Buffer
func (Buffer) Len ¶
Len returns the number of bytes that the Buffer holds
func (Buffer) MarshalJSON ¶
MarshalJSON marshals the buffer into JSON format after encoding the buffer with base64.RawURLEncoding
func (Buffer) NData ¶
NData returns Datalen || Data, where Datalen is a 32 bit counter for the length of the following data, and Data is the octets that comprise the buffer data
func (*Buffer) UnmarshalJSON ¶
UnmarshalJSON unmarshals from a JSON string into a Buffer, after decoding it with base64.RawURLEncoding
Source Files ¶
- Version
- v1.4.2 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 6 hours ago –
Tools for package owners.