Skip to content

Commit 177b79b

Browse files
committed
Upgrade pkg and typeid
1 parent 975f73c commit 177b79b

File tree

3 files changed

+38
-20
lines changed

3 files changed

+38
-20
lines changed

go.mod

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ require (
3838
github.com/tailscale/hujson v0.0.0-20250226034555-ec1d1c113d33
3939
github.com/wk8/go-ordered-map/v2 v2.1.8
4040
github.com/zealic/go2node v0.1.0
41-
go.jetify.com/envsec v0.0.16-0.20250224183918-888379403227
42-
go.jetify.com/pkg v0.0.0-20250305231704-b305f9e8bd85
43-
go.jetify.com/typeid v1.3.0
41+
go.jetify.com/envsec v0.0.16-0.20250709181241-04401af54a3c
42+
go.jetify.com/pkg v0.0.0-20250709180804-ea4301dbbaab
43+
go.jetify.com/typeid/v2 v2.0.0-alpha.2
4444
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
4545
golang.org/x/mod v0.24.0
4646
golang.org/x/oauth2 v0.28.0
@@ -113,7 +113,7 @@ require (
113113
github.com/chavacava/garif v0.1.0 // indirect
114114
github.com/ckaznocha/intrange v0.3.0 // indirect
115115
github.com/cloudflare/circl v1.6.1 // indirect
116-
github.com/codeclysm/extract/v3 v3.1.1 // indirect
116+
github.com/codeclysm/extract/v4 v4.0.0 // indirect
117117
github.com/coreos/go-oidc/v3 v3.12.0 // indirect
118118
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
119119
github.com/creack/pty v1.1.24 // indirect
@@ -141,7 +141,7 @@ require (
141141
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
142142
github.com/gobwas/glob v0.2.3 // indirect
143143
github.com/gofrs/flock v0.12.1 // indirect
144-
github.com/gofrs/uuid/v5 v5.3.1 // indirect
144+
github.com/gofrs/uuid/v5 v5.3.2 // indirect
145145
github.com/golang/protobuf v1.5.3 // indirect
146146
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
147147
github.com/golangci/go-printf-func-name v0.1.0 // indirect
@@ -275,6 +275,7 @@ require (
275275
gitlab.com/bosi/decorder v0.4.2 // indirect
276276
go-simpler.org/musttag v0.13.0 // indirect
277277
go-simpler.org/sloglint v0.9.0 // indirect
278+
go.jetify.com/typeid v1.3.1-0.20250708200829-05dce5112f3d // indirect
278279
go.uber.org/atomic v1.7.0 // indirect
279280
go.uber.org/automaxprocs v1.6.0 // indirect
280281
go.uber.org/multierr v1.6.0 // indirect

go.sum

Lines changed: 16 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/devbox/providers/identity/identity.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package identity
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"os"
78
"path"
89
"strings"
@@ -15,7 +16,7 @@ import (
1516
"go.jetify.com/pkg/auth"
1617
"go.jetify.com/pkg/auth/session"
1718
"go.jetify.com/pkg/ids"
18-
"go.jetify.com/typeid"
19+
"go.jetify.com/typeid/v2"
1920
"golang.org/x/oauth2"
2021
)
2122

@@ -33,6 +34,19 @@ var scopes = []string{"openid", "offline_access", "email", "profile"}
3334

3435
var cachedAccessTokenFromAPIToken *session.Token
3536

37+
// parseAPIToken parses an API token string following the same pattern as other Parse functions
38+
func parseAPIToken(s string) (ids.APIToken, error) {
39+
var zero ids.APIToken
40+
tid, err := typeid.Parse(s)
41+
if err != nil {
42+
return zero, err
43+
}
44+
if tid.Prefix() != ids.APITokenPrefix {
45+
return zero, fmt.Errorf("invalid api_token ID: %s", s)
46+
}
47+
return ids.APIToken{TypeID: tid}, nil
48+
}
49+
3650
func GenSession(ctx context.Context) (*session.Token, error) {
3751
if t, err := getAccessTokenFromAPIToken(ctx); err != nil || t != nil {
3852
return t, err
@@ -91,7 +105,7 @@ func getAccessTokenFromAPIToken(
91105
return nil, nil
92106
}
93107

94-
apiToken, err := typeid.Parse[ids.APIToken](apiTokenRaw)
108+
apiToken, err := parseAPIToken(apiTokenRaw)
95109
if err != nil {
96110
return nil, err
97111
}

0 commit comments

Comments
 (0)