From b745e95568af89fb578b7aec985153f0ab60f6d5 Mon Sep 17 00:00:00 2001 From: Munawar mohammed jemal Date: Sat, 9 Nov 2024 00:34:37 +0300 Subject: [PATCH 01/43] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..dd84ea78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. From dfcaa86b45498877a3f51a806c9677e2a71d9896 Mon Sep 17 00:00:00 2001 From: Munawar mohammed jemal Date: Sat, 9 Nov 2024 01:16:40 +0300 Subject: [PATCH 02/43] Update issue templates --- .github/ISSUE_TEMPLATE/{bug_report.md => bug-report.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/ISSUE_TEMPLATE/{bug_report.md => bug-report.md} (100%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug-report.md similarity index 100% rename from .github/ISSUE_TEMPLATE/bug_report.md rename to .github/ISSUE_TEMPLATE/bug-report.md From 766f526543ec8539fbab0584ac53a1020d7d9d9c Mon Sep 17 00:00:00 2001 From: Munawar mohammed jemal Date: Sat, 9 Nov 2024 01:22:53 +0300 Subject: [PATCH 03/43] Create Munawarmoja Signed-off-by: Munawar mohammed jemal --- .github/Munawarmoja | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/Munawarmoja diff --git a/.github/Munawarmoja b/.github/Munawarmoja new file mode 100644 index 00000000..42bf91fd --- /dev/null +++ b/.github/Munawarmoja @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 9c192010af5e4df53933fdfb47b3ffb9944dfe76 Mon Sep 17 00:00:00 2001 From: Munawar mohammed jemal Date: Sat, 9 Nov 2024 01:24:33 +0300 Subject: [PATCH 04/43] Create Munawarmoja Signed-off-by: Munawar mohammed jemal --- Munawarmoja | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Munawarmoja diff --git a/Munawarmoja b/Munawarmoja new file mode 100644 index 00000000..42bf91fd --- /dev/null +++ b/Munawarmoja @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +polar: # Replace with a single Polar username +buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +thanks_dev: # Replace with a single thanks.dev username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From b87713187b232262d88013f254d2db813d4a888e Mon Sep 17 00:00:00 2001 From: Munawar mohammed jemal Date: Sun, 10 Nov 2024 00:49:12 +0300 Subject: [PATCH 05/43] Create generator-generic-ossf-slsa3-publish.yml Signed-off-by: Munawar mohammed jemal --- .../generator-generic-ossf-slsa3-publish.yml | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/generator-generic-ossf-slsa3-publish.yml diff --git a/.github/workflows/generator-generic-ossf-slsa3-publish.yml b/.github/workflows/generator-generic-ossf-slsa3-publish.yml new file mode 100644 index 00000000..35c829b1 --- /dev/null +++ b/.github/workflows/generator-generic-ossf-slsa3-publish.yml @@ -0,0 +1,66 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow lets you generate SLSA provenance file for your project. +# The generation satisfies level 3 for the provenance requirements - see https://slsa.dev/spec/v0.1/requirements +# The project is an initiative of the OpenSSF (openssf.org) and is developed at +# https://github.com/slsa-framework/slsa-github-generator. +# The provenance file can be verified using https://github.com/slsa-framework/slsa-verifier. +# For more information about SLSA and how it improves the supply-chain, visit slsa.dev. + +name: SLSA generic generator +on: + workflow_dispatch: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + outputs: + digests: ${{ steps.hash.outputs.digests }} + + steps: + - uses: actions/checkout@v4 + + # ======================================================== + # + # Step 1: Build your artifacts. + # + # ======================================================== + - name: Build artifacts + run: | + # These are some amazing artifacts. + echo "artifact1" > artifact1 + echo "artifact2" > artifact2 + + # ======================================================== + # + # Step 2: Add a step to generate the provenance subjects + # as shown below. Update the sha256 sum arguments + # to include all binaries that you generate + # provenance for. + # + # ======================================================== + - name: Generate subject for provenance + id: hash + run: | + set -euo pipefail + + # List the artifacts the provenance will refer to. + files=$(ls artifact*) + # Generate the subjects (base64 encoded). + echo "hashes=$(sha256sum $files | base64 -w0)" >> "${GITHUB_OUTPUT}" + + provenance: + needs: [build] + permissions: + actions: read # To read the workflow path. + id-token: write # To sign the provenance. + contents: write # To add assets to a release. + uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.4.0 + with: + base64-subjects: "${{ needs.build.outputs.digests }}" + upload-assets: true # Optional: Upload to a new release From c1c429ad293646568b0c9187e5fec42a54f83e0d Mon Sep 17 00:00:00 2001 From: moja Date: Tue, 12 Nov 2024 18:17:27 +0300 Subject: [PATCH 06/43] Update .env.example --- .env.example | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.env.example b/.env.example index d843ca2a..af87eb63 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,9 @@ BACKEND_DOMAIN_NAME=backend.example.com # Obtain the following 2 values on the Pi Developer Portal (open develop.pi in the Pi Browser). # Domain validation key: + +5f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 + DOMAIN_VALIDATION_KEY=todo_developer_portal # Pi Platform API Key: PI_API_KEY=todo_developer_portal From 87379c9f6261cc28ee6cb92b93ab7dc932d41caf Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 00:07:44 +0300 Subject: [PATCH 07/43] Rename deployment.md to deployment.md gibee Signed-off-by: Gibee From b81babd8fcdf2439415e7de04e3ae909712988bd Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 14:06:03 +0300 Subject: [PATCH 08/43] Update .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index af87eb63..348d957c 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,7 @@ # # this is a comment: # FOO=value # ``` - +b326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 # # # From 04b2969061172705ae8a773c9310b6041a538dd9 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 15:42:19 +0300 Subject: [PATCH 09/43] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fdb78603..90c86890 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It is composed of two major parts: * **backend**: a backend app (a very simple JSON API built using Node and ExpressJS) * **frontend**: a single-page frontend app (built using React and create-react-app) - + ## Initial Development Read [`doc/development.md`](./doc/development.md) to get started and learn how to run this app in development. From 3072fbd595bf19a2f1e9d48e7539cd2bb69e4618 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 15:44:00 +0300 Subject: [PATCH 10/43] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 90c86890..737765a6 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,6 @@ It is composed of two major parts: * **backend**: a backend app (a very simple JSON API built using Node and ExpressJS) * **frontend**: a single-page frontend app (built using React and create-react-app) - -## Initial Development Read [`doc/development.md`](./doc/development.md) to get started and learn how to run this app in development. From af7a75e9daba34df07e86db898749d2feee679ed Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 15:54:50 +0300 Subject: [PATCH 11/43] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 737765a6..2be86554 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,6 @@ Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app To dive into the implementation of the flows that support the demo app features, please refer to [Pi Demo App Flows](./FLOWS.md). + + + \ No newline at end of file From 4321c3349cd53106feca34b05657c86b2c1ee3b9 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:02:31 +0300 Subject: [PATCH 12/43] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2be86554..d4bb74aa 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,7 @@ To dive into the implementation of the flows that support the demo app features, [Pi Demo App Flows](./FLOWS.md). - \ No newline at end of file + + +git clone git@github.com:pi-apps/platform-demo-app.git +cd platform-demo-app \ No newline at end of file From d9cec9ed6e33700c28b771a764aad11c60a750b8 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:06:13 +0300 Subject: [PATCH 13/43] Update docker-compose.yml --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 0c34b211..12850b54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,15 @@ version: "3.9" services: + +apt-get update && \ +apt-get install -y zip apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \ +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ +add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \ +apt-get update && \ +apt-get install -y docker-ce docker-ce-cli containerd.io && \ +curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \ +chmod +x /usr/local/bin/docker-compose + reverse-proxy: build: ./reverse-proxy environment: From 51cd0e56cf156fd3fafe66e2f73180734b6bd286 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:14:00 +0300 Subject: [PATCH 14/43] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index d4bb74aa..19047736 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,5 @@ Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app To dive into the implementation of the flows that support the demo app features, please refer to [Pi Demo App Flows](./FLOWS.md). - - - git clone git@github.com:pi-apps/platform-demo-app.git cd platform-demo-app \ No newline at end of file From 4dfe7c9d48facba4a68fe1cf8768df2eca6e76b0 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:15:00 +0300 Subject: [PATCH 15/43] demo ap --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 19047736..2c66a23f 100644 --- a/README.md +++ b/README.md @@ -28,5 +28,3 @@ Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app To dive into the implementation of the flows that support the demo app features, please refer to [Pi Demo App Flows](./FLOWS.md). -git clone git@github.com:pi-apps/platform-demo-app.git -cd platform-demo-app \ No newline at end of file From 6785c8112effe58012a402a00f2c26fca16fff10 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:20:30 +0300 Subject: [PATCH 16/43] Update demo --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2c66a23f..21d7b552 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,9 @@ Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app To dive into the implementation of the flows that support the demo app features, please refer to [Pi Demo App Flows](./FLOWS.md). + + +https://sandbox.minepi.com/app/moja-3b24d0bd54f45e15 + + +https://sandbox.minepi.com/app/munawarmoja From 7ec4c89620174909a127c9cc3a11444b0ba81ec5 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:26:11 +0300 Subject: [PATCH 17/43] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 21d7b552..7965e64d 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,3 @@ To dive into the implementation of the flows that support the demo app features, -https://sandbox.minepi.com/app/moja-3b24d0bd54f45e15 - - -https://sandbox.minepi.com/app/munawarmoja From 9acc7e27518e47287a0e35a66d9ad215bcd87a11 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 16:57:14 +0300 Subject: [PATCH 18/43] Update README.md Signed-off-by: Gibee --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 7965e64d..503f37b0 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,36 @@ To dive into the implementation of the flows that support the demo app features, +// Authenticate the user, and get permission to request payments from them: +const scopes = ['payments']; + +// Read more about this callback in the SDK reference: +function onIncompletePaymentFound(payment) { /* ... */ }; + +Pi.authenticate(scopes, onIncompletePaymentFound).then(function(auth) { + console.log(Hi there! You're ready to make payments!); +}).catch(function(error) { + console.error(error); +}); + + + + + + + +Pi.createPayment({ + // Amount of π to be paid: + amount: 3.14, + // An explanation of the payment - will be shown to the user: + memo: "...", // e.g: "Digital kitten #1234", + // An arbitrary developer-provided metadata object - for your own usage: + metadata: { /* ... */ }, // e.g: { kittenId: 1234 } +}, { + // Callbacks you need to implement - read more about those in the detailed docs linked below: + onReadyForServerApproval: function(paymentId) { /* ... */ }, + onReadyForServerCompletion: function(paymentId, txid) { /* ... */ }, + onCancel: function(paymentId) { /* ... */ }, + onError: function(error, payment) { /* ... */ }, +}); + From 429b4690685b106af40ba34dfb0e1bca8e1f2d74 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 17:04:32 +0300 Subject: [PATCH 19/43] Update README.md --- README.md | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/README.md b/README.md index 503f37b0..cc785748 100644 --- a/README.md +++ b/README.md @@ -30,36 +30,4 @@ To dive into the implementation of the flows that support the demo app features, -// Authenticate the user, and get permission to request payments from them: -const scopes = ['payments']; - -// Read more about this callback in the SDK reference: -function onIncompletePaymentFound(payment) { /* ... */ }; - -Pi.authenticate(scopes, onIncompletePaymentFound).then(function(auth) { - console.log(Hi there! You're ready to make payments!); -}).catch(function(error) { - console.error(error); -}); - - - - - - - -Pi.createPayment({ - // Amount of π to be paid: - amount: 3.14, - // An explanation of the payment - will be shown to the user: - memo: "...", // e.g: "Digital kitten #1234", - // An arbitrary developer-provided metadata object - for your own usage: - metadata: { /* ... */ }, // e.g: { kittenId: 1234 } -}, { - // Callbacks you need to implement - read more about those in the detailed docs linked below: - onReadyForServerApproval: function(paymentId) { /* ... */ }, - onReadyForServerCompletion: function(paymentId, txid) { /* ... */ }, - onCancel: function(paymentId) { /* ... */ }, - onError: function(error, payment) { /* ... */ }, -}); From c89cef76260bf57883f040dd0be9c56efc3a9e59 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 17:13:43 +0300 Subject: [PATCH 20/43] Update README.md --- README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/README.md b/README.md index cc785748..681724d3 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,59 @@ To dive into the implementation of the flows that support the demo app features, + + + +## +## BUILDER CONTAINER +## + +FROM node:12.20.0 as builder + +RUN mkdir /app + +COPY ./package.json /app/package.json +COPY ./yarn.lock /app/yarn.lock + +WORKDIR /app + +RUN yarn install + +# Copy the resources needed to build the app +# We could copy ./ but it weigh more and bust cache more often +COPY ./src /app/src +COPY ./public /app/public +COPY ./tsconfig.json /app/tsconfig.json + +RUN NODE_PATH=./src yarn build + +# We have set GENERATE_SOURCEMAP=false in our build script but we're doing this to add an extra layer +# of safety - we want to keep JS source maps from getting deployed on the production servers: +RUN rm -rf ./build/static/js/*.map + +## +## RUNNER CONTAINER +## + +FROM nginx:1.15.7 + +COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf +COPY ./docker/entrypoint.sh /var/entrypoint.sh +RUN chmod +x /var/entrypoint.sh + +RUN mkdir -p /var/www/webapp + +COPY --from=builder /app/build /var/www/webapp + +# Default nginx configuration has only one worker process running. "Auto" is a better setting. +# Commenting out any existing setting, and adding the desired one is more robust against new docker image versions. +RUN sed -i "s/worker_processes/#worker_processes/" /etc/nginx/nginx.conf && \ + echo "worker_processes auto;" >> /etc/nginx/nginx.conf && \ + echo "worker_rlimit_nofile 16384;" >> /etc/nginx/nginx.conf + +# Override the default command of the base image: +# See: https://github.com/nginxinc/docker-nginx/blob/1.15.7/mainline/stretch/Dockerfile#L99 +CMD ["/var/entrypoint.sh"] + + + From 9f3cbc5928bc831419ce7abe34572c89cf717e7c Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 17:20:39 +0300 Subject: [PATCH 21/43] Update README.md --- README.md | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) diff --git a/README.md b/README.md index 681724d3..4a681ee7 100644 --- a/README.md +++ b/README.md @@ -34,56 +34,6 @@ To dive into the implementation of the flows that support the demo app features, -## -## BUILDER CONTAINER -## - -FROM node:12.20.0 as builder - -RUN mkdir /app - -COPY ./package.json /app/package.json -COPY ./yarn.lock /app/yarn.lock - -WORKDIR /app - -RUN yarn install - -# Copy the resources needed to build the app -# We could copy ./ but it weigh more and bust cache more often -COPY ./src /app/src -COPY ./public /app/public -COPY ./tsconfig.json /app/tsconfig.json - -RUN NODE_PATH=./src yarn build - -# We have set GENERATE_SOURCEMAP=false in our build script but we're doing this to add an extra layer -# of safety - we want to keep JS source maps from getting deployed on the production servers: -RUN rm -rf ./build/static/js/*.map - -## -## RUNNER CONTAINER -## - -FROM nginx:1.15.7 - -COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf -COPY ./docker/entrypoint.sh /var/entrypoint.sh -RUN chmod +x /var/entrypoint.sh - -RUN mkdir -p /var/www/webapp - -COPY --from=builder /app/build /var/www/webapp - -# Default nginx configuration has only one worker process running. "Auto" is a better setting. -# Commenting out any existing setting, and adding the desired one is more robust against new docker image versions. -RUN sed -i "s/worker_processes/#worker_processes/" /etc/nginx/nginx.conf && \ - echo "worker_processes auto;" >> /etc/nginx/nginx.conf && \ - echo "worker_rlimit_nofile 16384;" >> /etc/nginx/nginx.conf - -# Override the default command of the base image: -# See: https://github.com/nginxinc/docker-nginx/blob/1.15.7/mainline/stretch/Dockerfile#L99 -CMD ["/var/entrypoint.sh"] From 76ec28929908ec7e8a429fa9a9e4f51f8eff9b6a Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 17:50:30 +0300 Subject: [PATCH 22/43] Update README.md --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/README.md b/README.md index 4a681ee7..0b19d983 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,86 @@ To dive into the implementation of the flows that support the demo app features, +Frontend Javascript SDK +The JS SDK is the frontend SDK, designed to be used in your HTML pages or Single-Page Apps, served in the Pi Browser. + +In order to enable the SDK to function correctly, you need to declare your apps on the Developer Portal (open +develop.pi in the Pi Browser to access the Developer Portal). + +This SDK is not for a server-side NodeJS app. + + +## Installation + +Add the following script tags to all pages where you need to call the Pi Apps SDK: + + + +This will load the Pi Network JS SDK as a global window.Pi object. + +## Usage + +### Authenticate a user + +You cannot perform any user-related operations (e.g read the user's info, request a payment from them) until you +have successfully authenticated the user. The first time, they will be presented with a dialog asking for +their consent to share their data with your app. + +// Authenticate the user, and get permission to request payments from them: +const scopes = ['payments']; + +// Read more about this callback in the SDK reference: +function onIncompletePaymentFound(payment) { /* ... */ }; + +Pi.authenticate(scopes, onIncompletePaymentFound).then(function(auth) { + console.log(`Hi there! You're ready to make payments!`); +}).catch(function(error) { + console.error(error); +}); +### Request a payment (User-To-App) + +The createPayment method enables you to request a payment from the current user to your app's account. + +The user will be prompted with a modal provided by the Pi Wallet, enabling them to sign the +transaction and submit it to the Pi Blockchain. + +Pi.createPayment({ + // Amount of π to be paid: + amount: 3.14, + // An explanation of the payment - will be shown to the user: + memo: "...", // e.g: "Digital kitten #1234", + // An arbitrary developer-provided metadata object - for your own usage: + metadata: { /* ... */ }, // e.g: { kittenId: 1234 } +}, { + // Callbacks you need to implement - read more about those in the detailed docs linked below: + onReadyForServerApproval: function(paymentId) { /* ... */ }, + onReadyForServerCompletion: function(paymentId, txid) { /* ... */ }, + onCancel: function(paymentId) { /* ... */ }, + onError: function(error, payment) { /* ... */ }, +}); + +### Request a payment (App-To-User) + +If you want to send Pi from your app to a user, you need to use one of Pi Network's backend SDKs, depending +on the language your backend is written in. Refer to the [Advanced payments guide](./payments_advanced.md) +for more information. + + + + + +In order to make sure that all involved parties (your app, your server, the Pi servers, and the Pi Blockchain) are in sync, +the payment needs to go through a Server-Side Approval flow (for User-to-App payment) and/or a Server-Side Completion +flow (for all types of payments). + +Please refer to: +* [the full Payments documentation](./payments.md) to learn about the complete payment flow +* [the Advanced Payments documentation](./payments_advanced.md) to learn about App-to-User payment flow +* [the Platform API documentation](./platform_API.md) to learn how to confirm the payment and acknowledge it from your + server +* [the client SDK documentation](./SDK_reference.md) to learn about Pi Apps SDK and provided methods in detail +* [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code From e0cc85231feb9330276417d138d984dae7635a16 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 22:13:55 +0300 Subject: [PATCH 23/43] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0b19d983..91b891f4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Pi Demo App +https://github.com/Munawarmoja/demo Pi Demo App is an example of how you can implement the various required flows in your app's code. It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. From 6f67c67cce29c5af1df21a3b840b34a4f26bc1b5 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 22:40:50 +0300 Subject: [PATCH 24/43] Update README.md --- README.md | 59 ------------------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/README.md b/README.md index 91b891f4..53e24162 100644 --- a/README.md +++ b/README.md @@ -42,65 +42,6 @@ develop.pi in the Pi Browser to access the Developer Portal). This SDK is not for a server-side NodeJS app. -## Installation - -Add the following script tags to all pages where you need to call the Pi Apps SDK: - - - -This will load the Pi Network JS SDK as a global window.Pi object. - -## Usage - -### Authenticate a user - -You cannot perform any user-related operations (e.g read the user's info, request a payment from them) until you -have successfully authenticated the user. The first time, they will be presented with a dialog asking for -their consent to share their data with your app. - -// Authenticate the user, and get permission to request payments from them: -const scopes = ['payments']; - -// Read more about this callback in the SDK reference: -function onIncompletePaymentFound(payment) { /* ... */ }; - -Pi.authenticate(scopes, onIncompletePaymentFound).then(function(auth) { - console.log(`Hi there! You're ready to make payments!`); -}).catch(function(error) { - console.error(error); -}); -### Request a payment (User-To-App) - -The createPayment method enables you to request a payment from the current user to your app's account. - -The user will be prompted with a modal provided by the Pi Wallet, enabling them to sign the -transaction and submit it to the Pi Blockchain. - -Pi.createPayment({ - // Amount of π to be paid: - amount: 3.14, - // An explanation of the payment - will be shown to the user: - memo: "...", // e.g: "Digital kitten #1234", - // An arbitrary developer-provided metadata object - for your own usage: - metadata: { /* ... */ }, // e.g: { kittenId: 1234 } -}, { - // Callbacks you need to implement - read more about those in the detailed docs linked below: - onReadyForServerApproval: function(paymentId) { /* ... */ }, - onReadyForServerCompletion: function(paymentId, txid) { /* ... */ }, - onCancel: function(paymentId) { /* ... */ }, - onError: function(error, payment) { /* ... */ }, -}); - -### Request a payment (App-To-User) - -If you want to send Pi from your app to a user, you need to use one of Pi Network's backend SDKs, depending -on the language your backend is written in. Refer to the [Advanced payments guide](./payments_advanced.md) -for more information. - - - - - In order to make sure that all involved parties (your app, your server, the Pi servers, and the Pi Blockchain) are in sync, the payment needs to go through a Server-Side Approval flow (for User-to-App payment) and/or a Server-Side Completion flow (for all types of payments). From 4e6e3cd2d31b3222bc722ba912da3b035b8bf050 Mon Sep 17 00:00:00 2001 From: Gibee Date: Wed, 13 Nov 2024 23:22:10 +0300 Subject: [PATCH 25/43] Create Color Signed-off-by: Gibee --- .github/ISSUE_TEMPLATE/Color | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/Color diff --git a/.github/ISSUE_TEMPLATE/Color b/.github/ISSUE_TEMPLATE/Color new file mode 100644 index 00000000..bc3ab216 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Color @@ -0,0 +1,7 @@ +This XML file does not appear to have any style information associated with it. The document tree is shown below. + + +#FFFFFF +#000000 +#FF4081 + From 33ca967134cd15d6fab51240e2526d2ba8a7b61e Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 00:06:37 +0300 Subject: [PATCH 26/43] Update README.md --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 53e24162..b67d79aa 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,34 @@ Please refer to: * [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code +react-scripts build Creating an optimized production build... Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/my-project/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16) at handleParseError (/my-project/node_modules/webpack/lib/NormalModule.js:471:10) at /my-project/node_modules/webpack/lib/NormalModule.js:503:5 at /my-project/node_modules/webpack/lib/NormalModule.js:358:12 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:373:3 at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:214:10) at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:221:10) at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:236:3 at runSyncOrAsync (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:130:11) at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:232:2) at Array. (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:205:4) at Storage.finished (/my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16) at /my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9 /my-project/node_modules/react-scripts/scripts/build.js:19 throw err; ^ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/my-project/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16) at /my-project/node_modules/webpack/lib/NormalModule.js:452:10 at /my-project/node_modules/webpack/lib/NormalModule.js:323:13 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18 at context.callback (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13) at /my-project/node_modules/babel-loader/lib/index.js:59:103 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v17.0.0 ERROR: Job failed: exit status 1 + + + + + + +current version of create-react-app: 4.0.3 + running from /home/.npm/_npx/34113/lib/node_modules/create-react-app + + System: + OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri) + CPU: (4) x64 Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz + Binaries: + Node: 17.0.0 - /usr/bin/node + Yarn: Not Found + npm: 8.1.0 - /usr/bin/npm + Browsers: + Chrome: 95.0.4638.54 + Firefox: 93.0 + npmPackages: + react: ^16.13.1 => 16.13.1 + react-dom: ^16.13.1 => 16.13.1 + react-scripts: ^4.0.3 => 4.0.3 + npmGlobalPackages: + create-react-app: Not Found + + From 7fb43d28d846b7f606785cec968dc12c0f6ee118 Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 00:11:18 +0300 Subject: [PATCH 27/43] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b67d79aa..51e20d94 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ current version of create-react-app: 4.0.3 create-react-app: Not Found - +This XML file does not appear to have any style information associated with it. The document tree is shown below. + + +#FFFFFF +#000000 +#FF4081 + From 6d19db36a3e55cfb8093d60de005ca3c18949bd6 Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 00:55:23 +0300 Subject: [PATCH 28/43] Update .env.example --- .env.example | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 348d957c..0beca942 100644 --- a/.env.example +++ b/.env.example @@ -6,7 +6,6 @@ # # this is a comment: # FOO=value # ``` -b326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 # # # @@ -24,12 +23,15 @@ BACKEND_DOMAIN_NAME=backend.example.com # Domain validation key: -5f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 - DOMAIN_VALIDATION_KEY=todo_developer_portal # Pi Platform API Key: PI_API_KEY=todo_developer_portal +https://github.munawarmoja.com/validation-key.txt + +b326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 + +5f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 # Generate a random string, or roll your face on the keyboard to fill this value: SESSION_SECRET=abcd1324_TODO From b1ff050d4169f790fda76c6665a24e0e426d7191 Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 01:10:33 +0300 Subject: [PATCH 29/43] Update .env.example --- .env.example | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 0beca942..fe687494 100644 --- a/.env.example +++ b/.env.example @@ -22,16 +22,11 @@ BACKEND_DOMAIN_NAME=backend.example.com # Obtain the following 2 values on the Pi Developer Portal (open develop.pi in the Pi Browser). # Domain validation key: - +https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76435f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 DOMAIN_VALIDATION_KEY=todo_developer_portal # Pi Platform API Key: PI_API_KEY=todo_developer_portal -https://github.munawarmoja.com/validation-key.txt - -b326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 - -5f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 # Generate a random string, or roll your face on the keyboard to fill this value: SESSION_SECRET=abcd1324_TODO From ee6d9826c7a4ed734cbe9d99e7244d201c3b5aa1 Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 15:43:00 +0300 Subject: [PATCH 30/43] Update README.md --- README.md | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/README.md b/README.md index 51e20d94..540c27ab 100644 --- a/README.md +++ b/README.md @@ -55,40 +55,3 @@ Please refer to: * [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code -react-scripts build Creating an optimized production build... Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/my-project/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16) at handleParseError (/my-project/node_modules/webpack/lib/NormalModule.js:471:10) at /my-project/node_modules/webpack/lib/NormalModule.js:503:5 at /my-project/node_modules/webpack/lib/NormalModule.js:358:12 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:373:3 at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:214:10) at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:221:10) at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:236:3 at runSyncOrAsync (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:130:11) at iterateNormalLoaders (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:232:2) at Array. (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:205:4) at Storage.finished (/my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16) at /my-project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9 /my-project/node_modules/react-scripts/scripts/build.js:19 throw err; ^ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:67:19) at Object.createHash (node:crypto:130:10) at module.exports (/my-project/node_modules/webpack/lib/util/createHash.js:135:53) at NormalModule._initBuildHash (/my-project/node_modules/webpack/lib/NormalModule.js:417:16) at /my-project/node_modules/webpack/lib/NormalModule.js:452:10 at /my-project/node_modules/webpack/lib/NormalModule.js:323:13 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:367:11 at /my-project/node_modules/loader-runner/lib/LoaderRunner.js:233:18 at context.callback (/my-project/node_modules/loader-runner/lib/LoaderRunner.js:111:13) at /my-project/node_modules/babel-loader/lib/index.js:59:103 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v17.0.0 ERROR: Job failed: exit status 1 - - - - - - -current version of create-react-app: 4.0.3 - running from /home/.npm/_npx/34113/lib/node_modules/create-react-app - - System: - OS: Linux 5.13 Ubuntu 21.10 21.10 (Impish Indri) - CPU: (4) x64 Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz - Binaries: - Node: 17.0.0 - /usr/bin/node - Yarn: Not Found - npm: 8.1.0 - /usr/bin/npm - Browsers: - Chrome: 95.0.4638.54 - Firefox: 93.0 - npmPackages: - react: ^16.13.1 => 16.13.1 - react-dom: ^16.13.1 => 16.13.1 - react-scripts: ^4.0.3 => 4.0.3 - npmGlobalPackages: - create-react-app: Not Found - - -This XML file does not appear to have any style information associated with it. The document tree is shown below. - - -#FFFFFF -#000000 -#FF4081 - - - From a88c7ca1608472be82234faa41100f6af417e0ec Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 15:51:13 +0300 Subject: [PATCH 31/43] Update README.md --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 540c27ab..7469fcdb 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,54 @@ Please refer to: * [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code +# WARNING: Commenting after a variable's value DOES NOT WORK in .env files. +# In other words, don't to this: `FOO=value # this is a comment`. +# This would give the value "value # this is a comment" to the FOO variable. +# You need to use single-line comments instead, e.g: +# ``` +# # this is a comment: +# FOO=value +# ``` +# +# +# + +# Frontend app URL and bare domain name: +FRONTEND_URL=https://frontend.example.com +FRONTEND_DOMAIN_NAME=frontend.example.com + +# Backend app URL and bare domain name: +BACKEND_URL=https://backend.example.com +BACKEND_DOMAIN_NAME=backend.example.com + + +# Obtain the following 2 values on the Pi Developer Portal (open develop.pi in the Pi Browser). + +# Domain validation key: +https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76435f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 +DOMAIN_VALIDATION_KEY=todo_developer_portal +# Pi Platform API Key: +PI_API_KEY=todo_developer_portal + +# Generate a random string, or roll your face on the keyboard to fill this value: +SESSION_SECRET=abcd1324_TODO + +# MongoDB database connection details: +MONGODB_DATABASE_NAME=demoapp +MONGODB_USERNAME=demoapp +MONGODB_PASSWORD=abcd1234 + + +# This will be prepended to all container names. +# Changing this will make docker-compose lose track of all your containers. +# Run `docker-compose down` before changing it. +COMPOSE_PROJECT_NAME=pi-demo-app + +# Set this to either "development" or "production" (XXX "staging"?): +ENVIRONMENT=production + +# This directory will be used to store all persistent data needed by Docker (using volumes): +DATA_DIRECTORY=./docker-data + +# URL of the Pi Platform API - you should not need to change this. +PLATFORM_API_URL=https://api.minepi.com \ No newline at end of file From aaba545377c9e84ef81f7b9eaabe1f567356b6f4 Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 15:54:27 +0300 Subject: [PATCH 32/43] Update README.md --- README.md | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) diff --git a/README.md b/README.md index 7469fcdb..540c27ab 100644 --- a/README.md +++ b/README.md @@ -55,54 +55,3 @@ Please refer to: * [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code -# WARNING: Commenting after a variable's value DOES NOT WORK in .env files. -# In other words, don't to this: `FOO=value # this is a comment`. -# This would give the value "value # this is a comment" to the FOO variable. -# You need to use single-line comments instead, e.g: -# ``` -# # this is a comment: -# FOO=value -# ``` -# -# -# - -# Frontend app URL and bare domain name: -FRONTEND_URL=https://frontend.example.com -FRONTEND_DOMAIN_NAME=frontend.example.com - -# Backend app URL and bare domain name: -BACKEND_URL=https://backend.example.com -BACKEND_DOMAIN_NAME=backend.example.com - - -# Obtain the following 2 values on the Pi Developer Portal (open develop.pi in the Pi Browser). - -# Domain validation key: -https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76435f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 -DOMAIN_VALIDATION_KEY=todo_developer_portal -# Pi Platform API Key: -PI_API_KEY=todo_developer_portal - -# Generate a random string, or roll your face on the keyboard to fill this value: -SESSION_SECRET=abcd1324_TODO - -# MongoDB database connection details: -MONGODB_DATABASE_NAME=demoapp -MONGODB_USERNAME=demoapp -MONGODB_PASSWORD=abcd1234 - - -# This will be prepended to all container names. -# Changing this will make docker-compose lose track of all your containers. -# Run `docker-compose down` before changing it. -COMPOSE_PROJECT_NAME=pi-demo-app - -# Set this to either "development" or "production" (XXX "staging"?): -ENVIRONMENT=production - -# This directory will be used to store all persistent data needed by Docker (using volumes): -DATA_DIRECTORY=./docker-data - -# URL of the Pi Platform API - you should not need to change this. -PLATFORM_API_URL=https://api.minepi.com \ No newline at end of file From de04e73189426b88b50873ab3792906a93670d3b Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 16:17:11 +0300 Subject: [PATCH 33/43] Update README.md --- README.md | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/README.md b/README.md index 540c27ab..139597f9 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,2 @@ -# Pi Demo App - -https://github.com/Munawarmoja/demo -Pi Demo App is an example of how you can implement the various required flows in your app's code. -It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. - - -It is composed of two major parts: - -* **backend**: a backend app (a very simple JSON API built using Node and ExpressJS) -* **frontend**: a single-page frontend app (built using React and create-react-app) - - -Read [`doc/development.md`](./doc/development.md) to get started and learn how to run this app in development. - -> **WARNING** -> -> The demo app uses express session cookies which, in the Sandbox environment, are not correctly saved on the client on some browsers. -> To properly test all of the features of the Demo App, we recommend you to open the sandbox app using Mozilla Firefox. - - -## Deployment - -Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app on a server using Docker and docker-compose. - - -## Flows - -To dive into the implementation of the flows that support the demo app features, please refer to -[Pi Demo App Flows](./FLOWS.md). - - - - -Frontend Javascript SDK - -The JS SDK is the frontend SDK, designed to be used in your HTML pages or Single-Page Apps, served in the Pi Browser. - -In order to enable the SDK to function correctly, you need to declare your apps on the Developer Portal (open -develop.pi in the Pi Browser to access the Developer Portal). - -This SDK is not for a server-side NodeJS app. - - -In order to make sure that all involved parties (your app, your server, the Pi servers, and the Pi Blockchain) are in sync, -the payment needs to go through a Server-Side Approval flow (for User-to-App payment) and/or a Server-Side Completion -flow (for all types of payments). - -Please refer to: -* [the full Payments documentation](./payments.md) to learn about the complete payment flow -* [the Advanced Payments documentation](./payments_advanced.md) to learn about App-to-User payment flow -* [the Platform API documentation](./platform_API.md) to learn how to confirm the payment and acknowledge it from your - server -* [the client SDK documentation](./SDK_reference.md) to learn about Pi Apps SDK and provided methods in detail -* [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code From f6cbf5ee15b84aa57bad4eaa0b4ee42d7635ab2b Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 16:18:15 +0300 Subject: [PATCH 34/43] Update Munawarmoja --- Munawarmoja | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Munawarmoja b/Munawarmoja index 42bf91fd..c01163ad 100644 --- a/Munawarmoja +++ b/Munawarmoja @@ -1,3 +1,61 @@ +Pi Demo App + +https://github.com/Munawarmoja/demo +Pi Demo App is an example of how you can implement the various required flows in your app's code. +It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. + + +It is composed of two major parts: + +* **backend**: a backend app (a very simple JSON API built using Node and ExpressJS) +* **frontend**: a single-page frontend app (built using React and create-react-app) + + +Read [`doc/development.md`](./doc/development.md) to get started and learn how to run this app in development. + +> **WARNING** +> +> The demo app uses express session cookies which, in the Sandbox environment, are not correctly saved on the client on some browsers. +> To properly test all of the features of the Demo App, we recommend you to open the sandbox app using Mozilla Firefox. + + +## Deployment + +Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app on a server using Docker and docker-compose. + + +## Flows + +To dive into the implementation of the flows that support the demo app features, please refer to +[Pi Demo App Flows](./FLOWS.md). + + + + +Frontend Javascript SDK + +The JS SDK is the frontend SDK, designed to be used in your HTML pages or Single-Page Apps, served in the Pi Browser. + +In order to enable the SDK to function correctly, you need to declare your apps on the Developer Portal (open +develop.pi in the Pi Browser to access the Developer Portal). + +This SDK is not for a server-side NodeJS app. + + +In order to make sure that all involved parties (your app, your server, the Pi servers, and the Pi Blockchain) are in sync, +the payment needs to go through a Server-Side Approval flow (for User-to-App payment) and/or a Server-Side Completion +flow (for all types of payments). + +Please refer to: +* [the full Payments documentation](./payments.md) to learn about the complete payment flow +* [the Advanced Payments documentation](./payments_advanced.md) to learn about App-to-User payment flow +* [the Platform API documentation](./platform_API.md) to learn how to confirm the payment and acknowledge it from your + server +* [the client SDK documentation](./SDK_reference.md) to learn about Pi Apps SDK and provided methods in detail +* [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code + + + # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] From d8fb038839f9bf48c30776b4ed9a6249e6a5870e Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 16:21:41 +0300 Subject: [PATCH 35/43] Update README.md --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/README.md b/README.md index 139597f9..d078a89f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,57 @@ +Pi Demo App + +https://github.com/Munawarmoja/demo +Pi Demo App is an example of how you can implement the various required flows in your app's code. +It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. + + +It is composed of two major parts: + +* **backend**: a backend app (a very simple JSON API built using Node and ExpressJS) +* **frontend**: a single-page frontend app (built using React and create-react-app) + + +Read [`doc/development.md`](./doc/development.md) to get started and learn how to run this app in development. + +> **WARNING** +> +> The demo app uses express session cookies which, in the Sandbox environment, are not correctly saved on the client on some browsers. +> To properly test all of the features of the Demo App, we recommend you to open the sandbox app using Mozilla Firefox. + + +## Deployment + +Read [`doc/deployment.md`](./doc/deployment.md) to learn how to deploy this app on a server using Docker and docker-compose. + + +## Flows + +To dive into the implementation of the flows that support the demo app features, please refer to +[Pi Demo App Flows](./FLOWS.md). + + + + +Frontend Javascript SDK + +The JS SDK is the frontend SDK, designed to be used in your HTML pages or Single-Page Apps, served in the Pi Browser. + +In order to enable the SDK to function correctly, you need to declare your apps on the Developer Portal (open +develop.pi in the Pi Browser to access the Developer Portal). + +This SDK is not for a server-side NodeJS app. + + +In order to make sure that all involved parties (your app, your server, the Pi servers, and the Pi Blockchain) are in sync, +the payment needs to go through a Server-Side Approval flow (for User-to-App payment) and/or a Server-Side Completion +flow (for all types of payments). + +Please refer to: +* [the full Payments documentation](./payments.md) to learn about the complete payment flow +* [the Advanced Payments documentation](./payments_advanced.md) to learn about App-to-User payment flow +* [the Platform API documentation](./platform_API.md) to learn how to confirm the payment and acknowledge it from your + server +* [the client SDK documentation](./SDK_reference.md) to learn about Pi Apps SDK and provided methods in detail +* [the Demo App](https://github.com/pi-apps/demo) to view an example of how you can implement the various required flows in your app's code From 6dc21030649c40a42a90247834c59b51cebdc49d Mon Sep 17 00:00:00 2001 From: Gibee Date: Thu, 14 Nov 2024 16:47:16 +0300 Subject: [PATCH 36/43] Update Munawarmoja --- Munawarmoja | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Munawarmoja b/Munawarmoja index c01163ad..f554f130 100644 --- a/Munawarmoja +++ b/Munawarmoja @@ -1,3 +1,71 @@ + +Pi Demo App Flows + +- [Authentication](#authentication) + - [Pi.authenticate()](#1-obtain-user-data-with-piauthenticate-sdk-method) + - [GET /me Platform API endpoint](#2-verify-the-user-by-calling-pi-platform-api-get-me-endpoint) +- [Payments](#payments) + - [onReadyForServerApproval](#1-onreadyforserverapproval) + - [onReadyForServerCompletion](#2-onreadyforservercompletion) + - [onCancel](#3-oncancel) + - [onError](#4-onerror) + - [onIncompletePaymentFound](#onincompletepaymentfound) + +## Authentication + +User authentication consists of two steps: + +1. obtaining user accessToken using Pi SDK +2. verifying accessToken using Pi Platform API + +
+ +> Disclaimer: +> +> Pi SDK method Pi.authenticate() should only be used to retrieve user accessToken and MUST be verified on the backend side of your app. +> +> For a detailed guide on how to use Pi SDK, please refer to [SDK Docs](https://github.com/pi-apps/pi-platform-docs/blob/master/SDK_reference.md) +> +> Pi Platform API should remain the only source of truth about user data in your app (a malicious user could tamper with the requests and send you wrong data). +> +> For a detailed guide on how to use Pi Platform API, please refer to [Platform API Docs](https://github.com/pi-apps/pi-platform-docs/blob/master/platform_API.md) + +
+ +### 1. Obtain user data with Pi.authenticate() SDK method + +Pi.authenticate() method takes in two arguments: scopes and onIncompletePaymentFound and returns AuthResult object with different keys available. + +scopes determine what keys are available on the AuthResult object. For full documentation on available scopes, please refer to [SDK Docs](https://github.com/pi-apps/pi-platform-docs/blob/master/SDK_reference.md#scopes). + +onIncompletePaymentFound is a function that connects both Authorization and Payments flows. To preview example implementation, proceed to [onIncompletePaymentFound](#onincompletepaymentfound) section. + +// frontend/src/shop/index.ts + +const signIn = async () => { + const scopes = ["username", "payments"]; + const authResponse = await window.Pi.authenticate(scopes, onIncompletePaymentFound); + + /* pass obtained data to backend */ + await signInUser(authResponse); + + /* use the obtained data however you want */ + setUser(authResponse.user); +}; + +const signInUser = (authResult: any) => { + axiosClient.post("/signin", { authResult }, config); + + return setShowModal(false); +}; +
+ +### 2. Verify the user by calling Pi Platform API GET /me endpoint + +
+ + + Pi Demo App https://github.com/Munawarmoja/demo From ff28635e7b62641b4a5cc1774ba142d5c09d0b3b Mon Sep 17 00:00:00 2001 From: Gibee Date: Fri, 15 Nov 2024 13:17:21 +0300 Subject: [PATCH 37/43] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d078a89f..1fc506ee 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ -Pi Demo App -https://github.com/Munawarmoja/demo Pi Demo App is an example of how you can implement the various required flows in your app's code. It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. From 6449539c823463f336e858b08cdda38d0b27a338 Mon Sep 17 00:00:00 2001 From: Gibee Date: Fri, 15 Nov 2024 13:20:21 +0300 Subject: [PATCH 38/43] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1fc506ee..182b3d02 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - - +validation-key +https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 Pi Demo App is an example of how you can implement the various required flows in your app's code. It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. From 0f4f4ad80809cf15d672d8366839dec19556ed3a Mon Sep 17 00:00:00 2001 From: Gibee Date: Fri, 15 Nov 2024 23:06:24 +0300 Subject: [PATCH 39/43] Update README.md. --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 182b3d02..fc1ecfe7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,29 @@ validation-key https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 + + + +environment: + name: github-pages + url: ${{ steps.change-page-url.outputs.new_page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy docs to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 + - name: Override page_url + id: change-page-url + run: echo "new_page_url=${{ steps.deployment.outputs.page_url }}notebook/" >> $GITHUB_OUTPUT + + + + + + + + + Pi Demo App is an example of how you can implement the various required flows in your app's code. It aims to show you how to use Pi Platform API on the backend side and Pi SDK on the frontend side of your app. From 6206d0dea0afddd8494c25739a66b6499c549088 Mon Sep 17 00:00:00 2001 From: Gibee Date: Fri, 15 Nov 2024 23:07:42 +0300 Subject: [PATCH 40/43] Update README.md --- README.md | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/README.md b/README.md index fc1ecfe7..3321c6c0 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,5 @@ validation-key -https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 - - - -environment: - name: github-pages - url: ${{ steps.change-page-url.outputs.new_page_url }} - - runs-on: ubuntu-latest - steps: - - name: Deploy docs to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 - - name: Override page_url - id: change-page-url - run: echo "new_page_url=${{ steps.deployment.outputs.page_url }}notebook/" >> $GITHUB_OUTPUT - - - - - - - +https://github.com.munawarmoja/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 Pi Demo App is an example of how you can implement the various required flows in your app's code. From de34565f83a621efb5239006a9219a24cc2431b0 Mon Sep 17 00:00:00 2001 From: Gibee Date: Fri, 15 Nov 2024 23:15:11 +0300 Subject: [PATCH 41/43] Update .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index fe687494..7a213dda 100644 --- a/.env.example +++ b/.env.example @@ -22,7 +22,7 @@ BACKEND_DOMAIN_NAME=backend.example.com # Obtain the following 2 values on the Pi Developer Portal (open develop.pi in the Pi Browser). # Domain validation key: -https://github.munawarmoja.com/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76435f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 +https://github.com.munawarmojavalidation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76435f6e156bb951c8883117f9b3a26e895fc82b6b264c9cf49f3922a3f2ab36282fcc460889388b307f90018d834b02b9c7582529014233b75a18806041b3cac821 DOMAIN_VALIDATION_KEY=todo_developer_portal # Pi Platform API Key: PI_API_KEY=todo_developer_portal From 9ecd5673d38848f834407f111aa07a529b673703 Mon Sep 17 00:00:00 2001 From: Gibee Date: Sat, 16 Nov 2024 23:13:01 +0300 Subject: [PATCH 42/43] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 3321c6c0..1fc506ee 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -validation-key -https://github.com.munawarmoja/validation-key.txtb326b315d412570cbfa80e810e6f069e364b65eef8374a4c995264501110d518a8455d30c753c197f3aae087db225fe9f051b3080293ba45be3c0aa6b7b76439 Pi Demo App is an example of how you can implement the various required flows in your app's code. From 2f248e205558705af328fed0e8ce51592e6b18af Mon Sep 17 00:00:00 2001 From: Gibee Date: Sat, 16 Nov 2024 23:37:44 +0300 Subject: [PATCH 43/43] Update docker-compose.yml --- docker-compose.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 12850b54..71c7c72a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,16 @@ +apt-get update && \ +apt-get install -y zip apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \ +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ +add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \ +apt-get update && \ +apt-get install -y docker-ce docker-ce-cli containerd.io && \ +curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \ +chmod +x /usr/local/bin/docker-compose + + + + + version: "3.9" services: