-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(platform): Extract relay into separate services (#2823)
* Split relay into multiple services - no GHA workflows yet * lint errors * Fixes and GHA workflows * Corrects old masked email pattern * Error, check utils, source account retrieval tweaks and worker renames * Add missing lock file from renames in prev commit * Cleanup of types and added eslint * yarn :/ * More eslint * Rename workflow and env vars from relay to email.
- Loading branch information
1 parent
d7fb632
commit 5ca7b8c
Showing
43 changed files
with
964 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Singleton Email distributor | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: platform/emaildistributor | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: cachix/install-nix-action@v18 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
|
||
- run: nix-build ../platform.nix | ||
|
||
- name: Cache Dependencies | ||
id: cache-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
.yarn | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }} | ||
|
||
- name: Install Dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn run test | ||
|
||
- name: Deploy | ||
uses: cloudflare/[email protected] | ||
with: | ||
wranglerVersion: '3.19.0' | ||
apiToken: ${{ secrets.TOKEN_CLOUDFLARE_API }} | ||
accountId: ${{ secrets.INTERNAL_CLOUDFLARE_ACCOUNT_ID }} | ||
workingDirectory: platform/emaildistributor | ||
command: publish | ||
secrets: | | ||
SECRET_EMAIL_DISTRIBUTION_MAP | ||
env: | ||
SECRET_EMAIL_DISTRIBUTION_MAP: ${{ secrets.SECRET_EMAIL_DISTRIBUTION_MAP }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Mail Email inbounder | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
working-directory: platform/emailinbounder | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: dev | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: cachix/install-nix-action@v18 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
|
||
- run: nix-build ../platform.nix | ||
|
||
- name: Cache Dependencies | ||
id: cache-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
.yarn | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }} | ||
|
||
- name: Install Dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn run test | ||
|
||
- name: Deploy | ||
uses: cloudflare/[email protected] | ||
with: | ||
wranglerVersion: '3.19.0' | ||
apiToken: ${{ secrets.TOKEN_CLOUDFLARE_API }} | ||
accountId: ${{ secrets.INTERNAL_CLOUDFLARE_ACCOUNT_ID }} | ||
workingDirectory: platform/emailinbounder | ||
command: publish | ||
secrets: | | ||
SECRET_EMAIL_DISTRIBUTION_MAP | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY | ||
env: | ||
SECRET_EMAIL_DISTRIBUTION_MAP: ${{ secrets.SECRET_EMAIL_DISTRIBUTION_MAP }} | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY: ${{secrets.INTERNAL_EMAIL_DISTRIBUTION_KEY_DEV }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Next Email inbounder | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
defaults: | ||
run: | ||
working-directory: platform/emailinbounder | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: next | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: cachix/install-nix-action@v18 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
|
||
- run: nix-build ../platform.nix | ||
|
||
- name: Cache Dependencies | ||
id: cache-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
.yarn | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }} | ||
|
||
- name: Install Dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn run test | ||
|
||
- name: Deploy | ||
uses: cloudflare/[email protected] | ||
with: | ||
wranglerVersion: '3.19.0' | ||
apiToken: ${{ secrets.TOKEN_CLOUDFLARE_API }} | ||
accountId: ${{ secrets.INTERNAL_CLOUDFLARE_ACCOUNT_ID }} | ||
workingDirectory: platform/emailinbounder | ||
command: publish --config wrangler.next.toml --env next | ||
environment: 'next' | ||
secrets: | | ||
SECRET_EMAIL_DISTRIBUTION_MAP | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY | ||
env: | ||
SECRET_EMAIL_DISTRIBUTION_MAP: ${{ secrets.SECRET_EMAIL_DISTRIBUTION_MAP }} | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY: ${{secrets.INTERNAL_EMAIL_DISTRIBUTION_KEY_TEST }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Release Email inbounder | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
defaults: | ||
run: | ||
working-directory: platform/emailinbounder | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: prod | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: cachix/install-nix-action@v18 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
|
||
- run: nix-build ../platform.nix | ||
|
||
- name: Cache Dependencies | ||
id: cache-modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
node_modules | ||
.yarn | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }} | ||
|
||
- name: Install Dependencies | ||
run: yarn install | ||
|
||
- name: Test | ||
run: yarn run test | ||
|
||
- name: Deploy | ||
uses: cloudflare/[email protected] | ||
with: | ||
wranglerVersion: '3.19.0' | ||
apiToken: ${{ secrets.TOKEN_CLOUDFLARE_API }} | ||
accountId: ${{ secrets.INTERNAL_CLOUDFLARE_ACCOUNT_ID }} | ||
workingDirectory: platform/emailinbounder | ||
command: publish --config wrangler.current.toml --env current | ||
environment: 'current' | ||
secrets: | | ||
SECRET_EMAIL_DISTRIBUTION_MAP | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY | ||
env: | ||
SECRET_EMAIL_DISTRIBUTION_MAP: ${{ secrets.SECRET_EMAIL_DISTRIBUTION_MAP }} | ||
INTERNAL_EMAIL_DISTRIBUTION_KEY: ${{secrets.INTERNAL_EMAIL_DISTRIBUTION_KEY_PROD }} |
Binary file added
BIN
+296 KB
.yarn/cache/@cloudflare-workers-types-npm-4.20221111.1-69d0ea0925-6ee1ba28ee.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
platform/account/src/jsonrpc/methods/getSourceFromMaskedAddress.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { z } from 'zod' | ||
import { router } from '@proofzero/platform.core' | ||
import { EDGE_ACCOUNT } from '@proofzero/platform.account/src/constants' | ||
import { Context } from '../../context' | ||
import { EmailAccountType } from '@proofzero/types/account' | ||
import { AccountURN, AccountURNSpace } from '@proofzero/urns/account' | ||
import { | ||
BadRequestError, | ||
InternalServerError, | ||
NotFoundError, | ||
} from '@proofzero/errors' | ||
import { generateHashedIDRef } from '@proofzero/packages/urns/idref' | ||
import { EmailAccount, initAccountNodeByName } from '../../nodes' | ||
|
||
export const GetSourceByMaskedAddressInput = z.object({ | ||
maskedEmail: z.string(), | ||
}) | ||
|
||
export const GetSourceByMaskedAddressOutput = z.object({ | ||
nickname: z.string(), | ||
sourceEmail: z.string(), | ||
}) | ||
|
||
type GetSourceByMaskedAddressParams = z.infer< | ||
typeof GetSourceByMaskedAddressInput | ||
> | ||
type GetSourceByMaskedAddressResult = z.infer< | ||
typeof GetSourceByMaskedAddressOutput | ||
> | ||
|
||
export const getSourceFromMaskedAddressMethod = async ({ | ||
input, | ||
ctx, | ||
}: { | ||
input: GetSourceByMaskedAddressParams | ||
ctx: Context | ||
}): Promise<GetSourceByMaskedAddressResult> => { | ||
const nss = generateHashedIDRef(EmailAccountType.Mask, input.maskedEmail) | ||
const urn = AccountURNSpace.componentizedUrn(nss) | ||
const node = initAccountNodeByName(urn, ctx.env.Account) | ||
|
||
const emailNode = new EmailAccount(node, ctx.env) | ||
const sourceAccountURN = await emailNode.getSourceAccount() | ||
if (!sourceAccountURN) | ||
throw new NotFoundError({ | ||
message: `Could not find hidden address ${input.maskedEmail}`, | ||
}) | ||
|
||
const sourceAccountNode = initAccountNodeByName( | ||
sourceAccountURN, | ||
ctx.env.Account | ||
) | ||
|
||
const name = (await sourceAccountNode.class.getNickname()) || '' | ||
const address = await sourceAccountNode.class.getAddress() | ||
|
||
if (!address) | ||
throw new InternalServerError({ | ||
message: `Could not find source address for masked email ${input.maskedEmail}`, | ||
}) | ||
|
||
return { sourceEmail: address, nickname: name } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.