Skip to content

Commit 1bc0776

Browse files
fix: Verifiable PayID JWS Consumable (PayString#661)
* fixes * test: update tests to use strinfied json * drop unused type Co-authored-by: Hans Bergren <[email protected]>
1 parent e737428 commit 1bc0776

9 files changed

Lines changed: 69 additions & 81 deletions

File tree

‎package-lock.json‎

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

‎src/db/seed/seeded_values_for_testing.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ INSERT INTO account(id, pay_id) VALUES
1313
/* Verified accounts*/
1414
INSERT INTO account(id, pay_id, identity_key) VALUES
1515
('27944333-faf6-41e8-90c3-1ec9001f0830', 'emptyverified$127.0.0.1', ''),
16+
('9a75f884-ab16-40c4-a82a-aca454dad6b2', 'verifiabledemo$127.0.0.1', 'eyJuYW1lIjoiaWRlbnRpdHlLZXkiLCJhbGciOiJFUzI1NksiLCJ0eXAiOiJKT1NFK0pTT04iLCJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCIsIm5hbWUiXSwiandrIjp7ImNydiI6InNlY3AyNTZrMSIsIngiOiI2S0dtcEF6WUhWUm9qVmU5UEpfWTVyZHltQ21kTy1xaVRHem1Edl9waUlvIiwieSI6ImhxS3Vnc1g3Vjk3eFRNLThCMTBONUQxcW44MUZWMjItM1p0TURXaXZfSnciLCJrdHkiOiJFQyIsImtpZCI6Im4zNlhTc0M1TjRnNUtCVzRBWXJ5d1ZtRE1kUWNEV1BJX0RfNUR1UlNhNDAifX0'),
1617
('2955cce9-c350-4b60-9726-c415072961ed', 'verified$127.0.0.1', 'bGV0IG1lIHNlZSB0aGVtIGNvcmdpcyBOT1cgb3IgcGF5IHRoZSBwcmljZQ=='),
1718
('67d9ad5f-5cd8-4a0c-b642-70e63354e647', 'postmalone$127.0.0.1', 'aGkgbXkgbmFtZSBpcyBhdXN0aW4gYW5kIEkgYW0gdGVzdGluZyB0aGluZ3M='),
1819
('35192b90-9b88-4137-85c9-3d1d3d92cf2c', 'johnwick$127.0.0.1', 'aGV0IG1lIHNlZSB0aGVtIGNvcmdpcyBOT1cgb3IgcGF5IHRoZSBwcmljZQ==');
@@ -30,6 +31,7 @@ INSERT INTO address(account_id, payment_network, environment, details) VALUES
3031

3132
/* Verified addresses*/
3233
INSERT INTO address(account_id, payment_network, environment, details, identity_key_signature) VALUES
34+
('9a75f884-ab16-40c4-a82a-aca454dad6b2', 'XRPL', 'TESTNET', '{"address": "rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS"}', 'rsoKeVLzwg2PpGRK0S10fpmh5WNtttF9dyJgSv3USEr4aN3bUBzp5ImRQo8wlh3E00GtZ2cse-lhoQ4zJKj0Jw'),
3335
('67d9ad5f-5cd8-4a0c-b642-70e63354e647', 'BTC', 'TESTNET', '{"address": "2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE"}', 'TG9vayBhdCBtZSEgd29vIEknbSB0ZXN0aW5nIHRoaW5ncyBhbmQgdGhpcyBpcyBhIHNpZ25hdHVyZQ=='),
3436
('35192b90-9b88-4137-85c9-3d1d3d92cf2c', 'BTC', 'TESTNET', '{"address": "2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE"}', 'TG9vayBhdCBtZSEgd29vIEknbSB0ZXN0aW5nIHRoaW5ncyBhbmQgdGhpcyBpcyBhIHNpZ25hdHVyZQ=='),
3537
('35192b90-9b88-4137-85c9-3d1d3d92cf2c', 'XRPL', 'TESTNET', '{"address": "rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS"}', 'TG9vayBhdCBtZSEgd29vIEknbSB0ZXN0aW5nIHRoaW5ncyBhbmQgdGhpcyBpcyBhIHNpZ25hdHVyZQ=='),

‎src/services/basePayId.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function formatPaymentInfo(
4343
signature: address.identityKeySignature ?? '',
4444
},
4545
],
46-
payload: {
46+
payload: JSON.stringify({
4747
payId,
4848
// Call the address a "payIdAddress" so we don't step on the JWT "address"
4949
// field if we ever change our minds
@@ -53,7 +53,7 @@ export function formatPaymentInfo(
5353
addressDetailsType: getAddressDetailsType(address, version),
5454
addressDetails: address.details,
5555
},
56-
},
56+
}),
5757
}
5858
}),
5959
payId,

