Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize workspaces into packages and apps #128

Merged
merged 13 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/odis-combiner-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ name: Build ODIS combiner image
on:
push:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-combiner'
- 'packages/phone-number-privacy/combiner/**'
- 'dockerfiles//Dockerfile-combiner'
- 'apps/combiner/**'
branches:
- main
pull_request:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-combiner'
- 'packages/phone-number-privacy/combiner/**'
- 'dockerfiles//Dockerfile-combiner'
- 'apps/combiner/**'
workflow_dispatch:

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/odis-combiner
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-combiner
file: dockerfiles//Dockerfile-combiner
trivy: true

odis-combiner-build:
Expand All @@ -40,5 +40,5 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/social-connect/odis-combiner
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-combiner
file: dockerfiles//Dockerfile-combiner
trivy: true
12 changes: 6 additions & 6 deletions .github/workflows/odis-loadtest-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ name: Build ODIS loadtest image
on:
push:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-loadtest'
- 'packages/phone-number-privacy/monitor/**'
- 'dockerfiles//Dockerfile-loadtest'
- 'apps/monitor/**'
branches:
- main
pull_request:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-loadtest'
- 'packages/phone-number-privacy/monitor/**'
- 'dockerfiles//Dockerfile-loadtest'
- 'apps/monitor/**'
workflow_dispatch:

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/odis-loadtest
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-loadtest
file: dockerfiles//Dockerfile-loadtest
trivy: true

odis-loadtest-build:
Expand All @@ -40,5 +40,5 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/social-connect/odis-loadtest
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-loadtest
file: dockerfiles//Dockerfile-loadtest
trivy: true
12 changes: 6 additions & 6 deletions .github/workflows/odis-signer-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ name: Build ODIS signer image
on:
push:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-signer'
- 'packages/phone-number-privacy/signer/**'
- 'dockerfiles//Dockerfile-signer'
- 'apps/signer/**'
branches:
- main
pull_request:
paths:
- 'dockerfiles/phone-number-privacy/Dockerfile-signer'
- 'packages/phone-number-privacy/signer/**'
- 'dockerfiles//Dockerfile-signer'
- 'apps/signer/**'
workflow_dispatch:

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/odis-signer
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-signer
file: dockerfiles//Dockerfile-signer
trivy: true

odis-signer-build:
Expand All @@ -40,5 +40,5 @@ jobs:
artifact-registry: us-west1-docker.pkg.dev/devopsre/social-connect/odis-signer
tag: ${{ github.sha }}
context: .
file: dockerfiles/phone-number-privacy/Dockerfile-signer
file: dockerfiles//Dockerfile-signer
trivy: true
15 changes: 8 additions & 7 deletions .github/workflows/social-connect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ jobs:
yarn --cwd=packages/odis-identifiers test
- name: Run Encrypted Backup tests
run: |
yarn --cwd=packages/sdk/encrypted-backup test
yarn --cwd=packages/encrypted-backup test
- name: Run Identity Tests
run: |
yarn --cwd=packages/sdk/identity test
yarn --cwd=packages/identity test

- name: Upload Jest Test Results
uses: actions/upload-artifact@v3
Expand All @@ -220,7 +220,7 @@ jobs:
needs: install-dependencies
if: |
github.base_ref == 'main' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/phone-number-privacy/combiner') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'apps/combiner') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
Expand All @@ -237,7 +237,7 @@ jobs:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- name: Run Tests for combiner
run: |
yarn --cwd=packages/phone-number-privacy/combiner test:coverage
yarn --cwd=apps/combiner test:coverage
odis-test:
name: ODIS (signer + common) test
needs: install-dependencies
Expand All @@ -247,7 +247,8 @@ jobs:
timeout-minutes: 30
if: |
github.base_ref == 'main' || contains(github.base_ref, 'staging') || contains(github.base_ref, 'production') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages/phone-number-privacy') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'packages') ||
contains(needs.install-dependencies.outputs.all_modified_files, 'apps/signer') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',package.json') ||
contains(needs.install-dependencies.outputs.all_modified_files, ',yarn.lock') ||
false
Expand All @@ -264,7 +265,7 @@ jobs:
package-json-checksum: ${{ needs.install-dependencies.outputs.package-json-checksum }}
- name: Run Tests for common package
run: |
yarn --cwd=packages/phone-number-privacy/common test:coverage
yarn --cwd=packages/common test:coverage
- name: Run Tests for signer
run: |
yarn --cwd=packages/phone-number-privacy/signer test:coverage
yarn --cwd=apps/signer test:coverage
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--rootDir",
"${workspaceFolder}/packages/phone-number-privacy",
"${workspaceFolder}/packages",
"--runInBand",
"${workspaceFolder}/packages/phone-number-privacy/combiner/test/**",
"${workspaceFolder}/apps/combiner/test/**",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand All @@ -25,9 +25,9 @@
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"--rootDir",
"${workspaceFolder}/packages/phone-number-privacy/signer",
"${workspaceFolder}/apps/signer",
"--runInBand",
"${workspaceFolder}/packages/phone-number-privacy/signer/test/**",
"${workspaceFolder}/apps/signer/test/**",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ You can test your mainnet service is set up correctly by running specific tests

