diff --git a/README.md b/README.md index 99d08f2..a816a45 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ Native Authenticator for JavaScript and TypeScript (written in TypeScript). ## Distribution -[npm](https://www.npmjs.com/package/@elrondnetwork/native-auth) +[npm](https://www.npmjs.com/package/@multiversx/mx-sdk-erdjs-native-auth-client) ## Example + ### Client-side ```js @@ -15,7 +16,7 @@ const init = await client.initialize(); // obtain signature by signing the following message: `${address}${init}` // Example: -// - if the address is `erd1qnk2vmuqywfqtdnkmauvpm8ls0xh00k8xeupuaf6cm6cd4rx89qqz0ppgl` +// - if the address is `erd1qnk2vmuqywfqtdnkmauvpm8ls0xh00k8xeupuaf6cm6cd4rx89qqz0ppgl` // - and the init string is `YXBpLmVscm9uZC5jb20.066de4ba7df143f2383c3e0cd7ef8eeaf13375d1123ec8bafcef9f7908344b0f.86400.e30` // - then the signable message should be `erd1qnk2vmuqywfqtdnkmauvpm8ls0xh00k8xeupuaf6cm6cd4rx89qqz0ppgl066de4ba7df143f2383c3e0cd7ef8eeaf13375d1123ec8bafcef9f7908344b0f.86400.e30` @@ -37,15 +38,15 @@ When initializing the client object, an optional config can also be specified wi // The endpoint from where the current block information will be fetched upon initialization. // The default value points to the mainnet API, but can be overridden to be network-specific // or to point to a self-hosted location - apiUrl: string = 'https://api.elrond.com'; + apiUrl: string = 'https://api.multiversx.com'; // TTL that will be encoded in the access token. // This value will also be validated by the server and must not be greater than the maximum ttl allowed. // Default: one day (86400 seconds) expirySeconds: number = 60 * 60 * 24; - + // Optional, to fetch the block hash from a single shard. - // Useful in the situations where the server connects directly to a node to fetch block info + // Useful in the situations where the server connects directly to a node to fetch block info // and would like a predictable shard for the validation of tokens blockHashShard: 0; } diff --git a/package-lock.json b/package-lock.json index 48014a1..f7c7e8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "@elrondnetwork/native-auth-client", - "version": "0.1.5", + "name": "@multiversx/mx-sdk-erdjs-native-auth-client", + "version": "0.1.6", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@elrondnetwork/native-auth-client", - "version": "0.1.5", + "name": "@multiversx/mx-sdk-erdjs-native-auth-client", + "version": "0.1.6", "license": "GPL-3.0-or-later", "dependencies": { "axios": "^0.27.2" diff --git a/package.json b/package.json index ec10722..c93a02a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@elrondnetwork/native-auth-client", - "version": "0.1.5", + "name": "@multiversx/mx-sdk-erdjs-native-auth-client", + "version": "0.1.6", "description": "Native authentication client-side", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -15,15 +15,15 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/ElrondNetwork/native-auth-client.git" + "url": "git+https://github.com/MultiversX/mx-sdk-erdjs-native-auth-client.git" }, "keywords": [ - "elrond", + "multiversx", "native", "auth", "client" ], - "author": "ElrondNetwork", + "author": "MultiversX", "license": "GPL-3.0-or-later", "devDependencies": { "@babel/core": "^7.17.8", @@ -43,4 +43,4 @@ "dependencies": { "axios": "^0.27.2" } -} \ No newline at end of file +} diff --git a/src/entities/native.auth.client.config.ts b/src/entities/native.auth.client.config.ts index d9b3bd1..e02d1b8 100644 --- a/src/entities/native.auth.client.config.ts +++ b/src/entities/native.auth.client.config.ts @@ -1,6 +1,6 @@ export class NativeAuthClientConfig { host: string = typeof window !== "undefined" ? window.location.hostname : ''; - apiUrl: string = 'https://api.elrond.com'; + apiUrl: string = 'https://api.multiversx.com'; expirySeconds: number = 60 * 60 * 24; blockHashShard?: number; gatewayUrl?: string; diff --git a/test/native.auth.test.ts b/test/native.auth.test.ts index e1534e1..fc54882 100644 --- a/test/native.auth.test.ts +++ b/test/native.auth.test.ts @@ -4,16 +4,16 @@ import { NativeAuthClient } from '../src'; describe("Native Auth", () => { let mock: MockAdapter; - const ADDRESS = 'erd13rrn3fwjds8r5260n6q3pd2qa6wqkudrhczh26d957c0edyzermshds0k8'; - const SIGNATURE = '4b445f287663b868e269aa0532c9fd73acb37cfd45f46e33995777e68e5ecc15d97318d9af09c4102f9b40ecf347a75e2d2e81acbcc3c72ae32fcf659c2acd0e'; - const BLOCK_HASH = 'b3d07565293fd5684c97d2b96eb862d124fd698678f3f95b2515ed07178a27b4'; + const ADDRESS = 'erd1qnk2vmuqywfqtdnkmauvpm8ls0xh00k8xeupuaf6cm6cd4rx89qqz0ppgl'; + const SIGNATURE = '563cb2dfdf96ab335423a05287fa3cd00154034423d0062421ee6ce03230d941da6df9ce79689fcd173c0ba5d4331b3ccd82c8ec2e6ab4d875db1587c2ab720c'; + const BLOCK_HASH = '82ec8044966efb2d00e8a6367ea23ddbc7bea6504ed98f4a1a536d7c21bb2682'; const TTL = 86400; - const HOST = 'elrond.com'; - const TOKEN = `ZWxyb25kLmNvbQ.${BLOCK_HASH}.${TTL}.e30`; - const ACCESS_TOKEN = 'ZXJkMTNycm4zZndqZHM4cjUyNjBuNnEzcGQycWE2d3FrdWRyaGN6aDI2ZDk1N2MwZWR5emVybXNoZHMwazg.Wld4eWIyNWtMbU52YlEuYjNkMDc1NjUyOTNmZDU2ODRjOTdkMmI5NmViODYyZDEyNGZkNjk4Njc4ZjNmOTViMjUxNWVkMDcxNzhhMjdiNC44NjQwMC5lMzA.4b445f287663b868e269aa0532c9fd73acb37cfd45f46e33995777e68e5ecc15d97318d9af09c4102f9b40ecf347a75e2d2e81acbcc3c72ae32fcf659c2acd0e'; + const HOST = 'api.multiversx.com'; + const TOKEN = `YXBpLm11bHRpdmVyc3guY29t.${BLOCK_HASH}.${TTL}.e30`; + const ACCESS_TOKEN = 'ZXJkMXFuazJ2bXVxeXdmcXRkbmttYXV2cG04bHMweGgwMGs4eGV1cHVhZjZjbTZjZDRyeDg5cXF6MHBwZ2w.WVhCcExtMTFiSFJwZG1WeWMzZ3VZMjl0LjgyZWM4MDQ0OTY2ZWZiMmQwMGU4YTYzNjdlYTIzZGRiYzdiZWE2NTA0ZWQ5OGY0YTFhNTM2ZDdjMjFiYjI2ODIuODY0MDAuZTMw.563cb2dfdf96ab335423a05287fa3cd00154034423d0062421ee6ce03230d941da6df9ce79689fcd173c0ba5d4331b3ccd82c8ec2e6ab4d875db1587c2ab720c'; const onLatestBlockHashGet = function (mock: MockAdapter): RequestHandler { - return mock.onGet('https://api.elrond.com/blocks?size=1&fields=hash'); + return mock.onGet('https://api.multiversx.com/blocks?size=1&fields=hash'); }; beforeAll(() => { @@ -61,22 +61,22 @@ describe("Native Auth", () => { describe("Native Auth with gateway", () => { let mock: MockAdapter; - const ADDRESS = 'erd13rrn3fwjds8r5260n6q3pd2qa6wqkudrhczh26d957c0edyzermshds0k8'; - const SIGNATURE = '4b445f287663b868e269aa0532c9fd73acb37cfd45f46e33995777e68e5ecc15d97318d9af09c4102f9b40ecf347a75e2d2e81acbcc3c72ae32fcf659c2acd0e'; - const BLOCK_HASH = 'b3d07565293fd5684c97d2b96eb862d124fd698678f3f95b2515ed07178a27b4'; + const ADDRESS = 'erd1qnk2vmuqywfqtdnkmauvpm8ls0xh00k8xeupuaf6cm6cd4rx89qqz0ppgl'; + const SIGNATURE = '563cb2dfdf96ab335423a05287fa3cd00154034423d0062421ee6ce03230d941da6df9ce79689fcd173c0ba5d4331b3ccd82c8ec2e6ab4d875db1587c2ab720c'; + const BLOCK_HASH = '82ec8044966efb2d00e8a6367ea23ddbc7bea6504ed98f4a1a536d7c21bb2682'; const TTL = 86400; - const HOST = 'elrond.com'; - const TOKEN = `ZWxyb25kLmNvbQ.${BLOCK_HASH}.${TTL}.e30`; - const ACCESS_TOKEN = 'ZXJkMTNycm4zZndqZHM4cjUyNjBuNnEzcGQycWE2d3FrdWRyaGN6aDI2ZDk1N2MwZWR5emVybXNoZHMwazg.Wld4eWIyNWtMbU52YlEuYjNkMDc1NjUyOTNmZDU2ODRjOTdkMmI5NmViODYyZDEyNGZkNjk4Njc4ZjNmOTViMjUxNWVkMDcxNzhhMjdiNC44NjQwMC5lMzA.4b445f287663b868e269aa0532c9fd73acb37cfd45f46e33995777e68e5ecc15d97318d9af09c4102f9b40ecf347a75e2d2e81acbcc3c72ae32fcf659c2acd0e'; + const HOST = 'api.multiversx.com'; + const TOKEN = `YXBpLm11bHRpdmVyc3guY29t.${BLOCK_HASH}.${TTL}.e30`; + const ACCESS_TOKEN = 'ZXJkMXFuazJ2bXVxeXdmcXRkbmttYXV2cG04bHMweGgwMGs4eGV1cHVhZjZjbTZjZDRyeDg5cXF6MHBwZ2w.WVhCcExtMTFiSFJwZG1WeWMzZ3VZMjl0LjgyZWM4MDQ0OTY2ZWZiMmQwMGU4YTYzNjdlYTIzZGRiYzdiZWE2NTA0ZWQ5OGY0YTFhNTM2ZDdjMjFiYjI2ODIuODY0MDAuZTMw.563cb2dfdf96ab335423a05287fa3cd00154034423d0062421ee6ce03230d941da6df9ce79689fcd173c0ba5d4331b3ccd82c8ec2e6ab4d875db1587c2ab720c'; const latestRound = 115656; const METASHARD = 4294967295; - const GATEWAY = 'https://gateway.elrond.com'; + const GATEWAY = 'https://gateway.multiversx.com'; const onBlocksByRound = function (mock: MockAdapter): RequestHandler { return mock.onGet(`${GATEWAY}/blocks/by-round/${latestRound}`); }; - //https://testnet-gateway.elrond.com/network/status/4294967295 + //https://testnet-gateway.multiversx.com/network/status/4294967295 const onNetworkStatus = function (mock: MockAdapter): RequestHandler { return mock.onGet(`${GATEWAY}/network/status/${METASHARD}`); };