opencode-m365-copilot 0.3.4 → 0.4.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/README.md +19 -4
- package/dist/{agent-Cd7BGDdu.mjs → agent-CtiM1nN_.mjs} +2 -3
- package/dist/cli.mjs +4 -5
- package/dist/{dist-CMVPFMhc.mjs → dist-Dp9sO-mB.mjs} +402 -511
- package/dist/{login-DTenVKcz.mjs → login-CWvKVY0k.mjs} +4 -5
- package/dist/{otpauth.node-CBOz_1IZ.mjs → otpauth.node-DaSYf7YH.mjs} +21 -13
- package/dist/plugin.d.mts +0 -4
- package/dist/plugin.mjs +5 -8
- package/dist/{server-DQW-8ns2.mjs → server-Cow8-T6p.mjs} +289 -147
- package/dist/server.d.mts +1 -5
- package/dist/server.mjs +1 -2
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as SECRETS_FILE, S as CONFIG_DIR, _ as createLogger, c as AUTHORITY, f as REDIRECT_URI, h as createCachePlugin, m as authCodeFromUrl, o as object, p as SYDNEY_SCOPES, s as string, u as CLIENT_ID, v as ensurePrivateDir } from "./server-
|
|
1
|
+
import { C as SECRETS_FILE, S as CONFIG_DIR, _ as createLogger, c as AUTHORITY, f as REDIRECT_URI, h as createCachePlugin, m as authCodeFromUrl, o as object, p as SYDNEY_SCOPES, s as string, u as CLIENT_ID, v as ensurePrivateDir } from "./server-Cow8-T6p.mjs";
|
|
2
2
|
import { chmodSync, existsSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/login.ts
|
|
5
5
|
/**
|
|
6
6
|
* Interactive / automated sign-in. Loaded only by the CLI, never by the plugin.
|
|
7
7
|
*
|
|
@@ -79,7 +79,7 @@ function normaliseTotpSecret(raw) {
|
|
|
79
79
|
}
|
|
80
80
|
/** Current 6-digit code for a base32 seed. */
|
|
81
81
|
async function totpCode(secret) {
|
|
82
|
-
const { TOTP, Secret } = await import("./otpauth.node-
|
|
82
|
+
const { TOTP, Secret } = await import("./otpauth.node-DaSYf7YH.mjs");
|
|
83
83
|
return new TOTP({
|
|
84
84
|
secret: Secret.fromBase32(normaliseTotpSecret(secret)),
|
|
85
85
|
digits: 6,
|
|
@@ -96,7 +96,7 @@ async function login(options = {}) {
|
|
|
96
96
|
const secrets = loadSecrets(options.secretsFile);
|
|
97
97
|
const interactive = options.interactive ?? !secrets?.mfaSecret;
|
|
98
98
|
if (!interactive && !secrets) throw new Error(`No credentials at ${options.secretsFile ?? SECRETS_FILE}. Create it with { "email", "password", "mfaSecret" }, or sign in interactively with --interactive.`);
|
|
99
|
-
const { PublicClientApplication, CryptoProvider } = await import("./dist-
|
|
99
|
+
const { PublicClientApplication, CryptoProvider } = await import("./dist-Dp9sO-mB.mjs");
|
|
100
100
|
const app = new PublicClientApplication({
|
|
101
101
|
auth: {
|
|
102
102
|
clientId: CLIENT_ID,
|
|
@@ -205,5 +205,4 @@ async function importPlaywright() {
|
|
|
205
205
|
throw new Error("Playwright is not installed. It is an optional peer dependency, deliberately not pulled in by the plugin itself — install it alongside this CLI with `npm i -g playwright && npx playwright install chromium`, or set CHROMIUM_PATH to an existing browser.");
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
//#endregion
|
|
209
208
|
export { login };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as crypto from "node:crypto";
|
|
2
|
-
|
|
3
|
-
//! otpauth 9.
|
|
2
|
+
// node_modules/otpauth/dist/otpauth.node.mjs
|
|
3
|
+
//! otpauth 9.6.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth
|
|
4
4
|
/**
|
|
5
5
|
* Converts an integer to an Uint8Array.
|
|
6
6
|
* @param {number} num Integer.
|
|
@@ -355,15 +355,16 @@ import * as crypto from "node:crypto";
|
|
|
355
355
|
/**
|
|
356
356
|
* Generates an HOTP token.
|
|
357
357
|
* @param {Object} config Configuration options.
|
|
358
|
-
* @param {Secret} config.secret Secret key.
|
|
358
|
+
* @param {Secret|string} config.secret Secret key.
|
|
359
359
|
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
360
360
|
* @param {number} [config.digits=6] Token length.
|
|
361
361
|
* @param {number} [config.counter=0] Counter value.
|
|
362
362
|
* @param {(algorithm: string, key: Uint8Array, message: Uint8Array) => Uint8Array} [config.hmac] Custom HMAC function.
|
|
363
363
|
* @returns {string} Token.
|
|
364
364
|
*/ static generate({ secret, algorithm = HOTP.defaults.algorithm, digits = HOTP.defaults.digits, counter = HOTP.defaults.counter, hmac = hmacDigest }) {
|
|
365
|
+
const key = typeof secret === "string" ? Secret.fromBase32(secret) : secret;
|
|
365
366
|
const message = uintDecode(counter);
|
|
366
|
-
const digest = hmac(algorithm,
|
|
367
|
+
const digest = hmac(algorithm, key.bytes, message);
|
|
367
368
|
if (!digest?.byteLength || digest.byteLength < 19) throw new TypeError("Return value must be at least 19 bytes");
|
|
368
369
|
const offset = digest[digest.byteLength - 1] & 15;
|
|
369
370
|
return (((digest[offset] & 127) << 24 | (digest[offset + 1] & 255) << 16 | (digest[offset + 2] & 255) << 8 | digest[offset + 3] & 255) % 10 ** digits).toString().padStart(digits, "0");
|
|
@@ -386,17 +387,19 @@ import * as crypto from "node:crypto";
|
|
|
386
387
|
* Validates an HOTP token.
|
|
387
388
|
* @param {Object} config Configuration options.
|
|
388
389
|
* @param {string} config.token Token value.
|
|
389
|
-
* @param {Secret} config.secret Secret key.
|
|
390
|
+
* @param {Secret|string} config.secret Secret key.
|
|
390
391
|
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
391
392
|
* @param {number} [config.digits=6] Token length.
|
|
392
393
|
* @param {number} [config.counter=0] Counter value.
|
|
393
394
|
* @param {number} [config.window=1] Window of counter values to test.
|
|
395
|
+
* @param {number|null} [config.afterCounter] Reject tokens with a counter less than or equal to this value.
|
|
394
396
|
* @param {(algorithm: string, key: Uint8Array, message: Uint8Array) => Uint8Array} [config.hmac] Custom HMAC function.
|
|
395
397
|
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
396
|
-
*/ static validate({ token, secret, algorithm, digits = HOTP.defaults.digits, counter = HOTP.defaults.counter, window = HOTP.defaults.window, hmac = hmacDigest }) {
|
|
397
|
-
if (token.length !== digits) return null;
|
|
398
|
+
*/ static validate({ token, secret, algorithm, digits = HOTP.defaults.digits, counter = HOTP.defaults.counter, window = HOTP.defaults.window, afterCounter, hmac = hmacDigest }) {
|
|
399
|
+
if (typeof token !== "string" || token.length !== digits || !/^\d+$/.test(token)) return null;
|
|
398
400
|
let delta = null;
|
|
399
401
|
const check = (i) => {
|
|
402
|
+
if (!(i > (afterCounter ?? -Infinity))) return;
|
|
400
403
|
const generatedToken = HOTP.generate({
|
|
401
404
|
secret,
|
|
402
405
|
algorithm,
|
|
@@ -421,8 +424,9 @@ import * as crypto from "node:crypto";
|
|
|
421
424
|
* @param {string} config.token Token value.
|
|
422
425
|
* @param {number} [config.counter=this.counter] Counter value.
|
|
423
426
|
* @param {number} [config.window=1] Window of counter values to test.
|
|
427
|
+
* @param {number|null} [config.afterCounter] Reject tokens with a counter less than or equal to this value.
|
|
424
428
|
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
425
|
-
*/ validate({ token, counter = this.counter, window }) {
|
|
429
|
+
*/ validate({ token, counter = this.counter, window, afterCounter }) {
|
|
426
430
|
return HOTP.validate({
|
|
427
431
|
token,
|
|
428
432
|
secret: this.secret,
|
|
@@ -430,6 +434,7 @@ import * as crypto from "node:crypto";
|
|
|
430
434
|
digits: this.digits,
|
|
431
435
|
counter,
|
|
432
436
|
window,
|
|
437
|
+
afterCounter,
|
|
433
438
|
hmac: this.hmac
|
|
434
439
|
});
|
|
435
440
|
}
|
|
@@ -555,7 +560,7 @@ import * as crypto from "node:crypto";
|
|
|
555
560
|
/**
|
|
556
561
|
* Generates a TOTP token.
|
|
557
562
|
* @param {Object} config Configuration options.
|
|
558
|
-
* @param {Secret} config.secret Secret key.
|
|
563
|
+
* @param {Secret|string} config.secret Secret key.
|
|
559
564
|
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
560
565
|
* @param {number} [config.digits=6] Token length.
|
|
561
566
|
* @param {number} [config.period=30] Token time-step duration.
|
|
@@ -593,15 +598,16 @@ import * as crypto from "node:crypto";
|
|
|
593
598
|
* Validates a TOTP token.
|
|
594
599
|
* @param {Object} config Configuration options.
|
|
595
600
|
* @param {string} config.token Token value.
|
|
596
|
-
* @param {Secret} config.secret Secret key.
|
|
601
|
+
* @param {Secret|string} config.secret Secret key.
|
|
597
602
|
* @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.
|
|
598
603
|
* @param {number} [config.digits=6] Token length.
|
|
599
604
|
* @param {number} [config.period=30] Token time-step duration.
|
|
600
605
|
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
601
606
|
* @param {number} [config.window=1] Window of counter values to test.
|
|
607
|
+
* @param {number|null} [config.afterCounter] Reject tokens with a counter less than or equal to this value.
|
|
602
608
|
* @param {(algorithm: string, key: Uint8Array, message: Uint8Array) => Uint8Array} [config.hmac] Custom HMAC function.
|
|
603
609
|
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
604
|
-
*/ static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window, hmac }) {
|
|
610
|
+
*/ static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window, afterCounter, hmac }) {
|
|
605
611
|
return HOTP.validate({
|
|
606
612
|
token,
|
|
607
613
|
secret,
|
|
@@ -612,6 +618,7 @@ import * as crypto from "node:crypto";
|
|
|
612
618
|
timestamp
|
|
613
619
|
}),
|
|
614
620
|
window,
|
|
621
|
+
afterCounter,
|
|
615
622
|
hmac
|
|
616
623
|
});
|
|
617
624
|
}
|
|
@@ -621,8 +628,9 @@ import * as crypto from "node:crypto";
|
|
|
621
628
|
* @param {string} config.token Token value.
|
|
622
629
|
* @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.
|
|
623
630
|
* @param {number} [config.window=1] Window of counter values to test.
|
|
631
|
+
* @param {number|null} [config.afterCounter] Reject tokens with a counter less than or equal to this value.
|
|
624
632
|
* @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.
|
|
625
|
-
*/ validate({ token, timestamp, window }) {
|
|
633
|
+
*/ validate({ token, timestamp, window, afterCounter }) {
|
|
626
634
|
return TOTP.validate({
|
|
627
635
|
token,
|
|
628
636
|
secret: this.secret,
|
|
@@ -631,6 +639,7 @@ import * as crypto from "node:crypto";
|
|
|
631
639
|
period: this.period,
|
|
632
640
|
timestamp,
|
|
633
641
|
window,
|
|
642
|
+
afterCounter,
|
|
634
643
|
hmac: this.hmac
|
|
635
644
|
});
|
|
636
645
|
}
|
|
@@ -687,5 +696,4 @@ import * as crypto from "node:crypto";
|
|
|
687
696
|
*/ this.hmac = hmac;
|
|
688
697
|
}
|
|
689
698
|
};
|
|
690
|
-
//#endregion
|
|
691
699
|
export { Secret, TOTP };
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { Plugin } from "@opencode/plugin";
|
|
2
2
|
import { Hooks, PluginInput } from "@opencode-ai/plugin";
|
|
3
|
-
//#region src/plugin-v1.d.ts
|
|
4
3
|
declare function server(input: PluginInput, rawOptions?: Record<string, unknown>): Promise<Hooks>;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/plugin.d.ts
|
|
7
4
|
declare const _default: {
|
|
8
5
|
id: string;
|
|
9
6
|
setup: (context: Plugin.Context) => Promise<Plugin.Cleanup | void> | Plugin.Cleanup | void;
|
|
10
7
|
server: typeof server;
|
|
11
8
|
};
|
|
12
|
-
//#endregion
|
|
13
9
|
export { _default as default };
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as resolveOptions, D as buildModelInfos, E as applyPluginConfig, N as isLocalModel, O as buildProviderInfo, T as PROVIDER_ID, _ as createLogger, a as startServer, g as createTokenClient, j as DEFAULT_MODEL, r as SESSION_ID_HEADER, t as AUX_REQUEST_KIND_HEADER, w as PLUGIN_ID } from "./server-
|
|
2
|
-
import { t as getOrCreateAgent } from "./agent-
|
|
3
|
-
|
|
1
|
+
import { A as resolveOptions, D as buildModelInfos, E as applyPluginConfig, N as isLocalModel, O as buildProviderInfo, T as PROVIDER_ID, _ as createLogger, a as startServer, g as createTokenClient, j as DEFAULT_MODEL, r as SESSION_ID_HEADER, t as AUX_REQUEST_KIND_HEADER, w as PLUGIN_ID } from "./server-Cow8-T6p.mjs";
|
|
2
|
+
import { t as getOrCreateAgent } from "./agent-CtiM1nN_.mjs";
|
|
3
|
+
// src/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* The part of the plugin that is the same under both opencode plugin APIs.
|
|
6
6
|
*
|
|
@@ -77,8 +77,7 @@ async function startRuntime(rawOptions) {
|
|
|
77
77
|
close: () => proxy.close()
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
//#region src/plugin-v1.ts
|
|
80
|
+
// src/plugin-v1.ts
|
|
82
81
|
async function server(input, rawOptions) {
|
|
83
82
|
const runtime = await startRuntime(rawOptions);
|
|
84
83
|
await input.client.app.log({ body: {
|
|
@@ -96,8 +95,7 @@ async function server(input, rawOptions) {
|
|
|
96
95
|
}
|
|
97
96
|
};
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
//#region src/plugin-v2.ts
|
|
98
|
+
// src/plugin-v2.ts
|
|
101
99
|
const log = createLogger("plugin");
|
|
102
100
|
const setup = async (ctx) => {
|
|
103
101
|
const runtime = await startRuntime(ctx.options);
|
|
@@ -132,5 +130,4 @@ var plugin_default = {
|
|
|
132
130
|
setup,
|
|
133
131
|
server
|
|
134
132
|
};
|
|
135
|
-
//#endregion
|
|
136
133
|
export { plugin_default as default };
|