‎src/types/protocol.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,10 @@ export interface Address {
4949
* Object containing address information alongside signatures.
5050
*/
5151
interface VerifiedAddress {
52-
readonly payload: VerifiedAddressPayload
52+
readonly payload: string
5353
readonly signatures: readonly VerifiedAddressSignature[]
5454
}
5555

56-
interface VerifiedAddressPayload {
57-
payId: string
58-
payIdAddress: Address
59-
}
60-
6156
/**
6257
* JWS object for verification.
6358
*/

‎test/integration/data-access/reports.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ describe('Data Access - getPayIdCounts()', function (): void {
4343
{
4444
paymentNetwork: 'XRPL',
4545
environment: 'TESTNET',
46-
count: 5,
46+
count: 6,
4747
},
4848
]
4949
assert.deepEqual(results, expected)
5050
})
5151

5252
it('getPayIdCount - Returns a count of PayIDs', async function () {
5353
const payIdCount = await getPayIdCount()
54-
const expectedPayIdCount = 10
54+
const expectedPayIdCount = 11
5555

5656
assert.strictEqual(payIdCount, expectedPayIdCount)
5757
})

‎test/integration/e2e/admin-api/metrics.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ describe('E2E - adminApiRouter - GET /metrics', function (): void {
9999
await metrics.generatePayIdCountMetrics()
100100

101101
// We create 8 PayIDs in the tests before this one,
102-
// and start with 10 seeded PayIDs, for a total of 18.
103-
await assertMetrics(/actual_payid_count\{org="127.0.0.1"\} 18/u)
102+
// and start with 11 seeded PayIDs, for a total of 19.
103+
await assertMetrics(/actual_payid_count\{org="127.0.0.1"\} 19/u)
104104
})
105105

