Skip to content

Commit 3a5df18

Browse files
Merge pull request #14 from afterpay/maintenance/update-from-upstream-4.5.1
Maintenance: update from upstream 4.5.1
2 parents 71d7879 + c8077b6 commit 3a5df18

File tree

15 files changed

+315
-127
lines changed

15 files changed

+315
-127
lines changed

afterpay/src/main/kotlin/com/afterpay/android/cashapp/AfterpayCashAppJwt.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.afterpay.android.cashapp
22

33
import android.util.Base64
44
import kotlinx.serialization.Serializable
5-
import kotlinx.serialization.decodeFromString
65
import kotlinx.serialization.json.Json
76

87
@Serializable
@@ -39,7 +38,8 @@ data class AfterpayCashAppJwt(
3938
val split = jwt.split(".").toTypedArray()
4039
val jwtBody = getJson(split[1])
4140

42-
Json.decodeFromString(jwtBody)
41+
val json = Json { ignoreUnknownKeys = true }
42+
json.decodeFromString(jwtBody)
4343
}
4444
}
4545

afterpay/src/main/kotlin/com/afterpay/android/internal/ApiV3.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.afterpay.android.internal
22

33
import com.afterpay.android.BuildConfig
44
import kotlinx.serialization.Serializable
5-
import kotlinx.serialization.decodeFromString
65
import kotlinx.serialization.encodeToString
76
import kotlinx.serialization.json.Json
87
import java.io.InvalidObjectException
@@ -12,12 +11,13 @@ import javax.net.ssl.HttpsURLConnection
1211
import kotlin.Exception
1312

