MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / scrubAuthInfo

Function scrubAuthInfo

src/lib/live-logging.ts:102–112  ·  view source on GitHub ↗
(obj: object)

Source from the content-addressed store, hash-verified

100export const networkEnvironmentInfo = (): string => inspect(networkInterfaces())
101
102export const scrubAuthInfo = (obj: object): string => {
103 const message = inspect(obj)
104 const bearerRegex = /(Bearer [0-9a-f]{8})[0-9a-f-]{28}/i
105
106 if (bearerRegex.test(message)) {
107 return message.replace(bearerRegex, '$1-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
108 } else { // assume there is some other auth format and redact the entire header value
109 const authHeaderRegex = /Authorization:\s*(.*)/i
110 return message.replace(authHeaderRegex, 'Authorization: (redacted)')
111 }
112}
113
114/**
115 * Expected to manually verify the connected host (similar to overriding tls.checkServerIdentity)

Callers 1

requestFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected