@juspay/neurolink 11.29.2 → 11.30.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/CHANGELOG.md +3 -3
- package/dist/auth/anthropicOAuth.d.ts +50 -0
- package/dist/auth/anthropicOAuth.js +78 -0
- package/dist/browser/neurolink.min.js +393 -393
- package/dist/cli/commands/proxy.d.ts +2 -0
- package/dist/cli/commands/proxy.js +284 -4
- package/dist/cli/commands/proxyExpose.d.ts +35 -0
- package/dist/cli/commands/proxyExpose.js +252 -0
- package/dist/cli/commands/proxyPeer.d.ts +29 -0
- package/dist/cli/commands/proxyPeer.js +738 -0
- package/dist/cli/commands/proxyShare.d.ts +37 -0
- package/dist/cli/commands/proxyShare.js +1080 -0
- package/dist/cli/parser.js +7 -1
- package/dist/proxy/peerStore.d.ts +52 -0
- package/dist/proxy/peerStore.js +324 -0
- package/dist/proxy/peerTransport.d.ts +38 -0
- package/dist/proxy/peerTransport.js +242 -0
- package/dist/proxy/proxyPaths.d.ts +8 -0
- package/dist/proxy/proxyPaths.js +55 -17
- package/dist/proxy/requestLogger.js +8 -0
- package/dist/proxy/residentGrants.d.ts +57 -0
- package/dist/proxy/residentGrants.js +393 -0
- package/dist/proxy/shareAudit.d.ts +81 -0
- package/dist/proxy/shareAudit.js +280 -0
- package/dist/proxy/shareContext.d.ts +38 -0
- package/dist/proxy/shareContext.js +92 -0
- package/dist/proxy/shareGate.d.ts +64 -0
- package/dist/proxy/shareGate.js +216 -0
- package/dist/proxy/shareGrants.d.ts +115 -0
- package/dist/proxy/shareGrants.js +590 -0
- package/dist/proxy/shareLease.d.ts +101 -0
- package/dist/proxy/shareLease.js +192 -0
- package/dist/proxy/shareLedger.d.ts +105 -0
- package/dist/proxy/shareLedger.js +406 -0
- package/dist/proxy/shareListener.d.ts +60 -0
- package/dist/proxy/shareListener.js +143 -0
- package/dist/proxy/shareNotes.d.ts +97 -0
- package/dist/proxy/shareNotes.js +234 -0
- package/dist/proxy/sharePolicy.d.ts +110 -0
- package/dist/proxy/sharePolicy.js +366 -0
- package/dist/proxy/shareProvisioning.d.ts +110 -0
- package/dist/proxy/shareProvisioning.js +237 -0
- package/dist/proxy/shareReceipts.d.ts +99 -0
- package/dist/proxy/shareReceipts.js +303 -0
- package/dist/proxy/shareSigning.d.ts +40 -0
- package/dist/proxy/shareSigning.js +78 -0
- package/dist/server/routes/claudeProxyRoutes.js +1066 -3
- package/dist/types/cli.d.ts +61 -0
- package/dist/types/proxy.d.ts +781 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
## [11.
|
|
1
|
+
## [11.30.0](https://github.com/juspay/neurolink/compare/v11.29.2...v11.30.0) (2026-08-25)
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### Features
|
|
4
4
|
|
|
5
|
-
- **(
|
|
5
|
+
- **(proxy):** peer capacity sharing with lender-controlled grants ([d0eab07](https://github.com/juspay/neurolink/commit/d0eab07556fb2a73180c86a23acc9a1b6aecea70))
|
|
6
6
|
|
|
7
7
|
## [11.2.3](https://github.com/juspay/neurolink/compare/v11.2.2...v11.2.3) (2026-08-19)
|
|
8
8
|
|
|
@@ -349,6 +349,56 @@ export declare function stopCallbackServer(server: Server): Promise<void>;
|
|
|
349
349
|
* const authUrl = oauth.generateAuthUrl({ codeChallenge });
|
|
350
350
|
* ```
|
|
351
351
|
*/
|
|
352
|
+
/**
|
|
353
|
+
* The scopes a Claude Pro/Max subscription login asks for.
|
|
354
|
+
*
|
|
355
|
+
* Narrower than {@link DEFAULT_SCOPES}: the subscription flow does not create
|
|
356
|
+
* API keys, so `org:create_api_key` would be asking for a permission nothing
|
|
357
|
+
* downstream uses.
|
|
358
|
+
*/
|
|
359
|
+
export declare const SUBSCRIPTION_SCOPES = "user:profile user:inference";
|
|
360
|
+
/**
|
|
361
|
+
* Build the Claude Pro/Max authorization URL for a caller-supplied challenge.
|
|
362
|
+
*
|
|
363
|
+
* Extracted so the subscription login and split-PKCE provisioning cannot drift
|
|
364
|
+
* apart: they must produce byte-identical URLs but for the challenge and state,
|
|
365
|
+
* and a second hand-rolled copy is how one of them ends up missing `code=true`
|
|
366
|
+
* and silently redirecting instead of showing a code.
|
|
367
|
+
*
|
|
368
|
+
* **`state` is not the verifier here.** The interactive login sets `state` to
|
|
369
|
+
* the verifier as a convenience, which is safe when one machine holds both. In
|
|
370
|
+
* split provisioning it would hand the verifier to the party that must not have
|
|
371
|
+
* it, so the caller supplies an unrelated random state and keeps its verifier.
|
|
372
|
+
*/
|
|
373
|
+
export declare function buildSubscriptionAuthUrl(params: {
|
|
374
|
+
codeChallenge: string;
|
|
375
|
+
state: string;
|
|
376
|
+
clientId?: string;
|
|
377
|
+
redirectUri?: string;
|
|
378
|
+
scope?: string;
|
|
379
|
+
}): string;
|
|
380
|
+
/**
|
|
381
|
+
* Exchange an authorization code for subscription tokens.
|
|
382
|
+
*
|
|
383
|
+
* The token endpoint wants a JSON body, not form encoding, and it wants the
|
|
384
|
+
* verifier that produced the challenge in the authorization URL. In split
|
|
385
|
+
* provisioning that verifier lives only on the borrower's machine, which is the
|
|
386
|
+
* entire point: the code alone buys nothing.
|
|
387
|
+
*/
|
|
388
|
+
export declare function exchangeSubscriptionCode(params: {
|
|
389
|
+
code: string;
|
|
390
|
+
state: string;
|
|
391
|
+
codeVerifier: string;
|
|
392
|
+
clientId?: string;
|
|
393
|
+
redirectUri?: string;
|
|
394
|
+
}): Promise<{
|
|
395
|
+
accessToken: string;
|
|
396
|
+
refreshToken?: string;
|
|
397
|
+
expiresAt?: number;
|
|
398
|
+
tokenType: string;
|
|
399
|
+
scope?: string;
|
|
400
|
+
accountEmail?: string;
|
|
401
|
+
}>;
|
|
352
402
|
export declare function createAnthropicOAuth(overrides?: Partial<AnthropicOAuthConfig>): AnthropicOAuth;
|
|
353
403
|
/**
|
|
354
404
|
* Anthropic OAuth configuration creator for providerConfig pattern
|
|
@@ -1046,6 +1046,84 @@ export async function stopCallbackServer(server) {
|
|
|
1046
1046
|
* const authUrl = oauth.generateAuthUrl({ codeChallenge });
|
|
1047
1047
|
* ```
|
|
1048
1048
|
*/
|
|
1049
|
+
/**
|
|
1050
|
+
* The scopes a Claude Pro/Max subscription login asks for.
|
|
1051
|
+
*
|
|
1052
|
+
* Narrower than {@link DEFAULT_SCOPES}: the subscription flow does not create
|
|
1053
|
+
* API keys, so `org:create_api_key` would be asking for a permission nothing
|
|
1054
|
+
* downstream uses.
|
|
1055
|
+
*/
|
|
1056
|
+
export const SUBSCRIPTION_SCOPES = "user:profile user:inference";
|
|
1057
|
+
/**
|
|
1058
|
+
* Build the Claude Pro/Max authorization URL for a caller-supplied challenge.
|
|
1059
|
+
*
|
|
1060
|
+
* Extracted so the subscription login and split-PKCE provisioning cannot drift
|
|
1061
|
+
* apart: they must produce byte-identical URLs but for the challenge and state,
|
|
1062
|
+
* and a second hand-rolled copy is how one of them ends up missing `code=true`
|
|
1063
|
+
* and silently redirecting instead of showing a code.
|
|
1064
|
+
*
|
|
1065
|
+
* **`state` is not the verifier here.** The interactive login sets `state` to
|
|
1066
|
+
* the verifier as a convenience, which is safe when one machine holds both. In
|
|
1067
|
+
* split provisioning it would hand the verifier to the party that must not have
|
|
1068
|
+
* it, so the caller supplies an unrelated random state and keeps its verifier.
|
|
1069
|
+
*/
|
|
1070
|
+
export function buildSubscriptionAuthUrl(params) {
|
|
1071
|
+
const url = new URL(ANTHROPIC_AUTH_URL);
|
|
1072
|
+
url.searchParams.set("code", "true");
|
|
1073
|
+
url.searchParams.set("client_id", params.clientId ?? CLAUDE_CODE_CLIENT_ID);
|
|
1074
|
+
url.searchParams.set("response_type", "code");
|
|
1075
|
+
url.searchParams.set("redirect_uri", params.redirectUri ?? ANTHROPIC_REDIRECT_URI);
|
|
1076
|
+
url.searchParams.set("scope", params.scope ?? SUBSCRIPTION_SCOPES);
|
|
1077
|
+
url.searchParams.set("code_challenge", params.codeChallenge);
|
|
1078
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
1079
|
+
url.searchParams.set("state", params.state);
|
|
1080
|
+
return url.toString();
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Exchange an authorization code for subscription tokens.
|
|
1084
|
+
*
|
|
1085
|
+
* The token endpoint wants a JSON body, not form encoding, and it wants the
|
|
1086
|
+
* verifier that produced the challenge in the authorization URL. In split
|
|
1087
|
+
* provisioning that verifier lives only on the borrower's machine, which is the
|
|
1088
|
+
* entire point: the code alone buys nothing.
|
|
1089
|
+
*/
|
|
1090
|
+
export async function exchangeSubscriptionCode(params) {
|
|
1091
|
+
const response = await fetch(ANTHROPIC_TOKEN_URL, {
|
|
1092
|
+
method: "POST",
|
|
1093
|
+
headers: { "Content-Type": "application/json" },
|
|
1094
|
+
body: JSON.stringify({
|
|
1095
|
+
code: params.code,
|
|
1096
|
+
state: params.state,
|
|
1097
|
+
grant_type: "authorization_code",
|
|
1098
|
+
client_id: params.clientId ?? CLAUDE_CODE_CLIENT_ID,
|
|
1099
|
+
redirect_uri: params.redirectUri ?? ANTHROPIC_REDIRECT_URI,
|
|
1100
|
+
code_verifier: params.codeVerifier,
|
|
1101
|
+
}),
|
|
1102
|
+
});
|
|
1103
|
+
if (!response.ok) {
|
|
1104
|
+
const detail = await response.text().catch(() => "");
|
|
1105
|
+
throw new OAuthError(`Token exchange failed: ${response.status} ${detail.slice(0, 300)}`, "TOKEN_EXCHANGE_FAILED");
|
|
1106
|
+
}
|
|
1107
|
+
const data = (await response.json());
|
|
1108
|
+
// A 200 with no token is not a success. Returning `undefined` here would be
|
|
1109
|
+
// written to the token store as a credential and only fail on first use, by
|
|
1110
|
+
// which point the authorization code that could have fixed it is spent.
|
|
1111
|
+
if (typeof data.access_token !== "string" || data.access_token === "") {
|
|
1112
|
+
throw new OAuthError("Token exchange returned no access token.", "TOKEN_EXCHANGE_FAILED");
|
|
1113
|
+
}
|
|
1114
|
+
return {
|
|
1115
|
+
accessToken: data.access_token,
|
|
1116
|
+
...(data.refresh_token ? { refreshToken: data.refresh_token } : {}),
|
|
1117
|
+
...(data.expires_in
|
|
1118
|
+
? { expiresAt: Date.now() + data.expires_in * 1000 }
|
|
1119
|
+
: {}),
|
|
1120
|
+
tokenType: data.token_type || "Bearer",
|
|
1121
|
+
...(data.scope ? { scope: data.scope } : {}),
|
|
1122
|
+
...(data.account?.email_address
|
|
1123
|
+
? { accountEmail: data.account.email_address }
|
|
1124
|
+
: {}),
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1049
1127
|
export function createAnthropicOAuth(overrides = {}) {
|
|
1050
1128
|
return new AnthropicOAuth(overrides);
|
|
1051
1129
|
}
|