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
18 changes: 17 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,25 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- run: rm -rf node_modules/.cache/rollup-plugin-typescript2
- name: Determine version specifier from commit title
id: specifier
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
TITLE=$(printf '%s' "$COMMIT_MSG" | head -n1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[WARNING] agentic/bug

The regex '^feat(\(.+\))?!?:' matches both feat: (new feature) and feat!: (breaking change) and maps both to minor. Per Conventional Commits, feat!: (or fix!: below) signals a breaking change and should bump major. The ! case needs to be tested separately before the non-breaking path.

Suggested fix:

Split the conditional so breaking changes are caught first:
```yaml
if printf '%s' "$TITLE" | grep -qE '^(feat|fix)(\(.+\))?!:'; then
  SPECIFIER=major
elif printf '%s' "$TITLE" | grep -qE '^feat(\(.+\))?:'; then
  SPECIFIER=minor
else
  SPECIFIER=patch
fi

<!-- justalab-agents:hash:cc8a6785b8bb -->

echo "Commit title: $TITLE"
if printf '%s' "$TITLE" | grep -qE '^feat(\(.+\))?!?:'; then
SPECIFIER=minor
elif printf '%s' "$TITLE" | grep -qE '^fix(\(.+\))?!?:'; then
SPECIFIER=patch
else
SPECIFIER=patch
fi
echo "Resolved specifier: $SPECIFIER"
echo "specifier=$SPECIFIER" >> "$GITHUB_OUTPUT"
- name: Release
run: |
npx nx release --specifier=patch --yes
npx nx release --specifier=${{ steps.specifier.outputs.specifier }} --yes
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ node_modules
!.vscode/extensions.json
.cursor

/.env
/.env.local

# misc
/.sass-cache
/connect.lock
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/wallet-providers/para.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ Run the following command to install the necessary packages:

{% tabs %}
{% tab title="npm" %}
<pre class="language-bash"><code class="lang-bash"><strong>npm install @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query ethers
<pre class="language-bash"><code class="lang-bash"><strong>npm install @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query
</strong></code></pre>
{% endtab %}

{% tab title="pnpm" %}
```bash
pnpm install @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query ethers
pnpm install @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query
```
{% endtab %}

{% tab title="yarn" %}
```bash
yarn add @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query ethers
yarn add @justweb3/widget @getpara/react-sdk @getpara/wagmi-v2-integration wagmi @tanstack/react-query
```
{% endtab %}
{% endtabs %}
Expand Down
10 changes: 5 additions & 5 deletions docs/sdk/JustaName Core SDK/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ First, import the JustaName SDK and initialize it with your configuration:

```typescript
import { JustaName } from '@justaname.id/sdk';
import { ethers } from 'ethers';
import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts';

// Initialize the SDK with your configuration
const justaname = JustaName.init({
Expand All @@ -85,7 +85,7 @@ const justaname = JustaName.init({
});

// Create a signer (for example purposes, we're creating a random wallet)
const signer = ethers.Wallet.createRandom();
const signer = privateKeyToAccount(generatePrivateKey());
```

### Issuing a Subname
Expand All @@ -98,7 +98,7 @@ async function issueSubname() {
chainId: 1 // Ethereum Mainnet
});

const signature = await signer.signMessage(challenge.challenge);
const signature = await signer.signMessage({ message: challenge.challenge });

const response = await justaname.subnames.addSubname(
{
Expand All @@ -125,7 +125,7 @@ async function updateSubname() {
chainId: 1
});

const signature = await signer.signMessage(challenge.challenge);
const signature = await signer.signMessage({ message: challenge.challenge });

const response = await justaname.subnames.updateSubname(
{
Expand Down Expand Up @@ -159,7 +159,7 @@ async function signIn() {
address: signer.address
});

const signature = await signer.signMessage(message);
const signature = await signer.signMessage({ message });

const response = await justaname.signIn.signIn({
message: message,
Expand Down
6 changes: 3 additions & 3 deletions docs/sdk/siwens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ yarn add @justaname.id/siwens
### Example Usage
```typescript
import { SIWENS, InvalidDomainException, InvalidENSException, InvalidStatementException, InvalidTimeException } f, InvalidDomainException, InvalidENSException, InvalidStatementException, InvalidTimeException } from '@justaname.id/siwens';rom '@justaname.id/siwens';
import { ethers } from 'ethers';
import { privateKeyToAccount } from 'viem/accounts';

// Define your provider URL (e.g., Infura)
const providerUrl = 'https://mainnet.infura.io/v3/YOUR_INFURA_KEY';

const signer = new ethers.Wallet('YOUR_PRIVATE_KEY_ENS_HOLDER')
const signer = privateKeyToAccount('YOUR_PRIVATE_KEY_ENS_HOLDER')

async function signInUser() {
const siwens = new SIWENS({
Expand All @@ -66,7 +66,7 @@ async function signInUser() {
providerUrl
});
const message = await siwens.prepareMessage();
const signature = await signer.signMessage(message);
const signature = await signer.signMessage({ message });
return signature;
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"react-router-dom": "6.11.2",
"react-timer-hook": "3.0.8",
"react-tiny-popover": "8.0.4",
"siwe": "2.3.2",
"tailwind-merge": "2.5.2",
"tailwindcss-animate": "1.0.7",
"tslib": "2.3.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/@justaname.id/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ First, import the JustaName SDK and initialize it with your configuration:

```typescript
import { JustaName } from '@justaname.id/sdk';
import { ethers } from 'ethers';
import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts';

// Initialize the SDK with your configuration
const justaname = JustaName.init({
Expand All @@ -80,8 +80,8 @@ const justaname = JustaName.init({
}
});

// Create a signer (for example purposes, we're creating a random wallet)
const signer = ethers.Wallet.createRandom();
// Create a signer (for example purposes, we're creating a random account)
const signer = privateKeyToAccount(generatePrivateKey());
```

### Issuing a Subname
Expand All @@ -94,7 +94,7 @@ async function issueSubname() {
chainId: 1 // Ethereum Mainnet
});

const signature = await signer.signMessage(challenge.challenge);
const signature = await signer.signMessage({ message: challenge.challenge });

const response = await justaname.subnames.addSubname(
{
Expand All @@ -121,7 +121,7 @@ async function updateSubname() {
chainId: 1
});

const signature = await signer.signMessage(challenge.challenge);
const signature = await signer.signMessage({ message: challenge.challenge });

const response = await justaname.subnames.updateSubname(
{
Expand Down Expand Up @@ -155,7 +155,7 @@ async function signIn() {
address: signer.address
});

const signature = await signer.signMessage(message);
const signature = await signer.signMessage({ message });

const response = await justaname.signIn.signIn({
message: message,
Expand Down
1 change: 0 additions & 1 deletion packages/@justaname.id/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"jest": "^29.4.1"
},
"peerDependencies": {
"siwe": ">=2.0.0",
"viem": "^2.48.0"
},
"exports": {
Expand Down
65 changes: 7 additions & 58 deletions packages/@justaname.id/sdk/src/lib/features/sign-in/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
} from '../../errors';
import { OffchainResolvers } from '../offchain-resolvers';
import { RequestSignInParams, SignInFunctionParams } from '../../types/signin';
import { createPublicClient, http } from 'viem';
import { mainnet, sepolia } from 'viem/chains';
import { normalize } from 'viem/ens';

export interface SignInResponse extends SiwensResponse {
Expand Down Expand Up @@ -110,62 +108,13 @@ export class SignIn {
providerUrl: network.providerUrl,
});

const siwensResponse = await siwens.verify(
{
signature: params.signature,
nonce: params.nonce,
domain: params.domain,
},
{
// Smart-contract (EIP-1271) verification is handled inside
// `verificationFallback` below using viem's `verifySiweMessage`.
// We no longer pass `provider` here because it must be an ethers
// `Provider`, and the SDK is now viem-only.
verificationFallback: async (params, opts, message, EIP1271Promise) => {
// Use the chainId extracted from the SIWE message itself, not the
// SDK-default. Otherwise contract-wallet (EIP-1271) verification
// runs against the wrong chain when the message is cross-chain.
const publicClient = createPublicClient({
chain: chainId === 1 ? mainnet : sepolia,
transport: http(network.providerUrl),
});

const result = await EIP1271Promise;

if (result.success) {
return result;
} else {
let signature = params.signature;
const lastByte = parseInt(params.signature.slice(-2), 16);
if (lastByte < 27) {
const adjustedV = (27 + (lastByte % 2))
.toString(16)
.padStart(2, '0');
signature = signature.slice(0, -2) + adjustedV;
}

const viemResponse = await publicClient.verifySiweMessage({
message: message.toMessage(),
signature: signature as `0x${string}`,
address: result.data.address as `0x${string}`,
nonce: params.nonce,
domain: params.domain as string,
time: params.time ? new Date(params.time) : undefined,
scheme: params.scheme as string,
});

if (viemResponse) {
return {
data: result.data,
success: true,
};
}

return result;
}
},
}
);
// SIWENS.verify performs EOA recovery, EIP-1271 and ERC-6492 verification
// internally via viem (`verifySiweMessage`) against the message's chain.
const siwensResponse = await siwens.verify({
signature: params.signature,
nonce: params.nonce,
domain: params.domain,
});

if (siwensResponse.data.chainId !== chainId) {
throw InvalidSignInException.chainIdMismatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
} from '../../types';
import { SiweConfig } from '../../types/siwe/siwe-config';
import { ChallengeRequestException } from '../../errors/ChallengeRequest.expection';
import { SiweMessage } from 'siwe';
import { generateNonce } from '@justaname.id/siwens';
import { getAddress } from 'viem';
import { createSiweMessage } from 'viem/siwe';

/**
* Represents the Sign-In with Ethereum (SIWE) functionality, providing methods
Expand Down Expand Up @@ -104,19 +106,18 @@ export class SubnameChallenge {
const { expirationTime, issuedAt } =
this.generateIssuedAndExpirationTime(_ttl);

const siweMessage = new SiweMessage({
const prepared = createSiweMessage({
domain: _domain,
uri: _origin,
address: _address,
address: getAddress(_address),
statement: statement,
chainId: _chainId,
version: '1',
issuedAt,
expirationTime,
nonce: generateNonce(),
issuedAt: new Date(issuedAt),
expirationTime: new Date(expirationTime),
});

const prepared = siweMessage.prepareMessage();

if (this.dev) {
// eslint-disable-next-line no-console
console.debug(
Expand Down
7 changes: 3 additions & 4 deletions packages/@justaname.id/siwens/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ yarn add @justaname.id/siwens
### Example Usage
```typescript
import { SIWENS, InvalidENSException } from '@justaname.id/siwens';
import { Wallet } from 'ethers';
import { privateKeyToAccount } from 'viem/accounts';

// Define your provider URL (e.g., Infura)
const infuraProjectId = 'YOUR_INFURA_PROJECT_ID';
const providerUrl = 'https://mainnet.infura.io/v3/' + infuraProjectId;

// const signer = Wallet.createRandom();
const signer = new Wallet('YOUR_PRIVATE_KEY');
const signer = privateKeyToAccount('YOUR_PRIVATE_KEY');

async function signInUser() {
const siwens = new SIWENS({
Expand All @@ -67,7 +66,7 @@ async function signInUser() {
providerUrl
});
const message = await siwens.prepareMessage();
const signature = await signer.signMessage(message);
const signature = await signer.signMessage({ message });
return {signature, message};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@justaname.id/siwens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@justaname.id/siwens",
"version": "0.0.145",
"dependencies": {
"@stablelib/random": "^1.0.2",
"punycode": "^2.3.1"
},
"peerDependencies": {
"siwe": ">=2.0.0",
"viem": "^2.48.0"
},
"exports": {
Expand Down
1 change: 1 addition & 0 deletions packages/@justaname.id/siwens/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './errors';
export * from './types';
export * from './siwens/siwens';
export * from './utils';
Loading
Loading