Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/big-lands-read.md

This file was deleted.

44 changes: 0 additions & 44 deletions .changeset/unified-error-handling.md

This file was deleted.

43 changes: 43 additions & 0 deletions packages/siwe-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
# @signinwithethereum/siwe-parser

## 4.1.0

### Minor Changes

- [`f537bdb`](https://github.com/signinwithethereum/siwe/commit/f537bdb290effcfc2206a963009db4ebc911ea3c) Thanks [@jwahdatehagh](https://github.com/jwahdatehagh)! - Harden and unify error handling across the library

**`SiweError` now extends `Error`** — Provides stack traces, works with `instanceof Error`, and integrates with error reporting tools (Sentry, etc.). The `type`, `expected`, and `received` fields are now `readonly`.

**`SiweError.type` narrowed from `SiweErrorType | string` to `SiweErrorType`** — Enables exhaustive `switch`/`case` on error types without a default fallback.

**`SiweResponse.error` narrowed from `SiweError | Error` to `SiweError`** — No more type narrowing needed when handling verification results.

**`verify()` now throws `SiweError` directly** when `suppressExceptions` is `false` (the default). Previously it threw the entire `SiweResponse` object. Update catch blocks:

```ts
// Before (v4.0):
try {
await msg.verify(params)
} catch (e) {
console.log(e.error.type)
} // e was SiweResponse

// After (v4.1):
try {
await msg.verify(params)
} catch (e) {
if (e instanceof SiweError) {
console.log(e.type) // e is SiweError directly
}
}
```

**All error paths now throw `SiweError`** — Configuration errors (`createConfig`, `createEthersConfig`, `createViemConfig`), nonce generation, invalid verify params, and message preparation failures all throw typed `SiweError` instances instead of bare `Error`.

**New `SiweErrorType` entries:**
- `MISSING_CONFIG` — no verification config found
- `MISSING_PROVIDER_LIBRARY` — required provider library (viem/ethers) not installed
- `NONCE_GENERATION_FAILED` — nonce creation failed
- `INVALID_PARAMS` — invalid keys passed to `verify()`
- `MALFORMED_MESSAGE` — message could not be prepared for signing

**`SiweParseError`** — New structured error class in `@signinwithethereum/siwe-parser` (and re-exported from `@signinwithethereum/siwe`) for parse failures, with an `errors: string[]` field containing individual validation errors.

## 4.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/siwe-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signinwithethereum/siwe-parser",
"version": "4.0.2",
"version": "4.1.0",
"type": "module",
"description": "Parse Messages that conform to EIP-4361: Sign in with Ethereum (SIWE)",
"main": "dist/parsers.cjs",
Expand Down
50 changes: 50 additions & 0 deletions packages/siwe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# @signinwithethereum/siwe

## 4.1.0

### Minor Changes

- [`f537bdb`](https://github.com/signinwithethereum/siwe/commit/f537bdb290effcfc2206a963009db4ebc911ea3c) Thanks [@jwahdatehagh](https://github.com/jwahdatehagh)! - Harden and unify error handling across the library

**`SiweError` now extends `Error`** — Provides stack traces, works with `instanceof Error`, and integrates with error reporting tools (Sentry, etc.). The `type`, `expected`, and `received` fields are now `readonly`.

**`SiweError.type` narrowed from `SiweErrorType | string` to `SiweErrorType`** — Enables exhaustive `switch`/`case` on error types without a default fallback.

**`SiweResponse.error` narrowed from `SiweError | Error` to `SiweError`** — No more type narrowing needed when handling verification results.

**`verify()` now throws `SiweError` directly** when `suppressExceptions` is `false` (the default). Previously it threw the entire `SiweResponse` object. Update catch blocks:

```ts
// Before (v4.0):
try {
await msg.verify(params)
} catch (e) {
console.log(e.error.type)
} // e was SiweResponse

// After (v4.1):
try {
await msg.verify(params)
} catch (e) {
if (e instanceof SiweError) {
console.log(e.type) // e is SiweError directly
}
}
```

**All error paths now throw `SiweError`** — Configuration errors (`createConfig`, `createEthersConfig`, `createViemConfig`), nonce generation, invalid verify params, and message preparation failures all throw typed `SiweError` instances instead of bare `Error`.

**New `SiweErrorType` entries:**
- `MISSING_CONFIG` — no verification config found
- `MISSING_PROVIDER_LIBRARY` — required provider library (viem/ethers) not installed
- `NONCE_GENERATION_FAILED` — nonce creation failed
- `INVALID_PARAMS` — invalid keys passed to `verify()`
- `MALFORMED_MESSAGE` — message could not be prepared for signing

**`SiweParseError`** — New structured error class in `@signinwithethereum/siwe-parser` (and re-exported from `@signinwithethereum/siwe`) for parse failures, with an `errors: string[]` field containing individual validation errors.

### Patch Changes

- [`60ada57`](https://github.com/signinwithethereum/siwe/commit/60ada5780b50e2b8a4cb9f422cc55bf456b62b99) Thanks [@jwahdatehagh](https://github.com/jwahdatehagh)! - Cleanup: Lazy imports, improve error messages and logs

- Updated dependencies [[`f537bdb`](https://github.com/signinwithethereum/siwe/commit/f537bdb290effcfc2206a963009db4ebc911ea3c)]:
- @signinwithethereum/siwe-parser@4.1.0

## 4.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/siwe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signinwithethereum/siwe",
"version": "4.0.3",
"version": "4.1.0",
"type": "module",
"description": "Sign in with Ethereum (SIWE)",
"main": "dist/siwe.cjs",
Expand Down
Loading