Skip to content

Commit

Permalink
feat: extract wallet address from RS (#315)
Browse files Browse the repository at this point in the history
* feat: extract wallet address from RS

* fix: address comments from @sabineschaller

* fix: validate OpenAPI spec

* fix: linting issues

* fix: remove spectral config

* fix: add code generation

* fix: add types and fix mocks

* fix: lint and format

* fix: update open-payments client

* docs: update docs autogen

* fix: add changesets

* test: add tests for DID Document

* fix: accept suggestions
  • Loading branch information
adrianhopebailie authored Dec 8, 2023
1 parent ca08398 commit ec04a61
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 253 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-snails-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@interledger/open-payments': minor
---

Mapped wallet address and jwks get to new stand along Open API spec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ dist
**/.terraform

tmp
.spectral.json
5 changes: 5 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const { starlightOpenAPI } = await generateAPI([
label: 'Open Payments',
schema: '../openapi/resource-server.yaml'
},
{
base: 'apis/wallet-address-server',
label: 'Wallet Addresses',
schema: '../openapi/wallet-address-server.yaml'
},
{
base: 'apis/auth-server',
label: 'Open Payments Authorization Server',
Expand Down
150 changes: 0 additions & 150 deletions openapi/resource-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,55 +42,6 @@ tags:
- name: quote
description: quote operations
paths:
/:
get:
summary: Get a Wallet Address
tags:
- wallet-address
responses:
'200':
description: Wallet Address Found
content:
application/json:
schema:
$ref: '#/components/schemas/wallet-address'
examples:
Get wallet address for $ilp.rafiki.money/alice:
value:
id: 'https://ilp.rafiki.money/alice'
publicName: Alice
assetCode: USD
assetScale: 2
authServer: 'https://auth.rafiki.money'
'404':
description: Wallet Address Not Found
operationId: get-wallet-address
description: |-
Retrieve the public information of the Wallet Address.
This end-point should be open to anonymous requests as it allows clients to verify a Wallet Address URL and get the basic information required to construct new transactions and discover the grant request URL.
The content should be slow changing and cacheable for long periods. Servers SHOULD use cache control headers.
security: []
x-internal: false
/jwks.json:
get:
summary: Get the keys bound to a Wallet Address
tags:
- wallet-address
responses:
'200':
description: JWKS Document Found
content:
application/json:
schema:
$ref: '#/components/schemas/json-web-key-set'
examples: {}
'404':
description: JWKS Document Not Found
operationId: get-wallet-address-keys
description: Retrieve the public keys of the Wallet Address.
security: []
/incoming-payments:
post:
summary: Create an Incoming Payment
Expand Down Expand Up @@ -817,62 +768,6 @@ paths:
- $ref: '#/components/parameters/id'
components:
schemas:
wallet-address:
title: Wallet Address
type: object
description: A **wallet address** resource is the root of the API and contains the public details of the financial account represented by the Wallet Address that is also the service endpoint URL.
additionalProperties: true
examples:
- id: 'https://ilp.rafiki.money/alice'
publicName: Alice
assetCode: USD
assetScale: 2
authServer: 'https://auth.rafiki.money'
properties:
id:
type: string
format: uri
description: The URL identifying the wallet address.
readOnly: true
publicName:
type: string
description: A public name for the account. This should be set by the account holder with their provider to provide a hint to counterparties as to the identity of the account holder.
readOnly: true
assetCode:
$ref: ./schemas.yaml#/components/schemas/assetCode
assetScale:
$ref: ./schemas.yaml#/components/schemas/assetScale
authServer:
type: string
format: uri
description: The URL of the authorization server endpoint for getting grants and access tokens for this wallet address.
readOnly: true
required:
- id
- assetCode
- assetScale
- authServer
json-web-key-set:
title: JSON Web Key Set document
type: object
description: 'A JSON Web Key Set document according to [rfc7517](https://datatracker.ietf.org/doc/html/rfc7517) listing the keys associated with this wallet address. These keys are used to sign requests made by this wallet address.'
additionalProperties: false
properties:
keys:
type: array
items:
$ref: '#/components/schemas/json-web-key'
readOnly: true
required:
- keys
examples:
- keys:
- kid: key-1
alg: EdDSA
use: sig
kty: OKP
crv: Ed25519
x: 11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo
incoming-payment:
title: Incoming Payment
description: 'An **incoming payment** resource represents a payment that will be, is currently being, or has been received by the account.'
Expand Down Expand Up @@ -1187,51 +1082,6 @@ components:
- hasNextPage
- hasPreviousPage
additionalProperties: false
json-web-key:
type: object
properties:
kid:
type: string
alg:
type: string
description: 'The cryptographic algorithm family used with the key. The only allowed value is `EdDSA`. '
enum:
- EdDSA
use:
type: string
enum:
- sig
kty:
type: string
enum:
- OKP
crv:
type: string
enum:
- Ed25519
x:
type: string
pattern: '^[a-zA-Z0-9-_]+$'
description: The base64 url-encoded public key.
required:
- kid
- alg
- kty
- crv
- x
title: Ed25519 Public Key
description: A JWK representation of an Ed25519 Public Key
examples:
- kid: key-1
use: sig
kty: OKP
crv: Ed25519
x: 11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo
- kid: '2022-09-02'
use: sig
kty: OKP
crv: Ed25519
x: oy0L_vTygNE4IogRyn_F5GmHXdqYVjIXkWs2jky7zsI
payment-method:
type: string
enum:
Expand Down
201 changes: 201 additions & 0 deletions openapi/wallet-address-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
openapi: 3.1.0
info:
title: Wallet Address API
version: '1.4'
license:
name: Apache 2.0
identifier: Apache-2.0
description: |-
The Wallet Address API is a simple REST API to get basic details about a wallet address.
contact:
email: [email protected]
servers:
- url: 'https://rafiki.money/alice'
description: "Server for Alice's wallet address"
- url: 'https://rafiki.money/bob'
description: "Server for Bob's wallet address"
tags:
- name: wallet-address
description: wallet address operations
paths:
/:
get:
summary: Get a Wallet Address
tags:
- wallet-address
responses:
'200':
description: Wallet Address Found
content:
application/json:
schema:
$ref: '#/components/schemas/wallet-address'
examples:
Get wallet address for $rafiki.money/alice:
value:
id: 'https://rafiki.money/alice'
publicName: Alice
assetCode: USD
assetScale: 2
authServer: 'https://rafiki.money/auth'
resourceServer: 'https://rafiki.money/op'
'404':
description: Wallet Address Not Found
operationId: get-wallet-address
description: |-
Retrieve the public information of the Wallet Address.
This end-point should be open to anonymous requests as it allows clients to verify a Wallet Address URL and get the basic information required to construct new transactions and discover the grant request URL.
The content should be slow changing and cacheable for long periods. Servers SHOULD use cache control headers.
security: []
x-internal: false
/jwks.json:
get:
summary: Get the keys bound to a Wallet Address
tags:
- wallet-address
responses:
'200':
description: JWKS Document Found
content:
application/json:
schema:
$ref: '#/components/schemas/json-web-key-set'
examples: {}
'404':
description: JWKS Document Not Found
operationId: get-wallet-address-keys
description: Retrieve the public keys of the Wallet Address.
security: []
/did.json:
get:
summary: Get the DID Document for this wallet
tags:
- wallet-address
responses:
'200':
description: DID Document Found
content:
application/json:
schema:
$ref: '#/components/schemas/did-document'
'500':
description: DID Document not yet implemented
operationId: get-wallet-address-did-document
description: Retrieve the DID Document of the Wallet Address.
security: []
components:
schemas:
wallet-address:
title: Wallet Address
type: object
description: A **wallet address** resource is the root of the API and contains the public details of the financial account represented by the Wallet Address that is also the service endpoint URL.
additionalProperties: true
examples:
- id: 'https://rafiki.money/alice'
publicName: Alice
assetCode: USD
assetScale: 2
authServer: 'https://rafiki.money/auth'
resourceServer: 'https://rafiki.money/op'
properties:
id:
type: string
format: uri
description: The URL identifying the wallet address.
readOnly: true
publicName:
type: string
description: A public name for the account. This should be set by the account holder with their provider to provide a hint to counterparties as to the identity of the account holder.
readOnly: true
assetCode:
$ref: ./schemas.yaml#/components/schemas/assetCode
assetScale:
$ref: ./schemas.yaml#/components/schemas/assetScale
authServer:
type: string
format: uri
description: The URL of the authorization server endpoint for getting grants and access tokens for this wallet address.
readOnly: true
resourceServer:
type: string
format: uri
description: The URL of the resource server endpoint for performing Open Payments with this wallet address.
readOnly: true
required:
- id
- assetCode
- assetScale
- authServer
- resourceServer
json-web-key-set:
title: JSON Web Key Set document
type: object
description: 'A JSON Web Key Set document according to [rfc7517](https://datatracker.ietf.org/doc/html/rfc7517) listing the keys associated with this wallet address. These keys are used to sign requests made by this wallet address.'
additionalProperties: false
properties:
keys:
type: array
items:
$ref: '#/components/schemas/json-web-key'
readOnly: true
required:
- keys
examples:
- keys:
- kid: key-1
alg: EdDSA
use: sig
kty: OKP
crv: Ed25519
x: 11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo
json-web-key:
type: object
properties:
kid:
type: string
alg:
type: string
description: 'The cryptographic algorithm family used with the key. The only allowed value is `EdDSA`. '
enum:
- EdDSA
use:
type: string
enum:
- sig
kty:
type: string
enum:
- OKP
crv:
type: string
enum:
- Ed25519
x:
type: string
pattern: '^[a-zA-Z0-9-_]+$'
description: The base64 url-encoded public key.
required:
- kid
- alg
- kty
- crv
- x
title: Ed25519 Public Key
description: A JWK representation of an Ed25519 Public Key
examples:
- kid: key-1
use: sig
kty: OKP
crv: Ed25519
x: 11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo
- kid: '2022-09-02'
use: sig
kty: OKP
crv: Ed25519
x: oy0L_vTygNE4IogRyn_F5GmHXdqYVjIXkWs2jky7zsI
did-document:
type: object
title: DID Document
description: A DID Document using JSON encoding
Loading

0 comments on commit ec04a61

Please sign in to comment.