1413
internal object ApiV3 {
14+
private val json = Json { ignoreUnknownKeys = true }
1515

1616
internal inline fun <reified T, reified B> request(url: URL, method: HttpVerb, body: B): Result<T> {
1717
val connection = url.openConnection() as HttpsURLConnection
1818
return try {
1919
configure(connection, method)
20-
val payload = (body as? String) ?: Json.encodeToString(body)
20+
val payload = (body as? String) ?: json.encodeToString(body)
2121

2222
val outputStreamWriter = OutputStreamWriter(connection.outputStream)
2323
outputStreamWriter.write(payload)
@@ -26,13 +26,13 @@ internal object ApiV3 {
2626
// TODO: Status code checking, error object decoding, bypass if return type is Unit
2727
val data = connection.inputStream.bufferedReader().readText()
2828
connection.inputStream.close()
29-
val result = Json.decodeFromString<T>(data)
29+
val result = json.decodeFromString<T>(data)
3030
Result.success(result)
3131
} catch (exception: Exception) {
3232
try {
3333
val data = connection.errorStream.bufferedReader().readText()
3434
connection.errorStream.close()
35-
val result = Json.decodeFromString<ApiErrorV3>(data)
35+
val result = json.decodeFromString<ApiErrorV3>(data)
3636
Result.failure(InvalidObjectException(result.message))
3737
} catch (_: Exception) {
3838
Result.failure(exception)
@@ -46,7 +46,7 @@ internal object ApiV3 {
4646
val connection = url.openConnection() as HttpsURLConnection
4747
return try {
4848
configure(connection, method)
49-
val payload = (body as? String) ?: Json.encodeToString(body)
49+
val payload = (body as? String) ?: json.encodeToString(body)
5050

5151
val outputStreamWriter = OutputStreamWriter(connection.outputStream)
5252
outputStreamWriter.write(payload)
@@ -61,7 +61,7 @@ internal object ApiV3 {
6161
try {
6262
val data = connection.errorStream.bufferedReader().readText()
6363
connection.errorStream.close()
64-
val result = Json.decodeFromString<ApiErrorV3>(data)
64+
val result = json.decodeFromString<ApiErrorV3>(data)
6565
Result.failure(InvalidObjectException(result.message))
6666
} catch (_: Exception) {
6767
Result.failure(exception)
@@ -78,13 +78,13 @@ internal object ApiV3 {
7878

7979
val data = connection.inputStream.bufferedReader().readText()
8080
connection.inputStream.close()
81-
val result = Json.decodeFromString<T>(data)
81+
val result = json.decodeFromString<T>(data)
8282
Result.success(result)
8383
} catch (exception: Exception) {
8484
try {
8585
val data = connection.errorStream.bufferedReader().readText()
8686
connection.errorStream.close()
87-
val result = Json.decodeFromString<ApiErrorV3>(data)
87+
val result = json.decodeFromString<ApiErrorV3>(data)
8888
Result.failure(InvalidObjectException(result.message))
8989
} catch (_: Exception) {
9090
Result.failure(exception)

afterpay/src/main/kotlin/com/afterpay/android/internal/Intent.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.afterpay.android.AfterpayCheckoutV3Options
66
import com.afterpay.android.CancellationStatus
77
import com.afterpay.android.CancellationStatusV3
88
import com.afterpay.android.model.CheckoutV3Data
9-
import kotlinx.serialization.decodeFromString
109
import kotlinx.serialization.encodeToString
1110
import kotlinx.serialization.json.Json
1211
import java.lang.Exception
@@ -59,8 +58,9 @@ internal fun Intent.putResultDataV3(resultData: CheckoutV3Data): Intent {
5958
}
6059

6160
internal fun Intent.getResultDataExtra(): CheckoutV3Data? {
62-
val json = getStringExtra(AfterpayIntent.RESULT_DATA_V3) ?: return null
63-
return Json.decodeFromString(json)
61+
val data = getStringExtra(AfterpayIntent.RESULT_DATA_V3) ?: return null
62+
val json = Json { ignoreUnknownKeys = true }
63+
return json.decodeFromString(data)
6464
}
6565

6666
internal fun Intent.putCancellationStatusExtra(status: CancellationStatus): Intent =

afterpay/src/test/kotlin/com/afterpay/android/AfterpayCashAppJwtTest.kt

-26
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,6 @@ class AfterpayCashAppJwtTest {
2323
*/
2424
private val validJwtValidPayload = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjRjYmMwNzY4NGQxYzRlZmIzMGY2YjA1M2VhZjM1Zjc1In0.eyJhbW91bnQiOnsiYW1vdW50IjoiODAuOCIsImN1cnJlbmN5IjoiVVNEIiwic3ltYm9sIjoiJCJ9LCJ0b2tlbiI6IjEyMyIsImV4dGVybmFsTWVyY2hhbnRJZCI6Im1lcmNoYW50X2FiYzEyMyIsInJlZGlyZWN0VXJsIjoiaHR0cHM6Ly9leGFtcGxlLmNvbSJ9.OJo_w8zisdC5572lxfAP2TYf434G_MH9KqpO0nInTabhTvJXIrtfWJsW2Ic4YupN0BfiRKUMdxAAD9f3jtszHQ"
2525

26-
/**
27-
* JWT was created with the following payload
28-
*
29-
* {
30-
* "amount": {
31-
* "amount": "80.8",
32-
* "currency": "USD",
33-
* "symbol": "$"
34-
* },
35-
* "token": "123",
36-
* "externalMerchantId": "merchant_abc123",
37-
* "redirectUrl": "https://example.com",
38-
* "randomKey": "122312dalfdj"
39-
* }
40-
*/
41-
private val validJwtUnknownKeys = "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiIsImtpZCI6IjRjYmMwNzY4NGQxYzRlZmIzMGY2YjA1M2VhZjM1Zjc1In0.eyJhbW91bnQiOnsiYW1vdW50IjoiODAuOCIsImN1cnJlbmN5IjoiVVNEIiwic3ltYm9sIjoiJCJ9LCJ0b2tlbiI6IjEyMyIsImV4dGVybmFsTWVyY2hhbnRJZCI6Im1lcmNoYW50X2FiYzEyMyIsInJlZGlyZWN0VXJsIjoiaHR0cHM6Ly9leGFtcGxlLmNvbSIsInJhbmRvbUtleSI6IjEyMjMxMmRhbGZkaiJ9.XAr-rWeFDgDy7DgeZKdynU_NkCijTKpLcgnz3p-cgmmFW8QCDkHqGgViosA3DYsMLPY3aj-ngpxfkQS83pHLoQ"
42-
4326
/**
4427
* JWT was created randomly
4528
*/
@@ -63,15 +46,6 @@ class AfterpayCashAppJwtTest {
6346
assertEquals("https://example.com", jwt.redirectUrl)
6447
}
6548

66-
@Test
67-
fun `Should decode valid jwt but fail to serialize to AfterpayCashAppJwt with unknown keys`() {
68-
val jwtResult = AfterpayCashAppJwt.decode(validJwtUnknownKeys)
69-
val jwt = jwtResult.exceptionOrNull()!!
70-
71-
assertEquals(true, jwtResult.isFailure)
72-
assertThat(jwt.message, containsString("Encountered an unknown key 'randomKey' at path"))
73-
}
74-
7549
@Test
7650
fun `Should fail to decode randomly generated invalid JWT`() {
7751
val jwtResult = AfterpayCashAppJwt.decode(invalidJwtRandomGenerated)

docs/Gemfile.lock

+61-52
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,56 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (7.0.5)
4+
activesupport (7.1.3.3)
5+
base64
6+
bigdecimal
57
concurrent-ruby (~> 1.0, >= 1.0.2)
8+
connection_pool (>= 2.2.5)
9+
drb
610
i18n (>= 1.6, < 2)
711
minitest (>= 5.1)
12+
mutex_m
813
tzinfo (~> 2.0)
9-
addressable (2.8.4)
14+
addressable (2.8.6)
1015
public_suffix (>= 2.0.2, < 6.0)
16+
base64 (0.2.0)
17+
bigdecimal (3.1.8)
1118
coffee-script (2.4.1)
1219
coffee-script-source
1320
execjs
14-
coffee-script-source (1.11.1)
21+
coffee-script-source (1.12.2)
1522
colorator (1.1.0)
16-
commonmarker (0.23.9)
17-
concurrent-ruby (1.2.2)
18-
dnsruby (1.70.0)
23+
commonmarker (0.23.10)
24+
concurrent-ruby (1.2.3)
25+
connection_pool (2.4.1)
26+
dnsruby (1.72.1)
1927
simpleidn (~> 0.2.1)
28+
drb (2.2.1)
2029
em-websocket (0.5.3)
2130
eventmachine (>= 0.12.9)
2231
http_parser.rb (~> 0)
2332
ethon (0.16.0)
2433
ffi (>= 1.15.0)
2534
eventmachine (1.2.7)
26-
execjs (2.8.1)
27-
faraday (2.7.6)
35+
execjs (2.9.1)
36+
faraday (2.8.1)
37+
base64
2838
faraday-net_http (>= 2.0, < 3.1)
2939
ruby2_keywords (>= 0.0.4)
3040
faraday-net_http (3.0.2)
31-
ffi (1.15.5)
41+
ffi (1.16.3)
3242
forwardable-extended (2.6.0)
33-
gemoji (3.0.1)
34-
github-pages (228)
35-
github-pages-health-check (= 1.17.9)
36-
jekyll (= 3.9.3)
37-
jekyll-avatar (= 0.7.0)
38-
jekyll-coffeescript (= 1.1.1)
43+
gemoji (4.1.0)
44+
github-pages (231)
45+
github-pages-health-check (= 1.18.2)
46+
jekyll (= 3.9.5)
47+
jekyll-avatar (= 0.8.0)
48+
jekyll-coffeescript (= 1.2.2)
3949
jekyll-commonmark-ghpages (= 0.4.0)
40-
jekyll-default-layout (= 0.1.4)
41-
jekyll-feed (= 0.15.1)
50+
jekyll-default-layout (= 0.1.5)
51+
jekyll-feed (= 0.17.0)
4252
jekyll-gist (= 1.5.0)
43-
jekyll-github-metadata (= 2.13.0)
53+
jekyll-github-metadata (= 2.16.1)
4454
jekyll-include-cache (= 0.2.1)
4555
jekyll-mentions (= 1.6.0)
4656
jekyll-optional-front-matter (= 0.3.2)
@@ -67,28 +77,28 @@ GEM
6777
jekyll-theme-tactile (= 0.2.0)
6878
jekyll-theme-time-machine (= 0.2.0)
6979
jekyll-titles-from-headings (= 0.5.3)
70-
jemoji (= 0.12.0)
71-
kramdown (= 2.3.2)
80+
jemoji (= 0.13.0)
81+
kramdown (= 2.4.0)
7282
kramdown-parser-gfm (= 1.1.0)
7383
liquid (= 4.0.4)
7484
mercenary (~> 0.3)
7585
minima (= 2.5.1)
7686
nokogiri (>= 1.13.6, < 2.0)
77-
rouge (= 3.26.0)
87+
rouge (= 3.30.0)
7888
terminal-table (~> 1.4)
79-
github-pages-health-check (1.17.9)
89+
github-pages-health-check (1.18.2)
8090
addressable (~> 2.3)
8191
dnsruby (~> 1.60)
82-
octokit (~> 4.0)
83-
public_suffix (>= 3.0, < 5.0)
92+
octokit (>= 4, < 8)
93+
public_suffix (>= 3.0, < 6.0)
8494
typhoeus (~> 1.3)
8595
html-pipeline (2.14.3)
8696
activesupport (>= 2)
8797
nokogiri (>= 1.4)
8898
http_parser.rb (0.8.0)
89-
i18n (1.14.1)
99+
i18n (1.14.5)
90100
concurrent-ruby (~> 1.0)
91-
jekyll (3.9.3)
101+
jekyll (3.9.5)
92102
addressable (~> 2.4)
93103
colorator (~> 1.0)
94104
em-websocket (~> 0.5)
@@ -101,27 +111,27 @@ GEM
101111
pathutil (~> 0.9)
102112
rouge (>= 1.7, < 4)
103113
safe_yaml (~> 1.0)
104-
jekyll-avatar (0.7.0)
114+
jekyll-avatar (0.8.0)
105115
jekyll (>= 3.0, < 5.0)
106-
jekyll-coffeescript (1.1.1)
116+
jekyll-coffeescript (1.2.2)
107117
coffee-script (~> 2.2)
108-
coffee-script-source (~> 1.11.1)
118+
coffee-script-source (~> 1.12)
109119
jekyll-commonmark (1.4.0)
110120
commonmarker (~> 0.22)
111121
jekyll-commonmark-ghpages (0.4.0)
112122
commonmarker (~> 0.23.7)
113123
jekyll (~> 3.9.0)
114124
jekyll-commonmark (~> 1.4.0)
115125
rouge (>= 2.0, < 5.0)
116-
jekyll-default-layout (0.1.4)
117-
jekyll (~> 3.0)
118-
jekyll-feed (0.15.1)
126+
jekyll-default-layout (0.1.5)
127+
jekyll (>= 3.0, < 5.0)
128+
jekyll-feed (0.17.0)
119129
jekyll (>= 3.7, < 5.0)
120130
jekyll-gist (1.5.0)
121131
octokit (~> 4.2)
122-
jekyll-github-metadata (2.13.0)
132+
jekyll-github-metadata (2.16.1)
123133
jekyll (>= 3.4, < 5.0)
124-
octokit (~> 4.0, != 4.4.0)
134+
octokit (>= 4, < 7, != 4.4.0)
125135
jekyll-include-cache (0.2.1)
126136
jekyll (>= 3.7, < 5.0)
127137
jekyll-mentions (1.6.0)
@@ -192,40 +202,42 @@ GEM
192202
jekyll (>= 3.3, < 5.0)
193203
jekyll-watch (2.2.1)
194204
listen (~> 3.0)
195-
jemoji (0.12.0)
196-
gemoji (~> 3.0)
205+
jemoji (0.13.0)
206+
gemoji (>= 3, < 5)
197207
html-pipeline (~> 2.2)
198208
jekyll (>= 3.0, < 5.0)
199-
kramdown (2.3.2)
209+
kramdown (2.4.0)
200210
rexml
201211
kramdown-parser-gfm (1.1.0)
202212
kramdown (~> 2.0)
203213
liquid (4.0.4)
204-
listen (3.8.0)
214+
listen (3.9.0)
205215
rb-fsevent (~> 0.10, >= 0.10.3)
206216
rb-inotify (~> 0.9, >= 0.9.10)
207217
mercenary (0.3.6)
208-
mini_portile2 (2.8.2)
218+
mini_portile2 (2.8.6)
209219
minima (2.5.1)
210220
jekyll (>= 3.5, < 5.0)
211221
jekyll-feed (~> 0.9)
212222
jekyll-seo-tag (~> 2.1)
213-
minitest (5.18.0)
214-
nokogiri (1.15.2)
223+
minitest (5.23.1)
224+
mutex_m (0.2.0)
225+
nokogiri (1.15.6)
215226
mini_portile2 (~> 2.8.2)
216227
racc (~> 1.4)
217228
octokit (4.25.1)
218229
faraday (>= 1, < 3)
219230
sawyer (~> 0.9)
220231
pathutil (0.16.2)
221232
forwardable-extended (~> 2.6)
222-
public_suffix (4.0.7)
223-
racc (1.7.0)
233+
public_suffix (5.0.5)
234+
racc (1.8.0)
224235
rb-fsevent (0.11.2)
225-
rb-inotify (0.10.1)
236+
rb-inotify (0.11.1)
226237
ffi (~> 1.0)
227-
rexml (3.2.5)
228-
rouge (3.26.0)
238+
rexml (3.2.8)
239+
strscan (>= 3.0.9)
240+
rouge (3.30.0)
229241
ruby2_keywords (0.0.5)
230242
rubyzip (2.3.2)
231243
safe_yaml (1.0.5)
@@ -237,17 +249,14 @@ GEM
237249
sawyer (0.9.2)
238250
addressable (>= 2.3.5)
239251
faraday (>= 0.17.3, < 3)
240-
simpleidn (0.2.1)
241-
unf (~> 0.1.4)
252+
simpleidn (0.2.3)
253+
strscan (3.1.0)
242254
terminal-table (1.8.0)
243255
unicode-display_width (~> 1.1, >= 1.1.1)
244-
typhoeus (1.4.0)
256+
typhoeus (1.4.1)
245257
ethon (>= 0.9.0)
246258
tzinfo (2.0.6)
247259
concurrent-ruby (~> 1.0)
248-
unf (0.1.4)
249-
unf_ext
250-
unf_ext (0.0.8.2)
251260
unicode-display_width (1.8.0)
252261

253262
PLATFORMS

docs/_config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ callouts:
2626
info:
2727
title: Info
2828
color: blue
29+
30+
mermaid:
31+
version: "10.9.1"

docs/_includes/mermaid_config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
theme: "base",
3+
'themeVariables': {
4+
'primaryColor': '#b2fce4',
5+
'primaryBorderColor': '#dfdfdf',
6+
'lineColor': '#F8B229',
7+
'secondaryColor': '#006100',
8+
'tertiaryColor': '#fff',
9+
'fontFamily': 'system-ui, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, sans-serif, "Segoe UI Emoji"'
10+
}
11+
}

docs/_sass/color_schemes/afterpay.scss

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ $feedback-color: rgb(223, 234, 246);
55
$sidebar-color: $white;
66
$nav-width: 18.75rem;
77
$nav-width-md: 18.75rem;
8+
$content-width: 60rem;

0 commit comments

Comments
 (0)