106106
it('Includes server version info', async function () {

‎test/integration/e2e/public-api/verifiablePayId.test.ts‎

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
2828
payId: 'johnwick$127.0.0.1',
2929
verifiedAddresses: [
3030
{
31-
payload: {
31+
payload: JSON.stringify({
3232
payId: 'johnwick$127.0.0.1',
3333
payIdAddress: {
34+
paymentNetwork: 'XRPL',
35+
environment: 'MAINNET',
36+
addressDetailsType: AddressDetailsType.CryptoAddress,
3437
addressDetails: {
3538
address: 'rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS',
3639
},
37-
addressDetailsType: AddressDetailsType.CryptoAddress,
38-
environment: 'MAINNET',
39-
paymentNetwork: 'XRPL',
4040
},
41-
},
41+
}),
4242
signatures: [
4343
{
4444
name: 'identityKey',
@@ -74,17 +74,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
7474
payId: 'johnwick$127.0.0.1',
7575
verifiedAddresses: [
7676
{
77-
payload: {
77+
payload: JSON.stringify({
7878
payId: 'johnwick$127.0.0.1',
7979
payIdAddress: {
80+
paymentNetwork: 'XRPL',
81+
environment: 'TESTNET',
82+
addressDetailsType: AddressDetailsType.CryptoAddress,
8083
addressDetails: {
8184
address: 'rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS',
8285
},
83-
addressDetailsType: AddressDetailsType.CryptoAddress,
84-
environment: 'TESTNET',
85-
paymentNetwork: 'XRPL',
8686
},
87-
},
87+
}),
8888
signatures: [
8989
{
9090
name: 'identityKey',
@@ -120,17 +120,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
120120
payId: 'johnwick$127.0.0.1',
121121
verifiedAddresses: [
122122
{
123-
payload: {
123+
payload: JSON.stringify({
124124
payId: 'johnwick$127.0.0.1',
125125
payIdAddress: {
126+
paymentNetwork: 'BTC',
127+
environment: 'TESTNET',
128+
addressDetailsType: AddressDetailsType.CryptoAddress,
126129
addressDetails: {
127130
address: '2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE',
128131
},
129-
addressDetailsType: AddressDetailsType.CryptoAddress,
130-
environment: 'TESTNET',
131-
paymentNetwork: 'BTC',
132132
},
133-
},
133+
}),
134134
signatures: [
135135
{
136136
name: 'identityKey',
@@ -166,17 +166,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
166166
payId: 'johnwick$127.0.0.1',
167167
verifiedAddresses: [
168168
{
169-
payload: {
169+
payload: JSON.stringify({
170170
payId: 'johnwick$127.0.0.1',
171171
payIdAddress: {
172+
paymentNetwork: 'ACH',
173+
addressDetailsType: AddressDetailsType.FiatAddress,
172174
addressDetails: {
173175
accountNumber: '000123456789',
174176
routingNumber: '123456789',
175177
},
176-
addressDetailsType: AddressDetailsType.FiatAddress,
177-
paymentNetwork: 'ACH',
178178
},
179-
},
179+
}),
180180
signatures: [
181181
{
182182
name: 'identityKey',
@@ -221,17 +221,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
221221
payId: 'johnwick$127.0.0.1',
222222
verifiedAddresses: [
223223
{
224-
payload: {
224+
payload: JSON.stringify({
225225
payId: 'johnwick$127.0.0.1',
226226
payIdAddress: {
227+
paymentNetwork: 'BTC',
228+
environment: 'TESTNET',
229+
addressDetailsType: AddressDetailsType.CryptoAddress,
227230
addressDetails: {
228231
address: '2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE',
229232
},
230-
addressDetailsType: AddressDetailsType.CryptoAddress,
231-
environment: 'TESTNET',
232-
paymentNetwork: 'BTC',
233233
},
234-
},
234+
}),
235235
signatures: [
236236
{
237237
name: 'identityKey',
@@ -243,17 +243,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
243243
],
244244
},
245245
{
246-
payload: {
246+
payload: JSON.stringify({
247247
payId: 'johnwick$127.0.0.1',
248248
payIdAddress: {
249+
paymentNetwork: 'XRPL',
250+
environment: 'TESTNET',
251+
addressDetailsType: AddressDetailsType.CryptoAddress,
249252
addressDetails: {
250253
address: 'rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS',
251254
},
252-
addressDetailsType: AddressDetailsType.CryptoAddress,
253-
environment: 'TESTNET',
254-
paymentNetwork: 'XRPL',
255255
},
256-
},
256+
}),
257257
signatures: [
258258
{
259259
name: 'identityKey',
@@ -265,17 +265,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
265265
],
266266
},
267267
{
268-
payload: {
268+
payload: JSON.stringify({
269269
payId: 'johnwick$127.0.0.1',
270270
payIdAddress: {
271+
paymentNetwork: 'XRPL',
272+
environment: 'MAINNET',
273+
addressDetailsType: AddressDetailsType.CryptoAddress,
271274
addressDetails: {
272275
address: 'rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS',
273276
},
274-
addressDetailsType: AddressDetailsType.CryptoAddress,
275-
environment: 'MAINNET',
276-
paymentNetwork: 'XRPL',
277277
},
278-
},
278+
}),
279279
signatures: [
280280
{
281281
name: 'identityKey',
@@ -287,17 +287,17 @@ describe('E2E - publicAPIRouter - Verifiable PayID', function (): void {
287287
],
288288
},
289289
{
290-
payload: {
290+
payload: JSON.stringify({
291291
payId: 'johnwick$127.0.0.1',
292292
payIdAddress: {
293+
paymentNetwork: 'ACH',
294+
addressDetailsType: AddressDetailsType.FiatAddress,
293295
addressDetails: {
294296
accountNumber: '000123456789',
295297
routingNumber: '123456789',
296298
},
297-
addressDetailsType: AddressDetailsType.FiatAddress,
298-
paymentNetwork: 'ACH',
299299
},
300-
},
300+
}),
301301
signatures: [
302302
{
303303
name: 'identityKey',

‎test/integration/e2e/public-api/verifiablePayIdContentNegotiation.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ const XRPL_EXPECTED_TESTNET_RESPONSE = {
2323
verifiedAddresses: [
2424
{
2525
signatures: [SIGNATURE],
26-
payload: {
26+
payload: JSON.stringify({
2727
payId: PAYID,
2828
payIdAddress: XRPL_TESTNET_ADDRESS,
29-
},
29+
}),
3030
},
3131
],
3232
payId: PAYID,

‎test/unit/formatPaymentInfoVerifiablePayId.test.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ describe('Verifiable PayID - formatPaymentInfo()', function (): void {
3535
addresses: [],
3636
verifiedAddresses: [
3737
{
38-
payload: {
38+
payload: JSON.stringify({
3939
payId: 'alice$example.com',
4040
payIdAddress: {
41-
addressDetailsType: AddressDetailsType.CryptoAddress,
42-
environment: 'TESTNET',
4341
paymentNetwork: 'XRP',
42+
environment: 'TESTNET',
43+
addressDetailsType: AddressDetailsType.CryptoAddress,
4444
addressDetails: {
4545
address: 'rDk7FQvkQxQQNGTtfM2Fr66s7Nm3k87vdS',
4646
},
4747
},
48-
},
48+
}),
4949
signatures: [
5050
{
5151
name: 'identityKey',
@@ -55,17 +55,17 @@ describe('Verifiable PayID - formatPaymentInfo()', function (): void {
5555
],
5656
},
5757
{
58-
payload: {
58+
payload: JSON.stringify({
5959
payId: 'alice$example.com',
6060
payIdAddress: {
61-
addressDetailsType: AddressDetailsType.FiatAddress,
6261
paymentNetwork: 'ACH',
62+
addressDetailsType: AddressDetailsType.FiatAddress,
6363
addressDetails: {
6464
accountNumber: '000123456789',
6565
routingNumber: '123456789',
6666
},
6767
},
68-
},
68+
}),
6969
signatures: [
7070
{
7171
name: 'identityKey',

0 commit comments

Comments
 (0)