Skip to content

Commit

Permalink
feat(SPV-886): switch to TOTP algorithm from ts-sdk (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain authored Jun 20, 2024
1 parent a32d60b commit f14284d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 273 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsv/spv-wallet-js-client",
"version": "1.0.0-beta.17",
"version": "1.0.0-beta.18",
"description": "TypeScript library for connecting to a SPV Wallet server",
"repository": {
"type": "git",
Expand Down
21 changes: 0 additions & 21 deletions src/totp/converters.ts

This file was deleted.

17 changes: 5 additions & 12 deletions src/totp/pike-totp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { HD, PublicKey } from '@bsv/sdk';
import { HD, PublicKey, TOTP, TOTPOptions, Utils } from '@bsv/sdk';
import { Contact } from '../types';
import { TOTP, TOTPOptions } from './totp';
import { hexToUint8Array } from './converters';

export const DEFAULT_TOTP_PERIOD = 30;
export const DEFAULT_TOTP_DIGITS = 2;
Expand Down Expand Up @@ -80,14 +78,9 @@ const makeSharedSecret = (contact: Contact, clientXPriv: HD) => {
return ss.getX().toHex(32);
};

const directedSecret = (sharedSecret: string, paymail: string): Uint8Array => {
const paymailEncoded = Uint8Array.from(paymail, (c) => c.charCodeAt(0));
const sharedSecretEncoded = hexToUint8Array(sharedSecret);

// Concatenate sharedSecretEncoded and paymailEncoded
const concatenated = new Uint8Array(sharedSecretEncoded.length + paymailEncoded.length);
concatenated.set(sharedSecretEncoded, 0);
concatenated.set(paymailEncoded, sharedSecretEncoded.length);

const directedSecret = (sharedSecret: string, paymail: string): number[] => {
const sharedSecretDigest = Utils.toArray(sharedSecret, 'hex') as number[];
const paymailDigest = Utils.toArray(paymail, 'utf8') as number[];
const concatenated = [...sharedSecretDigest, ...paymailDigest];
return concatenated;
};
51 changes: 0 additions & 51 deletions src/totp/sha1hmac.ts

This file was deleted.

63 changes: 0 additions & 63 deletions src/totp/totp.test.ts

This file was deleted.

125 changes: 0 additions & 125 deletions src/totp/totp.ts

This file was deleted.

0 comments on commit f14284d

Please sign in to comment.