Skip to content

Commit

Permalink
move more stuff out to applesauce
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Sep 30, 2024
1 parent aa2f210 commit 38bc52b
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 560 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
"@uiw/codemirror-theme-github": "^4.23.0",
"@uiw/react-codemirror": "^4.23.0",
"@webscopeio/react-textarea-autocomplete": "^4.9.2",
"applesauce-core": "^0.4.0",
"applesauce-channel": "^0.5.0",
"applesauce-core": "^0.5.0",
"applesauce-signer": "^0.5.0",
"bech32": "^2.0.0",
"blossom-client-sdk": "^0.7.0",
"blossom-drive-sdk": "^0.4.0",
Expand Down
52 changes: 39 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/classes/accounts/account.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { AppSettings } from "../../services/settings/migrations";
import { Nip07Signer } from "../../types/nostr-extensions";
import { Nip07Interface } from "applesauce-signer";

export class Account {
readonly type: string = "unknown";
pubkey: string;
localSettings?: AppSettings;

protected _signer?: Nip07Signer | undefined;
public get signer(): Nip07Signer | undefined {
protected _signer?: Nip07Interface | undefined;
public get signer(): Nip07Interface | undefined {
return this._signer;
}
public set signer(value: Nip07Signer | undefined) {
public set signer(value: Nip07Interface | undefined) {
this._signer = value;
}

Expand Down
10 changes: 5 additions & 5 deletions src/classes/accounts/amber-account.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import AmberSigner from "../signers/amber-signer";
import { AmberClipboardSigner } from "applesauce-signer";
import { Account } from "./account";

export default class AmberAccount extends Account {
readonly type = "amber";

protected declare _signer?: AmberSigner | undefined;
public get signer(): AmberSigner | undefined {
protected declare _signer?: AmberClipboardSigner | undefined;
public get signer(): AmberClipboardSigner | undefined {
return this._signer;
}
public set signer(value: AmberSigner | undefined) {
public set signer(value: AmberClipboardSigner | undefined) {
this._signer = value;
}

constructor(pubkey: string) {
super(pubkey);
this.signer = new AmberSigner();
this.signer = new AmberClipboardSigner();
}
}
6 changes: 3 additions & 3 deletions src/classes/accounts/extension-account.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Nip07Signer } from "../../types/nostr-extensions";
import { Nip07Interface } from "applesauce-signer";
import { Account } from "./account";

export default class ExtensionAccount extends Account {
readonly type = "extension";

public get signer(): Nip07Signer | undefined {
public get signer(): Nip07Interface | undefined {
return window.nostr;
}
set signer(signer: Nip07Signer) {
set signer(signer: Nip07Interface) {
throw new Error("Cant update signer");
}

Expand Down
2 changes: 1 addition & 1 deletion src/classes/accounts/nsec-account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateSecretKey, getPublicKey, nip19 } from "nostr-tools";
import SimpleSigner from "../signers/simple-signer";
import { SimpleSigner } from "applesauce-signer";
import { Account } from "./account";

export default class NsecAccount extends Account {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/accounts/serial-port-account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SerialPortSigner from "../signers/serial-port-signer";
import { SerialPortSigner } from "applesauce-signer";
import { Account } from "./account";

export default class SerialPortAccount extends Account {
Expand Down
167 changes: 0 additions & 167 deletions src/classes/signers/amber-signer.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/classes/signers/nostr-connect-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import {
import dayjs from "dayjs";
import { nanoid } from "nanoid";
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
import { Nip07Interface } from "applesauce-signer";

import MultiSubscription from "../multi-subscription";
import { logger } from "../../helpers/debug";
import createDefer, { Deferred } from "../deferred";
import { Nip07Signer } from "../../types/nostr-extensions";

export function isErrorResponse(response: any): response is NostrConnectErrorResponse {
return !!response.error;
Expand Down Expand Up @@ -66,7 +66,7 @@ export type NostrConnectErrorResponse = {
error: string;
};

export default class NostrConnectSigner implements Nip07Signer {
export default class NostrConnectSigner implements Nip07Interface {
sub: MultiSubscription;
log = logger.extend("NostrConnectSigner");

Expand Down
4 changes: 2 additions & 2 deletions src/classes/signers/password-signer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventTemplate, finalizeEvent, getPublicKey, nip04, nip44 } from "nostr-tools";
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
import { encrypt, decrypt } from "nostr-tools/nip49";
import { Nip07Interface } from "applesauce-signer";

import { Nip07Signer } from "../../types/nostr-extensions";
import createDefer, { Deferred } from "../deferred";
import db from "../../services/db";

Expand Down Expand Up @@ -75,7 +75,7 @@ async function subltCryptoDecryptSecKey(buffer: ArrayBuffer, iv: Uint8Array, pas
}
}

export default class PasswordSigner implements Nip07Signer {
export default class PasswordSigner implements Nip07Interface {
key: Uint8Array | null = null;

// legacy
Expand Down
Loading

0 comments on commit 38bc52b

Please sign in to comment.