(token string)
| 257 | } |
| 258 | |
| 259 | func (conn *GithubConn) typeIs(token string) string { |
| 260 | // classical tokens: |
| 261 | // ghp_ for Personal Access Tokens |
| 262 | // gho_ for OAuth Access tokens |
| 263 | // ghu_ for GitHub App user-to-server tokens |
| 264 | // ghs_ for GitHub App server-to-server tokens |
| 265 | // ghr_ for GitHub App refresh tokens |
| 266 | // total len is 40, {prefix}{showPrefix}{secret}{showSuffix} |
| 267 | // fine-grained tokens |
| 268 | // github_pat_{82_characters} |
| 269 | classicalTokenClassicalPrefixes := []string{"ghp_", "gho_", "ghs_", "ghr_", "ghu_"} |
| 270 | classicalTokenFindGrainedPrefixes := []string{"github_pat_"} |
| 271 | for _, prefix := range classicalTokenClassicalPrefixes { |
| 272 | if strings.HasPrefix(token, prefix) { |
| 273 | return GithubTokenTypeClassical |
| 274 | } |
| 275 | } |
| 276 | for _, prefix := range classicalTokenFindGrainedPrefixes { |
| 277 | if strings.HasPrefix(token, prefix) { |
| 278 | return GithubTokenTypeFineGrained |
| 279 | } |
| 280 | } |
| 281 | return GithubTokenTypeUnknown |
| 282 | } |
| 283 | |
| 284 | func (connection GithubConnection) Sanitize() GithubConnection { |
| 285 | connection.GithubConn = connection.GithubConn.Sanitize() |
no outgoing calls