digiid-ts 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pawel Zelawski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # digiid-ts
2
+
3
+ A modern TypeScript implementation of the Digi-ID authentication protocol, inspired by the original [digiid-js](https://github.com/digibyte-core/digiid-js).
4
+
5
+ Provides utilities for generating Digi-ID URIs for QR code display and verifying the callback data signed by a user's Digi-ID-compatible wallet.
6
+
7
+ ## Features
8
+
9
+ * Generates Digi-ID URIs according to the specification.
10
+ * Verifies Digi-ID callback signatures and data.
11
+ * Full TypeScript support with comprehensive type definitions.
12
+ * Modern ES modules support.
13
+ * Zero dependencies (except for Node.js built-ins).
14
+ * Comprehensive test coverage.
15
+ * Detailed error messages for debugging.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install digiid-ts
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Generating a Digi-ID URI
26
+
27
+ ```typescript
28
+ import { generateDigiIDUri, DigiIDError } from 'digiid-ts';
29
+
30
+ const options = {
31
+ callbackUrl: 'https://your-site.com/auth/callback',
32
+ // Optional parameters:
33
+ nonce: 'custom-nonce', // Defaults to random UUID
34
+ unsecure: false, // Defaults to false (requires HTTPS)
35
+ };
36
+
37
+ try {
38
+ const digiidUri = generateDigiIDUri(options);
39
+ console.log('Generated Digi-ID URI:', digiidUri);
40
+ // Display this URI as a QR code for the user to scan
41
+ } catch (error) {
42
+ if (error instanceof DigiIDError) {
43
+ console.error('Failed to generate Digi-ID URI:', error.message);
44
+ }
45
+ }
46
+ ```
47
+
48
+ ### Verifying the Digi-ID Callback
49
+
50
+ ```typescript
51
+ import { verifyDigiIDCallback, DigiIDError, DigiIDCallbackData } from 'digiid-ts';
52
+
53
+ // In your Express route handler:
54
+ app.post('/auth/callback', async (req, res) => {
55
+ const callbackData: DigiIDCallbackData = req.body; // { address, uri, signature }
56
+
57
+ const verifyOptions = {
58
+ expectedCallbackUrl: 'https://your-site.com/auth/callback',
59
+ expectedNonce: 'your-stored-nonce', // The nonce you generated earlier
60
+ };
61
+
62
+ try {
63
+ const verificationResult = await verifyDigiIDCallback(callbackData, verifyOptions);
64
+
65
+ // Verification successful!
66
+ console.log(`Successfully verified Digi-ID login for address: ${verificationResult.address}`);
67
+
68
+ // Store the verified address in your session/database
69
+ // Redirect to success page
70
+ res.redirect('/dashboard');
71
+ } catch (error) {
72
+ if (error instanceof DigiIDError) {
73
+ // Specific Digi-ID error (e.g., signature invalid, nonce mismatch, URL mismatch)
74
+ console.error('Digi-ID verification failed:', error.message);
75
+ res.status(400).json({ error: error.message });
76
+ } else {
77
+ // Unexpected error
78
+ console.error('Unexpected error:', error);
79
+ res.status(500).json({ error: 'Internal server error' });
80
+ }
81
+ }
82
+ });
83
+ ```
84
+
85
+ ## API Reference
86
+
87
+ ### Core Functions
88
+
89
+ * `generateDigiIDUri(options: DigiIDUriOptions): string`
90
+ * Generates a Digi-ID URI for QR code display.
91
+ * `verifyDigiIDCallback(callbackData: DigiIDCallbackData, verifyOptions: DigiIDVerifyOptions): Promise<DigiIDVerificationResult>`
92
+ * Verifies the data received from the wallet callback. Resolves on success, throws `DigiIDError` on failure.
93
+
94
+ ### Type Definitions
95
+
96
+ * `DigiIDUriOptions`: Options for `generateDigiIDUri`.
97
+ * `DigiIDCallbackData`: Shape of data expected from the wallet callback.
98
+ * `DigiIDVerifyOptions`: Options for `verifyDigiIDCallback`.
99
+ * `DigiIDVerificationResult`: Shape of the success result from `verifyDigiIDCallback`.
100
+ * `DigiIDError`: Custom error class thrown on failures.
101
+
102
+ ## Development
103
+
104
+ ### Prerequisites
105
+
106
+ * Node.js 18+
107
+ * npm 9+
108
+
109
+ ### Setup
110
+
111
+ 1. Clone the repository
112
+ 2. Install dependencies: `npm install`
113
+ 3. Run tests: `npm test`
114
+
115
+ ### Project Structure
116
+
117
+ * `src/` - Source code
118
+ * `digiid.ts` - Core implementation
119
+ * `types.ts` - TypeScript type definitions
120
+ * `test/` - Test files
121
+ * `examples/` - Usage examples
122
+ * `dist/` - Built files (generated)
123
+
124
+ ## License
125
+
126
+ MIT
127
+
128
+ ## Contributing
129
+
130
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,87 @@
1
+ import { randomBytes as m } from "crypto";
2
+ import { createRequire as U } from "module";
3
+ class e extends Error {
4
+ constructor(r) {
5
+ super(r), this.name = "DigiIDError";
6
+ }
7
+ }
8
+ async function f(t, r, i) {
9
+ const s = U(import.meta.url)("digibyte-message");
10
+ try {
11
+ const a = new s(t);
12
+ return !!await Promise.resolve(
13
+ a.verify(r, i)
14
+ );
15
+ } catch (a) {
16
+ throw new e(`Signature verification failed: ${a.message || a}`);
17
+ }
18
+ }
19
+ function b(t = 16) {
20
+ return m(t).toString("hex");
21
+ }
22
+ function k(t) {
23
+ if (!t.callbackUrl)
24
+ throw new e("Callback URL is required.");
25
+ let r;
26
+ try {
27
+ r = new URL(t.callbackUrl);
28
+ } catch (o) {
29
+ throw new e(`Invalid callback URL: ${o.message}`);
30
+ }
31
+ const i = r.host + r.pathname, c = t.nonce || b(), s = t.unsecure ? "1" : "0";
32
+ if (t.unsecure && r.protocol !== "http:")
33
+ throw new e("Unsecure flag is true, but callback URL does not use http protocol.");
34
+ if (!t.unsecure && r.protocol !== "https:")
35
+ throw new e("Callback URL must use https protocol unless unsecure flag is set to true.");
36
+ return `digiid://${i}?x=${c}&u=${s}`;
37
+ }
38
+ async function v(t, r) {
39
+ const { address: i, uri: c, signature: s } = t, { expectedCallbackUrl: a, expectedNonce: o } = r;
40
+ if (!i || !c || !s)
41
+ throw new e("Missing required callback data: address, uri, or signature.");
42
+ let l;
43
+ try {
44
+ const n = c.replace(/^digiid:/, "http:");
45
+ l = new URL(n);
46
+ } catch (n) {
47
+ throw new e(`Invalid URI received in callback: ${n.message}`);
48
+ }
49
+ const u = l.searchParams.get("x"), h = l.searchParams.get("u"), g = l.host + l.pathname;
50
+ if (u === null || h === null)
51
+ throw new e("URI missing nonce (x) or unsecure (u) parameter.");
52
+ let d;
53
+ try {
54
+ d = typeof a == "string" ? new URL(a) : a;
55
+ } catch (n) {
56
+ throw new e(`Invalid expectedCallbackUrl provided: ${n.message}`);
57
+ }
58
+ const p = d.host + d.pathname;
59
+ if (g !== p)
60
+ throw new e(`Callback URL mismatch: URI contained "${g}", expected "${p}"`);
61
+ const w = d.protocol;
62
+ if (h === "1" && w !== "http:")
63
+ throw new e("URI indicates unsecure (u=1), but expectedCallbackUrl is not http.");
64
+ if (h === "0" && w !== "https:")
65
+ throw new e("URI indicates secure (u=0), but expectedCallbackUrl is not https.");
66
+ if (o && u !== o)
67
+ throw new e(`Nonce mismatch: URI contained "${u}", expected "${o}". Possible replay attack.`);
68
+ try {
69
+ if (!await f(c, i, s))
70
+ throw new e("Invalid signature.");
71
+ } catch (n) {
72
+ throw n instanceof e ? n : new e(`Unexpected error during signature verification: ${n.message}`);
73
+ }
74
+ return {
75
+ isValid: !0,
76
+ address: i,
77
+ nonce: u
78
+ // Return the nonce from the URI
79
+ };
80
+ }
81
+ export {
82
+ e as DigiIDError,
83
+ f as _internalVerifySignature,
84
+ k as generateDigiIDUri,
85
+ v as verifyDigiIDCallback
86
+ };
87
+ //# sourceMappingURL=digiid-ts.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digiid-ts.es.js","sources":["../src/types.ts","../src/digiid.ts"],"sourcesContent":["/**\n * Options for generating a DigiID URI.\n */\nexport interface DigiIDUriOptions {\n /** The full URL that the user's DigiID wallet will send the verification data back to. */\n callbackUrl: string;\n /** A unique, unpredictable nonce (number used once) for this authentication request. If not provided, a secure random one might be generated (implementation specific). */\n nonce?: string;\n /** Set to true for testing over HTTP (insecure), defaults to false (HTTPS required). */\n unsecure?: boolean;\n}\n\n/**\n * Data structure typically received from the DigiID wallet callback.\n */\nexport interface DigiIDCallbackData {\n /** The DigiByte address used for signing. */\n address: string;\n /** The DigiID URI that was originally presented to the user. */\n uri: string;\n /** The signature proving ownership of the address, signing the URI. */\n signature: string;\n}\n\n/**\n * Options for verifying a DigiID callback.\n */\nexport interface DigiIDVerifyOptions {\n /** The expected callback URL (or parts of it, like domain/path) that should match the one in the received URI. */\n expectedCallbackUrl: string | URL;\n /** The specific nonce that was originally generated for this authentication attempt, to prevent replay attacks. */\n expectedNonce?: string;\n}\n\n/**\n * Result of a successful DigiID verification.\n */\nexport interface DigiIDVerificationResult {\n /** Indicates the verification was successful. */\n isValid: true;\n /** The DigiByte address that was successfully verified. */\n address: string;\n /** The nonce extracted from the verified URI. */\n nonce: string;\n}\n\n/**\n * Represents an error during DigiID processing.\n */\nexport class DigiIDError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DigiIDError';\n }\n}\n","import { randomBytes } from 'crypto';\n// Import createRequire for CJS dependencies in ESM\nimport { createRequire } from 'module';\nimport { \n DigiIDUriOptions, \n DigiIDError, \n DigiIDCallbackData, \n DigiIDVerifyOptions, \n DigiIDVerificationResult \n} from './types';\n\n// Moved require inside the function that uses it to potentially help mocking\n// and avoid top-level side effects if require itself does something complex.\n\n/**\n * INTERNAL: Verifies the signature using the digibyte-message library.\n * Exported primarily for testing purposes (mocking/spying).\n * @internal\n */\nexport async function _internalVerifySignature(\n uri: string,\n address: string,\n signature: string\n): Promise<boolean> {\n // Create a require function scoped to this module\n const require = createRequire(import.meta.url);\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const Message = require('digibyte-message');\n try {\n const messageInstance = new Message(uri);\n // Assuming synchronous based on common bitcore patterns, but wrapping for safety\n const isValidSignature = await Promise.resolve(\n messageInstance.verify(address, signature)\n );\n return !!isValidSignature; // Ensure boolean return\n } catch (e: any) {\n // Re-throw specific errors (like format/checksum errors) from the underlying library\n // to be caught by the main verification function.\n throw new DigiIDError(`Signature verification failed: ${e.message || e}`);\n }\n}\n\n/**\n * Generates a secure random nonce (hex string).\n * @param length - The number of bytes to generate (default: 16, resulting in 32 hex chars).\n * @returns A hex-encoded random string.\n */\nfunction generateNonce(length = 16): string {\n return randomBytes(length).toString('hex');\n}\n\n/**\n * Generates a DigiID authentication URI.\n *\n * @param options - Options for URI generation, including the callback URL.\n * @returns The generated DigiID URI string.\n * @throws {DigiIDError} If the callback URL is invalid or missing.\n */\nexport function generateDigiIDUri(options: DigiIDUriOptions): string {\n if (!options.callbackUrl) {\n throw new DigiIDError('Callback URL is required.');\n }\n\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(options.callbackUrl);\n } catch (e) {\n throw new DigiIDError(`Invalid callback URL: ${(e as Error).message}`);\n }\n\n // DigiID spec requires stripping the scheme (http/https)\n const domainAndPath = parsedUrl.host + parsedUrl.pathname;\n\n const nonce = options.nonce || generateNonce();\n const unsecureFlag = options.unsecure ? '1' : '0'; // 1 for http, 0 for https\n\n // Validate scheme based on unsecure flag\n if (options.unsecure && parsedUrl.protocol !== 'http:') {\n throw new DigiIDError('Unsecure flag is true, but callback URL does not use http protocol.');\n }\n if (!options.unsecure && parsedUrl.protocol !== 'https:') {\n throw new DigiIDError('Callback URL must use https protocol unless unsecure flag is set to true.');\n }\n\n // Construct the URI\n // Example: digiid://example.com/callback?x=nonce_value&u=0\n const uri = `digiid://${domainAndPath}?x=${nonce}&u=${unsecureFlag}`;\n\n // Clean up potential trailing slash in path if no query params exist (though DigiID always has params)\n // This check might be redundant given DigiID structure, but good practice\n // const cleanedUri = uri.endsWith('/') && parsedUrl.search === '' ? uri.slice(0, -1) : uri;\n\n return uri;\n}\n\n/**\n * Verifies the signature and data received from a DigiID callback.\n *\n * @param callbackData - The data received from the wallet (address, uri, signature).\n * @param verifyOptions - Options for verification, including the expected callback URL and nonce.\n * @returns {Promise<DigiIDVerificationResult>} A promise that resolves with verification details if successful.\n * @throws {DigiIDError} If validation or signature verification fails.\n */\nexport async function verifyDigiIDCallback(\n callbackData: DigiIDCallbackData,\n verifyOptions: DigiIDVerifyOptions\n): Promise<DigiIDVerificationResult> {\n const { address, uri, signature } = callbackData;\n const { expectedCallbackUrl, expectedNonce } = verifyOptions;\n\n if (!address || !uri || !signature) {\n throw new DigiIDError('Missing required callback data: address, uri, or signature.');\n }\n\n // 1. Parse the received URI\n let parsedReceivedUri: URL;\n try {\n // Temporarily replace digiid:// with http:// for standard URL parsing\n const parsableUri = uri.replace(/^digiid:/, 'http:');\n parsedReceivedUri = new URL(parsableUri);\n } catch (e) {\n throw new DigiIDError(`Invalid URI received in callback: ${(e as Error).message}`);\n }\n\n const receivedNonce = parsedReceivedUri.searchParams.get('x');\n const receivedUnsecure = parsedReceivedUri.searchParams.get('u'); // 0 or 1\n const receivedDomainAndPath = parsedReceivedUri.host + parsedReceivedUri.pathname;\n\n if (receivedNonce === null || receivedUnsecure === null) {\n throw new DigiIDError('URI missing nonce (x) or unsecure (u) parameter.');\n }\n\n // 2. Validate Callback URL\n let parsedExpectedUrl: URL;\n try {\n // Allow expectedCallbackUrl to be a string or URL object\n parsedExpectedUrl = typeof expectedCallbackUrl === 'string' ? new URL(expectedCallbackUrl) : expectedCallbackUrl;\n } catch (e) {\n throw new DigiIDError(`Invalid expectedCallbackUrl provided: ${(e as Error).message}`);\n }\n\n const expectedDomainAndPath = parsedExpectedUrl.host + parsedExpectedUrl.pathname;\n\n if (receivedDomainAndPath !== expectedDomainAndPath) {\n throw new DigiIDError(`Callback URL mismatch: URI contained \"${receivedDomainAndPath}\", expected \"${expectedDomainAndPath}\"`);\n }\n\n // Validate scheme consistency\n const expectedScheme = parsedExpectedUrl.protocol;\n if (receivedUnsecure === '1' && expectedScheme !== 'http:') {\n throw new DigiIDError('URI indicates unsecure (u=1), but expectedCallbackUrl is not http.');\n }\n if (receivedUnsecure === '0' && expectedScheme !== 'https:') {\n throw new DigiIDError('URI indicates secure (u=0), but expectedCallbackUrl is not https.');\n }\n\n // 3. Validate Nonce (optional)\n if (expectedNonce && receivedNonce !== expectedNonce) {\n throw new DigiIDError(`Nonce mismatch: URI contained \"${receivedNonce}\", expected \"${expectedNonce}\". Possible replay attack.`);\n }\n\n // 4. Verify Signature using internal helper\n try {\n const isValidSignature = await _internalVerifySignature(uri, address, signature);\n if (!isValidSignature) {\n // If the helper returns false, throw the standard invalid signature error\n throw new DigiIDError('Invalid signature.');\n }\n } catch (error) {\n // If _internalVerifySignature throws (e.g., due to format/checksum errors from the lib, or our re-thrown error),\n // re-throw it. It should already be a DigiIDError.\n if (error instanceof DigiIDError) {\n throw error;\n } else {\n // Catch any unexpected errors and wrap them\n throw new DigiIDError(`Unexpected error during signature verification: ${(error as Error).message}`);\n }\n }\n\n // 5. Return successful result\n return {\n isValid: true,\n address: address,\n nonce: receivedNonce, // Return the nonce from the URI\n };\n}\n"],"names":["DigiIDError","message","_internalVerifySignature","uri","address","signature","Message","createRequire","messageInstance","e","generateNonce","length","randomBytes","generateDigiIDUri","options","parsedUrl","domainAndPath","nonce","unsecureFlag","verifyDigiIDCallback","callbackData","verifyOptions","expectedCallbackUrl","expectedNonce","parsedReceivedUri","parsableUri","receivedNonce","receivedUnsecure","receivedDomainAndPath","parsedExpectedUrl","expectedDomainAndPath","expectedScheme","error"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ (function(r,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("crypto"),require("module")):typeof define=="function"&&define.amd?define(["exports","crypto","module"],d):(r=typeof globalThis<"u"?globalThis:r||self,d(r.DigiIDTs={},r.crypto,r.module))})(this,function(r,d,b){"use strict";var p=typeof document<"u"?document.currentScript:null;class e extends Error{constructor(n){super(n),this.name="DigiIDError"}}async function m(t,n,c){const o=b.createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:p&&p.tagName.toUpperCase()==="SCRIPT"&&p.src||new URL("digiid-ts.umd.js",document.baseURI).href)("digibyte-message");try{const a=new o(t);return!!await Promise.resolve(a.verify(n,c))}catch(a){throw new e(`Signature verification failed: ${a.message||a}`)}}function I(t=16){return d.randomBytes(t).toString("hex")}function R(t){if(!t.callbackUrl)throw new e("Callback URL is required.");let n;try{n=new URL(t.callbackUrl)}catch(u){throw new e(`Invalid callback URL: ${u.message}`)}const c=n.host+n.pathname,s=t.nonce||I(),o=t.unsecure?"1":"0";if(t.unsecure&&n.protocol!=="http:")throw new e("Unsecure flag is true, but callback URL does not use http protocol.");if(!t.unsecure&&n.protocol!=="https:")throw new e("Callback URL must use https protocol unless unsecure flag is set to true.");return`digiid://${c}?x=${s}&u=${o}`}async function v(t,n){const{address:c,uri:s,signature:o}=t,{expectedCallbackUrl:a,expectedNonce:u}=n;if(!c||!s||!o)throw new e("Missing required callback data: address, uri, or signature.");let l;try{const i=s.replace(/^digiid:/,"http:");l=new URL(i)}catch(i){throw new e(`Invalid URI received in callback: ${i.message}`)}const h=l.searchParams.get("x"),g=l.searchParams.get("u"),w=l.host+l.pathname;if(h===null||g===null)throw new e("URI missing nonce (x) or unsecure (u) parameter.");let f;try{f=typeof a=="string"?new URL(a):a}catch(i){throw new e(`Invalid expectedCallbackUrl provided: ${i.message}`)}const U=f.host+f.pathname;if(w!==U)throw new e(`Callback URL mismatch: URI contained "${w}", expected "${U}"`);const y=f.protocol;if(g==="1"&&y!=="http:")throw new e("URI indicates unsecure (u=1), but expectedCallbackUrl is not http.");if(g==="0"&&y!=="https:")throw new e("URI indicates secure (u=0), but expectedCallbackUrl is not https.");if(u&&h!==u)throw new e(`Nonce mismatch: URI contained "${h}", expected "${u}". Possible replay attack.`);try{if(!await m(s,c,o))throw new e("Invalid signature.")}catch(i){throw i instanceof e?i:new e(`Unexpected error during signature verification: ${i.message}`)}return{isValid:!0,address:c,nonce:h}}r.DigiIDError=e,r._internalVerifySignature=m,r.generateDigiIDUri=R,r.verifyDigiIDCallback=v,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
2
+ //# sourceMappingURL=digiid-ts.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digiid-ts.umd.js","sources":["../src/types.ts","../src/digiid.ts"],"sourcesContent":["/**\n * Options for generating a DigiID URI.\n */\nexport interface DigiIDUriOptions {\n /** The full URL that the user's DigiID wallet will send the verification data back to. */\n callbackUrl: string;\n /** A unique, unpredictable nonce (number used once) for this authentication request. If not provided, a secure random one might be generated (implementation specific). */\n nonce?: string;\n /** Set to true for testing over HTTP (insecure), defaults to false (HTTPS required). */\n unsecure?: boolean;\n}\n\n/**\n * Data structure typically received from the DigiID wallet callback.\n */\nexport interface DigiIDCallbackData {\n /** The DigiByte address used for signing. */\n address: string;\n /** The DigiID URI that was originally presented to the user. */\n uri: string;\n /** The signature proving ownership of the address, signing the URI. */\n signature: string;\n}\n\n/**\n * Options for verifying a DigiID callback.\n */\nexport interface DigiIDVerifyOptions {\n /** The expected callback URL (or parts of it, like domain/path) that should match the one in the received URI. */\n expectedCallbackUrl: string | URL;\n /** The specific nonce that was originally generated for this authentication attempt, to prevent replay attacks. */\n expectedNonce?: string;\n}\n\n/**\n * Result of a successful DigiID verification.\n */\nexport interface DigiIDVerificationResult {\n /** Indicates the verification was successful. */\n isValid: true;\n /** The DigiByte address that was successfully verified. */\n address: string;\n /** The nonce extracted from the verified URI. */\n nonce: string;\n}\n\n/**\n * Represents an error during DigiID processing.\n */\nexport class DigiIDError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DigiIDError';\n }\n}\n","import { randomBytes } from 'crypto';\n// Import createRequire for CJS dependencies in ESM\nimport { createRequire } from 'module';\nimport { \n DigiIDUriOptions, \n DigiIDError, \n DigiIDCallbackData, \n DigiIDVerifyOptions, \n DigiIDVerificationResult \n} from './types';\n\n// Moved require inside the function that uses it to potentially help mocking\n// and avoid top-level side effects if require itself does something complex.\n\n/**\n * INTERNAL: Verifies the signature using the digibyte-message library.\n * Exported primarily for testing purposes (mocking/spying).\n * @internal\n */\nexport async function _internalVerifySignature(\n uri: string,\n address: string,\n signature: string\n): Promise<boolean> {\n // Create a require function scoped to this module\n const require = createRequire(import.meta.url);\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const Message = require('digibyte-message');\n try {\n const messageInstance = new Message(uri);\n // Assuming synchronous based on common bitcore patterns, but wrapping for safety\n const isValidSignature = await Promise.resolve(\n messageInstance.verify(address, signature)\n );\n return !!isValidSignature; // Ensure boolean return\n } catch (e: any) {\n // Re-throw specific errors (like format/checksum errors) from the underlying library\n // to be caught by the main verification function.\n throw new DigiIDError(`Signature verification failed: ${e.message || e}`);\n }\n}\n\n/**\n * Generates a secure random nonce (hex string).\n * @param length - The number of bytes to generate (default: 16, resulting in 32 hex chars).\n * @returns A hex-encoded random string.\n */\nfunction generateNonce(length = 16): string {\n return randomBytes(length).toString('hex');\n}\n\n/**\n * Generates a DigiID authentication URI.\n *\n * @param options - Options for URI generation, including the callback URL.\n * @returns The generated DigiID URI string.\n * @throws {DigiIDError} If the callback URL is invalid or missing.\n */\nexport function generateDigiIDUri(options: DigiIDUriOptions): string {\n if (!options.callbackUrl) {\n throw new DigiIDError('Callback URL is required.');\n }\n\n let parsedUrl: URL;\n try {\n parsedUrl = new URL(options.callbackUrl);\n } catch (e) {\n throw new DigiIDError(`Invalid callback URL: ${(e as Error).message}`);\n }\n\n // DigiID spec requires stripping the scheme (http/https)\n const domainAndPath = parsedUrl.host + parsedUrl.pathname;\n\n const nonce = options.nonce || generateNonce();\n const unsecureFlag = options.unsecure ? '1' : '0'; // 1 for http, 0 for https\n\n // Validate scheme based on unsecure flag\n if (options.unsecure && parsedUrl.protocol !== 'http:') {\n throw new DigiIDError('Unsecure flag is true, but callback URL does not use http protocol.');\n }\n if (!options.unsecure && parsedUrl.protocol !== 'https:') {\n throw new DigiIDError('Callback URL must use https protocol unless unsecure flag is set to true.');\n }\n\n // Construct the URI\n // Example: digiid://example.com/callback?x=nonce_value&u=0\n const uri = `digiid://${domainAndPath}?x=${nonce}&u=${unsecureFlag}`;\n\n // Clean up potential trailing slash in path if no query params exist (though DigiID always has params)\n // This check might be redundant given DigiID structure, but good practice\n // const cleanedUri = uri.endsWith('/') && parsedUrl.search === '' ? uri.slice(0, -1) : uri;\n\n return uri;\n}\n\n/**\n * Verifies the signature and data received from a DigiID callback.\n *\n * @param callbackData - The data received from the wallet (address, uri, signature).\n * @param verifyOptions - Options for verification, including the expected callback URL and nonce.\n * @returns {Promise<DigiIDVerificationResult>} A promise that resolves with verification details if successful.\n * @throws {DigiIDError} If validation or signature verification fails.\n */\nexport async function verifyDigiIDCallback(\n callbackData: DigiIDCallbackData,\n verifyOptions: DigiIDVerifyOptions\n): Promise<DigiIDVerificationResult> {\n const { address, uri, signature } = callbackData;\n const { expectedCallbackUrl, expectedNonce } = verifyOptions;\n\n if (!address || !uri || !signature) {\n throw new DigiIDError('Missing required callback data: address, uri, or signature.');\n }\n\n // 1. Parse the received URI\n let parsedReceivedUri: URL;\n try {\n // Temporarily replace digiid:// with http:// for standard URL parsing\n const parsableUri = uri.replace(/^digiid:/, 'http:');\n parsedReceivedUri = new URL(parsableUri);\n } catch (e) {\n throw new DigiIDError(`Invalid URI received in callback: ${(e as Error).message}`);\n }\n\n const receivedNonce = parsedReceivedUri.searchParams.get('x');\n const receivedUnsecure = parsedReceivedUri.searchParams.get('u'); // 0 or 1\n const receivedDomainAndPath = parsedReceivedUri.host + parsedReceivedUri.pathname;\n\n if (receivedNonce === null || receivedUnsecure === null) {\n throw new DigiIDError('URI missing nonce (x) or unsecure (u) parameter.');\n }\n\n // 2. Validate Callback URL\n let parsedExpectedUrl: URL;\n try {\n // Allow expectedCallbackUrl to be a string or URL object\n parsedExpectedUrl = typeof expectedCallbackUrl === 'string' ? new URL(expectedCallbackUrl) : expectedCallbackUrl;\n } catch (e) {\n throw new DigiIDError(`Invalid expectedCallbackUrl provided: ${(e as Error).message}`);\n }\n\n const expectedDomainAndPath = parsedExpectedUrl.host + parsedExpectedUrl.pathname;\n\n if (receivedDomainAndPath !== expectedDomainAndPath) {\n throw new DigiIDError(`Callback URL mismatch: URI contained \"${receivedDomainAndPath}\", expected \"${expectedDomainAndPath}\"`);\n }\n\n // Validate scheme consistency\n const expectedScheme = parsedExpectedUrl.protocol;\n if (receivedUnsecure === '1' && expectedScheme !== 'http:') {\n throw new DigiIDError('URI indicates unsecure (u=1), but expectedCallbackUrl is not http.');\n }\n if (receivedUnsecure === '0' && expectedScheme !== 'https:') {\n throw new DigiIDError('URI indicates secure (u=0), but expectedCallbackUrl is not https.');\n }\n\n // 3. Validate Nonce (optional)\n if (expectedNonce && receivedNonce !== expectedNonce) {\n throw new DigiIDError(`Nonce mismatch: URI contained \"${receivedNonce}\", expected \"${expectedNonce}\". Possible replay attack.`);\n }\n\n // 4. Verify Signature using internal helper\n try {\n const isValidSignature = await _internalVerifySignature(uri, address, signature);\n if (!isValidSignature) {\n // If the helper returns false, throw the standard invalid signature error\n throw new DigiIDError('Invalid signature.');\n }\n } catch (error) {\n // If _internalVerifySignature throws (e.g., due to format/checksum errors from the lib, or our re-thrown error),\n // re-throw it. It should already be a DigiIDError.\n if (error instanceof DigiIDError) {\n throw error;\n } else {\n // Catch any unexpected errors and wrap them\n throw new DigiIDError(`Unexpected error during signature verification: ${(error as Error).message}`);\n }\n }\n\n // 5. Return successful result\n return {\n isValid: true,\n address: address,\n nonce: receivedNonce, // Return the nonce from the URI\n };\n}\n"],"names":["DigiIDError","message","_internalVerifySignature","uri","address","signature","Message","createRequire","messageInstance","e","generateNonce","length","randomBytes","generateDigiIDUri","options","parsedUrl","domainAndPath","nonce","unsecureFlag","verifyDigiIDCallback","callbackData","verifyOptions","expectedCallbackUrl","expectedNonce","parsedReceivedUri","parsableUri","receivedNonce","receivedUnsecure","receivedDomainAndPath","parsedExpectedUrl","expectedDomainAndPath","expectedScheme","error"],"mappings":"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"}
@@ -0,0 +1,25 @@
1
+ import { DigiIDUriOptions, DigiIDCallbackData, DigiIDVerifyOptions, DigiIDVerificationResult } from './types';
2
+ /**
3
+ * INTERNAL: Verifies the signature using the digibyte-message library.
4
+ * Exported primarily for testing purposes (mocking/spying).
5
+ * @internal
6
+ */
7
+ export declare function _internalVerifySignature(uri: string, address: string, signature: string): Promise<boolean>;
8
+ /**
9
+ * Generates a DigiID authentication URI.
10
+ *
11
+ * @param options - Options for URI generation, including the callback URL.
12
+ * @returns The generated DigiID URI string.
13
+ * @throws {DigiIDError} If the callback URL is invalid or missing.
14
+ */
15
+ export declare function generateDigiIDUri(options: DigiIDUriOptions): string;
16
+ /**
17
+ * Verifies the signature and data received from a DigiID callback.
18
+ *
19
+ * @param callbackData - The data received from the wallet (address, uri, signature).
20
+ * @param verifyOptions - Options for verification, including the expected callback URL and nonce.
21
+ * @returns {Promise<DigiIDVerificationResult>} A promise that resolves with verification details if successful.
22
+ * @throws {DigiIDError} If validation or signature verification fails.
23
+ */
24
+ export declare function verifyDigiIDCallback(callbackData: DigiIDCallbackData, verifyOptions: DigiIDVerifyOptions): Promise<DigiIDVerificationResult>;
25
+ //# sourceMappingURL=digiid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digiid.d.ts","sourceRoot":"","sources":["../src/digiid.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAEhB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAKjB;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAWD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAmCnE;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,kBAAkB,EAChC,aAAa,EAAE,mBAAmB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CA+EnC"}
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './digiid';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Options for generating a DigiID URI.
3
+ */
4
+ export interface DigiIDUriOptions {
5
+ /** The full URL that the user's DigiID wallet will send the verification data back to. */
6
+ callbackUrl: string;
7
+ /** A unique, unpredictable nonce (number used once) for this authentication request. If not provided, a secure random one might be generated (implementation specific). */
8
+ nonce?: string;
9
+ /** Set to true for testing over HTTP (insecure), defaults to false (HTTPS required). */
10
+ unsecure?: boolean;
11
+ }
12
+ /**
13
+ * Data structure typically received from the DigiID wallet callback.
14
+ */
15
+ export interface DigiIDCallbackData {
16
+ /** The DigiByte address used for signing. */
17
+ address: string;
18
+ /** The DigiID URI that was originally presented to the user. */
19
+ uri: string;
20
+ /** The signature proving ownership of the address, signing the URI. */
21
+ signature: string;
22
+ }
23
+ /**
24
+ * Options for verifying a DigiID callback.
25
+ */
26
+ export interface DigiIDVerifyOptions {
27
+ /** The expected callback URL (or parts of it, like domain/path) that should match the one in the received URI. */
28
+ expectedCallbackUrl: string | URL;
29
+ /** The specific nonce that was originally generated for this authentication attempt, to prevent replay attacks. */
30
+ expectedNonce?: string;
31
+ }
32
+ /**
33
+ * Result of a successful DigiID verification.
34
+ */
35
+ export interface DigiIDVerificationResult {
36
+ /** Indicates the verification was successful. */
37
+ isValid: true;
38
+ /** The DigiByte address that was successfully verified. */
39
+ address: string;
40
+ /** The nonce extracted from the verified URI. */
41
+ nonce: string;
42
+ }
43
+ /**
44
+ * Represents an error during DigiID processing.
45
+ */
46
+ export declare class DigiIDError extends Error {
47
+ constructor(message: string);
48
+ }
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0FAA0F;IAC1F,WAAW,EAAE,MAAM,CAAC;IACpB,2KAA2K;IAC3K,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAC;IACZ,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kHAAkH;IAClH,mBAAmB,EAAE,MAAM,GAAG,GAAG,CAAC;IAClC,mHAAmH;IACnH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,iDAAiD;IACjD,OAAO,EAAE,IAAI,CAAC;IACd,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "digiid-ts",
3
+ "version": "1.0.0",
4
+ "description": "A modern TypeScript implementation of the DigiID authentication protocol.",
5
+ "main": "dist/digiid-ts.umd.js",
6
+ "module": "dist/digiid-ts.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/digiid-ts.es.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/digiid-ts.umd.js"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "vite build",
26
+ "dev": "vite",
27
+ "test": "vitest run",
28
+ "test:watch": "vitest",
29
+ "coverage": "vitest run --coverage",
30
+ "lint": "eslint . --ext .ts",
31
+ "lint:fix": "eslint . --ext .ts --fix",
32
+ "format": "prettier --check .",
33
+ "format:fix": "prettier --write .",
34
+ "prepublishOnly": "npm run test && npm run build"
35
+ },
36
+ "keywords": [
37
+ "digiid",
38
+ "digibyte",
39
+ "authentication",
40
+ "crypto",
41
+ "typescript"
42
+ ],
43
+ "author": "Pawel Zelawski",
44
+ "license": "MIT",
45
+ "homepage": "https://pzelawski.com/",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/pawelzelawski/digiid-ts.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/pawelzelawski/digiid-ts/issues"
52
+ },
53
+ "engines": {
54
+ "node": ">=16.0.0"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^22.14.0",
61
+ "@typescript-eslint/eslint-plugin": "^8.29.1",
62
+ "@typescript-eslint/parser": "^8.29.1",
63
+ "@vitest/coverage-v8": "^3.1.1",
64
+ "eslint": "^9.24.0",
65
+ "eslint-config-prettier": "^10.1.1",
66
+ "prettier": "^3.5.3",
67
+ "ts-node": "^10.9.2",
68
+ "typescript": "^5.8.3",
69
+ "vite": "^6.2.5",
70
+ "vite-plugin-dts": "^4.5.3",
71
+ "vitest": "^3.1.1"
72
+ },
73
+ "dependencies": {
74
+ "digibyte-message": "github:digicontributer/bitcore-message#9d9c8ad30158db25f683e2dee746a14a9d7ec8a0"
75
+ }
76
+ }