github.com/lestrrat-go/jwx/v2@v2.0.21/jwe/options_gen.go (about)

     1  // Code generated by tools/cmd/genoptions/main.go. DO NOT EDIT.
     2  
     3  package jwe
     4  
     5  import (
     6  	"io/fs"
     7  
     8  	"github.com/lestrrat-go/jwx/v2/jwa"
     9  	"github.com/lestrrat-go/option"
    10  )
    11  
    12  type Option = option.Interface
    13  
    14  // CompactOption describes options that can be passed to `jwe.Compact`
    15  type CompactOption interface {
    16  	Option
    17  	compactOption()
    18  }
    19  
    20  type compactOption struct {
    21  	Option
    22  }
    23  
    24  func (*compactOption) compactOption() {}
    25  
    26  // DecryptOption describes options that can be passed to `jwe.Decrypt`
    27  type DecryptOption interface {
    28  	Option
    29  	decryptOption()
    30  }
    31  
    32  type decryptOption struct {
    33  	Option
    34  }
    35  
    36  func (*decryptOption) decryptOption() {}
    37  
    38  // EncryptDecryptOption describes options that can be passed to either `jwe.Encrypt` or `jwe.Decrypt`
    39  type EncryptDecryptOption interface {
    40  	Option
    41  	encryptOption()
    42  	decryptOption()
    43  }
    44  
    45  type encryptDecryptOption struct {
    46  	Option
    47  }
    48  
    49  func (*encryptDecryptOption) encryptOption() {}
    50  
    51  func (*encryptDecryptOption) decryptOption() {}
    52  
    53  // EncryptOption describes options that can be passed to `jwe.Encrypt`
    54  type EncryptOption interface {
    55  	Option
    56  	encryptOption()
    57  }
    58  
    59  type encryptOption struct {
    60  	Option
    61  }
    62  
    63  func (*encryptOption) encryptOption() {}
    64  
    65  // GlobalDecryptOption describes options that changes global settings and for each call of the `jwe.Decrypt` function
    66  type GlobalDecryptOption interface {
    67  	Option
    68  	globalOption()
    69  	decryptOption()
    70  }
    71  
    72  type globalDecryptOption struct {
    73  	Option
    74  }
    75  
    76  func (*globalDecryptOption) globalOption() {}
    77  
    78  func (*globalDecryptOption) decryptOption() {}
    79  
    80  // GlobalOption describes options that changes global settings for this package
    81  type GlobalOption interface {
    82  	Option
    83  	globalOption()
    84  }
    85  
    86  type globalOption struct {
    87  	Option
    88  }
    89  
    90  func (*globalOption) globalOption() {}
    91  
    92  // ReadFileOption is a type of `Option` that can be passed to `jwe.Parse`
    93  type ParseOption interface {
    94  	Option
    95  	readFileOption()
    96  }
    97  
    98  type parseOption struct {
    99  	Option
   100  }
   101  
   102  func (*parseOption) readFileOption() {}
   103  
   104  // ReadFileOption is a type of `Option` that can be passed to `jwe.ReadFile`
   105  type ReadFileOption interface {
   106  	Option
   107  	readFileOption()
   108  }
   109  
   110  type readFileOption struct {
   111  	Option
   112  }
   113  
   114  func (*readFileOption) readFileOption() {}
   115  
   116  // JSONSuboption describes suboptions that can be passed to `jwe.WithJSON()` option
   117  type WithJSONSuboption interface {
   118  	Option
   119  	withJSONSuboption()
   120  }
   121  
   122  type withJSONSuboption struct {
   123  	Option
   124  }
   125  
   126  func (*withJSONSuboption) withJSONSuboption() {}
   127  
   128  // WithKeySetSuboption is a suboption passed to the WithKeySet() option
   129  type WithKeySetSuboption interface {
   130  	Option
   131  	withKeySetSuboption()
   132  }
   133  
   134  type withKeySetSuboption struct {
   135  	Option
   136  }
   137  
   138  func (*withKeySetSuboption) withKeySetSuboption() {}
   139  
   140  type identCEK struct{}
   141  type identCompress struct{}
   142  type identContentEncryptionAlgorithm struct{}
   143  type identFS struct{}
   144  type identKey struct{}
   145  type identKeyProvider struct{}
   146  type identKeyUsed struct{}
   147  type identMaxBufferSize struct{}
   148  type identMaxDecompressBufferSize struct{}
   149  type identMaxPBES2Count struct{}
   150  type identMergeProtectedHeaders struct{}
   151  type identMessage struct{}
   152  type identPerRecipientHeaders struct{}
   153  type identPretty struct{}
   154  type identProtectedHeaders struct{}
   155  type identRequireKid struct{}
   156  type identSerialization struct{}
   157  
   158  func (identCEK) String() string {
   159  	return "WithCEK"
   160  }
   161  
   162  func (identCompress) String() string {
   163  	return "WithCompress"
   164  }
   165  
   166  func (identContentEncryptionAlgorithm) String() string {
   167  	return "WithContentEncryption"
   168  }
   169  
   170  func (identFS) String() string {
   171  	return "WithFS"
   172  }
   173  
   174  func (identKey) String() string {
   175  	return "WithKey"
   176  }
   177  
   178  func (identKeyProvider) String() string {
   179  	return "WithKeyProvider"
   180  }
   181  
   182  func (identKeyUsed) String() string {
   183  	return "WithKeyUsed"
   184  }
   185  
   186  func (identMaxBufferSize) String() string {
   187  	return "WithMaxBufferSize"
   188  }
   189  
   190  func (identMaxDecompressBufferSize) String() string {
   191  	return "WithMaxDecompressBufferSize"
   192  }
   193  
   194  func (identMaxPBES2Count) String() string {
   195  	return "WithMaxPBES2Count"
   196  }
   197  
   198  func (identMergeProtectedHeaders) String() string {
   199  	return "WithMergeProtectedHeaders"
   200  }
   201  
   202  func (identMessage) String() string {
   203  	return "WithMessage"
   204  }
   205  
   206  func (identPerRecipientHeaders) String() string {
   207  	return "WithPerRecipientHeaders"
   208  }
   209  
   210  func (identPretty) String() string {
   211  	return "WithPretty"
   212  }
   213  
   214  func (identProtectedHeaders) String() string {
   215  	return "WithProtectedHeaders"
   216  }
   217  
   218  func (identRequireKid) String() string {
   219  	return "WithRequireKid"
   220  }
   221  
   222  func (identSerialization) String() string {
   223  	return "WithSerialization"
   224  }
   225  
   226  // WithCEK allows users to specify a variable to store the CEK used in the
   227  // message upon successful decryption. The variable must be a pointer to
   228  // a byte slice, and it will only be populated if the decryption is successful.
   229  //
   230  // This option is currently considered EXPERIMENTAL, and is subject to
   231  // future changes across minor/micro versions.
   232  func WithCEK(v *[]byte) DecryptOption {
   233  	return &decryptOption{option.New(identCEK{}, v)}
   234  }
   235  
   236  // WithCompress specifies the compression algorithm to use when encrypting
   237  // a payload using `jwe.Encrypt` (Yes, we know it can only be "" or "DEF",
   238  // but the way the specification is written it could allow for more options,
   239  // and therefore this option takes an argument)
   240  func WithCompress(v jwa.CompressionAlgorithm) EncryptOption {
   241  	return &encryptOption{option.New(identCompress{}, v)}
   242  }
   243  
   244  // WithContentEncryptionAlgorithm specifies the algorithm to encrypt the
   245  // JWE message content with. If not provided, `jwa.A256GCM` is used.
   246  func WithContentEncryption(v jwa.ContentEncryptionAlgorithm) EncryptOption {
   247  	return &encryptOption{option.New(identContentEncryptionAlgorithm{}, v)}
   248  }
   249  
   250  // WithFS specifies the source `fs.FS` object to read the file from.
   251  func WithFS(v fs.FS) ReadFileOption {
   252  	return &readFileOption{option.New(identFS{}, v)}
   253  }
   254  
   255  func WithKeyProvider(v KeyProvider) DecryptOption {
   256  	return &decryptOption{option.New(identKeyProvider{}, v)}
   257  }
   258  
   259  // WithKeyUsed allows you to specify the `jwe.Decrypt()` function to
   260  // return the key used for decryption. This may be useful when
   261  // you specify multiple key sources or if you pass a `jwk.Set`
   262  // and you want to know which key was successful at decrypting the
   263  // signature.
   264  //
   265  // `v` must be a pointer to an empty `interface{}`. Do not use
   266  // `jwk.Key` here unless you are 100% sure that all keys that you
   267  // have provided are instances of `jwk.Key` (remember that the
   268  // jwx API allows users to specify a raw key such as *rsa.PublicKey)
   269  func WithKeyUsed(v interface{}) DecryptOption {
   270  	return &decryptOption{option.New(identKeyUsed{}, v)}
   271  }
   272  
   273  // WithMaxBufferSize specifies the maximum buffer size for internal
   274  // calculations, such as when AES-CBC is performed. The default value is 256MB.
   275  // If set to an invalid value, the default value is used.
   276  //
   277  // This option has a global effect.
   278  //
   279  // Due to historical reasons this option has a vague name, but in future versions
   280  // it will be appropriately renamed.
   281  func WithMaxBufferSize(v int64) GlobalOption {
   282  	return &globalOption{option.New(identMaxBufferSize{}, v)}
   283  }
   284  
   285  // WithMaxDecompressBufferSize specifies the maximum buffer size for used when
   286  // decompressing the payload of a JWE message. If a compressed JWE payload
   287  // exceeds this amount when decompressed, jwe.Decrypt will return an error.
   288  // The default value is 10MB.
   289  //
   290  // This option can be used for `jwe.Settings()`, which changes the behavior
   291  // globally, or for `jwe.Decrypt()`, which changes the behavior for that
   292  // specific call.
   293  func WithMaxDecompressBufferSize(v int64) GlobalDecryptOption {
   294  	return &globalDecryptOption{option.New(identMaxDecompressBufferSize{}, v)}
   295  }
   296  
   297  // WithMaxPBES2Count specifies the maximum number of PBES2 iterations
   298  // to use when decrypting a message. If not specified, the default
   299  // value of 10,000 is used.
   300  //
   301  // This option has a global effect.
   302  func WithMaxPBES2Count(v int) GlobalOption {
   303  	return &globalOption{option.New(identMaxPBES2Count{}, v)}
   304  }
   305  
   306  // WithMergeProtectedHeaders specify that when given multiple headers
   307  // as options to `jwe.Encrypt`, these headers should be merged instead
   308  // of overwritten
   309  func WithMergeProtectedHeaders(v bool) EncryptOption {
   310  	return &encryptOption{option.New(identMergeProtectedHeaders{}, v)}
   311  }
   312  
   313  // WithMessage provides a message object to be populated by `jwe.Decrpt`
   314  // Using this option allows you to decrypt AND obtain the `jwe.Message`
   315  // in one go.
   316  //
   317  // Note that you should NOT be using the message object for anything other
   318  // than inspecting its contents. Particularly, do not expect the message
   319  // reliable when you call `Decrypt` on it. `(jwe.Message).Decrypt` is
   320  // slated to be deprecated in the next major version.
   321  func WithMessage(v *Message) DecryptOption {
   322  	return &decryptOption{option.New(identMessage{}, v)}
   323  }
   324  
   325  // WithPretty specifies whether the JSON output should be formatted and
   326  // indented
   327  func WithPretty(v bool) WithJSONSuboption {
   328  	return &withJSONSuboption{option.New(identPretty{}, v)}
   329  }
   330  
   331  // WithrequiredKid specifies whether the keys in the jwk.Set should
   332  // only be matched if the target JWE message's Key ID and the Key ID
   333  // in the given key matches.
   334  func WithRequireKid(v bool) WithKeySetSuboption {
   335  	return &withKeySetSuboption{option.New(identRequireKid{}, v)}
   336  }
   337  
   338  // WithCompact specifies that the result of `jwe.Encrypt()` is serialized in
   339  // compact format.
   340  //
   341  // By default `jwe.Encrypt()` will opt to use compact format, so you usually
   342  // do not need to specify this option other than to be explicit about it
   343  func WithCompact() EncryptOption {
   344  	return &encryptOption{option.New(identSerialization{}, fmtCompact)}
   345  }