@atproto/aws 0.3.12 → 0.3.14
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.
- package/CHANGELOG.md +14 -0
- package/dist/kms.d.ts.map +1 -1
- package/dist/kms.js +7 -8
- package/dist/kms.js.map +1 -1
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atproto/aws
|
|
2
2
|
|
|
3
|
+
## 0.3.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5348](https://github.com/bluesky-social/atproto/pull/5348) [`5c3b7c9`](https://github.com/bluesky-social/atproto/commit/5c3b7c9c87efa4d48d41bc55af61f5b1f1e04920) Thanks [@dreyfus92](https://github.com/dreyfus92)! - Remove `key-encoder` dependency (and its `elliptic`/`asn1.js`/`bn.js` transitive tree) in favor of Node's native JWK key import and the already-present `@noble/curves`
|
|
8
|
+
|
|
9
|
+
## 0.3.13
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa), [`898c469`](https://github.com/bluesky-social/atproto/commit/898c469cf568b941f38f9c3371997a513ac05cfa)]:
|
|
14
|
+
- @atproto/common@0.8.0
|
|
15
|
+
- @atproto/repo@0.10.11
|
|
16
|
+
|
|
3
17
|
## 0.3.12
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/kms.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kms.d.ts","sourceRoot":"","sources":["../src/kms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"kms.d.ts","sourceRoot":"","sources":["../src/kms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;AAE1C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AAEzC,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAC9C,GAAG,CAAC,eAAe,EACnB,YAAY,CACb,CAAA;AAED,qBAAa,UAAW,YAAW,MAAM,CAAC,OAAO;IAI7C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,SAAS;IALnB,MAAM,SAA2B;IAEjC,YACU,MAAM,EAAE,GAAG,CAAC,GAAG,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,UAAU,EAC3B;IAEJ,OAAa,IAAI,CAAC,GAAG,EAAE,SAAS,uBAoB/B;IAED,GAAG,IAAI,MAAM,CAEZ;IAEK,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAiB/C;CACF;eAEc,UAAU"}
|
package/dist/kms.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as aws from '@aws-sdk/client-kms';
|
|
2
2
|
import { secp256k1 as noble } from '@noble/curves/secp256k1';
|
|
3
|
-
import KeyEncoderModule from 'key-encoder';
|
|
4
|
-
import * as ui8 from 'uint8arrays';
|
|
5
3
|
import * as crypto from '@atproto/crypto';
|
|
6
|
-
// key-encoder is CJS with exports.default; Node ESM interop wraps it as { default: Class }
|
|
7
|
-
const KeyEncoder = ((m) => m.default ?? m)(KeyEncoderModule);
|
|
8
|
-
const keyEncoder = new KeyEncoder('secp256k1');
|
|
9
4
|
export class KmsKeypair {
|
|
10
5
|
constructor(client, keyId, publicKey) {
|
|
11
6
|
this.client = client;
|
|
@@ -23,9 +18,13 @@ export class KmsKeypair {
|
|
|
23
18
|
if (!res.PublicKey) {
|
|
24
19
|
throw new Error('Could not find public key');
|
|
25
20
|
}
|
|
26
|
-
// public key comes back DER-encoded
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
// public key comes back SPKI DER-encoded. we can slice instead of parsing
|
|
22
|
+
// the ASN.1 because the uncompressed point (0x04 prefix + 32-byte x +
|
|
23
|
+
// 32-byte y = 65 bytes) is the payload of the final field, so it always
|
|
24
|
+
// sits at the very end of the DER. fromHex then rejects anything that
|
|
25
|
+
// isn't a valid on-curve point, so a malformed structure can't slip
|
|
26
|
+
// through
|
|
27
|
+
const publicKey = noble.ProjectivePoint.fromHex(new Uint8Array(res.PublicKey).slice(-65)).toRawBytes(false);
|
|
29
28
|
return new KmsKeypair(client, keyId, publicKey);
|
|
30
29
|
}
|
|
31
30
|
did() {
|
package/dist/kms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kms.js","sourceRoot":"","sources":["../src/kms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,SAAS,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"kms.js","sourceRoot":"","sources":["../src/kms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,SAAS,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AAOzC,MAAM,OAAO,UAAU;IAGrB,YACU,MAAe,EACf,KAAa,EACb,SAAqB;QAFrB,WAAM,GAAN,MAA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ACF,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC5C,CAAC;QACD,oDAAoD;QACpD,uCAAuC;QACvC,kFAAkF;QAClF,qCAAqC;QACrC,8HAA8H;QAC9H,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;QAClD,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,EAAE,CAAA;QACnC,OAAO,UAAU,CAAC,iBAAiB,EAAE,CAAA;IACvC,CAAC;CACF;AAED,eAAe,UAAU,CAAA","sourcesContent":["import * as aws from '@aws-sdk/client-kms'\nimport { secp256k1 as noble } from '@noble/curves/secp256k1'\nimport * as crypto from '@atproto/crypto'\n\nexport type KmsConfig = { keyId: string } & Omit<\n aws.KMSClientConfig,\n 'apiVersion'\n>\n\nexport class KmsKeypair implements crypto.Keypair {\n jwtAlg = crypto.SECP256K1_JWT_ALG\n\n constructor(\n private client: aws.KMS,\n private keyId: string,\n private publicKey: Uint8Array,\n ) {}\n\n static async load(cfg: KmsConfig) {\n const { keyId, ...rest } = cfg\n const client = new aws.KMS({\n ...rest,\n apiVersion: '2014-11-01',\n })\n const res = await client.getPublicKey({ KeyId: keyId })\n if (!res.PublicKey) {\n throw new Error('Could not find public key')\n }\n // public key comes back SPKI DER-encoded. we can slice instead of parsing\n // the ASN.1 because the uncompressed point (0x04 prefix + 32-byte x +\n // 32-byte y = 65 bytes) is the payload of the final field, so it always\n // sits at the very end of the DER. fromHex then rejects anything that\n // isn't a valid on-curve point, so a malformed structure can't slip\n // through\n const publicKey = noble.ProjectivePoint.fromHex(\n new Uint8Array(res.PublicKey).slice(-65),\n ).toRawBytes(false)\n return new KmsKeypair(client, keyId, publicKey)\n }\n\n did(): string {\n return crypto.formatDidKey(this.jwtAlg, this.publicKey)\n }\n\n async sign(msg: Uint8Array): Promise<Uint8Array> {\n const res = await this.client.sign({\n KeyId: this.keyId,\n Message: msg,\n SigningAlgorithm: 'ECDSA_SHA_256',\n })\n if (!res.Signature) {\n throw new Error('Could not get signature')\n }\n // signature comes back DER encoded & not-normalized\n // we translate to raw 64 byte encoding\n // we also normalize s as no more than 1/2 prime order to pass strict verification\n // (prevents duplicating a signature)\n // more: https://github.com/bitcoin-core/secp256k1/blob/a1102b12196ea27f44d6201de4d25926a2ae9640/include/secp256k1.h#L530-L534\n const sig = noble.Signature.fromDER(res.Signature)\n const normalized = sig.normalizeS()\n return normalized.toCompactRawBytes()\n }\n}\n\nexport default KmsKeypair\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/aws",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared AWS cloud API helpers for atproto services",
|
|
6
6
|
"keywords": [
|
|
@@ -34,13 +34,12 @@
|
|
|
34
34
|
"@aws-sdk/client-s3": "^3.879.0",
|
|
35
35
|
"@aws-sdk/lib-storage": "3.879.0",
|
|
36
36
|
"@noble/curves": "^1.7.0",
|
|
37
|
-
"key-encoder": "^2.0.3",
|
|
38
37
|
"multiformats": "^13.0.0",
|
|
39
38
|
"uint8arrays": "^5.0.0",
|
|
40
|
-
"@atproto/common": "^0.
|
|
39
|
+
"@atproto/common": "^0.8.0",
|
|
40
|
+
"@atproto/common-web": "^0.5.9",
|
|
41
41
|
"@atproto/crypto": "^0.5.4",
|
|
42
|
-
"@atproto/repo": "^0.10.
|
|
43
|
-
"@atproto/common-web": "^0.5.9"
|
|
42
|
+
"@atproto/repo": "^0.10.11"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"vitest": "^4.1.10"
|