Skip to content

Commit c6141d7

Browse files
authored
Merge pull request #308 from Vovcharaa/master
Update `golang-jwt/jwt` to v5
2 parents 453944c + aff14ad commit c6141d7

12 files changed

+176
-115
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func main() {
191191
```go
192192
import (
193193
"github.com/awa/go-iap/appstore"
194-
"github.com/golang-jwt/jwt/v4"
194+
"github.com/golang-jwt/jwt/v5"
195195
)
196196

197197
func main() {

appstore/api/model.go

+70-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package api
22

3-
import "github.com/awa/go-iap/appstore"
3+
import (
4+
"github.com/awa/go-iap/appstore"
5+
"github.com/golang-jwt/jwt/v5"
6+
)
47

58
// OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
69
type OrderLookupResponse struct {
@@ -83,6 +86,9 @@ type ConsumptionRequestBody struct {
8386
RefundPreference int32 `json:"refundPreference"`
8487
}
8588

89+
// Verify that JWSRenewalInfoDecodedPayload implements jwt.Claims
90+
var _ jwt.Claims = JWSRenewalInfoDecodedPayload{}
91+
8692
// JWSRenewalInfoDecodedPayload https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload
8793
type JWSRenewalInfoDecodedPayload struct {
8894
AutoRenewProductId string `json:"autoRenewProductId"`
@@ -105,8 +111,34 @@ type JWSRenewalInfoDecodedPayload struct {
105111
EligibleWinBackOfferIds []string `json:"eligibleWinBackOfferIds,omitempty"`
106112
}
107113

108-
func (J JWSRenewalInfoDecodedPayload) Valid() error {
109-
return nil
114+
// GetAudience implements jwt.Claims.
115+
func (J JWSRenewalInfoDecodedPayload) GetAudience() (jwt.ClaimStrings, error) {
116+
return nil, nil
117+
}
118+
119+
// GetExpirationTime implements jwt.Claims.
120+
func (J JWSRenewalInfoDecodedPayload) GetExpirationTime() (*jwt.NumericDate, error) {
121+
return nil, nil
122+
}
123+
124+
// GetIssuedAt implements jwt.Claims.
125+
func (J JWSRenewalInfoDecodedPayload) GetIssuedAt() (*jwt.NumericDate, error) {
126+
return nil, nil
127+
}
128+
129+
// GetIssuer implements jwt.Claims.
130+
func (J JWSRenewalInfoDecodedPayload) GetIssuer() (string, error) {
131+
return "", nil
132+
}
133+
134+
// GetNotBefore implements jwt.Claims.
135+
func (J JWSRenewalInfoDecodedPayload) GetNotBefore() (*jwt.NumericDate, error) {
136+
return nil, nil
137+
}
138+
139+
// GetSubject implements jwt.Claims.
140+
func (J JWSRenewalInfoDecodedPayload) GetSubject() (string, error) {
141+
return "", nil
110142
}
111143

112144
// JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
@@ -143,6 +175,9 @@ const (
143175
OfferDiscountTypePayUpFront OfferDiscountType = "PAY_UP_FRONT"
144176
)
145177

178+
// Verify that JWSTransaction implements jwt.Claims
179+
var _ jwt.Claims = JWSTransaction{}
180+
146181
// JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
147182
type JWSTransaction struct {
148183
TransactionID string `json:"transactionId,omitempty"`
@@ -173,8 +208,34 @@ type JWSTransaction struct {
173208
OfferDiscountType OfferDiscountType `json:"offerDiscountType,omitempty"`
174209
}
175210

176-
func (J JWSTransaction) Valid() error {
177-
return nil
211+
// GetAudience implements jwt.Claims.
212+
func (J JWSTransaction) GetAudience() (jwt.ClaimStrings, error) {
213+
return nil, nil
214+
}
215+
216+
// GetExpirationTime implements jwt.Claims.
217+
func (J JWSTransaction) GetExpirationTime() (*jwt.NumericDate, error) {
218+
return nil, nil
219+
}
220+
221+
// GetIssuedAt implements jwt.Claims.
222+
func (J JWSTransaction) GetIssuedAt() (*jwt.NumericDate, error) {
223+
return nil, nil
224+
}
225+
226+
// GetIssuer implements jwt.Claims.
227+
func (J JWSTransaction) GetIssuer() (string, error) {
228+
return "", nil
229+
}
230+
231+
// GetNotBefore implements jwt.Claims.
232+
func (J JWSTransaction) GetNotBefore() (*jwt.NumericDate, error) {
233+
return nil, nil
234+
}
235+
236+
// GetSubject implements jwt.Claims.
237+
func (J JWSTransaction) GetSubject() (string, error) {
238+
return "", nil
178239
}
179240

180241
// https://developer.apple.com/documentation/appstoreserverapi/extendreasoncode
@@ -258,8 +319,10 @@ type SendTestNotificationResponse struct {
258319
TestNotificationToken string `json:"testNotificationToken"`
259320
}
260321

261-
type AutoRenewSubscriptionStatus int32
262-
type AutoRenewStatus int32
322+
type (
323+
AutoRenewSubscriptionStatus int32
324+
AutoRenewStatus int32
325+
)
263326

264327
const (
265328
SubscriptionActive AutoRenewSubscriptionStatus = 1

appstore/api/store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"strings"
1717
"time"
1818

19-
"github.com/golang-jwt/jwt/v4"
19+
"github.com/golang-jwt/jwt/v5"
2020
)
2121

2222
const (

appstore/api/token.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import (
55
"crypto/x509"
66
"encoding/pem"
77
"errors"
8-
"os"
98
"sync"
109
"time"
1110

12-
"github.com/golang-jwt/jwt/v4"
11+
"github.com/golang-jwt/jwt/v5"
1312
"github.com/google/uuid"
1413
)
1514

@@ -113,16 +112,6 @@ func (t *Token) Generate() error {
113112
return nil
114113
}
115114

116-
// loadKeyFromFile loads a .p8 certificate from a local file and returns a *ecdsa.PrivateKey.
117-
func (t *Token) loadKeyFromFile(filename string) (*ecdsa.PrivateKey, error) {
118-
bytes, err := os.ReadFile(filename)
119-
if err != nil {
120-
return nil, err
121-
}
122-
123-
return t.passKeyFromByte(bytes)
124-
}
125-
126115
// passKeyFromByte loads a .p8 certificate from an in memory byte array and returns an *ecdsa.PrivateKey.
127116
func (t *Token) passKeyFromByte(bytes []byte) (*ecdsa.PrivateKey, error) {
128117
block, _ := pem.Decode(bytes)

appstore/mocks/appstore.go

+19-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)