Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@samouraiwallet/auth47

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@samouraiwallet/auth47 - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

4

CHANGELOG.md
# Changelog
## v0.5.0
### Features
- use string as input for bitcoin network instead of object
## v0.4.0

@@ -4,0 +8,0 @@ ### Features

5

dist/index.d.ts

@@ -0,4 +1,3 @@

import { utils } from '@samouraiwallet/bip47';
import { ValidProofContainer } from './types.js';
declare const networks: Record<"bitcoin" | "regtest" | "testnet", import("@samouraiwallet/bip47/dist/types.js").Network>;
type Network = typeof networks.bitcoin;
interface GenerateURIArgs {

@@ -22,3 +21,3 @@ nonce: string;

generateURI(args: GenerateURIArgs): string;
verifyProof(proof: unknown, network?: Network): VerifyResult;
verifyProof(proof: unknown, networkString?: keyof typeof utils.networks): VerifyResult;
private validateProof;

@@ -25,0 +24,0 @@ }

@@ -11,5 +11,17 @@ import { boolean, either } from 'fp-ts';

const bip47 = BIP47Factory(ecc);
const getNetwork = (networkString) => {
switch (networkString) {
case 'bitcoin':
return either.right(networks.bitcoin);
case 'testnet':
return either.right(networks.testnet);
case 'regtest':
return either.right(networks.regtest);
default:
return either.left('Invalid bitcoin network');
}
};
export class Auth47Verifier {
constructor(callbackUri) {
this.validateProof = (network) => (proof) => pipe(isNymProof(proof) ? bip47.fromBase58(proof.value.nym, network).getNotificationAddress() : proof.value.address, (notifAddress) => verify(proof.value.challenge, notifAddress, proof.value.signature, network.messagePrefix), boolean.fold(() => either.left('invalid signature'), () => either.right(proof)));
this.validateProof = (networkString) => (proof) => pipe(getNetwork(networkString), either.chain((network) => pipe(isNymProof(proof) ? bip47.fromBase58(proof.value.nym, network).getNotificationAddress() : proof.value.address, (notifAddress) => verify(proof.value.challenge, notifAddress, proof.value.signature, network.messagePrefix), boolean.fold(() => either.left('invalid signature'), () => either.right(proof)))));
const validatedUri = pipe(D.string.decode(callbackUri), either.mapLeft(D.draw), either.chain((s) => pipe(either.tryCatch(() => new URL(s), () => 'invalid URL'), either.chain((url) => ['http:', 'https:', 'srbn:', 'srbns:'].includes(url.protocol) ? either.right(url) : either.left('invalid protocol for callback URI')), either.chain((url) => url.hash === '' ? either.right(url) : either.left('hash is forbidden in callback URI')), either.chain((url) => url.search === '' ? either.right(url) : either.left('search params are forbidden in callback URI')))), either.getOrElseW((e) => {

@@ -33,6 +45,6 @@ throw new Error(e);

}
verifyProof(proof, network = networks.bitcoin) {
return pipe(decodeProof(proof), either.chain(this.validateProof(network)), either.foldW((e) => ({ result: 'error', error: e }), (proofContainer) => ({ result: 'ok', data: proofContainer.value })));
verifyProof(proof, networkString = 'bitcoin') {
return pipe(decodeProof(proof), either.chain(this.validateProof(networkString)), either.foldW((e) => ({ result: 'error', error: e }), (proofContainer) => ({ result: 'ok', data: proofContainer.value })));
}
}
//# sourceMappingURL=index.js.map
{
"name": "@samouraiwallet/auth47",
"version": "0.4.0",
"version": "0.5.0",
"description": "A JS implementation of the Auth47 protocol",

@@ -15,3 +15,3 @@ "keywords": [

"engines": {
"node": ">=16.x.x"
"node": ">=14.x.x"
},

@@ -36,3 +36,3 @@ "exports": {

"type": "git",
"url": "git+ssh://git@code.samourai.io:dojo/auth47-js.git"
"url": "https://code.samourai.io/dojo/auth47-js.git"
},

@@ -49,4 +49,4 @@ "bugs": {

"bitcoinjs-message": "2.2.0",
"fp-ts": "2.13.0",
"io-ts": "2.2.19",
"fp-ts": "2.13.1",
"io-ts": "2.2.20",
"tiny-secp256k1": "2.2.1",

@@ -66,5 +66,5 @@ "validator": "13.7.0"

"eslint-plugin-unicorn": "^45.0.1",
"typescript": "^4.9.3",
"typescript": "^4.9.4",
"vitest": "^0.25.5"
}
}

@@ -5,3 +5,6 @@ # @samouraiwallet/auth47

This library uses ES Modules. Node.js v14 or later is required.
Source code was written in Typescript. Type definitions are included in the published bundle.
## Usage

@@ -8,0 +11,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc