Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #100

Merged
merged 22 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
697be21
chore(release): publish [skip ci] (#95)
anthony23991 Jan 23, 2025
48fa986
fix: feedbacks (#97)
anthony23991 Jan 28, 2025
9ecf8a1
Merge branch 'main' of https://github.com/JustaName-id/JustaName-sdk …
anthony23991 Jan 28, 2025
7caf0fc
Merge branch 'console' of https://github.com/JustaName-id/JustaName-s…
anthony23991 Jan 28, 2025
0d84004
Merge branch 'main' of https://github.com/JustaName-id/JustaName-sdk …
anthony23991 Jan 29, 2025
38bd657
Merge branch 'main' of https://github.com/JustaName-id/JustaName-sdk …
anthony23991 Jan 29, 2025
24cd482
Merge branch 'console' of https://github.com/JustaName-id/JustaName-s…
anthony23991 Feb 3, 2025
eed5f1d
Merge branch 'main' of https://github.com/JustaName-id/JustaName-sdk …
anthony23991 Feb 6, 2025
be21dfc
chore(release): publish [skip ci]
anthony23991 Feb 6, 2025
e10b619
chore(release): publish [skip ci]
anthony23991 Feb 6, 2025
b821e00
fix(sdk): made domain and origin optional
anthony23991 Feb 7, 2025
7b3f3cc
chore(release): publish [skip ci]
anthony23991 Feb 7, 2025
0ce5463
fix(sdk): build
anthony23991 Feb 7, 2025
c5c83f0
chore(release): publish [skip ci]
anthony23991 Feb 7, 2025
3ed3ea9
feat: override add
HadiKhai Feb 10, 2025
57d19df
chore(release): publish [skip ci]
HadiKhai Feb 10, 2025
da0c4c6
chore(release): publish [skip ci]
HadiKhai Feb 10, 2025
e7dd960
chore(release): publish [skip ci]
HadiKhai Feb 12, 2025
cefcfc0
Merge branch 'main' of https://github.com/JustaName-id/JustaName-sdk …
anthony23991 Feb 13, 2025
d63d916
feat: added disconnect and switch ens buttons
anthony23991 Feb 13, 2025
e028dc9
chore(release): publish [skip ci]
anthony23991 Feb 13, 2025
b15b363
Merge branch 'console' of https://github.com/JustaName-id/JustaName-s…
anthony23991 Feb 13, 2025
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
56 changes: 56 additions & 0 deletions packages/@justaname.id/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
## 0.3.183 (2025-02-13)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.180

## 0.3.182 (2025-02-12)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.179

## 0.3.181 (2025-02-10)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.178

## 0.3.180 (2025-02-10)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.177

## 0.3.179 (2025-02-07)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.176

## 0.3.178 (2025-02-07)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.175

## 0.3.177 (2025-02-06)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.174

## 0.3.176 (2025-02-06)


### 🧱 Updated Dependencies

- Updated @justaname.id/sdk to 0.2.173

## 0.3.175 (2025-02-06)


Expand Down
4 changes: 2 additions & 2 deletions packages/@justaname.id/react/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@justaname.id/react",
"version": "0.3.175",
"version": "0.3.183",
"dependencies": {
"@ensdomains/ensjs": "4.0.2",
"@justaname.id/sdk": "0.2.172",
"@justaname.id/sdk": "0.2.180",
"axios": "^1.6.0",
"qs": "^6.12.0"
},
Expand Down
86 changes: 86 additions & 0 deletions packages/@justaname.id/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,89 @@
## 0.2.180 (2025-02-13)


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.113

## 0.2.179 (2025-02-12)


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.112

## 0.2.178 (2025-02-10)


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.111

## 0.2.177 (2025-02-10)


### 🚀 Features

- override add ([3ed3ea98](https://github.com/JustaName-id/JustaName-sdk/commit/3ed3ea98))


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.110


### ❤️ Thank You

- HadiKhai

## 0.2.176 (2025-02-07)


### 🩹 Fixes

- **sdk:** build ([0ce5463b](https://github.com/JustaName-id/JustaName-sdk/commit/0ce5463b))


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.109


### ❤️ Thank You

- anthony2399 @anthony23991

## 0.2.175 (2025-02-07)


### 🩹 Fixes

- **sdk:** made domain and origin optional ([b821e007](https://github.com/JustaName-id/JustaName-sdk/commit/b821e007))


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.108


### ❤️ Thank You

- anthony2399 @anthony23991

## 0.2.174 (2025-02-06)


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.107

## 0.2.173 (2025-02-06)


### 🧱 Updated Dependencies

- Updated @justaname.id/siwens to 0.0.106

## 0.2.172 (2025-02-06)


Expand Down
4 changes: 2 additions & 2 deletions packages/@justaname.id/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@justaname.id/sdk",
"version": "0.2.172",
"version": "0.2.180",
"dependencies": {
"@justaname.id/siwens": "0.0.105",
"@justaname.id/siwens": "0.0.113",
"axios": "^1.6.0",
"qs": "^6.12.0"
},
Expand Down
30 changes: 22 additions & 8 deletions packages/@justaname.id/sdk/src/lib/features/subnames/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SubnameSearchRoute,
SubnameUpdateRoute,
PrimaryNameGetByAddressRoute,
SetPrimaryNameRoute,
SetPrimaryNameRoute, SIWEHeaders
} from '../../types';
import { sanitizeAddresses, sanitizeTexts } from '../../utils';
import { InvalidConfigurationException } from '../../errors';
Expand Down Expand Up @@ -151,7 +151,7 @@ export class Subnames {

async addSubname(
params: SubnameAddRoute['params'],
headers: SubnameAddRoute['headers']
headers?: SubnameAddRoute['headers']
): Promise<SubnameAddRoute['response']> {
const {
text,
Expand All @@ -165,7 +165,8 @@ export class Subnames {

const { signature, xSignature } = this.checkSignature(
paramSignature,
headers.xSignature
headers?.xSignature,
rest.overrideSignatureCheck
);

const sanitizedAddresses = sanitizeAddresses(params.addresses);
Expand All @@ -180,11 +181,17 @@ export class Subnames {
?.ensDomain;

const _apiKey =
headers.xApiKey ||
headers?.xApiKey ||
this.ensDomains?.find((ensDomain) => ensDomain.chainId === _chainId)
?.apiKey ||
apiKey;

const requiredHeaders = ["xApiKey"] as ('xApiKey' | keyof SIWEHeaders)[]

if(!rest.overrideSignatureCheck) {
requiredHeaders.push("xAddress", "xMessage");
}

return assertRestCall(
'ADD_SUBNAME_ROUTE',
'POST',
Expand All @@ -197,7 +204,7 @@ export class Subnames {
: [
{
coinType: 60,
address: headers.xAddress as string,
address: headers?.xAddress as string,
},
...(sanitizedAddresses === undefined ? [] : sanitizedAddresses),
],
Expand All @@ -212,7 +219,7 @@ export class Subnames {
this.dev
)(
['username', 'ensDomain', 'chainId'],
['xApiKey', 'xAddress', 'xMessage']
requiredHeaders
);
}

Expand Down Expand Up @@ -543,14 +550,21 @@ export class Subnames {

private checkSignature(
params: string | undefined,
headers: string | undefined
headers: string | undefined,
skipThrowError = false
): {
signature: string | undefined;
xSignature: string | undefined;
} {
const signature = params || headers;
const signature = params || headers

if (!signature) {
if (skipThrowError) {
return {
signature: undefined,
xSignature: undefined,
};
}
throw InvalidConfigurationException.missingParameterOrHeader('signature');
}

Expand Down
15 changes: 9 additions & 6 deletions packages/@justaname.id/sdk/src/lib/justaname/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ export class JustaName {

this.checkConfig(sanitizedConfiguration);

const siweConfig = configuration.config
? {
domain: configuration.config.domain,
origin: configuration.config.origin,
}
: undefined;
const siweConfig =
configuration.config &&
configuration.config.domain &&
configuration.config.origin
? {
domain: configuration.config.domain,
origin: configuration.config.origin,
}
: undefined;

const subnameChallenge = new SubnameChallenge({
siweConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type NetworksWithProvider = [
];

export interface Configuration {
domain: string;
origin: string;
domain?: string;
origin?: string;
subnameChallengeTtl?: number;
signInTtl?: number;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/@justaname.id/sdk/src/lib/types/subnames/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface SubnameAddRequest extends IRequest {
contentHash?: string;

signature?: string;

overrideSignatureCheck?: boolean;
}

export interface SubnameAddRoute
Expand All @@ -47,5 +49,6 @@ export interface SubnameAddRoute
addresses?: PartialAddressJson | AddressWithTypedCoins[];
text?: Record<string, string> | TextRecordAddRequest[];
apiKey?: string;
overrideSignatureCheck?: boolean;
}
> {}
23 changes: 21 additions & 2 deletions packages/@justaname.id/sdk/src/test/integration/justaname.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ describe('justaname', () => {
});

it('should request a challenge', async () => {
const challenge = await justaname.siwe.requestChallenge({
const challenge = justaname.siwe.requestChallenge({
// 30mins
ttl: 1800000,
chainId: CHAIN_ID,
origin: 'http://localhost:3333',
address: '0x59c44836630760F97b74b569B379ca94c37B93ca',
domain: 'justaname.id',
domain: 'justaname.id'
});
expect(challenge).toBeDefined();
});
Expand Down Expand Up @@ -107,6 +107,25 @@ describe('justaname', () => {
expect(response).toBeDefined();
});


it('should add a subname without signature if overrideSignatureCheck is enabled', async () => {

const response = await justaname.subnames.addSubname(
{
username: subnameToBeAdded,
chainId: CHAIN_ID,
addresses: [{
coinType: "60",
address: '0x59c44836630760F97b74b569B379ca94c37B93ca',
}],
overrideSignatureCheck: true,
}
);

expect(response).toBeDefined();
});


it('should check if subname2 is available', async () => {
const response = await justaname.subnames.isSubnameAvailable({
subname: subnameToBeAdded + '2' + '.' + ENS_DOMAIN,
Expand Down
32 changes: 32 additions & 0 deletions packages/@justaname.id/siwens/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## 0.0.113 (2025-02-13)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.112 (2025-02-12)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.111 (2025-02-10)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.110 (2025-02-10)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.109 (2025-02-07)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.108 (2025-02-07)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.107 (2025-02-06)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.106 (2025-02-06)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.

## 0.0.105 (2025-02-06)

This was a version bump only for @justaname.id/siwens to align it with other projects, there were no code changes.
Expand Down
2 changes: 1 addition & 1 deletion packages/@justaname.id/siwens/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@justaname.id/siwens",
"version": "0.0.105",
"version": "0.0.113",
"peerDependencies": {
"ethers": "^5.6.8 || ^6.0.8",
"siwe": ">=2.0.0"
Expand Down
Loading
Loading