@xmodelin/dsh-collab-auth-api 0.0.0-stage → 0.0.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.
- package/README.md +18 -2
- package/cordis.patch.yml +4 -0
- package/lib/client.js +65 -0
- package/lib/host.d.ts +8 -0
- package/lib/host.js +38 -0
- package/lib/index.d.ts +72 -0
- package/lib/index.js +163 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +382 -0
- package/lib/typert.remote-client.d.ts +34 -0
- package/lib/typert.remote-client.d.ts.map +1 -0
- package/lib/typert.remote-client.js +266 -0
- package/lib/types.d.ts +41 -0
- package/lib/types.js +2 -0
- package/package.json +79 -4
package/lib/host.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Host runtime for the generated authorization Remote. */
|
|
2
|
+
/**
|
|
3
|
+
* Provide the service object under the generated service key. The Typert
|
|
4
|
+
* gateway already owns the generated strict invocation descriptors, so the
|
|
5
|
+
* runtime only has to expose the methods the descriptors name.
|
|
6
|
+
* @param ctx - owning Host Context.
|
|
7
|
+
*/
|
|
8
|
+
export declare function apply(ctx: any): void;
|
package/lib/host.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Host runtime for the generated authorization Remote. */
|
|
2
|
+
/**
|
|
3
|
+
* Provide the service object under the generated service key. The Typert
|
|
4
|
+
* gateway already owns the generated strict invocation descriptors, so the
|
|
5
|
+
* runtime only has to expose the methods the descriptors name.
|
|
6
|
+
* @param ctx - owning Host Context.
|
|
7
|
+
*/
|
|
8
|
+
export function apply(ctx) {
|
|
9
|
+
const assertOwner = () => {
|
|
10
|
+
const principal = ctx.invocation?.peer?.principal;
|
|
11
|
+
if (principal !== undefined && principal.kind !== 'owner')
|
|
12
|
+
throw new Error('collaboration management is owner-only');
|
|
13
|
+
};
|
|
14
|
+
const admin = () => {
|
|
15
|
+
const face = ctx.get('collabAdmin');
|
|
16
|
+
if (face === undefined)
|
|
17
|
+
throw new Error('collabAdmin is not available');
|
|
18
|
+
return face;
|
|
19
|
+
};
|
|
20
|
+
const service = {
|
|
21
|
+
list: () => { assertOwner(); return admin().listAuth(); },
|
|
22
|
+
authorize: (a, b) => { assertOwner(); return admin().authorize(a, b); },
|
|
23
|
+
revoke: (a, b) => { assertOwner(); return admin().revoke(a, b); },
|
|
24
|
+
panel: (sessionId, operation, argsJson) => {
|
|
25
|
+
assertOwner();
|
|
26
|
+
let args = {};
|
|
27
|
+
if (argsJson.trim().length > 0) {
|
|
28
|
+
const parsed = JSON.parse(argsJson);
|
|
29
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
30
|
+
throw new Error('panel args must be a JSON object');
|
|
31
|
+
args = parsed;
|
|
32
|
+
}
|
|
33
|
+
return JSON.stringify(admin().panel(sessionId, operation, args));
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
service.typertRemote = { service, serviceKey: 'collabAuth', namespace: 'collabAuth' };
|
|
37
|
+
ctx.provide('collabAuth', service);
|
|
38
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host authorization Remote: the human-facing pair list and the two
|
|
3
|
+
* user-only mutations. Transport is generated Typert Remote, so the UI never
|
|
4
|
+
* needs a control Session or a slash command.
|
|
5
|
+
*/
|
|
6
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
import type { AuthSnapshot, CollabAdminFace } from './types.js';
|
|
9
|
+
export type * from './types.js';
|
|
10
|
+
/** Host service backing the generated `ctx.remote.collabAuth` namespace. */
|
|
11
|
+
export declare class CollabAuthService extends TypertRemoteService {
|
|
12
|
+
/** Required Host services: the collaborator admin face and Typert registration. */
|
|
13
|
+
static inject: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Bind the service to the generated namespace.
|
|
16
|
+
* @param ctx - owning Host Context.
|
|
17
|
+
*/
|
|
18
|
+
constructor(ctx: Context);
|
|
19
|
+
/**
|
|
20
|
+
* Preserve the management surface's owner-only policy. The generated
|
|
21
|
+
* resource readers still describe the sessions each call touches; a future
|
|
22
|
+
* non-owner grant cannot bypass this check accidentally.
|
|
23
|
+
*/
|
|
24
|
+
private assertOwner;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the collaborator admin face at call time so a later Host reload
|
|
27
|
+
* can replace it without re-mounting this Remote service.
|
|
28
|
+
* @returns the live admin face.
|
|
29
|
+
*/
|
|
30
|
+
private admin;
|
|
31
|
+
/**
|
|
32
|
+
* Read entirely authorized pairs and one-sided pending grants.
|
|
33
|
+
* @returns the current authorization snapshot.
|
|
34
|
+
*/
|
|
35
|
+
list(): AuthSnapshot;
|
|
36
|
+
/**
|
|
37
|
+
* Authorize both directions of a pair.
|
|
38
|
+
* @param a - first Session id.
|
|
39
|
+
* @param b - second Session id.
|
|
40
|
+
* @returns the resulting authorization snapshot.
|
|
41
|
+
*/
|
|
42
|
+
authorize(a: string, b: string): AuthSnapshot;
|
|
43
|
+
/**
|
|
44
|
+
* Revoke both directions of a pair.
|
|
45
|
+
* @param a - first Session id.
|
|
46
|
+
* @param b - second Session id.
|
|
47
|
+
* @returns the resulting authorization snapshot.
|
|
48
|
+
*/
|
|
49
|
+
revoke(a: string, b: string): AuthSnapshot;
|
|
50
|
+
/**
|
|
51
|
+
* Read or mutate the supervisor board/base-prompt surface without writing a
|
|
52
|
+
* slash-command lifecycle into the conversation.
|
|
53
|
+
* @param sessionId - collaboration Session id.
|
|
54
|
+
* @param operation - board, baseGet, baseSet, link, unlink, pin, or live.
|
|
55
|
+
* @param args - operation-specific payload.
|
|
56
|
+
* @returns the operation result.
|
|
57
|
+
*/
|
|
58
|
+
panel(sessionId: string, operation: string, argsJson: string): string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Mount the generated Host service.
|
|
62
|
+
* @param ctx - owning Host Context.
|
|
63
|
+
*/
|
|
64
|
+
export declare function apply(ctx: Context): void;
|
|
65
|
+
declare module '@deepseek-ai/cordis' {
|
|
66
|
+
interface Context {
|
|
67
|
+
/** Collaboration authorization service exposed by the collab plugin. */
|
|
68
|
+
collabAdmin: CollabAdminFace;
|
|
69
|
+
/** Generated Remote service backing the authorization page. */
|
|
70
|
+
collabAuth: CollabAuthService;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host authorization Remote: the human-facing pair list and the two
|
|
3
|
+
* user-only mutations. Transport is generated Typert Remote, so the UI never
|
|
4
|
+
* needs a control Session or a slash command.
|
|
5
|
+
*/
|
|
6
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
7
|
+
var useValue = arguments.length > 2;
|
|
8
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
9
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
10
|
+
}
|
|
11
|
+
return useValue ? value : void 0;
|
|
12
|
+
};
|
|
13
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
14
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
15
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
16
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
17
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
18
|
+
var _, done = false;
|
|
19
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
20
|
+
var context = {};
|
|
21
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
22
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
23
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
24
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
25
|
+
if (kind === "accessor") {
|
|
26
|
+
if (result === void 0) continue;
|
|
27
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
28
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
29
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
30
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
31
|
+
}
|
|
32
|
+
else if (_ = accept(result)) {
|
|
33
|
+
if (kind === "field") initializers.unshift(_);
|
|
34
|
+
else descriptor[key] = _;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
38
|
+
done = true;
|
|
39
|
+
};
|
|
40
|
+
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
41
|
+
/** Diagnostic marker for the first Host mount. */
|
|
42
|
+
/** Session ids minted by DSH. */
|
|
43
|
+
const SESSION_ID = /^session-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
44
|
+
/** Reject ids that could not name a Session before touching the stores. */
|
|
45
|
+
function sessionId(value, parameter) {
|
|
46
|
+
if (!SESSION_ID.test(value))
|
|
47
|
+
throw new Error(`Invalid ${parameter}: ${value}`);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
/** Host service backing the generated `ctx.remote.collabAuth` namespace. */
|
|
51
|
+
let CollabAuthService = (() => {
|
|
52
|
+
let _classSuper = TypertRemoteService;
|
|
53
|
+
let _instanceExtraInitializers = [];
|
|
54
|
+
let _list_decorators;
|
|
55
|
+
let _authorize_decorators;
|
|
56
|
+
let _revoke_decorators;
|
|
57
|
+
let _panel_decorators;
|
|
58
|
+
return class CollabAuthService extends _classSuper {
|
|
59
|
+
static {
|
|
60
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
61
|
+
_list_decorators = [Remote('list')];
|
|
62
|
+
_authorize_decorators = [Remote({ name: 'authorize', resources: { session: (a, b) => [a, b] } })];
|
|
63
|
+
_revoke_decorators = [Remote({ name: 'revoke', resources: { session: (a, b) => [a, b] } })];
|
|
64
|
+
_panel_decorators = [Remote({ name: 'panel', resources: { session: (sessionId) => sessionId } })];
|
|
65
|
+
__esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
66
|
+
__esDecorate(this, null, _authorize_decorators, { kind: "method", name: "authorize", static: false, private: false, access: { has: obj => "authorize" in obj, get: obj => obj.authorize }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
67
|
+
__esDecorate(this, null, _revoke_decorators, { kind: "method", name: "revoke", static: false, private: false, access: { has: obj => "revoke" in obj, get: obj => obj.revoke }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
68
|
+
__esDecorate(this, null, _panel_decorators, { kind: "method", name: "panel", static: false, private: false, access: { has: obj => "panel" in obj, get: obj => obj.panel }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
69
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
70
|
+
}
|
|
71
|
+
/** Required Host services: the collaborator admin face and Typert registration. */
|
|
72
|
+
static inject = ['typert'];
|
|
73
|
+
/**
|
|
74
|
+
* Bind the service to the generated namespace.
|
|
75
|
+
* @param ctx - owning Host Context.
|
|
76
|
+
*/
|
|
77
|
+
constructor(ctx) {
|
|
78
|
+
super(ctx, 'collabAuth', { namespace: 'collabAuth' });
|
|
79
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Preserve the management surface's owner-only policy. The generated
|
|
83
|
+
* resource readers still describe the sessions each call touches; a future
|
|
84
|
+
* non-owner grant cannot bypass this check accidentally.
|
|
85
|
+
*/
|
|
86
|
+
assertOwner() {
|
|
87
|
+
const invocation = this.ctx.invocation;
|
|
88
|
+
const principal = invocation?.peer?.principal;
|
|
89
|
+
if (principal !== undefined && principal.kind !== 'owner') {
|
|
90
|
+
throw new Error('collaboration management is owner-only');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolve the collaborator admin face at call time so a later Host reload
|
|
95
|
+
* can replace it without re-mounting this Remote service.
|
|
96
|
+
* @returns the live admin face.
|
|
97
|
+
*/
|
|
98
|
+
admin() {
|
|
99
|
+
const admin = this.ctx.get('collabAdmin');
|
|
100
|
+
if (admin === undefined)
|
|
101
|
+
throw new Error('collabAdmin is not available');
|
|
102
|
+
return admin;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read entirely authorized pairs and one-sided pending grants.
|
|
106
|
+
* @returns the current authorization snapshot.
|
|
107
|
+
*/
|
|
108
|
+
list() {
|
|
109
|
+
this.assertOwner();
|
|
110
|
+
return this.admin().listAuth();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Authorize both directions of a pair.
|
|
114
|
+
* @param a - first Session id.
|
|
115
|
+
* @param b - second Session id.
|
|
116
|
+
* @returns the resulting authorization snapshot.
|
|
117
|
+
*/
|
|
118
|
+
authorize(a, b) {
|
|
119
|
+
this.assertOwner();
|
|
120
|
+
return this.admin().authorize(sessionId(a, 'a'), sessionId(b, 'b'));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Revoke both directions of a pair.
|
|
124
|
+
* @param a - first Session id.
|
|
125
|
+
* @param b - second Session id.
|
|
126
|
+
* @returns the resulting authorization snapshot.
|
|
127
|
+
*/
|
|
128
|
+
revoke(a, b) {
|
|
129
|
+
this.assertOwner();
|
|
130
|
+
return this.admin().revoke(sessionId(a, 'a'), sessionId(b, 'b'));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Read or mutate the supervisor board/base-prompt surface without writing a
|
|
134
|
+
* slash-command lifecycle into the conversation.
|
|
135
|
+
* @param sessionId - collaboration Session id.
|
|
136
|
+
* @param operation - board, baseGet, baseSet, link, unlink, pin, or live.
|
|
137
|
+
* @param args - operation-specific payload.
|
|
138
|
+
* @returns the operation result.
|
|
139
|
+
*/
|
|
140
|
+
panel(sessionId, operation, argsJson) {
|
|
141
|
+
this.assertOwner();
|
|
142
|
+
const checkedSessionId = sessionId === undefined ? '' : sessionId;
|
|
143
|
+
if (!SESSION_ID.test(checkedSessionId))
|
|
144
|
+
throw new Error(`Invalid sessionId: ${checkedSessionId}`);
|
|
145
|
+
let args = {};
|
|
146
|
+
if (argsJson.trim().length > 0) {
|
|
147
|
+
const parsed = JSON.parse(argsJson);
|
|
148
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
149
|
+
throw new Error('panel args must be a JSON object');
|
|
150
|
+
args = parsed;
|
|
151
|
+
}
|
|
152
|
+
return JSON.stringify(this.admin().panel(checkedSessionId, operation, args));
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
})();
|
|
156
|
+
export { CollabAuthService };
|
|
157
|
+
/**
|
|
158
|
+
* Mount the generated Host service.
|
|
159
|
+
* @param ctx - owning Host Context.
|
|
160
|
+
*/
|
|
161
|
+
export function apply(ctx) {
|
|
162
|
+
ctx.plugin(CollabAuthService);
|
|
163
|
+
}
|