Skip to content

Commit faa9dc7

Browse files
njlieBlairCurreydragosp1011
authored
feat: add directed identity (#3889)
* feat(token-instrospection): widen client spec to include jwk, add types (#3834) * feat(token-instrospection): widen client spec to include jwk, add types * feat: update typegen package * fix: rm unused types * fix(auth): token info type * Revert "fix(auth): token info type" This reverts commit 1b28db2. * fix: resolve asset query issue in mock ase (#3840) --------- Co-authored-by: dragosp1011 <109967337+dragosp1011@users.noreply.github.com> * feat: support jwk directed identity in auth server (#3842) * feat: add jwk support to client/grant * fix: use grant error * fix: dont cast, use better types * chore: format * chore: dont unecessarily check kid against jwk * refactor: simplify types, logic for getting client field * refactor: move logic involving jwk/client into serivice * test: logic moved into grant service * fix: tests * feat(backend): handle JWK as possible client value in auth middleware (#3838) * feat(token-instrospection): widen client spec to include jwk, add types * feat: update typegen package * fix: rm unused types * fix(auth): token info type * Revert "fix(auth): token info type" This reverts commit 1b28db2. * feat(backend): handle JWK as possible client value in auth middleware --------- Co-authored-by: Blair Currey <12960453+BlairCurrey@users.noreply.github.com> * feat(auth, backend): bump to open-payments 7.4.0, fix build errors (#3868) * feat(tests): integration tests for directed identity (#3876) * feat(tests): integration tests for directed identity * chore: formatting * feat(bruno): directed identity bruno collection (#3890) * clean up bruno collection, better error handling * fix: tests --------- Co-authored-by: Blair Currey <12960453+BlairCurrey@users.noreply.github.com> Co-authored-by: dragosp1011 <109967337+dragosp1011@users.noreply.github.com>
1 parent 994a4d7 commit faa9dc7

57 files changed

Lines changed: 4220 additions & 1998 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
meta {
2+
name: Continuation Request
3+
type: http
4+
seq: 8
5+
}
6+
7+
post {
8+
url: {{senderOpenPaymentsContinuationUri}}
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{continueToken}}
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
await scripts.addSignatureHeaders();
21+
}
22+
23+
script:post-response {
24+
const scripts = require('./scripts');
25+
26+
scripts.storeTokenDetails();
27+
}
28+
29+
tests {
30+
test("Status code is 200", function() {
31+
expect(res.getStatus()).to.equal(200);
32+
});
33+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
meta {
2+
name: Create Incoming Payment
3+
type: http
4+
seq: 4
5+
}
6+
7+
post {
8+
url: {{receiverOpenPaymentsHost}}/incoming-payments
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{accessToken}}
15+
}
16+
17+
body:json {
18+
{
19+
"walletAddress": "{{receiverWalletAddress}}",
20+
"incomingAmount": {
21+
"value": "100",
22+
"assetCode": "{{receiverAssetCode}}",
23+
"assetScale": {{receiverAssetScale}}
24+
},
25+
"expiresAt": "{{tomorrow}}",
26+
"metadata": {
27+
"description": "Free Money!"
28+
}
29+
}
30+
}
31+
32+
script:pre-request {
33+
const scripts = require('./scripts');
34+
35+
bru.setEnvVar("tomorrow", (new Date(new Date().setDate(new Date().getDate() + 1))).toISOString());
36+
37+
scripts.addHostHeader();
38+
39+
await scripts.addDirectedIdentitySignatureHeaders();
40+
}
41+
42+
script:post-response {
43+
const body = res.getBody();
44+
45+
if (body?.id) {
46+
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
47+
}
48+
49+
}
50+
51+
tests {
52+
test("Status code is 201", function() {
53+
expect(res.getStatus()).to.equal(201);
54+
});
55+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
meta {
2+
name: Create Outgoing Payment
3+
type: http
4+
seq: 9
5+
}
6+
7+
post {
8+
url: {{senderOpenPaymentsHost}}/outgoing-payments
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{accessToken}}
15+
}
16+
17+
body:json {
18+
{
19+
"walletAddress": "{{senderWalletAddress}}",
20+
"quoteId": "{{senderWalletAddress}}/quotes/{{quoteId}}",
21+
"metadata": {
22+
"description": "Free Money!"
23+
}
24+
}
25+
}
26+
27+
script:pre-request {
28+
const scripts = require('./scripts');
29+
30+
scripts.addHostHeader();
31+
32+
await scripts.addSignatureHeaders();
33+
}
34+
35+
script:post-response {
36+
const body = res.getBody();
37+
38+
if (body?.id) {
39+
bru.setEnvVar("outgoingPaymentId", body.id.split("/").pop());
40+
}
41+
42+
}
43+
44+
tests {
45+
test("Status code is 201", function() {
46+
expect(res.getStatus()).to.equal(201);
47+
});
48+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
meta {
2+
name: Create Quote
3+
type: http
4+
seq: 6
5+
}
6+
7+
post {
8+
url: {{senderOpenPaymentsHost}}/quotes
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{accessToken}}
15+
}
16+
17+
body:json {
18+
{
19+
"walletAddress": "{{senderWalletAddress}}",
20+
"receiver": "{{receiverOpenPaymentsHost}}/incoming-payments/{{incomingPaymentId}}",
21+
"method": "ilp"
22+
}
23+
}
24+
25+
script:pre-request {
26+
const scripts = require('./scripts');
27+
28+
scripts.addHostHeader();
29+
30+
await scripts.addDirectedIdentitySignatureHeaders();
31+
}
32+
33+
script:post-response {
34+
const body = res.getBody();
35+
if (body?.id) {
36+
bru.setEnvVar("quoteId", body.id.split("/").pop());
37+
bru.setEnvVar("quoteDebitAmount", JSON.stringify(body.debitAmount))
38+
bru.setEnvVar("quoteReceiveAmount", JSON.stringify(body.receiveAmount))
39+
}
40+
41+
}
42+
43+
tests {
44+
test("Status code is 201", function() {
45+
expect(res.getStatus()).to.equal(201);
46+
});
47+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
meta {
2+
name: Get Outgoing Payment
3+
type: http
4+
seq: 10
5+
}
6+
7+
get {
8+
url: {{senderOpenPaymentsHost}}/outgoing-payments/{{outgoingPaymentId}}
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: GNAP {{accessToken}}
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
scripts.addHostHeader();
21+
22+
await scripts.addSignatureHeaders();
23+
}
24+
25+
tests {
26+
test("Status code is 200", function() {
27+
expect(res.getStatus()).to.equal(200);
28+
});
29+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
meta {
2+
name: Get receiver wallet address
3+
type: http
4+
seq: 2
5+
}
6+
7+
get {
8+
url: {{receiverWalletAddress}}
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Accept: application/json
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
scripts.addHostHeader("receiverOpenPaymentsHost");
21+
}
22+
23+
script:post-response {
24+
const url = require('url')
25+
26+
if (res.getStatus() !== 200) {
27+
return
28+
}
29+
30+
const body = res.getBody()
31+
bru.setEnvVar("receiverAssetCode", body?.assetCode)
32+
bru.setEnvVar("receiverAssetScale", body?.assetScale)
33+
34+
const authUrl = url.parse(body?.authServer)
35+
if (
36+
authUrl.hostname.includes('cloud-nine-wallet') ||
37+
authUrl.hostname.includes('happy-life-bank')
38+
){
39+
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
40+
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
41+
} else {
42+
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
43+
}
44+
45+
const resourceUrl = url.parse(body?.resourceServer)
46+
if (
47+
resourceUrl.hostname.includes('cloud-nine-wallet') ||
48+
resourceUrl.hostname.includes('happy-life-bank')
49+
){
50+
const port = resourceUrl.hostname.includes('cloud-nine-wallet') ? bru.getEnvVar('cloudNineOpenPaymentsPort') : bru.getEnvVar('happyLifeOpenPaymentsPort')
51+
bru.setEnvVar("receiverOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path);
52+
} else {
53+
bru.setEnvVar("receiverOpenPaymentsHost", body?.resourceServer);
54+
}
55+
}
56+
57+
tests {
58+
test("Status code is 200", function() {
59+
expect(res.getStatus()).to.equal(200);
60+
});
61+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
meta {
2+
name: Get sender wallet address
3+
type: http
4+
seq: 1
5+
}
6+
7+
get {
8+
url: {{senderWalletAddress}}
9+
body: none
10+
auth: none
11+
}
12+
13+
headers {
14+
Accept: application/json
15+
}
16+
17+
script:pre-request {
18+
const scripts = require('./scripts');
19+
20+
scripts.addHostHeader("senderOpenPaymentsHost");
21+
}
22+
23+
script:post-response {
24+
const url = require('url')
25+
26+
if (res.getStatus() !== 200) {
27+
return
28+
}
29+
30+
const body = res.getBody()
31+
bru.setEnvVar("senderAssetCode", body?.assetCode)
32+
bru.setEnvVar("senderAssetScale", body?.assetScale)
33+
34+
const authUrl = url.parse(body?.authServer)
35+
if (
36+
authUrl.hostname.includes('cloud-nine-wallet') ||
37+
authUrl.hostname.includes('happy-life-bank')
38+
){
39+
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
40+
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
41+
} else {
42+
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
43+
}
44+
45+
const resourceUrl = url.parse(body?.resourceServer)
46+
if (resourceUrl.hostname.includes('cloud-nine-wallet') || resourceUrl.hostname.includes('happy-life-bank')) {
47+
const port = resourceUrl.hostname.includes('happy-life-bank') ? bru.getEnvVar('happyLifeOpenPaymentsPort') : bru.getEnvVar('cloudNineOpenPaymentsPort')
48+
bru.setEnvVar("senderOpenPaymentsHost", 'http://localhost:' + port + resourceUrl.path);
49+
} else {
50+
bru.setEnvVar("senderOpenPaymentsHost", body?.resourceServer);
51+
}
52+
}
53+
54+
tests {
55+
test("Status code is 200", function() {
56+
expect(res.getStatus()).to.equal(200);
57+
});
58+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
meta {
2+
name: Grant Request Incoming Payment
3+
type: http
4+
seq: 3
5+
}
6+
7+
post {
8+
url: {{receiverOpenPaymentsAuthHost}}
9+
body: json
10+
auth: none
11+
}
12+
13+
body:json {
14+
{
15+
"access_token": {
16+
"access": [
17+
{
18+
"type": "incoming-payment",
19+
"actions": [
20+
"create", "read", "list", "complete"
21+
]
22+
}
23+
]
24+
},
25+
"client": {
26+
"jwk": {{directedIdentityPublicKey}}
27+
}
28+
}
29+
}
30+
31+
script:pre-request {
32+
const scripts = require('./scripts');
33+
34+
scripts.generateDirectedIdentityKeys();
35+
36+
await scripts.addDirectedIdentitySignatureHeaders();
37+
}
38+
39+
script:post-response {
40+
const scripts = require('./scripts');
41+
42+
scripts.storeTokenDetails();
43+
}
44+
45+
tests {
46+
test("Status code is 200", function() {
47+
expect(res.getStatus()).to.equal(200);
48+
});
49+
}

0 commit comments

Comments
 (0)