@cortexkit/pi-anthropic-auth 2.1.0 → 2.1.2
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/native.d.ts +8 -1
- package/dist/native.js +19 -1
- package/dist/stream.js +7 -1
- package/package.json +2 -2
package/dist/native.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type NativeAccountRuntime, type NativeAccountSnapshot, type NativeCustodyClient, type NativeCustodyReceipt, type NativeCustodyReporterSource, type NativeRefreshResult } from '@cortexkit/anthropic-auth-core';
|
|
1
|
+
import { type NativeAccountRuntime, type NativeAccountRuntimeOptions, type NativeAccountSnapshot, type NativeCustodyClient, type NativeCustodyReceipt, type NativeCustodyReporterSource, type NativeRefreshResult } from '@cortexkit/anthropic-auth-core';
|
|
2
2
|
export type PiNativeAttempt = {
|
|
3
3
|
source: 'local';
|
|
4
4
|
accountIdentity: string;
|
|
@@ -38,8 +38,14 @@ export declare class PiNativeRuntime {
|
|
|
38
38
|
publish(write: () => Promise<unknown>): void;
|
|
39
39
|
drain(): Promise<void>;
|
|
40
40
|
};
|
|
41
|
+
private readonly routingPublications;
|
|
42
|
+
ownRoutingPublications(router: {
|
|
43
|
+
drain(): Promise<void>;
|
|
44
|
+
}): void;
|
|
45
|
+
drainRoutingPublications(): Promise<void>;
|
|
41
46
|
constructor(storagePath: string, options?: {
|
|
42
47
|
connect?: () => Promise<NativeCustodyClient>;
|
|
48
|
+
local?: NativeAccountRuntimeOptions['local'];
|
|
43
49
|
vaultPoll?: PiVaultPollOptions;
|
|
44
50
|
});
|
|
45
51
|
service(): Promise<NativeAccountRuntime>;
|
|
@@ -68,6 +74,7 @@ export declare class PiNativeRuntime {
|
|
|
68
74
|
}
|
|
69
75
|
export declare function getPiNativeRuntime(storagePath?: string, options?: {
|
|
70
76
|
connect?: () => Promise<NativeCustodyClient>;
|
|
77
|
+
local?: NativeAccountRuntimeOptions['local'];
|
|
71
78
|
vaultPoll?: PiVaultPollOptions;
|
|
72
79
|
}): PiNativeRuntime;
|
|
73
80
|
export declare function closePiNativeRuntime(storagePath?: string): Promise<void>;
|
package/dist/native.js
CHANGED
|
@@ -66,6 +66,16 @@ export class PiNativeRuntime {
|
|
|
66
66
|
closed = false;
|
|
67
67
|
closing;
|
|
68
68
|
usagePublications = createNativeUsagePublisher('native-auth');
|
|
69
|
+
routingPublications = new Set();
|
|
70
|
+
ownRoutingPublications(router) {
|
|
71
|
+
this.routingPublications.add(router);
|
|
72
|
+
}
|
|
73
|
+
async drainRoutingPublications() {
|
|
74
|
+
await Promise.all([
|
|
75
|
+
...[...this.routingPublications].map((router) => router.drain()),
|
|
76
|
+
this.initialization.then((runtime) => runtime.drainRoutingPublications(), () => { }),
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
69
79
|
constructor(storagePath, options = {}) {
|
|
70
80
|
const env = { ...process.env };
|
|
71
81
|
this.env = env;
|
|
@@ -76,6 +86,7 @@ export class PiNativeRuntime {
|
|
|
76
86
|
const runtime = acquireNativeAccountRuntime({
|
|
77
87
|
paths,
|
|
78
88
|
host: 'pi',
|
|
89
|
+
local: options.local,
|
|
79
90
|
vault: {
|
|
80
91
|
// Core checks Pi enrollment and reads a fresh scoped receipt on every send.
|
|
81
92
|
// Keep the injected connector's identity rather than wrapping it per instance.
|
|
@@ -269,8 +280,11 @@ export class PiNativeRuntime {
|
|
|
269
280
|
this.vaultWatch?.close();
|
|
270
281
|
this.closing ??= (async () => {
|
|
271
282
|
await this.usagePublications.drain();
|
|
283
|
+
await this.drainRoutingPublications();
|
|
284
|
+
this.routingPublications.clear();
|
|
272
285
|
await this.initialization.then(async (runtime) => {
|
|
273
286
|
await runtime.drainQuotaPublications();
|
|
287
|
+
await runtime.drainRoutingPublications();
|
|
274
288
|
runtime.close();
|
|
275
289
|
}, () => { });
|
|
276
290
|
})();
|
|
@@ -282,11 +296,15 @@ export function getPiNativeRuntime(storagePath = getPiAccountStoragePath(), opti
|
|
|
282
296
|
const key = JSON.stringify([
|
|
283
297
|
contextKey,
|
|
284
298
|
nativeRuntimeOptionIdentity(options.connect),
|
|
299
|
+
nativeRuntimeOptionIdentity(options.local?.onLockEvent),
|
|
300
|
+
nativeRuntimeOptionIdentity(options.local?.refreshToken),
|
|
301
|
+
nativeRuntimeOptionIdentity(options.local?.resolveIdentity),
|
|
302
|
+
nativeRuntimeOptionIdentity(options.local?.now),
|
|
285
303
|
]);
|
|
286
304
|
const existing = runtimes.get(key);
|
|
287
305
|
if (existing)
|
|
288
306
|
return existing.runtime;
|
|
289
|
-
if (!options.connect) {
|
|
307
|
+
if (!options.connect && !options.local) {
|
|
290
308
|
// A supplied connector installs the context's test transport. Ordinary host
|
|
291
309
|
// lookups reuse it, but an explicitly different connector owns another key.
|
|
292
310
|
const configured = [...runtimes.values()].find((entry) => entry.contextKey === contextKey);
|
package/dist/stream.js
CHANGED
|
@@ -109,10 +109,16 @@ async function getPiStickyRouter(storagePath) {
|
|
|
109
109
|
const { path, vaultSeed } = await getPiNativeRuntime(storagePath).routingStorage();
|
|
110
110
|
let router = stickyRouters.get(path);
|
|
111
111
|
if (!router) {
|
|
112
|
-
|
|
112
|
+
const runtime = await getPiNativeRuntime(storagePath).service();
|
|
113
|
+
router = new StickySessionRouter({
|
|
114
|
+
path,
|
|
115
|
+
vaultSeed,
|
|
116
|
+
onLockEvent: runtime.onLockEvent,
|
|
117
|
+
});
|
|
113
118
|
setBoundedService(stickyRouters, path, router);
|
|
114
119
|
}
|
|
115
120
|
router.setVaultSeed(vaultSeed);
|
|
121
|
+
getPiNativeRuntime(storagePath).ownRoutingPublications(router);
|
|
116
122
|
return router;
|
|
117
123
|
}
|
|
118
124
|
export async function clearPiStickyRoutingSession(storagePath, sessionId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-anthropic-auth",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"prepublishOnly": "bun run build"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@cortexkit/anthropic-auth-core": "2.1.
|
|
39
|
+
"@cortexkit/anthropic-auth-core": "2.1.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": ">=0.86.1 <2",
|