mirror of
https://github.com/alexgo-io/stacks.js.git
synced 2026-05-01 02:32:52 +08:00
refactor: remove query-string dependency
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -25002,8 +25002,7 @@
|
|||||||
"@stacks/network": "^6.1.1",
|
"@stacks/network": "^6.1.1",
|
||||||
"@stacks/profile": "^6.1.1",
|
"@stacks/profile": "^6.1.1",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"jsontokens": "^4.0.1",
|
"jsontokens": "^4.0.1"
|
||||||
"query-string": "^6.13.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
@@ -29952,7 +29951,6 @@
|
|||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"jsontokens": "^4.0.1",
|
"jsontokens": "^4.0.1",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"query-string": "^6.13.1",
|
|
||||||
"rimraf": "^3.0.2"
|
"rimraf": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
"@stacks/network": "^6.1.1",
|
"@stacks/network": "^6.1.1",
|
||||||
"@stacks/profile": "^6.1.1",
|
"@stacks/profile": "^6.1.1",
|
||||||
"cross-fetch": "^3.1.5",
|
"cross-fetch": "^3.1.5",
|
||||||
"jsontokens": "^4.0.1",
|
"jsontokens": "^4.0.1"
|
||||||
"query-string": "^6.13.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import * as queryString from 'query-string';
|
|
||||||
import { decodeToken } from 'jsontokens';
|
import { decodeToken } from 'jsontokens';
|
||||||
import { BLOCKSTACK_HANDLER, getGlobalObject } from '@stacks/common';
|
import { BLOCKSTACK_HANDLER, getGlobalObject } from '@stacks/common';
|
||||||
import { createFetchFn, FetchFn } from '@stacks/network';
|
import { createFetchFn, FetchFn } from '@stacks/network';
|
||||||
@@ -10,21 +9,14 @@ import { createFetchFn, FetchFn } from '@stacks/network';
|
|||||||
* @private
|
* @private
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
export function getAuthRequestFromURL() {
|
export function getAuthRequestFromURL(): string | null {
|
||||||
const location = getGlobalObject('location', {
|
const location = getGlobalObject('location', {
|
||||||
throwIfUnavailable: true,
|
throwIfUnavailable: true,
|
||||||
usageDesc: 'getAuthRequestFromURL',
|
usageDesc: 'getAuthRequestFromURL',
|
||||||
});
|
});
|
||||||
if (location?.search) {
|
|
||||||
const queryDict = queryString.parse(location?.search);
|
const params = new URLSearchParams(location?.search);
|
||||||
if (queryDict.authRequest) {
|
return params.get('authRequest')?.replaceAll(`${BLOCKSTACK_HANDLER}:`, '') ?? null;
|
||||||
return (queryDict.authRequest as string).split(`${BLOCKSTACK_HANDLER}:`).join('');
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
} from '@stacks/common';
|
} from '@stacks/common';
|
||||||
import { extractProfile } from '@stacks/profile';
|
import { extractProfile } from '@stacks/profile';
|
||||||
import { AuthScope, DEFAULT_PROFILE } from './constants';
|
import { AuthScope, DEFAULT_PROFILE } from './constants';
|
||||||
import * as queryString from 'query-string';
|
|
||||||
import { UserData } from './userData';
|
import { UserData } from './userData';
|
||||||
import { createFetchFn, FetchFn, StacksMainnet } from '@stacks/network';
|
import { createFetchFn, FetchFn, StacksMainnet } from '@stacks/network';
|
||||||
import { protocolEchoReplyDetection } from './protocolEchoDetection';
|
import { protocolEchoReplyDetection } from './protocolEchoDetection';
|
||||||
@@ -162,11 +162,9 @@ export class UserSession {
|
|||||||
throwIfUnavailable: true,
|
throwIfUnavailable: true,
|
||||||
usageDesc: 'getAuthResponseToken',
|
usageDesc: 'getAuthResponseToken',
|
||||||
})?.search;
|
})?.search;
|
||||||
if (search) {
|
|
||||||
const queryDict = queryString.parse(search);
|
const params = new URLSearchParams(search);
|
||||||
return queryDict.authResponse ? (queryDict.authResponse as string) : '';
|
return params.get('authResponse') ?? '';
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user