@atproto/crypto 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +3 -0
  2. package/build.js +22 -0
  3. package/dist/aes.d.ts +8 -0
  4. package/dist/const.d.ts +5 -0
  5. package/dist/did.d.ts +7 -0
  6. package/dist/index.d.ts +12 -0
  7. package/dist/index.js +3955 -0
  8. package/dist/index.js.map +7 -0
  9. package/dist/multibase.d.ts +1 -0
  10. package/dist/p256/encoding.d.ts +2 -0
  11. package/dist/p256/keypair.d.ts +19 -0
  12. package/dist/p256/operations.d.ts +4 -0
  13. package/dist/p256/plugin.d.ts +3 -0
  14. package/dist/plugins.d.ts +2 -0
  15. package/dist/random.d.ts +4 -0
  16. package/dist/secp256k1/encoding.d.ts +2 -0
  17. package/dist/secp256k1/keypair.d.ts +19 -0
  18. package/dist/secp256k1/operations.d.ts +1 -0
  19. package/dist/secp256k1/plugin.d.ts +3 -0
  20. package/dist/sha.d.ts +3 -0
  21. package/dist/verify.d.ts +1 -0
  22. package/jest.config.js +6 -0
  23. package/package.json +29 -0
  24. package/src/aes.ts +64 -0
  25. package/src/const.ts +6 -0
  26. package/src/did.ts +56 -0
  27. package/src/index.ts +15 -0
  28. package/src/multibase.ts +26 -0
  29. package/src/p256/encoding.ts +81 -0
  30. package/src/p256/keypair.ts +85 -0
  31. package/src/p256/operations.ts +64 -0
  32. package/src/p256/plugin.ts +13 -0
  33. package/src/plugins.ts +6 -0
  34. package/src/random.ts +19 -0
  35. package/src/secp256k1/encoding.ts +16 -0
  36. package/src/secp256k1/keypair.ts +65 -0
  37. package/src/secp256k1/operations.ts +16 -0
  38. package/src/secp256k1/plugin.ts +11 -0
  39. package/src/sha.ts +28 -0
  40. package/src/verify.ts +15 -0
  41. package/tests/did.test.ts +95 -0
  42. package/tests/export.test.ts +50 -0
  43. package/tests/key-compression.test.ts +69 -0
  44. package/tsconfig.build.json +4 -0
  45. package/tsconfig.build.tsbuildinfo +1 -0
  46. package/tsconfig.json +9 -0
  47. package/update-pkg.js +14 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # ATP Crypto Library
2
+
3
+ ATP's common cryptographic operations.
package/build.js ADDED
@@ -0,0 +1,22 @@
1
+ const pkgJson = require('@npmcli/package-json')
2
+ const { nodeExternalsPlugin } = require('esbuild-node-externals')
3
+
4
+ const buildShallow =
5
+ process.argv.includes('--shallow') || process.env.ATP_BUILD_SHALLOW === 'true'
6
+
7
+ if (process.argv.includes('--update-main-to-dist')) {
8
+ return pkgJson
9
+ .load(__dirname)
10
+ .then((pkg) => pkg.update({ main: 'dist/index.js' }))
11
+ .then((pkg) => pkg.save())
12
+ }
13
+
14
+ require('esbuild').build({
15
+ logLevel: 'info',
16
+ entryPoints: ['src/index.ts'],
17
+ bundle: true,
18
+ sourcemap: true,
19
+ outdir: 'dist',
20
+ platform: 'node',
21
+ plugins: buildShallow ? [nodeExternalsPlugin()] : [],
22
+ })
package/dist/aes.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare class AesKey {
2
+ private key;
3
+ constructor(key: CryptoKey);
4
+ static create(): Promise<AesKey>;
5
+ encrypt(data: string): Promise<string>;
6
+ decrypt(data: string): Promise<string>;
7
+ }
8
+ export default AesKey;
@@ -0,0 +1,5 @@
1
+ export declare const P256_DID_PREFIX: Uint8Array;
2
+ export declare const SECP256K1_DID_PREFIX: Uint8Array;
3
+ export declare const BASE58_DID_PREFIX = "did:key:z";
4
+ export declare const P256_JWT_ALG = "ES256";
5
+ export declare const SECP256K1_JWT_ALG = "ES256K";
package/dist/did.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const DID_KEY_BASE58_PREFIX = "did:key:z";
2
+ export declare type ParsedDidKey = {
3
+ jwtAlg: string;
4
+ keyBytes: Uint8Array;
5
+ };
6
+ export declare const parseDidKey: (did: string) => ParsedDidKey;
7
+ export declare const formatDidKey: (jwtAlg: string, keyBytes: Uint8Array) => string;
@@ -0,0 +1,12 @@
1
+ export * from './aes';
2
+ export * from './const';
3
+ export * from './did';
4
+ export * from './multibase';
5
+ export * from './random';
6
+ export * from './sha';
7
+ export * from './verify';
8
+ export * from './p256/keypair';
9
+ export * from './p256/plugin';
10
+ export * from './secp256k1/keypair';
11
+ export * from './secp256k1/plugin';
12
+ export type { DidableKey } from '@ucans/core';