@authenticdoc/sdk 0.1.1
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/LICENSE +10 -0
- package/README.md +130 -0
- package/dist/index.d.ts +173 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +319 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/wasm/authenticdoc.d.ts +318 -0
- package/dist/wasm/authenticdoc.js +1734 -0
- package/dist/wasm/authenticdoc_bg.wasm +0 -0
- package/dist/wasm/authenticdoc_bg.wasm.d.ts +56 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
PROPRIETARY LICENSE — PLACEHOLDER
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Illuminodes. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This source code is proprietary and confidential. Unauthorized copying,
|
|
6
|
+
distribution, modification, or use of this code, via any medium, is strictly
|
|
7
|
+
prohibited without express written permission from the copyright holder.
|
|
8
|
+
|
|
9
|
+
This file is a placeholder. A definitive license will be selected and applied
|
|
10
|
+
before any public release.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @authenticdoc/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript/WASM bindings for the
|
|
4
|
+
[authenticdoc-sdk](https://gitlab.illuminodes.com/authenticdoc/sdk) Rust crypto
|
|
5
|
+
library. The cryptography (secp256k1, NIP-44, nahui AEAD, Nostr event shaping)
|
|
6
|
+
runs in WebAssembly compiled from the **same Rust core** the
|
|
7
|
+
[Go SDK](https://gitlab.illuminodes.com/authenticdoc/go-sdk) binds to — so the
|
|
8
|
+
on-the-wire JSON shapes are identical across all three languages.
|
|
9
|
+
|
|
10
|
+
Runs in **the browser and in Node 20+** from a single artifact.
|
|
11
|
+
|
|
12
|
+
## Status
|
|
13
|
+
|
|
14
|
+
v0.1.0 — keypairs, templates, multi-party signing envelopes, identity helpers,
|
|
15
|
+
badge issuance/verification, and generic note signing.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm install @authenticdoc/sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
The WASM module loads asynchronously, so call `init()` once before anything
|
|
26
|
+
else.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { init, Keypair, Template, Envelope } from "@authenticdoc/sdk";
|
|
30
|
+
|
|
31
|
+
await init();
|
|
32
|
+
|
|
33
|
+
// Author and sign a template.
|
|
34
|
+
const author = Keypair.generate();
|
|
35
|
+
const template = Template.create("Service Agreement", "<contract body>");
|
|
36
|
+
const signed = template.sign(author);
|
|
37
|
+
signed.verify();
|
|
38
|
+
|
|
39
|
+
// Multi-party envelope: each participant signs, the owner finalizes.
|
|
40
|
+
const alice = Keypair.generate();
|
|
41
|
+
const bob = Keypair.generate();
|
|
42
|
+
const relay = "wss://relay.example.com";
|
|
43
|
+
|
|
44
|
+
const envelope = Envelope.create(template, [
|
|
45
|
+
{ role: "signer", pubkey: alice.pubkey, relay },
|
|
46
|
+
{ role: "signer", pubkey: bob.pubkey, relay },
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
const aliceSig = envelope.createParticipantSig(alice);
|
|
50
|
+
const bobSig = envelope.createParticipantSig(bob);
|
|
51
|
+
const finalized = envelope.addParticipantSigsAsOwner(alice, [aliceSig, bobSig]);
|
|
52
|
+
|
|
53
|
+
finalized.verifyAllParticipantSigs(bob); // throws on any bad signature
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This crate is a **primitives library**, not a turn-key client. It encrypts,
|
|
57
|
+
signs, verifies and shapes Nostr events; it does not own a relay connection or
|
|
58
|
+
an HTTP client. Publish the resulting notes (`template.json` / `envelope.json`)
|
|
59
|
+
to your relays with whatever transport you already have.
|
|
60
|
+
|
|
61
|
+
## Building from source
|
|
62
|
+
|
|
63
|
+
The package builds its WASM from the `authenticdoc-sdk` source (the
|
|
64
|
+
`bindings/wasm` crate), pinned as the `vendor/authenticdoc-sdk` git submodule.
|
|
65
|
+
Requires the Rust toolchain with the `wasm32-unknown-unknown` target and
|
|
66
|
+
[`wasm-pack`](https://rustwasm.github.io/wasm-pack/).
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
git clone --recurse-submodules <this repo>
|
|
70
|
+
# or, after a plain clone:
|
|
71
|
+
git submodule update --init
|
|
72
|
+
|
|
73
|
+
npm ci
|
|
74
|
+
npm run build # build wasm + compile TS into dist/
|
|
75
|
+
npm test # build, then run the Node smoke tests
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The build resolves the SDK source in this order: `$AUTHENTICDOC_SDK_DIR`, the
|
|
79
|
+
`vendor/authenticdoc-sdk` submodule, then a sibling `../authenticdoc-sdk`
|
|
80
|
+
checkout (handy for local dev against an unpinned SDK).
|
|
81
|
+
|
|
82
|
+
## Releases
|
|
83
|
+
|
|
84
|
+
Tagging a commit `vX.Y.Z` (matching `package.json`'s version) triggers CI to
|
|
85
|
+
build and publish `@authenticdoc/sdk` to the **public npm registry**. See
|
|
86
|
+
`.gitlab-ci.yml`.
|
|
87
|
+
|
|
88
|
+
### One-time CI setup
|
|
89
|
+
|
|
90
|
+
The runner authenticates to npm with a token stored as a CI variable — no
|
|
91
|
+
`npm login` on the runner.
|
|
92
|
+
|
|
93
|
+
> npm's **Trusted Publishing** (OIDC, no token) is *not* available here: it
|
|
94
|
+
> only supports GitHub Actions, CircleCI, and **GitLab.com SaaS** runners — not
|
|
95
|
+
> self-hosted GitLab instances or self-hosted runners. So we use a scoped,
|
|
96
|
+
> expiring token.
|
|
97
|
+
|
|
98
|
+
1. **Create a npm Granular Access Token.** npmjs.com → Access Tokens → Generate
|
|
99
|
+
New Token → **Granular Access Token**. Set an expiry (e.g. 90 days),
|
|
100
|
+
**Read and write**, restricted to the `@authenticdoc` scope. (Granular and
|
|
101
|
+
classic "Automation" tokens bypass 2FA, which CI requires; a classic
|
|
102
|
+
"Publish" token does not and will hang in CI. Prefer granular — it's scoped
|
|
103
|
+
and expiring, which is what npm recommends when Trusted Publishing is
|
|
104
|
+
unavailable.) Rotate it before expiry.
|
|
105
|
+
2. **Add it to GitLab CI.** Project → Settings → CI/CD → Variables → Add:
|
|
106
|
+
- Key `NPM_TOKEN`, value the `npm_…` token, **Masked** and **Protected**.
|
|
107
|
+
3. **Protect the release tags.** Settings → Repository → Protected tags → add
|
|
108
|
+
`v*`. Protected CI variables are only exposed on protected refs, so without
|
|
109
|
+
this the token would be empty in the tag pipeline and publish fails with
|
|
110
|
+
`ENEEDAUTH`.
|
|
111
|
+
|
|
112
|
+
The committed `.npmrc` reads `${NPM_TOKEN}` at publish time. To cut a release:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
# bump version in package.json, commit, then:
|
|
116
|
+
git tag -a vX.Y.Z -m "Release vX.Y.Z"
|
|
117
|
+
git push origin vX.Y.Z # CI verifies tag == package.json version, then publishes
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Architecture
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
authenticdoc-sdk (Rust core, pure compute)
|
|
124
|
+
├── bindings/ffi → C ABI → Go SDK (cgo)
|
|
125
|
+
└── bindings/wasm → wasm-bindgen → this package (browser + Node)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The wasm bindings mirror the FFI surface (JSON in / JSON out), with two
|
|
129
|
+
WASM-native improvements: keypairs are real JS objects (no integer handle
|
|
130
|
+
table, no lock), and errors surface as thrown exceptions.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @authenticdoc/sdk — TypeScript/WASM bindings for the authenticdoc-sdk Rust
|
|
3
|
+
* crypto library.
|
|
4
|
+
*
|
|
5
|
+
* The heavy lifting (secp256k1, NIP-44, nahui AEAD, Nostr event shaping) runs
|
|
6
|
+
* in WebAssembly compiled from the same Rust core the Go SDK binds to, so the
|
|
7
|
+
* JSON shapes are identical across languages.
|
|
8
|
+
*
|
|
9
|
+
* ## Usage
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { init, Keypair, Template, Envelope } from "@authenticdoc/sdk";
|
|
13
|
+
*
|
|
14
|
+
* await init(); // load the wasm module once, before anything else
|
|
15
|
+
*
|
|
16
|
+
* const alice = Keypair.generate();
|
|
17
|
+
* const tpl = Template.create("Service Agreement", "<body>");
|
|
18
|
+
* const signed = tpl.sign(alice);
|
|
19
|
+
* signed.verify();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import * as wasm from "./wasm/authenticdoc.js";
|
|
23
|
+
import type { DecodedDataUrl, Envelope as EnvelopeJson, EnvelopeParticipant, EnvelopeSignature, NostrNote, Template as TemplateJson } from "./types.js";
|
|
24
|
+
export type { DecodedDataUrl, EnvelopeParticipant, EnvelopeRole, EnvelopeSignature, NostrNote, } from "./types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Load and instantiate the WASM module. Must be awaited once before using any
|
|
27
|
+
* other export. Idempotent — subsequent calls resolve immediately.
|
|
28
|
+
*
|
|
29
|
+
* @param input Optional override for the `.wasm` location (a URL, Request,
|
|
30
|
+
* Response, or bytes). Defaults to the `.wasm` shipped next to the glue,
|
|
31
|
+
* which works out of the box in Node and most bundlers.
|
|
32
|
+
*/
|
|
33
|
+
export declare function init(input?: string | URL | Request | Response | BufferSource | WebAssembly.Module): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* A secp256k1 keypair. The secret key never leaves WASM memory — this object
|
|
36
|
+
* is an opaque handle. Call {@link Keypair.free} when done, or use
|
|
37
|
+
* `using kp = Keypair.generate()` for automatic disposal.
|
|
38
|
+
*/
|
|
39
|
+
export declare class Keypair {
|
|
40
|
+
/** @internal */
|
|
41
|
+
readonly inner: wasm.Keypair;
|
|
42
|
+
private constructor();
|
|
43
|
+
/** Generate a fresh extractable keypair. */
|
|
44
|
+
static generate(): Keypair;
|
|
45
|
+
/** Load a keypair from a bech32 `nsec1…` string. */
|
|
46
|
+
static fromNsec(nsec: string): Keypair;
|
|
47
|
+
/** Load a keypair from a 64-character hex private key. */
|
|
48
|
+
static fromHex(hex: string): Keypair;
|
|
49
|
+
/** Load a keypair from a BIP-39 mnemonic phrase (English, 12 or 24 words). */
|
|
50
|
+
static fromMnemonic(phrase: string): Keypair;
|
|
51
|
+
/** The hex-encoded public key. */
|
|
52
|
+
get pubkey(): string;
|
|
53
|
+
/** Export the bech32 `nsec` (secret material — handle with care). */
|
|
54
|
+
nsec(): string;
|
|
55
|
+
/** Export the 24-word BIP-39 mnemonic (secret material — handle with care). */
|
|
56
|
+
mnemonic(): string;
|
|
57
|
+
/** Release the underlying WASM keypair (scrubs secret material). */
|
|
58
|
+
free(): void;
|
|
59
|
+
[Symbol.dispose](): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A signable document (title, body, UUID) backed by a Nostr parameterized
|
|
63
|
+
* replaceable event. Methods that mutate return a new {@link Template}; the
|
|
64
|
+
* wasm core is stateless (JSON in, JSON out).
|
|
65
|
+
*/
|
|
66
|
+
export declare class Template {
|
|
67
|
+
/** The underlying Nostr note JSON. */
|
|
68
|
+
readonly json: TemplateJson;
|
|
69
|
+
private constructor();
|
|
70
|
+
/** Wrap an existing template JSON object (e.g. one received over the wire). */
|
|
71
|
+
static fromJson(json: TemplateJson): Template;
|
|
72
|
+
/** Build a fresh template with a minted UUID. */
|
|
73
|
+
static create(title: string, body: string): Template;
|
|
74
|
+
/**
|
|
75
|
+
* Build a template from raw file bytes, stored as an RFC 2397 data URL.
|
|
76
|
+
* Pass `id = undefined` or `""` to mint a UUID.
|
|
77
|
+
*/
|
|
78
|
+
static fromBytes(title: string, mime: string, bytes: Uint8Array, id?: string): Template;
|
|
79
|
+
private get raw();
|
|
80
|
+
/** Sign this template with `keypair`, returning the signed template. */
|
|
81
|
+
sign(keypair: Keypair): Template;
|
|
82
|
+
/** Verify the template's event id, signature and shape. Throws on failure. */
|
|
83
|
+
verify(): void;
|
|
84
|
+
/** The document id (the `d` parameter tag). */
|
|
85
|
+
documentId(): string;
|
|
86
|
+
/** The title. */
|
|
87
|
+
title(): string;
|
|
88
|
+
/** The body content. */
|
|
89
|
+
content(): string;
|
|
90
|
+
/** Read the first value of a custom tag. Throws if absent. */
|
|
91
|
+
getTag(key: string): string;
|
|
92
|
+
/** Read the `description` tag. Throws if absent. */
|
|
93
|
+
description(): string;
|
|
94
|
+
/** Whether `content` is a base64 data URL (built via {@link fromBytes}). */
|
|
95
|
+
isDataUrl(): boolean;
|
|
96
|
+
/** Decode a data-URL `content`. Throws if `content` is not a data URL. */
|
|
97
|
+
decodeDataUrl(): DecodedDataUrl;
|
|
98
|
+
/** Add a custom tag, returning the updated template. */
|
|
99
|
+
addTag(key: string, value: string): Template;
|
|
100
|
+
/** Set the document id, returning the updated template. */
|
|
101
|
+
setDocumentId(id: string): Template;
|
|
102
|
+
/** Set the title, returning the updated template. */
|
|
103
|
+
setTitle(title: string): Template;
|
|
104
|
+
/** Add a `description` tag, returning the updated template. */
|
|
105
|
+
addDescription(description: string): Template;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A multi-party signing envelope wrapping a {@link Template} with
|
|
109
|
+
* per-participant key material. Mutating methods return a new {@link Envelope}.
|
|
110
|
+
*/
|
|
111
|
+
export declare class Envelope {
|
|
112
|
+
/** The underlying Nostr note JSON. */
|
|
113
|
+
readonly json: EnvelopeJson;
|
|
114
|
+
private constructor();
|
|
115
|
+
/** Wrap an existing envelope JSON object (e.g. one received over the wire). */
|
|
116
|
+
static fromJson(json: EnvelopeJson): Envelope;
|
|
117
|
+
/** Build a v2 envelope wrapping `template` for `participants`. */
|
|
118
|
+
static create(template: Template, participants: EnvelopeParticipant[]): Envelope;
|
|
119
|
+
/**
|
|
120
|
+
* Build a v2 envelope directly from raw file bytes. Pass `id = undefined` or
|
|
121
|
+
* `""` to mint a UUID.
|
|
122
|
+
*/
|
|
123
|
+
static fromBytes(title: string, mime: string, bytes: Uint8Array, participants: EnvelopeParticipant[], id?: string): Envelope;
|
|
124
|
+
private get raw();
|
|
125
|
+
/** This keypair's participant signature over the inner document. */
|
|
126
|
+
createParticipantSig(keypair: Keypair): EnvelopeSignature;
|
|
127
|
+
/**
|
|
128
|
+
* Verify a single peer's signature (`peerPubkey` hex), returning it.
|
|
129
|
+
* `keypair` must be a participant able to decrypt the body.
|
|
130
|
+
*/
|
|
131
|
+
verifyParticipantSig(keypair: Keypair, peerPubkey: string): EnvelopeSignature;
|
|
132
|
+
/** Attach signatures via the (non-owner) participant path. */
|
|
133
|
+
addParticipantSigs(keypair: Keypair, sigs: EnvelopeSignature[]): Envelope;
|
|
134
|
+
/** Attach signatures via the owner path (idempotent). */
|
|
135
|
+
addParticipantSigsAsOwner(ownerKeypair: Keypair, sigs: EnvelopeSignature[]): Envelope;
|
|
136
|
+
/** Verify every participant signature, returning them. */
|
|
137
|
+
verifyAllParticipantSigs(keypair: Keypair): EnvelopeSignature[];
|
|
138
|
+
/** Decrypt and return the inner document as a Nostr note. */
|
|
139
|
+
viewDocument(keypair: Keypair): NostrNote;
|
|
140
|
+
/** Decrypt the envelope title using a participant keypair. */
|
|
141
|
+
title(keypair: Keypair): string;
|
|
142
|
+
/** The envelope's parameter id (matches the wrapped template id). */
|
|
143
|
+
id(): string;
|
|
144
|
+
/** The participant list. */
|
|
145
|
+
participants(): EnvelopeParticipant[];
|
|
146
|
+
/** The `created_at` timestamp (Unix seconds). */
|
|
147
|
+
timestamp(): bigint;
|
|
148
|
+
/** Sign the envelope's outer Nostr event with `keypair`. */
|
|
149
|
+
sign(keypair: Keypair): Envelope;
|
|
150
|
+
/** Verify the signed envelope (outer event id + signature + shape). */
|
|
151
|
+
verify(): void;
|
|
152
|
+
}
|
|
153
|
+
/** Identity-card and badge helpers. */
|
|
154
|
+
export declare const identity: {
|
|
155
|
+
/** Encode a hex Nostr public key as a bech32 `npub`. */
|
|
156
|
+
npub(pubkeyHex: string): string;
|
|
157
|
+
/** Build an unsigned Nostr event from an Identity JSON object. */
|
|
158
|
+
toEvent(identityJson: unknown): NostrNote;
|
|
159
|
+
/** Parse a Nostr badge-award event into an Identity JSON object. */
|
|
160
|
+
fromEvent(note: NostrNote): unknown;
|
|
161
|
+
/** Wrap a signed inner badge for delivery to a holder. */
|
|
162
|
+
wrapBadge(signedInner: NostrNote, holderPubkey: string, issuerKeypair: Keypair): NostrNote;
|
|
163
|
+
/** Unwrap a badge addressed to the holder keypair. */
|
|
164
|
+
unwrapBadge(outer: NostrNote, holderKeypair: Keypair): unknown;
|
|
165
|
+
/** Verify a badge was issued by `expectedIssuerPubkey`. Throws on mismatch. */
|
|
166
|
+
verifyBadge(badge: unknown, expectedIssuerPubkey: string): void;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Sign any Nostr note with `keypair`. A zero/absent `created_at` is replaced
|
|
170
|
+
* with the current Unix timestamp before signing.
|
|
171
|
+
*/
|
|
172
|
+
export declare function signNote(note: NostrNote, keypair: Keypair): NostrNote;
|
|
173
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAiB,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,IAAI,YAAY,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,QAAQ,IAAI,YAAY,EACzB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,iBAAiB,EACjB,SAAS,GACV,MAAM,YAAY,CAAC;AAIp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AO,EAAE,OAAO,GAAG,SAAS,CAErE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @authenticdoc/sdk — TypeScript/WASM bindings for the authenticdoc-sdk Rust
|
|
3
|
+
* crypto library.
|
|
4
|
+
*
|
|
5
|
+
* The heavy lifting (secp256k1, NIP-44, nahui AEAD, Nostr event shaping) runs
|
|
6
|
+
* in WebAssembly compiled from the same Rust core the Go SDK binds to, so the
|
|
7
|
+
* JSON shapes are identical across languages.
|
|
8
|
+
*
|
|
9
|
+
* ## Usage
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { init, Keypair, Template, Envelope } from "@authenticdoc/sdk";
|
|
13
|
+
*
|
|
14
|
+
* await init(); // load the wasm module once, before anything else
|
|
15
|
+
*
|
|
16
|
+
* const alice = Keypair.generate();
|
|
17
|
+
* const tpl = Template.create("Service Agreement", "<body>");
|
|
18
|
+
* const signed = tpl.sign(alice);
|
|
19
|
+
* signed.verify();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import wasmInit, * as wasm from "./wasm/authenticdoc.js";
|
|
23
|
+
let initialized = false;
|
|
24
|
+
/**
|
|
25
|
+
* Load and instantiate the WASM module. Must be awaited once before using any
|
|
26
|
+
* other export. Idempotent — subsequent calls resolve immediately.
|
|
27
|
+
*
|
|
28
|
+
* @param input Optional override for the `.wasm` location (a URL, Request,
|
|
29
|
+
* Response, or bytes). Defaults to the `.wasm` shipped next to the glue,
|
|
30
|
+
* which works out of the box in Node and most bundlers.
|
|
31
|
+
*/
|
|
32
|
+
export async function init(input) {
|
|
33
|
+
if (initialized)
|
|
34
|
+
return;
|
|
35
|
+
let moduleOrPath = input;
|
|
36
|
+
if (moduleOrPath === undefined && isNode()) {
|
|
37
|
+
// The `web` target defaults to `fetch(new URL('…_bg.wasm', import.meta.url))`,
|
|
38
|
+
// but Node's fetch can't load `file://` URLs. Read the bytes ourselves so
|
|
39
|
+
// the same artifact works in Node without the caller doing anything; in the
|
|
40
|
+
// browser we leave `input` undefined and let the glue fetch it.
|
|
41
|
+
moduleOrPath = await loadWasmBytesFromDisk();
|
|
42
|
+
}
|
|
43
|
+
await wasmInit(moduleOrPath !== undefined ? { module_or_path: moduleOrPath } : undefined);
|
|
44
|
+
initialized = true;
|
|
45
|
+
}
|
|
46
|
+
function isNode() {
|
|
47
|
+
return (typeof process !== "undefined" &&
|
|
48
|
+
process.versions != null &&
|
|
49
|
+
process.versions.node != null);
|
|
50
|
+
}
|
|
51
|
+
async function loadWasmBytesFromDisk() {
|
|
52
|
+
// Dynamic imports so bundlers targeting the browser never pull in node:fs.
|
|
53
|
+
const { readFile } = await import("node:fs/promises");
|
|
54
|
+
const { fileURLToPath } = await import("node:url");
|
|
55
|
+
const wasmUrl = new URL("./wasm/authenticdoc_bg.wasm", import.meta.url);
|
|
56
|
+
return readFile(fileURLToPath(wasmUrl));
|
|
57
|
+
}
|
|
58
|
+
function assertInit() {
|
|
59
|
+
if (!initialized) {
|
|
60
|
+
throw new Error("@authenticdoc/sdk: call `await init()` before using the SDK.");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ---------- keypair ---------------------------------------------------------
|
|
64
|
+
/**
|
|
65
|
+
* A secp256k1 keypair. The secret key never leaves WASM memory — this object
|
|
66
|
+
* is an opaque handle. Call {@link Keypair.free} when done, or use
|
|
67
|
+
* `using kp = Keypair.generate()` for automatic disposal.
|
|
68
|
+
*/
|
|
69
|
+
export class Keypair {
|
|
70
|
+
/** @internal */
|
|
71
|
+
inner;
|
|
72
|
+
constructor(inner) {
|
|
73
|
+
this.inner = inner;
|
|
74
|
+
}
|
|
75
|
+
/** Generate a fresh extractable keypair. */
|
|
76
|
+
static generate() {
|
|
77
|
+
assertInit();
|
|
78
|
+
return new Keypair(wasm.Keypair.generate());
|
|
79
|
+
}
|
|
80
|
+
/** Load a keypair from a bech32 `nsec1…` string. */
|
|
81
|
+
static fromNsec(nsec) {
|
|
82
|
+
assertInit();
|
|
83
|
+
return new Keypair(wasm.Keypair.fromNsec(nsec));
|
|
84
|
+
}
|
|
85
|
+
/** Load a keypair from a 64-character hex private key. */
|
|
86
|
+
static fromHex(hex) {
|
|
87
|
+
assertInit();
|
|
88
|
+
return new Keypair(wasm.Keypair.fromHex(hex));
|
|
89
|
+
}
|
|
90
|
+
/** Load a keypair from a BIP-39 mnemonic phrase (English, 12 or 24 words). */
|
|
91
|
+
static fromMnemonic(phrase) {
|
|
92
|
+
assertInit();
|
|
93
|
+
return new Keypair(wasm.Keypair.fromMnemonic(phrase));
|
|
94
|
+
}
|
|
95
|
+
/** The hex-encoded public key. */
|
|
96
|
+
get pubkey() {
|
|
97
|
+
return this.inner.pubkey;
|
|
98
|
+
}
|
|
99
|
+
/** Export the bech32 `nsec` (secret material — handle with care). */
|
|
100
|
+
nsec() {
|
|
101
|
+
return this.inner.nsec();
|
|
102
|
+
}
|
|
103
|
+
/** Export the 24-word BIP-39 mnemonic (secret material — handle with care). */
|
|
104
|
+
mnemonic() {
|
|
105
|
+
return this.inner.mnemonic();
|
|
106
|
+
}
|
|
107
|
+
/** Release the underlying WASM keypair (scrubs secret material). */
|
|
108
|
+
free() {
|
|
109
|
+
this.inner.free();
|
|
110
|
+
}
|
|
111
|
+
[Symbol.dispose]() {
|
|
112
|
+
this.free();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ---------- template --------------------------------------------------------
|
|
116
|
+
/**
|
|
117
|
+
* A signable document (title, body, UUID) backed by a Nostr parameterized
|
|
118
|
+
* replaceable event. Methods that mutate return a new {@link Template}; the
|
|
119
|
+
* wasm core is stateless (JSON in, JSON out).
|
|
120
|
+
*/
|
|
121
|
+
export class Template {
|
|
122
|
+
/** The underlying Nostr note JSON. */
|
|
123
|
+
json;
|
|
124
|
+
constructor(json) {
|
|
125
|
+
this.json = json;
|
|
126
|
+
}
|
|
127
|
+
/** Wrap an existing template JSON object (e.g. one received over the wire). */
|
|
128
|
+
static fromJson(json) {
|
|
129
|
+
return new Template(json);
|
|
130
|
+
}
|
|
131
|
+
/** Build a fresh template with a minted UUID. */
|
|
132
|
+
static create(title, body) {
|
|
133
|
+
assertInit();
|
|
134
|
+
return new Template(JSON.parse(wasm.templateNew(title, body)));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Build a template from raw file bytes, stored as an RFC 2397 data URL.
|
|
138
|
+
* Pass `id = undefined` or `""` to mint a UUID.
|
|
139
|
+
*/
|
|
140
|
+
static fromBytes(title, mime, bytes, id) {
|
|
141
|
+
assertInit();
|
|
142
|
+
return new Template(JSON.parse(wasm.templateFromBytes(id, title, mime, bytes)));
|
|
143
|
+
}
|
|
144
|
+
get raw() {
|
|
145
|
+
return JSON.stringify(this.json);
|
|
146
|
+
}
|
|
147
|
+
/** Sign this template with `keypair`, returning the signed template. */
|
|
148
|
+
sign(keypair) {
|
|
149
|
+
return new Template(JSON.parse(wasm.templateSign(this.raw, keypair.inner)));
|
|
150
|
+
}
|
|
151
|
+
/** Verify the template's event id, signature and shape. Throws on failure. */
|
|
152
|
+
verify() {
|
|
153
|
+
wasm.templateVerify(this.raw);
|
|
154
|
+
}
|
|
155
|
+
/** The document id (the `d` parameter tag). */
|
|
156
|
+
documentId() {
|
|
157
|
+
return wasm.templateDocumentId(this.raw);
|
|
158
|
+
}
|
|
159
|
+
/** The title. */
|
|
160
|
+
title() {
|
|
161
|
+
return wasm.templateTitle(this.raw);
|
|
162
|
+
}
|
|
163
|
+
/** The body content. */
|
|
164
|
+
content() {
|
|
165
|
+
return wasm.templateContent(this.raw);
|
|
166
|
+
}
|
|
167
|
+
/** Read the first value of a custom tag. Throws if absent. */
|
|
168
|
+
getTag(key) {
|
|
169
|
+
return wasm.templateGetTag(this.raw, key);
|
|
170
|
+
}
|
|
171
|
+
/** Read the `description` tag. Throws if absent. */
|
|
172
|
+
description() {
|
|
173
|
+
return wasm.templateDescription(this.raw);
|
|
174
|
+
}
|
|
175
|
+
/** Whether `content` is a base64 data URL (built via {@link fromBytes}). */
|
|
176
|
+
isDataUrl() {
|
|
177
|
+
return wasm.templateIsDataUrl(this.raw);
|
|
178
|
+
}
|
|
179
|
+
/** Decode a data-URL `content`. Throws if `content` is not a data URL. */
|
|
180
|
+
decodeDataUrl() {
|
|
181
|
+
return JSON.parse(wasm.templateDecodeDataUrl(this.raw));
|
|
182
|
+
}
|
|
183
|
+
/** Add a custom tag, returning the updated template. */
|
|
184
|
+
addTag(key, value) {
|
|
185
|
+
return new Template(JSON.parse(wasm.templateAddTag(this.raw, key, value)));
|
|
186
|
+
}
|
|
187
|
+
/** Set the document id, returning the updated template. */
|
|
188
|
+
setDocumentId(id) {
|
|
189
|
+
return new Template(JSON.parse(wasm.templateSetDocumentId(this.raw, id)));
|
|
190
|
+
}
|
|
191
|
+
/** Set the title, returning the updated template. */
|
|
192
|
+
setTitle(title) {
|
|
193
|
+
return new Template(JSON.parse(wasm.templateSetTitle(this.raw, title)));
|
|
194
|
+
}
|
|
195
|
+
/** Add a `description` tag, returning the updated template. */
|
|
196
|
+
addDescription(description) {
|
|
197
|
+
return new Template(JSON.parse(wasm.templateAddDescription(this.raw, description)));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// ---------- envelope --------------------------------------------------------
|
|
201
|
+
/**
|
|
202
|
+
* A multi-party signing envelope wrapping a {@link Template} with
|
|
203
|
+
* per-participant key material. Mutating methods return a new {@link Envelope}.
|
|
204
|
+
*/
|
|
205
|
+
export class Envelope {
|
|
206
|
+
/** The underlying Nostr note JSON. */
|
|
207
|
+
json;
|
|
208
|
+
constructor(json) {
|
|
209
|
+
this.json = json;
|
|
210
|
+
}
|
|
211
|
+
/** Wrap an existing envelope JSON object (e.g. one received over the wire). */
|
|
212
|
+
static fromJson(json) {
|
|
213
|
+
return new Envelope(json);
|
|
214
|
+
}
|
|
215
|
+
/** Build a v2 envelope wrapping `template` for `participants`. */
|
|
216
|
+
static create(template, participants) {
|
|
217
|
+
assertInit();
|
|
218
|
+
return new Envelope(JSON.parse(wasm.envelopeNew(JSON.stringify(template.json), JSON.stringify(participants))));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Build a v2 envelope directly from raw file bytes. Pass `id = undefined` or
|
|
222
|
+
* `""` to mint a UUID.
|
|
223
|
+
*/
|
|
224
|
+
static fromBytes(title, mime, bytes, participants, id) {
|
|
225
|
+
assertInit();
|
|
226
|
+
return new Envelope(JSON.parse(wasm.envelopeFromBytes(id, title, mime, bytes, JSON.stringify(participants))));
|
|
227
|
+
}
|
|
228
|
+
get raw() {
|
|
229
|
+
return JSON.stringify(this.json);
|
|
230
|
+
}
|
|
231
|
+
/** This keypair's participant signature over the inner document. */
|
|
232
|
+
createParticipantSig(keypair) {
|
|
233
|
+
return JSON.parse(wasm.envelopeCreateParticipantSig(this.raw, keypair.inner));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Verify a single peer's signature (`peerPubkey` hex), returning it.
|
|
237
|
+
* `keypair` must be a participant able to decrypt the body.
|
|
238
|
+
*/
|
|
239
|
+
verifyParticipantSig(keypair, peerPubkey) {
|
|
240
|
+
return JSON.parse(wasm.envelopeVerifyParticipantSig(this.raw, keypair.inner, peerPubkey));
|
|
241
|
+
}
|
|
242
|
+
/** Attach signatures via the (non-owner) participant path. */
|
|
243
|
+
addParticipantSigs(keypair, sigs) {
|
|
244
|
+
return new Envelope(JSON.parse(wasm.envelopeAddParticipantSigs(this.raw, keypair.inner, JSON.stringify(sigs))));
|
|
245
|
+
}
|
|
246
|
+
/** Attach signatures via the owner path (idempotent). */
|
|
247
|
+
addParticipantSigsAsOwner(ownerKeypair, sigs) {
|
|
248
|
+
return new Envelope(JSON.parse(wasm.envelopeAddParticipantSigsAsOwner(this.raw, ownerKeypair.inner, JSON.stringify(sigs))));
|
|
249
|
+
}
|
|
250
|
+
/** Verify every participant signature, returning them. */
|
|
251
|
+
verifyAllParticipantSigs(keypair) {
|
|
252
|
+
return JSON.parse(wasm.envelopeVerifyAllParticipantSigs(this.raw, keypair.inner));
|
|
253
|
+
}
|
|
254
|
+
/** Decrypt and return the inner document as a Nostr note. */
|
|
255
|
+
viewDocument(keypair) {
|
|
256
|
+
return JSON.parse(wasm.envelopeViewDocument(this.raw, keypair.inner));
|
|
257
|
+
}
|
|
258
|
+
/** Decrypt the envelope title using a participant keypair. */
|
|
259
|
+
title(keypair) {
|
|
260
|
+
return wasm.envelopeTitle(this.raw, keypair.inner);
|
|
261
|
+
}
|
|
262
|
+
/** The envelope's parameter id (matches the wrapped template id). */
|
|
263
|
+
id() {
|
|
264
|
+
return wasm.envelopeId(this.raw);
|
|
265
|
+
}
|
|
266
|
+
/** The participant list. */
|
|
267
|
+
participants() {
|
|
268
|
+
return JSON.parse(wasm.envelopeParticipants(this.raw));
|
|
269
|
+
}
|
|
270
|
+
/** The `created_at` timestamp (Unix seconds). */
|
|
271
|
+
timestamp() {
|
|
272
|
+
return wasm.envelopeTimestamp(this.raw);
|
|
273
|
+
}
|
|
274
|
+
/** Sign the envelope's outer Nostr event with `keypair`. */
|
|
275
|
+
sign(keypair) {
|
|
276
|
+
return new Envelope(JSON.parse(wasm.envelopeSign(this.raw, keypair.inner)));
|
|
277
|
+
}
|
|
278
|
+
/** Verify the signed envelope (outer event id + signature + shape). */
|
|
279
|
+
verify() {
|
|
280
|
+
wasm.envelopeVerify(this.raw);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// ---------- identity & badges ----------------------------------------------
|
|
284
|
+
/** Identity-card and badge helpers. */
|
|
285
|
+
export const identity = {
|
|
286
|
+
/** Encode a hex Nostr public key as a bech32 `npub`. */
|
|
287
|
+
npub(pubkeyHex) {
|
|
288
|
+
return wasm.identityNpub(pubkeyHex);
|
|
289
|
+
},
|
|
290
|
+
/** Build an unsigned Nostr event from an Identity JSON object. */
|
|
291
|
+
toEvent(identityJson) {
|
|
292
|
+
return JSON.parse(wasm.identityToEvent(JSON.stringify(identityJson)));
|
|
293
|
+
},
|
|
294
|
+
/** Parse a Nostr badge-award event into an Identity JSON object. */
|
|
295
|
+
fromEvent(note) {
|
|
296
|
+
return JSON.parse(wasm.identityFromEvent(JSON.stringify(note)));
|
|
297
|
+
},
|
|
298
|
+
/** Wrap a signed inner badge for delivery to a holder. */
|
|
299
|
+
wrapBadge(signedInner, holderPubkey, issuerKeypair) {
|
|
300
|
+
return JSON.parse(wasm.badgeWrap(JSON.stringify(signedInner), holderPubkey, issuerKeypair.inner));
|
|
301
|
+
},
|
|
302
|
+
/** Unwrap a badge addressed to the holder keypair. */
|
|
303
|
+
unwrapBadge(outer, holderKeypair) {
|
|
304
|
+
return JSON.parse(wasm.badgeUnwrap(JSON.stringify(outer), holderKeypair.inner));
|
|
305
|
+
},
|
|
306
|
+
/** Verify a badge was issued by `expectedIssuerPubkey`. Throws on mismatch. */
|
|
307
|
+
verifyBadge(badge, expectedIssuerPubkey) {
|
|
308
|
+
wasm.badgeVerify(JSON.stringify(badge), expectedIssuerPubkey);
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
// ---------- generic note signing -------------------------------------------
|
|
312
|
+
/**
|
|
313
|
+
* Sign any Nostr note with `keypair`. A zero/absent `created_at` is replaced
|
|
314
|
+
* with the current Unix timestamp before signing.
|
|
315
|
+
*/
|
|
316
|
+
export function signNote(note, keypair) {
|
|
317
|
+
return JSON.parse(wasm.noteSign(JSON.stringify(note), keypair.inner));
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAQ,EAAE,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAkBzD,IAAI,WAAW,GAAG,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,KAA6E;IAE7E,IAAI,WAA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