dsh-subscriptions 0.1.0
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/LICENSE +21 -0
- package/README.md +129 -0
- package/cordis.patch.yml +12 -0
- package/lib/auth/claude-code-creds.d.ts +23 -0
- package/lib/auth/claude-code-creds.js +172 -0
- package/lib/auth/device-flow.d.ts +55 -0
- package/lib/auth/device-flow.js +177 -0
- package/lib/auth/jwt.d.ts +10 -0
- package/lib/auth/jwt.js +25 -0
- package/lib/auth/oauth-flow.d.ts +91 -0
- package/lib/auth/oauth-flow.js +227 -0
- package/lib/auth/pkce.d.ts +31 -0
- package/lib/auth/pkce.js +35 -0
- package/lib/auth/rpc.d.ts +209 -0
- package/lib/auth/rpc.js +386 -0
- package/lib/auth/store.d.ts +196 -0
- package/lib/auth/store.js +468 -0
- package/lib/client/CursorCard.d.ts +9 -0
- package/lib/client/CursorCard.js +113 -0
- package/lib/client/ExternalUsageCards.d.ts +9 -0
- package/lib/client/ExternalUsageCards.js +72 -0
- package/lib/client/ImageGallery.d.ts +54 -0
- package/lib/client/ImageGallery.js +112 -0
- package/lib/client/ImageGenerateToolview.d.ts +48 -0
- package/lib/client/ImageGenerateToolview.js +133 -0
- package/lib/client/ProviderAccountManager.d.ts +13 -0
- package/lib/client/ProviderAccountManager.js +147 -0
- package/lib/client/ProviderModelEditor.d.ts +39 -0
- package/lib/client/ProviderModelEditor.js +107 -0
- package/lib/client/SpeedSelect.d.ts +71 -0
- package/lib/client/SpeedSelect.js +177 -0
- package/lib/client/SubscriptionUsageBadge.d.ts +116 -0
- package/lib/client/SubscriptionUsageBadge.js +543 -0
- package/lib/client/SubscriptionsSection.d.ts +140 -0
- package/lib/client/SubscriptionsSection.js +544 -0
- package/lib/client/UsageBadgeDisplaySetting.d.ts +7 -0
- package/lib/client/UsageBadgeDisplaySetting.js +36 -0
- package/lib/client/VideoGenerateToolview.d.ts +42 -0
- package/lib/client/VideoGenerateToolview.js +175 -0
- package/lib/client/account-preferences.d.ts +24 -0
- package/lib/client/account-preferences.js +21 -0
- package/lib/client/fast-command.d.ts +2 -0
- package/lib/client/fast-command.js +4 -0
- package/lib/client/host-contract.d.ts +90 -0
- package/lib/client/host-contract.js +101 -0
- package/lib/client/host-icons.d.ts +24 -0
- package/lib/client/host-icons.js +21 -0
- package/lib/client/index.d.ts +27 -0
- package/lib/client/index.js +136 -0
- package/lib/client/locales.d.ts +297 -0
- package/lib/client/locales.js +295 -0
- package/lib/client/subscription-card-styles.d.ts +3 -0
- package/lib/client/subscription-card-styles.js +53 -0
- package/lib/client/subscriptions-rpc.d.ts +14 -0
- package/lib/client/subscriptions-rpc.js +34 -0
- package/lib/client/usage-badge-preferences.d.ts +11 -0
- package/lib/client/usage-badge-preferences.js +41 -0
- package/lib/client.js +4472 -0
- package/lib/client.js.map +1 -0
- package/lib/compat.d.ts +36 -0
- package/lib/compat.js +20 -0
- package/lib/http.d.ts +6 -0
- package/lib/http.js +15 -0
- package/lib/index.d.ts +80 -0
- package/lib/index.js +14018 -0
- package/lib/model-defaults.d.ts +23 -0
- package/lib/model-defaults.js +237 -0
- package/lib/provider-settings.d.ts +39 -0
- package/lib/provider-settings.js +151 -0
- package/lib/providers/account-preferences.d.ts +41 -0
- package/lib/providers/account-preferences.js +153 -0
- package/lib/providers/accounts.d.ts +112 -0
- package/lib/providers/accounts.js +142 -0
- package/lib/providers/antigravity-oauth-client.d.ts +7 -0
- package/lib/providers/antigravity-oauth-client.js +7 -0
- package/lib/providers/antigravity.d.ts +110 -0
- package/lib/providers/antigravity.js +516 -0
- package/lib/providers/catalog-store.d.ts +48 -0
- package/lib/providers/catalog-store.js +243 -0
- package/lib/providers/claude-cli-version.d.ts +15 -0
- package/lib/providers/claude-cli-version.js +24 -0
- package/lib/providers/claude.d.ts +181 -0
- package/lib/providers/claude.js +680 -0
- package/lib/providers/codex-client-version.d.ts +8 -0
- package/lib/providers/codex-client-version.js +17 -0
- package/lib/providers/codex-search.d.ts +29 -0
- package/lib/providers/codex-search.js +198 -0
- package/lib/providers/codex.d.ts +229 -0
- package/lib/providers/codex.js +821 -0
- package/lib/providers/common.d.ts +389 -0
- package/lib/providers/common.js +656 -0
- package/lib/providers/copilot.d.ts +344 -0
- package/lib/providers/copilot.js +888 -0
- package/lib/providers/cursor-adapter.d.ts +15 -0
- package/lib/providers/cursor-adapter.js +39 -0
- package/lib/providers/cursor-auth.d.ts +43 -0
- package/lib/providers/cursor-auth.js +169 -0
- package/lib/providers/cursor-model-settings.d.ts +15 -0
- package/lib/providers/cursor-model-settings.js +51 -0
- package/lib/providers/cursor-usage.d.ts +9 -0
- package/lib/providers/cursor-usage.js +112 -0
- package/lib/providers/external-usage-controller.d.ts +19 -0
- package/lib/providers/external-usage-controller.js +32 -0
- package/lib/providers/external-usage.d.ts +8 -0
- package/lib/providers/external-usage.js +82 -0
- package/lib/providers/grok.d.ts +205 -0
- package/lib/providers/grok.js +713 -0
- package/lib/providers/image-pool.d.ts +30 -0
- package/lib/providers/image-pool.js +89 -0
- package/lib/providers/npm-cli-version.d.ts +56 -0
- package/lib/providers/npm-cli-version.js +98 -0
- package/lib/providers/pool-family.d.ts +56 -0
- package/lib/providers/pool-family.js +45 -0
- package/lib/providers/pool-health.d.ts +74 -0
- package/lib/providers/pool-health.js +150 -0
- package/lib/providers/pool-usage.d.ts +86 -0
- package/lib/providers/pool-usage.js +223 -0
- package/lib/providers/pool.d.ts +108 -0
- package/lib/providers/pool.js +368 -0
- package/lib/providers/rate-limit.d.ts +192 -0
- package/lib/providers/rate-limit.js +338 -0
- package/lib/tools/image-generate.d.ts +128 -0
- package/lib/tools/image-generate.js +438 -0
- package/lib/tools/registration.d.ts +15 -0
- package/lib/tools/registration.js +24 -0
- package/lib/tools/video-generate.d.ts +89 -0
- package/lib/tools/video-generate.js +257 -0
- package/lib/tools/x-search.d.ts +58 -0
- package/lib/tools/x-search.js +197 -0
- package/lib/translate/anthropic.d.ts +161 -0
- package/lib/translate/anthropic.js +515 -0
- package/lib/translate/antigravity-schema.d.ts +4 -0
- package/lib/translate/antigravity-schema.js +145 -0
- package/lib/translate/antigravity-thinking.d.ts +5 -0
- package/lib/translate/antigravity-thinking.js +44 -0
- package/lib/translate/antigravity.d.ts +114 -0
- package/lib/translate/antigravity.js +366 -0
- package/lib/translate/chat-completions.d.ts +120 -0
- package/lib/translate/chat-completions.js +382 -0
- package/lib/translate/resolved.d.ts +80 -0
- package/lib/translate/resolved.js +118 -0
- package/lib/translate/responses.d.ts +179 -0
- package/lib/translate/responses.js +408 -0
- package/lib/translate/sse.d.ts +21 -0
- package/lib/translate/sse.js +56 -0
- package/package.json +114 -0
- package/vendor/cursor/LICENSE +21 -0
- package/vendor/cursor/index.d.ts +18 -0
- package/vendor/cursor/index.js +3574 -0
- package/vendor/cursor/proto.js +254 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The node half mounts every endpoint as an exact POST route on the shared
|
|
3
|
+
* `/api` channel (`/api/subscriptions-auth.<endpoint>`), so the browser
|
|
4
|
+
* reaches it through the `/api` channel with a prefixed endpoint name.
|
|
5
|
+
* A dedicated channel is no longer used: since dsh 0.1.5 `rpc.handle`
|
|
6
|
+
* cannot register one from a plugin (see `src/auth/rpc.ts`).
|
|
7
|
+
*/
|
|
8
|
+
const SUBSCRIPTIONS_AUTH_CHANNEL = '/api';
|
|
9
|
+
const SUBSCRIPTIONS_AUTH_PREFIX = 'subscriptions-auth.';
|
|
10
|
+
/** Business error returned by a `subscriptions-auth` endpoint (error branch message). */
|
|
11
|
+
export class SubscriptionsAuthError extends Error {
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Call one `subscriptions-auth` endpoint and unwrap the business result.
|
|
15
|
+
* Shared by the settings section, the composer Speed toggle, the usage
|
|
16
|
+
* badge, and the image/video toolviews.
|
|
17
|
+
* @param rpc - Connection RPC caller.
|
|
18
|
+
* @param endpoint - endpoint name (`status`, `usage`, `image`, ...).
|
|
19
|
+
* @param payload - endpoint-owned request payload.
|
|
20
|
+
* @returns the success value, cast by the caller to the endpoint's shape.
|
|
21
|
+
*/
|
|
22
|
+
export async function callSubscriptionsAuth(rpc, endpoint, payload) {
|
|
23
|
+
let result;
|
|
24
|
+
try {
|
|
25
|
+
result = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, `${SUBSCRIPTIONS_AUTH_PREFIX}${endpoint}`, payload);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// The transport rejected rather than answering; surface the same way.
|
|
29
|
+
throw new SubscriptionsAuthError(error instanceof Error ? error.message : String(error));
|
|
30
|
+
}
|
|
31
|
+
if (!result.ok)
|
|
32
|
+
throw new SubscriptionsAuthError(result.error.message);
|
|
33
|
+
return result.value;
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Display-only preference: no credentials or account history are stored. */
|
|
2
|
+
export type UsageBadgeMode = 'recent' | 'hidden';
|
|
3
|
+
export declare const USAGE_BADGE_REFRESH_EVENT = "dsh:subscriptions:usage-refresh";
|
|
4
|
+
/** Read the browser preference; blocked storage retains the default display. */
|
|
5
|
+
export declare function readUsageBadgeMode(): UsageBadgeMode;
|
|
6
|
+
/** Save first, then notify; the settings control reports a rejected write. */
|
|
7
|
+
export declare function setUsageBadgeMode(mode: UsageBadgeMode): void;
|
|
8
|
+
/** Same-tab writes need a custom event; other tabs use the storage event. */
|
|
9
|
+
export declare function subscribeUsageBadgeMode(notify: () => void): () => void;
|
|
10
|
+
/** Shared React snapshot used by the settings control and every mounted badge. */
|
|
11
|
+
export declare function useUsageBadgeMode(): UsageBadgeMode;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
const MODE_KEY = 'dsh.subscriptions.usageBadgeMode';
|
|
3
|
+
const MODE_EVENT = 'dsh:subscriptions:usage-badge-mode';
|
|
4
|
+
export const USAGE_BADGE_REFRESH_EVENT = 'dsh:subscriptions:usage-refresh';
|
|
5
|
+
/** Read the browser preference; blocked storage retains the default display. */
|
|
6
|
+
export function readUsageBadgeMode() {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return 'recent';
|
|
9
|
+
try {
|
|
10
|
+
return window.localStorage.getItem(MODE_KEY) === 'hidden' ? 'hidden' : 'recent';
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (!(error instanceof DOMException) || error.name !== 'SecurityError')
|
|
14
|
+
throw error;
|
|
15
|
+
return 'recent';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Save first, then notify; the settings control reports a rejected write. */
|
|
19
|
+
export function setUsageBadgeMode(mode) {
|
|
20
|
+
if (mode !== 'recent' && mode !== 'hidden')
|
|
21
|
+
throw new TypeError('Invalid subscription usage display mode');
|
|
22
|
+
window.localStorage.setItem(MODE_KEY, mode);
|
|
23
|
+
window.dispatchEvent(new Event(MODE_EVENT));
|
|
24
|
+
}
|
|
25
|
+
/** Same-tab writes need a custom event; other tabs use the storage event. */
|
|
26
|
+
export function subscribeUsageBadgeMode(notify) {
|
|
27
|
+
const onStorage = (event) => {
|
|
28
|
+
if (event.key === MODE_KEY || event.key === null)
|
|
29
|
+
notify();
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener(MODE_EVENT, notify);
|
|
32
|
+
window.addEventListener('storage', onStorage);
|
|
33
|
+
return () => {
|
|
34
|
+
window.removeEventListener(MODE_EVENT, notify);
|
|
35
|
+
window.removeEventListener('storage', onStorage);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Shared React snapshot used by the settings control and every mounted badge. */
|
|
39
|
+
export function useUsageBadgeMode() {
|
|
40
|
+
return useSyncExternalStore(subscribeUsageBadgeMode, readUsageBadgeMode, () => 'recent');
|
|
41
|
+
}
|