-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #684 from xmtp/rygine/merge-web-packages
Merge `consent-proof-signature` and `frames-client` from web repo
- Loading branch information
Showing
42 changed files
with
1,579 additions
and
229 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Packages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
paths: | ||
- "packages/**" | ||
- ".github/workflows/packages.yml" | ||
- "dev/**" | ||
- ".node-version" | ||
- ".nvmrc" | ||
- ".yarnrc.yml" | ||
- "turbo.json" | ||
- "yarn.lock" | ||
|
||
jobs: | ||
typecheck: | ||
name: Typecheck | ||
runs-on: warp-ubuntu-latest-x64-8x | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "yarn" | ||
env: | ||
SKIP_YARN_COREPACK_CHECK: "1" | ||
- name: Enable corepack | ||
run: corepack enable | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Typecheck | ||
run: yarn turbo run typecheck --filter='./packages/*' | ||
|
||
test: | ||
name: Test | ||
runs-on: warp-ubuntu-latest-x64-8x | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "yarn" | ||
env: | ||
SKIP_YARN_COREPACK_CHECK: "1" | ||
- name: Enable corepack | ||
run: corepack enable | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Start dev environment | ||
run: ./dev/up | ||
- name: Sleep for 5 seconds | ||
run: sleep 5s | ||
- name: Run tests | ||
run: yarn turbo run test --filter='./packages/*' | ||
|
||
build: | ||
name: Build | ||
runs-on: warp-ubuntu-latest-x64-8x | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: "yarn" | ||
env: | ||
SKIP_YARN_COREPACK_CHECK: "1" | ||
- name: Enable corepack | ||
run: corepack enable | ||
- name: Install dependencies | ||
run: yarn | ||
- name: Build | ||
run: yarn turbo run build --filter='./packages/*' |
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
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
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
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
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 |
---|---|---|
|
@@ -40,7 +40,7 @@ | |
"rimraf": "^6.0.1", | ||
"turbo": "^2.1.3", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.9.0" | ||
"typescript-eslint": "^8.10.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
|
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,13 @@ | ||
# @xmtp/consent-proof-signature | ||
|
||
## 0.1.3 | ||
|
||
### Patch Changes | ||
|
||
- 8adc23f: Add CommonJS export to `consent-proof-signature` package | ||
|
||
## 0.1.1 | ||
|
||
### Patch Changes | ||
|
||
- 6fbe931: Created package |
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,24 @@ | ||
# Consent Proof Signature | ||
|
||
## Usage | ||
|
||
```ts | ||
// Sign the message for example with Viem | ||
import { createWalletClient, custom } from "viem"; | ||
|
||
const timestamp = Date.now(); | ||
const message = createConsentMessage(broadcastAddress, timestamp); | ||
|
||
const walletClient = createWalletClient({ | ||
chain: mainnet, | ||
transport: custom((window as any).ethereum!), | ||
}); | ||
const [account] = await walletClient.getAddresses(); | ||
const signature = await walletClient.signMessage({ | ||
account, | ||
message, | ||
}); | ||
const consentProofBytes = createConsentProofPayload(signature, timestamp); | ||
``` | ||
|
||
Now the `consentProofBytes` can be encoded and sent to a service to decode and add in a new conversation invitation |
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,88 @@ | ||
{ | ||
"name": "@xmtp/consent-proof-signature", | ||
"version": "0.1.3", | ||
"keywords": [ | ||
"xmtp", | ||
"messaging", | ||
"web3", | ||
"sdk", | ||
"js", | ||
"ts", | ||
"javascript", | ||
"typescript" | ||
], | ||
"homepage": "https://github.com/xmtp/xmtp-js", | ||
"bugs": { | ||
"url": "https://github.com/xmtp/xmtp-js/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:xmtp/xmtp-js.git", | ||
"directory": "packages/consent-proof-signature" | ||
}, | ||
"license": "MIT", | ||
"author": "XMTP Labs <[email protected]>", | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"require": "./dist/index.cjs", | ||
"import": "./dist/index.js" | ||
} | ||
}, | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"browser": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src", | ||
"!src/**/*.test.*", | ||
"tsconfig.json" | ||
], | ||
"scripts": { | ||
"build": "yarn clean:dist && yarn rollup -c", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && yarn clean:dist", | ||
"clean:dist": "rm -rf dist", | ||
"dev": "yarn clean:dist && yarn rollup -c --watch", | ||
"test": "vitest run --passWithNoTests", | ||
"typecheck": "tsc", | ||
"typedoc": "typedoc" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 3 chrome versions", | ||
"last 3 firefox versions", | ||
"last 3 safari versions" | ||
] | ||
}, | ||
"dependencies": { | ||
"@xmtp/proto": "3.62.1", | ||
"long": "^5.2.3" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@rollup/plugin-typescript": "^12.1.1", | ||
"ethers": "^6.13.1", | ||
"rollup": "^4.24.0", | ||
"rollup-plugin-dts": "^6.1.1", | ||
"rollup-plugin-filesize": "^10.0.0", | ||
"tsconfig": "workspace:*", | ||
"typedoc": "^0.26.4", | ||
"typescript": "^5.6.3", | ||
"vite": "^5.4.9", | ||
"vitest": "^2.1.3" | ||
}, | ||
"packageManager": "[email protected]", | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true, | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
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,58 @@ | ||
import terser from "@rollup/plugin-terser"; | ||
import typescript from "@rollup/plugin-typescript"; | ||
import { defineConfig } from "rollup"; | ||
import { dts } from "rollup-plugin-dts"; | ||
import filesize from "rollup-plugin-filesize"; | ||
|
||
const plugins = [ | ||
typescript({ | ||
declaration: false, | ||
declarationMap: false, | ||
}), | ||
filesize({ | ||
showMinifiedSize: false, | ||
}), | ||
]; | ||
|
||
const external = ["@xmtp/proto", "node:crypto", "long"]; | ||
|
||
export default defineConfig([ | ||
{ | ||
input: "src/index.ts", | ||
output: { | ||
file: "dist/index.js", | ||
format: "es", | ||
sourcemap: true, | ||
}, | ||
external, | ||
plugins, | ||
}, | ||
{ | ||
input: "src/index.ts", | ||
output: { | ||
file: "dist/index.cjs", | ||
format: "cjs", | ||
sourcemap: true, | ||
}, | ||
external, | ||
plugins, | ||
}, | ||
{ | ||
input: "src/index.ts", | ||
output: { | ||
file: "dist/browser/index.js", | ||
format: "es", | ||
sourcemap: true, | ||
}, | ||
external, | ||
plugins: [terser(), ...plugins], | ||
}, | ||
{ | ||
input: "src/index.ts", | ||
output: { | ||
file: "dist/index.d.ts", | ||
format: "es", | ||
}, | ||
plugins: [dts()], | ||
}, | ||
]); |
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,30 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { createConsentMessage, createConsentProofPayload } from "."; | ||
|
||
describe("createConsentMessage", () => { | ||
it("should return a signature", () => { | ||
const timestampMs = 1581663600000; | ||
const exampleAddress = "0x1234567890abcdef"; | ||
const signatureMessage = createConsentMessage(exampleAddress, timestampMs); | ||
expect(signatureMessage).toEqual( | ||
"XMTP : Grant inbox consent to sender\n\nCurrent Time: Fri, 14 Feb 2020 07:00:00 GMT\nFrom Address: 0x1234567890abcdef\n\nFor more info: https://xmtp.org/signatures/", | ||
); | ||
}); | ||
}); | ||
|
||
describe("createConsentProofPayload", () => { | ||
it("should return data of consent proof", () => { | ||
const timestampMs = 1581663600000; | ||
const exampleSignature = "0x1234567890abcdef"; | ||
const signatureMessage = createConsentProofPayload( | ||
exampleSignature, | ||
timestampMs, | ||
); | ||
expect(signatureMessage).toEqual( | ||
Buffer.from([ | ||
10, 18, 48, 120, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 97, 98, 99, | ||
100, 101, 102, 16, 128, 251, 252, 147, 132, 46, 24, 1, | ||
]), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.