aws-kms-ethers-signer
Advanced tools
Comparing version 0.0.3 to 0.1.0-alpha.0
@@ -1,1 +0,22 @@ | ||
export * from "./kms-ethers-signer"; | ||
import { Signer } from '@ethersproject/abstract-signer'; | ||
import { Deferrable } from '@ethersproject/properties'; | ||
import { Bytes } from '@ethersproject/bytes'; | ||
import { Provider, TransactionRequest } from '@ethersproject/abstract-provider'; | ||
import { KMSClientConfig } from '@aws-sdk/client-kms'; | ||
declare type KmsEthersSignerConfig = { | ||
keyId: string; | ||
kmsClientConfig?: KMSClientConfig; | ||
}; | ||
declare class KmsEthersSigner extends Signer { | ||
private readonly config; | ||
private readonly kmsSigner; | ||
private readonly adapter; | ||
constructor(config: KmsEthersSignerConfig, provider?: Provider); | ||
getAddress(): Promise<string>; | ||
signMessage(message: Bytes | string): Promise<string>; | ||
signTransaction(deferrableTransaction: Deferrable<TransactionRequest>): Promise<string>; | ||
connect(provider: Provider): KmsEthersSigner; | ||
} | ||
export { KmsEthersSigner, KmsEthersSignerConfig }; |
@@ -1,13 +0,220 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __esm = (fn, res) => function __init() { | ||
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./kms-ethers-signer"), exports); | ||
var __export = (target, all) => { | ||
for (var name2 in all) | ||
__defProp(target, name2, { get: all[name2], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, copyDefault, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toCommonJS = /* @__PURE__ */ ((cache) => { | ||
return (module2, temp) => { | ||
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp); | ||
}; | ||
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); | ||
// package.json | ||
var package_exports = {}; | ||
__export(package_exports, { | ||
default: () => package_default, | ||
dependencies: () => dependencies, | ||
devDependencies: () => devDependencies, | ||
exports: () => exports, | ||
files: () => files, | ||
license: () => license, | ||
main: () => main, | ||
module: () => module, | ||
name: () => name, | ||
publishConfig: () => publishConfig, | ||
repository: () => repository, | ||
scripts: () => scripts, | ||
type: () => type, | ||
types: () => types, | ||
version: () => version | ||
}); | ||
var name, version, repository, license, type, exports, main, module, types, files, scripts, publishConfig, dependencies, devDependencies, package_default; | ||
var init_package = __esm({ | ||
"package.json"() { | ||
name = "aws-kms-ethers-signer"; | ||
version = "0.0.3"; | ||
repository = { | ||
type: "git", | ||
url: "https://github.com/odanado/aws-kms-provider" | ||
}; | ||
license = "MIT"; | ||
type = "module"; | ||
exports = { | ||
".": { | ||
import: "./dist/index.js", | ||
require: "./dist/index.cjs", | ||
node: "./dist/index.cjs", | ||
default: "./dist/index.js" | ||
} | ||
}; | ||
main = "dist/index.cjs"; | ||
module = "dist/index.js"; | ||
types = "dist/index.d.ts"; | ||
files = [ | ||
"README.md", | ||
"dist", | ||
"src", | ||
"package.json", | ||
"yarn.lock" | ||
]; | ||
scripts = { | ||
prebuild: "rm -rf dist", | ||
build: "tsup" | ||
}; | ||
publishConfig = { | ||
access: "public" | ||
}; | ||
dependencies = { | ||
"@aws-sdk/client-kms": "^3.39.0", | ||
"@ethersproject/abstract-provider": "^5.5.1", | ||
"@ethersproject/abstract-signer": "^5.5.0", | ||
"@ethersproject/address": "^5.5.0", | ||
"@ethersproject/bignumber": "^5.5.0", | ||
"@ethersproject/bytes": "^5.5.0", | ||
"@ethersproject/hash": "^5.5.0", | ||
"@ethersproject/keccak256": "^5.5.0", | ||
"@ethersproject/logger": "^5.5.0", | ||
"@ethersproject/properties": "^5.5.0", | ||
"@ethersproject/transactions": "^5.5.0", | ||
"aws-kms-signer": "^0.4.0" | ||
}; | ||
devDependencies = { | ||
ethers: "^5.5.1" | ||
}; | ||
package_default = { | ||
name, | ||
version, | ||
repository, | ||
license, | ||
type, | ||
exports, | ||
main, | ||
module, | ||
types, | ||
files, | ||
scripts, | ||
publishConfig, | ||
dependencies, | ||
devDependencies | ||
}; | ||
} | ||
}); | ||
// src/kms-ethers-signer.ts | ||
import { Signer as Signer2 } from "@ethersproject/abstract-signer"; | ||
import { defineReadOnly as defineReadOnly2 } from "@ethersproject/properties"; | ||
import { KmsSigner } from "aws-kms-signer"; | ||
// src/adapter.ts | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { | ||
defineReadOnly, | ||
resolveProperties | ||
} from "@ethersproject/properties"; | ||
import { splitSignature } from "@ethersproject/bytes"; | ||
import { hashMessage } from "@ethersproject/hash"; | ||
import { Logger } from "@ethersproject/logger"; | ||
import { getAddress } from "@ethersproject/address"; | ||
import { keccak256 } from "@ethersproject/keccak256"; | ||
import { BigNumber } from "@ethersproject/bignumber"; | ||
import { serialize } from "@ethersproject/transactions"; | ||
var Adapter = class extends Signer { | ||
constructor(config, provider) { | ||
super(); | ||
this.signer = config.signer; | ||
defineReadOnly(this, "provider", provider); | ||
this.logger = new Logger(config.version); | ||
} | ||
async getAddress() { | ||
const address = await this.signer.getAddress(); | ||
return getAddress(address.toString()); | ||
} | ||
async signMessage(message) { | ||
const digest = hashMessage(message); | ||
const signature = await this.signer.sign(Buffer.from(digest.slice(2), "hex")); | ||
return signature.toString(); | ||
} | ||
async signTransaction(deferrableTransaction) { | ||
const transaction = await resolveProperties(deferrableTransaction); | ||
const address = await this.getAddress(); | ||
if (transaction.from != null) { | ||
if (getAddress(transaction.from) !== address) { | ||
this.logger.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from); | ||
} | ||
} | ||
const nonce = transaction.nonce ? BigNumber.from(transaction.nonce).toNumber() : void 0; | ||
const unsignedTransaction = { | ||
to: transaction.to, | ||
nonce, | ||
gasLimit: transaction.gasLimit, | ||
gasPrice: transaction.gasPrice, | ||
data: transaction.data, | ||
value: transaction.value, | ||
chainId: transaction.chainId, | ||
type: transaction.type, | ||
accessList: transaction.accessList, | ||
maxPriorityFeePerGas: transaction.maxPriorityFeePerGas, | ||
maxFeePerGas: transaction.maxFeePerGas | ||
}; | ||
Object.keys(unsignedTransaction).forEach((key) => { | ||
if (key in unsignedTransaction && unsignedTransaction[key] == void 0) { | ||
delete unsignedTransaction[key]; | ||
} | ||
}); | ||
const digest = keccak256(serialize(unsignedTransaction)); | ||
const signature = await this.signer.sign(Buffer.from(digest.slice(2), "hex")); | ||
const ethersSignature = splitSignature({ | ||
v: signature.v, | ||
r: `0x${signature.r.toString("hex")}`, | ||
s: `0x${signature.s.toString("hex")}` | ||
}); | ||
return serialize(unsignedTransaction, ethersSignature); | ||
} | ||
connect(provider) { | ||
return new Adapter({ signer: this.signer, version: this.logger.version }, provider); | ||
} | ||
}; | ||
// src/kms-ethers-signer.ts | ||
var version2 = (init_package(), __toCommonJS(package_exports)).version; | ||
var KmsEthersSigner = class extends Signer2 { | ||
constructor(config, provider) { | ||
super(); | ||
this.config = config; | ||
var _a; | ||
defineReadOnly2(this, "provider", provider); | ||
this.kmsSigner = new KmsSigner(config.keyId, (_a = config.kmsClientConfig) != null ? _a : {}); | ||
this.adapter = new Adapter({ signer: this.kmsSigner, version: version2 }, provider); | ||
} | ||
async getAddress() { | ||
return this.adapter.getAddress(); | ||
} | ||
async signMessage(message) { | ||
return this.adapter.signMessage(message); | ||
} | ||
async signTransaction(deferrableTransaction) { | ||
return this.adapter.signTransaction(deferrableTransaction); | ||
} | ||
connect(provider) { | ||
return new KmsEthersSigner(this.config, provider); | ||
} | ||
}; | ||
export { | ||
KmsEthersSigner | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "aws-kms-ethers-signer", | ||
"version": "0.0.3", | ||
"version": "0.1.0-alpha.0", | ||
"repository": { | ||
@@ -9,16 +9,18 @@ "type": "git", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./lib/index.js", | ||
"require": "./dist/index.js", | ||
"node": "./dist/index.js", | ||
"default": "./lib/index.js" | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs", | ||
"node": "./dist/index.cjs", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"main": "dist/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"README.md", | ||
"dist", | ||
"lib", | ||
"src", | ||
"package.json", | ||
@@ -28,6 +30,4 @@ "yarn.lock" | ||
"scripts": { | ||
"prebuild": "rm -rf lib dist", | ||
"build": "run-p build:*", | ||
"build:esm": "tsc", | ||
"build:cjs": "tsc --module commonjs --outDir dist" | ||
"prebuild": "rm -rf dist", | ||
"build": "tsup" | ||
}, | ||
@@ -49,3 +49,3 @@ "publishConfig": { | ||
"@ethersproject/transactions": "^5.5.0", | ||
"aws-kms-signer": "^0.4.0" | ||
"aws-kms-signer": "^0.5.0-alpha.0" | ||
}, | ||
@@ -55,3 +55,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "3012ecad2165daa0cc1448cc3053b444b6648ee7" | ||
"gitHead": "a722bbbde2995f5a21d2c10191ef647ad0b2a6fb" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38466
596
Yes
11
1
+ Addedasn1js@3.0.5(transitive)
+ Addedaws-kms-signer@0.5.3(transitive)
+ Addedpvtsutils@1.3.5(transitive)
- Removedasn1js@2.4.0(transitive)
- Removedaws-kms-signer@0.4.0(transitive)