github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/libkb/proof_icon.go (about)

     1  package libkb
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/keybase/client/go/protocol/keybase1"
     8  )
     9  
    10  func normalizeIconKey(key string) string {
    11  	switch key {
    12  	case "bitcoin":
    13  		return "btc"
    14  	case "zcash.t", "zcash.z", "zcash.s":
    15  		return "zcash"
    16  	case "http", "https", "dns":
    17  		return "web"
    18  	default:
    19  		return key
    20  	}
    21  }
    22  
    23  const ProofIconTypeSmall = "logo_black"
    24  const ProofIconTypeSmallDarkmode = "logo_white"
    25  const ProofIconTypeFull = "logo_full"
    26  const ProofIconTypeFullDarkmode = "logo_full_darkmode"
    27  
    28  func MakeProofIcons(mctx MetaContext, serviceKey, iconType string, size int) (res []keybase1.SizedImage) {
    29  	for _, factor := range []int{1, 2} {
    30  		factorix := ""
    31  		if factor > 1 {
    32  			factorix = fmt.Sprintf("@%vx", factor)
    33  		}
    34  
    35  		site := SiteURILookup[mctx.G().Env.GetRunMode()]
    36  		if mctx.G().Env.GetRunMode() == DevelRunMode {
    37  			site = strings.Replace(site, "localhost", "127.0.0.1", 1)
    38  		}
    39  
    40  		res = append(res, keybase1.SizedImage{
    41  			Path: strings.Join([]string{site,
    42  				"images/paramproofs/services",
    43  				normalizeIconKey(serviceKey),
    44  				// The 'c' query parameter is just for cache busting. It's ignored by the server.
    45  				fmt.Sprintf("%v_%v%v.png?c=3", iconType, size, factorix),
    46  			}, "/"),
    47  			Width: size * factor,
    48  		})
    49  	}
    50  	return res
    51  }