From 82ba980ea8a3f7367c2c37f02de7d52312996963 Mon Sep 17 00:00:00 2001
From: Sabine Schaller
Date: Thu, 23 May 2024 14:27:32 +0200
Subject: [PATCH] chore: add JS tab to code snippets
---
.../content/docs/snippets/grant-continue.mdx | 35 ++++++
.../content/docs/snippets/grant-create.mdx | 44 +++++++
.../content/docs/snippets/grant-revoke.mdx | 29 +++++
.../docs/snippets/incoming-complete.mdx | 34 ++++++
.../content/docs/snippets/incoming-create.mdx | 40 ++++++-
.../content/docs/snippets/incoming-get.mdx | 34 ++++++
.../content/docs/snippets/incoming-list.mdx | 34 ++++++
.../content/docs/snippets/outgoing-create.mdx | 34 ++++++
.../content/docs/snippets/outgoing-get.mdx | 34 ++++++
.../content/docs/snippets/outgoing-list.mdx | 34 ++++++
.../content/docs/snippets/quote-create.mdx | 110 ++++++++++++++++++
docs/src/content/docs/snippets/quote-get.mdx | 34 ++++++
.../content/docs/snippets/token-revoke.mdx | 29 +++++
.../content/docs/snippets/token-rotate.mdx | 34 ++++++
.../content/docs/snippets/wallet-get-info.mdx | 34 ++++++
.../content/docs/snippets/wallet-get-keys.mdx | 34 ++++++
docs/src/partials/js-prerequisites.mdx | 15 +++
docs/src/partials/ts-prerequisites.mdx | 2 +-
18 files changed, 640 insertions(+), 4 deletions(-)
create mode 100644 docs/src/partials/js-prerequisites.mdx
diff --git a/docs/src/content/docs/snippets/grant-continue.mdx b/docs/src/content/docs/snippets/grant-continue.mdx
index 48efa62f..b3702a19 100644
--- a/docs/src/content/docs/snippets/grant-continue.mdx
+++ b/docs/src/content/docs/snippets/grant-continue.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
During a grant request flow, an authorization server can require an individual (typically a client's end user) to approve the grant by interacting directly with the server. For example, by tapping an Approve button on a web page provided by the auth server.
@@ -53,6 +54,40 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/grant-create.mdx b/docs/src/content/docs/snippets/grant-create.mdx
index 792db198..f9d51b70 100644
--- a/docs/src/content/docs/snippets/grant-create.mdx
+++ b/docs/src/content/docs/snippets/grant-create.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
Before a client can call the Open Payments API, it must request/receive a grant from the appropriate authorization server. The request must indicate the resource type the client intends to work with and the actions the client wants to take at the resource server.
@@ -65,6 +66,49 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/grant-revoke.mdx b/docs/src/content/docs/snippets/grant-revoke.mdx
index 199ced60..579997f5 100644
--- a/docs/src/content/docs/snippets/grant-revoke.mdx
+++ b/docs/src/content/docs/snippets/grant-revoke.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
If an authorized client no longer needs access to protected resources, the client can revoke the corresponding grant request.
@@ -46,6 +47,34 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/incoming-complete.mdx b/docs/src/content/docs/snippets/incoming-complete.mdx
index e303337a..35c42c83 100644
--- a/docs/src/content/docs/snippets/incoming-complete.mdx
+++ b/docs/src/content/docs/snippets/incoming-complete.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
An authorized client can complete an unexpired incoming payment to indicate it will not send any additional payments to the wallet address.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/incoming-create.mdx b/docs/src/content/docs/snippets/incoming-create.mdx
index d3b3e48a..612950d7 100644
--- a/docs/src/content/docs/snippets/incoming-create.mdx
+++ b/docs/src/content/docs/snippets/incoming-create.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
Once an authorized client obtains the requisite grant from the recipient’s authentication server, the client must create an incoming payment resource before any payments can be sent to the recipient’s wallet address.
@@ -44,9 +45,6 @@ These code snippets create an incoming payment of $10 USD at a given wallet addr
chunk='4'
/>
-
-
-
Run `tsx path/to/directory/index.ts`.
{/* prettier-ignore */}
@@ -54,6 +52,42 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
+
+
+
## References
- [API specification](/apis/resource-server/operations/create-incoming-payment)
diff --git a/docs/src/content/docs/snippets/incoming-get.mdx b/docs/src/content/docs/snippets/incoming-get.mdx
index 56c91db3..762fb59a 100644
--- a/docs/src/content/docs/snippets/incoming-get.mdx
+++ b/docs/src/content/docs/snippets/incoming-get.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
An authorized client can look up the state of an incoming payment on a wallet address. This is useful when a client must determine if an incoming payment is still active and pending payment.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/incoming-list.mdx b/docs/src/content/docs/snippets/incoming-list.mdx
index 9beff816..c31651ac 100644
--- a/docs/src/content/docs/snippets/incoming-list.mdx
+++ b/docs/src/content/docs/snippets/incoming-list.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
After one or more incoming payments have been created on a wallet address, an authorized client can look up active and pending incoming payments on that wallet address.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/outgoing-create.mdx b/docs/src/content/docs/snippets/outgoing-create.mdx
index 30a79df6..0871f5e9 100644
--- a/docs/src/content/docs/snippets/outgoing-create.mdx
+++ b/docs/src/content/docs/snippets/outgoing-create.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
After a quote is accepted and the authorized client obtains the requisite grant from the payer’s authorization server, the client can create an outgoing payment resource against the payer’s wallet address.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/outgoing-get.mdx b/docs/src/content/docs/snippets/outgoing-get.mdx
index 202f6ec3..595858d0 100644
--- a/docs/src/content/docs/snippets/outgoing-get.mdx
+++ b/docs/src/content/docs/snippets/outgoing-get.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
An authorized client can look up the state of an outgoing payment on a wallet address. This is useful when a client must determine if an outgoing payment is still active and pending payment.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/outgoing-list.mdx b/docs/src/content/docs/snippets/outgoing-list.mdx
index f574fe02..c8518955 100644
--- a/docs/src/content/docs/snippets/outgoing-list.mdx
+++ b/docs/src/content/docs/snippets/outgoing-list.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
After one or more outgoing payments have been created on a wallet address, an authorized client can look up active and pending outgoing payments on that wallet address.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/quote-create.mdx b/docs/src/content/docs/snippets/quote-create.mdx
index 326ec86d..474e0f32 100644
--- a/docs/src/content/docs/snippets/quote-create.mdx
+++ b/docs/src/content/docs/snippets/quote-create.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
A quote is a commitment from an account servicing entity to deliver a particular amount to a payee when sending a particular amount from a payer. Once an authorized client obtains the requisite grant from the payer’s authorization server, the client can create a quote resource against the payer’s wallet address. The quote indicates how much it will cost the payer to proceed with the transaction.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
@@ -96,6 +130,44 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
@@ -141,6 +213,44 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/quote-get.mdx b/docs/src/content/docs/snippets/quote-get.mdx
index 72e31e13..01ae66f2 100644
--- a/docs/src/content/docs/snippets/quote-get.mdx
+++ b/docs/src/content/docs/snippets/quote-get.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
A quote is a commitment from an account servicing entity to deliver a particular amount to a payee when sending a particular amount from a payer. The quote is only valid for a limited time.
@@ -53,6 +54,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/token-revoke.mdx b/docs/src/content/docs/snippets/token-revoke.mdx
index a156d558..f7d5067b 100644
--- a/docs/src/content/docs/snippets/token-revoke.mdx
+++ b/docs/src/content/docs/snippets/token-revoke.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
Revoking an access token consists of the authorization server invalidating the token for all purposes. If, for example, a user indicates to a client that they no longer want the client to have access to something, the client can request the associated token be revoked.
@@ -46,6 +47,34 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+### Get started
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/token-rotate.mdx b/docs/src/content/docs/snippets/token-rotate.mdx
index b2adde86..ccc53367 100644
--- a/docs/src/content/docs/snippets/token-rotate.mdx
+++ b/docs/src/content/docs/snippets/token-rotate.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
Rotating an access token consists of the authorization server issuing a new token in place of the existing token, with the same rights and properties as the original token. If, for example, an access token expires, an authorized client can request the token be rotated.
@@ -53,6 +54,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/wallet-get-info.mdx b/docs/src/content/docs/snippets/wallet-get-info.mdx
index 6abf285a..775c7b52 100644
--- a/docs/src/content/docs/snippets/wallet-get-info.mdx
+++ b/docs/src/content/docs/snippets/wallet-get-info.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
For a client to request a grant from an authorization server, the client must first verify the validity of the wallet address and get the URL of the wallet's authorization server.
@@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/content/docs/snippets/wallet-get-keys.mdx b/docs/src/content/docs/snippets/wallet-get-keys.mdx
index 2f04ff96..51d73d78 100644
--- a/docs/src/content/docs/snippets/wallet-get-keys.mdx
+++ b/docs/src/content/docs/snippets/wallet-get-keys.mdx
@@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
+import Js from '/src/partials/js-prerequisites.mdx'
While most Open Payments code snippets are intended for clients, getting the keys bound to a wallet address is primarily a function of account servicing entities.
@@ -53,6 +54,39 @@ Run `tsx path/to/directory/index.ts`.
View full source
+
+
+
+
+#### Get started
+
+
+
+
+
+
+
+
+
+Run `node path/to/directory/index.js`.
+
+{/* prettier-ignore */}
+
+ View full source
+
+
diff --git a/docs/src/partials/js-prerequisites.mdx b/docs/src/partials/js-prerequisites.mdx
new file mode 100644
index 00000000..106685f1
--- /dev/null
+++ b/docs/src/partials/js-prerequisites.mdx
@@ -0,0 +1,15 @@
+import { LinkOut, Disclosure } from '@interledger/docs-design-system'
+
+
+
+- Node 18 or higher
+- A package manager such as NPM or PNPM
+-
+ Open Payments SDK
+
+
+**Additional configuration**
+
+Add `"type": "module"` to `package.json`
+
+
diff --git a/docs/src/partials/ts-prerequisites.mdx b/docs/src/partials/ts-prerequisites.mdx
index af69fd2c..75e95c7f 100644
--- a/docs/src/partials/ts-prerequisites.mdx
+++ b/docs/src/partials/ts-prerequisites.mdx
@@ -4,7 +4,7 @@ import { LinkOut, Disclosure } from '@interledger/docs-design-system'
- Node 18
- A package manager such as NPM or PNPM
--
+-
Open Payments SDK
- TSX