-
Notifications
You must be signed in to change notification settings - Fork 42
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 #508 from xmtp/rygine/add-exports
Add `bundler` build and more exports
- Loading branch information
Showing
7 changed files
with
98 additions
and
7 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
File renamed without changes.
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,39 @@ | ||
/*********************************************************************************************** | ||
* DO NOT IMPORT THIS FILE DIRECTLY | ||
***********************************************************************************************/ | ||
|
||
import { | ||
// eslint-disable-next-line camelcase | ||
generate_private_preferences_topic, | ||
// eslint-disable-next-line camelcase | ||
user_preferences_decrypt, | ||
// eslint-disable-next-line camelcase | ||
user_preferences_encrypt, | ||
} from '@xmtp/user-preferences-bindings-wasm/bundler' | ||
import { PrivateKey } from './PrivateKey' | ||
|
||
export async function userPreferencesEncrypt( | ||
identityKey: PrivateKey, | ||
payload: Uint8Array | ||
) { | ||
const publicKey = identityKey.publicKey.secp256k1Uncompressed.bytes | ||
const privateKey = identityKey.secp256k1.bytes | ||
// eslint-disable-next-line camelcase | ||
return user_preferences_encrypt(publicKey, privateKey, payload) | ||
} | ||
|
||
export async function userPreferencesDecrypt( | ||
identityKey: PrivateKey, | ||
payload: Uint8Array | ||
) { | ||
const publicKey = identityKey.publicKey.secp256k1Uncompressed.bytes | ||
const privateKey = identityKey.secp256k1.bytes | ||
// eslint-disable-next-line camelcase | ||
return user_preferences_decrypt(publicKey, privateKey, payload) | ||
} | ||
|
||
export async function generateUserPreferencesTopic(identityKey: PrivateKey) { | ||
const privateKey = identityKey.secp256k1.bytes | ||
// eslint-disable-next-line camelcase | ||
return generate_private_preferences_topic(privateKey) | ||
} |
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,32 @@ | ||
import { defineConfig } from 'tsup' | ||
import { resolveExtensionsPlugin } from './build/esbuild-plugin-resolve-extensions/index.ts' | ||
import { Plugin } from 'esbuild' | ||
|
||
export default defineConfig((options) => { | ||
const esbuildPlugins: Plugin[] = [] | ||
|
||
// replace imports if there's a file with the same name but with a | ||
// `.bundler` or `.browser` extension | ||
// i.e. crypto.ts -> crypto.browser.ts | ||
esbuildPlugins.push( | ||
resolveExtensionsPlugin({ | ||
extensions: ['.bundler', '.browser'], | ||
}) | ||
) | ||
|
||
return { | ||
entry: ['src/index.ts'], | ||
outDir: 'dist/bundler', | ||
splitting: false, | ||
sourcemap: true, | ||
treeshake: true, | ||
clean: true, | ||
bundle: true, | ||
platform: 'browser', | ||
minify: true, | ||
dts: false, | ||
format: ['esm'], | ||
esbuildPlugins, | ||
target: 'esnext', | ||
} | ||
}) |
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