WIP: Save agent roles integration work before CHORUS rebrand
- Agent roles and coordination features - Chat API integration testing - New configuration and workspace management 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1
vendor/github.com/multiformats/go-multibase/.codecov.yml
generated
vendored
Normal file
1
vendor/github.com/multiformats/go-multibase/.codecov.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
comment: off
|
||||
3
vendor/github.com/multiformats/go-multibase/.gitignore
generated
vendored
Normal file
3
vendor/github.com/multiformats/go-multibase/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.swp
|
||||
|
||||
multibase-conv/multibase-conv
|
||||
3
vendor/github.com/multiformats/go-multibase/.gitmodules
generated
vendored
Normal file
3
vendor/github.com/multiformats/go-multibase/.gitmodules
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "spec"]
|
||||
path = spec
|
||||
url = https://github.com/multiformats/multibase.git
|
||||
21
vendor/github.com/multiformats/go-multibase/LICENSE
generated
vendored
Normal file
21
vendor/github.com/multiformats/go-multibase/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Protocol Labs Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
7
vendor/github.com/multiformats/go-multibase/Makefile
generated
vendored
Normal file
7
vendor/github.com/multiformats/go-multibase/Makefile
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
test: deps
|
||||
go test -count=1 -race -v ./...
|
||||
|
||||
export IPFS_API ?= v04x.ipfs.io
|
||||
|
||||
deps:
|
||||
go get -t ./...
|
||||
31
vendor/github.com/multiformats/go-multibase/README.md
generated
vendored
Normal file
31
vendor/github.com/multiformats/go-multibase/README.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# go-multibase
|
||||
|
||||
[](http://ipn.io)
|
||||
[](https://github.com/multiformats/multiformats)
|
||||
[](https://webchat.freenode.net/?channels=%23ipfs)
|
||||
[](https://github.com/RichardLitt/standard-readme)
|
||||
[](https://travis-ci.org/multiformats/go-multibase)
|
||||
[](https://codecov.io/github/multiformats/go-multibase?branch=master)
|
||||
|
||||
> Implementation of [multibase](https://github.com/multiformats/multibase) -self identifying base encodings- in Go.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
`go-multibase` is a standard Go module which can be installed with:
|
||||
|
||||
```sh
|
||||
go get github.com/multiformats/go-multibase
|
||||
```
|
||||
|
||||
## Contribute
|
||||
|
||||
Contributions welcome. Please check out [the issues](https://github.com/multiformats/go-multibase/issues).
|
||||
|
||||
Check out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
|
||||
|
||||
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE) © 2016 Protocol Labs Inc.
|
||||
21
vendor/github.com/multiformats/go-multibase/base16.go
generated
vendored
Normal file
21
vendor/github.com/multiformats/go-multibase/base16.go
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
package multibase
|
||||
|
||||
func hexEncodeToStringUpper(src []byte) string {
|
||||
dst := make([]byte, len(src)*2)
|
||||
hexEncodeUpper(dst, src)
|
||||
return string(dst)
|
||||
}
|
||||
|
||||
var hexTableUppers = [16]byte{
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F',
|
||||
}
|
||||
|
||||
func hexEncodeUpper(dst, src []byte) int {
|
||||
for i, v := range src {
|
||||
dst[i*2] = hexTableUppers[v>>4]
|
||||
dst[i*2+1] = hexTableUppers[v&0x0f]
|
||||
}
|
||||
|
||||
return len(src) * 2
|
||||
}
|
||||
52
vendor/github.com/multiformats/go-multibase/base2.go
generated
vendored
Normal file
52
vendor/github.com/multiformats/go-multibase/base2.go
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
package multibase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// binaryEncodeToString takes an array of bytes and returns
|
||||
// multibase binary representation
|
||||
func binaryEncodeToString(src []byte) string {
|
||||
dst := make([]byte, len(src)*8)
|
||||
encodeBinary(dst, src)
|
||||
return string(dst)
|
||||
}
|
||||
|
||||
// encodeBinary takes the src and dst bytes and converts each
|
||||
// byte to their binary rep using power reduction method
|
||||
func encodeBinary(dst []byte, src []byte) {
|
||||
for i, b := range src {
|
||||
for j := 0; j < 8; j++ {
|
||||
if b&(1<<uint(7-j)) == 0 {
|
||||
dst[i*8+j] = '0'
|
||||
} else {
|
||||
dst[i*8+j] = '1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// decodeBinaryString takes multibase binary representation
|
||||
// and returns a byte array
|
||||
func decodeBinaryString(s string) ([]byte, error) {
|
||||
if len(s)&7 != 0 {
|
||||
// prepend the padding
|
||||
s = strings.Repeat("0", 8-len(s)&7) + s
|
||||
}
|
||||
|
||||
data := make([]byte, len(s)>>3)
|
||||
|
||||
for i, dstIndex := 0, 0; i < len(s); i = i + 8 {
|
||||
value, err := strconv.ParseInt(s[i:i+8], 2, 0)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while conversion: %s", err)
|
||||
}
|
||||
|
||||
data[dstIndex] = byte(value)
|
||||
dstIndex++
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
95
vendor/github.com/multiformats/go-multibase/base256emoji.go
generated
vendored
Normal file
95
vendor/github.com/multiformats/go-multibase/base256emoji.go
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
package multibase
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var base256emojiTable = [256]rune{
|
||||
// Curated list, this is just a list of things that *somwhat* are related to our comunity
|
||||
'🚀', '🪐', '☄', '🛰', '🌌', // Space
|
||||
'🌑', '🌒', '🌓', '🌔', '🌕', '🌖', '🌗', '🌘', // Moon
|
||||
'🌍', '🌏', '🌎', // Our Home, for now (earth)
|
||||
'🐉', // Dragon!!!
|
||||
'☀', // Our Garden, for now (sol)
|
||||
'💻', '🖥', '💾', '💿', // Computer
|
||||
// The rest is completed from https://home.unicode.org/emoji/emoji-frequency/ at the time of creation (december 2021) (the data is from 2019), most used first until we reach 256.
|
||||
// We exclude modifier based emojies (such as flags) as they are bigger than one single codepoint.
|
||||
// Some other emojies were removed adhoc for various reasons.
|
||||
'😂', '❤', '😍', '🤣', '😊', '🙏', '💕', '😭', '😘', '👍',
|
||||
'😅', '👏', '😁', '🔥', '🥰', '💔', '💖', '💙', '😢', '🤔',
|
||||
'😆', '🙄', '💪', '😉', '☺', '👌', '🤗', '💜', '😔', '😎',
|
||||
'😇', '🌹', '🤦', '🎉', '💞', '✌', '✨', '🤷', '😱', '😌',
|
||||
'🌸', '🙌', '😋', '💗', '💚', '😏', '💛', '🙂', '💓', '🤩',
|
||||
'😄', '😀', '🖤', '😃', '💯', '🙈', '👇', '🎶', '😒', '🤭',
|
||||
'❣', '😜', '💋', '👀', '😪', '😑', '💥', '🙋', '😞', '😩',
|
||||
'😡', '🤪', '👊', '🥳', '😥', '🤤', '👉', '💃', '😳', '✋',
|
||||
'😚', '😝', '😴', '🌟', '😬', '🙃', '🍀', '🌷', '😻', '😓',
|
||||
'⭐', '✅', '🥺', '🌈', '😈', '🤘', '💦', '✔', '😣', '🏃',
|
||||
'💐', '☹', '🎊', '💘', '😠', '☝', '😕', '🌺', '🎂', '🌻',
|
||||
'😐', '🖕', '💝', '🙊', '😹', '🗣', '💫', '💀', '👑', '🎵',
|
||||
'🤞', '😛', '🔴', '😤', '🌼', '😫', '⚽', '🤙', '☕', '🏆',
|
||||
'🤫', '👈', '😮', '🙆', '🍻', '🍃', '🐶', '💁', '😲', '🌿',
|
||||
'🧡', '🎁', '⚡', '🌞', '🎈', '❌', '✊', '👋', '😰', '🤨',
|
||||
'😶', '🤝', '🚶', '💰', '🍓', '💢', '🤟', '🙁', '🚨', '💨',
|
||||
'🤬', '✈', '🎀', '🍺', '🤓', '😙', '💟', '🌱', '😖', '👶',
|
||||
'🥴', '▶', '➡', '❓', '💎', '💸', '⬇', '😨', '🌚', '🦋',
|
||||
'😷', '🕺', '⚠', '🙅', '😟', '😵', '👎', '🤲', '🤠', '🤧',
|
||||
'📌', '🔵', '💅', '🧐', '🐾', '🍒', '😗', '🤑', '🌊', '🤯',
|
||||
'🐷', '☎', '💧', '😯', '💆', '👆', '🎤', '🙇', '🍑', '❄',
|
||||
'🌴', '💣', '🐸', '💌', '📍', '🥀', '🤢', '👅', '💡', '💩',
|
||||
'👐', '📸', '👻', '🤐', '🤮', '🎼', '🥵', '🚩', '🍎', '🍊',
|
||||
'👼', '💍', '📣', '🥂',
|
||||
}
|
||||
|
||||
var base256emojiReverseTable map[rune]byte
|
||||
|
||||
func init() {
|
||||
base256emojiReverseTable = make(map[rune]byte, len(base256emojiTable))
|
||||
for i, v := range base256emojiTable {
|
||||
base256emojiReverseTable[v] = byte(i)
|
||||
}
|
||||
}
|
||||
|
||||
func base256emojiEncode(in []byte) string {
|
||||
var l int
|
||||
for _, v := range in {
|
||||
l += utf8.RuneLen(base256emojiTable[v])
|
||||
}
|
||||
var out strings.Builder
|
||||
out.Grow(l)
|
||||
for _, v := range in {
|
||||
out.WriteRune(base256emojiTable[v])
|
||||
}
|
||||
return out.String()
|
||||
}
|
||||
|
||||
type base256emojiCorruptInputError struct {
|
||||
index int
|
||||
char rune
|
||||
}
|
||||
|
||||
func (e base256emojiCorruptInputError) Error() string {
|
||||
return "illegal base256emoji data at input byte " + strconv.FormatInt(int64(e.index), 10) + ", char: '" + string(e.char) + "'"
|
||||
}
|
||||
|
||||
func (e base256emojiCorruptInputError) String() string {
|
||||
return e.Error()
|
||||
}
|
||||
|
||||
func base256emojiDecode(in string) ([]byte, error) {
|
||||
out := make([]byte, utf8.RuneCountInString(in))
|
||||
var stri int
|
||||
for i := 0; len(in) > 0; i++ {
|
||||
r, n := utf8.DecodeRuneInString(in)
|
||||
in = in[n:]
|
||||
var ok bool
|
||||
out[i], ok = base256emojiReverseTable[r]
|
||||
if !ok {
|
||||
return nil, base256emojiCorruptInputError{stri, r}
|
||||
}
|
||||
stri += n
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
17
vendor/github.com/multiformats/go-multibase/base32.go
generated
vendored
Normal file
17
vendor/github.com/multiformats/go-multibase/base32.go
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
package multibase
|
||||
|
||||
import (
|
||||
b32 "github.com/multiformats/go-base32"
|
||||
)
|
||||
|
||||
var base32StdLowerPad = b32.NewEncodingCI("abcdefghijklmnopqrstuvwxyz234567")
|
||||
var base32StdLowerNoPad = base32StdLowerPad.WithPadding(b32.NoPadding)
|
||||
|
||||
var base32StdUpperPad = b32.NewEncodingCI("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")
|
||||
var base32StdUpperNoPad = base32StdUpperPad.WithPadding(b32.NoPadding)
|
||||
|
||||
var base32HexLowerPad = b32.NewEncodingCI("0123456789abcdefghijklmnopqrstuv")
|
||||
var base32HexLowerNoPad = base32HexLowerPad.WithPadding(b32.NoPadding)
|
||||
|
||||
var base32HexUpperPad = b32.NewEncodingCI("0123456789ABCDEFGHIJKLMNOPQRSTUV")
|
||||
var base32HexUpperNoPad = base32HexUpperPad.WithPadding(b32.NoPadding)
|
||||
65
vendor/github.com/multiformats/go-multibase/encoder.go
generated
vendored
Normal file
65
vendor/github.com/multiformats/go-multibase/encoder.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
package multibase
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
// Encoder is a multibase encoding that is verified to be supported and
|
||||
// supports an Encode method that does not return an error
|
||||
type Encoder struct {
|
||||
enc Encoding
|
||||
}
|
||||
|
||||
// NewEncoder create a new Encoder from an Encoding
|
||||
func NewEncoder(base Encoding) (Encoder, error) {
|
||||
_, ok := EncodingToStr[base]
|
||||
if !ok {
|
||||
return Encoder{-1}, fmt.Errorf("unsupported multibase encoding: %d", base)
|
||||
}
|
||||
return Encoder{base}, nil
|
||||
}
|
||||
|
||||
// MustNewEncoder is like NewEncoder but will panic if the encoding is
|
||||
// invalid.
|
||||
func MustNewEncoder(base Encoding) Encoder {
|
||||
_, ok := EncodingToStr[base]
|
||||
if !ok {
|
||||
panic("Unsupported multibase encoding")
|
||||
}
|
||||
return Encoder{base}
|
||||
}
|
||||
|
||||
// EncoderByName creates an encoder from a string, the string can
|
||||
// either be the multibase name or single character multibase prefix
|
||||
func EncoderByName(str string) (Encoder, error) {
|
||||
var base Encoding
|
||||
var ok bool
|
||||
if len(str) == 0 {
|
||||
return Encoder{-1}, fmt.Errorf("empty multibase encoding")
|
||||
} else if utf8.RuneCountInString(str) == 1 {
|
||||
r, _ := utf8.DecodeRuneInString(str)
|
||||
base = Encoding(r)
|
||||
_, ok = EncodingToStr[base]
|
||||
} else {
|
||||
base, ok = Encodings[str]
|
||||
}
|
||||
if !ok {
|
||||
return Encoder{-1}, fmt.Errorf("unsupported multibase encoding: %s", str)
|
||||
}
|
||||
return Encoder{base}, nil
|
||||
}
|
||||
|
||||
func (p Encoder) Encoding() Encoding {
|
||||
return p.enc
|
||||
}
|
||||
|
||||
// Encode encodes the multibase using the given Encoder.
|
||||
func (p Encoder) Encode(data []byte) string {
|
||||
str, err := Encode(p.enc, data)
|
||||
if err != nil {
|
||||
// should not happen
|
||||
panic(err)
|
||||
}
|
||||
return str
|
||||
}
|
||||
194
vendor/github.com/multiformats/go-multibase/multibase.go
generated
vendored
Normal file
194
vendor/github.com/multiformats/go-multibase/multibase.go
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
package multibase
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"unicode/utf8"
|
||||
|
||||
b58 "github.com/mr-tron/base58/base58"
|
||||
b32 "github.com/multiformats/go-base32"
|
||||
b36 "github.com/multiformats/go-base36"
|
||||
)
|
||||
|
||||
// Encoding identifies the type of base-encoding that a multibase is carrying.
|
||||
type Encoding int
|
||||
|
||||
// These are the encodings specified in the standard, not are all
|
||||
// supported yet
|
||||
const (
|
||||
Identity = 0x00
|
||||
Base2 = '0'
|
||||
Base8 = '7'
|
||||
Base10 = '9'
|
||||
Base16 = 'f'
|
||||
Base16Upper = 'F'
|
||||
Base32 = 'b'
|
||||
Base32Upper = 'B'
|
||||
Base32pad = 'c'
|
||||
Base32padUpper = 'C'
|
||||
Base32hex = 'v'
|
||||
Base32hexUpper = 'V'
|
||||
Base32hexPad = 't'
|
||||
Base32hexPadUpper = 'T'
|
||||
Base36 = 'k'
|
||||
Base36Upper = 'K'
|
||||
Base58BTC = 'z'
|
||||
Base58Flickr = 'Z'
|
||||
Base64 = 'm'
|
||||
Base64url = 'u'
|
||||
Base64pad = 'M'
|
||||
Base64urlPad = 'U'
|
||||
Base256Emoji = '🚀'
|
||||
)
|
||||
|
||||
// EncodingToStr is a map of the supported encoding, unsupported encoding
|
||||
// specified in standard are left out
|
||||
var EncodingToStr = map[Encoding]string{
|
||||
0x00: "identity",
|
||||
'0': "base2",
|
||||
'f': "base16",
|
||||
'F': "base16upper",
|
||||
'b': "base32",
|
||||
'B': "base32upper",
|
||||
'c': "base32pad",
|
||||
'C': "base32padupper",
|
||||
'v': "base32hex",
|
||||
'V': "base32hexupper",
|
||||
't': "base32hexpad",
|
||||
'T': "base32hexpadupper",
|
||||
'k': "base36",
|
||||
'K': "base36upper",
|
||||
'z': "base58btc",
|
||||
'Z': "base58flickr",
|
||||
'm': "base64",
|
||||
'u': "base64url",
|
||||
'M': "base64pad",
|
||||
'U': "base64urlpad",
|
||||
Base256Emoji: "base256emoji",
|
||||
}
|
||||
|
||||
var Encodings = map[string]Encoding{}
|
||||
|
||||
func init() {
|
||||
for e, n := range EncodingToStr {
|
||||
Encodings[n] = e
|
||||
}
|
||||
}
|
||||
|
||||
// ErrUnsupportedEncoding is returned when the selected encoding is not known or
|
||||
// implemented.
|
||||
var ErrUnsupportedEncoding = fmt.Errorf("selected encoding not supported")
|
||||
|
||||
// Encode encodes a given byte slice with the selected encoding and returns a
|
||||
// multibase string (<encoding><base-encoded-string>). It will return
|
||||
// an error if the selected base is not known.
|
||||
func Encode(base Encoding, data []byte) (string, error) {
|
||||
switch base {
|
||||
case Identity:
|
||||
// 0x00 inside a string is OK in golang and causes no problems with the length calculation.
|
||||
return string(rune(Identity)) + string(data), nil
|
||||
case Base2:
|
||||
return string(Base2) + binaryEncodeToString(data), nil
|
||||
case Base16:
|
||||
return string(Base16) + hex.EncodeToString(data), nil
|
||||
case Base16Upper:
|
||||
return string(Base16Upper) + hexEncodeToStringUpper(data), nil
|
||||
case Base32:
|
||||
return string(Base32) + base32StdLowerNoPad.EncodeToString(data), nil
|
||||
case Base32Upper:
|
||||
return string(Base32Upper) + base32StdUpperNoPad.EncodeToString(data), nil
|
||||
case Base32hex:
|
||||
return string(Base32hex) + base32HexLowerNoPad.EncodeToString(data), nil
|
||||
case Base32hexUpper:
|
||||
return string(Base32hexUpper) + base32HexUpperNoPad.EncodeToString(data), nil
|
||||
case Base32pad:
|
||||
return string(Base32pad) + base32StdLowerPad.EncodeToString(data), nil
|
||||
case Base32padUpper:
|
||||
return string(Base32padUpper) + base32StdUpperPad.EncodeToString(data), nil
|
||||
case Base32hexPad:
|
||||
return string(Base32hexPad) + base32HexLowerPad.EncodeToString(data), nil
|
||||
case Base32hexPadUpper:
|
||||
return string(Base32hexPadUpper) + base32HexUpperPad.EncodeToString(data), nil
|
||||
case Base36:
|
||||
return string(Base36) + b36.EncodeToStringLc(data), nil
|
||||
case Base36Upper:
|
||||
return string(Base36Upper) + b36.EncodeToStringUc(data), nil
|
||||
case Base58BTC:
|
||||
return string(Base58BTC) + b58.EncodeAlphabet(data, b58.BTCAlphabet), nil
|
||||
case Base58Flickr:
|
||||
return string(Base58Flickr) + b58.EncodeAlphabet(data, b58.FlickrAlphabet), nil
|
||||
case Base64pad:
|
||||
return string(Base64pad) + base64.StdEncoding.EncodeToString(data), nil
|
||||
case Base64urlPad:
|
||||
return string(Base64urlPad) + base64.URLEncoding.EncodeToString(data), nil
|
||||
case Base64url:
|
||||
return string(Base64url) + base64.RawURLEncoding.EncodeToString(data), nil
|
||||
case Base64:
|
||||
return string(Base64) + base64.RawStdEncoding.EncodeToString(data), nil
|
||||
case Base256Emoji:
|
||||
return string(Base256Emoji) + base256emojiEncode(data), nil
|
||||
default:
|
||||
return "", ErrUnsupportedEncoding
|
||||
}
|
||||
}
|
||||
|
||||
// Decode takes a multibase string and decodes into a bytes buffer.
|
||||
// It will return an error if the selected base is not known.
|
||||
func Decode(data string) (Encoding, []byte, error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil, fmt.Errorf("cannot decode multibase for zero length string")
|
||||
}
|
||||
|
||||
r, _ := utf8.DecodeRuneInString(data)
|
||||
enc := Encoding(r)
|
||||
|
||||
switch enc {
|
||||
case Identity:
|
||||
return Identity, []byte(data[1:]), nil
|
||||
case Base2:
|
||||
bytes, err := decodeBinaryString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base16, Base16Upper:
|
||||
bytes, err := hex.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base32, Base32Upper:
|
||||
bytes, err := b32.RawStdEncoding.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base32hex, Base32hexUpper:
|
||||
bytes, err := b32.RawHexEncoding.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base32pad, Base32padUpper:
|
||||
bytes, err := b32.StdEncoding.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base32hexPad, Base32hexPadUpper:
|
||||
bytes, err := b32.HexEncoding.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base36, Base36Upper:
|
||||
bytes, err := b36.DecodeString(data[1:])
|
||||
return enc, bytes, err
|
||||
case Base58BTC:
|
||||
bytes, err := b58.DecodeAlphabet(data[1:], b58.BTCAlphabet)
|
||||
return Base58BTC, bytes, err
|
||||
case Base58Flickr:
|
||||
bytes, err := b58.DecodeAlphabet(data[1:], b58.FlickrAlphabet)
|
||||
return Base58Flickr, bytes, err
|
||||
case Base64pad:
|
||||
bytes, err := base64.StdEncoding.DecodeString(data[1:])
|
||||
return Base64pad, bytes, err
|
||||
case Base64urlPad:
|
||||
bytes, err := base64.URLEncoding.DecodeString(data[1:])
|
||||
return Base64urlPad, bytes, err
|
||||
case Base64:
|
||||
bytes, err := base64.RawStdEncoding.DecodeString(data[1:])
|
||||
return Base64, bytes, err
|
||||
case Base64url:
|
||||
bytes, err := base64.RawURLEncoding.DecodeString(data[1:])
|
||||
return Base64url, bytes, err
|
||||
case Base256Emoji:
|
||||
bytes, err := base256emojiDecode(data[4:])
|
||||
return Base256Emoji, bytes, err
|
||||
default:
|
||||
return -1, nil, ErrUnsupportedEncoding
|
||||
}
|
||||
}
|
||||
10
vendor/github.com/multiformats/go-multibase/package.json
generated
vendored
Normal file
10
vendor/github.com/multiformats/go-multibase/package.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"bugs": {
|
||||
"url": "https://github.com/multiformats/go-multibase"
|
||||
},
|
||||
"language": "go",
|
||||
"license": "",
|
||||
"name": "go-multibase",
|
||||
"version": "0.3.0"
|
||||
}
|
||||
3
vendor/github.com/multiformats/go-multibase/version.json
generated
vendored
Normal file
3
vendor/github.com/multiformats/go-multibase/version.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "v0.2.0"
|
||||
}
|
||||
Reference in New Issue
Block a user