### Logs

Error logs will be prefixed with `CELO_ODIS_ERROR_XX`. You can see a full list of them in [errors.ts](https://github.com/celo-org/celo-monorepo/blob/master/packages/phone-number-privacy/common/src/interfaces/errors.ts) in the common package.
Error logs will be prefixed with `CELO_ODIS_ERROR_XX`. You can see a full list of them in [errors.ts](https://github.com/celo-org/celo-monorepo/blob/master/packages/common/src/interfaces/errors.ts) in the common package.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Prerequisites

- awscli (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html)
- AWS credentials configured (https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
- awscli (<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html>)
- AWS credentials configured (<https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html>)

## Steps

Expand Down Expand Up @@ -35,7 +35,7 @@ For the DB Instance size, `Free tier` should be enough.
### Running the Signer on Fargate

ECS Fargate is a container execution service provided by AWS. It runs containers without requiring explicit management of hosts or virtual machines.
Alternatively the signer service can be run using any other service that allows to run containers, such as EC2 or EKS. In the case of EC2, you will need to install docker, configure the instance profile and follow the documentation from [the signer readme](https://github.com/celo-org/celo-monorepo/tree/master/packages/phone-number-privacy/signer).
Alternatively the signer service can be run using any other service that allows to run containers, such as EC2 or EKS. In the case of EC2, you will need to install docker, configure the instance profile and follow the documentation from [the signer readme](https://github.com/celo-org/celo-monorepo/tree/master/apps/signer).

1. Create the service-linked role. If it is the first time you run ECS on your account you will need to run this command.

Expand All @@ -44,7 +44,7 @@ Alternatively the signer service can be run using any other service that allows
```

1. Create a Task Role for the signer ([documentation](https://docs.amazonaws.cn/en_us/AmazonECS/latest/userguide/ecs-cli-tutorial-fargate.html)).
First we will create the `assume-role` policy that allows ECS tasks to be assigned to this task role.
First we will create the `assume-role` policy that allows ECS tasks to be assigned to this task role.

```bash
cat <<'EOF' > /tmp/task-execution-assume-role.json
Expand All @@ -70,7 +70,7 @@ First we will create the `assume-role` policy that allows ECS tasks to be assign
aws iam --region us-east-2 create-role --role-name signerTaskExecutionRole --assume-role-policy-document file:///tmp/task-execution-assume-role.json
```

Finally we create the policy assigned to this task-role that allows retrieval of secrets from AWS Secret Manager. Then we attach that policy to the task role.
Finally we create the policy assigned to this task-role that allows retrieval of secrets from AWS Secret Manager. Then we attach that policy to the task role.

```bash
cat <<'EOF' > /tmp/secret-manager-signer-policy.json
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ coverage:
target: auto
threshold: null
removed_code_behavior: adjust_base
odis:
packages:
paths:
- packages/phone-number-privacy
sdk:
- packages/
apps:
paths:
- packages/sdk
- apps/
patch: off
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ FROM scratch AS packages
# Assemble all dependencies into the packages folder so the second stage can select whether to
# include all packages, or just the phone-number-privacy packages.
WORKDIR /celo-phone-number-privacy/
COPY packages/phone-number-privacy/combiner packages/phone-number-privacy/combiner
COPY packages/phone-number-privacy/common packages/phone-number-privacy/common
COPY packages/sdk/encrypted-backup packages/sdk/encrypted-backup
COPY packages/sdk/identity packages/sdk/identity
COPY apps/combiner apps/combiner
COPY packages/common packages/common
COPY packages/encrypted-backup packages/encrypted-backup
COPY packages/identity packages/identity
COPY packages/odis-identifiers packages/odis-identifiers

##### Main stage
Expand Down Expand Up @@ -39,6 +39,6 @@ RUN rm -r .git

# Setup and run the combiner application.
ENV NODE_ENV production
WORKDIR /celo-phone-number-privacy/packages/phone-number-privacy/combiner
WORKDIR /celo-phone-number-privacy/apps/combiner
EXPOSE 8080
ENTRYPOINT ["yarn", "start:docker"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ FROM scratch AS packages
# Assemble all dependencies into the packages folder so the second stage can select whether to
# include all packages, or just the phone-number-privacy packages.
WORKDIR /celo-phone-number-privacy/
COPY packages/phone-number-privacy/monitor packages/phone-number-privacy/monitor
COPY packages/phone-number-privacy/common packages/phone-number-privacy/common
COPY packages/sdk/encrypted-backup packages/sdk/encrypted-backup
COPY packages/sdk/identity packages/sdk/identity
COPY apps/monitor apps/monitor
COPY packages/common packages/common
COPY packages/encrypted-backup packages/encrypted-backup
COPY packages/identity packages/identity
COPY packages/odis-identifiers packages/odis-identifiers

##### Main stage
Expand Down Expand Up @@ -41,6 +41,6 @@ RUN rm -r .git

# Setup and run the signer application.
ENV NODE_ENV production
WORKDIR /celo-phone-number-privacy/packages/phone-number-privacy/monitor
WORKDIR /celo-phone-number-privacy/apps/monitor
EXPOSE 8080
ENTRYPOINT ["yarn", "loadTest"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ FROM scratch AS packages
# Assemble all dependencies into the packages folder so the second stage can select whether to
# include all packages, or just the phone-number-privacy packages.
WORKDIR /celo-phone-number-privacy/
COPY packages/phone-number-privacy/signer packages/phone-number-privacy/signer
COPY packages/phone-number-privacy/common packages/phone-number-privacy/common
COPY packages/sdk/encrypted-backup packages/sdk/encrypted-backup
COPY packages/sdk/identity packages/sdk/identity
COPY apps/signer apps/signer
COPY packages/common packages/common
COPY packages/encrypted-backup packages/encrypted-backup
COPY packages/identity packages/identity
COPY packages/odis-identifiers packages/odis-identifiers

##### Main stage
Expand Down Expand Up @@ -40,6 +40,6 @@ RUN rm -r .git

# Setup and run the signer application.
ENV NODE_ENV production
WORKDIR /celo-phone-number-privacy/packages/phone-number-privacy/signer
WORKDIR /celo-phone-number-privacy/apps/signer
EXPOSE 8080
ENTRYPOINT ["yarn", "start:docker"]
6 changes: 3 additions & 3 deletions docs/privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Below describes the steps to derive the *obfuscated identifier*, which is public
|**pepper**| Unique secret, obtained by taking the first 13 characters of the sha256 hash of the *unblinded signature*|
|**obfuscated identifier**| Identifier used for on-chain attestations, obtained by hashing the *plaintext identifier*, *identifier prefix*, and *pepper* using this schema: `sha3(sha3({prefix}://{plaintextIdentifier})__{pepper})`. For backwards compatibility, identifiers that are phone numbers use this schema: `sha3({prefix}://{plaintextIdentifier}__{pepper})`|

You can see these steps implemented in the `@celo/identity` sdk [here](https://github.com/celo-org/socialconnect/blob/main/packages/sdk/identity/src/odis/identifier.ts).
You can see these steps implemented in the `@celo/identity` sdk [here](https://github.com/celo-org/socialconnect/blob/main/packages/identity/src/odis/identifier.ts).

Here is a concrete example:

Expand All @@ -45,7 +45,7 @@ Here is a concrete example:

Each identifier type has a corresponding prefix that is appended before the blinding and hashing. This prevents identifiers from different sources from having the same pepper (ie. if you have the same handle for twitter and instagram, the obfuscated identifier should be different for each).

These are the prefixes currently defined in the SDK. We are using [DID methods](https://w3c.github.io/did-spec-registries/#did-methods) as prefixes when they exist. We welcome PRs here and [in the SDK](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/identity/src/odis/identifier.ts#L27-L34) if you'd like to add a new identifier type and prefix! You can also cast an arbitrary string as your prefix if you would like.
These are the prefixes currently defined in the SDK. We are using [DID methods](https://w3c.github.io/did-spec-registries/#did-methods) as prefixes when they exist. We welcome PRs here and [in the SDK](https://github.com/celo-org/celo-monorepo/blob/master/packages/identity/src/odis/identifier.ts#L27-L34) if you'd like to add a new identifier type and prefix! You can also cast an arbitrary string as your prefix if you would like.

| Type | Prefix |
|---------|--------|
Expand Down Expand Up @@ -169,7 +169,7 @@ await OdisUtils.Identifier.getObfuscatedIdentifier(
// unblindedSignature: '9as8duf98as...df80u'
// }
```
*Source code for `getObfuscatedIdentifier` and other relevant functions [here](https://github.com/celo-org/celo-monorepo/blob/master/packages/sdk/identity/src/odis/identifier.ts)*
*Source code for `getObfuscatedIdentifier` and other relevant functions [here](https://github.com/celo-org/celo-monorepo/blob/master/packages/identity/src/odis/identifier.ts)*

-------------

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"reset-modules": "rm -rf node_modules/ packages/*/node_modules",
"reset-yarn": "yarn cache clean",
"test": "yarn workspaces foreach --all run test",
"test:fast": "yarn workspaces foreach -ip --since --exclude '{odis,packages/phone-number-privacy/combiner}' run test",
"test:fast": "yarn workspaces foreach -ip --since --exclude '{odis,apps/combiner}' run test",
"build": "yarn workspaces foreach --all -pitv run build",
"build:fast": "yarn workspaces foreach -pitv --since run build",
"clean": "yarn workspaces foreach --all -piv run clean",
Expand All @@ -32,8 +32,7 @@
},
"workspaces": [
"packages/*",
"packages/phone-number-privacy/*",
"packages/sdk/*",
"apps/*",
"docs/examples"
],
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Celo",
"license": "Apache-2.0",
"homepage": "https://celo-sdk-docs.readthedocs.io/en/latest/encrypted-backup",
"repository": "https://github.com/celo-org/social-connect/tree/main/packages/sdk/encrypted-backup",
"repository": "https://github.com/celo-org/social-connect/tree/main/packages/encrypted-backup",
"keywords": [
"celo",
"blockchain",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Celo",
"license": "Apache-2.0",
"homepage": "https://celo-sdk-docs.readthedocs.io/en/latest/identity",
"repository": "https://github.com/celo-org/social-connect/tree/main/packages/sdk/identity",
"repository": "https://github.com/celo-org/social-connect/tree/main/packages/identity",
"keywords": [
"celo",
"blockchain",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
],
"references": [
{"path":"./docs/examples","name":"odis-example-scripts"},
{"path":"./packages/phone-number-privacy/combiner","name":"@celo/phone-number-privacy-combiner"},
{"path":"./packages/phone-number-privacy/common","name":"@celo/phone-number-privacy-common"},
{"path":"./packages/phone-number-privacy/monitor","name":"@celo/phone-number-privacy-monitor"},
{"path":"./packages/phone-number-privacy/signer","name":"@celo/phone-number-privacy-signer"},
{"path":"./packages/sdk/encrypted-backup","name":"@celo/encrypted-backup"},
{"path":"./packages/sdk/identity","name":"@celo/identity"},
{"path":"./apps/combiner","name":"@celo/phone-number-privacy-combiner"},
{"path":"./packages/common","name":"@celo/phone-number-privacy-common"},
{"path":"./apps/monitor","name":"@celo/phone-number-privacy-monitor"},
{"path":"./apps/signer","name":"@celo/phone-number-privacy-signer"},
{"path":"./packages/encrypted-backup","name":"@celo/encrypted-backup"},
{"path":"./packages/identity","name":"@celo/identity"},
]
}

Expand Down
Loading
Loading