dsh-openai-subscription 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.
@@ -0,0 +1,12 @@
1
+ /** Normalized OAuth fields accepted from the authorization subprocess. */
2
+ export interface OAuthCredential {
3
+ access: string;
4
+ refresh?: string;
5
+ expires?: number;
6
+ accountId?: string;
7
+ }
8
+ /**
9
+ * Require a new access token and inherit missing optional fields from a
10
+ * previously normalized credential.
11
+ */
12
+ export declare function normalizeOAuthCredential(value: unknown, fallback?: Partial<OAuthCredential>): OAuthCredential | null;
package/dist/oauth.js ADDED
@@ -0,0 +1,29 @@
1
+ function nonEmptyString(value) {
2
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
3
+ }
4
+ function positiveFiniteNumber(value) {
5
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined;
6
+ }
7
+ /**
8
+ * Require a new access token and inherit missing optional fields from a
9
+ * previously normalized credential.
10
+ */
11
+ export function normalizeOAuthCredential(value, fallback = {}) {
12
+ if (typeof value !== 'object' || value === null)
13
+ return null;
14
+ const raw = value;
15
+ const access = nonEmptyString(raw.access);
16
+ if (access === undefined)
17
+ return null;
18
+ const credential = { access };
19
+ const refresh = nonEmptyString(raw.refresh) ?? nonEmptyString(fallback.refresh);
20
+ const expires = positiveFiniteNumber(raw.expires) ?? positiveFiniteNumber(fallback.expires);
21
+ const accountId = nonEmptyString(raw.accountId) ?? nonEmptyString(fallback.accountId);
22
+ if (refresh !== undefined)
23
+ credential.refresh = refresh;
24
+ if (expires !== undefined)
25
+ credential.expires = expires;
26
+ if (accountId !== undefined)
27
+ credential.accountId = accountId;
28
+ return credential;
29
+ }
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "dsh-openai-subscription",
3
+ "version": "0.1.0",
4
+ "description": "ChatGPT subscription sign-in for DeepSeek Harness via OpenAI device authorization.",
5
+ "type": "module",
6
+ "packageManager": "bun@1.4.0",
7
+ "engines": {
8
+ "node": ">=22.19.0"
9
+ },
10
+ "main": "./dist/host.js",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/host.d.ts",
14
+ "default": "./dist/host.js"
15
+ },
16
+ "./host": {
17
+ "types": "./dist/host.d.ts",
18
+ "default": "./dist/host.js"
19
+ },
20
+ "./client": {
21
+ "types": "./dist/client.d.ts",
22
+ "default": "./dist/client.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "scripts": {
27
+ "build": "rm -rf dist && tsc -p tsconfig.json",
28
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
29
+ "test": "rm -rf .test-dist && tsc -p tsconfig.test.json && node --test .test-dist/tests/*.test.js && rm -rf .test-dist",
30
+ "check": "bun run typecheck && bun run build && bun run test",
31
+ "prepack": "bun run check"
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "cordis.patch.yml",
36
+ "README.md",
37
+ "README.zh.md",
38
+ "LICENSE"
39
+ ],
40
+ "keywords": [
41
+ "dsh",
42
+ "deepseek-harness",
43
+ "cordis",
44
+ "openai",
45
+ "chatgpt",
46
+ "oauth",
47
+ "device-code",
48
+ "plugin"
49
+ ],
50
+ "license": "MIT",
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "https://github.com/AQian0/dsh-openai-subscription.git"
58
+ },
59
+ "dsh": {
60
+ "bundle": {
61
+ "patch": "./cordis.patch.yml"
62
+ },
63
+ "client": {
64
+ "platform": "web",
65
+ "inject": [
66
+ "@deepseek-ai/dsh-client-connection"
67
+ ]
68
+ }
69
+ },
70
+ "peerDependencies": {
71
+ "@deepseek-ai/cordis": "^4.0.2",
72
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-rc.1",
73
+ "@deepseek-ai/dsh-client-connection": "^0.1.2-rc.1"
74
+ },
75
+ "devDependencies": {
76
+ "@deepseek-ai/cordis": "^4.0.2",
77
+ "@deepseek-ai/cordis-plugin-timer": "^1.1.4",
78
+ "@deepseek-ai/dsh-authorization": "^0.1.2-rc.1",
79
+ "@deepseek-ai/dsh-credentials": "^0.1.2-rc.1",
80
+ "@deepseek-ai/dsh-settings": "^0.1.2-rc.1",
81
+ "@deepseek-ai/dsh-shell": "^0.1.2-rc.1",
82
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.2-rc.1",
83
+ "@types/node": "^25.6.1",
84
+ "typescript": "^7.0.2"
85
+ }
86
+ }