@welshman/signer 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/index.cjs +22 -0
- package/build/src/index.cjs.map +1 -0
- package/build/src/index.d.ts +4 -4
- package/build/src/index.mjs +4 -4
- package/build/src/nip59.cjs +76 -0
- package/build/src/nip59.cjs.map +1 -0
- package/build/src/nip59.d.ts +26 -0
- package/build/src/nip59.mjs +66 -0
- package/build/src/nip59.mjs.map +1 -0
- package/build/src/signers/nip01.cjs +24 -0
- package/build/src/signers/nip01.cjs.map +1 -0
- package/build/src/signers/{secret.d.ts → nip01.d.ts} +6 -5
- package/build/src/signers/{secret.mjs → nip01.mjs} +6 -5
- package/build/src/signers/nip01.mjs.map +1 -0
- package/build/src/signers/nip07.cjs +50 -0
- package/build/src/signers/nip07.cjs.map +1 -0
- package/build/src/signers/{extension.d.ts → nip07.d.ts} +6 -6
- package/build/src/signers/nip07.mjs +45 -0
- package/build/src/signers/nip07.mjs.map +1 -0
- package/build/src/signers/nip46.cjs +157 -0
- package/build/src/signers/nip46.cjs.map +1 -0
- package/build/src/signers/nip46.d.ts +48 -0
- package/build/src/signers/nip46.mjs +152 -0
- package/build/src/signers/nip46.mjs.map +1 -0
- package/build/src/util.cjs +42 -0
- package/build/src/util.cjs.map +1 -0
- package/build/src/util.d.ts +20 -8
- package/build/src/util.mjs +4 -3
- package/build/src/util.mjs.map +1 -1
- package/package.json +5 -4
- package/build/src/signers/connect.d.ts +0 -47
- package/build/src/signers/connect.mjs +0 -152
- package/build/src/signers/connect.mjs.map +0 -1
- package/build/src/signers/extension.mjs +0 -48
- package/build/src/signers/extension.mjs.map +0 -1
- package/build/src/signers/secret.mjs.map +0 -1
- package/build/src/wrapper.d.ts +0 -21
- package/build/src/wrapper.mjs +0 -56
- package/build/src/wrapper.mjs.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./util.cjs"), exports);
|
|
18
|
+
__exportStar(require("./nip59.cjs"), exports);
|
|
19
|
+
__exportStar(require("./signers/nip01.cjs"), exports);
|
|
20
|
+
__exportStar(require("./signers/nip07.cjs"), exports);
|
|
21
|
+
__exportStar(require("./signers/nip46.cjs"), exports);
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAAsB;AACtB,8CAAuB;AACvB,sDAA+B;AAC/B,sDAA+B;AAC/B,sDAA+B"}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './util';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './signers/
|
|
4
|
-
export * from './signers/
|
|
5
|
-
export * from './signers/
|
|
2
|
+
export * from './nip59';
|
|
3
|
+
export * from './signers/nip01';
|
|
4
|
+
export * from './signers/nip07';
|
|
5
|
+
export * from './signers/nip46';
|
package/build/src/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./util.mjs";
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./signers/
|
|
4
|
-
export * from "./signers/
|
|
5
|
-
export * from "./signers/
|
|
2
|
+
export * from "./nip59.mjs";
|
|
3
|
+
export * from "./signers/nip01.mjs";
|
|
4
|
+
export * from "./signers/nip07.mjs";
|
|
5
|
+
export * from "./signers/nip46.mjs";
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Nip59 = exports.unwrap = exports.wrap = exports.getWrap = exports.getSeal = exports.getRumor = exports.now = exports.seen = void 0;
|
|
4
|
+
const util_1 = require("@welshman/util");
|
|
5
|
+
const util_2 = require("./util.cjs");
|
|
6
|
+
const nip01_1 = require("./signers/nip01.cjs");
|
|
7
|
+
exports.seen = new Map();
|
|
8
|
+
const now = (drift = 0) => Math.round(Date.now() / 1000 - Math.random() * Math.pow(10, drift));
|
|
9
|
+
exports.now = now;
|
|
10
|
+
const getRumor = async (signer, template) => (0, util_2.hash)((0, util_2.own)(template, await signer.getPubkey()));
|
|
11
|
+
exports.getRumor = getRumor;
|
|
12
|
+
const getSeal = async (signer, pubkey, rumor) => signer.sign((0, util_2.hash)({
|
|
13
|
+
kind: util_1.SEAL,
|
|
14
|
+
pubkey: await signer.getPubkey(),
|
|
15
|
+
content: await signer.nip44.encrypt(pubkey, JSON.stringify(rumor)),
|
|
16
|
+
created_at: (0, exports.now)(5),
|
|
17
|
+
tags: [],
|
|
18
|
+
}));
|
|
19
|
+
exports.getSeal = getSeal;
|
|
20
|
+
const getWrap = async (wrapper, pubkey, seal, tags) => wrapper.sign((0, util_2.hash)({
|
|
21
|
+
kind: util_1.WRAP,
|
|
22
|
+
pubkey: await wrapper.getPubkey(),
|
|
23
|
+
content: await wrapper.nip44.encrypt(pubkey, JSON.stringify(seal)),
|
|
24
|
+
created_at: (0, exports.now)(5),
|
|
25
|
+
tags: [...tags, ["p", pubkey]],
|
|
26
|
+
}));
|
|
27
|
+
exports.getWrap = getWrap;
|
|
28
|
+
const wrap = async (signer, wrapper, pubkey, template, tags = []) => {
|
|
29
|
+
const rumor = await (0, exports.getRumor)(signer, template);
|
|
30
|
+
const seal = await (0, exports.getSeal)(signer, pubkey, rumor);
|
|
31
|
+
const wrap = await (0, exports.getWrap)(wrapper, pubkey, seal, tags);
|
|
32
|
+
return Object.assign(rumor, { wrap });
|
|
33
|
+
};
|
|
34
|
+
exports.wrap = wrap;
|
|
35
|
+
const unwrap = async (signer, wrap) => {
|
|
36
|
+
// Avoid decrypting the same event multiple times
|
|
37
|
+
if (exports.seen.has(wrap.id)) {
|
|
38
|
+
const rumorOrError = exports.seen.get(wrap.id);
|
|
39
|
+
if (rumorOrError instanceof Error) {
|
|
40
|
+
throw rumorOrError;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return rumorOrError;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const seal = JSON.parse(await (0, util_2.decrypt)(signer, wrap.pubkey, wrap.content));
|
|
48
|
+
const rumor = JSON.parse(await (0, util_2.decrypt)(signer, seal.pubkey, seal.content));
|
|
49
|
+
if (seal.pubkey !== rumor.pubkey)
|
|
50
|
+
throw new Error("Seal pubkey does not match rumor pubkey");
|
|
51
|
+
exports.seen.set(wrap.id, rumor);
|
|
52
|
+
return Object.assign(rumor, { wrap });
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
exports.seen.set(wrap.id, error);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.unwrap = unwrap;
|
|
60
|
+
// This is a utility that makes it harder to re-use wrapper signers, since that can result in
|
|
61
|
+
// leaked metadata. It simultaneously makes it easier to wrap stuff, because it allows for
|
|
62
|
+
// wrapping a single user signer and omit the wrapper signer argument to wrap, while still
|
|
63
|
+
// making it possible to pass a wrapper signer if desired.
|
|
64
|
+
class Nip59 {
|
|
65
|
+
constructor(signer, wrapper) {
|
|
66
|
+
this.signer = signer;
|
|
67
|
+
this.wrapper = wrapper;
|
|
68
|
+
this.withWrapper = (wrapper) => new Nip59(this.signer, wrapper);
|
|
69
|
+
this.wrap = (pubkey, template, tags = []) => (0, exports.wrap)(this.signer, this.wrapper || nip01_1.Nip01Signer.ephemeral(), pubkey, template, tags);
|
|
70
|
+
this.unwrap = (event) => (0, exports.unwrap)(this.signer, event);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Nip59 = Nip59;
|
|
74
|
+
Nip59.fromSigner = (signer) => new Nip59(signer);
|
|
75
|
+
Nip59.fromSecret = (secret) => new Nip59(new nip01_1.Nip01Signer(secret));
|
|
76
|
+
//# sourceMappingURL=nip59.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip59.cjs","sourceRoot":"","sources":["../../src/nip59.ts"],"names":[],"mappings":";;;AAAA,yCAAiG;AACjG,qCAAkD;AAClD,+CAA2C;AAE9B,QAAA,IAAI,GAAG,IAAI,GAAG,EAAkC,CAAA;AAEtD,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;AADxD,QAAA,GAAG,OACqD;AAE9D,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAe,EAAE,QAAsB,EAAE,EAAE,CACxE,IAAA,WAAI,EAAC,IAAA,UAAG,EAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AADlC,QAAA,QAAQ,YAC0B;AAExC,MAAM,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AAC,CAAA;AA1BY,QAAA,MAAM,UA0BlB;AAED,6FAA6F;AAC7F,0FAA0F;AAC1F,0FAA0F;AAC1F,0DAA0D;AAC1D,MAAa,KAAK;IAChB,YAAoB,MAAe,EAAU,OAAiB;QAA1C,WAAM,GAAN,MAAM,CAAS;QAAU,YAAO,GAAP,OAAO,CAAU;QAM9D,gBAAW,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAEnE,SAAI,GAAG,CAAC,MAAc,EAAE,QAAsB,EAAE,OAAmB,EAAE,EAAE,EAAE,CACvE,IAAA,YAAI,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,mBAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;QAEpF,WAAM,GAAG,CAAC,KAAkB,EAAE,EAAE,CAC9B,IAAA,cAAM,EAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAZqC,CAAC;;AADpE,sBAcC;AAXQ,gBAAU,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,AAAzC,CAAyC;AAEnD,gBAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,mBAAW,CAAC,MAAM,CAAC,CAAC,AAAzD,CAAyD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UnwrappedEvent, SignedEvent, HashedEvent, StampedEvent } from '@welshman/util';
|
|
2
|
+
import { ISigner } from './util';
|
|
3
|
+
export declare const seen: Map<string, UnwrappedEvent | Error>;
|
|
4
|
+
export declare const now: (drift?: number) => number;
|
|
5
|
+
export declare const getRumor: (signer: ISigner, template: StampedEvent) => Promise<{
|
|
6
|
+
id: string;
|
|
7
|
+
tags: string[][];
|
|
8
|
+
content: string;
|
|
9
|
+
kind: number;
|
|
10
|
+
created_at: number;
|
|
11
|
+
pubkey: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const getSeal: (signer: ISigner, pubkey: string, rumor: HashedEvent) => Promise<SignedEvent>;
|
|
14
|
+
export declare const getWrap: (wrapper: ISigner, pubkey: string, seal: SignedEvent, tags: string[][]) => Promise<SignedEvent>;
|
|
15
|
+
export declare const wrap: (signer: ISigner, wrapper: ISigner, pubkey: string, template: StampedEvent, tags?: string[][]) => Promise<UnwrappedEvent>;
|
|
16
|
+
export declare const unwrap: (signer: ISigner, wrap: SignedEvent) => Promise<UnwrappedEvent | undefined>;
|
|
17
|
+
export declare class Nip59 {
|
|
18
|
+
private signer;
|
|
19
|
+
private wrapper?;
|
|
20
|
+
constructor(signer: ISigner, wrapper?: ISigner | undefined);
|
|
21
|
+
static fromSigner: (signer: ISigner) => Nip59;
|
|
22
|
+
static fromSecret: (secret: string) => Nip59;
|
|
23
|
+
withWrapper: (wrapper: ISigner) => Nip59;
|
|
24
|
+
wrap: (pubkey: string, template: StampedEvent, tags?: string[][]) => Promise<UnwrappedEvent>;
|
|
25
|
+
unwrap: (event: SignedEvent) => Promise<UnwrappedEvent | undefined>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { WRAP, SEAL } from '@welshman/util';
|
|
2
|
+
import { own, hash, decrypt } from "./util.mjs";
|
|
3
|
+
import { Nip01Signer } from "./signers/nip01.mjs";
|
|
4
|
+
export const seen = new Map();
|
|
5
|
+
export const now = (drift = 0) => Math.round(Date.now() / 1000 - Math.random() * Math.pow(10, drift));
|
|
6
|
+
export const getRumor = async (signer, template) => hash(own(template, await signer.getPubkey()));
|
|
7
|
+
export const getSeal = async (signer, pubkey, rumor) => signer.sign(hash({
|
|
8
|
+
kind: SEAL,
|
|
9
|
+
pubkey: await signer.getPubkey(),
|
|
10
|
+
content: await signer.nip44.encrypt(pubkey, JSON.stringify(rumor)),
|
|
11
|
+
created_at: now(5),
|
|
12
|
+
tags: [],
|
|
13
|
+
}));
|
|
14
|
+
export const getWrap = async (wrapper, pubkey, seal, tags) => wrapper.sign(hash({
|
|
15
|
+
kind: WRAP,
|
|
16
|
+
pubkey: await wrapper.getPubkey(),
|
|
17
|
+
content: await wrapper.nip44.encrypt(pubkey, JSON.stringify(seal)),
|
|
18
|
+
created_at: now(5),
|
|
19
|
+
tags: [...tags, ["p", pubkey]],
|
|
20
|
+
}));
|
|
21
|
+
export const wrap = async (signer, wrapper, pubkey, template, tags = []) => {
|
|
22
|
+
const rumor = await getRumor(signer, template);
|
|
23
|
+
const seal = await getSeal(signer, pubkey, rumor);
|
|
24
|
+
const wrap = await getWrap(wrapper, pubkey, seal, tags);
|
|
25
|
+
return Object.assign(rumor, { wrap });
|
|
26
|
+
};
|
|
27
|
+
export const unwrap = async (signer, wrap) => {
|
|
28
|
+
// Avoid decrypting the same event multiple times
|
|
29
|
+
if (seen.has(wrap.id)) {
|
|
30
|
+
const rumorOrError = seen.get(wrap.id);
|
|
31
|
+
if (rumorOrError instanceof Error) {
|
|
32
|
+
throw rumorOrError;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return rumorOrError;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const seal = JSON.parse(await decrypt(signer, wrap.pubkey, wrap.content));
|
|
40
|
+
const rumor = JSON.parse(await decrypt(signer, seal.pubkey, seal.content));
|
|
41
|
+
if (seal.pubkey !== rumor.pubkey)
|
|
42
|
+
throw new Error("Seal pubkey does not match rumor pubkey");
|
|
43
|
+
seen.set(wrap.id, rumor);
|
|
44
|
+
return Object.assign(rumor, { wrap });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
seen.set(wrap.id, error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
// This is a utility that makes it harder to re-use wrapper signers, since that can result in
|
|
52
|
+
// leaked metadata. It simultaneously makes it easier to wrap stuff, because it allows for
|
|
53
|
+
// wrapping a single user signer and omit the wrapper signer argument to wrap, while still
|
|
54
|
+
// making it possible to pass a wrapper signer if desired.
|
|
55
|
+
export class Nip59 {
|
|
56
|
+
constructor(signer, wrapper) {
|
|
57
|
+
this.signer = signer;
|
|
58
|
+
this.wrapper = wrapper;
|
|
59
|
+
this.withWrapper = (wrapper) => new Nip59(this.signer, wrapper);
|
|
60
|
+
this.wrap = (pubkey, template, tags = []) => wrap(this.signer, this.wrapper || Nip01Signer.ephemeral(), pubkey, template, tags);
|
|
61
|
+
this.unwrap = (event) => unwrap(this.signer, event);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
Nip59.fromSigner = (signer) => new Nip59(signer);
|
|
65
|
+
Nip59.fromSecret = (secret) => new Nip59(new Nip01Signer(secret));
|
|
66
|
+
//# sourceMappingURL=nip59.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip59.mjs","sourceRoot":"","sources":["../../src/nip59.ts"],"names":[],"mappings":"OAAO,EAAyD,IAAI,EAAE,IAAI,EAAC,MAAM,gBAAgB;OAC1F,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAU;OAC7B,EAAC,WAAW,EAAC;AAEpB,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkC,CAAA;AAE7D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAA;AAErE,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAe,EAAE,QAAsB,EAAE,EAAE,CACxE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;AAE/C,MAAM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M,OAAO,KAAK;IAChB,YAAoB,MAAe,EAAU,OAAiB;QAA1C,WAAM,GAAN,MAAM,CAAS;QAAU,YAAO,GAAP,OAAO,CAAU;QAM9D,gBAAW,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAEnE,SAAI,GAAG,CAAC,MAAc,EAAE,QAAsB,EAAE,OAAmB,EAAE,EAAE,EAAE,CACvE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;QAEpF,WAAM,GAAG,CAAC,KAAkB,EAAE,EAAE,CAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAZqC,CAAC;;AAE3D,gBAAU,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,AAAzC,CAAyC;AAEnD,gBAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,AAAzD,CAAyD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Nip01Signer = void 0;
|
|
4
|
+
const util_1 = require("../util.cjs");
|
|
5
|
+
class Nip01Signer {
|
|
6
|
+
constructor(secret) {
|
|
7
|
+
this.secret = secret;
|
|
8
|
+
this.getPubkey = async () => this.pubkey;
|
|
9
|
+
this.sign = async (event) => (0, util_1.sign)((0, util_1.hash)((0, util_1.own)(event, this.pubkey)), this.secret);
|
|
10
|
+
this.nip04 = {
|
|
11
|
+
encrypt: async (pubkey, message) => util_1.nip04.encrypt(pubkey, this.secret, message),
|
|
12
|
+
decrypt: async (pubkey, message) => util_1.nip04.decrypt(pubkey, this.secret, message),
|
|
13
|
+
};
|
|
14
|
+
this.nip44 = {
|
|
15
|
+
encrypt: async (pubkey, message) => util_1.nip44.encrypt(pubkey, this.secret, message),
|
|
16
|
+
decrypt: async (pubkey, message) => util_1.nip44.decrypt(pubkey, this.secret, message),
|
|
17
|
+
};
|
|
18
|
+
this.pubkey = (0, util_1.getPubkey)(this.secret);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Nip01Signer = Nip01Signer;
|
|
22
|
+
Nip01Signer.fromSecret = (secret) => new Nip01Signer(secret);
|
|
23
|
+
Nip01Signer.ephemeral = () => new Nip01Signer((0, util_1.makeSecret)());
|
|
24
|
+
//# sourceMappingURL=nip01.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip01.cjs","sourceRoot":"","sources":["../../../src/signers/nip01.ts"],"names":[],"mappings":";;;AACA,sCAAqF;AAErF,MAAa,WAAW;IAGtB,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAQlC,cAAS,GAAG,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAA;QAEnC,SAAI,GAAG,KAAK,EAAE,KAAmB,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAA,WAAI,EAAC,IAAA,UAAG,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEtF,UAAK,GAAG;YACN,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,YAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC7C,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,YAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;SAC9C,CAAA;QAED,UAAK,GAAG;YACN,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,YAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC7C,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,YAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;SAC9C,CAAA;QAvBC,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;;AALH,kCA4BC;AArBQ,sBAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,AAA9C,CAA8C;AAExD,qBAAS,GAAG,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,IAAA,iBAAU,GAAE,CAAC,AAAtC,CAAsC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StampedEvent } from '@welshman/util';
|
|
2
2
|
import { ISigner } from "../util";
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class Nip01Signer implements ISigner {
|
|
4
4
|
private secret;
|
|
5
5
|
private pubkey;
|
|
6
6
|
constructor(secret: string);
|
|
7
|
-
|
|
7
|
+
static fromSecret: (secret: string) => Nip01Signer;
|
|
8
|
+
static ephemeral: () => Nip01Signer;
|
|
8
9
|
getPubkey: () => Promise<string>;
|
|
9
|
-
sign: (event:
|
|
10
|
+
sign: (event: StampedEvent) => Promise<{
|
|
10
11
|
sig: string;
|
|
11
|
-
kind: number;
|
|
12
12
|
tags: string[][];
|
|
13
13
|
content: string;
|
|
14
|
+
kind: number;
|
|
14
15
|
created_at: number;
|
|
15
16
|
pubkey: string;
|
|
16
17
|
id: string;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { nip04, nip44, own, hash, sign, getPubkey } from "../util.mjs";
|
|
2
|
-
export class
|
|
1
|
+
import { nip04, nip44, own, hash, sign, getPubkey, makeSecret } from "../util.mjs";
|
|
2
|
+
export class Nip01Signer {
|
|
3
3
|
constructor(secret) {
|
|
4
4
|
this.secret = secret;
|
|
5
|
-
this.isEnabled = () => true;
|
|
6
5
|
this.getPubkey = async () => this.pubkey;
|
|
7
|
-
this.sign = async (event) => sign(hash(own(this.pubkey
|
|
6
|
+
this.sign = async (event) => sign(hash(own(event, this.pubkey)), this.secret);
|
|
8
7
|
this.nip04 = {
|
|
9
8
|
encrypt: async (pubkey, message) => nip04.encrypt(pubkey, this.secret, message),
|
|
10
9
|
decrypt: async (pubkey, message) => nip04.decrypt(pubkey, this.secret, message),
|
|
@@ -16,4 +15,6 @@ export class SecretSigner {
|
|
|
16
15
|
this.pubkey = getPubkey(this.secret);
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
Nip01Signer.fromSecret = (secret) => new Nip01Signer(secret);
|
|
19
|
+
Nip01Signer.ephemeral = () => new Nip01Signer(makeSecret());
|
|
20
|
+
//# sourceMappingURL=nip01.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip01.mjs","sourceRoot":"","sources":["../../../src/signers/nip01.ts"],"names":[],"mappings":"OACO,EAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAW,UAAU,EAAC;AAEtE,MAAM,OAAO,WAAW;IAGtB,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAQlC,cAAS,GAAG,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAA;QAEnC,SAAI,GAAG,KAAK,EAAE,KAAmB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEtF,UAAK,GAAG;YACN,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC7C,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;SAC9C,CAAA;QAED,UAAK,GAAG;YACN,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;YAC7C,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,OAAe,EAAE,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;SAC9C,CAAA;QAvBC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACtC,CAAC;;AAEM,sBAAU,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,AAA9C,CAA8C;AAExD,qBAAS,GAAG,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,UAAU,EAAE,CAAC,AAAtC,CAAsC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
+
};
|
|
13
|
+
var _Nip07Signer_lock, _Nip07Signer_then;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Nip07Signer = exports.getNip07 = void 0;
|
|
16
|
+
const util_1 = require("../util.cjs");
|
|
17
|
+
const getNip07 = () => window.nostr;
|
|
18
|
+
exports.getNip07 = getNip07;
|
|
19
|
+
class Nip07Signer {
|
|
20
|
+
constructor() {
|
|
21
|
+
_Nip07Signer_lock.set(this, Promise.resolve());
|
|
22
|
+
_Nip07Signer_then.set(this, async (f) => {
|
|
23
|
+
const promise = __classPrivateFieldGet(this, _Nip07Signer_lock, "f").then(() => {
|
|
24
|
+
const ext = (0, exports.getNip07)();
|
|
25
|
+
if (!ext)
|
|
26
|
+
throw new Error("Nip07 is not enabled");
|
|
27
|
+
return f(ext);
|
|
28
|
+
});
|
|
29
|
+
// Recover from errors
|
|
30
|
+
__classPrivateFieldSet(this, _Nip07Signer_lock, promise.then(() => undefined, () => undefined), "f");
|
|
31
|
+
return promise;
|
|
32
|
+
});
|
|
33
|
+
this.getPubkey = async () => (0, exports.getNip07)().getPublicKey();
|
|
34
|
+
this.sign = async (template) => {
|
|
35
|
+
const event = (0, util_1.hash)((0, util_1.own)(template, await this.getPubkey()));
|
|
36
|
+
return __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.signEvent(event));
|
|
37
|
+
};
|
|
38
|
+
this.nip04 = {
|
|
39
|
+
encrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip04.encrypt(pubkey, message)),
|
|
40
|
+
decrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip04.decrypt(pubkey, message)),
|
|
41
|
+
};
|
|
42
|
+
this.nip44 = {
|
|
43
|
+
encrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip44.encrypt(pubkey, message)),
|
|
44
|
+
decrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip44.decrypt(pubkey, message)),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Nip07Signer = Nip07Signer;
|
|
49
|
+
_Nip07Signer_lock = new WeakMap(), _Nip07Signer_then = new WeakMap();
|
|
50
|
+
//# sourceMappingURL=nip07.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip07.cjs","sourceRoot":"","sources":["../../../src/signers/nip07.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,sCAA0E;AASnE,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAE,MAA0B,CAAC,KAAK,CAAA;AAAlD,QAAA,QAAQ,YAA0C;AAE/D,MAAa,WAAW;IAAxB;QACE,4BAAQ,OAAO,CAAC,OAAO,EAAE,EAAA;QAEzB,4BAAQ,KAAK,EAAK,CAAiC,EAAE,EAAE;YACrD,MAAM,OAAO,GAAG,uBAAA,IAAI,yBAAM,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnC,MAAM,GAAG,GAAG,IAAA,gBAAQ,GAAE,CAAA;gBAEtB,IAAI,CAAC,GAAG;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;gBAEjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;YAEF,sBAAsB;YACtB,uBAAA,IAAI,qBAAS,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE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AC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACxD,CAAA;IACH,CAAC;CAAA;AAvCD,kCAuCC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StampedEvent } from '@welshman/util';
|
|
2
2
|
import { Sign, ISigner, EncryptionImplementation } from '../util';
|
|
3
|
-
export type
|
|
4
|
-
|
|
3
|
+
export type Nip07 = {
|
|
4
|
+
signEvent: Sign;
|
|
5
5
|
nip04: EncryptionImplementation;
|
|
6
6
|
nip44: EncryptionImplementation;
|
|
7
7
|
getPublicKey: () => string | undefined;
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
9
|
+
export declare const getNip07: () => Nip07 | undefined;
|
|
10
|
+
export declare class Nip07Signer implements ISigner {
|
|
10
11
|
#private;
|
|
11
|
-
isEnabled: () => boolean;
|
|
12
12
|
getPubkey: () => Promise<string>;
|
|
13
|
-
sign: (
|
|
13
|
+
sign: (template: StampedEvent) => Promise<import("@welshman/util").SignedEvent>;
|
|
14
14
|
nip04: {
|
|
15
15
|
encrypt: (pubkey: string, message: string) => Promise<string>;
|
|
16
16
|
decrypt: (pubkey: string, message: string) => Promise<string>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _Nip07Signer_lock, _Nip07Signer_then;
|
|
13
|
+
import { hash, own } from "../util.mjs";
|
|
14
|
+
export const getNip07 = () => window.nostr;
|
|
15
|
+
export class Nip07Signer {
|
|
16
|
+
constructor() {
|
|
17
|
+
_Nip07Signer_lock.set(this, Promise.resolve());
|
|
18
|
+
_Nip07Signer_then.set(this, async (f) => {
|
|
19
|
+
const promise = __classPrivateFieldGet(this, _Nip07Signer_lock, "f").then(() => {
|
|
20
|
+
const ext = getNip07();
|
|
21
|
+
if (!ext)
|
|
22
|
+
throw new Error("Nip07 is not enabled");
|
|
23
|
+
return f(ext);
|
|
24
|
+
});
|
|
25
|
+
// Recover from errors
|
|
26
|
+
__classPrivateFieldSet(this, _Nip07Signer_lock, promise.then(() => undefined, () => undefined), "f");
|
|
27
|
+
return promise;
|
|
28
|
+
});
|
|
29
|
+
this.getPubkey = async () => getNip07().getPublicKey();
|
|
30
|
+
this.sign = async (template) => {
|
|
31
|
+
const event = hash(own(template, await this.getPubkey()));
|
|
32
|
+
return __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.signEvent(event));
|
|
33
|
+
};
|
|
34
|
+
this.nip04 = {
|
|
35
|
+
encrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip04.encrypt(pubkey, message)),
|
|
36
|
+
decrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip04.decrypt(pubkey, message)),
|
|
37
|
+
};
|
|
38
|
+
this.nip44 = {
|
|
39
|
+
encrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip44.encrypt(pubkey, message)),
|
|
40
|
+
decrypt: (pubkey, message) => __classPrivateFieldGet(this, _Nip07Signer_then, "f").call(this, ext => ext.nip44.decrypt(pubkey, message)),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
_Nip07Signer_lock = new WeakMap(), _Nip07Signer_then = new WeakMap();
|
|
45
|
+
//# sourceMappingURL=nip07.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip07.mjs","sourceRoot":"","sources":["../../../src/signers/nip07.ts"],"names":[],"mappings":";;;;;;;;;;;;OACO,EAAC,IAAI,EAAE,GAAG,EAA0C;AAS3D,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAE,MAA0B,CAAC,KAAK,CAAA;AAE/D,MAAM,OAAO,WAAW;IAAxB;QACE,4BAAQ,OAAO,CAAC,OAAO,EAAE,EAAA;QAEzB,4BAAQ,KAAK,EAAK,CAAiC,EAAE,EAAE;YACrD,MAAM,OAAO,GAAG,uBAAA,IAAI,yBAAM,CAAC,IAAI,CAAC,GAAG,EAAE;gBACnC,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAA;gBAEtB,IAAI,CAAC,GAAG;oBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;gBAEjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAA;YACf,CAAC,CAAC,CAAA;YAEF,sBAAsB;YACtB,uBAAA,IAAI,qBAAS,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,MAAA,CAAA;YAE3D,OAAO,OAAO,CAAA;QAChB,CAAC,EAAA;QAED,cAAS,GAAG,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAG,CAAC,YAAY,EAAG,CAAA;QAEnD,SAAI,GAAG,KAAK,EAAE,QAAsB,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;YAEzD,OAAO,uBAAA,IAAI,yBAAM,MAAV,IAAI,EAAO,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAChD,CAAC,CAAA;QAED,UAAK,GAAG;YACN,OAAO,EAAE,CAAC,MAAc,EAAE,OAAe,EAAE,EAAE,CAC3C,uBAAA,IAAI,yBAAM,MAAV,IAAI,EAAO,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvD,OAAO,EAAE,CAAC,MAAc,EAAE,OAAe,EAAE,EAAE,CAC3C,uBAAA,IAAI,yBAAM,MAAV,IAAI,EAAO,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACxD,CAAA;QAED,UAAK,GAAG;YACN,OAAO,EAAE,CAAC,MAAc,EAAE,OAAe,EAAE,EAAE,CAC3C,uBAAA,IAAI,yBAAM,MAAV,IAAI,EAAO,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvD,OAAO,EAAE,CAAC,MAAc,EAAE,OAAe,EAAE,EAAE,CAC3C,uBAAA,IAAI,yBAAM,MAAV,IAAI,EAAO,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACxD,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Nip46Broker_sub, _Nip46Broker_signer, _Nip46Broker_ready, _Nip46Broker_closed, _Nip46Broker_connectResult;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Nip46Signer = exports.Nip46Broker = void 0;
|
|
16
|
+
const nostr_tools_1 = require("nostr-tools");
|
|
17
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
18
|
+
const lib_1 = require("@welshman/lib");
|
|
19
|
+
const util_1 = require("@welshman/util");
|
|
20
|
+
const net_1 = require("@welshman/net");
|
|
21
|
+
const util_2 = require("../util.cjs");
|
|
22
|
+
const nip01_1 = require("./nip01.cjs");
|
|
23
|
+
let singleton;
|
|
24
|
+
class Nip46Broker extends lib_1.Emitter {
|
|
25
|
+
static get(pubkey, secret, handler, algorithm = "nip04") {
|
|
26
|
+
if ((singleton === null || singleton === void 0 ? void 0 : singleton.pubkey) !== pubkey ||
|
|
27
|
+
(singleton === null || singleton === void 0 ? void 0 : singleton.secret) !== secret ||
|
|
28
|
+
!(0, lib_1.equals)(singleton === null || singleton === void 0 ? void 0 : singleton.handler, handler) ||
|
|
29
|
+
(singleton === null || singleton === void 0 ? void 0 : singleton.algorithm) !== algorithm) {
|
|
30
|
+
singleton === null || singleton === void 0 ? void 0 : singleton.teardown();
|
|
31
|
+
singleton = new Nip46Broker(pubkey, secret, handler, algorithm);
|
|
32
|
+
}
|
|
33
|
+
return singleton;
|
|
34
|
+
}
|
|
35
|
+
constructor(pubkey, secret, handler, algorithm) {
|
|
36
|
+
super();
|
|
37
|
+
this.pubkey = pubkey;
|
|
38
|
+
this.secret = secret;
|
|
39
|
+
this.handler = handler;
|
|
40
|
+
this.algorithm = algorithm;
|
|
41
|
+
_Nip46Broker_sub.set(this, void 0);
|
|
42
|
+
_Nip46Broker_signer.set(this, void 0);
|
|
43
|
+
_Nip46Broker_ready.set(this, (0, lib_1.sleep)(500));
|
|
44
|
+
_Nip46Broker_closed.set(this, false);
|
|
45
|
+
_Nip46Broker_connectResult.set(this, void 0);
|
|
46
|
+
this.subscribe = () => {
|
|
47
|
+
const sub = (0, net_1.subscribe)({
|
|
48
|
+
relays: this.handler.relays,
|
|
49
|
+
filters: [
|
|
50
|
+
{
|
|
51
|
+
since: (0, lib_1.now)() - 30,
|
|
52
|
+
kinds: [util_1.NOSTR_CONNECT],
|
|
53
|
+
"#p": [(0, nostr_tools_1.getPublicKey)((0, utils_1.hexToBytes)(this.secret))],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
sub.emitter.on("event", async (url, e) => {
|
|
58
|
+
const json = await (0, util_2.decrypt)(__classPrivateFieldGet(this, _Nip46Broker_signer, "f"), e.pubkey, e.content);
|
|
59
|
+
const res = await (0, lib_1.tryCatch)(() => JSON.parse(json));
|
|
60
|
+
if (!res.id) {
|
|
61
|
+
console.error(`Invalid nostr-connect response: ${json}`);
|
|
62
|
+
}
|
|
63
|
+
if (res.result === "auth_url") {
|
|
64
|
+
this.emit(`auth-${res.id}`, res);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.emit(`res-${res.id}`, res);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
sub.emitter.on("complete", () => {
|
|
71
|
+
if (!__classPrivateFieldGet(this, _Nip46Broker_closed, "f")) {
|
|
72
|
+
__classPrivateFieldSet(this, _Nip46Broker_sub, this.subscribe(), "f");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return sub;
|
|
76
|
+
};
|
|
77
|
+
this.request = async (method, params, admin = false) => {
|
|
78
|
+
// nsecbunker has a race condition
|
|
79
|
+
await __classPrivateFieldGet(this, _Nip46Broker_ready, "f");
|
|
80
|
+
const id = (0, lib_1.randomId)();
|
|
81
|
+
const pubkey = admin ? this.handler.pubkey : this.pubkey;
|
|
82
|
+
const payload = JSON.stringify({ id, method, params });
|
|
83
|
+
const crypt = this.algorithm === "nip04" ? util_2.nip04 : util_2.nip44;
|
|
84
|
+
const content = await crypt.encrypt(pubkey, this.secret, payload);
|
|
85
|
+
const template = (0, util_1.createEvent)(util_1.NOSTR_CONNECT, { content, tags: [["p", pubkey]] });
|
|
86
|
+
const event = (0, nostr_tools_1.finalizeEvent)(template, this.secret);
|
|
87
|
+
(0, net_1.publish)({ event, relays: this.handler.relays });
|
|
88
|
+
this.once(`auth-${id}`, res => {
|
|
89
|
+
window.open(res.error, "Coracle", "width=600,height=800,popup=yes");
|
|
90
|
+
});
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
this.once(`res-${id}`, ({ result, error }) => {
|
|
93
|
+
if (error) {
|
|
94
|
+
reject(error);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
resolve(result);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
this.createAccount = (username, perms = "") => {
|
|
103
|
+
if (!this.handler.domain) {
|
|
104
|
+
throw new Error("Unable to create an account without a handler domain");
|
|
105
|
+
}
|
|
106
|
+
return this.request("create_account", [username, this.handler.domain, "", perms], true);
|
|
107
|
+
};
|
|
108
|
+
this.connect = async (token = "", perms = "") => {
|
|
109
|
+
if (!__classPrivateFieldGet(this, _Nip46Broker_connectResult, "f")) {
|
|
110
|
+
const params = [this.pubkey, token, perms];
|
|
111
|
+
__classPrivateFieldSet(this, _Nip46Broker_connectResult, await this.request("connect", params), "f");
|
|
112
|
+
}
|
|
113
|
+
return __classPrivateFieldGet(this, _Nip46Broker_connectResult, "f") === "ack";
|
|
114
|
+
};
|
|
115
|
+
this.signEvent = async (event) => {
|
|
116
|
+
return JSON.parse(await this.request("sign_event", [JSON.stringify(event)]));
|
|
117
|
+
};
|
|
118
|
+
this.nip04Encrypt = (pk, message) => {
|
|
119
|
+
return this.request("nip04_encrypt", [pk, message]);
|
|
120
|
+
};
|
|
121
|
+
this.nip04Decrypt = (pk, message) => {
|
|
122
|
+
return this.request("nip04_decrypt", [pk, message]);
|
|
123
|
+
};
|
|
124
|
+
this.nip44Encrypt = (pk, message) => {
|
|
125
|
+
return this.request("nip44_encrypt", [pk, message]);
|
|
126
|
+
};
|
|
127
|
+
this.nip44Decrypt = (pk, message) => {
|
|
128
|
+
return this.request("nip44_decrypt", [pk, message]);
|
|
129
|
+
};
|
|
130
|
+
this.teardown = () => {
|
|
131
|
+
var _a;
|
|
132
|
+
__classPrivateFieldSet(this, _Nip46Broker_closed, true, "f");
|
|
133
|
+
(_a = __classPrivateFieldGet(this, _Nip46Broker_sub, "f")) === null || _a === void 0 ? void 0 : _a.close();
|
|
134
|
+
};
|
|
135
|
+
__classPrivateFieldSet(this, _Nip46Broker_signer, new nip01_1.Nip01Signer(secret), "f");
|
|
136
|
+
__classPrivateFieldSet(this, _Nip46Broker_sub, this.subscribe(), "f");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Nip46Broker = Nip46Broker;
|
|
140
|
+
_Nip46Broker_sub = new WeakMap(), _Nip46Broker_signer = new WeakMap(), _Nip46Broker_ready = new WeakMap(), _Nip46Broker_closed = new WeakMap(), _Nip46Broker_connectResult = new WeakMap();
|
|
141
|
+
class Nip46Signer {
|
|
142
|
+
constructor(broker) {
|
|
143
|
+
this.broker = broker;
|
|
144
|
+
this.getPubkey = async () => this.broker.pubkey;
|
|
145
|
+
this.sign = (template) => this.broker.signEvent((0, util_2.hash)((0, util_2.own)(template, this.broker.pubkey)));
|
|
146
|
+
this.nip04 = {
|
|
147
|
+
encrypt: this.broker.nip04Encrypt,
|
|
148
|
+
decrypt: this.broker.nip04Decrypt,
|
|
149
|
+
};
|
|
150
|
+
this.nip44 = {
|
|
151
|
+
encrypt: this.broker.nip44Encrypt,
|
|
152
|
+
decrypt: this.broker.nip44Decrypt,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.Nip46Signer = Nip46Signer;
|
|
157
|
+
//# sourceMappingURL=nip46.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nip46.cjs","sourceRoot":"","sources":["../../../src/signers/nip46.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,+CAA8C;AAC9C,uCAA6E;AAC7E,yCAAqF;AACrF,uCAA8D;AAC9D,sCAAiE;AACjE,uCAAmC;AAgBnC,IAAI,SAAsB,CAAA;AAE1B,MAAa,WAAY,SAAQ,aAAO;IAOtC,MAAM,CAAC,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,OAAqB,EAAE,YAAuB,OAAO;QAC9F,IACE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,MAAK,MAAM;YAC5B,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,MAAK,MAAM;YAC5B,CAAC,IAAA,YAAM,EAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,EAAE,OAAO,CAAC;YACpC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,MAAK,SAAS,EAClC;YACA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,CAAA;YACrB,SAAS,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;S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