@huaweidevtools/aishell-dsh-client-credentials 0.0.0-stage → 0.0.1-beta.1

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,148 @@
1
+ /**
2
+ * aishell credentials host plugin.
3
+ *
4
+ * Owns Huawei Cloud AK/SK end to end: the browser half POSTs them to an
5
+ * authenticated Host route, this half verifies them against Huawei Cloud IAM,
6
+ * and only a verified set reaches the credential store (OS keyring with
7
+ * memory fallback). Secrets never enter the settings document, so the profile
8
+ * carries no plaintext at any point and the write path never touches the HMR
9
+ * transaction that settings edits run inside.
10
+ *
11
+ * The route is registered through `ctx.connection.fetch`, the framework's
12
+ * authenticated browser↔Host channel. Only the non-secret presence flag
13
+ * `credentialsStored` and the verified account name `accessKeyIdHint` reach
14
+ * the settings document, where the browser half reads them for the composer
15
+ * chip and the settings section.
16
+ *
17
+ * This plugin owns credential management; `aishell-llm` only consumes the
18
+ * stored credentials.
19
+ *
20
+ * @module @huaweidevtools/aishell-dsh-client-credentials
21
+ */
22
+ import type { Context, Volatile } from '@deepseek-ai/cordis';
23
+ import z from '@deepseek-ai/schemastery';
24
+ import { type CredentialsStore } from '@huaweidevtools/aishell-dsh-credentials-store';
25
+ /** Plugin config — non-secret status the browser half reads. */
26
+ export interface Config {
27
+ /** Presence flag the browser half reads; true once credentials reached the store. */
28
+ credentialsStored: Volatile<boolean>;
29
+ /** Account name the Host's IAM verification wrote; the composer hint chip reads it. */
30
+ accessKeyIdHint: Volatile<string>;
31
+ /** Readable verification failure the client form displays; set when the IAM check rejects. */
32
+ lastError: Volatile<string>;
33
+ /**
34
+ * Session waiting for credentials, or `''` when none is.
35
+ *
36
+ * The session id rather than a boolean because the browser needs both facts
37
+ * and they arrive together: "show the form" and "show it in this
38
+ * conversation". `conversation.composer` is session-scoped, so a form without
39
+ * a session has nowhere to render. Empty string rather than `undefined` so
40
+ * the setting stays one string type across the wire.
41
+ */
42
+ credentialRequestSession: Volatile<string>;
43
+ }
44
+ /**
45
+ * Settings schema for this entry. Secrets are deliberately absent: they travel
46
+ * over the credential route into the credential store, never through a
47
+ * settings document.
48
+ */
49
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
50
+ credentialsStored: z<boolean, boolean, "volatile-defined">;
51
+ accessKeyIdHint: z<string, string, "volatile-defined">;
52
+ lastError: z<string, string, "volatile-defined">;
53
+ credentialRequestSession: z<string, string, "volatile-defined">;
54
+ }>>, Schemastery.ObjectT<NoInfer<{
55
+ credentialsStored: z<boolean, boolean, "volatile-defined">;
56
+ accessKeyIdHint: z<string, string, "volatile-defined">;
57
+ lastError: z<string, string, "volatile-defined">;
58
+ credentialRequestSession: z<string, string, "volatile-defined">;
59
+ }>>, "plain">;
60
+ /**
61
+ * What the credential form collects, as the asking package expects it back.
62
+ *
63
+ * Declared here rather than imported from `aishell-ops-deploy`: the two
64
+ * packages communicate over a Cordis event, not an import (see the event
65
+ * declaration below), and the form has no business depending on the MCP
66
+ * plugin's types. The shape is the contract; both sides state it.
67
+ *
68
+ * No region: the credential store holds none, and the region belongs to
69
+ * whoever is calling. The asking package adds its own when the answer reaches
70
+ * it.
71
+ */
72
+ interface SuppliedCredentials {
73
+ readonly ak: string;
74
+ readonly sk: string;
75
+ /** Present only for STS credentials. */
76
+ readonly securityToken?: string;
77
+ }
78
+ declare module '@deepseek-ai/cordis' {
79
+ interface Events {
80
+ /**
81
+ * The MCP server asked for credentials and the store has none: show the
82
+ * form, and call `settle` when the person is done.
83
+ *
84
+ * Declared (not imported) on both sides because it is the whole interface
85
+ * between the credentials UI and the MCP plugin — the same shape the
86
+ * permission switch's route uses, one step less direct.
87
+ *
88
+ * @mode emit
89
+ */
90
+ 'aishell/credential-request'(request: {
91
+ readonly settle: (credentials: SuppliedCredentials | undefined) => void;
92
+ readonly signal: AbortSignal | undefined;
93
+ readonly sessionId: string | undefined;
94
+ }): void;
95
+ }
96
+ }
97
+ declare module '@deepseek-ai/cordis' {
98
+ interface Events {
99
+ /**
100
+ * The stored Huawei Cloud credentials changed — a verified save, or a
101
+ * clear. Emitted because `loader/volatile-update` is dispatched to the
102
+ * owning fiber only, so a plugin that *consumes* credentials (rather than
103
+ * owning the settings that describe them) has no other way to hear about a
104
+ * rotation.
105
+ *
106
+ * Listeners read the credential store themselves; this event carries no
107
+ * value, so a secret can never ride on it.
108
+ *
109
+ * @mode emit
110
+ */
111
+ 'aishell/credentials-updated'(): void;
112
+ }
113
+ }
114
+ /** Collaborators the credential routes run against; injected so they are testable. */
115
+ export interface CredentialRoutesDeps {
116
+ /** Durable credential store the verified set is transferred into. */
117
+ readonly store: CredentialsStore;
118
+ /** Verifies AK/SK (and optional token) against Huawei Cloud IAM; resolves the account name. */
119
+ readonly verify: (ak: string, sk: string, token?: string) => Promise<string>;
120
+ /** Records the non-secret status the browser half reads. */
121
+ readonly recordStatus: (ops: Parameters<Context['settings']['mutate']>[1]) => void;
122
+ /** Reads the cached account-name hint for the status response. */
123
+ readonly hint: () => string;
124
+ /**
125
+ * Announces that the stored credentials changed, so consumers that hold a
126
+ * snapshot of them (the MCP subprocess env) can rebuild. Called only after
127
+ * the store actually changed — a rejected save stores nothing and stays silent.
128
+ */
129
+ readonly notifyChanged: () => void;
130
+ }
131
+ /**
132
+ * The three credential routes, bound to their collaborators.
133
+ *
134
+ * Returned as plain `(request) => Promise<Response>` handlers so a test can
135
+ * drive them with a real `Request` and assert on the `Response` alone — the
136
+ * behavior worth pinning is that a rejected credential stores nothing and that
137
+ * no response ever carries a secret.
138
+ */
139
+ export declare function createCredentialRoutes(deps: CredentialRoutesDeps): {
140
+ get: () => Promise<Response>;
141
+ save: (request: Request) => Promise<Response>;
142
+ clear: () => Promise<Response>;
143
+ };
144
+ export declare const name = "aishell-client-credentials";
145
+ export declare const inject: string[];
146
+ export declare function apply(ctx: Context, config: Config): void;
147
+ export {};
148
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@huaweidevtools/aishell-dsh-client-credentials",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "AI Shell credentials settings panel — web form for storing Huawei Cloud AK/SK in the credential store",
4
+ "version": "0.0.1-beta.1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/yusheng-g/aishell-dsh-plugins.git",
11
+ "directory": "packages/aishell-credentials"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./client": {
22
+ "types": "./lib/types/client/index.d.ts",
23
+ "default": "./lib/client.js"
24
+ },
25
+ "./src/*": "./src/*",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "dsh": {
29
+ "client": {
30
+ "inject": [
31
+ "@deepseek-ai/dsh-client-ui-settings",
32
+ "@deepseek-ai/dsh-client-ui-conversation",
33
+ "@deepseek-ai/dsh-client-locale",
34
+ "@deepseek-ai/dsh-api-remotes"
35
+ ],
36
+ "platform": "web"
37
+ },
38
+ "bundle": {
39
+ "patch": "./cordis.patch.yml"
40
+ }
41
+ },
42
+ "license": "Apache-2.0",
43
+ "dependencies": {
44
+ "@huaweidevtools/aishell-dsh-credentials-store": "0.0.1-beta.1"
45
+ },
46
+ "peerDependencies": {
47
+ "@deepseek-ai/cordis": "^4.0.4",
48
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.1 || 0.2.1-alpha.1 || ^0.2.1"
49
+ },
50
+ "devDependencies": {
51
+ "@deepseek-ai/cordis": "^4.0.4",
52
+ "@deepseek-ai/cordis-plugin-loader": "^1.0.5",
53
+ "@deepseek-ai/dsh-client-connection": "0.2.0-rc.1",
54
+ "@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
55
+ "@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
56
+ "@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.1",
57
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.1",
58
+ "@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.1",
59
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
60
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
61
+ "@deepseek-ai/dsh-session": "0.2.0-rc.1",
62
+ "@deepseek-ai/dsh-settings": "0.2.0-rc.1",
63
+ "@deepseek-ai/schemastery": "3.18.4",
64
+ "@types/react": "~18.3.1",
65
+ "react": "^18.2.0",
66
+ "tsdown": "^0.10.0",
67
+ "typescript": "^5.7.0"
68
+ },
69
+ "files": [
70
+ "lib/index.js",
71
+ "lib/client.js",
72
+ "lib/types/**/*.d.ts",
73
+ "cordis.patch.yml"
74
+ ],
75
+ "scripts": {
76
+ "build:bundle": "tsdown"
77
+ }
6
78
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.