@codetunezstudios/token-kit 0.1.0-beta.4 → 0.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -127,13 +127,13 @@ interface TokenKitConfig {
|
|
|
127
127
|
* ```typescript
|
|
128
128
|
* import { connectViaPortal } from '@codetunezstudios/token-kit';
|
|
129
129
|
*
|
|
130
|
-
* const userToken = await connectViaPortal({
|
|
130
|
+
* const userToken = await connectViaPortal({ clientId: 'app_abc123...' });
|
|
131
131
|
* tokenKit.setUserToken(userToken);
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
interface ConnectViaPortalOptions {
|
|
135
|
-
/** The
|
|
136
|
-
|
|
135
|
+
/** The clientId of the developer app (created in the token-kit.com Apps dashboard). */
|
|
136
|
+
clientId: string;
|
|
137
137
|
/**
|
|
138
138
|
* Base URL of the Token-Kit portal.
|
|
139
139
|
* Defaults to 'https://ai-tokens.me'.
|
package/dist/index.d.ts
CHANGED
|
@@ -127,13 +127,13 @@ interface TokenKitConfig {
|
|
|
127
127
|
* ```typescript
|
|
128
128
|
* import { connectViaPortal } from '@codetunezstudios/token-kit';
|
|
129
129
|
*
|
|
130
|
-
* const userToken = await connectViaPortal({
|
|
130
|
+
* const userToken = await connectViaPortal({ clientId: 'app_abc123...' });
|
|
131
131
|
* tokenKit.setUserToken(userToken);
|
|
132
132
|
* ```
|
|
133
133
|
*/
|
|
134
134
|
interface ConnectViaPortalOptions {
|
|
135
|
-
/** The
|
|
136
|
-
|
|
135
|
+
/** The clientId of the developer app (created in the token-kit.com Apps dashboard). */
|
|
136
|
+
clientId: string;
|
|
137
137
|
/**
|
|
138
138
|
* Base URL of the Token-Kit portal.
|
|
139
139
|
* Defaults to 'https://ai-tokens.me'.
|
package/dist/index.js
CHANGED
|
@@ -219,7 +219,9 @@ var STORAGE_KEY = "tokenkit_user_token";
|
|
|
219
219
|
async function connectViaPortal(options) {
|
|
220
220
|
const portalUrl = (options.portalUrl ?? "https://ai-tokens.me").replace(/\/$/, "");
|
|
221
221
|
const currentOrigin = encodeURIComponent(window.location.origin);
|
|
222
|
-
const
|
|
222
|
+
const existingToken = getStoredUserToken();
|
|
223
|
+
const reconnectParam = existingToken ? "&reconnect=true" : "";
|
|
224
|
+
const url = `${portalUrl}/connect?clientId=${encodeURIComponent(options.clientId)}&origin=${currentOrigin}${reconnectParam}`;
|
|
223
225
|
const popup = window.open(
|
|
224
226
|
url,
|
|
225
227
|
"tokenkit-connect",
|
package/dist/index.mjs
CHANGED
|
@@ -176,7 +176,9 @@ var STORAGE_KEY = "tokenkit_user_token";
|
|
|
176
176
|
async function connectViaPortal(options) {
|
|
177
177
|
const portalUrl = (options.portalUrl ?? "https://ai-tokens.me").replace(/\/$/, "");
|
|
178
178
|
const currentOrigin = encodeURIComponent(window.location.origin);
|
|
179
|
-
const
|
|
179
|
+
const existingToken = getStoredUserToken();
|
|
180
|
+
const reconnectParam = existingToken ? "&reconnect=true" : "";
|
|
181
|
+
const url = `${portalUrl}/connect?clientId=${encodeURIComponent(options.clientId)}&origin=${currentOrigin}${reconnectParam}`;
|
|
180
182
|
const popup = window.open(
|
|
181
183
|
url,
|
|
182
184
|
"tokenkit-connect",
|
package/package.json
CHANGED