MCPcopy
hub / github.com/nats-io/nats.go / UserCredentials

Function UserCredentials

nats.go:1380–1394  ·  view source on GitHub ↗

UserCredentials is a convenience function that takes a filename for a user's JWT and a filename for the user's private Nkey seed.

(userOrChainedFile string, seedFiles ...string)

Source from the content-addressed store, hash-verified

1378// UserCredentials is a convenience function that takes a filename
1379// for a user's JWT and a filename for the user's private Nkey seed.
1380func UserCredentials(userOrChainedFile string, seedFiles ...string) Option {
1381 userCB := func() (string, error) {
1382 return userFromFile(userOrChainedFile)
1383 }
1384 var keyFile string
1385 if len(seedFiles) > 0 {
1386 keyFile = seedFiles[0]
1387 } else {
1388 keyFile = userOrChainedFile
1389 }
1390 sigCB := func(nonce []byte) ([]byte, error) {
1391 return sigHandler(nonce, keyFile)
1392 }
1393 return UserJWT(userCB, sigCB)
1394}
1395
1396// UserCredentialBytes is a convenience function that takes the JWT and seed
1397// values as byte slices. This allows passing credentials directly from memory

Callers

nothing calls this directly

Calls 3

userFromFileFunction · 0.85
sigHandlerFunction · 0.85
UserJWTFunction · 0.85

Tested by

no test coverage detected