filecoin-pin
Version:
Bridge IPFS content to Filecoin Onchain Cloud using familiar tools
38 lines • 1.41 kB
JavaScript
/**
* Address-only signer for session key authentication
*
* This signer provides an address but throws on any signing operations.
* Used as the "owner" signer when authenticating with session keys,
* where the actual signing is done by the session key wallet.
*/
import { AbstractSigner } from 'ethers';
const cannotSign = (thing) => `Cannot sign ${thing} - this is an address-only signer for session key authentication. Signing operations should be performed by the session key.`;
/**
* Symbol used to identify AddressOnlySigner instances
* This is more reliable than instanceof checks across module boundaries
*/
export const ADDRESS_ONLY_SIGNER_SYMBOL = Symbol.for('filecoin-pin.AddressOnlySigner');
export class AddressOnlySigner extends AbstractSigner {
address;
[ADDRESS_ONLY_SIGNER_SYMBOL] = true;
constructor(address, provider) {
super(provider);
this.address = address;
}
async getAddress() {
return this.address;
}
connect(provider) {
return new AddressOnlySigner(this.address, provider);
}
async signTransaction(_tx) {
throw new Error(cannotSign('transaction'));
}
async signMessage(_message) {
throw new Error(cannotSign('message'));
}
async signTypedData(_domain, _types, _value) {
throw new Error(cannotSign('typed data'));
}
}
//# sourceMappingURL=address-only-signer.js.map